https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84077

            Bug ID: 84077
           Summary: Likely wrong code with `__builtin_expect()` on
                    i686-linux-gnu
           Product: gcc
           Version: 7.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: floessie.mail at gmail dot com
  Target Milestone: ---

Created attachment 43263
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43263&action=edit
CMake generated compile command line

Hi,

We're having some strange behavior with `__builtin_expect()` on
i686-linux-gnu in RawTherapee, probably due to wrong code generation.
The `__builtin_expect()` is used as

#define LIKELY(x)   __builtin_expect (!!(x), 1)

in our code and employed in an `if` within an OpenMP for loop:

https://github.com/Beep6581/RawTherapee/blob/f5bd232cd2a1d709a25c3b3feda88ebf86dd6092/rtengine/dcp.cc#L1077

When compiling RawTherapee on i686 with a vanilla GCC 7.3 a RAW with
a supplied DCP base table will show obviously wrong colors. This is
neither the case with (the Debian) GCC 6.4 on i686 nor with GCC 7.2
on x86_64, but also with GCC 7.2 on i686.

We've worked around that problem by disabling the use of `__builtin_expect()`
on 32 bit platforms with GCC >= 7 for now. See

https://github.com/Beep6581/RawTherapee/pull/4324#issuecomment-360110007

for the original issue.

Reproducing the problem requires building RawTherapee. You can find
instructions for various distributions here:

http://rawpedia.rawtherapee.com/Linux

After cloning, please checkout the commit right before we worked around
the bug:

git checkout f5bd232cd2a1d709a25c3b3feda88ebf86dd6092

You can find an image to test here:

http://rawtherapee.com/shared/test_images/amsterdam.pef

As soon as you open it, the wrong colors will be apparent, as the DCP
base table should be active, otherwise you can find it on the "Color"
tab.

If I forgot anything, just let me know. I can also test patches against
vanilla GCC 7.3.

On behalf of the RawTherapee team,
Flössie

Reply via email to