[llvm] [X86] Invert (and X, ~(and ~Y, Z)) back into (and X, (or Y, ~Z)) (PR #109215)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 9 06:42:47 PDT 2024
================
@@ -50034,6 +50034,32 @@ static bool hasBZHI(const X86Subtarget &Subtarget, MVT VT) {
(VT == MVT::i32 || (VT == MVT::i64 && Subtarget.is64Bit()));
}
+/// InstCombine converts:
+/// `(and X, ~(and ~Y, Z))`
+/// to
+/// `(and X, (or Y, ~Z))`
+///
+/// But we should undo this transformation if the `andn` instruction is
+/// available to us.
+static SDValue combineAndNotOrIntoAndNotAnd(SDNode *N, SelectionDAG &DAG,
+ const X86Subtarget &Subtarget) {
+
+ using namespace llvm::SDPatternMatch;
+ MVT VT = N->getSimpleValueType(0);
+ SDLoc DL(N);
+ const TargetLowering &TLI = DAG.getTargetLoweringInfo();
+ if (TLI.hasAndNot(SDValue(N, 0))) {
----------------
RKSimon wrote:
(style)
```
if (!TLI.hasAndNot(SDValue(N, 0)))
return SDValue();
```
https://github.com/llvm/llvm-project/pull/109215
More information about the llvm-commits
mailing list