https://llvm.org/bugs/show_bug.cgi?id=24366
Bug ID: 24366
Summary: [x86, FMA] use FMA instructions for negation instead
of loading a constant and xor'ing?
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
With the addition of FMA instructions, x86 can negate FP values without loading
a constant:
$ cat nmul.ll
define float @nmul(float %a, float %b) {
%mul = fmul float %a, %b
%neg = fsub float -0.0, %mul
ret float %neg
}
$ ./llc -o - nmul.ll -mattr=fma
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 14, 4
.section __TEXT,__literal16,16byte_literals
.align 4
LCPI0_0:
.long 2147483648 ## 0x80000000
.long 2147483648 ## 0x80000000
.long 2147483648 ## 0x80000000
.long 2147483648 ## 0x80000000
.section __TEXT,__text,regular,pure_instructions
.globl _nmul
.align 4, 0x90
_nmul: ## @nmul
.cfi_startproc
## BB#0:
vmulss %xmm1, %xmm0, %xmm0
vxorps LCPI0_0(%rip), %xmm0, %xmm0
retq
-------------------------------------------------------------------------------
Better speed/size, but does require a temp register:
vxorps %xmm2, %xmm2, %xmm2 <--- make zero cheaply for add operand
vfnmadd213ss %xmm2, %xmm1, %xmm0
I don't think this causes any IEEE-754 problems, but if it does, it should
still be possible to do this with -ffast-math?
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs