mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 00:32:55 +00:00
Instcombine: X * -1 -> -X
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6904 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5db61fdc8a
commit
0af1fab019
@ -361,10 +361,11 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
|
||||
if (Constant *Op1 = dyn_cast<Constant>(I.getOperand(1))) {
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
|
||||
const Type *Ty = CI->getType();
|
||||
uint64_t Val = Ty->isSigned() ?
|
||||
(uint64_t)cast<ConstantSInt>(CI)->getValue() :
|
||||
cast<ConstantUInt>(CI)->getValue();
|
||||
int64_t Val = Ty->isSigned() ? cast<ConstantSInt>(CI)->getValue() :
|
||||
(int64_t)cast<ConstantUInt>(CI)->getValue();
|
||||
switch (Val) {
|
||||
case -1: // X * -1 -> -X
|
||||
return BinaryOperator::createNeg(Op0, I.getName());
|
||||
case 0:
|
||||
return ReplaceInstUsesWith(I, Op1); // Eliminate 'mul double %X, 0'
|
||||
case 1:
|
||||
|
Loading…
x
Reference in New Issue
Block a user