summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM
diff options
context:
space:
mode:
authorEli Friedman <efriedma@codeaurora.org>2018-08-22 20:13:45 +0000
committerEli Friedman <efriedma@codeaurora.org>2018-08-22 20:13:45 +0000
commitc11e2b94700e98606150db233e53b220431a5be2 (patch)
treee4e285d9c04e82d2351b3729782f2c3fa5372358 /llvm/lib/Target/ARM
parent8b83d685442096a620e6aa521c0aeef37a24d1f3 (diff)
downloadbcm5719-llvm-c11e2b94700e98606150db233e53b220431a5be2.tar.gz
bcm5719-llvm-c11e2b94700e98606150db233e53b220431a5be2.zip
[ARM] Handle all-ones mask explicitly in targetShrinkDemandedConstant.
This avoids a potential infinite loop setting and unsetting bits in the mask. Reduced from a failure on the polly-aosp bot. Differential Revision: https://reviews.llvm.org/D51066 llvm-svn: 340446
Diffstat (limited to 'llvm/lib/Target/ARM')
-rw-r--r--llvm/lib/Target/ARM/ARMISelLowering.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index a0b612ff3c9..738f8234e4a 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -13647,14 +13647,21 @@ ARMTargetLowering::targetShrinkDemandedConstant(SDValue Op,
unsigned Mask = C->getZExtValue();
- // If mask is zero, nothing to do.
- if (!Mask)
- return false;
-
unsigned Demanded = DemandedAPInt.getZExtValue();
unsigned ShrunkMask = Mask & Demanded;
unsigned ExpandedMask = Mask | ~Demanded;
+ // If the mask is all zeros, let the target-independent code replace the
+ // result with zero.
+ if (ShrunkMask == 0)
+ return false;
+
+ // If the mask is all ones, erase the AND. (Currently, the target-independent
+ // code won't do this, so we have to do it explicitly to avoid an infinite
+ // loop in obscure cases.)
+ if (ExpandedMask == ~0U)
+ return TLO.CombineTo(Op, Op.getOperand(0));
+
auto IsLegalMask = [ShrunkMask, ExpandedMask](unsigned Mask) -> bool {
return (ShrunkMask & Mask) == ShrunkMask && (~ExpandedMask & Mask) == 0;
};
OpenPOWER on IntegriCloud