1*9880d681SAndroid Build Coastguard Worker; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=x86_64-apple-macosx10.6.6 -mattr=+sse4.1 | FileCheck %s 3*9880d681SAndroid Build Coastguard Worker 4*9880d681SAndroid Build Coastguard Worker%0 = type { double } 5*9880d681SAndroid Build Coastguard Worker%union.anon = type { float } 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard Workerdefine i32 @double_signbit(double %d1) nounwind uwtable readnone ssp { 8*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: double_signbit: 9*9880d681SAndroid Build Coastguard Worker; CHECK: ## BB#0: ## %entry 10*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movsd %xmm0, -{{[0-9]+}}(%rsp) 11*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movsd %xmm0, -{{[0-9]+}}(%rsp) 12*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movmskpd %xmm0, %eax 13*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: andl $1, %eax 14*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: retq 15*9880d681SAndroid Build Coastguard Workerentry: 16*9880d681SAndroid Build Coastguard Worker %__x.addr.i = alloca double, align 8 17*9880d681SAndroid Build Coastguard Worker %__u.i = alloca %0, align 8 18*9880d681SAndroid Build Coastguard Worker %0 = bitcast double* %__x.addr.i to i8* 19*9880d681SAndroid Build Coastguard Worker %1 = bitcast %0* %__u.i to i8* 20*9880d681SAndroid Build Coastguard Worker store double %d1, double* %__x.addr.i, align 8 21*9880d681SAndroid Build Coastguard Worker %__f.i = getelementptr inbounds %0, %0* %__u.i, i64 0, i32 0 22*9880d681SAndroid Build Coastguard Worker store double %d1, double* %__f.i, align 8 23*9880d681SAndroid Build Coastguard Worker %tmp = bitcast double %d1 to i64 24*9880d681SAndroid Build Coastguard Worker %tmp1 = lshr i64 %tmp, 63 25*9880d681SAndroid Build Coastguard Worker %shr.i = trunc i64 %tmp1 to i32 26*9880d681SAndroid Build Coastguard Worker ret i32 %shr.i 27*9880d681SAndroid Build Coastguard Worker} 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Workerdefine i32 @double_add_signbit(double %d1, double %d2) nounwind uwtable readnone ssp { 30*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: double_add_signbit: 31*9880d681SAndroid Build Coastguard Worker; CHECK: ## BB#0: ## %entry 32*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: addsd %xmm1, %xmm0 33*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movsd %xmm0, -{{[0-9]+}}(%rsp) 34*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movsd %xmm0, -{{[0-9]+}}(%rsp) 35*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movmskpd %xmm0, %eax 36*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: andl $1, %eax 37*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: retq 38*9880d681SAndroid Build Coastguard Workerentry: 39*9880d681SAndroid Build Coastguard Worker %__x.addr.i = alloca double, align 8 40*9880d681SAndroid Build Coastguard Worker %__u.i = alloca %0, align 8 41*9880d681SAndroid Build Coastguard Worker %add = fadd double %d1, %d2 42*9880d681SAndroid Build Coastguard Worker %0 = bitcast double* %__x.addr.i to i8* 43*9880d681SAndroid Build Coastguard Worker %1 = bitcast %0* %__u.i to i8* 44*9880d681SAndroid Build Coastguard Worker store double %add, double* %__x.addr.i, align 8 45*9880d681SAndroid Build Coastguard Worker %__f.i = getelementptr inbounds %0, %0* %__u.i, i64 0, i32 0 46*9880d681SAndroid Build Coastguard Worker store double %add, double* %__f.i, align 8 47*9880d681SAndroid Build Coastguard Worker %tmp = bitcast double %add to i64 48*9880d681SAndroid Build Coastguard Worker %tmp1 = lshr i64 %tmp, 63 49*9880d681SAndroid Build Coastguard Worker %shr.i = trunc i64 %tmp1 to i32 50*9880d681SAndroid Build Coastguard Worker ret i32 %shr.i 51*9880d681SAndroid Build Coastguard Worker} 52*9880d681SAndroid Build Coastguard Worker 53*9880d681SAndroid Build Coastguard Workerdefine i32 @float_signbit(float %f1) nounwind uwtable readnone ssp { 54*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: float_signbit: 55*9880d681SAndroid Build Coastguard Worker; CHECK: ## BB#0: ## %entry 56*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movss %xmm0, -{{[0-9]+}}(%rsp) 57*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movss %xmm0, -{{[0-9]+}}(%rsp) 58*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movmskps %xmm0, %eax 59*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: andl $1, %eax 60*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: retq 61*9880d681SAndroid Build Coastguard Workerentry: 62*9880d681SAndroid Build Coastguard Worker %__x.addr.i = alloca float, align 4 63*9880d681SAndroid Build Coastguard Worker %__u.i = alloca %union.anon, align 4 64*9880d681SAndroid Build Coastguard Worker %0 = bitcast float* %__x.addr.i to i8* 65*9880d681SAndroid Build Coastguard Worker %1 = bitcast %union.anon* %__u.i to i8* 66*9880d681SAndroid Build Coastguard Worker store float %f1, float* %__x.addr.i, align 4 67*9880d681SAndroid Build Coastguard Worker %__f.i = getelementptr inbounds %union.anon, %union.anon* %__u.i, i64 0, i32 0 68*9880d681SAndroid Build Coastguard Worker store float %f1, float* %__f.i, align 4 69*9880d681SAndroid Build Coastguard Worker %2 = bitcast float %f1 to i32 70*9880d681SAndroid Build Coastguard Worker %shr.i = lshr i32 %2, 31 71*9880d681SAndroid Build Coastguard Worker ret i32 %shr.i 72*9880d681SAndroid Build Coastguard Worker} 73*9880d681SAndroid Build Coastguard Worker 74*9880d681SAndroid Build Coastguard Workerdefine i32 @float_add_signbit(float %f1, float %f2) nounwind uwtable readnone ssp { 75*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: float_add_signbit: 76*9880d681SAndroid Build Coastguard Worker; CHECK: ## BB#0: ## %entry 77*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: addss %xmm1, %xmm0 78*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movss %xmm0, -{{[0-9]+}}(%rsp) 79*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movss %xmm0, -{{[0-9]+}}(%rsp) 80*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movmskps %xmm0, %eax 81*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: andl $1, %eax 82*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: retq 83*9880d681SAndroid Build Coastguard Workerentry: 84*9880d681SAndroid Build Coastguard Worker %__x.addr.i = alloca float, align 4 85*9880d681SAndroid Build Coastguard Worker %__u.i = alloca %union.anon, align 4 86*9880d681SAndroid Build Coastguard Worker %add = fadd float %f1, %f2 87*9880d681SAndroid Build Coastguard Worker %0 = bitcast float* %__x.addr.i to i8* 88*9880d681SAndroid Build Coastguard Worker %1 = bitcast %union.anon* %__u.i to i8* 89*9880d681SAndroid Build Coastguard Worker store float %add, float* %__x.addr.i, align 4 90*9880d681SAndroid Build Coastguard Worker %__f.i = getelementptr inbounds %union.anon, %union.anon* %__u.i, i64 0, i32 0 91*9880d681SAndroid Build Coastguard Worker store float %add, float* %__f.i, align 4 92*9880d681SAndroid Build Coastguard Worker %2 = bitcast float %add to i32 93*9880d681SAndroid Build Coastguard Worker %shr.i = lshr i32 %2, 31 94*9880d681SAndroid Build Coastguard Worker ret i32 %shr.i 95*9880d681SAndroid Build Coastguard Worker} 96*9880d681SAndroid Build Coastguard Worker 97*9880d681SAndroid Build Coastguard Worker; PR11570 98*9880d681SAndroid Build Coastguard Worker; FIXME: This should also use movmskps; we don't form the FGETSIGN node 99*9880d681SAndroid Build Coastguard Worker; in this case, though. 100*9880d681SAndroid Build Coastguard Workerdefine void @float_call_signbit(double %n) { 101*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: float_call_signbit: 102*9880d681SAndroid Build Coastguard Worker; CHECK: ## BB#0: ## %entry 103*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movd %xmm0, %rdi 104*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: shrq $63, %rdi 105*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ## kill: %EDI<def> %EDI<kill> %RDI<kill> 106*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: jmp _float_call_signbit_callee ## TAILCALL 107*9880d681SAndroid Build Coastguard Workerentry: 108*9880d681SAndroid Build Coastguard Worker %t0 = bitcast double %n to i64 109*9880d681SAndroid Build Coastguard Worker %tobool.i.i.i.i = icmp slt i64 %t0, 0 110*9880d681SAndroid Build Coastguard Worker tail call void @float_call_signbit_callee(i1 zeroext %tobool.i.i.i.i) 111*9880d681SAndroid Build Coastguard Worker ret void 112*9880d681SAndroid Build Coastguard Worker} 113*9880d681SAndroid Build Coastguard Workerdeclare void @float_call_signbit_callee(i1 zeroext) 114*9880d681SAndroid Build Coastguard Worker 115*9880d681SAndroid Build Coastguard Worker 116*9880d681SAndroid Build Coastguard Worker; rdar://10247336 117*9880d681SAndroid Build Coastguard Worker; movmskp{s|d} only set low 4/2 bits, high bits are known zero 118*9880d681SAndroid Build Coastguard Worker 119*9880d681SAndroid Build Coastguard Workerdefine i32 @t1(<4 x float> %x, i32* nocapture %indexTable) nounwind uwtable readonly ssp { 120*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: t1: 121*9880d681SAndroid Build Coastguard Worker; CHECK: ## BB#0: ## %entry 122*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movmskps %xmm0, %eax 123*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movl (%rdi,%rax,4), %eax 124*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: retq 125*9880d681SAndroid Build Coastguard Workerentry: 126*9880d681SAndroid Build Coastguard Worker %0 = tail call i32 @llvm.x86.sse.movmsk.ps(<4 x float> %x) nounwind 127*9880d681SAndroid Build Coastguard Worker %idxprom = sext i32 %0 to i64 128*9880d681SAndroid Build Coastguard Worker %arrayidx = getelementptr inbounds i32, i32* %indexTable, i64 %idxprom 129*9880d681SAndroid Build Coastguard Worker %1 = load i32, i32* %arrayidx, align 4 130*9880d681SAndroid Build Coastguard Worker ret i32 %1 131*9880d681SAndroid Build Coastguard Worker} 132*9880d681SAndroid Build Coastguard Worker 133*9880d681SAndroid Build Coastguard Workerdefine i32 @t2(<4 x float> %x, i32* nocapture %indexTable) nounwind uwtable readonly ssp { 134*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: t2: 135*9880d681SAndroid Build Coastguard Worker; CHECK: ## BB#0: ## %entry 136*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movmskpd %xmm0, %eax 137*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movl (%rdi,%rax,4), %eax 138*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: retq 139*9880d681SAndroid Build Coastguard Workerentry: 140*9880d681SAndroid Build Coastguard Worker %0 = bitcast <4 x float> %x to <2 x double> 141*9880d681SAndroid Build Coastguard Worker %1 = tail call i32 @llvm.x86.sse2.movmsk.pd(<2 x double> %0) nounwind 142*9880d681SAndroid Build Coastguard Worker %idxprom = sext i32 %1 to i64 143*9880d681SAndroid Build Coastguard Worker %arrayidx = getelementptr inbounds i32, i32* %indexTable, i64 %idxprom 144*9880d681SAndroid Build Coastguard Worker %2 = load i32, i32* %arrayidx, align 4 145*9880d681SAndroid Build Coastguard Worker ret i32 %2 146*9880d681SAndroid Build Coastguard Worker} 147*9880d681SAndroid Build Coastguard Worker 148*9880d681SAndroid Build Coastguard Workerdeclare i32 @llvm.x86.sse2.movmsk.pd(<2 x double>) nounwind readnone 149*9880d681SAndroid Build Coastguard Workerdeclare i32 @llvm.x86.sse.movmsk.ps(<4 x float>) nounwind readnone 150