[llvm] [X86][GlobalISel] Support G_FADD, G_FSUB, G_FMUL, G_FDIV (PR #87339)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 2 04:42:04 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-globalisel

@llvm/pr-subscribers-backend-x86

Author: Evgenii Kudriashov (e-kud)

<details>
<summary>Changes</summary>

* Add vector legalization
* Add vector tests and reorganize existing tests

---

Patch is 31.48 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/87339.diff


13 Files Affected:

- (modified) llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp (+6-1) 
- (removed) llvm/test/CodeGen/X86/GlobalISel/fadd-scalar.ll (-21) 
- (removed) llvm/test/CodeGen/X86/GlobalISel/fdiv-scalar.ll (-21) 
- (removed) llvm/test/CodeGen/X86/GlobalISel/fmul-scalar.ll (-21) 
- (removed) llvm/test/CodeGen/X86/GlobalISel/fsub-scalar.ll (-21) 
- (added) llvm/test/CodeGen/X86/isel-fadd-vector.ll (+134) 
- (added) llvm/test/CodeGen/X86/isel-fadd.ll (+52) 
- (added) llvm/test/CodeGen/X86/isel-fdiv-vector.ll (+134) 
- (added) llvm/test/CodeGen/X86/isel-fdiv.ll (+52) 
- (added) llvm/test/CodeGen/X86/isel-fmul-vector.ll (+134) 
- (added) llvm/test/CodeGen/X86/isel-fmul.ll (+52) 
- (added) llvm/test/CodeGen/X86/isel-fsub-vector.ll (+134) 
- (added) llvm/test/CodeGen/X86/isel-fsub.ll (+52) 


``````````diff
diff --git a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
index 07041cc5b0491c..3be3121bab66f8 100644
--- a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
+++ b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
@@ -429,7 +429,12 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
                (HasAVX && typeInSet(0, {v8s32, v4s64})(Query)) ||
                (HasAVX512 && typeInSet(0, {v16s32, v8s64})(Query)) ||
                (UseX87 && typeInSet(0, {s80})(Query));
-      });
+      })
+      .clampMinNumElements(0, s32, 4)
+      .clampMinNumElements(0, s64, 2)
+      .clampMaxNumElements(0, s32, HasAVX512 ? 16 : (HasAVX ? 8 : 4))
+      .clampMaxNumElements(0, s64, HasAVX512 ? 8 : (HasAVX ? 4 : 2))
+      .scalarize(0);
 
   // fp comparison
   getActionDefinitionsBuilder(G_FCMP)
diff --git a/llvm/test/CodeGen/X86/GlobalISel/fadd-scalar.ll b/llvm/test/CodeGen/X86/GlobalISel/fadd-scalar.ll
deleted file mode 100644
index 73be29e5d8438b..00000000000000
--- a/llvm/test/CodeGen/X86/GlobalISel/fadd-scalar.ll
+++ /dev/null
@@ -1,21 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X64
-
-define float @test_fadd_float(float %arg1, float %arg2) {
-; X64-LABEL: test_fadd_float:
-; X64:       # %bb.0:
-; X64-NEXT:    addss %xmm1, %xmm0
-; X64-NEXT:    retq
-  %ret = fadd float %arg1, %arg2
-  ret float %ret
-}
-
-define double @test_fadd_double(double %arg1, double %arg2) {
-; X64-LABEL: test_fadd_double:
-; X64:       # %bb.0:
-; X64-NEXT:    addsd %xmm1, %xmm0
-; X64-NEXT:    retq
-  %ret = fadd double %arg1, %arg2
-  ret double %ret
-}
-
diff --git a/llvm/test/CodeGen/X86/GlobalISel/fdiv-scalar.ll b/llvm/test/CodeGen/X86/GlobalISel/fdiv-scalar.ll
deleted file mode 100644
index f2dc6de08528ed..00000000000000
--- a/llvm/test/CodeGen/X86/GlobalISel/fdiv-scalar.ll
+++ /dev/null
@@ -1,21 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X64
-
-define float @test_fdiv_float(float %arg1, float %arg2) {
-; X64-LABEL: test_fdiv_float:
-; X64:       # %bb.0:
-; X64-NEXT:    divss %xmm1, %xmm0
-; X64-NEXT:    retq
-  %ret = fdiv float %arg1, %arg2
-  ret float %ret
-}
-
-define double @test_fdiv_double(double %arg1, double %arg2) {
-; X64-LABEL: test_fdiv_double:
-; X64:       # %bb.0:
-; X64-NEXT:    divsd %xmm1, %xmm0
-; X64-NEXT:    retq
-  %ret = fdiv double %arg1, %arg2
-  ret double %ret
-}
-
diff --git a/llvm/test/CodeGen/X86/GlobalISel/fmul-scalar.ll b/llvm/test/CodeGen/X86/GlobalISel/fmul-scalar.ll
deleted file mode 100644
index 187593d082c543..00000000000000
--- a/llvm/test/CodeGen/X86/GlobalISel/fmul-scalar.ll
+++ /dev/null
@@ -1,21 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X64
-
-define float @test_fmul_float(float %arg1, float %arg2) {
-; X64-LABEL: test_fmul_float:
-; X64:       # %bb.0:
-; X64-NEXT:    mulss %xmm1, %xmm0
-; X64-NEXT:    retq
-  %ret = fmul float %arg1, %arg2
-  ret float %ret
-}
-
-define double @test_fmul_double(double %arg1, double %arg2) {
-; X64-LABEL: test_fmul_double:
-; X64:       # %bb.0:
-; X64-NEXT:    mulsd %xmm1, %xmm0
-; X64-NEXT:    retq
-  %ret = fmul double %arg1, %arg2
-  ret double %ret
-}
-
diff --git a/llvm/test/CodeGen/X86/GlobalISel/fsub-scalar.ll b/llvm/test/CodeGen/X86/GlobalISel/fsub-scalar.ll
deleted file mode 100644
index b2a82834af5bbe..00000000000000
--- a/llvm/test/CodeGen/X86/GlobalISel/fsub-scalar.ll
+++ /dev/null
@@ -1,21 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X64
-
-define float @test_fsub_float(float %arg1, float %arg2) {
-; X64-LABEL: test_fsub_float:
-; X64:       # %bb.0:
-; X64-NEXT:    subss %xmm1, %xmm0
-; X64-NEXT:    retq
-  %ret = fsub float %arg1, %arg2
-  ret float %ret
-}
-
-define double @test_fsub_double(double %arg1, double %arg2) {
-; X64-LABEL: test_fsub_double:
-; X64:       # %bb.0:
-; X64-NEXT:    subsd %xmm1, %xmm0
-; X64-NEXT:    retq
-  %ret = fsub double %arg1, %arg2
-  ret double %ret
-}
-
diff --git a/llvm/test/CodeGen/X86/isel-fadd-vector.ll b/llvm/test/CodeGen/X86/isel-fadd-vector.ll
new file mode 100644
index 00000000000000..b44818d49344db
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-fadd-vector.ll
@@ -0,0 +1,134 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 | FileCheck %s --check-prefixes=SSE
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=SSE
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=SSE
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx | FileCheck %s --check-prefixes=AVX
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=AVX
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=AVX
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f | FileCheck %s --check-prefixes=AVX512
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=AVX512
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=AVX512
+
+define <4 x float> @test_fadd_v4s32(<4 x float> %arg1, <4 x float> %arg2) {
+; SSE-LABEL: test_fadd_v4s32:
+; SSE:       # %bb.0:
+; SSE-NEXT:    addps %xmm1, %xmm0
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fadd_v4s32:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vaddps %xmm1, %xmm0, %xmm0
+; AVX-NEXT:    retq
+;
+; AVX512-LABEL: test_fadd_v4s32:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vaddps %xmm1, %xmm0, %xmm0
+; AVX512-NEXT:    retq
+  %ret = fadd <4 x float> %arg1, %arg2
+  ret <4 x float> %ret
+}
+
+define <2 x double> @test_fadd_v2s64(<2 x double> %arg1, <2 x double> %arg2) {
+; SSE-LABEL: test_fadd_v2s64:
+; SSE:       # %bb.0:
+; SSE-NEXT:    addpd %xmm1, %xmm0
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fadd_v2s64:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vaddpd %xmm1, %xmm0, %xmm0
+; AVX-NEXT:    retq
+;
+; AVX512-LABEL: test_fadd_v2s64:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vaddpd %xmm1, %xmm0, %xmm0
+; AVX512-NEXT:    retq
+  %ret = fadd <2 x double> %arg1, %arg2
+  ret <2 x double> %ret
+}
+
+define <8 x float> @test_fadd_v8s32(<8 x float> %arg1, <8 x float> %arg2) {
+; SSE-LABEL: test_fadd_v8s32:
+; SSE:       # %bb.0:
+; SSE-NEXT:    addps %xmm2, %xmm0
+; SSE-NEXT:    addps %xmm3, %xmm1
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fadd_v8s32:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vaddps %ymm1, %ymm0, %ymm0
+; AVX-NEXT:    retq
+;
+; AVX512-LABEL: test_fadd_v8s32:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vaddps %ymm1, %ymm0, %ymm0
+; AVX512-NEXT:    retq
+  %ret = fadd <8 x float> %arg1, %arg2
+  ret <8 x float> %ret
+}
+
+define <4 x double> @test_fadd_v4s64(<4 x double> %arg1, <4 x double> %arg2) {
+; SSE-LABEL: test_fadd_v4s64:
+; SSE:       # %bb.0:
+; SSE-NEXT:    addpd %xmm2, %xmm0
+; SSE-NEXT:    addpd %xmm3, %xmm1
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fadd_v4s64:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vaddpd %ymm1, %ymm0, %ymm0
+; AVX-NEXT:    retq
+;
+; AVX512-LABEL: test_fadd_v4s64:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vaddpd %ymm1, %ymm0, %ymm0
+; AVX512-NEXT:    retq
+  %ret = fadd <4 x double> %arg1, %arg2
+  ret <4 x double> %ret
+}
+
+define <16 x float> @test_fadd_v16s32(<16 x float> %arg1, <16 x float> %arg2) {
+; SSE-LABEL: test_fadd_v16s32:
+; SSE:       # %bb.0:
+; SSE-NEXT:    addps %xmm4, %xmm0
+; SSE-NEXT:    addps %xmm5, %xmm1
+; SSE-NEXT:    addps %xmm6, %xmm2
+; SSE-NEXT:    addps %xmm7, %xmm3
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fadd_v16s32:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vaddps %ymm2, %ymm0, %ymm0
+; AVX-NEXT:    vaddps %ymm3, %ymm1, %ymm1
+; AVX-NEXT:    retq
+;
+; AVX512-LABEL: test_fadd_v16s32:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vaddps %zmm1, %zmm0, %zmm0
+; AVX512-NEXT:    retq
+  %ret = fadd <16 x float> %arg1, %arg2
+  ret <16 x float> %ret
+}
+
+define <8 x double> @test_fadd_v8s64(<8 x double> %arg1, <8 x double> %arg2) {
+; SSE-LABEL: test_fadd_v8s64:
+; SSE:       # %bb.0:
+; SSE-NEXT:    addpd %xmm4, %xmm0
+; SSE-NEXT:    addpd %xmm5, %xmm1
+; SSE-NEXT:    addpd %xmm6, %xmm2
+; SSE-NEXT:    addpd %xmm7, %xmm3
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fadd_v8s64:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vaddpd %ymm2, %ymm0, %ymm0
+; AVX-NEXT:    vaddpd %ymm3, %ymm1, %ymm1
+; AVX-NEXT:    retq
+;
+; AVX512-LABEL: test_fadd_v8s64:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vaddpd %zmm1, %zmm0, %zmm0
+; AVX512-NEXT:    retq
+  %ret = fadd <8 x double> %arg1, %arg2
+  ret <8 x double> %ret
+}
diff --git a/llvm/test/CodeGen/X86/isel-fadd.ll b/llvm/test/CodeGen/X86/isel-fadd.ll
new file mode 100644
index 00000000000000..16e005828608c1
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-fadd.ll
@@ -0,0 +1,52 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-- | FileCheck %s --check-prefixes=SDAG-X86
+; RUN: llc < %s -mtriple=i686-- -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=FASTISEL-X86
+; TODO: Enable when x87 is supported
+; llc < %s -mtriple=i686-- -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s --check-prefixes=X64
+; RUN: llc < %s -mtriple=x86_64-- -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X64
+; RUN: llc < %s -mtriple=x86_64-- -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=X64
+
+define float @test_fadd_float(float %arg1, float %arg2) {
+; SDAG-X86-LABEL: test_fadd_float:
+; SDAG-X86:       # %bb.0:
+; SDAG-X86-NEXT:    flds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT:    fadds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT:    retl
+;
+; FASTISEL-X86-LABEL: test_fadd_float:
+; FASTISEL-X86:       # %bb.0:
+; FASTISEL-X86-NEXT:    flds {{[0-9]+}}(%esp)
+; FASTISEL-X86-NEXT:    flds {{[0-9]+}}(%esp)
+; FASTISEL-X86-NEXT:    faddp %st, %st(1)
+; FASTISEL-X86-NEXT:    retl
+;
+; X64-LABEL: test_fadd_float:
+; X64:       # %bb.0:
+; X64-NEXT:    addss %xmm1, %xmm0
+; X64-NEXT:    retq
+  %ret = fadd float %arg1, %arg2
+  ret float %ret
+}
+
+define double @test_fadd_double(double %arg1, double %arg2) {
+; SDAG-X86-LABEL: test_fadd_double:
+; SDAG-X86:       # %bb.0:
+; SDAG-X86-NEXT:    fldl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT:    faddl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT:    retl
+;
+; FASTISEL-X86-LABEL: test_fadd_double:
+; FASTISEL-X86:       # %bb.0:
+; FASTISEL-X86-NEXT:    fldl {{[0-9]+}}(%esp)
+; FASTISEL-X86-NEXT:    fldl {{[0-9]+}}(%esp)
+; FASTISEL-X86-NEXT:    faddp %st, %st(1)
+; FASTISEL-X86-NEXT:    retl
+;
+; X64-LABEL: test_fadd_double:
+; X64:       # %bb.0:
+; X64-NEXT:    addsd %xmm1, %xmm0
+; X64-NEXT:    retq
+  %ret = fadd double %arg1, %arg2
+  ret double %ret
+}
diff --git a/llvm/test/CodeGen/X86/isel-fdiv-vector.ll b/llvm/test/CodeGen/X86/isel-fdiv-vector.ll
new file mode 100644
index 00000000000000..ff114c2af7e96b
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-fdiv-vector.ll
@@ -0,0 +1,134 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 | FileCheck %s --check-prefixes=SSE
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=SSE
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=SSE
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx | FileCheck %s --check-prefixes=AVX
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=AVX
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=AVX
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f | FileCheck %s --check-prefixes=AVX512
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=AVX512
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=AVX512
+
+define <4 x float> @test_fdiv_v4s32(<4 x float> %arg1, <4 x float> %arg2) {
+; SSE-LABEL: test_fdiv_v4s32:
+; SSE:       # %bb.0:
+; SSE-NEXT:    divps %xmm1, %xmm0
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fdiv_v4s32:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vdivps %xmm1, %xmm0, %xmm0
+; AVX-NEXT:    retq
+;
+; AVX512-LABEL: test_fdiv_v4s32:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vdivps %xmm1, %xmm0, %xmm0
+; AVX512-NEXT:    retq
+  %ret = fdiv <4 x float> %arg1, %arg2
+  ret <4 x float> %ret
+}
+
+define <2 x double> @test_fdiv_v2s64(<2 x double> %arg1, <2 x double> %arg2) {
+; SSE-LABEL: test_fdiv_v2s64:
+; SSE:       # %bb.0:
+; SSE-NEXT:    divpd %xmm1, %xmm0
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fdiv_v2s64:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vdivpd %xmm1, %xmm0, %xmm0
+; AVX-NEXT:    retq
+;
+; AVX512-LABEL: test_fdiv_v2s64:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vdivpd %xmm1, %xmm0, %xmm0
+; AVX512-NEXT:    retq
+  %ret = fdiv <2 x double> %arg1, %arg2
+  ret <2 x double> %ret
+}
+
+define <8 x float> @test_fdiv_v8s32(<8 x float> %arg1, <8 x float> %arg2) {
+; SSE-LABEL: test_fdiv_v8s32:
+; SSE:       # %bb.0:
+; SSE-NEXT:    divps %xmm2, %xmm0
+; SSE-NEXT:    divps %xmm3, %xmm1
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fdiv_v8s32:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vdivps %ymm1, %ymm0, %ymm0
+; AVX-NEXT:    retq
+;
+; AVX512-LABEL: test_fdiv_v8s32:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vdivps %ymm1, %ymm0, %ymm0
+; AVX512-NEXT:    retq
+  %ret = fdiv <8 x float> %arg1, %arg2
+  ret <8 x float> %ret
+}
+
+define <4 x double> @test_fdiv_v4s64(<4 x double> %arg1, <4 x double> %arg2) {
+; SSE-LABEL: test_fdiv_v4s64:
+; SSE:       # %bb.0:
+; SSE-NEXT:    divpd %xmm2, %xmm0
+; SSE-NEXT:    divpd %xmm3, %xmm1
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fdiv_v4s64:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vdivpd %ymm1, %ymm0, %ymm0
+; AVX-NEXT:    retq
+;
+; AVX512-LABEL: test_fdiv_v4s64:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vdivpd %ymm1, %ymm0, %ymm0
+; AVX512-NEXT:    retq
+  %ret = fdiv <4 x double> %arg1, %arg2
+  ret <4 x double> %ret
+}
+
+define <16 x float> @test_fdiv_v16s32(<16 x float> %arg1, <16 x float> %arg2) {
+; SSE-LABEL: test_fdiv_v16s32:
+; SSE:       # %bb.0:
+; SSE-NEXT:    divps %xmm4, %xmm0
+; SSE-NEXT:    divps %xmm5, %xmm1
+; SSE-NEXT:    divps %xmm6, %xmm2
+; SSE-NEXT:    divps %xmm7, %xmm3
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fdiv_v16s32:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vdivps %ymm2, %ymm0, %ymm0
+; AVX-NEXT:    vdivps %ymm3, %ymm1, %ymm1
+; AVX-NEXT:    retq
+;
+; AVX512-LABEL: test_fdiv_v16s32:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vdivps %zmm1, %zmm0, %zmm0
+; AVX512-NEXT:    retq
+  %ret = fdiv <16 x float> %arg1, %arg2
+  ret <16 x float> %ret
+}
+
+define <8 x double> @test_fdiv_v8s64(<8 x double> %arg1, <8 x double> %arg2) {
+; SSE-LABEL: test_fdiv_v8s64:
+; SSE:       # %bb.0:
+; SSE-NEXT:    divpd %xmm4, %xmm0
+; SSE-NEXT:    divpd %xmm5, %xmm1
+; SSE-NEXT:    divpd %xmm6, %xmm2
+; SSE-NEXT:    divpd %xmm7, %xmm3
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fdiv_v8s64:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vdivpd %ymm2, %ymm0, %ymm0
+; AVX-NEXT:    vdivpd %ymm3, %ymm1, %ymm1
+; AVX-NEXT:    retq
+;
+; AVX512-LABEL: test_fdiv_v8s64:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vdivpd %zmm1, %zmm0, %zmm0
+; AVX512-NEXT:    retq
+  %ret = fdiv <8 x double> %arg1, %arg2
+  ret <8 x double> %ret
+}
diff --git a/llvm/test/CodeGen/X86/isel-fdiv.ll b/llvm/test/CodeGen/X86/isel-fdiv.ll
new file mode 100644
index 00000000000000..74ad27a8414d2c
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-fdiv.ll
@@ -0,0 +1,52 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-- | FileCheck %s --check-prefixes=SDAG-X86
+; RUN: llc < %s -mtriple=i686-- -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=FASTISEL-X86
+; TODO: Enable when x87 is supported
+; llc < %s -mtriple=i686-- -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X86
+; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s --check-prefixes=X64
+; RUN: llc < %s -mtriple=x86_64-- -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=X64
+; RUN: llc < %s -mtriple=x86_64-- -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=X64
+
+define float @test_fdiv_float(float %arg1, float %arg2) {
+; SDAG-X86-LABEL: test_fdiv_float:
+; SDAG-X86:       # %bb.0:
+; SDAG-X86-NEXT:    flds {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT:    fdivs {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT:    retl
+;
+; FASTISEL-X86-LABEL: test_fdiv_float:
+; FASTISEL-X86:       # %bb.0:
+; FASTISEL-X86-NEXT:    flds {{[0-9]+}}(%esp)
+; FASTISEL-X86-NEXT:    flds {{[0-9]+}}(%esp)
+; FASTISEL-X86-NEXT:    fdivp %st, %st(1)
+; FASTISEL-X86-NEXT:    retl
+;
+; X64-LABEL: test_fdiv_float:
+; X64:       # %bb.0:
+; X64-NEXT:    divss %xmm1, %xmm0
+; X64-NEXT:    retq
+  %ret = fdiv float %arg1, %arg2
+  ret float %ret
+}
+
+define double @test_fdiv_double(double %arg1, double %arg2) {
+; SDAG-X86-LABEL: test_fdiv_double:
+; SDAG-X86:       # %bb.0:
+; SDAG-X86-NEXT:    fldl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT:    fdivl {{[0-9]+}}(%esp)
+; SDAG-X86-NEXT:    retl
+;
+; FASTISEL-X86-LABEL: test_fdiv_double:
+; FASTISEL-X86:       # %bb.0:
+; FASTISEL-X86-NEXT:    fldl {{[0-9]+}}(%esp)
+; FASTISEL-X86-NEXT:    fldl {{[0-9]+}}(%esp)
+; FASTISEL-X86-NEXT:    fdivp %st, %st(1)
+; FASTISEL-X86-NEXT:    retl
+;
+; X64-LABEL: test_fdiv_double:
+; X64:       # %bb.0:
+; X64-NEXT:    divsd %xmm1, %xmm0
+; X64-NEXT:    retq
+  %ret = fdiv double %arg1, %arg2
+  ret double %ret
+}
diff --git a/llvm/test/CodeGen/X86/isel-fmul-vector.ll b/llvm/test/CodeGen/X86/isel-fmul-vector.ll
new file mode 100644
index 00000000000000..7734f00f351cfb
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-fmul-vector.ll
@@ -0,0 +1,134 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 | FileCheck %s --check-prefixes=SSE
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=SSE
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=SSE
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx | FileCheck %s --check-prefixes=AVX
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=AVX
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=AVX
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f | FileCheck %s --check-prefixes=AVX512
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=AVX512
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=AVX512
+
+define <4 x float> @test_fmul_v4s32(<4 x float> %arg1, <4 x float> %arg2) {
+; SSE-LABEL: test_fmul_v4s32:
+; SSE:       # %bb.0:
+; SSE-NEXT:    mulps %xmm1, %xmm0
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fmul_v4s32:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vmulps %xmm1, %xmm0, %xmm0
+; AVX-NEXT:    retq
+;
+; AVX512-LABEL: test_fmul_v4s32:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vmulps %xmm1, %xmm0, %xmm0
+; AVX512-NEXT:    retq
+  %ret = fmul <4 x float> %arg1, %arg2
+  ret <4 x float> %ret
+}
+
+define <2 x double> @test_fmul_v2s64(<2 x double> %arg1, <2 x double> %arg2) {
+; SSE-LABEL: test_fmul_v2s64:
+; SSE:       # %bb.0:
+; SSE-NEXT:    mulpd %xmm1, %xmm0
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: test_fmul_v2s64:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vmulpd %xmm1, %xmm0, %xmm0
+; AVX-NEXT:    retq
+;
...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/87339


More information about the llvm-commits mailing list