[llvm] [RISCV] Fix incorrect folding of select on ctlz/cttz (PR #155231)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 25 07:06:32 PDT 2025


================
@@ -18754,7 +18758,6 @@ static SDValue foldSelectOfCTTZOrCTLZ(SDNode *N, SelectionDAG &DAG) {
                               CountZeroes.getValueType(), CountZeroesArgument);
   }
 
-  unsigned BitWidth = CountZeroes.getValueSizeInBits();
   SDValue BitWidthMinusOne =
       DAG.getConstant(BitWidth - 1, SDLoc(N), CountZeroes.getValueType());
----------------
lukel97 wrote:

Could we still allow non-power of 2 types if we used `maskTrailingOnes(BitWidth)` instead?

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


More information about the llvm-commits mailing list