[PATCH] D130333: [DAGCombiner] Simplify code around call to reduceLoadWidth in visitAND. NFC

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 23:47:40 PDT 2022


craig.topper created this revision.
craig.topper added reviewers: efriedma, RKSimon, spatel.
Herald added subscribers: StephenFan, ecnelises, hiraditya.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: LLVM.

We were looking for loads or any_extend+load. reduceLoadWidth
hasn't known how to look through such an any_extend to find the
load since D40667 <https://reviews.llvm.org/D40667> almost 5 years ago.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130333

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -6364,17 +6364,9 @@
   // fold (and (load x), 255) -> (zextload x, i8)
   // fold (and (extload x, i16), 255) -> (zextload x, i8)
   // fold (and (any_ext (extload x, i16)), 255) -> (zextload x, i8)
-  if (!VT.isVector() && N1C && (N0.getOpcode() == ISD::LOAD ||
-                                (N0.getOpcode() == ISD::ANY_EXTEND &&
-                                 N0.getOperand(0).getOpcode() == ISD::LOAD))) {
-    if (SDValue Res = reduceLoadWidth(N)) {
-      LoadSDNode *LN0 = N0->getOpcode() == ISD::ANY_EXTEND
-        ? cast<LoadSDNode>(N0.getOperand(0)) : cast<LoadSDNode>(N0);
-      AddToWorklist(N);
-      DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 0), Res);
-      return SDValue(N, 0);
-    }
-  }
+  if (!VT.isVector() && N1C && (N0.getOpcode() == ISD::LOAD))
+    if (SDValue Res = reduceLoadWidth(N))
+      return Res;
 
   if (LegalTypes) {
     // Attempt to propagate the AND back up to the leaves which, if they're


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130333.446724.patch
Type: text/x-patch
Size: 1165 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220722/dd7e66b8/attachment.bin>


More information about the llvm-commits mailing list