public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112361] New: [14 Regression] avx512f-reduce-op-1.c miscompiled since r14-5076
@ 2023-11-03  7:20 jakub at gcc dot gnu.org
  2023-11-03  7:20 ` [Bug tree-optimization/112361] " jakub at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-11-03  7:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112361
           Summary: [14 Regression] avx512f-reduce-op-1.c miscompiled
                    since r14-5076
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

Since r14-5076-g01c18f58d37865d5f3bbe93e666183b54ec608c7 I see
gcc.target/i386/avx512f-reduce-op-1.c execution failure.
Reduced -O2 -mavx512f:
__attribute__((noipa)) float
foo (void)
{
  float a[16] = { 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4 };
  float r3 = 0.0f;
  for (int i = 0; i < 16; i++)
    if ((1 << i) & 0xA6BA)
      r3 = r3 + a[i];
  return r3;
}

int
main ()
{
  if (foo () != 37.0f)
    __builtin_abort ();
}
where before r14-5076 r3 has been correctly computed as 37.0f, but starting
with r14-5076 it is 64.0f, i.e. the masking is ignored and all elements are
added, not just the ones under the mask.
The ifcvt dump has
  _1 = 42682 >> i_31;
  _2 = _1 & 1;
  _24 = _2 != 0;
  _3 = a[i_31];
  _ifc__43 = .COND_ADD (_24, r3_29, _3, r3_29);
which I assume is correct, and vect dump shows computation of the mask but then
instead of using masked addition and at the end of loop reduction (well, can we
vectorize it at all without -ffast-math?) it scalarizes the addition but
doesn't actually conditionalize it.  Note, with -O2 -mavx512f -ffast-math the
.COND_ADD is actually vectorized and so correctly returns 37.0f.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-11-08  7:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-03  7:20 [Bug tree-optimization/112361] New: [14 Regression] avx512f-reduce-op-1.c miscompiled since r14-5076 jakub at gcc dot gnu.org
2023-11-03  7:20 ` [Bug tree-optimization/112361] " jakub at gcc dot gnu.org
2023-11-03  7:22 ` pinskia at gcc dot gnu.org
2023-11-03  7:51 ` rdapp at gcc dot gnu.org
2023-11-03  8:13 ` rguenth at gcc dot gnu.org
2023-11-03  8:14 ` jakub at gcc dot gnu.org
2023-11-04  5:24 ` pinskia at gcc dot gnu.org
2023-11-06  9:51 ` rdapp at gcc dot gnu.org
2023-11-06 10:06 ` rguenther at suse dot de
2023-11-07 21:38 ` cvs-commit at gcc dot gnu.org
2023-11-08  7:01 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).