aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Gohman <sunfish@mozilla.com>2014-03-06 12:23:34 -0800
committerDan Gohman <sunfish@mozilla.com>2014-03-06 12:56:53 -0800
commit68081ee62375a1d900d46f969e38330f14fb8775 (patch)
treeeff19c661971d355ad3894006b63262ec3d2f94d /lib
parent0444ffab64aab77d74252b9c08445cd46b595d84 (diff)
Implement integer promotion for urem, udiv, srem, and sdiv
The optimizer sometimes thinks it's beneficial to truncate all manner of i64 operators to narrower types, even when still wider than the platform's widest legal type.
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/NaCl/PromoteIntegers.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/lib/Transforms/NaCl/PromoteIntegers.cpp b/lib/Transforms/NaCl/PromoteIntegers.cpp
index af34faa7e5..ed374da3dd 100644
--- a/lib/Transforms/NaCl/PromoteIntegers.cpp
+++ b/lib/Transforms/NaCl/PromoteIntegers.cpp
@@ -577,18 +577,38 @@ void PromoteIntegers::convertInstruction(Instruction *Inst, ConversionState &Sta
State.getConverted(Binop->getOperand(1)),
Binop->getName() + ".result", Binop), Binop);
break;
+ // XXX EMSCRIPTEN: Implement {U,S}{Div,Rem}
+ case Instruction::UDiv:
+ case Instruction::URem:
+ NewInst = CopyDebug(BinaryOperator::Create(
+ Binop->getOpcode(),
+ getClearConverted(Binop->getOperand(0),
+ Binop,
+ State),
+ getClearConverted(Binop->getOperand(1),
+ Binop,
+ State),
+ Binop->getName() + ".result", Binop), Binop);
+ break;
+ case Instruction::SDiv:
+ case Instruction::SRem:
+ NewInst = CopyDebug(BinaryOperator::Create(
+ Binop->getOpcode(),
+ getSignExtend(State.getConverted(Binop->getOperand(0)),
+ Binop->getOperand(0),
+ Binop),
+ getSignExtend(State.getConverted(Binop->getOperand(1)),
+ Binop->getOperand(0),
+ Binop),
+ Binop->getName() + ".result", Binop), Binop);
+ break;
case Instruction::FAdd:
case Instruction::FSub:
case Instruction::FMul:
- case Instruction::UDiv:
- case Instruction::SDiv:
case Instruction::FDiv:
- case Instruction::URem:
- case Instruction::SRem:
case Instruction::FRem:
case Instruction::BinaryOpsEnd:
// We should not see FP operators here.
- // We don't handle div.
errs() << *Inst << "\n";
llvm_unreachable("Cannot handle binary operator");
break;