1*9880d681SAndroid Build Coastguard Worker; RUN: opt -scoped-noalias -basicaa -gvn -S < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Workerdefine i32 @test1(i32* %p, i32* %q) { 4*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test1(i32* %p, i32* %q) 5*9880d681SAndroid Build Coastguard Worker; CHECK: load i32, i32* %p 6*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: noalias 7*9880d681SAndroid Build Coastguard Worker; CHECK: %c = add i32 %a, %a 8*9880d681SAndroid Build Coastguard Worker %a = load i32, i32* %p, !noalias !0 9*9880d681SAndroid Build Coastguard Worker %b = load i32, i32* %p 10*9880d681SAndroid Build Coastguard Worker %c = add i32 %a, %b 11*9880d681SAndroid Build Coastguard Worker ret i32 %c 12*9880d681SAndroid Build Coastguard Worker} 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Workerdefine i32 @test2(i32* %p, i32* %q) { 15*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test2(i32* %p, i32* %q) 16*9880d681SAndroid Build Coastguard Worker; CHECK: load i32, i32* %p, !alias.scope !0 17*9880d681SAndroid Build Coastguard Worker; CHECK: %c = add i32 %a, %a 18*9880d681SAndroid Build Coastguard Worker %a = load i32, i32* %p, !alias.scope !0 19*9880d681SAndroid Build Coastguard Worker %b = load i32, i32* %p, !alias.scope !0 20*9880d681SAndroid Build Coastguard Worker %c = add i32 %a, %b 21*9880d681SAndroid Build Coastguard Worker ret i32 %c 22*9880d681SAndroid Build Coastguard Worker} 23*9880d681SAndroid Build Coastguard Worker 24*9880d681SAndroid Build Coastguard Worker; FIXME: In this case we can do better than intersecting the scopes, and can 25*9880d681SAndroid Build Coastguard Worker; concatenate them instead. Both loads are in the same basic block, the first 26*9880d681SAndroid Build Coastguard Worker; makes the second safe to speculatively execute, and there are no calls that may 27*9880d681SAndroid Build Coastguard Worker; throw in between. 28*9880d681SAndroid Build Coastguard Workerdefine i32 @test3(i32* %p, i32* %q) { 29*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @test3(i32* %p, i32* %q) 30*9880d681SAndroid Build Coastguard Worker; CHECK: load i32, i32* %p, !alias.scope !1 31*9880d681SAndroid Build Coastguard Worker; CHECK: %c = add i32 %a, %a 32*9880d681SAndroid Build Coastguard Worker %a = load i32, i32* %p, !alias.scope !1 33*9880d681SAndroid Build Coastguard Worker %b = load i32, i32* %p, !alias.scope !2 34*9880d681SAndroid Build Coastguard Worker %c = add i32 %a, %b 35*9880d681SAndroid Build Coastguard Worker ret i32 %c 36*9880d681SAndroid Build Coastguard Worker} 37*9880d681SAndroid Build Coastguard Worker 38*9880d681SAndroid Build Coastguard Workerdeclare i32 @foo(i32*) readonly 39*9880d681SAndroid Build Coastguard Worker 40*9880d681SAndroid Build Coastguard Worker!0 = !{!0} 41*9880d681SAndroid Build Coastguard Worker!1 = !{!1} 42*9880d681SAndroid Build Coastguard Worker!2 = !{!0, !1} 43*9880d681SAndroid Build Coastguard Worker 44