[llvm] ce2345d - [X86] getTargetShuffleInputs - ensure we limit the maximum recursion depth to match SelectionDAG::MaxRecursionDepth

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 18 07:25:33 PST 2022


Author: Simon Pilgrim
Date: 2022-01-18T15:25:21Z
New Revision: ce2345d8c14b2c8b9a420b8ca53dc1ea5d43dc6a

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

LOG: [X86] getTargetShuffleInputs - ensure we limit the maximum recursion depth to match SelectionDAG::MaxRecursionDepth

Regressions were pre-handled by rG62e36b120749

Fixes Issue #52960

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 a0e1f4aa6ca4..d4c757fba154 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -7922,6 +7922,7 @@ static bool getTargetShuffleInputs(SDValue Op, SmallVectorImpl<SDValue> &Inputs,
 // Attempt to decode ops that could be represented as a shuffle mask.
 // The decoded shuffle mask may contain a 
diff erent number of elements to the
 // destination value type.
+// TODO: Merge into getTargetShuffleInputs()
 static bool getFauxShuffleMask(SDValue N, const APInt &DemandedElts,
                                SmallVectorImpl<int> &Mask,
                                SmallVectorImpl<SDValue> &Ops,
@@ -8370,6 +8371,9 @@ static bool getTargetShuffleInputs(SDValue Op, const APInt &DemandedElts,
                                    APInt &KnownUndef, APInt &KnownZero,
                                    const SelectionDAG &DAG, unsigned Depth,
                                    bool ResolveKnownElts) {
+  if (Depth >= SelectionDAG::MaxRecursionDepth)
+    return false; // Limit search depth.
+
   EVT VT = Op.getValueType();
   if (!VT.isSimple() || !VT.isVector())
     return false;


        


More information about the llvm-commits mailing list