1 ; RUN: opt -scoped-noalias -basicaa -gvn -S < %s | FileCheck %s 2 3 define i32 @test1(i32* %p, i32* %q) { 4 ; CHECK-LABEL: @test1(i32* %p, i32* %q) 5 ; CHECK: load i32, i32* %p 6 ; CHECK-NOT: noalias 7 ; CHECK: %c = add i32 %a, %a 8 %a = load i32, i32* %p, !noalias !0 9 %b = load i32, i32* %p 10 %c = add i32 %a, %b 11 ret i32 %c 12 } 13 14 define i32 @test2(i32* %p, i32* %q) { 15 ; CHECK-LABEL: @test2(i32* %p, i32* %q) 16 ; CHECK: load i32, i32* %p, !alias.scope !0 17 ; CHECK: %c = add i32 %a, %a 18 %a = load i32, i32* %p, !alias.scope !0 19 %b = load i32, i32* %p, !alias.scope !0 20 %c = add i32 %a, %b 21 ret i32 %c 22 } 23 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, i32* %p, !alias.scope !1 31 ; CHECK: %c = add i32 %a, %a 32 %a = load i32, i32* %p, !alias.scope !1 33 %b = load i32, i32* %p, !alias.scope !2 34 %c = add i32 %a, %b 35 ret i32 %c 36 } 37 38 declare i32 @foo(i32*) readonly 39 40 !0 = !{!0} 41 !1 = !{!1} 42 !2 = !{!0, !1} 43 44