Skip to content

Commit be264b0

Browse files
committed
Fix unassigned add handling in aarch64
1 parent b9ad0b6 commit be264b0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5279,6 +5279,13 @@ SDValue DAGCombiner::visitAVG(SDNode *N) {
52795279
DAG.getNode(ISD::ADD, DL, VT, N0, DAG.getAllOnesConstant(DL, VT)));
52805280
}
52815281

5282+
// Fold shadd(x,y) -> uhadd(x,y) if both x and y are non-negative
5283+
if (Opcode == ISD::SHADD && !hasOperation(ISD::SHADD, VT) &&
5284+
(!LegalOperations || hasOperation(ISD::UHADD, VT))) {
5285+
if (DAG.isKnownNeverNegative(N0) && DAG.isKnownNeverNegative(N1))
5286+
return DAG.getNode(ISD::UHADD, DL, VT, N0, N1);
5287+
}
5288+
52825289
return SDValue();
52835290
}
52845291

0 commit comments

Comments
 (0)