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

Issue 2158213002: Subzero: Fix lowering for x86 div/rem instructions. (Closed)

Created:
4 years, 5 months ago by Jim Stichnoth
Modified:
4 years, 5 months ago
Reviewers:
Eric Holk, Karl, John, manasijm
CC:
native-client-reviews_googlegroups.com
Base URL:
https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Subzero: Fix lowering for x86 div/rem instructions. The x86 lowering sequences for sdiv/udiv/srem/urem all have a problem, in that they don't reflect the fact that two registers are affected by the instruction. For example, the urem instruction: dest = src0 urem src1 lowers to something like this: t1:eax = src0 t2:edx = 0 t2:edx = (t1:eax and t2:edx) div src1 dest = t2:edx The problem is that there is no indication that the div instruction smashes eax. As such, it's possible that the register allocator could erroneously assume that src0 is still available in eax after the div instruction. To fix this, we make use of the FakeDef instruction. In this example, we change the div instruction to "officially" produce eax as its result, then fakedef edx in terms of eax. This means that as long as the urem result is actually used, the definitions of eax and edx will be preserved, but if the urem result is unused, then the whole sequence can be dead-code eliminated. t1:eax = src0 t2:edx = 0 t1:eax = (t1:eax and t2:edx) div src1 # dest var changed to t1:eax t2:edx = fakedef t1:eax # fakedef instruction added dest = t2:edx BUG= none R=jpp@chromium.org Committed: https://gerrit.chromium.org/gerrit/gitweb?p=native_client/pnacl-subzero.git;a=commit;h=017a55389fd6ef05ad70870363911db0fc816d98

Patch Set 1 #

Total comments: 2

Patch Set 2 : Use the _redefined() utility. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+8 lines, -4 lines) Patch
M src/IceTargetLoweringX86BaseImpl.h View 1 4 chunks +8 lines, -4 lines 0 comments Download

Messages

Total messages: 8 (4 generated)
Jim Stichnoth
Spec2k output is unchanged by this, except for emitting commented-out "fakedef" instructions. I was unable ...
4 years, 5 months ago (2016-07-18 23:36:10 UTC) #4
John
lgtm https://codereview.chromium.org/2158213002/diff/1/src/IceTargetLoweringX86BaseImpl.h File src/IceTargetLoweringX86BaseImpl.h (right): https://codereview.chromium.org/2158213002/diff/1/src/IceTargetLoweringX86BaseImpl.h#newcode2349 src/IceTargetLoweringX86BaseImpl.h:2349: Context.insert<InstFakeDef>(T, T_edx); can you use the _redefined method ...
4 years, 5 months ago (2016-07-19 03:18:19 UTC) #5
Jim Stichnoth
https://codereview.chromium.org/2158213002/diff/1/src/IceTargetLoweringX86BaseImpl.h File src/IceTargetLoweringX86BaseImpl.h (right): https://codereview.chromium.org/2158213002/diff/1/src/IceTargetLoweringX86BaseImpl.h#newcode2349 src/IceTargetLoweringX86BaseImpl.h:2349: Context.insert<InstFakeDef>(T, T_edx); On 2016/07/19 03:18:19, John wrote: > can ...
4 years, 5 months ago (2016-07-19 13:35:35 UTC) #6
Jim Stichnoth
4 years, 5 months ago (2016-07-19 13:35:57 UTC) #8
Message was sent while issue was closed.
Committed patchset #2 (id:20001) manually as
017a55389fd6ef05ad70870363911db0fc816d98 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698