1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=armv7-apple-ios6.0 | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=thumbv7-apple-ios6.0 | FileCheck %s 3*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=armv7-unknown-nacl-gnueabi | FileCheck %s -check-prefix=NACL 4*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=armv5-none-linux-gnueabi | FileCheck %s -check-prefix=NOMOVT 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker; NOMOVT-NOT: movt 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Worker; rdar://9877866 9*9880d681SAndroid Build Coastguard Worker%struct.SmallStruct = type { i32, [8 x i32], [37 x i8] } 10*9880d681SAndroid Build Coastguard Worker%struct.LargeStruct = type { i32, [1001 x i8], [300 x i32] } 11*9880d681SAndroid Build Coastguard Worker 12*9880d681SAndroid Build Coastguard Workerdefine i32 @f() nounwind ssp { 13*9880d681SAndroid Build Coastguard Workerentry: 14*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f: 15*9880d681SAndroid Build Coastguard Worker; CHECK: ldr 16*9880d681SAndroid Build Coastguard Worker; CHECK: str 17*9880d681SAndroid Build Coastguard Worker; CHECK-NOT:bne 18*9880d681SAndroid Build Coastguard Worker %st = alloca %struct.SmallStruct, align 4 19*9880d681SAndroid Build Coastguard Worker %call = call i32 @e1(%struct.SmallStruct* byval %st) 20*9880d681SAndroid Build Coastguard Worker ret i32 0 21*9880d681SAndroid Build Coastguard Worker} 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Worker; Generate a loop for large struct byval 24*9880d681SAndroid Build Coastguard Workerdefine i32 @g() nounwind ssp { 25*9880d681SAndroid Build Coastguard Workerentry: 26*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: g: 27*9880d681SAndroid Build Coastguard Worker; CHECK: ldr 28*9880d681SAndroid Build Coastguard Worker; CHECK: sub 29*9880d681SAndroid Build Coastguard Worker; CHECK: str 30*9880d681SAndroid Build Coastguard Worker; CHECK: bne 31*9880d681SAndroid Build Coastguard Worker; NACL-LABEL: g: 32*9880d681SAndroid Build Coastguard Worker; Ensure that use movw instead of constpool for the loop trip count. But don't 33*9880d681SAndroid Build Coastguard Worker; match the __stack_chk_guard movw 34*9880d681SAndroid Build Coastguard Worker; NACL: movw r{{[1-9]}}, # 35*9880d681SAndroid Build Coastguard Worker; NACL: ldr 36*9880d681SAndroid Build Coastguard Worker; NACL: sub 37*9880d681SAndroid Build Coastguard Worker; NACL: str 38*9880d681SAndroid Build Coastguard Worker; NACL: bne 39*9880d681SAndroid Build Coastguard Worker %st = alloca %struct.LargeStruct, align 4 40*9880d681SAndroid Build Coastguard Worker %call = call i32 @e2(%struct.LargeStruct* byval %st) 41*9880d681SAndroid Build Coastguard Worker ret i32 0 42*9880d681SAndroid Build Coastguard Worker} 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard Worker; Generate a loop using NEON instructions 45*9880d681SAndroid Build Coastguard Workerdefine i32 @h() nounwind ssp { 46*9880d681SAndroid Build Coastguard Workerentry: 47*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: h: 48*9880d681SAndroid Build Coastguard Worker; CHECK: vld1 49*9880d681SAndroid Build Coastguard Worker; CHECK: sub 50*9880d681SAndroid Build Coastguard Worker; CHECK: vst1 51*9880d681SAndroid Build Coastguard Worker; CHECK: bne 52*9880d681SAndroid Build Coastguard Worker; NACL: movw r{{[1-9]}}, # 53*9880d681SAndroid Build Coastguard Worker; NACL: vld1 54*9880d681SAndroid Build Coastguard Worker; NACL: sub 55*9880d681SAndroid Build Coastguard Worker; NACL: vst1 56*9880d681SAndroid Build Coastguard Worker; NACL: bne 57*9880d681SAndroid Build Coastguard Worker %st = alloca %struct.LargeStruct, align 16 58*9880d681SAndroid Build Coastguard Worker %call = call i32 @e3(%struct.LargeStruct* byval align 16 %st) 59*9880d681SAndroid Build Coastguard Worker ret i32 0 60*9880d681SAndroid Build Coastguard Worker} 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard Workerdeclare i32 @e1(%struct.SmallStruct* nocapture byval %in) nounwind 63*9880d681SAndroid Build Coastguard Workerdeclare i32 @e2(%struct.LargeStruct* nocapture byval %in) nounwind 64*9880d681SAndroid Build Coastguard Workerdeclare i32 @e3(%struct.LargeStruct* nocapture byval align 16 %in) nounwind 65*9880d681SAndroid Build Coastguard Worker 66*9880d681SAndroid Build Coastguard Worker; rdar://12442472 67*9880d681SAndroid Build Coastguard Worker; We can't do tail call since address of s is passed to the callee and part of 68*9880d681SAndroid Build Coastguard Worker; s is in caller's local frame. 69*9880d681SAndroid Build Coastguard Workerdefine void @f3(%struct.SmallStruct* nocapture byval %s) nounwind optsize { 70*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f3 71*9880d681SAndroid Build Coastguard Worker; CHECK: bl _consumestruct 72*9880d681SAndroid Build Coastguard Workerentry: 73*9880d681SAndroid Build Coastguard Worker %0 = bitcast %struct.SmallStruct* %s to i8* 74*9880d681SAndroid Build Coastguard Worker tail call void @consumestruct(i8* %0, i32 80) optsize 75*9880d681SAndroid Build Coastguard Worker ret void 76*9880d681SAndroid Build Coastguard Worker} 77*9880d681SAndroid Build Coastguard Worker 78*9880d681SAndroid Build Coastguard Workerdefine void @f4(%struct.SmallStruct* nocapture byval %s) nounwind optsize { 79*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f4 80*9880d681SAndroid Build Coastguard Worker; CHECK: bl _consumestruct 81*9880d681SAndroid Build Coastguard Workerentry: 82*9880d681SAndroid Build Coastguard Worker %addr = getelementptr inbounds %struct.SmallStruct, %struct.SmallStruct* %s, i32 0, i32 0 83*9880d681SAndroid Build Coastguard Worker %0 = bitcast i32* %addr to i8* 84*9880d681SAndroid Build Coastguard Worker tail call void @consumestruct(i8* %0, i32 80) optsize 85*9880d681SAndroid Build Coastguard Worker ret void 86*9880d681SAndroid Build Coastguard Worker} 87*9880d681SAndroid Build Coastguard Worker 88*9880d681SAndroid Build Coastguard Worker; We can do tail call here since s is in the incoming argument area. 89*9880d681SAndroid Build Coastguard Workerdefine void @f5(i32 %a, i32 %b, i32 %c, i32 %d, %struct.SmallStruct* nocapture byval %s) nounwind optsize { 90*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f5 91*9880d681SAndroid Build Coastguard Worker; CHECK: b{{(\.w)?}} _consumestruct 92*9880d681SAndroid Build Coastguard Workerentry: 93*9880d681SAndroid Build Coastguard Worker %0 = bitcast %struct.SmallStruct* %s to i8* 94*9880d681SAndroid Build Coastguard Worker tail call void @consumestruct(i8* %0, i32 80) optsize 95*9880d681SAndroid Build Coastguard Worker ret void 96*9880d681SAndroid Build Coastguard Worker} 97*9880d681SAndroid Build Coastguard Worker 98*9880d681SAndroid Build Coastguard Workerdefine void @f6(i32 %a, i32 %b, i32 %c, i32 %d, %struct.SmallStruct* nocapture byval %s) nounwind optsize { 99*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f6 100*9880d681SAndroid Build Coastguard Worker; CHECK: b{{(\.w)?}} _consumestruct 101*9880d681SAndroid Build Coastguard Workerentry: 102*9880d681SAndroid Build Coastguard Worker %addr = getelementptr inbounds %struct.SmallStruct, %struct.SmallStruct* %s, i32 0, i32 0 103*9880d681SAndroid Build Coastguard Worker %0 = bitcast i32* %addr to i8* 104*9880d681SAndroid Build Coastguard Worker tail call void @consumestruct(i8* %0, i32 80) optsize 105*9880d681SAndroid Build Coastguard Worker ret void 106*9880d681SAndroid Build Coastguard Worker} 107*9880d681SAndroid Build Coastguard Worker 108*9880d681SAndroid Build Coastguard Workerdeclare void @consumestruct(i8* nocapture %structp, i32 %structsize) nounwind 109*9880d681SAndroid Build Coastguard Worker 110*9880d681SAndroid Build Coastguard Worker; PR17309 111*9880d681SAndroid Build Coastguard Worker%struct.I.8 = type { [10 x i32], [3 x i8] } 112*9880d681SAndroid Build Coastguard Worker 113*9880d681SAndroid Build Coastguard Workerdeclare void @use_I(%struct.I.8* byval) 114*9880d681SAndroid Build Coastguard Workerdefine void @test_I_16() { 115*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_I_16 116*9880d681SAndroid Build Coastguard Worker; CHECK: ldrb 117*9880d681SAndroid Build Coastguard Worker; CHECK: strb 118*9880d681SAndroid Build Coastguard Workerentry: 119*9880d681SAndroid Build Coastguard Worker call void @use_I(%struct.I.8* byval align 16 undef) 120*9880d681SAndroid Build Coastguard Worker ret void 121*9880d681SAndroid Build Coastguard Worker} 122