1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker;; GetMemInstArgs() folded the two getElementPtr instructions together, 4*9880d681SAndroid Build Coastguard Worker;; producing an illegal getElementPtr. That's because the type generated 5*9880d681SAndroid Build Coastguard Worker;; by the last index for the first one is a structure field, not an array 6*9880d681SAndroid Build Coastguard Worker;; element, and the second one indexes off that structure field. 7*9880d681SAndroid Build Coastguard Worker;; The code is legal but not type-safe and the two GEPs should not be folded. 8*9880d681SAndroid Build Coastguard Worker;; 9*9880d681SAndroid Build Coastguard Worker;; This code fragment is from Spec/CINT2000/197.parser/197.parser.bc, 10*9880d681SAndroid Build Coastguard Worker;; file post_process.c, function build_domain(). 11*9880d681SAndroid Build Coastguard Worker;; (Modified to replace store with load and return load value.) 12*9880d681SAndroid Build Coastguard Worker;; 13*9880d681SAndroid Build Coastguard Worker %Domain = type { i8*, i32, i32*, i32, i32, i32*, %Domain* } 14*9880d681SAndroid Build Coastguard Worker@domain_array = external global [497 x %Domain] ; <[497 x %Domain]*> [#uses=2] 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Workerdeclare void @opaque([497 x %Domain]*) 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Workerdefine i32 @main(i32 %argc, i8** %argv) { 19*9880d681SAndroid Build Coastguard Workerbb0: 20*9880d681SAndroid Build Coastguard Worker call void @opaque( [497 x %Domain]* @domain_array ) 21*9880d681SAndroid Build Coastguard Worker %cann-indvar-idxcast = sext i32 %argc to i64 ; <i64> [#uses=1] 22*9880d681SAndroid Build Coastguard Worker %reg841 = getelementptr [497 x %Domain], [497 x %Domain]* @domain_array, i64 0, i64 %cann-indvar-idxcast, i32 3 ; <i32*> [#uses=1] 23*9880d681SAndroid Build Coastguard Worker %reg846 = getelementptr i32, i32* %reg841, i64 1 ; <i32*> [#uses=1] 24*9880d681SAndroid Build Coastguard Worker %reg820 = load i32, i32* %reg846 ; <i32> [#uses=1] 25*9880d681SAndroid Build Coastguard Worker ret i32 %reg820 26*9880d681SAndroid Build Coastguard Worker} 27*9880d681SAndroid Build Coastguard Worker 28