[llvm] [RISCV] Add BREV8 to SimplifyDemandedBitsForTargetNode. (PR #141898)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu May 29 07:13:12 PDT 2025
================
@@ -20717,6 +20716,35 @@ unsigned RISCVTargetLowering::ComputeNumSignBitsForTargetNode(
return 1;
}
+bool RISCVTargetLowering::SimplifyDemandedBitsForTargetNode(
+ SDValue Op, const APInt &OriginalDemandedBits,
+ const APInt &OriginalDemandedElts, KnownBits &Known, TargetLoweringOpt &TLO,
+ unsigned Depth) const {
+ unsigned BitWidth = OriginalDemandedBits.getBitWidth();
+
+ switch (Op.getOpcode()) {
+ case RISCVISD::BREV8: {
+ KnownBits Known2;
+ APInt DemandedBits =
+ APInt(BitWidth, computeGREVOrGORC(OriginalDemandedBits.getZExtValue(),
+ 7, /*IsGORC=*/false));
+ if (SimplifyDemandedBits(Op.getOperand(0), DemandedBits,
+ OriginalDemandedElts, Known2, TLO, Depth + 1))
+ return true;
+
+ // To compute zeros, we need to invert the value and invert it back after.
----------------
preames wrote:
I'm not getting this comment. This just a bit reverse in byte, if we have xxx0xx00, that's just 0xxx00xx isn't it? With the Zero form of that being 000F00FF, the result is still F000FF00 right?
https://github.com/llvm/llvm-project/pull/141898
More information about the llvm-commits
mailing list