forked from OSchip/llvm-project
Implement Regression/Transforms/InstCombine/bswap-fold.ll,
folding seteq (bswap(x)), c -> seteq(x,bswap(c)) llvm-svn: 32006
This commit is contained in:
parent
e7f83dcf4b
commit
a7942b7bbd
|
@ -4664,7 +4664,7 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simplify seteq and setne instructions...
|
// Simplify seteq and setne instructions with integer constant RHS.
|
||||||
if (I.isEquality()) {
|
if (I.isEquality()) {
|
||||||
bool isSetNE = I.getOpcode() == Instruction::SetNE;
|
bool isSetNE = I.getOpcode() == Instruction::SetNE;
|
||||||
|
|
||||||
|
@ -4780,6 +4780,29 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) {
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
} else if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(Op0)) {
|
||||||
|
// Handle set{eq|ne} <intrinsic>, intcst.
|
||||||
|
switch (II->getIntrinsicID()) {
|
||||||
|
default: break;
|
||||||
|
case Intrinsic::bswap_i16: // seteq (bswap(x)), c -> seteq(x,bswap(c))
|
||||||
|
WorkList.push_back(II); // Dead?
|
||||||
|
I.setOperand(0, II->getOperand(1));
|
||||||
|
I.setOperand(1, ConstantInt::get(Type::UShortTy,
|
||||||
|
ByteSwap_16(CI->getZExtValue())));
|
||||||
|
return &I;
|
||||||
|
case Intrinsic::bswap_i32: // seteq (bswap(x)), c -> seteq(x,bswap(c))
|
||||||
|
WorkList.push_back(II); // Dead?
|
||||||
|
I.setOperand(0, II->getOperand(1));
|
||||||
|
I.setOperand(1, ConstantInt::get(Type::UIntTy,
|
||||||
|
ByteSwap_32(CI->getZExtValue())));
|
||||||
|
return &I;
|
||||||
|
case Intrinsic::bswap_i64: // seteq (bswap(x)), c -> seteq(x,bswap(c))
|
||||||
|
WorkList.push_back(II); // Dead?
|
||||||
|
I.setOperand(0, II->getOperand(1));
|
||||||
|
I.setOperand(1, ConstantInt::get(Type::ULongTy,
|
||||||
|
ByteSwap_64(CI->getZExtValue())));
|
||||||
|
return &I;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else { // Not a SetEQ/SetNE
|
} else { // Not a SetEQ/SetNE
|
||||||
// If the LHS is a cast from an integral value of the same size,
|
// If the LHS is a cast from an integral value of the same size,
|
||||||
|
|
Loading…
Reference in New Issue