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

Issue 1146803002: Subzero: Strength-reduce mul by certain constants. (Closed)

Created:
5 years, 7 months ago by Jim Stichnoth
Modified:
5 years, 6 months ago
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: Strength-reduce mul by certain constants. These all appear to some degree in spec2k. This is implemented for i8/i16/i32 types. It is done as part of core lowering, so in theory all optimization levels could benefit, but it is explicitly disabled for Om1/O0 to keep things simple there. While clang appears to strength-reduce udiv/urem by a constant power of 2, for some reason it does not always strength-reduce multiplies (given that they appear in the spec2k bitcode). For multiplies by 3, 5, or 9, we can make use of the lea instruction. We can do combinations of shift and lea to multiply by other constants, e.g. 100=5*5*4. If too many operations would be required, just give up and use the mul instruction. BUG= https://code.google.com/p/nativeclient/issues/detail?id=4095 R=jpp@chromium.org, jvoung@chromium.org Committed: https://gerrit.chromium.org/gerrit/gitweb?p=native_client/pnacl-subzero.git;a=commit;h=0933c0cfb8183a662e44a61d8671b20987d12c78

Patch Set 1 #

Patch Set 2 : Fix existing lit tests #

Patch Set 3 : Also optimize for multiplies by 3/5/9 by using lea #

Patch Set 4 : Disable for Om1 and O0 #

Patch Set 5 : Initial skeleton of a cross test #

Patch Set 6 : Fill out the cross test. Cleanup. #

Total comments: 5

Patch Set 7 : Add lit tests. Suppress lea optimization for i8 multiply. #

Patch Set 8 : Remove a TODO #

Unified diffs Side-by-side diffs Delta from patch set Stats (+589 lines, -181 lines) Patch
M crosstest/crosstest.cfg View 1 2 3 4 5 1 chunk +7 lines, -0 lines 0 comments Download
A crosstest/test_strengthreduce.h View 1 2 3 4 5 1 chunk +23 lines, -0 lines 0 comments Download
A crosstest/test_strengthreduce.cpp View 1 2 3 4 5 1 chunk +30 lines, -0 lines 0 comments Download
A crosstest/test_strengthreduce.def View 1 2 3 4 5 6 1 chunk +38 lines, -0 lines 0 comments Download
A crosstest/test_strengthreduce_main.cpp View 1 2 3 4 5 1 chunk +65 lines, -0 lines 0 comments Download
M pydir/crosstest.py View 1 2 3 4 5 6 2 chunks +5 lines, -2 lines 0 comments Download
M src/IceELFObjectWriter.cpp View 1 2 3 4 5 6 1 chunk +3 lines, -2 lines 0 comments Download
M src/IceGlobalInits.h View 1 2 3 4 5 6 1 chunk +1 line, -3 lines 0 comments Download
M src/IceTargetLoweringX8632.h View 1 2 3 4 5 6 1 chunk +2 lines, -0 lines 0 comments Download
M src/IceTargetLoweringX8632.cpp View 1 2 3 4 5 6 7 5 chunks +340 lines, -166 lines 0 comments Download
M tests_lit/assembler/x86/immediate_encodings.ll View 1 2 3 4 5 6 2 chunks +8 lines, -8 lines 0 comments Download
A tests_lit/llvm2ice_tests/strength-reduce.ll View 1 2 3 4 5 6 1 chunk +67 lines, -0 lines 0 comments Download

Messages

Total messages: 7 (1 generated)
Jim Stichnoth
5 years, 6 months ago (2015-06-09 23:07:05 UTC) #2
John
lgtm If my comment does not make sense, please ignore it... LGTM otherwise. https://codereview.chromium.org/1146803002/diff/100001/src/IceTargetLoweringX8632.cpp File ...
5 years, 6 months ago (2015-06-10 17:27:52 UTC) #3
jvoung (off chromium)
lgtm too -- would it be good to add a .ll test showing the optimization ...
5 years, 6 months ago (2015-06-10 18:12:28 UTC) #4
John
lgtm Still LGTM. https://codereview.chromium.org/1146803002/diff/100001/src/IceTargetLoweringX8632.cpp File src/IceTargetLoweringX8632.cpp (right): https://codereview.chromium.org/1146803002/diff/100001/src/IceTargetLoweringX8632.cpp#newcode1345 src/IceTargetLoweringX8632.cpp:1345: const uint32_t MaxOpsForOptimizedMul = 5; On ...
5 years, 6 months ago (2015-06-10 23:47:19 UTC) #5
Jim Stichnoth
https://codereview.chromium.org/1146803002/diff/100001/src/IceTargetLoweringX8632.cpp File src/IceTargetLoweringX8632.cpp (right): https://codereview.chromium.org/1146803002/diff/100001/src/IceTargetLoweringX8632.cpp#newcode1314 src/IceTargetLoweringX8632.cpp:1314: if (Src1 <= 0) On 2015/06/10 17:27:52, John wrote: ...
5 years, 6 months ago (2015-06-12 17:31:47 UTC) #6
Jim Stichnoth
5 years, 6 months ago (2015-06-12 17:41:21 UTC) #7
Message was sent while issue was closed.
Committed patchset #8 (id:140001) manually as
0933c0cfb8183a662e44a61d8671b20987d12c78 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698