forked from OSchip/llvm-project
[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,18 +1406,28 @@ static void translateSetCCForBranch(const SDLoc &DL, SDValue &LHS, SDValue &RHS,
|
|||
}
|
||||
}
|
||||
|
||||
// Convert X > -1 to X >= 0.
|
||||
if (CC == ISD::SETGT && isAllOnesConstant(RHS)) {
|
||||
RHS = DAG.getConstant(0, DL, RHS.getValueType());
|
||||
CC = ISD::SETGE;
|
||||
return;
|
||||
}
|
||||
// Convert X < 1 to 0 >= X.
|
||||
if (CC == ISD::SETLT && isOneConstant(RHS)) {
|
||||
RHS = LHS;
|
||||
LHS = DAG.getConstant(0, DL, RHS.getValueType());
|
||||
CC = ISD::SETGE;
|
||||
return;
|
||||
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.
|
||||
if (C == -1) {
|
||||
RHS = DAG.getConstant(0, DL, RHS.getValueType());
|
||||
CC = ISD::SETGE;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case ISD::SETLT:
|
||||
// Convert X < 1 to 0 <= X.
|
||||
if (C == 1) {
|
||||
RHS = LHS;
|
||||
LHS = DAG.getConstant(0, DL, RHS.getValueType());
|
||||
CC = ISD::SETGE;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (CC) {
|
||||
|
|
Loading…
Reference in New Issue