]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/blob - test/Transforms/GVN/noalias.ll
IR: Make metadata typeless in assembly
[opencl/llvm.git] / test / Transforms / GVN / noalias.ll
1 ; RUN: opt -scoped-noalias -basicaa -gvn -S < %s | FileCheck %s
3 define i32 @test1(i32* %p, i32* %q) {
4 ; CHECK-LABEL: @test1(i32* %p, i32* %q)
5 ; CHECK: load i32* %p
6 ; CHECK-NOT: noalias
7 ; CHECK: %c = add i32 %a, %a
8   %a = load i32* %p, !noalias !0
9   %b = load i32* %p
10   %c = add i32 %a, %b
11   ret i32 %c
12 }
14 define i32 @test2(i32* %p, i32* %q) {
15 ; CHECK-LABEL: @test2(i32* %p, i32* %q)
16 ; CHECK: load i32* %p, !alias.scope !0
17 ; CHECK: %c = add i32 %a, %a
18   %a = load i32* %p, !alias.scope !0
19   %b = load i32* %p, !alias.scope !0
20   %c = add i32 %a, %b
21   ret i32 %c
22 }
24 ; FIXME: In this case we can do better than intersecting the scopes, and can
25 ; concatenate them instead. Both loads are in the same basic block, the first
26 ; makes the second safe to speculatively execute, and there are no calls that may
27 ; throw in between.
28 define i32 @test3(i32* %p, i32* %q) {
29 ; CHECK-LABEL: @test3(i32* %p, i32* %q)
30 ; CHECK: load i32* %p, !alias.scope !1
31 ; CHECK: %c = add i32 %a, %a
32   %a = load i32* %p, !alias.scope !1
33   %b = load i32* %p, !alias.scope !2
34   %c = add i32 %a, %b
35   ret i32 %c
36 }
38 declare i32 @foo(i32*) readonly
40 !0 = !{!0}
41 !1 = !{!1}
42 !2 = !{!0, !1}