Skip to content

Commit

Permalink
[DAGCombiner] Minor improvements to foldAndOrOfSETCC. NFC
Browse files Browse the repository at this point in the history
Reduce the scope of some variables.
Replace an if with an assertion.

Reviewed By: kmitropoulou

Differential Revision: https://reviews.llvm.org/D156140
  • Loading branch information
topperc committed Jul 25, 2023
1 parent 7084c3e commit 1f5a1b8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6054,17 +6054,15 @@ 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
// predicate of one of the comparisons is the opposite of the other one.
(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;
Expand All @@ -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;
Expand Down

0 comments on commit 1f5a1b8

Please sign in to comment.