Fix PR4748: don't fold gep(bitcast(x)) into bitcast(gep) when x
[oota-llvm.git] / test / Transforms / InstCombine / getelementptr-2.ll
1 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep load
2 ; PR4748
3 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
4 target triple = "i386-apple-darwin9"
5         %struct.B = type { double }
6         %struct.A = type { %struct.B, i32, i32 }
7
8 define i32 @_Z4funcv(%struct.A* %a) {
9 entry:
10   %g3 = getelementptr %struct.A* %a, i32 0, i32 1
11   store i32 10, i32* %g3, align 4
12
13   %g4 = getelementptr %struct.A* %a, i32 0, i32 0
14   
15   %new_a = bitcast %struct.B* %g4 to %struct.A*
16
17   %g5 = getelementptr %struct.A* %new_a, i32 0, i32 1   
18   %a_a = load i32* %g5, align 4 
19   ret i32 %a_a
20 }
21