[RISCV] Refactor translateSetCCForBranch to prepare for D130508. NFC.
D130508 handles more constants than just 1 or -1. We need to extract the constant instead of relying isOneConstant or isAllOnesConstant.
This commit is contained in:
parent
1e636f2676
commit
45944e7cf4
|
@ -1406,19 +1406,29 @@ static void translateSetCCForBranch(const SDLoc &DL, SDValue &LHS, SDValue &RHS,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto *RHSC = dyn_cast<ConstantSDNode>(RHS)) {
|
||||||
|
int64_t C = RHSC->getSExtValue();
|
||||||
|
switch (CC) {
|
||||||
|
default: break;
|
||||||
|
case ISD::SETGT:
|
||||||
// Convert X > -1 to X >= 0.
|
// Convert X > -1 to X >= 0.
|
||||||
if (CC == ISD::SETGT && isAllOnesConstant(RHS)) {
|
if (C == -1) {
|
||||||
RHS = DAG.getConstant(0, DL, RHS.getValueType());
|
RHS = DAG.getConstant(0, DL, RHS.getValueType());
|
||||||
CC = ISD::SETGE;
|
CC = ISD::SETGE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Convert X < 1 to 0 >= X.
|
break;
|
||||||
if (CC == ISD::SETLT && isOneConstant(RHS)) {
|
case ISD::SETLT:
|
||||||
|
// Convert X < 1 to 0 <= X.
|
||||||
|
if (C == 1) {
|
||||||
RHS = LHS;
|
RHS = LHS;
|
||||||
LHS = DAG.getConstant(0, DL, RHS.getValueType());
|
LHS = DAG.getConstant(0, DL, RHS.getValueType());
|
||||||
CC = ISD::SETGE;
|
CC = ISD::SETGE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (CC) {
|
switch (CC) {
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue