forked from OSchip/llvm-project
[FastISel] Don't transform FSUB(-0, X) -> FNEG(X) in FastISel
This corresponds with the SelectionDAGISel change in D84056. Also, rename some poorly named tests in CodeGen/X86/fast-isel-fneg.ll with NFC. Differential Revision: https://reviews.llvm.org/D85149
This commit is contained in:
parent
6d218b4adb
commit
0f2b47b6da
|
@ -1845,13 +1845,8 @@ bool FastISel::selectOperator(const User *I, unsigned Opcode) {
|
||||||
return selectBinaryOp(I, ISD::FADD);
|
return selectBinaryOp(I, ISD::FADD);
|
||||||
case Instruction::Sub:
|
case Instruction::Sub:
|
||||||
return selectBinaryOp(I, ISD::SUB);
|
return selectBinaryOp(I, ISD::SUB);
|
||||||
case Instruction::FSub: {
|
case Instruction::FSub:
|
||||||
// FNeg is currently represented in LLVM IR as a special case of FSub.
|
|
||||||
Value *X;
|
|
||||||
if (match(I, m_FNeg(m_Value(X))))
|
|
||||||
return selectFNeg(I, X);
|
|
||||||
return selectBinaryOp(I, ISD::FSUB);
|
return selectBinaryOp(I, ISD::FSUB);
|
||||||
}
|
|
||||||
case Instruction::Mul:
|
case Instruction::Mul:
|
||||||
return selectBinaryOp(I, ISD::MUL);
|
return selectBinaryOp(I, ISD::MUL);
|
||||||
case Instruction::FMul:
|
case Instruction::FMul:
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
||||||
; RUN: llc < %s -fast-isel -fast-isel-abort=3 -mtriple=x86_64-apple-darwin10 -stop-after=finalize-isel | FileCheck %s
|
|
||||||
|
|
||||||
; Make sure we output the right kill flag for the xor conversion.
|
|
||||||
|
|
||||||
define void @goo(double* %x, double* %y) nounwind {
|
|
||||||
; CHECK: %[[REG2:.*]]:gr64 = COPY $rsi
|
|
||||||
; CHECK-NEXT: %[[REG0:.*]]:gr64 = COPY $rdi
|
|
||||||
; CHECK-NEXT: %[[REG1:.*]]:gr64 = COPY killed %[[REG0]]
|
|
||||||
; CHECK-NEXT: %[[REG3:.*]]:gr64 = COPY killed %[[REG2]]
|
|
||||||
; CHECK-NEXT: %[[REG10:.*]]:fr64 = MOVSDrm_alt %[[REG1]], 1, $noreg, 0, $noreg :: (load 8 from %ir.x)
|
|
||||||
; CHECK-NEXT: %[[REG6:.*]]:gr64 = MOVSDto64rr killed %[[REG10]]
|
|
||||||
; CHECK-NEXT: %[[REG7:.*]]:gr64 = MOV64ri -9223372036854775808
|
|
||||||
; CHECK-NEXT: %[[REG8:.*]]:gr64 = XOR64rr killed %[[REG6]], killed %[[REG7]], implicit-def $eflags
|
|
||||||
; CHECK-NEXT: %[[REG9:.*]]:fr64 = MOV64toSDrr killed %[[REG8]]
|
|
||||||
; CHECK-NEXT: MOVSDmr %[[REG3]], 1, $noreg, 0, $noreg, killed %[[REG9]] :: (store 8 into %ir.y)
|
|
||||||
; CHECK-NEXT: RETQ
|
|
||||||
%a = load double, double* %x
|
|
||||||
%b = fsub double -0.0, %a
|
|
||||||
store double %b, double* %y
|
|
||||||
ret void
|
|
||||||
}
|
|
|
@ -2,8 +2,8 @@
|
||||||
; RUN: llc < %s -fast-isel -fast-isel-abort=3 -mtriple=x86_64-apple-darwin10 | FileCheck %s
|
; RUN: llc < %s -fast-isel -fast-isel-abort=3 -mtriple=x86_64-apple-darwin10 | FileCheck %s
|
||||||
; RUN: llc < %s -fast-isel -mtriple=i686-- -mattr=+sse2 | FileCheck --check-prefix=SSE2 %s
|
; RUN: llc < %s -fast-isel -mtriple=i686-- -mattr=+sse2 | FileCheck --check-prefix=SSE2 %s
|
||||||
|
|
||||||
define double @doo(double %x) nounwind {
|
define double @fneg_f64(double %x) nounwind {
|
||||||
; CHECK-LABEL: doo:
|
; CHECK-LABEL: fneg_f64:
|
||||||
; CHECK: ## %bb.0:
|
; CHECK: ## %bb.0:
|
||||||
; CHECK-NEXT: movq %xmm0, %rax
|
; CHECK-NEXT: movq %xmm0, %rax
|
||||||
; CHECK-NEXT: movabsq $-9223372036854775808, %rcx ## imm = 0x8000000000000000
|
; CHECK-NEXT: movabsq $-9223372036854775808, %rcx ## imm = 0x8000000000000000
|
||||||
|
@ -11,105 +11,7 @@ define double @doo(double %x) nounwind {
|
||||||
; CHECK-NEXT: movq %rcx, %xmm0
|
; CHECK-NEXT: movq %rcx, %xmm0
|
||||||
; CHECK-NEXT: retq
|
; CHECK-NEXT: retq
|
||||||
;
|
;
|
||||||
; SSE2-LABEL: doo:
|
; SSE2-LABEL: fneg_f64:
|
||||||
; SSE2: # %bb.0:
|
|
||||||
; SSE2-NEXT: pushl %ebp
|
|
||||||
; SSE2-NEXT: movl %esp, %ebp
|
|
||||||
; SSE2-NEXT: andl $-8, %esp
|
|
||||||
; SSE2-NEXT: subl $8, %esp
|
|
||||||
; SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
|
|
||||||
; SSE2-NEXT: xorps {{\.LCPI.*}}, %xmm0
|
|
||||||
; SSE2-NEXT: movlps %xmm0, (%esp)
|
|
||||||
; SSE2-NEXT: fldl (%esp)
|
|
||||||
; SSE2-NEXT: movl %ebp, %esp
|
|
||||||
; SSE2-NEXT: popl %ebp
|
|
||||||
; SSE2-NEXT: retl
|
|
||||||
%y = fsub double -0.0, %x
|
|
||||||
ret double %y
|
|
||||||
}
|
|
||||||
|
|
||||||
define float @foo(float %x) nounwind {
|
|
||||||
; CHECK-LABEL: foo:
|
|
||||||
; CHECK: ## %bb.0:
|
|
||||||
; CHECK-NEXT: movd %xmm0, %eax
|
|
||||||
; CHECK-NEXT: xorl $2147483648, %eax ## imm = 0x80000000
|
|
||||||
; CHECK-NEXT: movd %eax, %xmm0
|
|
||||||
; CHECK-NEXT: retq
|
|
||||||
;
|
|
||||||
; SSE2-LABEL: foo:
|
|
||||||
; SSE2: # %bb.0:
|
|
||||||
; SSE2-NEXT: pushl %eax
|
|
||||||
; SSE2-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
|
||||||
; SSE2-NEXT: xorps {{\.LCPI.*}}, %xmm0
|
|
||||||
; SSE2-NEXT: movss %xmm0, (%esp)
|
|
||||||
; SSE2-NEXT: flds (%esp)
|
|
||||||
; SSE2-NEXT: popl %eax
|
|
||||||
; SSE2-NEXT: retl
|
|
||||||
%y = fsub float -0.0, %x
|
|
||||||
ret float %y
|
|
||||||
}
|
|
||||||
|
|
||||||
define void @goo(double* %x, double* %y) nounwind {
|
|
||||||
; CHECK-LABEL: goo:
|
|
||||||
; CHECK: ## %bb.0:
|
|
||||||
; CHECK-NEXT: movq {{.*#+}} xmm0 = mem[0],zero
|
|
||||||
; CHECK-NEXT: movq %xmm0, %rax
|
|
||||||
; CHECK-NEXT: movabsq $-9223372036854775808, %rcx ## imm = 0x8000000000000000
|
|
||||||
; CHECK-NEXT: xorq %rax, %rcx
|
|
||||||
; CHECK-NEXT: movq %rcx, %xmm0
|
|
||||||
; CHECK-NEXT: movq %xmm0, (%rsi)
|
|
||||||
; CHECK-NEXT: retq
|
|
||||||
;
|
|
||||||
; SSE2-LABEL: goo:
|
|
||||||
; SSE2: # %bb.0:
|
|
||||||
; SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
||||||
; SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
|
||||||
; SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
|
|
||||||
; SSE2-NEXT: xorps {{\.LCPI.*}}, %xmm0
|
|
||||||
; SSE2-NEXT: movsd %xmm0, (%eax)
|
|
||||||
; SSE2-NEXT: retl
|
|
||||||
%a = load double, double* %x
|
|
||||||
%b = fsub double -0.0, %a
|
|
||||||
store double %b, double* %y
|
|
||||||
ret void
|
|
||||||
}
|
|
||||||
|
|
||||||
define void @loo(float* %x, float* %y) nounwind {
|
|
||||||
; CHECK-LABEL: loo:
|
|
||||||
; CHECK: ## %bb.0:
|
|
||||||
; CHECK-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
|
||||||
; CHECK-NEXT: movd %xmm0, %eax
|
|
||||||
; CHECK-NEXT: xorl $2147483648, %eax ## imm = 0x80000000
|
|
||||||
; CHECK-NEXT: movd %eax, %xmm0
|
|
||||||
; CHECK-NEXT: movd %xmm0, (%rsi)
|
|
||||||
; CHECK-NEXT: retq
|
|
||||||
;
|
|
||||||
; SSE2-LABEL: loo:
|
|
||||||
; SSE2: # %bb.0:
|
|
||||||
; SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
||||||
; SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
|
||||||
; SSE2-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
|
||||||
; SSE2-NEXT: movd %xmm0, %ecx
|
|
||||||
; SSE2-NEXT: xorl $2147483648, %ecx # imm = 0x80000000
|
|
||||||
; SSE2-NEXT: movd %ecx, %xmm0
|
|
||||||
; SSE2-NEXT: movd %xmm0, (%eax)
|
|
||||||
; SSE2-NEXT: retl
|
|
||||||
%a = load float, float* %x
|
|
||||||
%b = fsub float -0.0, %a
|
|
||||||
store float %b, float* %y
|
|
||||||
ret void
|
|
||||||
}
|
|
||||||
|
|
||||||
define double @too(double %x) nounwind {
|
|
||||||
; CHECK-LABEL: too:
|
|
||||||
; CHECK: ## %bb.0:
|
|
||||||
; CHECK-NEXT: movq %xmm0, %rax
|
|
||||||
; CHECK-NEXT: movabsq $-9223372036854775808, %rcx ## imm = 0x8000000000000000
|
|
||||||
; CHECK-NEXT: xorq %rax, %rcx
|
|
||||||
; CHECK-NEXT: movq %rcx, %xmm0
|
|
||||||
; CHECK-NEXT: retq
|
|
||||||
;
|
|
||||||
; SSE2-LABEL: too:
|
|
||||||
; SSE2: # %bb.0:
|
; SSE2: # %bb.0:
|
||||||
; SSE2-NEXT: pushl %ebp
|
; SSE2-NEXT: pushl %ebp
|
||||||
; SSE2-NEXT: movl %esp, %ebp
|
; SSE2-NEXT: movl %esp, %ebp
|
||||||
|
@ -126,15 +28,15 @@ define double @too(double %x) nounwind {
|
||||||
ret double %y
|
ret double %y
|
||||||
}
|
}
|
||||||
|
|
||||||
define float @zoo(float %x) nounwind {
|
define float @fneg_f32(float %x) nounwind {
|
||||||
; CHECK-LABEL: zoo:
|
; CHECK-LABEL: fneg_f32:
|
||||||
; CHECK: ## %bb.0:
|
; CHECK: ## %bb.0:
|
||||||
; CHECK-NEXT: movd %xmm0, %eax
|
; CHECK-NEXT: movd %xmm0, %eax
|
||||||
; CHECK-NEXT: xorl $2147483648, %eax ## imm = 0x80000000
|
; CHECK-NEXT: xorl $2147483648, %eax ## imm = 0x80000000
|
||||||
; CHECK-NEXT: movd %eax, %xmm0
|
; CHECK-NEXT: movd %eax, %xmm0
|
||||||
; CHECK-NEXT: retq
|
; CHECK-NEXT: retq
|
||||||
;
|
;
|
||||||
; SSE2-LABEL: zoo:
|
; SSE2-LABEL: fneg_f32:
|
||||||
; SSE2: # %bb.0:
|
; SSE2: # %bb.0:
|
||||||
; SSE2-NEXT: pushl %eax
|
; SSE2-NEXT: pushl %eax
|
||||||
; SSE2-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
; SSE2-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
||||||
|
@ -146,3 +48,54 @@ define float @zoo(float %x) nounwind {
|
||||||
%y = fneg float %x
|
%y = fneg float %x
|
||||||
ret float %y
|
ret float %y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define void @fneg_f64_mem(double* %x, double* %y) nounwind {
|
||||||
|
; CHECK-LABEL: fneg_f64_mem:
|
||||||
|
; CHECK: ## %bb.0:
|
||||||
|
; CHECK-NEXT: movq {{.*#+}} xmm0 = mem[0],zero
|
||||||
|
; CHECK-NEXT: movq %xmm0, %rax
|
||||||
|
; CHECK-NEXT: movabsq $-9223372036854775808, %rcx ## imm = 0x8000000000000000
|
||||||
|
; CHECK-NEXT: xorq %rax, %rcx
|
||||||
|
; CHECK-NEXT: movq %rcx, %xmm0
|
||||||
|
; CHECK-NEXT: movq %xmm0, (%rsi)
|
||||||
|
; CHECK-NEXT: retq
|
||||||
|
;
|
||||||
|
; SSE2-LABEL: fneg_f64_mem:
|
||||||
|
; SSE2: # %bb.0:
|
||||||
|
; SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
|
||||||
|
; SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
||||||
|
; SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
|
||||||
|
; SSE2-NEXT: xorps {{\.LCPI.*}}, %xmm0
|
||||||
|
; SSE2-NEXT: movsd %xmm0, (%eax)
|
||||||
|
; SSE2-NEXT: retl
|
||||||
|
%a = load double, double* %x
|
||||||
|
%b = fneg double %a
|
||||||
|
store double %b, double* %y
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @fneg_f32_mem(float* %x, float* %y) nounwind {
|
||||||
|
; CHECK-LABEL: fneg_f32_mem:
|
||||||
|
; CHECK: ## %bb.0:
|
||||||
|
; CHECK-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
||||||
|
; CHECK-NEXT: movd %xmm0, %eax
|
||||||
|
; CHECK-NEXT: xorl $2147483648, %eax ## imm = 0x80000000
|
||||||
|
; CHECK-NEXT: movd %eax, %xmm0
|
||||||
|
; CHECK-NEXT: movd %xmm0, (%rsi)
|
||||||
|
; CHECK-NEXT: retq
|
||||||
|
;
|
||||||
|
; SSE2-LABEL: fneg_f32_mem:
|
||||||
|
; SSE2: # %bb.0:
|
||||||
|
; SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
|
||||||
|
; SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
||||||
|
; SSE2-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
||||||
|
; SSE2-NEXT: movd %xmm0, %ecx
|
||||||
|
; SSE2-NEXT: xorl $2147483648, %ecx # imm = 0x80000000
|
||||||
|
; SSE2-NEXT: movd %ecx, %xmm0
|
||||||
|
; SSE2-NEXT: movd %xmm0, (%eax)
|
||||||
|
; SSE2-NEXT: retl
|
||||||
|
%a = load float, float* %x
|
||||||
|
%b = fneg float %a
|
||||||
|
store float %b, float* %y
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue