From a48e736a2c09da0189b869ff3964148e6bb0be43 Mon Sep 17 00:00:00 2001 From: mattarde Date: Tue, 3 Jun 2025 00:53:15 -0700 Subject: [PATCH 1/4] add test for fabs isel --- llvm/test/CodeGen/X86/isel-fabs-x87.ll | 21 ++++++++++ llvm/test/CodeGen/X86/isel-fabs.ll | 53 ++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 llvm/test/CodeGen/X86/isel-fabs-x87.ll create mode 100644 llvm/test/CodeGen/X86/isel-fabs.ll diff --git a/llvm/test/CodeGen/X86/isel-fabs-x87.ll b/llvm/test/CodeGen/X86/isel-fabs-x87.ll new file mode 100644 index 0000000000000..f47ffb0df47e9 --- /dev/null +++ b/llvm/test/CodeGen/X86/isel-fabs-x87.ll @@ -0,0 +1,21 @@ +; 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 +; RUN: llc < %s -mtriple=x86_64-- -mattr=+x87,-sse2,-sse -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X64 +; RUN: llc < %s -mtriple=i686-- -mattr=+x87,-sse2,-sse | FileCheck %s --check-prefixes=X86 +; RUN: llc < %s -mtriple=i686-- -mattr=+x87,-sse2,-sse -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X86 + +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 +} \ No newline at end of file diff --git a/llvm/test/CodeGen/X86/isel-fabs.ll b/llvm/test/CodeGen/X86/isel-fabs.ll new file mode 100644 index 0000000000000..cfaedf82751b8 --- /dev/null +++ b/llvm/test/CodeGen/X86/isel-fabs.ll @@ -0,0 +1,53 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; RUN: llc < %s -mtriple=x86_64-- -mattr=-x87 | FileCheck %s --check-prefixes=X64 +; RUN: llc < %s -mtriple=x86_64-- -mattr=-x87 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X64,FASTISEL-X64 +; RUN: llc < %s -mtriple=i686-- -mattr=-x87 | FileCheck %s --check-prefixes=X86 +; RUN: llc < %s -mtriple=i686-- -mattr=-x87 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=FASTISEL-X86 + + +define float @test_float_abs(float %arg) { +; X64-LABEL: test_float_abs: +; X64: # %bb.0: +; X64-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0 +; X64-NEXT: retq +; +; X86-LABEL: test_float_abs: +; X86: # %bb.0: +; X86-NEXT: movl $2147483647, %eax # imm = 0x7FFFFFFF +; X86-NEXT: andl {{[0-9]+}}(%esp), %eax +; X86-NEXT: retl +; +; FASTISEL-X86-LABEL: test_float_abs: +; FASTISEL-X86: # %bb.0: +; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax +; FASTISEL-X86-NEXT: andl $2147483647, %eax # imm = 0x7FFFFFFF +; FASTISEL-X86-NEXT: retl + %abs = tail call float @llvm.fabs.f32(float %arg) + ret float %abs +} + +define double @test_double_abs(double %arg) { +; X64-LABEL: test_double_abs: +; X64: # %bb.0: +; X64-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0 +; X64-NEXT: retq +; +; X86-LABEL: test_double_abs: +; X86: # %bb.0: +; X86-NEXT: movl {{[0-9]+}}(%esp), %eax +; X86-NEXT: movl $2147483647, %edx # imm = 0x7FFFFFFF +; X86-NEXT: andl {{[0-9]+}}(%esp), %edx +; X86-NEXT: retl +; +; FASTISEL-X86-LABEL: test_double_abs: +; FASTISEL-X86: # %bb.0: +; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %edx +; FASTISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax +; FASTISEL-X86-NEXT: andl $2147483647, %edx # imm = 0x7FFFFFFF +; FASTISEL-X86-NEXT: retl + %abs = tail call double @llvm.fabs.f64(double %arg) + ret double %abs +} + +;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: +; FASTISEL-X64: {{.*}} \ No newline at end of file From b0403b78c1e76e9d1791f14f934575b3e88347ab Mon Sep 17 00:00:00 2001 From: mattarde Date: Tue, 3 Jun 2025 01:10:07 -0700 Subject: [PATCH 2/4] fix line brk --- llvm/test/CodeGen/X86/isel-fabs-x87.ll | 2 +- llvm/test/CodeGen/X86/isel-fabs.ll | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/test/CodeGen/X86/isel-fabs-x87.ll b/llvm/test/CodeGen/X86/isel-fabs-x87.ll index f47ffb0df47e9..8b846499946cc 100644 --- a/llvm/test/CodeGen/X86/isel-fabs-x87.ll +++ b/llvm/test/CodeGen/X86/isel-fabs-x87.ll @@ -18,4 +18,4 @@ define x86_fp80 @test_x86_fp80_abs(x86_fp80 %arg) { ; X86-NEXT: retl %abs = tail call x86_fp80 @llvm.fabs.f80(x86_fp80 %arg) ret x86_fp80 %abs -} \ No newline at end of file +} diff --git a/llvm/test/CodeGen/X86/isel-fabs.ll b/llvm/test/CodeGen/X86/isel-fabs.ll index cfaedf82751b8..1e0647ac4f40a 100644 --- a/llvm/test/CodeGen/X86/isel-fabs.ll +++ b/llvm/test/CodeGen/X86/isel-fabs.ll @@ -50,4 +50,4 @@ define double @test_double_abs(double %arg) { } ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: -; FASTISEL-X64: {{.*}} \ No newline at end of file +; FASTISEL-X64: {{.*}} From f8ef36185c88a5d27a3773f6659041597c11978d Mon Sep 17 00:00:00 2001 From: mattarde Date: Tue, 3 Jun 2025 01:12:08 -0700 Subject: [PATCH 3/4] fix line brk --- llvm/test/CodeGen/X86/isel-fabs.ll | 3 --- 1 file changed, 3 deletions(-) diff --git a/llvm/test/CodeGen/X86/isel-fabs.ll b/llvm/test/CodeGen/X86/isel-fabs.ll index 1e0647ac4f40a..8c31a991ed867 100644 --- a/llvm/test/CodeGen/X86/isel-fabs.ll +++ b/llvm/test/CodeGen/X86/isel-fabs.ll @@ -48,6 +48,3 @@ define double @test_double_abs(double %arg) { %abs = tail call double @llvm.fabs.f64(double %arg) ret double %abs } - -;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: -; FASTISEL-X64: {{.*}} From aac9050a7016d12c1ead8b5616aec8c689c939a9 Mon Sep 17 00:00:00 2001 From: mattarde Date: Wed, 4 Jun 2025 08:03:13 -0700 Subject: [PATCH 4/4] fix label --- llvm/test/CodeGen/X86/isel-fabs.ll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/test/CodeGen/X86/isel-fabs.ll b/llvm/test/CodeGen/X86/isel-fabs.ll index 8c31a991ed867..10bd5799280ad 100644 --- a/llvm/test/CodeGen/X86/isel-fabs.ll +++ b/llvm/test/CodeGen/X86/isel-fabs.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 ; RUN: llc < %s -mtriple=x86_64-- -mattr=-x87 | FileCheck %s --check-prefixes=X64 -; RUN: llc < %s -mtriple=x86_64-- -mattr=-x87 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X64,FASTISEL-X64 +; RUN: llc < %s -mtriple=x86_64-- -mattr=-x87 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X64 ; RUN: llc < %s -mtriple=i686-- -mattr=-x87 | FileCheck %s --check-prefixes=X86 ; RUN: llc < %s -mtriple=i686-- -mattr=-x87 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=FASTISEL-X86