1 ; RUN: opt < %s -scalarrepl -S | FileCheck %s
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:32:32-n8:16:32"
4 target triple = "i386-pc-linux-gnu"
6 %nested = type { i32, [4 x i32] }
8 ; Check that a GEP with a non-zero first index does not prevent SROA as long
9 ; as the resulting offset corresponds to an element in the alloca.
13 ; CHECK: ret i32 undef
15 %B = getelementptr %nested* %A, i32 0, i32 1, i32 0
16 %C = getelementptr i32* %B, i32 2
21 ; But, if the offset is out of range, then it should not be transformed.
26 %B = getelementptr %nested* %A, i32 0, i32 1, i32 0
27 %C = getelementptr i32* %B, i32 4
32 ; Try it with a bitcast and single GEP....
36 ; CHECK: ret i32 undef
38 %B = bitcast %nested* %A to i32*
39 %C = getelementptr i32* %B, i32 2
44 ; ...and again make sure that out-of-range accesses are not transformed.
49 %B = bitcast %nested* %A to i32*
50 %C = getelementptr i32* %B, i32 -1