blob: d2be1cef996ff97d082ed20a0c246d5c0c324836 [file] [log] [blame]
Chris Lattnere4f318c2002-09-08 18:08:36 +00001; This testcase tests for various features the basicaa test should be able to
2; determine, as noted in the comments.
3
4; RUN: if as < %s | opt -basicaa -load-vn -gcse -instcombine -dce | dis | grep REMOVE
5; RUN: then exit 1
6; RUN: else exit 0
7; RUN: fi
8
9
10; Array test: Test that operations on one local array do not invalidate
11; operations on another array. Important for scientific codes.
12;
Chris Lattner66486452002-10-25 22:29:07 +000013int %different_array_test(long %A, long %B) {
Chris Lattnere4f318c2002-09-08 18:08:36 +000014 %Array1 = alloca int, uint 100
15 %Array2 = alloca int, uint 200
16
Chris Lattner66486452002-10-25 22:29:07 +000017 %pointer = getelementptr int* %Array1, long %A
Chris Lattnere4f318c2002-09-08 18:08:36 +000018 %val = load int* %pointer
19
Chris Lattner66486452002-10-25 22:29:07 +000020 %pointer2 = getelementptr int* %Array2, long %B
Chris Lattnere4f318c2002-09-08 18:08:36 +000021 store int 7, int* %pointer2
22
23 %REMOVE = load int* %pointer ; redundant with above load
24 %retval = sub int %REMOVE, %val
25 ret int %retval
26}
27
28; Constant index test: Constant indexes into the same array should not
29; interfere with each other. Again, important for scientific codes.
30;
31int %constant_array_index_test() {
32 %Array = alloca int, uint 100
Chris Lattner66486452002-10-25 22:29:07 +000033 %P1 = getelementptr int* %Array, long 7
34 %P2 = getelementptr int* %Array, long 6
Chris Lattnere4f318c2002-09-08 18:08:36 +000035
36 %A = load int* %P1
37 store int 1, int* %P2 ; Should not invalidate load
38 %BREMOVE = load int* %P1
39 %Val = sub int %A, %BREMOVE
40 ret int %Val
41}
42