2002-04-18 15:39:50 +00:00
|
|
|
; The %A getelementptr instruction should be eliminated here
|
|
|
|
|
2002-08-02 19:27:58 +00:00
|
|
|
; RUN: if as < %s | opt -instcombine -die | dis | grep getelementptr | grep '%A'
|
2002-04-18 15:39:50 +00:00
|
|
|
; RUN: then exit 1
|
|
|
|
; RUN: else exit 0
|
|
|
|
; RUN: fi
|
|
|
|
|
2002-08-16 21:18:21 +00:00
|
|
|
%Global = constant [10 x sbyte] c"helloworld"
|
|
|
|
|
2002-04-18 15:39:50 +00:00
|
|
|
implementation
|
|
|
|
|
2002-08-02 18:47:11 +00:00
|
|
|
int *"foo1"(int * %I) { ; Test noop elimination
|
2002-09-17 20:47:46 +00:00
|
|
|
%A = getelementptr int* %I, long 0
|
2002-05-02 15:24:40 +00:00
|
|
|
ret int * %A
|
2002-08-02 18:47:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int* %foo2(int* %I) { ; Test noop elimination
|
|
|
|
%A = getelementptr int* %I
|
|
|
|
ret int* %A
|
|
|
|
}
|
|
|
|
int* %foo3(int * %I) { ; Test that two array indexing geps fold
|
2002-09-17 20:47:46 +00:00
|
|
|
%A = getelementptr int* %I, long 17
|
|
|
|
%B = getelementptr int* %A, long 4
|
2002-08-02 18:47:11 +00:00
|
|
|
ret int* %B
|
|
|
|
}
|
2002-05-02 15:24:40 +00:00
|
|
|
|
2002-08-02 18:47:11 +00:00
|
|
|
int* %foo4({int} *%I) { ; Test that two getelementptr insts fold
|
2002-09-17 20:47:46 +00:00
|
|
|
%A = getelementptr {int}* %I, long 1
|
|
|
|
%B = getelementptr {int}* %A, long 0, ubyte 0
|
2002-08-02 18:47:11 +00:00
|
|
|
ret int* %B
|
|
|
|
}
|
2002-08-16 21:18:21 +00:00
|
|
|
|
|
|
|
sbyte * %foo5() {
|
|
|
|
; This should be turned into a constexpr instead of being an instruction
|
2002-09-17 20:47:46 +00:00
|
|
|
%A = getelementptr [10 x sbyte]* %Global, long 0, long 4
|
2002-08-16 21:18:21 +00:00
|
|
|
ret sbyte* %A
|
|
|
|
}
|