[llvm] ARM: Support OR and XOR in targetShrinkDemandedConstant (PR #165106)
John Brawn via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 27 05:25:58 PDT 2026
================
@@ -20132,88 +20133,151 @@ void ARMTargetLowering::computeKnownBitsForTargetNode(const SDValue Op,
}
}
-bool ARMTargetLowering::targetShrinkDemandedConstant(
- SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts,
- TargetLoweringOpt &TLO) const {
- // Delay optimization, so we don't have to deal with illegal types, or block
- // optimizations.
- if (!TLO.LegalOps)
- return false;
-
- // Only optimize AND for now.
- if (Op.getOpcode() != ISD::AND)
- return false;
-
- EVT VT = Op.getValueType();
-
- // Ignore vectors.
- if (VT.isVector())
- return false;
+static bool isLegalLogicalImmediate(unsigned Imm,
+ const ARMSubtarget *Subtarget) {
+ if (!Subtarget->isThumb())
+ return ARM_AM::getSOImmVal(Imm) != -1;
+ if (Subtarget->isThumb2())
+ return ARM_AM::getT2SOImmVal(Imm) != -1;
+ // Thumb1 only has 8-bit unsigned immediate.
+ return Imm <= 255;
+}
- assert(VT == MVT::i32 && "Unexpected integer type");
+/// Demanded-bits refinements for i32 AND/OR/XOR with a constant RHS (mirrors
----------------
john-brawn-arm wrote:
Referencing what the AArch64 target is doing isn't useful, this should just be saying what this function is doing.
https://github.com/llvm/llvm-project/pull/165106
More information about the llvm-commits
mailing list