[llvm] Fix unassigned add handling in aarch64 (PR #86636)
Yusuke Abe via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 20 01:26:44 PDT 2024
https://github.com/chansuke updated https://github.com/llvm/llvm-project/pull/86636
>From be264b099285cb61d8c442557644ad793afca277 Mon Sep 17 00:00:00 2001
From: chansuke <moonset20 at gmail.com>
Date: Thu, 20 Jun 2024 17:22:06 +0900
Subject: [PATCH] Fix unassigned add handling in aarch64
---
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 254d63abdf805..b62b0484c266f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -5279,6 +5279,13 @@ SDValue DAGCombiner::visitAVG(SDNode *N) {
DAG.getNode(ISD::ADD, DL, VT, N0, DAG.getAllOnesConstant(DL, VT)));
}
+ // Fold shadd(x,y) -> uhadd(x,y) if both x and y are non-negative
+ if (Opcode == ISD::SHADD && !hasOperation(ISD::SHADD, VT) &&
+ (!LegalOperations || hasOperation(ISD::UHADD, VT))) {
+ if (DAG.isKnownNeverNegative(N0) && DAG.isKnownNeverNegative(N1))
+ return DAG.getNode(ISD::UHADD, DL, VT, N0, N1);
+ }
+
return SDValue();
}
More information about the llvm-commits
mailing list