diff --git a/test/Analysis/BasicAA/2003-02-26-AccessSizeTest.ll b/test/Analysis/BasicAA/2003-02-26-AccessSizeTest.ll new file mode 100644 index 00000000000..f1458ce905f --- /dev/null +++ b/test/Analysis/BasicAA/2003-02-26-AccessSizeTest.ll @@ -0,0 +1,18 @@ +; This testcase makes sure that size is taken to account when alias analysis +; is performed. It is not legal to delete the second load instruction because +; the value computed by the first load instruction is changed by the store. + +; RUN: as < %s | opt -load-vn -gcse -instcombine | dis | grep DONOTREMOVE + +int %test() { + %A = alloca int + store int 0, int* %A + %X = load int* %A + %B = cast int* %A to sbyte* + %C = getelementptr sbyte* %B, long 1 + store sbyte 1, sbyte* %C ; Aliases %A + %Y.DONOTREMOVE = load int* %A + %Z = sub int %X, %Y.DONOTREMOVE + ret int %Z +} + diff --git a/test/Analysis/BasicAA/featuretest.ll b/test/Analysis/BasicAA/featuretest.ll index cd57ef1a79a..385144d173b 100644 --- a/test/Analysis/BasicAA/featuretest.ll +++ b/test/Analysis/BasicAA/featuretest.ll @@ -62,3 +62,11 @@ int %gep_distance_test2({int,int}* %A, long %distance) { %r = sub int %REMOVEu, %REMOVEv ret int %r } + +int %foo(int * %A) { + %X = load int* %A + %B = cast int* %A to sbyte* + %C = getelementptr sbyte* %B, long 4 + %Y = load sbyte* %C + ret int 8 +} diff --git a/test/Transforms/BasicAA/2003-02-26-AccessSizeTest.ll b/test/Transforms/BasicAA/2003-02-26-AccessSizeTest.ll new file mode 100644 index 00000000000..f1458ce905f --- /dev/null +++ b/test/Transforms/BasicAA/2003-02-26-AccessSizeTest.ll @@ -0,0 +1,18 @@ +; This testcase makes sure that size is taken to account when alias analysis +; is performed. It is not legal to delete the second load instruction because +; the value computed by the first load instruction is changed by the store. + +; RUN: as < %s | opt -load-vn -gcse -instcombine | dis | grep DONOTREMOVE + +int %test() { + %A = alloca int + store int 0, int* %A + %X = load int* %A + %B = cast int* %A to sbyte* + %C = getelementptr sbyte* %B, long 1 + store sbyte 1, sbyte* %C ; Aliases %A + %Y.DONOTREMOVE = load int* %A + %Z = sub int %X, %Y.DONOTREMOVE + ret int %Z +} + diff --git a/test/Transforms/BasicAA/featuretest.ll b/test/Transforms/BasicAA/featuretest.ll index cd57ef1a79a..385144d173b 100644 --- a/test/Transforms/BasicAA/featuretest.ll +++ b/test/Transforms/BasicAA/featuretest.ll @@ -62,3 +62,11 @@ int %gep_distance_test2({int,int}* %A, long %distance) { %r = sub int %REMOVEu, %REMOVEv ret int %r } + +int %foo(int * %A) { + %X = load int* %A + %B = cast int* %A to sbyte* + %C = getelementptr sbyte* %B, long 4 + %Y = load sbyte* %C + ret int 8 +}