[llvm] [X86][GlobalIsel] support G_FABS for f80 (PR #136718)
Evgenii Kudriashov via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 24 06:56:26 PDT 2025
================
@@ -0,0 +1,52 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=0 -mattr=+x87,+sse,+sse2 -o - | FileCheck %s --check-prefix=X64
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -global-isel=1 -mattr=+x87,+sse,+sse2 -o - | FileCheck %s -check-prefixes=GISEL
+
+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
+;
+; GISEL-LABEL: test_float_abs:
+; GISEL: # %bb.0:
+; GISEL-NEXT: movd %xmm0, %eax
+; GISEL-NEXT: andl $2147483647, %eax # imm = 0x7FFFFFFF
+; GISEL-NEXT: movd %eax, %xmm0
+; GISEL-NEXT: retq
+ %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
+;
+; GISEL-LABEL: test_double_abs:
+; GISEL: # %bb.0:
+; GISEL-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
----------------
e-kud wrote:
I've meant loading global variable using PLT when we need an extra load. I assume here the issue is that we can't select `andq` with the such large constant and we end up with `mov` + `and`. We can't select `andps` as SDAG. It requires to insert a value in a vector but we can't select this instruction yet because the index is of type pointer. Here was an attempt to allow matching with pointer type #111503. I'm still trying to find a good change to enable selection of vectors.
So, I'd say yes, this is expected but because of vectors, not global variables.
https://github.com/llvm/llvm-project/pull/136718
More information about the llvm-commits
mailing list