1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2 2; RUN: opt -S -passes='print<scalar-evolution>,indvars' < %s 2>/dev/null | FileCheck %s 3 4; We should use %invariant.op.us rather than %invariant.op for the exit 5; value expansion. They have the same SCEV, but %invariant.op is more 6; poisonous. 7define i32 @test(i1 %c) { 8; CHECK-LABEL: define i32 @test 9; CHECK-SAME: (i1 [[C:%.*]]) { 10; CHECK-NEXT: entry: 11; CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], i32 33, i32 0 12; CHECK-NEXT: [[SUB_I:%.*]] = add nsw i32 [[SEL]], -68 13; CHECK-NEXT: [[SHL_I:%.*]] = shl nuw nsw i32 1, [[SUB_I]] 14; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[SHL_I]], [[SEL]] 15; CHECK-NEXT: [[SEXT:%.*]] = shl i32 [[ADD]], 24 16; CHECK-NEXT: [[CONV2:%.*]] = ashr exact i32 [[SEXT]], 24 17; CHECK-NEXT: [[INVARIANT_OP:%.*]] = sub nsw i32 7, [[CONV2]] 18; CHECK-NEXT: call void @use(i32 [[INVARIANT_OP]]) 19; CHECK-NEXT: [[SEXT_US:%.*]] = shl i32 [[SEL]], 24 20; CHECK-NEXT: [[CONV2_US:%.*]] = ashr exact i32 [[SEXT_US]], 24 21; CHECK-NEXT: br label [[LOOP:%.*]] 22; CHECK: loop: 23; CHECK-NEXT: br i1 true, label [[EXIT:%.*]], label [[LOOP]] 24; CHECK: exit: 25; CHECK-NEXT: [[INVARIANT_OP_US:%.*]] = sub nsw i32 7, [[CONV2_US]] 26; CHECK-NEXT: ret i32 [[INVARIANT_OP_US]] 27; 28entry: 29 %sel = select i1 %c, i32 33, i32 0 30 %sub.i = add nsw i32 %sel, -68 31 %shl.i = shl nuw nsw i32 1, %sub.i 32 %add = add nsw i32 %shl.i, %sel 33 %sext = shl i32 %add, 24 34 %conv2 = ashr exact i32 %sext, 24 35 %invariant.op = sub nsw i32 7, %conv2 36 call void @use(i32 %invariant.op) 37 %sext.us = shl i32 %sel, 24 38 %conv2.us = ashr exact i32 %sext.us, 24 39 %invariant.op.us = sub nsw i32 7, %conv2.us 40 br label %loop 41 42loop: 43 %iv = phi i32 [ %iv.next , %loop ], [ 0, %entry ] 44 %iv.next = add i32 %iv, 1 45 %cmp = icmp eq i32 %iv.next, %invariant.op.us 46 br i1 %cmp, label %exit, label %loop 47 48exit: 49 ret i32 %iv.next 50} 51 52declare void @use(i32) 53