2004-03-25 22:59:06 +00:00
|
|
|
; Test folding of constantexpr geps into normal geps.
|
2008-08-16 00:00:54 +00:00
|
|
|
; RUN: llvm-as < %s | opt -instcombine -gvn -instcombine | \
|
2007-04-14 20:13:02 +00:00
|
|
|
; RUN: llvm-dis | not grep getelementptr
|
2004-03-25 22:59:06 +00:00
|
|
|
|
2008-03-09 08:16:40 +00:00
|
|
|
@Array = external global [40 x i32] ; <[40 x i32]*> [#uses=2]
|
2004-03-25 22:59:06 +00:00
|
|
|
|
2008-03-09 08:16:40 +00:00
|
|
|
define i32 @test(i64 %X) {
|
|
|
|
%A = getelementptr i32* getelementptr ([40 x i32]* @Array, i64 0, i64 0), i64 %X ; <i32*> [#uses=1]
|
|
|
|
%B = getelementptr [40 x i32]* @Array, i64 0, i64 %X ; <i32*> [#uses=1]
|
|
|
|
%a = ptrtoint i32* %A to i32 ; <i32> [#uses=1]
|
|
|
|
%b = ptrtoint i32* %B to i32 ; <i32> [#uses=1]
|
|
|
|
%c = sub i32 %a, %b ; <i32> [#uses=1]
|
|
|
|
ret i32 %c
|
2004-03-25 22:59:06 +00:00
|
|
|
}
|
2008-03-09 08:16:40 +00:00
|
|
|
|