1*9880d681SAndroid Build Coastguard Worker; RUN: llc -verify-machineinstrs -mtriple=armv7-none-linux-gnueabi -mcpu=cortex-a9 -mattr=+neon,+neonfp -float-abi=hard < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Workerdefine <2 x float> @test_vmovs_via_vext_lane0to0(float %arg, <2 x float> %in) { 4*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_vmovs_via_vext_lane0to0: 5*9880d681SAndroid Build Coastguard Worker %vec = insertelement <2 x float> %in, float %arg, i32 0 6*9880d681SAndroid Build Coastguard Worker %res = fadd <2 x float> %vec, %vec 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Worker; CHECK: vext.32 d1, d1, d0, #1 9*9880d681SAndroid Build Coastguard Worker; CHECK: vext.32 d1, d1, d1, #1 10*9880d681SAndroid Build Coastguard Worker; CHECK: vadd.f32 {{d[0-9]+}}, d1, d1 11*9880d681SAndroid Build Coastguard Worker 12*9880d681SAndroid Build Coastguard Worker ret <2 x float> %res 13*9880d681SAndroid Build Coastguard Worker} 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Workerdefine <2 x float> @test_vmovs_via_vext_lane0to1(float %arg, <2 x float> %in) { 16*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_vmovs_via_vext_lane0to1: 17*9880d681SAndroid Build Coastguard Worker %vec = insertelement <2 x float> %in, float %arg, i32 1 18*9880d681SAndroid Build Coastguard Worker %res = fadd <2 x float> %vec, %vec 19*9880d681SAndroid Build Coastguard Worker 20*9880d681SAndroid Build Coastguard Worker; CHECK: vext.32 d1, d1, d1, #1 21*9880d681SAndroid Build Coastguard Worker; CHECK: vext.32 d1, d1, d0, #1 22*9880d681SAndroid Build Coastguard Worker; CHECK: vadd.f32 {{d[0-9]+}}, d1, d1 23*9880d681SAndroid Build Coastguard Worker 24*9880d681SAndroid Build Coastguard Worker ret <2 x float> %res 25*9880d681SAndroid Build Coastguard Worker} 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard Workerdefine <2 x float> @test_vmovs_via_vext_lane1to0(float, float %arg, <2 x float> %in) { 28*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_vmovs_via_vext_lane1to0: 29*9880d681SAndroid Build Coastguard Worker %vec = insertelement <2 x float> %in, float %arg, i32 0 30*9880d681SAndroid Build Coastguard Worker %res = fadd <2 x float> %vec, %vec 31*9880d681SAndroid Build Coastguard Worker 32*9880d681SAndroid Build Coastguard Worker; CHECK: vext.32 d1, d1, d1, #1 33*9880d681SAndroid Build Coastguard Worker; CHECK: vext.32 d1, d0, d1, #1 34*9880d681SAndroid Build Coastguard Worker; CHECK: vadd.f32 {{d[0-9]+}}, d1, d1 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker ret <2 x float> %res 37*9880d681SAndroid Build Coastguard Worker} 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Workerdefine <2 x float> @test_vmovs_via_vext_lane1to1(float, float %arg, <2 x float> %in) { 40*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_vmovs_via_vext_lane1to1: 41*9880d681SAndroid Build Coastguard Worker %vec = insertelement <2 x float> %in, float %arg, i32 1 42*9880d681SAndroid Build Coastguard Worker %res = fadd <2 x float> %vec, %vec 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard Worker; CHECK: vext.32 d1, d0, d1, #1 45*9880d681SAndroid Build Coastguard Worker; CHECK: vext.32 d1, d1, d1, #1 46*9880d681SAndroid Build Coastguard Worker; CHECK: vadd.f32 {{d[0-9]+}}, d1, d1 47*9880d681SAndroid Build Coastguard Worker 48*9880d681SAndroid Build Coastguard Worker ret <2 x float> %res 49*9880d681SAndroid Build Coastguard Worker} 50*9880d681SAndroid Build Coastguard Worker 51*9880d681SAndroid Build Coastguard Worker 52*9880d681SAndroid Build Coastguard Workerdefine float @test_vmovs_via_vdup(float, float %ret, float %lhs, float %rhs) { 53*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_vmovs_via_vdup: 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Worker ; Do an operation (which will end up NEON because of +neonfp) to convince the 56*9880d681SAndroid Build Coastguard Worker ; execution-domain pass that NEON is a good thing to use. 57*9880d681SAndroid Build Coastguard Worker %res = fadd float %ret, %ret 58*9880d681SAndroid Build Coastguard Worker ; It makes sense for LLVM to do the addition in d0 here, because it's going 59*9880d681SAndroid Build Coastguard Worker ; to be returned. This means it will want a "vmov s0, s1": 60*9880d681SAndroid Build Coastguard Worker; CHECK: vdup.32 d0, d0[1] 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard Worker ret float %res 63*9880d681SAndroid Build Coastguard Worker} 64*9880d681SAndroid Build Coastguard Worker 65*9880d681SAndroid Build Coastguard Workerdeclare float @llvm.sqrt.f32(float) 66*9880d681SAndroid Build Coastguard Worker 67*9880d681SAndroid Build Coastguard Workerdeclare void @bar() 68*9880d681SAndroid Build Coastguard Worker 69*9880d681SAndroid Build Coastguard Worker; This is a comp 70*9880d681SAndroid Build Coastguard Workerdefine float @test_ineligible(float, float %in) { 71*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_ineligible: 72*9880d681SAndroid Build Coastguard Worker 73*9880d681SAndroid Build Coastguard Worker %sqrt = call float @llvm.sqrt.f32(float %in) 74*9880d681SAndroid Build Coastguard Worker %val = fadd float %sqrt, %sqrt 75*9880d681SAndroid Build Coastguard Worker 76*9880d681SAndroid Build Coastguard Worker ; This call forces a move from a callee-saved register to the return-reg. That 77*9880d681SAndroid Build Coastguard Worker ; move is not eligible for conversion to a d-register instructions because the 78*9880d681SAndroid Build Coastguard Worker ; use-def chains would be messed up. Primarily a compile-test (we used to 79*9880d681SAndroid Build Coastguard Worker ; internal fault). 80*9880d681SAndroid Build Coastguard Worker call void @bar() 81*9880d681SAndroid Build Coastguard Worker; CHECK: bl bar 82*9880d681SAndroid Build Coastguard Worker; CHECK: vext.32 83*9880d681SAndroid Build Coastguard Worker; CHECK: vext.32 84*9880d681SAndroid Build Coastguard Worker ret float %val 85*9880d681SAndroid Build Coastguard Worker} 86*9880d681SAndroid Build Coastguard Worker 87*9880d681SAndroid Build Coastguard Workerdefine i32 @test_vmovs_no_sreg(i32 %in) { 88*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_vmovs_no_sreg: 89*9880d681SAndroid Build Coastguard Worker 90*9880d681SAndroid Build Coastguard Worker ; Check that the movement to and from GPRs takes place in the NEON domain. 91*9880d681SAndroid Build Coastguard Worker; CHECK: vmov.32 d 92*9880d681SAndroid Build Coastguard Worker %x = bitcast i32 %in to float 93*9880d681SAndroid Build Coastguard Worker 94*9880d681SAndroid Build Coastguard Worker %res = fadd float %x, %x 95*9880d681SAndroid Build Coastguard Worker 96*9880d681SAndroid Build Coastguard Worker; CHECK: vmov.32 r{{[0-9]+}}, d 97*9880d681SAndroid Build Coastguard Worker %resi = bitcast float %res to i32 98*9880d681SAndroid Build Coastguard Worker 99*9880d681SAndroid Build Coastguard Worker ret i32 %resi 100*9880d681SAndroid Build Coastguard Worker} 101*9880d681SAndroid Build Coastguard Worker 102*9880d681SAndroid Build Coastguard Worker 103*9880d681SAndroid Build Coastguard Worker; The point of this test is: 104*9880d681SAndroid Build Coastguard Worker; + Make sure s1 is live before the BL 105*9880d681SAndroid Build Coastguard Worker; + Make sure s1 is clobbered by the BL 106*9880d681SAndroid Build Coastguard Worker; + Convince LLVM to emit a VMOV to S0 107*9880d681SAndroid Build Coastguard Worker; + Convince LLVM to domain-convert this. 108*9880d681SAndroid Build Coastguard Worker 109*9880d681SAndroid Build Coastguard Worker; When all of those are satisfied, LLVM should *not* mark s1 as an implicit-use 110*9880d681SAndroid Build Coastguard Worker; because it's dead. 111*9880d681SAndroid Build Coastguard Worker 112*9880d681SAndroid Build Coastguard Workerdeclare float @clobbers_s1(float, float) 113*9880d681SAndroid Build Coastguard Worker 114*9880d681SAndroid Build Coastguard Workerdefine <2 x float> @test_clobbers_recognised(<2 x float> %invec, float %val) { 115*9880d681SAndroid Build Coastguard Worker %elt = call float @clobbers_s1(float %val, float %val) 116*9880d681SAndroid Build Coastguard Worker 117*9880d681SAndroid Build Coastguard Worker %vec = insertelement <2 x float> %invec, float %elt, i32 0 118*9880d681SAndroid Build Coastguard Worker %res = fadd <2 x float> %vec, %vec 119*9880d681SAndroid Build Coastguard Worker ret <2 x float> %res 120*9880d681SAndroid Build Coastguard Worker} 121