[llvm] 1c2b756 - [DAG] visitTRUNCATE - move TRUNCATE(ADDE/ADDCARRY) folds to switch statement handling the other binops. NFC.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 21 14:07:57 PDT 2022
Author: Simon Pilgrim
Date: 2022-06-21T22:07:41+01:00
New Revision: 1c2b756cd6f9f9408863fb0e91f55731f81b46d9
URL: https://github.com/llvm/llvm-project/commit/1c2b756cd6f9f9408863fb0e91f55731f81b46d9
DIFF: https://github.com/llvm/llvm-project/commit/1c2b756cd6f9f9408863fb0e91f55731f81b46d9.diff
LOG: [DAG] visitTRUNCATE - move TRUNCATE(ADDE/ADDCARRY) folds to switch statement handling the other binops. NFC.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 58df419c3565..8f44edf379db 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -13333,21 +13333,6 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
if (SimplifyDemandedBits(SDValue(N, 0)))
return SDValue(N, 0);
- // (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.
- if ((N0.getOpcode() == ISD::ADDE || N0.getOpcode() == ISD::ADDCARRY) &&
- N0.hasOneUse() && !N0->hasAnyUseOfValue(1) &&
- // We only do for addcarry before legalize operation
- ((!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));
- auto VTs = DAG.getVTList(VT, N0->getValueType(1));
- return DAG.getNode(N0.getOpcode(), SL, VTs, X, Y, N0.getOperand(2));
- }
-
// fold (truncate (extract_subvector(ext x))) ->
// (extract_subvector x)
// TODO: This can be generalized to cover cases where the truncate and extract
@@ -13392,6 +13377,22 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
}
}
break;
+ case ISD::ADDE:
+ case ISD::ADDCARRY:
+ // (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.
+ // We only do for addcarry before legalize operation
+ if (((!LegalOperations && N0.getOpcode() == ISD::ADDCARRY) ||
+ TLI.isOperationLegal(N0.getOpcode(), VT)) &&
+ N0.hasOneUse() && !N0->hasAnyUseOfValue(1)) {
+ SDLoc DL(N);
+ SDValue X = DAG.getNode(ISD::TRUNCATE, DL, VT, N0.getOperand(0));
+ SDValue Y = DAG.getNode(ISD::TRUNCATE, DL, VT, N0.getOperand(1));
+ SDVTList VTs = DAG.getVTList(VT, N0->getValueType(1));
+ return DAG.getNode(N0.getOpcode(), DL, VTs, X, Y, N0.getOperand(2));
+ }
+ break;
case ISD::USUBSAT:
// Truncate the USUBSAT only if LHS is a known zero-extension, its not
// enough to know that the upper bits are zero we must ensure that we don't
More information about the llvm-commits
mailing list