xref: /aosp_15_r20/external/llvm/test/Transforms/LoopStrengthReduce/preserve-gep-loop-variant.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -loop-reduce -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{inttoptr|ptrtoint}}
3*9880d681SAndroid Build Coastguard Worker; CHECK: scevgep
4*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{inttoptr|ptrtoint}}
5*9880d681SAndroid Build Coastguard Workertarget datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128-n32:64"
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; Indvars shouldn't need inttoptr/ptrtoint to expand an address here.
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdefine void @foo(i8* %p) nounwind {
10*9880d681SAndroid Build Coastguard Workerentry:
11*9880d681SAndroid Build Coastguard Worker  br i1 true, label %bb.nph, label %for.end
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Workerfor.cond:
14*9880d681SAndroid Build Coastguard Worker  %phitmp = icmp slt i64 %inc, 20
15*9880d681SAndroid Build Coastguard Worker  br i1 %phitmp, label %for.body, label %for.cond.for.end_crit_edge
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Workerfor.cond.for.end_crit_edge:
18*9880d681SAndroid Build Coastguard Worker  br label %for.end
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Workerbb.nph:
21*9880d681SAndroid Build Coastguard Worker  br label %for.body
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Workerfor.body:
24*9880d681SAndroid Build Coastguard Worker  %storemerge1 = phi i64 [ %inc, %for.cond ], [ 0, %bb.nph ]
25*9880d681SAndroid Build Coastguard Worker  %call = tail call i64 @bar() nounwind
26*9880d681SAndroid Build Coastguard Worker  %call2 = tail call i64 @car() nounwind
27*9880d681SAndroid Build Coastguard Worker  %conv = trunc i64 %call2 to i8
28*9880d681SAndroid Build Coastguard Worker  %conv3 = sext i8 %conv to i64
29*9880d681SAndroid Build Coastguard Worker  %add = add nsw i64 %call, %storemerge1
30*9880d681SAndroid Build Coastguard Worker  %add4 = add nsw i64 %add, %conv3
31*9880d681SAndroid Build Coastguard Worker  %arrayidx = getelementptr inbounds i8, i8* %p, i64 %add4
32*9880d681SAndroid Build Coastguard Worker  store i8 0, i8* %arrayidx
33*9880d681SAndroid Build Coastguard Worker  %inc = add nsw i64 %storemerge1, 1
34*9880d681SAndroid Build Coastguard Worker  br label %for.cond
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Workerfor.end:
37*9880d681SAndroid Build Coastguard Worker  ret void
38*9880d681SAndroid Build Coastguard Worker}
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Workerdeclare i64 @bar()
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Workerdeclare i64 @car()
43