Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: src/IceTargetLoweringX8632.cpp

Issue 339643003: Legalize div/idiv operands to avoid immediates. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: default args Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/div_legalization.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTargetLoweringX8632.cpp
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 46a587fe1f139727438baf153e72f350b3945311..1e510471a902343e8b794a3dd7a8a9a1eb20862a 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -1136,6 +1136,9 @@ void TargetX8632::lowerArithmetic(const InstArithmetic *Inst) {
_mov(Dest, T);
break;
case InstArithmetic::Udiv:
+ // div and idiv are the few arithmetic operators that do not allow
+ // immediates as the operand.
+ Src1 = legalize(Src1, Legal_Reg | Legal_Mem);
if (Dest->getType() == IceType_i8) {
Variable *T_ah = NULL;
Constant *Zero = Ctx->getConstantInt(IceType_i8, 0);
@@ -1152,6 +1155,7 @@ void TargetX8632::lowerArithmetic(const InstArithmetic *Inst) {
}
break;
case InstArithmetic::Sdiv:
+ Src1 = legalize(Src1, Legal_Reg | Legal_Mem);
T_edx = makeReg(IceType_i32, Reg_edx);
_mov(T, Src0, Reg_eax);
_cdq(T_edx, T);
@@ -1159,6 +1163,7 @@ void TargetX8632::lowerArithmetic(const InstArithmetic *Inst) {
_mov(Dest, T);
break;
case InstArithmetic::Urem:
+ Src1 = legalize(Src1, Legal_Reg | Legal_Mem);
if (Dest->getType() == IceType_i8) {
Variable *T_ah = NULL;
Constant *Zero = Ctx->getConstantInt(IceType_i8, 0);
@@ -1175,6 +1180,7 @@ void TargetX8632::lowerArithmetic(const InstArithmetic *Inst) {
}
break;
case InstArithmetic::Srem:
+ Src1 = legalize(Src1, Legal_Reg | Legal_Mem);
T_edx = makeReg(IceType_i32, Reg_edx);
_mov(T, Src0, Reg_eax);
_cdq(T_edx, T);
@@ -1370,7 +1376,7 @@ void TargetX8632::lowerCast(const InstCast *Inst) {
// computing the strength-reduced result at translation time, but we're
// unlikely to see something like that in the bitcode that the optimizer
// wouldn't have already taken care of.
- Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem, true);
+ Operand *Src0RM = legalize(Inst->getSrc(0), Legal_Reg | Legal_Mem);
switch (CastKind) {
default:
Func->setError("Cast type not supported");
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/div_legalization.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698