Turn X < 0 -> TEST X,X js

llvm-svn: 30294
This commit is contained in:
Chris Lattner 2006-09-13 17:04:54 +00:00
parent 0c9ae46c5f
commit 971e33930d
1 changed files with 11 additions and 8 deletions

View File

@ -1873,14 +1873,17 @@ static bool translateX86CC(ISD::CondCode SetCCOpcode, bool isFP,
SelectionDAG &DAG) {
X86CC = X86ISD::COND_INVALID;
if (!isFP) {
if (SetCCOpcode == ISD::SETGT) {
if (ConstantSDNode *RHSC = dyn_cast<ConstantSDNode>(RHS))
if (RHSC->isAllOnesValue()) {
// X > -1 -> X == 0, jump on sign.
RHS = DAG.getConstant(0, RHS.getValueType());
X86CC = X86ISD::COND_NS;
return true;
}
if (ConstantSDNode *RHSC = dyn_cast<ConstantSDNode>(RHS)) {
if (SetCCOpcode == ISD::SETGT && RHSC->isAllOnesValue()) {
// X > -1 -> X == 0, jump !sign.
RHS = DAG.getConstant(0, RHS.getValueType());
X86CC = X86ISD::COND_NS;
return true;
} else if (SetCCOpcode == ISD::SETLT && RHSC->isNullValue()) {
// X < 0 -> X == 0, jump on sign.
X86CC = X86ISD::COND_S;
return true;
}
}
switch (SetCCOpcode) {