Home | History | Annotate | Download | only in IndVarSimplify
      1 ; RUN: opt < %s -indvars -S | FileCheck %s
      2 ; Test WidenIV::GetExtendedOperandRecurrence.
      3 ; %add, %sub and %mul should be extended to i64 because it is nsw, even though its
      4 ; sext cannot be hoisted outside the loop.
      5 
      6 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
      7 
      8 define void @test() nounwind {
      9 entry:
     10   br i1 undef, label %for.body11, label %for.end285
     11 
     12 for.body11:                                       ; preds = %entry
     13   %shl = shl i32 1, 1
     14   %shl132 = shl i32 %shl, 1
     15   br label %for.body153
     16 
     17 for.body153:                                      ; preds = %for.body153, %for.body11
     18   br i1 undef, label %for.body170, label %for.body153
     19 
     20 ; CHECK: add nuw nsw i64 %indvars.iv, 1
     21 ; CHECK: sub nsw i64 %indvars.iv, 2
     22 ; CHECK: sub nsw i64 4, %indvars.iv
     23 ; CHECK: mul nsw i64 %indvars.iv, 8
     24 for.body170:                                      ; preds = %for.body170, %for.body153
     25   %i2.19 = phi i32 [ %add249, %for.body170 ], [ 0, %for.body153 ]
     26 
     27   %add = add nsw i32 %i2.19, 1
     28   %add.idxprom = sext i32 %add to i64
     29 
     30   %sub = sub nsw i32 %i2.19, 2
     31   %sub.idxprom = sext i32 %sub to i64
     32 
     33   %sub.neg = sub nsw i32 4, %i2.19
     34   %sub.neg.idxprom = sext i32 %sub.neg to i64
     35 
     36   %mul = mul nsw i32 %i2.19, 8
     37   %mul.idxprom = sext i32 %mul to i64
     38 
     39   %add249 = add nsw i32 %i2.19, %shl132
     40   br label %for.body170
     41 for.end285:                                       ; preds = %entry
     42   ret void
     43 }
     44