Bug 162350 - B3 should have a Depend operation
Summary: B3 should have a Depend operation
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 162343
Blocks:
  Show dependency treegraph
 
Reported: 2016-09-21 11:16 PDT by Filip Pizlo
Modified: 2016-09-21 14:06 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2016-09-21 11:16:30 PDT
On ARM, there's a goofy way to force to loads to be dependent.  Say you have two loads:

a = *p
b = *q

You can make them dependent by doing:

a = *p
b = q[a ^ a]

Obviously, you can't say BitXor(a, a) since that would get strength-reduced away.  But we could introduce a Depend operation like this:

a = *p
b = *Depend(q, a)

On x86, this operation could get blown away just before lowering to Air.  On ARM, this operation would turn into the BitXor hack.

Intriguingly, this Depend operation would be useful even on x86 because it would let us express a load-load fence without pessimizing codegen too much.
Comment 1 JF Bastien 2016-09-21 11:50:08 PDT
Dependency should also support straight pointer chasing dependency. The key is that the compiler can't dematerialize the original pointer load. If you express this dependency then you can skip acquire fences as well.

The address dependency rule is an extra complication for non-pointer-chasing dependencies.
Comment 2 Filip Pizlo 2016-09-21 12:08:27 PDT
(In reply to comment #1)
> Dependency should also support straight pointer chasing dependency. The key
> is that the compiler can't dematerialize the original pointer load. If you
> express this dependency then you can skip acquire fences as well.
> 
> The address dependency rule is an extra complication for non-pointer-chasing
> dependencies.

I think that B3 already supports pointer chasing dependencies correctly.  Depend fills in the non-pointer-chasing case.
Comment 3 Filip Pizlo 2016-09-21 14:06:40 PDT
It's interesting that the way that B3 defines a load-load dependency as: load A load-depends on load B if the address of A cannot be computed without B.

The Depend operation is only necessary if you want to build a dependency like this for code where B is unnecessary for computing the address of A.

This is going to be fun to document.