diff options
author | Dan Gohman <sunfish@google.com> | 2013-07-01 17:29:45 -0700 |
---|---|---|
committer | Dan Gohman <sunfish@google.com> | 2013-07-01 17:29:45 -0700 |
commit | 0a2260ada3aa52de22168396b72de8851d3ca415 (patch) | |
tree | 4141332d987b0f5572ebf3856741ec0af6b49a80 /tools/test-js-optimizer-asm-pre.js | |
parent | 01708b7529bc4305272277c38c8f6c91ad27e367 (diff) |
Optimize (x<y)&1
Add an optimization to simplifyExpressionsPre to replace (x<y)&1 with x<y
if possible. This comes up frequently in C++ with bool variables.
Diffstat (limited to 'tools/test-js-optimizer-asm-pre.js')
-rw-r--r-- | tools/test-js-optimizer-asm-pre.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/test-js-optimizer-asm-pre.js b/tools/test-js-optimizer-asm-pre.js index c7c92124..7ca941fa 100644 --- a/tools/test-js-optimizer-asm-pre.js +++ b/tools/test-js-optimizer-asm-pre.js @@ -122,6 +122,18 @@ function sign_extension_simplification() { print(5); } } +function compare_result_simplification() { + // Eliminate these '&1's. + HEAP32[$4] = (HEAP32[$5] < HEAP32[$6]) & 1; + HEAP32[$4] = (HEAP32[$5] > HEAP32[$6]) & 1; + HEAP32[$4] = (HEAP32[$5] <= HEAP32[$6]) & 1; + HEAP32[$4] = (HEAP32[$5] <= HEAP32[$6]) & 1; + HEAP32[$4] = (HEAP32[$5] == HEAP32[$6]) & 1; + HEAP32[$4] = (HEAP32[$5] === HEAP32[$6]) & 1; + HEAP32[$4] = (HEAP32[$5] != HEAP32[$6]) & 1; + // Convert the &1 to |0 here, since we don't get an implicit coersion. + var x = (HEAP32[$5] != HEAP32[$6]) & 1; +} function tempDoublePtr($45, $14, $28, $42) { $45 = $45 | 0; $14 = $14 | 0; |