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

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
I think the problem can be seen already at omp-lower, in the body of the
butterfly loop.

Let's first look at what we have if we use reduction op '|':
...
                    D.2173 = .GOMP_SIMT_VF ();
                    D.2164 = 1;
                    D.2161 = 0;
                    goto <D.2175>;
                    <D.2174>:
                    D.2165 = D.2163;
                    D.2165 = D.2163;
                    D.2166 = .GOMP_SIMT_XCHG_BFLY (D.2165, D.2164);
                    D.2167 = D.2165 | D.2166;
                    D.2163 = D.2167;
                    D.2164 = D.2164 << 1;
                    <D.2175>:
                    if (D.2164 < D.2173) goto <D.2174>; else goto <D.2176>;
                    <D.2176>:
...
Fairly straightforward, we have a loop, runs a couple of times, first a shuffle
(GOMP_SIMT_XCHG_BFLY), then an update (D.2167 = D.2165 | D.2166).

Now compare that with reduction op '||':
...
                    D.2183 = .GOMP_SIMT_VF ();
                    D.2164 = 1;
                    D.2161 = 0;
                    goto <D.2185>;
                    <D.2184>:
                    D.2169 = D.2163;
                    D.2170 = (_Bool) D.2169;
                    if (D.2170 != 0) goto <D.2166>; else goto <D.2171>;
                    <D.2171>:
                    D.2169 = D.2163;
                    D.2172 = .GOMP_SIMT_XCHG_BFLY (D.2169, D.2164);
                    D.2173 = (_Bool) D.2172;
                    if (D.2173 != 0) goto <D.2166>; else goto <D.2167>;
                    <D.2166>:
                    iftmp.5 = 1;
                    goto <D.2168>;
                    <D.2167>:
                    iftmp.5 = 0;
                    <D.2168>:
                    D.2163 = iftmp.5;
                    D.2164 = D.2164 << 1;
                    <D.2185>:
                    if (D.2164 < D.2183) goto <D.2184>; else goto <D.2186>;
                    <D.2186>:
...

The shuffle is now conditional.  I think the shuffle is inserted too late, in
the middle of the update rather than before.

Reply via email to