aboutsummaryrefslogtreecommitdiff
path: root/tools/test-js-optimizer-asm-pre.js
diff options
context:
space:
mode:
authorDan Gohman <sunfish@google.com>2013-07-08 11:23:18 -0700
committerDan Gohman <sunfish@google.com>2013-07-08 11:23:18 -0700
commitb090967580b4b1d03134b4dd11d849fd50f23951 (patch)
tree041e5826045ab5482ac715b4e391cb30a09affea /tools/test-js-optimizer-asm-pre.js
parent3117fa129fe2aef34a7c954bfe02c1eb0e5f8d29 (diff)
Xor optimizations.
Optimize x^-1 to ~x; this comes up because LLVM does not have a bitwise negate operator. Optimize x&1^1 to !x; this comes up because of how LLVM lowers C++ bool variables. Also, add an optimization to simplifyExpressionsPre to eliminate |0 from '~' expressions in more cases.
Diffstat (limited to 'tools/test-js-optimizer-asm-pre.js')
-rw-r--r--tools/test-js-optimizer-asm-pre.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/test-js-optimizer-asm-pre.js b/tools/test-js-optimizer-asm-pre.js
index 7ca941fa..5c09043e 100644
--- a/tools/test-js-optimizer-asm-pre.js
+++ b/tools/test-js-optimizer-asm-pre.js
@@ -64,6 +64,12 @@ function b($this, $__n) {
HEAP32[(($this + 4 | 0) & 16777215) >> 2] = $40;
}
HEAP8[($38 + $40 | 0) & 16777215] = 0;
+ // Eliminate the |0.
+ HEAP32[$4] = ((~(HEAP32[$5]|0))|0);
+ // Rewrite to ~.
+ HEAP32[$4] = HEAP32[$5]^-1;
+ // Rewrite to ~ and eliminate the |0.
+ HEAP32[$4] = ((HEAP32[$5]|0)^-1)|0;
return;
}
function rett() {