xref: /aosp_15_r20/external/llvm/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -indvars -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; Test WidenIV::GetExtendedOperandRecurrence.
3*9880d681SAndroid Build Coastguard Worker; %add, %sub and %mul should be extended to i64 because it is nsw, even though its
4*9880d681SAndroid Build Coastguard Worker; sext cannot be hoisted outside the loop.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workertarget 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*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Workerdefine void @test() nounwind {
9*9880d681SAndroid Build Coastguard Workerentry:
10*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %for.body11, label %for.end285
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerfor.body11:                                       ; preds = %entry
13*9880d681SAndroid Build Coastguard Worker  %shl = shl i32 1, 1
14*9880d681SAndroid Build Coastguard Worker  %shl132 = shl i32 %shl, 1
15*9880d681SAndroid Build Coastguard Worker  br label %for.body153
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Workerfor.body153:                                      ; preds = %for.body153, %for.body11
18*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %for.body170, label %for.body153
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker; CHECK: add nuw nsw i64 %indvars.iv, 1
21*9880d681SAndroid Build Coastguard Worker; CHECK: sub nsw i64 %indvars.iv, 2
22*9880d681SAndroid Build Coastguard Worker; CHECK: sub nsw i64 4, %indvars.iv
23*9880d681SAndroid Build Coastguard Worker; CHECK: mul nsw i64 %indvars.iv, 8
24*9880d681SAndroid Build Coastguard Workerfor.body170:                                      ; preds = %for.body170, %for.body153
25*9880d681SAndroid Build Coastguard Worker  %i2.19 = phi i32 [ %add249, %for.body170 ], [ 0, %for.body153 ]
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %i2.19, 1
28*9880d681SAndroid Build Coastguard Worker  %add.idxprom = sext i32 %add to i64
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Worker  %sub = sub nsw i32 %i2.19, 2
31*9880d681SAndroid Build Coastguard Worker  %sub.idxprom = sext i32 %sub to i64
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Worker  %sub.neg = sub nsw i32 4, %i2.19
34*9880d681SAndroid Build Coastguard Worker  %sub.neg.idxprom = sext i32 %sub.neg to i64
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker  %mul = mul nsw i32 %i2.19, 8
37*9880d681SAndroid Build Coastguard Worker  %mul.idxprom = sext i32 %mul to i64
38*9880d681SAndroid Build Coastguard Worker
39*9880d681SAndroid Build Coastguard Worker  %add249 = add nsw i32 %i2.19, %shl132
40*9880d681SAndroid Build Coastguard Worker  br label %for.body170
41*9880d681SAndroid Build Coastguard Workerfor.end285:                                       ; preds = %entry
42*9880d681SAndroid Build Coastguard Worker  ret void
43*9880d681SAndroid Build Coastguard Worker}
44