[llvm] a834b79 - [X86] foldMaskAndShiftToExtract - as long as we call insertDAGNode in the creation order then duplicates don't matter.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 18 07:14:21 PDT 2023


Author: Simon Pilgrim
Date: 2023-08-18T15:14:06+01:00
New Revision: a834b79b7de3870045e039367775c988920d7d3a

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

LOG: [X86] foldMaskAndShiftToExtract - as long as we call insertDAGNode in the creation order then duplicates don't matter.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index ddb48ab49fee3e..b9bc1a4f07400b 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -1939,8 +1939,8 @@ static bool foldMaskAndShiftToExtract(SelectionDAG &DAG, SDValue N,
   SDValue NewMask = DAG.getConstant(0xff, DL, XVT);
   SDValue Srl = DAG.getNode(ISD::SRL, DL, XVT, X, Eight);
   SDValue And = DAG.getNode(ISD::AND, DL, XVT, Srl, NewMask);
-  SDValue ShlCount = DAG.getConstant(ScaleLog, DL, MVT::i8);
   SDValue Ext = DAG.getZExtOrTrunc(And, DL, VT);
+  SDValue ShlCount = DAG.getConstant(ScaleLog, DL, MVT::i8);
   SDValue Shl = DAG.getNode(ISD::SHL, DL, VT, Ext, ShlCount);
 
   // Insert the new nodes into the topological ordering. We must do this in
@@ -1949,12 +1949,11 @@ static bool foldMaskAndShiftToExtract(SelectionDAG &DAG, SDValue N,
   // essentially a pre-flattened and pre-sorted sequence of nodes. There is no
   // hierarchy left to express.
   insertDAGNode(DAG, N, Eight);
-  insertDAGNode(DAG, N, Srl);
   insertDAGNode(DAG, N, NewMask);
+  insertDAGNode(DAG, N, Srl);
   insertDAGNode(DAG, N, And);
+  insertDAGNode(DAG, N, Ext);
   insertDAGNode(DAG, N, ShlCount);
-  if (Ext != And)
-    insertDAGNode(DAG, N, Ext);
   insertDAGNode(DAG, N, Shl);
   DAG.ReplaceAllUsesWith(N, Shl);
   DAG.RemoveDeadNode(N.getNode());


        


More information about the llvm-commits mailing list