78 lines · plain
1; RUN: opt < %s -passes=loop-interchange -cache-line-size=4 -pass-remarks-missed='loop-interchange' -pass-remarks-output=%t -S \2; RUN: -verify-dom-info -verify-loop-info -verify-loop-lcssa3; RUN: FileCheck --input-file=%t --check-prefix=REMARKS %s4 5@b = external global [512 x [4 x i32]]6@c = global [2 x [4 x i32]] zeroinitializer, align 17 8; Check that the outermost and the middle loops are not interchanged since9; the innermost loop has a reduction operation which is however not in a form10; that loop interchange can handle. Interchanging the outermost and the11; middle loops would intervene with the reduction and cause miscompile.12 13; REMARKS: --- !Missed14; REMARKS-NEXT: Pass: loop-interchange15; REMARKS-NEXT: Name: UnsupportedPHIInner16; REMARKS-NEXT: Function: test717; REMARKS: --- !Missed18; REMARKS-NEXT: Pass: loop-interchange19; REMARKS-NEXT: Name: UnsupportedPHIInner20; REMARKS-NEXT: Function: test721 22define i32 @test7() {23entry:24 br label %for.cond1.preheader.i25 26for.cond1.preheader.i: ; preds = %for.inc19.i, %entry27 %i.011.i = phi i16 [ 0, %entry ], [ %inc20.i, %for.inc19.i ]28 br label %for.cond4.preheader.i29 30for.cond4.preheader.i: ; preds = %middle.block, %for.cond1.preheader.i31 %j.010.i = phi i16 [ 0, %for.cond1.preheader.i ], [ %inc17.i, %middle.block ]32 %arrayidx14.i = getelementptr inbounds [2 x [4 x i32]], ptr @c, i16 0, i16 %i.011.i, i16 %j.010.i33 %arrayidx14.promoted.i = load i32, ptr %arrayidx14.i, align 134 %0 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %arrayidx14.promoted.i, i64 035 br label %vector.body36 37vector.body: ; preds = %vector.body, %for.cond4.preheader.i38 %index = phi i16 [ 0, %for.cond4.preheader.i ], [ %index.next, %vector.body ]39 %vec.phi = phi <4 x i32> [ %0, %for.cond4.preheader.i ], [ %16, %vector.body ]40 %1 = or i16 %index, 141 %2 = or i16 %index, 242 %3 = or i16 %index, 343 %4 = getelementptr inbounds [512 x [4 x i32]], ptr @b, i16 0, i16 %index, i16 %j.010.i44 %5 = getelementptr inbounds [512 x [4 x i32]], ptr @b, i16 0, i16 %1, i16 %j.010.i45 %6 = getelementptr inbounds [512 x [4 x i32]], ptr @b, i16 0, i16 %2, i16 %j.010.i46 %7 = getelementptr inbounds [512 x [4 x i32]], ptr @b, i16 0, i16 %3, i16 %j.010.i47 %8 = load i32, ptr %4, align 148 %9 = load i32, ptr %5, align 149 %10 = load i32, ptr %6, align 150 %11 = load i32, ptr %7, align 151 %12 = insertelement <4 x i32> poison, i32 %8, i64 052 %13 = insertelement <4 x i32> %12, i32 %9, i64 153 %14 = insertelement <4 x i32> %13, i32 %10, i64 254 %15 = insertelement <4 x i32> %14, i32 %11, i64 355 %16 = add <4 x i32> %15, %vec.phi56 %index.next = add nuw i16 %index, 457 %17 = icmp eq i16 %index.next, 51258 br i1 %17, label %middle.block, label %vector.body59 60middle.block: ; preds = %vector.body61 %18 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %16)62 store i32 %18, ptr %arrayidx14.i, align 163 %inc17.i = add nuw nsw i16 %j.010.i, 164 %exitcond12.not.i = icmp eq i16 %inc17.i, 465 br i1 %exitcond12.not.i, label %for.inc19.i, label %for.cond4.preheader.i66 67for.inc19.i: ; preds = %middle.block68 %inc20.i = add nuw nsw i16 %i.011.i, 169 %exitcond13.not.i = icmp eq i16 %inc20.i, 270 br i1 %exitcond13.not.i, label %test.exit, label %for.cond1.preheader.i71 72test.exit: ; preds = %for.inc19.i73 %19 = load i32, ptr @c, align 174 ret i32 %1975}76 77declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>)78