[llvm] [RISCV] Fix incorrect folding of select on ctlz/cttz (PR #155231)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 25 09:49:51 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());
----------------
MitchBriles wrote:
This wouldn't work because it's handling the case where the MSB is set (which only happens with an input of 0). For example, in the case of `i7`, that mask would be `0b111` which is the max output of `ctlz`/`cttz` anyway.
https://github.com/llvm/llvm-project/pull/155231
More information about the llvm-commits
mailing list