[Bug target/114339] [13/14 regression] Tor miscompiled with -O2 -mavx -fno-vect-cost-model since r14-6822

2024-03-15 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114339

--- Comment #16 from GCC Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:ab2da8fb67b1aa0557a16b62689a888730dba610

commit r14-9494-gab2da8fb67b1aa0557a16b62689a888730dba610
Author: Jakub Jelinek 
Date:   Fri Mar 15 10:46:47 2024 +0100

i386: Fix a pasto in ix86_expand_int_sse_cmp [PR114339]

In r13-3803-gfa271afb58 I've added an optimization for LE/LEU/GE/GEU
comparison against CONST_VECTOR.  As the comments say:
 /* x <= cst can be handled as x < cst + 1 unless there is
wrap around in cst + 1.  */
...
 /* For LE punt if some element is signed maximum.  */
...
 /* For LEU punt if some element is unsigned maximum.  */
and
 /* x >= cst can be handled as x > cst - 1 unless there is
wrap around in cst - 1.  */
...
 /* For GE punt if some element is signed minimum.  */
...
 /* For GEU punt if some element is zero.  */
Apparently I wrote the GE/GEU (second case) first and then
copied/adjusted it for LE/LEU, most of the adjustments look correct, but
I've left if (code == GE) comparison when testing if it should punt for
signed maximum.  That condition is never true, because this is in
switch (code) { ... case LE: case LEU: block and we really meant to
be what the comment says, for LE punt if some element is signed maximum,
as then cst + 1 wraps around.

The following patch fixes the pasto.

2024-03-15  Jakub Jelinek  

PR target/114339
* config/i386/i386-expand.cc (ix86_expand_int_sse_cmp) :
Fix
a pasto, compare code against LE rather than GE.

* gcc.target/i386/pr114339.c: New test.

[Bug target/114339] [13/14 regression] Tor miscompiled with -O2 -mavx -fno-vect-cost-model since r14-6822

2024-03-14 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114339

--- Comment #15 from Jakub Jelinek  ---
Created attachment 57707
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57707=edit
gcc14-pr114339.patch

Untested fix.

[Bug target/114339] [13/14 regression] Tor miscompiled with -O2 -mavx -fno-vect-cost-model since r14-6822

2024-03-14 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114339

Jakub Jelinek  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org

--- Comment #14 from Jakub Jelinek  ---
Indeed, r13-3803-gfa271afb584230, so mine.

[Bug target/114339] [13/14 regression] Tor miscompiled with -O2 -mavx -fno-vect-cost-model since r14-6822

2024-03-14 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114339

--- Comment #13 from Jakub Jelinek  ---
Nice, further cleaned up:
/* PR target/114339 */
/* { dg-do run } */
/* { dg-options "-O2 -Wno-psabi" } */
/* { dg-additional-options "-mavx" { target avx_runtime } } */

typedef long V __attribute__((vector_size (16)));

__attribute__((noipa)) V
foo (V a)
{
  return a <= (V) {0, __LONG_MAX__ };
}

int
main ()
{
  V t = foo ((V) { 0, 0 });
  if (t[0] != -1L || t[1] != -1L)
__builtin_abort ();
}

[Bug target/114339] [13/14 regression] Tor miscompiled with -O2 -mavx -fno-vect-cost-model since r14-6822

2024-03-14 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114339

--- Comment #12 from Andrew Pinski  ---
I suspecting r13-3803-gfa271afb584230 which missed the border case of
INT_MAX/INT_MIN .

[Bug target/114339] [13/14 regression] Tor miscompiled with -O2 -mavx -fno-vect-cost-model since r14-6822

2024-03-14 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114339

Andrew Pinski  changed:

   What|Removed |Added

  Known to work||10.1.0, 12.1.0, 12.3.0,
   ||7.1.0
Summary|[14 regression] Tor |[13/14 regression] Tor
   |miscompiled with -O2 -mavx  |miscompiled with -O2 -mavx
   |-fno-vect-cost-model since  |-fno-vect-cost-model since
   |r14-6822|r14-6822
  Known to fail||13.1.0
   Target Milestone|14.0|13.3

--- Comment #11 from Andrew Pinski  ---
My reduced testcase started to fail in GCC 13.