Bug 151321

Summary: B3 should be be clever about choosing which child to reuse for result in two-operand commutative operations
Product: WebKit Reporter: Filip Pizlo <fpizlo>
Component: JavaScriptCoreAssignee: Filip Pizlo <fpizlo>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, benjamin, buildbot, commit-queue, ggaren, mark.lam, mhahnenb, msaboff, nrotem, oliver, rniwa, saam, sam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 150279    
Attachments:
Description Flags
I wrote some code
none
almost happy with it
none
the patch
buildbot: commit-queue-
Archive of layout-test-results from ews100 for mac-yosemite
none
Archive of layout-test-results from ews105 for mac-yosemite-wk2
none
Archive of layout-test-results from ews117 for mac-yosemite
none
the patch ggaren: review+

Description Filip Pizlo 2015-11-16 13:19:53 PST
If we have:

    Int32 @3 = Add(@1, @2)

and we know that @1 will die, then we should lower this to:

    Move %tmp1, %tmp3
    Add32 %tmp2, %tmp3

But if we know that @2 will die, then we should lower this to:

    Move %tmp2, %tmp3
    Add32 %tmp1, %tmp3
Comment 1 Filip Pizlo 2015-11-28 11:50:56 PST
Created attachment 266214 [details]
I wrote some code
Comment 2 Filip Pizlo 2015-11-29 16:06:13 PST
Created attachment 266227 [details]
almost happy with it

This is a regression on imaging-gaussian-blur because it commutes something that really should not have been commuted.  I'm thinking about what to do.
Comment 3 Filip Pizlo 2015-11-29 17:29:31 PST
Created attachment 266229 [details]
the patch
Comment 4 Filip Pizlo 2015-11-29 17:30:32 PST
Comment on attachment 266229 [details]
the patch

View in context: https://bugs.webkit.org/attachment.cgi?id=266229&action=review

> Source/JavaScriptCore/dfg/DFGCommon.h:41
> -#define FTL_USES_B3 0
> +#define FTL_USES_B3 1

I will revert, I promise!
Comment 5 WebKit Commit Bot 2015-11-29 17:32:01 PST
Attachment 266229 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/b3/B3PhiChildren.h:154:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Total errors found: 1 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Build Bot 2015-11-29 18:14:09 PST
Comment on attachment 266229 [details]
the patch

Attachment 266229 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/494819

Number of test failures exceeded the failure limit.
Comment 7 Build Bot 2015-11-29 18:14:12 PST
Created attachment 266231 [details]
Archive of layout-test-results from ews100 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 8 Build Bot 2015-11-29 18:15:33 PST
Comment on attachment 266229 [details]
the patch

Attachment 266229 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/494816

Number of test failures exceeded the failure limit.
Comment 9 Build Bot 2015-11-29 18:15:35 PST
Created attachment 266232 [details]
Archive of layout-test-results from ews105 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 10 Build Bot 2015-11-29 18:16:05 PST
Comment on attachment 266229 [details]
the patch

Attachment 266229 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/494812

Number of test failures exceeded the failure limit.
Comment 11 Build Bot 2015-11-29 18:16:07 PST
Created attachment 266233 [details]
Archive of layout-test-results from ews117 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews117  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 12 Filip Pizlo 2015-11-30 10:36:16 PST
Created attachment 266251 [details]
the patch
Comment 13 WebKit Commit Bot 2015-11-30 10:37:23 PST
Attachment 266251 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/b3/B3PhiChildren.h:154:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Total errors found: 1 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 14 Geoffrey Garen 2015-11-30 12:14:21 PST
Comment on attachment 266251 [details]
the patch

View in context: https://bugs.webkit.org/attachment.cgi?id=266251&action=review

r=me

> Source/JavaScriptCore/ChangeLog:8
> +        When lowering a commutative operation two a two-operand instruction, you have a choice of which

to

> Source/JavaScriptCore/b3/B3LowerToAir.cpp:542
> +        // then we can flip things around to held coalescing, which then kills the move instruction.

help

> Source/JavaScriptCore/b3/B3PhiChildren.h:109
> +        UpsilonCollection()
> +        {
> +        }

Do we use this null initializer? I couldn't find its use.

If we do use it, we should probably null-initialize our data members.
Comment 15 Filip Pizlo 2015-11-30 12:18:55 PST
(In reply to comment #14)
> Comment on attachment 266251 [details]
> the patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=266251&action=review
> 
> r=me
> 
> > Source/JavaScriptCore/ChangeLog:8
> > +        When lowering a commutative operation two a two-operand instruction, you have a choice of which
> 
> to
> 
> > Source/JavaScriptCore/b3/B3LowerToAir.cpp:542
> > +        // then we can flip things around to held coalescing, which then kills the move instruction.
> 
> help
> 
> > Source/JavaScriptCore/b3/B3PhiChildren.h:109
> > +        UpsilonCollection()
> > +        {
> > +        }
> 
> Do we use this null initializer? I couldn't find its use.
> 
> If we do use it, we should probably null-initialize our data members.

I added the new-style { } initializers.  I like it when these classes have a null initializer because then you can use them more freely, like:

PhiChildren::UpsilonCollection x;
if (things)
    x = phis[index];
else
    x = otherPhis[index];
Comment 16 Filip Pizlo 2015-11-30 15:20:23 PST
Landed in http://trac.webkit.org/changeset/192816