• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
2; RUN: opt -inline -enable-noalias-to-md-conversion -S < %s | FileCheck %s --check-prefixes=CHECK,NO_ASSUME
3; RUN: opt -inline -enable-noalias-to-md-conversion --enable-knowledge-retention -S < %s | FileCheck %s
4
5target 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-S128"
6target triple = "x86_64-unknown-linux-gnu"
7
8define void @hello(float* noalias nocapture %a, float* noalias nocapture readonly %c) #0 {
9; CHECK-LABEL: define {{[^@]+}}@hello
10; CHECK-SAME: (float* noalias nocapture [[A:%.*]], float* noalias nocapture readonly [[C:%.*]]) #0
11; CHECK-NEXT:  entry:
12; CHECK-NEXT:    [[TMP0:%.*]] = load float, float* [[C]], align 4
13; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds float, float* [[A]], i64 5
14; CHECK-NEXT:    store float [[TMP0]], float* [[ARRAYIDX]], align 4
15; CHECK-NEXT:    ret void
16;
17; ASSUME-LABEL: @hello(
18; ASSUME-NEXT:  entry:
19; ASSUME-NEXT:    [[TMP0:%.*]] = load float, float* [[C:%.*]], align 4
20; ASSUME-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds float, float* [[A:%.*]], i64 5
21; ASSUME-NEXT:    store float [[TMP0]], float* [[ARRAYIDX]], align 4
22; ASSUME-NEXT:    ret void
23entry:
24  %0 = load float, float* %c, align 4
25  %arrayidx = getelementptr inbounds float, float* %a, i64 5
26  store float %0, float* %arrayidx, align 4
27  ret void
28}
29
30define void @foo(float* noalias nocapture %a, float* noalias nocapture readonly %c) #0 {
31; CHECK-LABEL: define {{[^@]+}}@foo
32; CHECK-SAME: (float* noalias nocapture [[A:%.*]], float* noalias nocapture readonly [[C:%.*]]) #0
33; CHECK-NEXT:  entry:
34; CHECK-NEXT:    [[TMP0:%.*]] = load float, float* [[C]], align 4, !alias.scope !0, !noalias !3
35; CHECK-NEXT:    [[ARRAYIDX_I:%.*]] = getelementptr inbounds float, float* [[A]], i64 5
36; CHECK-NEXT:    store float [[TMP0]], float* [[ARRAYIDX_I]], align 4, !alias.scope !3, !noalias !0
37; CHECK-NEXT:    [[TMP1:%.*]] = load float, float* [[C]], align 4
38; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds float, float* [[A]], i64 7
39; CHECK-NEXT:    store float [[TMP1]], float* [[ARRAYIDX]], align 4
40; CHECK-NEXT:    ret void
41;
42; ASSUME-LABEL: @foo(
43; ASSUME-NEXT:  entry:
44; ASSUME-NEXT:    call void @llvm.assume(i1 true) [ "noalias"(float* [[A:%.*]]), "noalias"(float* [[C:%.*]]) ]
45; ASSUME-NEXT:    [[TMP0:%.*]] = load float, float* [[C]], align 4, !alias.scope !0, !noalias !3
46; ASSUME-NEXT:    [[ARRAYIDX_I:%.*]] = getelementptr inbounds float, float* [[A]], i64 5
47; ASSUME-NEXT:    store float [[TMP0]], float* [[ARRAYIDX_I]], align 4, !alias.scope !3, !noalias !0
48; ASSUME-NEXT:    [[TMP1:%.*]] = load float, float* [[C]], align 4
49; ASSUME-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds float, float* [[A]], i64 7
50; ASSUME-NEXT:    store float [[TMP1]], float* [[ARRAYIDX]], align 4
51; ASSUME-NEXT:    ret void
52entry:
53  tail call void @hello(float* %a, float* %c)
54  %0 = load float, float* %c, align 4
55  %arrayidx = getelementptr inbounds float, float* %a, i64 7
56  store float %0, float* %arrayidx, align 4
57  ret void
58}
59
60define void @hello2(float* noalias nocapture %a, float* noalias nocapture %b, float* nocapture readonly %c) #0 {
61; CHECK-LABEL: define {{[^@]+}}@hello2
62; CHECK-SAME: (float* noalias nocapture [[A:%.*]], float* noalias nocapture [[B:%.*]], float* nocapture readonly [[C:%.*]]) #0
63; CHECK-NEXT:  entry:
64; CHECK-NEXT:    [[TMP0:%.*]] = load float, float* [[C]], align 4
65; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds float, float* [[A]], i64 6
66; CHECK-NEXT:    store float [[TMP0]], float* [[ARRAYIDX]], align 4
67; CHECK-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr inbounds float, float* [[B]], i64 8
68; CHECK-NEXT:    store float [[TMP0]], float* [[ARRAYIDX1]], align 4
69; CHECK-NEXT:    ret void
70;
71entry:
72  %0 = load float, float* %c, align 4
73  %arrayidx = getelementptr inbounds float, float* %a, i64 6
74  store float %0, float* %arrayidx, align 4
75  %arrayidx1 = getelementptr inbounds float, float* %b, i64 8
76  store float %0, float* %arrayidx1, align 4
77  ret void
78}
79
80; Check that when hello() is inlined into foo(), and then foo() is inlined into
81; foo2(), the noalias scopes are properly concatenated.
82define void @foo2(float* nocapture %a, float* nocapture %b, float* nocapture readonly %c) #0 {
83; CHECK-LABEL: define {{[^@]+}}@foo2
84; CHECK-SAME: (float* nocapture [[A:%.*]], float* nocapture [[B:%.*]], float* nocapture readonly [[C:%.*]]) #0
85; CHECK-NEXT:  entry:
86; CHECK-NEXT:    [[TMP0:%.*]] = load float, float* [[C]], align 4, !alias.scope !5, !noalias !10
87; CHECK-NEXT:    [[ARRAYIDX_I_I:%.*]] = getelementptr inbounds float, float* [[A]], i64 5
88; CHECK-NEXT:    store float [[TMP0]], float* [[ARRAYIDX_I_I]], align 4, !alias.scope !10, !noalias !5
89; CHECK-NEXT:    [[TMP1:%.*]] = load float, float* [[C]], align 4, !alias.scope !13, !noalias !14
90; CHECK-NEXT:    [[ARRAYIDX_I:%.*]] = getelementptr inbounds float, float* [[A]], i64 7
91; CHECK-NEXT:    store float [[TMP1]], float* [[ARRAYIDX_I]], align 4, !alias.scope !14, !noalias !13
92; CHECK-NEXT:    [[TMP2:%.*]] = load float, float* [[C]], align 4, !noalias !15
93; CHECK-NEXT:    [[ARRAYIDX_I1:%.*]] = getelementptr inbounds float, float* [[A]], i64 6
94; CHECK-NEXT:    store float [[TMP2]], float* [[ARRAYIDX_I1]], align 4, !alias.scope !19, !noalias !20
95; CHECK-NEXT:    [[ARRAYIDX1_I:%.*]] = getelementptr inbounds float, float* [[B]], i64 8
96; CHECK-NEXT:    store float [[TMP2]], float* [[ARRAYIDX1_I]], align 4, !alias.scope !20, !noalias !19
97; CHECK-NEXT:    [[TMP3:%.*]] = load float, float* [[C]], align 4
98; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds float, float* [[A]], i64 7
99; CHECK-NEXT:    store float [[TMP3]], float* [[ARRAYIDX]], align 4
100; CHECK-NEXT:    ret void
101;
102entry:
103  tail call void @foo(float* %a, float* %c)
104  tail call void @hello2(float* %a, float* %b, float* %c)
105  %0 = load float, float* %c, align 4
106  %arrayidx = getelementptr inbounds float, float* %a, i64 7
107  store float %0, float* %arrayidx, align 4
108  ret void
109}
110
111; NO_ASSUME: !0 = !{!1}
112; NO_ASSUME: !1 = distinct !{!1, !2, !"hello: %c"}
113; NO_ASSUME: !2 = distinct !{!2, !"hello"}
114; NO_ASSUME: !3 = !{!4}
115; NO_ASSUME: !4 = distinct !{!4, !2, !"hello: %a"}
116; NO_ASSUME: !5 = !{!6, !8}
117; NO_ASSUME: !6 = distinct !{!6, !7, !"hello: %c"}
118; NO_ASSUME: !7 = distinct !{!7, !"hello"}
119; NO_ASSUME: !8 = distinct !{!8, !9, !"foo: %c"}
120; NO_ASSUME: !9 = distinct !{!9, !"foo"}
121; NO_ASSUME: !10 = !{!11, !12}
122; NO_ASSUME: !11 = distinct !{!11, !7, !"hello: %a"}
123; NO_ASSUME: !12 = distinct !{!12, !9, !"foo: %a"}
124; NO_ASSUME: !13 = !{!8}
125; NO_ASSUME: !14 = !{!12}
126; NO_ASSUME: !15 = !{!16, !18}
127; NO_ASSUME: !16 = distinct !{!16, !17, !"hello2: %a"}
128; NO_ASSUME: !17 = distinct !{!17, !"hello2"}
129; NO_ASSUME: !18 = distinct !{!18, !17, !"hello2: %b"}
130; NO_ASSUME: !19 = !{!16}
131; NO_ASSUME: !20 = !{!18}
132
133attributes #0 = { nounwind uwtable }
134
135