Bug 150761 - Add conditional moves to the MacroAssembler
Summary: Add conditional moves to the MacroAssembler
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Michael Saboff
URL:
Keywords:
Depends on:
Blocks: 150762
  Show dependency treegraph
 
Reported: 2015-10-31 16:44 PDT by Filip Pizlo
Modified: 2015-11-07 10:11 PST (History)
2 users (show)

See Also:


Attachments
Patch (9.61 KB, patch)
2015-11-03 18:02 PST, Michael Saboff
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2015-10-31 16:44:49 PDT
This would allow us to add Select to B3.  The FTL uses Select quite a bit, so this is probably a good idea.
Comment 1 Michael Saboff 2015-11-03 15:00:46 PST
Select is a non-branching instruction of the form x = select(a, b, c) where if a is non-zero then x = b else x = c.  This is implemented using conditional moves, a CPU instruction that does not branch, but performs a move dependent on some condition.

At the machine code level, a “cmov” is formatted very similarly to a branch, so it’s probably a matter of tweaking our branch formatting code.  We probably want the API to be something like:

m_jit.moveConditionally(LessThan, gpr1, gpr2, gpr3, gpr4); // move gpr3 to gpr4 if gpr1 is less than gpr2.
m_jit.moveConditionallyTest(NonZero, gpr1, gpr2, gpr3, gpr4); // move gpr3 to gpr4 if (gpr1 & gpr2) != 0.
m_jit.moveConditionallyDouble(DoubleEqual, fpr1, fpr2, gpr1, gpr2) // move gpr1 to gpr2 if fpr1 == fpr2.
Comment 2 Michael Saboff 2015-11-03 18:02:18 PST
Created attachment 264761 [details]
Patch
Comment 3 WebKit Commit Bot 2015-11-07 10:11:36 PST
Comment on attachment 264761 [details]
Patch

Clearing flags on attachment: 264761

Committed r192131: <http://trac.webkit.org/changeset/192131>
Comment 4 WebKit Commit Bot 2015-11-07 10:11:40 PST
All reviewed patches have been landed.  Closing bug.