xref: /aosp_15_r20/external/llvm/test/Analysis/DependenceAnalysis/UsefulGEP.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -analyze -basicaa -da
2*9880d681SAndroid Build Coastguard Worker;; Check this doesn't crash.
3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-unknown-linux-gnu"
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker;; struct s {
7*9880d681SAndroid Build Coastguard Worker;;   int A[10][10];
8*9880d681SAndroid Build Coastguard Worker;;   int C[10][10][10];
9*9880d681SAndroid Build Coastguard Worker;; } S;
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Worker;; void dep_constraint_crash_test(int k,int N) {
12*9880d681SAndroid Build Coastguard Worker;;   for( int i=0;i<N;i++)
13*9880d681SAndroid Build Coastguard Worker;;     for( int j=0;j<N;j++)
14*9880d681SAndroid Build Coastguard Worker;;       S.A[0][0] = S.C[0][0][k];
15*9880d681SAndroid Build Coastguard Worker;; }
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Worker%struct.s = type { [10 x [10 x i32]], [10 x [10 x [10 x i32]]] }
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker@S = common global %struct.s zeroinitializer
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Workerdefine void @dep_constraint_crash_test(i32 %k, i32 %N) {
23*9880d681SAndroid Build Coastguard Workerentry:
24*9880d681SAndroid Build Coastguard Worker  %cmp12 = icmp sgt i32 %N, 0
25*9880d681SAndroid Build Coastguard Worker  br i1 %cmp12, label %for.cond1.preheader.lr.ph, label %for.end6
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerfor.cond1.preheader.lr.ph:
28*9880d681SAndroid Build Coastguard Worker  %idxprom = sext i32 %k to i64
29*9880d681SAndroid Build Coastguard Worker  %arrayidx = getelementptr inbounds %struct.s, %struct.s* @S, i64 0, i32 1, i64 0, i64 0, i64 %idxprom
30*9880d681SAndroid Build Coastguard Worker  br label %for.body3.preheader
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Workerfor.body3.preheader:
33*9880d681SAndroid Build Coastguard Worker  %i.013 = phi i32 [ 0, %for.cond1.preheader.lr.ph ], [ %inc5, %for.inc4 ]
34*9880d681SAndroid Build Coastguard Worker  br label %for.body3
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Workerfor.body3:
37*9880d681SAndroid Build Coastguard Worker  %j.011 = phi i32 [ %inc, %for.body3 ], [ 0, %for.body3.preheader ]
38*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* %arrayidx
39*9880d681SAndroid Build Coastguard Worker  store i32 %0, i32* getelementptr inbounds (%struct.s, %struct.s* @S, i64 0, i32 0, i64 0, i64 0)
40*9880d681SAndroid Build Coastguard Worker  %inc = add nuw nsw i32 %j.011, 1
41*9880d681SAndroid Build Coastguard Worker  %exitcond = icmp eq i32 %inc, %N
42*9880d681SAndroid Build Coastguard Worker  br i1 %exitcond, label %for.inc4, label %for.body3
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Workerfor.inc4:
45*9880d681SAndroid Build Coastguard Worker  %inc5 = add nuw nsw i32 %i.013, 1
46*9880d681SAndroid Build Coastguard Worker  %exitcond14 = icmp eq i32 %inc5, %N
47*9880d681SAndroid Build Coastguard Worker  br i1 %exitcond14, label %for.end6, label %for.body3.preheader
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Workerfor.end6:
50*9880d681SAndroid Build Coastguard Worker  ret void
51*9880d681SAndroid Build Coastguard Worker}
52