[llvm] 5b06de7 - [X86] Add isLogicOp helper to match ISD::AND/OR/XOR and X86ISD::ANDNP

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 28 12:39:36 PDT 2024


Author: Simon Pilgrim
Date: 2024-03-28T19:39:17Z
New Revision: 5b06de7f99ef86c484f5fea5542c1868e798ac08

URL: https://github.com/llvm/llvm-project/commit/5b06de7f99ef86c484f5fea5542c1868e798ac08
DIFF: https://github.com/llvm/llvm-project/commit/5b06de7f99ef86c484f5fea5542c1868e798ac08.diff

LOG: [X86] Add isLogicOp helper to match ISD::AND/OR/XOR and X86ISD::ANDNP

We could easily support the X86ISD 'float' variants of the logic ops as well, but we don't have good test coverage at the moment (they're mainly for SSE1 targets).

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 9d98d31b31df0b..312e4487a8f17f 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -2631,6 +2631,11 @@ bool X86::mayFoldIntoZeroExtend(SDValue Op) {
   return false;
 }
 
+static bool isLogicOp(unsigned Opcode) {
+  // TODO: Add support for X86ISD::FAND/FOR/FXOR/FANDN with test coverage.
+  return ISD::isBitwiseLogicOp(Opcode) || X86ISD::ANDNP == Opcode;
+}
+
 static bool isTargetShuffle(unsigned Opcode) {
   switch(Opcode) {
   default: return false;
@@ -39975,8 +39980,7 @@ static SDValue canonicalizeShuffleWithOp(SDValue N, SelectionDAG &DAG,
   auto IsSafeToMoveShuffle = [ShuffleVT](SDValue Op, unsigned BinOp) {
     // Ensure we only shuffle whole vector src elements, unless its a logical
     // binops where we can more aggressively move shuffles from dst to src.
-    return BinOp == ISD::AND || BinOp == ISD::OR || BinOp == ISD::XOR ||
-           BinOp == X86ISD::ANDNP ||
+    return isLogicOp(BinOp) ||
            (Op.getScalarValueSizeInBits() <= ShuffleVT.getScalarSizeInBits());
   };
 


        


More information about the llvm-commits mailing list