blob: 45f6088eaf0cf6916e82c9270c7170dc18a7bc74 [file] [log] [blame]
Chris Lattner22a8d512003-02-26 21:39:52 +00001; This testcase makes sure that size is taken to account when alias analysis
2; is performed. It is not legal to delete the second load instruction because
3; the value computed by the first load instruction is changed by the store.
4
Bill Wendlingcd6df162012-04-24 09:15:38 +00005; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
Chris Lattner22a8d512003-02-26 21:39:52 +00006
Tanya Lattnerf865dcd2008-02-14 06:56:27 +00007define i32 @test() {
Bill Wendlingcd6df162012-04-24 09:15:38 +00008; CHECK: %Y.DONOTREMOVE = load i32* %A
9; CHECK: %Z = sub i32 0, %Y.DONOTREMOVE
10 %A = alloca i32
11 store i32 0, i32* %A
12 %X = load i32* %A
13 %B = bitcast i32* %A to i8*
14 %C = getelementptr i8* %B, i64 1
15 store i8 1, i8* %C ; Aliases %A
16 %Y.DONOTREMOVE = load i32* %A
17 %Z = sub i32 %X, %Y.DONOTREMOVE
18 ret i32 %Z
Chris Lattner22a8d512003-02-26 21:39:52 +000019}
20