[llvm] [AMDGPU] Omit umin on ctlz/cttz if operand is non-zero. (PR #79127)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 2 15:55:01 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff d8628a00fd92c6f9db631f817a63eada90707ad2 beae30d9c273b391ae44b54c41ca6fb78d6035e4 -- llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
index 2baaaf0cc3a..55b715c1ef6 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
@@ -4072,7 +4072,7 @@ bool AMDGPULegalizerInfo::legalizeMul(LegalizerHelper &Helper,
 // Legalize ctlz/cttz to ffbh/ffbl instead of the default legalization to
 // ctlz/cttz_zero_undef. This allows us to fix up the result for the zero input
 // case with a single min instruction instead of a compare+select.
-bool AMDGPULegalizerInfo::legalizeCTLZ_CTTZ(LegalizerHelper &Helper, 
+bool AMDGPULegalizerInfo::legalizeCTLZ_CTTZ(LegalizerHelper &Helper,
                                             MachineInstr &MI,
                                             MachineRegisterInfo &MRI,
                                             MachineIRBuilder &B) const {
@@ -4085,13 +4085,13 @@ bool AMDGPULegalizerInfo::legalizeCTLZ_CTTZ(LegalizerHelper &Helper,
                         ? AMDGPU::G_AMDGPU_FFBH_U32
                         : AMDGPU::G_AMDGPU_FFBL_B32;
   auto Tmp = B.buildInstr(NewOpc, {DstTy}, {Src});
-  
+
   // min instruction can be omitted if the operand is known to be non-zero.
   auto *KB = Helper.getKnownBits();
   if (!KB->getKnownBits(Src).isNonZero()) {
     B.buildUMin(Dst, Tmp, B.buildConstant(DstTy, SrcTy.getSizeInBits()));
   }
-  
+
   MI.eraseFromParent();
   return true;
 }
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.h b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.h
index 412c97a11bd..44ef9024be3 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.h
@@ -106,7 +106,7 @@ public:
                      bool UsePartialMad64_32,
                      bool SeparateOddAlignedProducts) const;
   bool legalizeMul(LegalizerHelper &Helper, MachineInstr &MI) const;
-  bool legalizeCTLZ_CTTZ(LegalizerHelper &Helper, MachineInstr &MI, 
+  bool legalizeCTLZ_CTTZ(LegalizerHelper &Helper, MachineInstr &MI,
                          MachineRegisterInfo &MRI, MachineIRBuilder &B) const;
 
   bool loadInputValue(Register DstReg, MachineIRBuilder &B,

``````````

</details>


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


More information about the llvm-commits mailing list