[llvm] [DAGCombine] Propagate truncate to operands (PR #98666)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 24 09:07:48 PDT 2024


================
@@ -5809,9 +5809,14 @@ SDValue DAGCombiner::hoistLogicOpWithSameOpcodeHands(SDNode *N) {
     if (LegalOperations && !TLI.isOperationLegal(LogicOpcode, XVT))
       return SDValue();
     // Be extra careful sinking truncate. If it's free, there's no benefit in
-    // widening a binop. Also, don't create a logic op on an illegal type.
+    // widening a binop.
     if (TLI.isZExtFree(VT, XVT) && TLI.isTruncateFree(XVT, VT))
       return SDValue();
+    // Prevent an infinite loop if the target preferts the inverse
+    // transformation.
+    if (TLI.isNarrowingProfitable(XVT, VT))
+      return SDValue();
+    // Don't create a logic op on an illegal type.
     if (!TLI.isTypeLegal(XVT))
----------------
arsenm wrote:

While you're touching the conditions, this isTypeLegal should have been the first, simplest check before all of these more complicated cases 

https://github.com/llvm/llvm-project/pull/98666


More information about the llvm-commits mailing list