On 2015/03/05 19:44:45, titzer wrote:
As far as I can tell, this just duplicates the logic of context
specialization
in the graph builder. The only advantage here I see is that it avoids
inserting
a branch that would be immediately optimized away after the first round of
context specialization + control reduction.
Have you observed a case where the existing context specialization +
control
reduction doesn't work?
Thank you all for the feedback. The issue is demonstrated by the following
example:
var buffer = new ArrayBuffer(16*1024*1024);
var asm = (function test (glob, env, b) {
'use asm';
const i32 = new glob.Int32Array(b);
var MASK = env.MASK|0;
function f(i, v) {
i = i | 0; v = v | 0;
var j = 0;
for (j = 0; (j | 0) < 10000; j = (j + 4) | 0)
i32[((i + j) & MASK) + 36 >> 2] = v;
return;
}
return f;
})(this, {MASK: 0x680}, buffer);
for (var i = 0; i < 1000000; i++) asm(16, 10);
Without this patch the MASK input to the bitwise-and and is a Phi, with one
input being 'undefined'. The derived type of this Phi is thus not the
constant
MASK, but includes zero. This in turn prevents the bounds check being
derived as
unnecessary, and the array access is encoded as a call which is much slower.
With this patch the generated code becomes:
0x378032006630 80 81fb10270000 cmpl rbx,0x2710
0x378032006636 86 0f8d1f000000 jge 123 (0x37803200665b)
0x37803200663c 92 8d4b04 leal rcx,[rbx+0x4]
0x37803200663f 95 8d1c1a leal rbx,[rdx+rbx*1]
0x378032006642 98 81e380060000 andl rbx,0x680
0x378032006648 104 48be10f0ffa20b7f0000 REX.W movq rsi,0x7f0ba2fff010
<< can
this is hoisted too?
0x378032006652 114 89441e24 movl [rsi+rbx*1+0x24],rax
0x378032006656 118 488bd9 REX.W movq rbx,rcx
0x378032006659 121 ebd5 jmp 80 (0x378032006630)
Perhaps the real issue is elsewhere. Perhaps the branch you mention is not
being
optimized away as cleanly as it could be. Shall explore further.
btw: it would be nice to have the loading of the array base hoisted out of
such
loops too.
https://codereview.chromium.org/967093002/
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.