mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-30 20:24:32 +00:00
InstSimplify: Move a transform from InstCombine to InstSimplify
Several combines involving icmp (shl C2, %X) C1 can be simplified without introducing any new instructions. Move them to InstSimplify; while we are at it, make them more powerful. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216642 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1503,16 +1503,10 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
||||
unsigned RHSLog2 = RHSV.logBase2();
|
||||
|
||||
// (1 << X) >= 2147483648 -> X >= 31 -> X == 31
|
||||
// (1 << X) > 2147483648 -> X > 31 -> false
|
||||
// (1 << X) <= 2147483648 -> X <= 31 -> true
|
||||
// (1 << X) < 2147483648 -> X < 31 -> X != 31
|
||||
if (RHSLog2 == TypeBits-1) {
|
||||
if (Pred == ICmpInst::ICMP_UGE)
|
||||
Pred = ICmpInst::ICMP_EQ;
|
||||
else if (Pred == ICmpInst::ICMP_UGT)
|
||||
return ReplaceInstUsesWith(ICI, Builder->getFalse());
|
||||
else if (Pred == ICmpInst::ICMP_ULE)
|
||||
return ReplaceInstUsesWith(ICI, Builder->getTrue());
|
||||
else if (Pred == ICmpInst::ICMP_ULT)
|
||||
Pred = ICmpInst::ICMP_NE;
|
||||
}
|
||||
@ -1547,10 +1541,6 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
||||
if (RHSVIsPowerOf2)
|
||||
return new ICmpInst(
|
||||
Pred, X, ConstantInt::get(RHS->getType(), RHSV.logBase2()));
|
||||
|
||||
return ReplaceInstUsesWith(
|
||||
ICI, Pred == ICmpInst::ICMP_EQ ? Builder->getFalse()
|
||||
: Builder->getTrue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user