1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN:opt -loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s | FileCheck %s 3 4; For %for.1, we are fine initially, because the previous value %for.1.next dominates the 5; user of %for.1. But for %for.2, we have to sink the user (%for.1.next) past the previous 6; value %for.2.next. This however breaks the condition we have for %for.1. We cannot fix 7; both first order recurrences and cannot vectorize the loop. 8define i32 @c(i32 %N) { 9; CHECK-LABEL: @c( 10; CHECK-NEXT: entry: 11; CHECK-NEXT: br label [[FOR_BODY:%.*]] 12; CHECK: for.body: 13; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 10, [[ENTRY:%.*]] ] 14; CHECK-NEXT: [[FOR_1:%.*]] = phi i32 [ [[FOR_1_NEXT:%.*]], [[FOR_BODY]] ], [ 20, [[ENTRY]] ] 15; CHECK-NEXT: [[FOR_2:%.*]] = phi i32 [ [[FOR_2_NEXT:%.*]], [[FOR_BODY]] ], [ 11, [[ENTRY]] ] 16; CHECK-NEXT: [[FOR_1_NEXT]] = add nsw i32 [[FOR_2]], 1 17; CHECK-NEXT: [[FOR_2_NEXT]] = shl i32 [[FOR_1]], 24 18; CHECK-NEXT: [[INC]] = add nsw i32 [[IV]], 1 19; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INC]], [[N:%.*]] 20; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_COND1_FOR_END_CRIT_EDGE:%.*]], label [[FOR_BODY]] 21; CHECK: for.cond1.for.end_crit_edge: 22; CHECK-NEXT: [[ADD_LCSSA:%.*]] = phi i32 [ [[FOR_1_NEXT]], [[FOR_BODY]] ] 23; CHECK-NEXT: [[SEXT_LCSSA:%.*]] = phi i32 [ [[FOR_2_NEXT]], [[FOR_BODY]] ] 24; CHECK-NEXT: [[RES:%.*]] = add i32 [[ADD_LCSSA]], [[SEXT_LCSSA]] 25; CHECK-NEXT: ret i32 [[RES]] 26; 27entry: 28 br label %for.body 29 30for.body: ; preds = %for.body.preheader, %for.body 31 %iv = phi i32 [ %inc, %for.body ], [ 10, %entry ] 32 %for.1 = phi i32 [ %for.1.next, %for.body ], [ 20, %entry ] 33 %for.2 = phi i32 [ %for.2.next, %for.body ], [ 11, %entry ] 34 %for.1.next = add nsw i32 %for.2, 1 35 %for.2.next = shl i32 %for.1, 24 36 %inc = add nsw i32 %iv, 1 37 %exitcond = icmp eq i32 %inc, %N 38 br i1 %exitcond, label %for.cond1.for.end_crit_edge, label %for.body 39 40for.cond1.for.end_crit_edge: ; preds = %for.body 41 %add.lcssa = phi i32 [ %for.1.next, %for.body ] 42 %sext.lcssa = phi i32 [ %for.2.next, %for.body ] 43 %res = add i32 %add.lcssa, %sext.lcssa 44 ret i32 %res 45} 46