Bug 68588 - [CG] ImageBufferData::getData has an invariant comparison in the inner part of a loop which doesn't get optimized out
Summary: [CG] ImageBufferData::getData has an invariant comparison in the inner part o...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Horton
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2011-09-21 17:23 PDT by Tim Horton
Modified: 2011-09-21 19:03 PDT (History)
3 users (show)

See Also:


Attachments
"repro" (732 bytes, image/svg+xml)
2011-09-21 17:29 PDT, Tim Horton
no flags Details
patch (5.32 KB, patch)
2011-09-21 17:29 PDT, Tim Horton
no flags Details | Formatted Diff | Diff
style fix (5.30 KB, patch)
2011-09-21 17:35 PDT, Tim Horton
no flags Details | Formatted Diff | Diff
patch (5.71 KB, patch)
2011-09-21 18:07 PDT, Tim Horton
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Horton 2011-09-21 17:23:57 PDT
The test of "unmultiplied" inside the inner loop of ImageBufferData::getData is unnecessary; unmultiplied won't change during the course of this calculation.

I would have expected this to be optimized out by the compiler, but this patch provides a consistent and reproducible 1.7x speedup (visible with Instruments) in ImageBufferData::getData in the not-unmultiplied case with the attached test case (requires filters to be turned on).
Comment 1 Radar WebKit Bug Importer 2011-09-21 17:24:24 PDT
<rdar://problem/10164955>
Comment 2 Tim Horton 2011-09-21 17:29:11 PDT
Created attachment 108257 [details]
"repro"
Comment 3 Tim Horton 2011-09-21 17:29:39 PDT
Created attachment 108259 [details]
patch
Comment 4 WebKit Review Bot 2011-09-21 17:32:31 PDT
Attachment 108259 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1

Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp:195:  One line control clauses should not use braces.  [whitespace/braces] [4]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Tim Horton 2011-09-21 17:35:42 PDT
Created attachment 108260 [details]
style fix
Comment 6 Tim Horton 2011-09-21 17:36:11 PDT
I should note that I was testing this on a release build.
Comment 7 Tim Horton 2011-09-21 18:07:49 PDT
Created attachment 108263 [details]
patch

Mark noted that with this patch, I'm not assigning any data in the case of 0 alpha. Fixed.
Comment 8 Simon Fraser (smfr) 2011-09-21 18:38:51 PDT
Comment on attachment 108263 [details]
patch

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

This code grows more and more unwieldy with each change.

> Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp:195
> +                    reinterpret_cast<uint32_t*>(destRows + x)[0] = reinterpret_cast<uint32_t*>(srcRows + x)[0];

Can this be a memcpy?
Comment 9 WebKit Review Bot 2011-09-21 19:03:36 PDT
Comment on attachment 108263 [details]
patch

Clearing flags on attachment: 108263

Committed r95695: <http://trac.webkit.org/changeset/95695>
Comment 10 WebKit Review Bot 2011-09-21 19:03:41 PDT
All reviewed patches have been landed.  Closing bug.