[llvm] [RISCV] Fix incorrect folding of select on ctlz/cttz (PR #155231)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 25 10:53:52 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());
----------------
topperc wrote:
We could use urem by bitwidth which becomes an AND when bitwidth is a power 2 and division by constant sequence for non power of 2. Not sure if that's better than select in that case.
https://github.com/llvm/llvm-project/pull/155231
More information about the llvm-commits
mailing list