mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-14 15:25:25 +00:00
InstCombine: Optimize x/INT_MIN to x==INT_MIN
The result of x/INT_MIN is either 0 or 1, we can just use an icmp instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212167 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -993,6 +993,10 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) {
|
||||
}
|
||||
|
||||
if (Constant *RHS = dyn_cast<Constant>(Op1)) {
|
||||
// X/INT_MIN -> X == INT_MIN
|
||||
if (RHS->isMinSignedValue())
|
||||
return new ZExtInst(Builder->CreateICmpEQ(Op0, Op1), I.getType());
|
||||
|
||||
// -X/C --> X/-C provided the negation doesn't overflow.
|
||||
if (SubOperator *Sub = dyn_cast<SubOperator>(Op0))
|
||||
if (match(Sub->getOperand(0), m_Zero()) && Sub->hasNoSignedWrap())
|
||||
|
Reference in New Issue
Block a user