[llvm] [AMDGPU] Omit umin on ctlz/cttz if operand is non-zero. (PR #79127)
Leon Clark via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 23 04:26:27 PST 2024
================
@@ -3114,8 +3114,13 @@ SDValue AMDGPUTargetLowering::LowerCTLZ_CTTZ(SDValue Op, SelectionDAG &DAG) cons
// (cttz hi:lo) -> (umin (S_FF1_I32_B64 src), 64)
// (ctlz_zero_undef src) -> (S_FLBIT_I32_B64 src)
// (cttz_zero_undef src) -> (S_FF1_I32_B64 src)
+
+ // umin can be omitted if the operand is known to be non-zero.
+ auto KB = DAG.computeKnownBits(Src);
+ auto const IsNonZero = KB.countMinPopulation() > 0u;
+
SDValue NewOpr = DAG.getNode(NewOpc, SL, MVT::i32, Src);
- if (!ZeroUndef) {
+ if (!ZeroUndef && !IsNonZero) {
----------------
PeddleSpam wrote:
Thanks, I'll fix that now.
https://github.com/llvm/llvm-project/pull/79127
More information about the llvm-commits
mailing list