2015-07-14 11:07:06 +08:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-darwin | FileCheck %s
|
2012-08-12 07:47:06 +08:00
|
|
|
|
2015-07-14 10:08:23 +08:00
|
|
|
; CHECK-LABEL: LCPI0_0:
|
|
|
|
; CHECK-NEXT: .long 4286578688
|
|
|
|
; CHECK-LABEL: LCPI0_1:
|
|
|
|
; CHECK-NEXT: .long 2139095040
|
|
|
|
|
|
|
|
; CHECK-LABEL: foo:
|
LegalizeDAG: Fix and improve FCOPYSIGN/FABS legalization
- Factor out code to query and modify the sign bit of a floatingpoint
value as an integer. This also works if none of the targets integer
types is big enough to hold all bits of the floatingpoint value.
- Legalize FABS(x) as FCOPYSIGN(x, 0.0) if FCOPYSIGN is available,
otherwise perform bit manipulation on the sign bit. The previous code
used "x >u 0 ? x : -x" which is incorrect for x being -0.0! It also
takes 34 instructions on ARM Cortex-M4. With this patch we only
require 5:
vldr d0, LCPI0_0
vmov r2, r3, d0
lsrs r2, r3, #31
bfi r1, r2, #31, #1
bx lr
(This could be further improved if the compiler would recognize that
r2, r3 is zero).
- Only lower FCOPYSIGN(x, y) = sign(x) ? -FABS(x) : FABS(x) if FABS is
available otherwise perform bit manipulation on the sign bit.
- Perform the sign(x) test by masking out the sign bit and comparing
with 0 rather than shifting the sign bit to the highest position and
testing for "<s 0". For x86 copysignl (on 80bit values) this gets us:
testl $32768, %eax
rather than:
shlq $48, %rax
sets %al
testb %al, %al
Differential Revision: http://reviews.llvm.org/D11172
llvm-svn: 252839
2015-11-12 09:02:47 +08:00
|
|
|
; CHECK: testb $-128, -15(%rsp)
|
2015-07-14 10:08:23 +08:00
|
|
|
; CHECK: flds LCPI0_0(%rip)
|
|
|
|
; CHECK: flds LCPI0_1(%rip)
|
|
|
|
; CHECK: fcmovne %st(1), %st(0)
|
|
|
|
; CHECK: fstp %st(1)
|
|
|
|
; CHECK: retq
|
2012-08-12 07:47:06 +08:00
|
|
|
define x86_fp80 @foo(x86_fp80 %a) {
|
|
|
|
%1 = tail call x86_fp80 @copysignl(x86_fp80 0xK7FFF8000000000000000, x86_fp80 %a) nounwind readnone
|
|
|
|
ret x86_fp80 %1
|
|
|
|
}
|
|
|
|
|
|
|
|
declare x86_fp80 @copysignl(x86_fp80, x86_fp80) nounwind readnone
|