1 ; RUN: opt -indvars -S < %s | FileCheck %s 2 3 declare void @use(i32) 4 declare void @use.i8(i8) 5 6 define void @f() { 7 ; CHECK-LABEL: @f 8 entry: 9 br label %loop 10 11 loop: 12 ; The only use for idx.mirror is to induce an nuw for %idx. It does 13 ; not induce an nuw for %idx.inc 14 %idx.mirror = phi i8 [ -6, %entry ], [ %idx.mirror.inc, %loop ] 15 %idx = phi i8 [ -5, %entry ], [ %idx.inc, %loop ] 16 17 %idx.sext = sext i8 %idx to i32 18 call void @use(i32 %idx.sext) 19 20 %idx.mirror.inc = add nuw i8 %idx.mirror, 1 21 call void @use.i8(i8 %idx.mirror.inc) 22 23 %idx.inc = add i8 %idx, 1 24 ; CHECK-NOT: %indvars.iv.next = add nuw nsw i32 %indvars.iv, 1 25 %cmp = icmp ugt i8 %idx.inc, 0 26 br i1 %cmp, label %loop, label %exit 27 28 exit: 29 ret void 30 } 31