public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu
@ 2023-06-14 14:52 shaohua.li at inf dot ethz.ch
  2023-06-14 16:13 ` [Bug tree-optimization/110252] [14 Regression] " pinskia at gcc dot gnu.org
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-06-14 14:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110252
           Summary: Wrong code at -O2/3/s on x86_64-linux-gnu
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shaohua.li at inf dot ethz.ch
  Target Milestone: ---

This seems to be a recent regression. 

Compiler explorer: https://godbolt.org/z/TW97cdYxv

$ cat a.c
int printf(const char *, ...);
int d, f;
const char a = 239;
short e, b, h = 2;
long g;
short *c = &e;
int *i = &f;
int(j)(int k, int l) { return k < 0 ? k : k >> l; }
int main() {
  for (;;) {
    g = (char)d + a;
    b = h && j(g, 6);
    *c = b;
    *i = e;
    break;
  }
  printf("%d\n", f);
}
$
$ gcc-tk -O0 a.c && ./a.out
1
$ gcc-tk -O1 a.c && ./a.out
1
$ gcc-tk -O2 a.c && ./a.out
-1
$ gcc-tk -O3 a.c && ./a.out
-1
$ gcc-tk -Os a.c && ./a.out
-1
$
$ gcc-tk -v
Using built-in specs.
COLLECT_GCC=gcc-tk
COLLECT_LTO_WRAPPER=/zdata/shaoli/compilers/ccbuilder-compilers/gcc-bf470895905e9152424076d1630a9d2c60de023b/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++
--prefix=/zdata/shaoli/compilers/ccbuilder-compilers/gcc-bf470895905e9152424076d1630a9d2c60de023b
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230612 (experimental) (GCC) 
$

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
@ 2023-06-14 16:13 ` pinskia at gcc dot gnu.org
  2023-06-14 21:09 ` pinskia at gcc dot gnu.org
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-14 16:13 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-06-14
          Component|c                           |tree-optimization
             Status|UNCONFIRMED                 |ASSIGNED
            Summary|Wrong code at -O2/3/s on    |[14 Regression] Wrong code
                   |x86_64-linux-gnu            |at -O2/3/s on
                   |                            |x86_64-linux-gnu
   Target Milestone|---                         |14.0
           Keywords|                            |wrong-code
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So phiopt does this:
phiopt match-simplify trying:
        _4 >= 0 ? iftmp.0_16 : 1
Matching expression match.pd:1990, gimple-match-5.cc:23
Matching expression match.pd:1990, gimple-match-5.cc:23
Applying pattern match.pd:5283, gimple-match-2.cc:942
Applying pattern match.pd:1378, gimple-match-2.cc:7699
Applying pattern match.pd:1885, gimple-match-3.cc:2770
Applying pattern match.pd:4745, gimple-match-7.cc:15371
Folded into the sequence:
_22 = _4 >= 0;
_21 = (int) _22;
_23 = _4 < 0;
_24 = (int) _23;
_25 = iftmp.0_16 | _24;
statement un-sinked:
iftmp.0_16 = _4 >> 6;

The problem is `_4 >> 6` only has a [0,1] range iff `_4 < 0`.
I have to think of a way of fixing this without too much trouble. Maybe
reverting the patch might be the best for now. But there could be other issues
dealing with phiopt and match-and-simplify later on for a similar reasons ...

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
  2023-06-14 16:13 ` [Bug tree-optimization/110252] [14 Regression] " pinskia at gcc dot gnu.org
@ 2023-06-14 21:09 ` pinskia at gcc dot gnu.org
  2023-06-15  2:13 ` pinskia at gcc dot gnu.org
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-14 21:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 55323
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55323&action=edit
Patch which fixes this issue

This patch fixes the issue by temporary removing the flow sensitive information
on the statement that will be moved while trying out match-and-simplify.

We don't want to remove the flow sensitive information always because if we
don't decide to move it in the end, we just lost it.
I am not the best at naming things so the name of the class will most likely
change before I submit the patch. But I wanted to give a preview here.
Note this is a latent bug in phiopt since the match-and-simplify usage was
added really; just only recently has been noticed due to range information
being used more in match.

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
  2023-06-14 16:13 ` [Bug tree-optimization/110252] [14 Regression] " pinskia at gcc dot gnu.org
  2023-06-14 21:09 ` pinskia at gcc dot gnu.org
@ 2023-06-15  2:13 ` pinskia at gcc dot gnu.org
  2023-06-15  3:11 ` pinskia at gcc dot gnu.org
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-15  2:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
smallest testcase:
```
signed char f() __attribute__((__noipa__));
signed char f() { return 0; }
int main()
{
  int g = f() - 1;
  int e = g < 0 ? 1 : ((g >> (8-2))!=0);
  asm("":"+r"(e));
  if (e != 1)
    __builtin_abort();
}
```

Note I changed 6 to 8-2 as it better explains what is going on and why 6 is the
one needed here.
Second the 239 is just changed over to -1 as it just needs any subtraction.
third is j is inlined and the != is moved over to the conditional expression.
4th and not least, removed all of the pointers and just changed over to using
inline-asm to hide the range of e at the if statement.

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (2 preceding siblings ...)
  2023-06-15  2:13 ` pinskia at gcc dot gnu.org
@ 2023-06-15  3:11 ` pinskia at gcc dot gnu.org
  2023-06-15  6:22 ` rguenth at gcc dot gnu.org
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-15  3:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
here is another testcase which is reduced from sel-sched.cc which we currently
miscompile:
```
[[gnu::noipa]]
int g(int min_need_stall)
{
  return  min_need_stall < 0 ? 1 : ((min_need_stall) < (1) ? (min_need_stall) :
(1));
}
int main(void)
{
  for(int i = -100; i <= 100; i++)
    {
      int t = g(i);
      if (t != (i!=0))
        __builtin_abort();
    }
}
```

Note g really could be reduced down to (min_need_stall != 0) but we don't do
that currently (nor does clang).

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (3 preceding siblings ...)
  2023-06-15  3:11 ` pinskia at gcc dot gnu.org
@ 2023-06-15  6:22 ` rguenth at gcc dot gnu.org
  2023-06-15  6:22 ` rguenth at gcc dot gnu.org
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-06-15  6:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
You can probably follow what maybe_fold_comparisons_from_match_pd does,
possibly exactly the same thing (or even use a similar helper extended to
maybe_fold_cond_expr_from_match_pd?!)

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (4 preceding siblings ...)
  2023-06-15  6:22 ` rguenth at gcc dot gnu.org
@ 2023-06-15  6:22 ` rguenth at gcc dot gnu.org
  2023-06-21 22:51 ` pinskia at gcc dot gnu.org
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-06-15  6:22 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (5 preceding siblings ...)
  2023-06-15  6:22 ` rguenth at gcc dot gnu.org
@ 2023-06-21 22:51 ` pinskia at gcc dot gnu.org
  2023-06-22 15:36 ` pinskia at gcc dot gnu.org
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-21 22:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 110337 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (6 preceding siblings ...)
  2023-06-21 22:51 ` pinskia at gcc dot gnu.org
@ 2023-06-22 15:36 ` pinskia at gcc dot gnu.org
  2023-06-28 20:31 ` pinskia at gcc dot gnu.org
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-22 15:36 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zhendong.su at inf dot ethz.ch

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 110365 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (7 preceding siblings ...)
  2023-06-22 15:36 ` pinskia at gcc dot gnu.org
@ 2023-06-28 20:31 ` pinskia at gcc dot gnu.org
  2023-06-28 20:35 ` pinskia at gcc dot gnu.org
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-28 20:31 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jwzeng at nuaa dot edu.cn

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 110446 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (8 preceding siblings ...)
  2023-06-28 20:31 ` pinskia at gcc dot gnu.org
@ 2023-06-28 20:35 ` pinskia at gcc dot gnu.org
  2023-06-29  9:22 ` zhendong.su at inf dot ethz.ch
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-28 20:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Another testcase (from PR 110446):
```
unsigned int a = 1387579096U;
void sinkandcheck(unsigned b) __attribute__((noipa));
void sinkandcheck(unsigned b)
{
        if (a != b)
        __builtin_abort();
}
int main() {
    a = 1 < (~a) ? 1 : (~a);
    sinkandcheck(1);
    return 0;
}
```

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (9 preceding siblings ...)
  2023-06-28 20:35 ` pinskia at gcc dot gnu.org
@ 2023-06-29  9:22 ` zhendong.su at inf dot ethz.ch
  2023-06-29 15:42 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2023-06-29  9:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
Another very likely related test.

Compiler Explorer: https://godbolt.org/z/1n5nsefWx

[557] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230629 (experimental) [master r14-924-gd709841ae0f] (GCC) 
[558] % 
[558] % gcctk -O2 small.c
[559] % ./a.out
Aborted
[560] % gcctk -O1 small.c; ./a.out
[561] % 
[561] % cat small.c
int a, b = 2, c = 2;
int main() {
  b = ~(1 % (a ^ (b - (1 && c) || c & b)));
  if (b < -1)
    __builtin_abort();
  return 0;
}

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (10 preceding siblings ...)
  2023-06-29  9:22 ` zhendong.su at inf dot ethz.ch
@ 2023-06-29 15:42 ` pinskia at gcc dot gnu.org
  2023-06-30  5:18 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-29 15:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 110475 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (11 preceding siblings ...)
  2023-06-29 15:42 ` pinskia at gcc dot gnu.org
@ 2023-06-30  5:18 ` pinskia at gcc dot gnu.org
  2023-07-03 11:31 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-30  5:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 110494 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (12 preceding siblings ...)
  2023-06-30  5:18 ` pinskia at gcc dot gnu.org
@ 2023-07-03 11:31 ` pinskia at gcc dot gnu.org
  2023-07-06  6:12 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-03 11:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 110532 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (13 preceding siblings ...)
  2023-07-03 11:31 ` pinskia at gcc dot gnu.org
@ 2023-07-06  6:12 ` pinskia at gcc dot gnu.org
  2023-07-08 17:16 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-06  6:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 110569 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (14 preceding siblings ...)
  2023-07-06  6:12 ` pinskia at gcc dot gnu.org
@ 2023-07-08 17:16 ` pinskia at gcc dot gnu.org
  2023-07-15  3:21 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-08 17:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 110599 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (15 preceding siblings ...)
  2023-07-08 17:16 ` pinskia at gcc dot gnu.org
@ 2023-07-15  3:21 ` pinskia at gcc dot gnu.org
  2023-07-19  7:41 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-15  3:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Updated patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624563.html

(depends on:
https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624562.html
)

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (16 preceding siblings ...)
  2023-07-15  3:21 ` pinskia at gcc dot gnu.org
@ 2023-07-19  7:41 ` pinskia at gcc dot gnu.org
  2023-07-19 16:19 ` cvs-commit at gcc dot gnu.org
  2023-07-19 16:19 ` pinskia at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-19  7:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #17 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 110732 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (17 preceding siblings ...)
  2023-07-19  7:41 ` pinskia at gcc dot gnu.org
@ 2023-07-19 16:19 ` cvs-commit at gcc dot gnu.org
  2023-07-19 16:19 ` pinskia at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-19 16:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:8c79b49cd4fa742f7be739dd21fd2aa040cc1ba3

commit r14-2650-g8c79b49cd4fa742f7be739dd21fd2aa040cc1ba3
Author: Andrew Pinski <apinski@marvell.com>
Date:   Fri Jul 14 15:55:34 2023 -0700

    [PATCH] Fix tree-opt/110252: wrong code due to phiopt using flow sensitive
info during match

    Match will query ranger via tree_nonzero_bits/get_nonzero_bits for 2 and
3rd
    operand of the COND_EXPR and phiopt tries to do create the COND_EXPR even
if we moving
    one statement. That one statement could have some flow sensitive
information on it
    based on the condition that is for the COND_EXPR but that might create
wrong code
    if the statement was moved out.

    This is similar to the previous version of the patch except now we use
    flow_sensitive_info_storage instead of manually doing the save/restore
    and also handle all defs on a gimple statement rather than just for lhs
    of the gimple statement. Oh and a few more testcases were added that
    was failing before.

    OK? Bootsrapped and tested on x86_64-linux-gnu with no regressions.

            PR tree-optimization/110252

    gcc/ChangeLog:

            * tree-ssa-phiopt.cc (class auto_flow_sensitive): New class.
            (auto_flow_sensitive::auto_flow_sensitive): New constructor.
            (auto_flow_sensitive::~auto_flow_sensitive): New deconstructor.
            (match_simplify_replacement): Temporarily
            remove the flow sensitive info on the two statements that might
            be moved.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/phi-opt-25b.c: Updated as
            __builtin_parity loses the nonzerobits info.
            * gcc.c-torture/execute/pr110252-1.c: New test.
            * gcc.c-torture/execute/pr110252-2.c: New test.
            * gcc.c-torture/execute/pr110252-3.c: New test.
            * gcc.c-torture/execute/pr110252-4.c: New test.

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

* [Bug tree-optimization/110252] [14 Regression] Wrong code at -O2/3/s on x86_64-linux-gnu
  2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
                   ` (18 preceding siblings ...)
  2023-07-19 16:19 ` cvs-commit at gcc dot gnu.org
@ 2023-07-19 16:19 ` pinskia at gcc dot gnu.org
  19 siblings, 0 replies; 21+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-19 16:19 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #19 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed finally.

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

end of thread, other threads:[~2023-07-19 16:19 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-14 14:52 [Bug c/110252] New: Wrong code at -O2/3/s on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
2023-06-14 16:13 ` [Bug tree-optimization/110252] [14 Regression] " pinskia at gcc dot gnu.org
2023-06-14 21:09 ` pinskia at gcc dot gnu.org
2023-06-15  2:13 ` pinskia at gcc dot gnu.org
2023-06-15  3:11 ` pinskia at gcc dot gnu.org
2023-06-15  6:22 ` rguenth at gcc dot gnu.org
2023-06-15  6:22 ` rguenth at gcc dot gnu.org
2023-06-21 22:51 ` pinskia at gcc dot gnu.org
2023-06-22 15:36 ` pinskia at gcc dot gnu.org
2023-06-28 20:31 ` pinskia at gcc dot gnu.org
2023-06-28 20:35 ` pinskia at gcc dot gnu.org
2023-06-29  9:22 ` zhendong.su at inf dot ethz.ch
2023-06-29 15:42 ` pinskia at gcc dot gnu.org
2023-06-30  5:18 ` pinskia at gcc dot gnu.org
2023-07-03 11:31 ` pinskia at gcc dot gnu.org
2023-07-06  6:12 ` pinskia at gcc dot gnu.org
2023-07-08 17:16 ` pinskia at gcc dot gnu.org
2023-07-15  3:21 ` pinskia at gcc dot gnu.org
2023-07-19  7:41 ` pinskia at gcc dot gnu.org
2023-07-19 16:19 ` cvs-commit at gcc dot gnu.org
2023-07-19 16:19 ` pinskia 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).