summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/MachineScheduler.cpp2
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp45
2 files changed, 35 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index 96131dc2983e..e5cd46268600 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -750,7 +750,7 @@ void ScheduleDAGMI::moveInstruction(
}
bool ScheduleDAGMI::checkSchedLimit() {
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS && !defined(NDEBUG)
if (NumInstrsScheduled == MISchedCutoff && MISchedCutoff != ~0U) {
CurrentTop = CurrentBottom;
return false;
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 654879115ff9..8d465b9520de 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -6353,6 +6353,24 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
}
}
+ if (N0.getOpcode() == ISD::EXTRACT_SUBVECTOR && N0.hasOneUse() && N1C &&
+ ISD::isExtOpcode(N0.getOperand(0).getOpcode())) {
+ SDValue Ext = N0.getOperand(0);
+ EVT ExtVT = Ext->getValueType(0);
+ SDValue Extendee = Ext->getOperand(0);
+
+ unsigned ScalarWidth = Extendee.getValueType().getScalarSizeInBits();
+ if (N1C->getAPIntValue().isMask(ScalarWidth)) {
+ // (and (extract_subvector (zext|anyext|sext v) _) iN_mask)
+ // => (extract_subvector (iN_zeroext v))
+ SDValue ZeroExtExtendee =
+ DAG.getNode(ISD::ZERO_EXTEND, SDLoc(N), ExtVT, Extendee);
+
+ return DAG.getNode(ISD::EXTRACT_SUBVECTOR, SDLoc(N), VT, ZeroExtExtendee,
+ N0.getOperand(1));
+ }
+ }
+
// fold (and (masked_gather x)) -> (zext_masked_gather x)
if (auto *GN0 = dyn_cast<MaskedGatherSDNode>(N0)) {
EVT MemVT = GN0->getMemoryVT();
@@ -7301,12 +7319,14 @@ static bool matchRotateSub(SDValue Pos, SDValue Neg, unsigned EltSize,
unsigned MaskLoBits = 0;
if (IsRotate && isPowerOf2_64(EltSize)) {
unsigned Bits = Log2_64(EltSize);
- APInt DemandedBits =
- APInt::getLowBitsSet(Neg.getScalarValueSizeInBits(), Bits);
- if (SDValue Inner =
- TLI.SimplifyMultipleUseDemandedBits(Neg, DemandedBits, DAG)) {
- Neg = Inner;
- MaskLoBits = Bits;
+ unsigned NegBits = Neg.getScalarValueSizeInBits();
+ if (NegBits >= Bits) {
+ APInt DemandedBits = APInt::getLowBitsSet(NegBits, Bits);
+ if (SDValue Inner =
+ TLI.SimplifyMultipleUseDemandedBits(Neg, DemandedBits, DAG)) {
+ Neg = Inner;
+ MaskLoBits = Bits;
+ }
}
}
@@ -7322,11 +7342,13 @@ static bool matchRotateSub(SDValue Pos, SDValue Neg, unsigned EltSize,
// affect Mask's demanded bits, just replace Pos with Pos'. These operations
// are redundant for the purpose of the equality.
if (MaskLoBits) {
- APInt DemandedBits =
- APInt::getLowBitsSet(Pos.getScalarValueSizeInBits(), MaskLoBits);
- if (SDValue Inner =
- TLI.SimplifyMultipleUseDemandedBits(Pos, DemandedBits, DAG)) {
- Pos = Inner;
+ unsigned PosBits = Pos.getScalarValueSizeInBits();
+ if (PosBits >= MaskLoBits) {
+ APInt DemandedBits = APInt::getLowBitsSet(PosBits, MaskLoBits);
+ if (SDValue Inner =
+ TLI.SimplifyMultipleUseDemandedBits(Pos, DemandedBits, DAG)) {
+ Pos = Inner;
+ }
}
}
@@ -22707,6 +22729,7 @@ SDValue DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) {
SDLoc DL(N);
EVT IntVT = VT.changeVectorElementTypeToInteger();
EVT IntSVT = VT.getVectorElementType().changeTypeToInteger();
+ IntSVT = TLI.getTypeToTransformTo(*DAG.getContext(), IntSVT);
SDValue ZeroElt = DAG.getConstant(0, DL, IntSVT);
SDValue AllOnesElt = DAG.getAllOnesConstant(DL, IntSVT);
SmallVector<SDValue, 16> AndMask(NumElts, DAG.getUNDEF(IntSVT));