projects
/
platform
/
upstream
/
dotnet
/
runtime.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c8c89a2
)
[RyuJIT] Avoid emitting cdq/coq for a positive constant in rax for idiv (#41551)
author
Egor Bogatov
<egorbo@gmail.com>
Tue, 1 Sep 2020 02:43:25 +0000
(
05:43
+0300)
committer
GitHub
<noreply@github.com>
Tue, 1 Sep 2020 02:43:25 +0000
(19:43 -0700)
* avoid emitting cdq/coq for dividend if it's a positive constant
src/coreclr/src/jit/codegenxarch.cpp
patch
|
blob
|
history
diff --git
a/src/coreclr/src/jit/codegenxarch.cpp
b/src/coreclr/src/jit/codegenxarch.cpp
index
88c021a
..
7e63dd6
100644
(file)
--- a/
src/coreclr/src/jit/codegenxarch.cpp
+++ b/
src/coreclr/src/jit/codegenxarch.cpp
@@
-788,7
+788,8
@@
void CodeGen::genCodeForDivMod(GenTreeOp* treeNode)
genCopyRegIfNeeded(dividend, REG_RAX);
// zero or sign extend rax to rdx
- if (oper == GT_UMOD || oper == GT_UDIV)
+ if (oper == GT_UMOD || oper == GT_UDIV ||
+ (dividend->IsIntegralConst() && (dividend->AsIntConCommon()->IconValue() > 0)))
{
instGen_Set_Reg_To_Zero(EA_PTRSIZE, REG_EDX);
}