aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@sifive.com>2023-07-25 00:20:05 -0700
committerCraig Topper <craig.topper@sifive.com>2023-07-25 00:20:06 -0700
commit1f5a1b8952921c39ed0f4a50872990533661278b (patch)
tree0fddb5914c32d53305782a38e5d30cfa70a10ca9
parent7084c3ee93e2c85071da626ed540abce4343cebf (diff)
downloadllvm-1f5a1b8952921c39ed0f4a50872990533661278b.zip
llvm-1f5a1b8952921c39ed0f4a50872990533661278b.tar.gz
llvm-1f5a1b8952921c39ed0f4a50872990533661278b.tar.bz2
[DAGCombiner] Minor improvements to foldAndOrOfSETCC. NFC
Reduce the scope of some variables. Replace an if with an assertion. Reviewed By: kmitropoulou Differential Revision: https://reviews.llvm.org/D156140
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 0cbf7bd..de909cc 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -6054,10 +6054,6 @@ static SDValue foldAndOrOfSETCC(SDNode *LogicOp, SelectionDAG &DAG) {
TLI.isOperationLegal(ISD::SMAX, OpVT) &&
TLI.isOperationLegal(ISD::UMIN, OpVT) &&
TLI.isOperationLegal(ISD::SMIN, OpVT)) {
- SDValue CommonValue;
- SDValue Operand1;
- SDValue Operand2;
- ISD::CondCode CC = ISD::SETCC_INVALID;
if (LHS->getOpcode() == ISD::SETCC && RHS->getOpcode() == ISD::SETCC &&
LHS->hasOneUse() && RHS->hasOneUse() &&
// The two comparisons should have either the same predicate or the
@@ -6065,6 +6061,8 @@ static SDValue foldAndOrOfSETCC(SDNode *LogicOp, SelectionDAG &DAG) {
(CCL == CCR || CCL == ISD::getSetCCSwappedOperands(CCR)) &&
// The optimization does not work for `==` or `!=` .
!ISD::isIntEqualitySetCC(CCL) && !ISD::isIntEqualitySetCC(CCR)) {
+ SDValue CommonValue, Operand1, Operand2;
+ ISD::CondCode CC = ISD::SETCC_INVALID;
if (CCL == CCR) {
if (LHS0 == RHS0) {
CommonValue = LHS0;
@@ -6077,7 +6075,8 @@ static SDValue foldAndOrOfSETCC(SDNode *LogicOp, SelectionDAG &DAG) {
Operand2 = RHS0;
CC = CCL;
}
- } else if (CCL == ISD::getSetCCSwappedOperands(CCR)) {
+ } else {
+ assert(CCL == ISD::getSetCCSwappedOperands(CCR) && "Unexpected CC");
if (LHS0 == RHS1) {
CommonValue = LHS0;
Operand1 = LHS1;