On Wed, 29 Apr 2020 21:08:52 +0200 (CEST)
Mark Kettenis <mark.kette...@xs4all.nl> wrote:

> Upstream fixed this issue as well.  Apparently only ADDE can't be
> legalized (because it is "special") but ADDCARRY can.  Do ypu want to
> adjust your diff based on that information?
> 
> Either way, ok kettenis@

This adjusted diff changes only ADDE and not ADDCARRY.  I expect it to
work as well as my previous diff (Tue 28 Apr) on PowerPC, because
PowerPC doesn't use ADDCARRY.

After I built macppc clang with the previous diff, I did a successful
"make build" in /usr/src.  I'm not doing another "make build" with
this adjusted diff, but I will check that some other stuff builds.

Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
RCS file: /cvs/src/gnu/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp,v
retrieving revision 1.1.1.8
diff -u -p -r1.1.1.8 DAGCombiner.cpp
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp    23 Jun 2019 21:36:48 -0000      
1.1.1.8
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp    30 Apr 2020 16:18:31 -0000
@@ -9904,9 +9904,11 @@ SDValue DAGCombiner::visitTRUNCATE(SDNod
   // (trunc adde(X, Y, Carry)) -> (adde trunc(X), trunc(Y), Carry)
   // (trunc addcarry(X, Y, Carry)) -> (addcarry trunc(X), trunc(Y), Carry)
   // When the adde's carry is not used.
+  // Don't make an illegal adde: LegalizeDAG can't expand nor promote it.
   if ((N0.getOpcode() == ISD::ADDE || N0.getOpcode() == ISD::ADDCARRY) &&
       N0.hasOneUse() && !N0.getNode()->hasAnyUseOfValue(1) &&
-      (!LegalOperations || TLI.isOperationLegal(N0.getOpcode(), VT))) {
+      ((!LegalOperations && N0.getOpcode() == ISD::ADDCARRY) ||
+       TLI.isOperationLegal(N0.getOpcode(), VT))) {
     SDLoc SL(N);
     auto X = DAG.getNode(ISD::TRUNCATE, SL, VT, N0.getOperand(0));
     auto Y = DAG.getNode(ISD::TRUNCATE, SL, VT, N0.getOperand(1));

Reply via email to