Hi Immanuel,

I talked to our TurboFan experts. As suspected, TurboFan currently does not
do any predication. In fact, the backend is lacking support for conditional
moves, so it would be a bigger undertaking to add such an optimization.
Also, other experiments have shown that branches often perform even better
than conditional moves, as in *most* cases, branches are pretty predictable
(see the pointer compression blog post
<https://v8.dev/blog/pointer-compression#bump-(1)%2C-%2B7%25>).

Also loop unrolling is an optimization we don't currently support. We do
some loop peeling, but that does not help in your case.
Loop unrolling of course would be an optimization you could do on the wasm
code you generate. But without conditional moves, that probably does not
give a significant gain.

So I am afraid there is no way currently to make that loop significantly
faster in TurboFan.

Cheers,
Clemens


On Wed, Apr 22, 2020 at 2:11 PM Immanuel Haffner <haffner.imman...@gmail.com>
wrote:

> Hi Clemens,
>
> in the example, the conditional branch is 50/50 true/false (per iteration)
> and hence a worst-case for branch prediction. Therefore, it seams
> reasonable that the machine code with a conditional branch is so much
> slower than the code with predication.
>
> Since we produce the WASM code ourselves we can fully trust it. So I
> disabled boundary checks with --no-wasm-bounds-checks and the check in the
> hot loop disappeard but this had no performance impact. As you already
> said, this branch is perfectly predictable.
>
> If there is an optimization pass that can perform predication, how would I
> instruct TurboFan to run it? In fact, in our system we know whether a
> branch will be predictable. So it would be great if we could opt-in to an
> optimization pass to perform predication if we deem it worthwhile. Directly
> generating predicated code is hypothetically possible, but a considerable
> development effort on our side and has the potential for code duplication.
> (This needs further investigation on my side.)
>
> Thanks a lot, Clemens :)
> Regards, Immanuel
>
> --
> --
> v8-dev mailing list
> v8-dev@googlegroups.com
> 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 v8-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/v8-dev/449743d7-f969-4d65-a1ab-a8b3aaa4ba1f%40googlegroups.com
> <https://groups.google.com/d/msgid/v8-dev/449743d7-f969-4d65-a1ab-a8b3aaa4ba1f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

Clemens Backes

Software Engineer

cleme...@google.com

Google Germany GmbH

Erika-Mann-Straße 33

80636 München

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten
haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter,
löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen,
dass die E-Mail an die falsche Person gesendet wurde.


This e-mail is confidential. If you received this communication by mistake,
please don't forward it to anyone else, please erase all copies and
attachments, and please let me know that it has gone to the wrong person.

-- 
-- 
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/CAGO%3DqhAFc2RsgSp3KJfR-20-j-EmKNuH_dbTW9GpudQyipgsLQ%40mail.gmail.com.

Reply via email to