[llvm] Revert "[X86] Invert (and X, ~(and ~Y, Z)) back into (and X, (or Y, ~Z)) (#109215)" (PR #113181)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 21 08:42:20 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Miguel Saldivar (Saldivarcher)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/113181.diff
2 Files Affected:
- (modified) llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (-2)
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (-28)
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 50a75bc5932c42..91566b9040bcbc 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -9595,7 +9595,6 @@ SDValue DAGCombiner::visitXOR(SDNode *N) {
}
// fold (not (or x, y)) -> (and (not x), (not y)) iff x or y are setcc
- // fold (not (and x, y)) -> (or (not x), (not y)) iff x or y are setcc
if (isOneConstant(N1) && VT == MVT::i1 && N0.hasOneUse() &&
(N0Opcode == ISD::OR || N0Opcode == ISD::AND)) {
SDValue N00 = N0.getOperand(0), N01 = N0.getOperand(1);
@@ -9608,7 +9607,6 @@ SDValue DAGCombiner::visitXOR(SDNode *N) {
}
}
// fold (not (or x, y)) -> (and (not x), (not y)) iff x or y are constants
- // fold (not (and x, y)) -> (or (not x), (not y)) iff x or y are constants
if (isAllOnesConstant(N1) && N0.hasOneUse() &&
(N0Opcode == ISD::OR || N0Opcode == ISD::AND)) {
SDValue N00 = N0.getOperand(0), N01 = N0.getOperand(1);
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index bcb84add65d83e..1b6f4fe0eec2db 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -50035,31 +50035,6 @@ static bool hasBZHI(const X86Subtarget &Subtarget, MVT VT) {
(VT == MVT::i32 || (VT == MVT::i64 && Subtarget.is64Bit()));
}
-/// Folds (and X, (or Y, ~Z)) --> (and X, ~(and ~Y, Z))
-/// This undoes the inverse fold performed in InstCombine
-static SDValue combineAndNotOrIntoAndNotAnd(SDNode *N, SelectionDAG &DAG) {
-
- using namespace llvm::SDPatternMatch;
- MVT VT = N->getSimpleValueType(0);
- SDLoc DL(N);
- const TargetLowering &TLI = DAG.getTargetLoweringInfo();
- if (!TLI.hasAndNot(SDValue(N, 0)))
- return SDValue();
-
- SDValue X, Y, Z;
- if (sd_match(N, m_And(m_Value(X),
- m_OneUse(m_Or(m_Value(Y), m_Not(m_Value(Z))))))) {
- // Don't fold if Y is a constant to prevent infinite loops.
- if (!isa<ConstantSDNode>(Y))
- return DAG.getNode(
- ISD::AND, DL, VT, X,
- DAG.getNOT(
- DL, DAG.getNode(ISD::AND, DL, VT, DAG.getNOT(DL, Y, VT), Z), VT));
- }
-
- return SDValue();
-}
-
// This function recognizes cases where X86 bzhi instruction can replace and
// 'and-load' sequence.
// In case of loading integer value from an array of constants which is defined
@@ -50551,9 +50526,6 @@ static SDValue combineAnd(SDNode *N, SelectionDAG &DAG,
if (SDValue R = combineAndLoadToBZHI(N, DAG, Subtarget))
return R;
- if (SDValue R = combineAndNotOrIntoAndNotAnd(N, DAG))
- return R;
-
// fold (and (mul x, c1), c2) -> (mul x, (and c1, c2))
// iff c2 is all/no bits mask - i.e. a select-with-zero mask.
// TODO: Handle PMULDQ/PMULUDQ/VPMADDWD/VPMADDUBSW?
``````````
</details>
https://github.com/llvm/llvm-project/pull/113181
More information about the llvm-commits
mailing list