[llvm-branch-commits] [llvm] [SPARC] Use op-then-halve instructions when we have VIS3 (PR #135718)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu May 22 18:50:14 PDT 2025


https://github.com/koachan updated https://github.com/llvm/llvm-project/pull/135718

>From 50422a4d24403ef55bf76ccd710511e8dec6b77d Mon Sep 17 00:00:00 2001
From: Koakuma <koachan at protonmail.com>
Date: Sun, 4 May 2025 09:33:39 +0700
Subject: [PATCH] Rework isFPImmLegal

Created using spr 1.3.5
---
 llvm/lib/Target/Sparc/SparcISelLowering.cpp | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Target/Sparc/SparcISelLowering.cpp b/llvm/lib/Target/Sparc/SparcISelLowering.cpp
index 68c523709d38d..727857b647acc 100644
--- a/llvm/lib/Target/Sparc/SparcISelLowering.cpp
+++ b/llvm/lib/Target/Sparc/SparcISelLowering.cpp
@@ -3613,15 +3613,14 @@ bool SparcTargetLowering::isFNegFree(EVT VT) const {
 
 bool SparcTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT,
                                        bool ForCodeSize) const {
-  bool CanLower = false;
   if (VT != MVT::f32 && VT != MVT::f64)
     return false;
-  if (Subtarget->isVIS())
-    CanLower = CanLower || Imm.isZero();
+  if (Subtarget->isVIS() && Imm.isZero())
+    return true;
   if (Subtarget->isVIS3())
-    CanLower =
-        CanLower || (Imm.isExactlyValue(+0.5) || Imm.isExactlyValue(-0.5));
-  return CanLower;
+    return Imm.isExactlyValue(+0.5) || Imm.isExactlyValue(-0.5) ||
+           Imm.getExactLog2Abs() == -1;
+  return false;
 }
 
 bool SparcTargetLowering::isCtlzFast() const { return Subtarget->isVIS3(); }



More information about the llvm-branch-commits mailing list