Skip to content

Commit 3737e7e

Browse files
mahesh-attardemattarde
andauthored
[X86][GlobalIsel] add test for fabs isel (#142558)
G_FABS Test update for #136718 --------- Co-authored-by: mattarde <[email protected]>
1 parent df4199c commit 3737e7e

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc < %s -mtriple=x86_64-- -mattr=+x87,-sse2,-sse | FileCheck %s --check-prefixes=X64
3+
; RUN: llc < %s -mtriple=x86_64-- -mattr=+x87,-sse2,-sse -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X64
4+
; RUN: llc < %s -mtriple=i686-- -mattr=+x87,-sse2,-sse | FileCheck %s --check-prefixes=X86
5+
; RUN: llc < %s -mtriple=i686-- -mattr=+x87,-sse2,-sse -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X86
6+
7+
define x86_fp80 @test_x86_fp80_abs(x86_fp80 %arg) {
8+
; X64-LABEL: test_x86_fp80_abs:
9+
; X64: # %bb.0:
10+
; X64-NEXT: fldt {{[0-9]+}}(%rsp)
11+
; X64-NEXT: fabs
12+
; X64-NEXT: retq
13+
;
14+
; X86-LABEL: test_x86_fp80_abs:
15+
; X86: # %bb.0:
16+
; X86-NEXT: fldt {{[0-9]+}}(%esp)
17+
; X86-NEXT: fabs
18+
; X86-NEXT: retl
19+
%abs = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %arg)
20+
ret x86_fp80 %abs
21+
}

llvm/test/CodeGen/X86/isel-fabs.ll

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc < %s -mtriple=x86_64-- -mattr=-x87 | FileCheck %s --check-prefixes=X64
3+
; RUN: llc < %s -mtriple=x86_64-- -mattr=-x87 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X64
4+
; RUN: llc < %s -mtriple=i686-- -mattr=-x87 | FileCheck %s --check-prefixes=X86
5+
; RUN: llc < %s -mtriple=i686-- -mattr=-x87 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=FASTISEL-X86
6+
7+
8+
define float @test_float_abs(float %arg) {
9+
; X64-LABEL: test_float_abs:
10+
; X64: # %bb.0:
11+
; X64-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
12+
; X64-NEXT: retq
13+
;
14+
; X86-LABEL: test_float_abs:
15+
; X86: # %bb.0:
16+
; X86-NEXT: movl $2147483647, %eax # imm = 0x7FFFFFFF
17+
; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
18+
; X86-NEXT: retl
19+
;
20+
; FASTISEL-X86-LABEL: test_float_abs:
21+
; FASTISEL-X86: # %bb.0:
22+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
23+
; FASTISEL-X86-NEXT: andl $2147483647, %eax # imm = 0x7FFFFFFF
24+
; FASTISEL-X86-NEXT: retl
25+
%abs = tail call float @llvm.fabs.f32(float %arg)
26+
ret float %abs
27+
}
28+
29+
define double @test_double_abs(double %arg) {
30+
; X64-LABEL: test_double_abs:
31+
; X64: # %bb.0:
32+
; X64-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
33+
; X64-NEXT: retq
34+
;
35+
; X86-LABEL: test_double_abs:
36+
; X86: # %bb.0:
37+
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
38+
; X86-NEXT: movl $2147483647, %edx # imm = 0x7FFFFFFF
39+
; X86-NEXT: andl {{[0-9]+}}(%esp), %edx
40+
; X86-NEXT: retl
41+
;
42+
; FASTISEL-X86-LABEL: test_double_abs:
43+
; FASTISEL-X86: # %bb.0:
44+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %edx
45+
; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax
46+
; FASTISEL-X86-NEXT: andl $2147483647, %edx # imm = 0x7FFFFFFF
47+
; FASTISEL-X86-NEXT: retl
48+
%abs = tail call double @llvm.fabs.f64(double %arg)
49+
ret double %abs
50+
}

0 commit comments

Comments
 (0)