xref: /llvm-project/polly/test/ScopInfo/aliasing_with_non_affine_access.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly '-passes=print<polly-ast>' -polly-process-unprofitable -polly-allow-nonaffine -disable-output < %s 2>&1 | FileCheck %s
2;
3; @test1
4; Make sure we generate the correct aliasing check for a fixed-size memset operation.
5; CHECK: if (1 && (&MemRef_tmp0[15] <= &MemRef_tmp1[0] || &MemRef_tmp1[32] <= &MemRef_tmp0[14]))
6;
7; @test2
8; Make sure we generate the correct aliasing check for a variable-size memset operation.
9; CHECK: if (1 && (&MemRef_tmp0[15] <= &MemRef_tmp1[0] || &MemRef_tmp1[n] <= &MemRef_tmp0[14]))
10;
11; @test3
12; We can't do anything interesting with a non-affine memset; just make sure it doesn't crash.
13;
14target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
15
16%struct.info = type { i32, ptr, i32, ptr, ptr, i32, ptr, i32, i32, double }
17%struct.ctr = type { i32, i8, i8, i32 }
18%struct.ord = type { i32, i8 }
19
20; Function Attrs: argmemonly nounwind
21declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i32, i1) #0
22
23define void @test1(ptr %ppIdxInfo) {
24entry:
25  %tmp0 = load ptr, ptr %ppIdxInfo, align 8
26  br label %if.end125
27
28if.end125:                                        ; preds = %entry
29  %tmp1 = load ptr, ptr undef, align 8
30  br label %for.end143
31
32for.end143:                                       ; preds = %if.end125
33  tail call void @llvm.memset.p0.i64(ptr %tmp1, i8 0, i64 32, i32 4, i1 false)
34  %needToFreeIdxStr = getelementptr inbounds %struct.info, ptr %tmp0, i64 0, i32 7
35  %tmp3 = load i32, ptr %needToFreeIdxStr, align 8
36  br i1 false, label %if.end149, label %if.then148
37
38if.then148:                                       ; preds = %for.end143
39  br label %if.end149
40
41if.end149:                                        ; preds = %if.then148, %for.end143
42  ret void
43}
44
45define void @test2(ptr %ppIdxInfo, i64 %n) {
46entry:
47  %tmp0 = load ptr, ptr %ppIdxInfo, align 8
48  br label %if.end125
49
50if.end125:                                        ; preds = %entry
51  %tmp1 = load ptr, ptr undef, align 8
52  br label %for.end143
53
54for.end143:                                       ; preds = %if.end125
55  tail call void @llvm.memset.p0.i64(ptr %tmp1, i8 0, i64 %n, i32 4, i1 false)
56  %needToFreeIdxStr = getelementptr inbounds %struct.info, ptr %tmp0, i64 0, i32 7
57  %tmp3 = load i32, ptr %needToFreeIdxStr, align 8
58  br i1 false, label %if.end149, label %if.then148
59
60if.then148:                                       ; preds = %for.end143
61  br label %if.end149
62
63if.end149:                                        ; preds = %if.then148, %for.end143
64  ret void
65}
66
67define i32 @test3(ptr %x, i32 %n) {
68entry:
69  br label %entry.split
70
71entry.split:                                      ; preds = %entry
72  %conv = sext i32 %n to i64
73  %cmp8 = icmp sgt i32 %n, 0
74  br i1 %cmp8, label %for.body.lr.ph, label %for.cond.cleanup
75
76for.body.lr.ph:                                   ; preds = %entry.split
77  br label %for.body
78
79for.cond.cleanup:                                 ; preds = %for.body, %entry.split
80  ret i32 0
81
82for.body:                                         ; preds = %for.body, %for.body.lr.ph
83  %i.09 = phi i64 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
84  %mul = mul nsw i64 %i.09, %i.09
85  tail call void @llvm.memset.p0.i64(ptr %x, i8 0, i64 %mul, i32 4, i1 false)
86  %add = add nuw nsw i64 %i.09, 1000
87  %arrayidx = getelementptr inbounds i32, ptr %x, i64 %add
88  store i32 5, ptr %arrayidx, align 4
89  %inc = add nuw nsw i64 %i.09, 1
90  %exitcond = icmp eq i64 %inc, %conv
91  br i1 %exitcond, label %for.cond.cleanup, label %for.body
92}
93
94attributes #0 = { argmemonly nounwind }
95