1 ; RUN: opt < %s -basicaa -globals-aa -gvn -instcombine -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
2 ; RUN: opt < %s -aa-pipeline=basic-aa,globals-aa -passes="require<globals-aa>,function(gvn,instcombine)" -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
4 ; Note that this test relies on an unsafe feature of GlobalsModRef. While this
5 ; test is correct and safe, GMR's technique for handling this isn't generally.
7 @G = internal global i32* null ; <i32**> [#uses=3]
9 declare i8* @malloc(i32)
11 %a = call i8* @malloc(i32 4)
12 %A = bitcast i8* %a to i32*
13 store i32* %A, i32** @G
17 define i32 @test1(i32* %P) {
19 %g1 = load i32*, i32** @G ; <i32*> [#uses=2]
20 %h1 = load i32, i32* %g1 ; <i32> [#uses=1]
21 store i32 123, i32* %P
22 %g2 = load i32*, i32** @G ; <i32*> [#uses=0]
23 %h2 = load i32, i32* %g1 ; <i32> [#uses=1]
24 %X = sub i32 %h1, %h2 ; <i32> [#uses=1]