aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/X86/isel-fabs-x87.ll
blob: 5579754a54b46c081644e89f7d7689a1fbc77738 (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc < %s -mtriple=x86_64-- -mattr=+x87,-sse2,-sse | FileCheck %s --check-prefixes=X64,SDAG-X64-ISEL
; RUN: llc < %s -mtriple=x86_64-- -mattr=+x87,-sse2,-sse -fast-isel | FileCheck %s --check-prefixes=X64,FAST-X64-ISEL
; RUN: llc < %s -mtriple=x86_64-- -mattr=+x87,-sse2,-sse -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=X64,GISEL-X64-ISEL
; RUN: llc < %s -mtriple=i686-- -mattr=+x87,-sse2,-sse | FileCheck %s --check-prefixes=X86,SDAG-X86-ISEL
; RUN: llc < %s -mtriple=i686-- -mattr=+x87,-sse2,-sse -fast-isel | FileCheck %s --check-prefixes=X86,FAST-X86-ISEL
; RUN: llc < %s -mtriple=i686-- -mattr=+x87,-sse2,-sse -global-isel -global-isel-abort=0 | FileCheck %s --check-prefixes=X86,GISEL-X86-ISEL

define void @test_float_abs(ptr %argptr)   {
; SDAG-X64-ISEL-LABEL: test_float_abs:
; SDAG-X64-ISEL:       # %bb.0:
; SDAG-X64-ISEL-NEXT:    andb $127, 3(%rdi)
; SDAG-X64-ISEL-NEXT:    retq
;
; FAST-X64-ISEL-LABEL: test_float_abs:
; FAST-X64-ISEL:       # %bb.0:
; FAST-X64-ISEL-NEXT:    andb $127, 3(%rdi)
; FAST-X64-ISEL-NEXT:    retq
;
; GISEL-X64-ISEL-LABEL: test_float_abs:
; GISEL-X64-ISEL:       # %bb.0:
; GISEL-X64-ISEL-NEXT:    andl $2147483647, (%rdi) # imm = 0x7FFFFFFF
; GISEL-X64-ISEL-NEXT:    retq
;
; SDAG-X86-ISEL-LABEL: test_float_abs:
; SDAG-X86-ISEL:       # %bb.0:
; SDAG-X86-ISEL-NEXT:    movl {{[0-9]+}}(%esp), %eax
; SDAG-X86-ISEL-NEXT:    andb $127, 3(%eax)
; SDAG-X86-ISEL-NEXT:    retl
;
; FAST-X86-ISEL-LABEL: test_float_abs:
; FAST-X86-ISEL:       # %bb.0:
; FAST-X86-ISEL-NEXT:    movl {{[0-9]+}}(%esp), %eax
; FAST-X86-ISEL-NEXT:    andb $127, 3(%eax)
; FAST-X86-ISEL-NEXT:    retl
;
; GISEL-X86-ISEL-LABEL: test_float_abs:
; GISEL-X86-ISEL:       # %bb.0:
; GISEL-X86-ISEL-NEXT:    movl {{[0-9]+}}(%esp), %eax
; GISEL-X86-ISEL-NEXT:    andl $2147483647, (%eax) # imm = 0x7FFFFFFF
; GISEL-X86-ISEL-NEXT:    retl
     %arg = load  float, float* %argptr
     %abs = tail call float @llvm.fabs.f32(float %arg)
     store float %abs, ptr %argptr
     ret void
 }

define void @test_double_abs(ptr %argptr)  {
; SDAG-X64-ISEL-LABEL: test_double_abs:
; SDAG-X64-ISEL:       # %bb.0:
; SDAG-X64-ISEL-NEXT:    andb $127, 7(%rdi)
; SDAG-X64-ISEL-NEXT:    retq
;
; FAST-X64-ISEL-LABEL: test_double_abs:
; FAST-X64-ISEL:       # %bb.0:
; FAST-X64-ISEL-NEXT:    andb $127, 7(%rdi)
; FAST-X64-ISEL-NEXT:    retq
;
; GISEL-X64-ISEL-LABEL: test_double_abs:
; GISEL-X64-ISEL:       # %bb.0:
; GISEL-X64-ISEL-NEXT:    movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
; GISEL-X64-ISEL-NEXT:    andq %rax, (%rdi)
; GISEL-X64-ISEL-NEXT:    retq
;
; X86-LABEL: test_double_abs:
; X86:       # %bb.0:
; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
; X86-NEXT:    fldl (%eax)
; X86-NEXT:    fabs
; X86-NEXT:    fstpl (%eax)
; X86-NEXT:    retl
    %arg = load double, double* %argptr
    %abs = tail call double @llvm.fabs.f64(double %arg)
    store double %abs, double* %argptr
    ret void
}

define x86_fp80 @test_x86_fp80_abs(x86_fp80 %arg) {
; X64-LABEL: test_x86_fp80_abs:
; X64:       # %bb.0:
; X64-NEXT:    fldt {{[0-9]+}}(%rsp)
; X64-NEXT:    fabs
; X64-NEXT:    retq
;
; X86-LABEL: test_x86_fp80_abs:
; X86:       # %bb.0:
; X86-NEXT:    fldt {{[0-9]+}}(%esp)
; X86-NEXT:    fabs
; X86-NEXT:    retl
  %abs = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %arg)
  ret x86_fp80 %abs
}