[llvm] bd9bf9c - [X86] SimplifyDemandedBits - move MaskedValueIsZero as late as possible to avoid unnecessary (recursive) analysis costs. NFC.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 18 07:14:23 PDT 2023
Author: Simon Pilgrim
Date: 2023-08-18T15:14:06+01:00
New Revision: bd9bf9cb6708ed193df23d09bafc16306f55d14e
URL: https://github.com/llvm/llvm-project/commit/bd9bf9cb6708ed193df23d09bafc16306f55d14e
DIFF: https://github.com/llvm/llvm-project/commit/bd9bf9cb6708ed193df23d09bafc16306f55d14e.diff
LOG: [X86] SimplifyDemandedBits - move MaskedValueIsZero as late as possible to avoid unnecessary (recursive) analysis costs. NFC.
Mentioned on D155472 for the SHL equivalent
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 4f5c07a8549ee5..8bb6724593574c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -1886,15 +1886,15 @@ bool TargetLowering::SimplifyDemandedBits(
// Narrow shift to lower half - similar to ShrinkDemandedOp.
// (srl i64:x, K) -> (i64 zero_extend (srl (i32 (trunc i64:x)), K))
- if ((BitWidth % 2) == 0 && !VT.isVector() &&
- ((InDemandedMask.countLeadingZeros() >= (BitWidth / 2)) ||
- TLO.DAG.MaskedValueIsZero(
- Op0, APInt::getHighBitsSet(BitWidth, BitWidth / 2)))) {
+ if ((BitWidth % 2) == 0 && !VT.isVector()) {
+ APInt HiBits = APInt::getHighBitsSet(BitWidth, BitWidth / 2);
EVT HalfVT = EVT::getIntegerVT(*TLO.DAG.getContext(), BitWidth / 2);
if (isNarrowingProfitable(VT, HalfVT) &&
isTypeDesirableForOp(ISD::SRL, HalfVT) &&
isTruncateFree(VT, HalfVT) && isZExtFree(HalfVT, VT) &&
- (!TLO.LegalOperations() || isOperationLegal(ISD::SRL, VT))) {
+ (!TLO.LegalOperations() || isOperationLegal(ISD::SRL, VT)) &&
+ ((InDemandedMask.countLeadingZeros() >= (BitWidth / 2)) ||
+ TLO.DAG.MaskedValueIsZero(Op0, HiBits))) {
SDValue NewOp = TLO.DAG.getNode(ISD::TRUNCATE, dl, HalfVT, Op0);
SDValue NewShiftAmt = TLO.DAG.getShiftAmountConstant(
ShAmt, HalfVT, dl, TLO.LegalTypes());
More information about the llvm-commits
mailing list