File: vec_fneg.ll

package info (click to toggle)
llvm-toolchain-3.8 1%3A3.8.1-24
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 379,280 kB
  • ctags: 388,501
  • sloc: cpp: 2,309,705; ansic: 477,070; objc: 100,918; asm: 97,974; python: 95,911; sh: 18,634; makefile: 7,294; perl: 5,584; ml: 5,460; pascal: 4,661; lisp: 2,548; xml: 686; cs: 350; php: 212; csh: 117
file content (45 lines) | stat: -rw-r--r-- 1,636 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=sse | FileCheck %s

; FNEG is defined as subtraction from -0.0.

; This test verifies that we use an xor with a constant to flip the sign bits; no subtraction needed.
define <4 x float> @t1(<4 x float> %Q) {
; CHECK-LABEL: t1:
; CHECK: xorps	{{.*}}LCPI0_0{{.*}}, %xmm0
; CHECK-NEXT: retq
        %tmp = fsub <4 x float> < float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00 >, %Q
	ret <4 x float> %tmp
}

; This test verifies that we generate an FP subtraction because "0.0 - x" is not an fneg.
define <4 x float> @t2(<4 x float> %Q) {
; CHECK-LABEL: t2:
; CHECK: xorps	%[[X:xmm[0-9]+]], %[[X]]
; CHECK-NEXT: subps	%xmm0, %[[X]]
; CHECK-NEXT: movaps	%[[X]], %xmm0
; CHECK-NEXT: retq
        %tmp = fsub <4 x float> zeroinitializer, %Q
	ret <4 x float> %tmp
}

; If we're bitcasting an integer to an FP vector, we should avoid the FPU/vector unit entirely.
; Make sure that we're flipping the sign bit and only the sign bit of each float.
; So instead of something like this:
;    movd	%rdi, %xmm0
;    xorps	.LCPI2_0(%rip), %xmm0
;
; We should generate:
;    movabsq     (put sign bit mask in integer register))
;    xorq        (flip sign bits)
;    movd        (move to xmm return register) 

define <2 x float> @fneg_bitcast(i64 %i) {
; CHECK-LABEL: fneg_bitcast:
; CHECK:	movabsq	$-9223372034707292160, %rax # imm = 0x8000000080000000
; CHECK-NEXT:	xorq	%rdi, %rax
; CHECK-NEXT:	movd	%rax, %xmm0
; CHECK-NEXT:	retq
  %bitcast = bitcast i64 %i to <2 x float>
  %fneg = fsub <2 x float> <float -0.0, float -0.0>, %bitcast
  ret <2 x float> %fneg
}