1 ; The %A getelementptr instruction should be eliminated here
3 ; RUN: llvm-as < %s | opt -instcombine -die | llvm-dis | grep getelementptr | not grep '%A '
5 %Global = constant [10 x sbyte] c"helloworld"
9 int *%foo1(int* %I) { ; Test noop elimination
10 %A = getelementptr int* %I, long 0
14 int* %foo2(int* %I) { ; Test noop elimination
15 %A = getelementptr int* %I
18 int* %foo3(int * %I) { ; Test that two array indexing geps fold
19 %A = getelementptr int* %I, long 17
20 %B = getelementptr int* %A, long 4
24 int* %foo4({int} *%I) { ; Test that two getelementptr insts fold
25 %A = getelementptr {int}* %I, long 1
26 %B = getelementptr {int}* %A, long 0, ubyte 0
31 ; This should be turned into a constexpr instead of being an instruction
32 %A = getelementptr [10 x sbyte]* %Global, long 0, long 4
38 %A = getelementptr [4 x int]* %M, long 0, long 0
39 %B = getelementptr int* %A, long 2
43 int* %foo7(int* %I, long %C, long %D) {
44 %A = getelementptr int* %I, long %C
45 %B = getelementptr int* %A, long %D
49 sbyte* %foo8([10 x int]* %X) {
50 %A = getelementptr [10 x int]* %X, long 0, long 0 ;; Fold into the cast.
51 %B = cast int* %A to sbyte*