public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp"
@ 2023-10-18 11:44 19373742 at buaa dot edu.cn
2023-10-18 11:45 ` [Bug c/111863] " 19373742 at buaa dot edu.cn
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: 19373742 at buaa dot edu.cn @ 2023-10-18 11:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111863
Bug ID: 111863
Summary: Wrong code with "-O3 -fno-tree-ccp
-fno-tree-dominator-opts -fno-tree-vrp"
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: 19373742 at buaa dot edu.cn
Target Milestone: ---
Created attachment 56138
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56138&action=edit
The preprocessed file
*******************************************************************************
OS and Platform:
Ubuntu 20.04.4 LTS
*******************************************************************************
gcc version:
$ gcc -v
Using built-in specs.
COLLECT_GCC=/home/cuisk/ctc/gcc-releases/gcc-14/bin/gcc
COLLECT_LTO_WRAPPER=/home/cuisk/ctc/gcc-releases/gcc-14/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/home/cuisk/ctc/gcc-releases/gcc-14
--disable-multilib --enable-language=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231015 (experimental) (GCC)
*******************************************************************************
Command Lines:
$ gcc -I ~/csmith/include/csmith-2.3.0/ -fsanitize=undefined a.c -o crt
$ ./crt
checksum = 2E494827
$ gcc -I ~/csmith/include/csmith-2.3.0/ -O3 -fno-tree-ccp
-fno-tree-dominator-opts -fno-tree-vrp a.c -o mis
$ ./mis
checksum = 326ED032
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/111863] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp"
2023-10-18 11:44 [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" 19373742 at buaa dot edu.cn
@ 2023-10-18 11:45 ` 19373742 at buaa dot edu.cn
2023-10-18 12:27 ` 19373742 at buaa dot edu.cn
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: 19373742 at buaa dot edu.cn @ 2023-10-18 11:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111863
--- Comment #1 from CTC <19373742 at buaa dot edu.cn> ---
Created attachment 56139
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56139&action=edit
The compiler output
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/111863] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp"
2023-10-18 11:44 [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" 19373742 at buaa dot edu.cn
2023-10-18 11:45 ` [Bug c/111863] " 19373742 at buaa dot edu.cn
@ 2023-10-18 12:27 ` 19373742 at buaa dot edu.cn
2023-10-18 12:50 ` [Bug c/111863] [14 Regression] " rguenth at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: 19373742 at buaa dot edu.cn @ 2023-10-18 12:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111863
--- Comment #2 from CTC <19373742 at buaa dot edu.cn> ---
A reduced testcase:
$ cat a.c
#include <stdio.h>
int a;
volatile int *b = &a;
volatile int **c = &b;
static int d = 1;
static int e() {
unsigned long f = 2;
*b = 0 || 5;
*b = ((**c & f) != d)%11;
return 0;
}
int main() {
e();
printf("%d\n", a);
}
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/111863] [14 Regression] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp"
2023-10-18 11:44 [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" 19373742 at buaa dot edu.cn
2023-10-18 11:45 ` [Bug c/111863] " 19373742 at buaa dot edu.cn
2023-10-18 12:27 ` 19373742 at buaa dot edu.cn
@ 2023-10-18 12:50 ` rguenth at gcc dot gnu.org
2023-10-18 14:04 ` [Bug c/111863] [14 Regression] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" since r14-1600 jakub at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-18 12:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111863
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |needs-bisection, wrong-code
Summary|Wrong code with "-O3 |[14 Regression] Wrong code
|-fno-tree-ccp |with "-O3 -fno-tree-ccp
|-fno-tree-dominator-opts |-fno-tree-dominator-opts
|-fno-tree-vrp" |-fno-tree-vrp"
Ever confirmed|0 |1
Last reconfirmed| |2023-10-18
Status|UNCONFIRMED |NEW
Known to work| |13.2.1
Target Milestone|--- |14.0
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/111863] [14 Regression] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" since r14-1600
2023-10-18 11:44 [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" 19373742 at buaa dot edu.cn
` (2 preceding siblings ...)
2023-10-18 12:50 ` [Bug c/111863] [14 Regression] " rguenth at gcc dot gnu.org
@ 2023-10-18 14:04 ` jakub at gcc dot gnu.org
2023-10-18 15:49 ` [Bug middle-end/111863] " pinskia at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-10-18 14:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111863
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[14 Regression] Wrong code |[14 Regression] Wrong code
|with "-O3 -fno-tree-ccp |with "-O3 -fno-tree-ccp
|-fno-tree-dominator-opts |-fno-tree-dominator-opts
|-fno-tree-vrp" |-fno-tree-vrp" since
| |r14-1600
CC| |jakub at gcc dot gnu.org,
| |pinskia at gcc dot gnu.org
Keywords|needs-bisection |
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r14-1600-ge60593f3881c72a96a3fa4844d73e8a2cd14f670
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/111863] [14 Regression] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" since r14-1600
2023-10-18 11:44 [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" 19373742 at buaa dot edu.cn
` (3 preceding siblings ...)
2023-10-18 14:04 ` [Bug c/111863] [14 Regression] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" since r14-1600 jakub at gcc dot gnu.org
@ 2023-10-18 15:49 ` pinskia at gcc dot gnu.org
2023-10-18 15:51 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-18 15:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111863
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Let me see where I made the mistake.
```
;; _11 = (int) _10;
(insn 10 9 11 (set (reg:CCZ 17 flags)
(compare:CCZ (reg:SI 102 [ _7 ])
(const_int 1 [0x1]))) "/app/example.cpp":10:24 -1
(nil))
(insn 11 10 12 (set (reg:QI 109)
(ne:QI (reg:CCZ 17 flags)
(const_int 0 [0]))) "/app/example.cpp":10:24 -1
(nil))
```
is definitely wrong.
It was in GCC 13:
```
(insn 10 9 11 (parallel [
(set (reg:SI 92)
(and:SI (reg:SI 86 [ _7 ])
(const_int 2 [0x2])))
(clobber (reg:CC 17 flags))
]) "/app/example.cpp":10:24 -1
(nil))
(insn 11 10 12 (set (reg:CCZ 17 flags)
(compare:CCZ (reg:SI 92)
(const_int 1 [0x1]))) "/app/example.cpp":10:24 -1
(nil))
(insn 12 11 13 (set (reg:QI 94)
(ne:QI (reg:CCZ 17 flags)
(const_int 0 [0]))) "/app/example.cpp":10:24 -1
(nil))
```
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/111863] [14 Regression] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" since r14-1600
2023-10-18 11:44 [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" 19373742 at buaa dot edu.cn
` (4 preceding siblings ...)
2023-10-18 15:49 ` [Bug middle-end/111863] " pinskia at gcc dot gnu.org
@ 2023-10-18 15:51 ` pinskia at gcc dot gnu.org
2023-10-18 15:57 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-18 15:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111863
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Oh I see the issue:
```
_8 = _7 & 2;
_10 = _8 != 1;
```
There needs to be a check that 1 here is the same as 2 or 0 ...
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/111863] [14 Regression] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" since r14-1600
2023-10-18 11:44 [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" 19373742 at buaa dot edu.cn
` (5 preceding siblings ...)
2023-10-18 15:51 ` pinskia at gcc dot gnu.org
@ 2023-10-18 15:57 ` pinskia at gcc dot gnu.org
2023-10-18 16:29 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-18 15:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111863
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #6)
> Oh I see the issue:
> ```
> _8 = _7 & 2;
> _10 = _8 != 1;
>
> ```
>
> There needs to be a check that 1 here is the same as 2 or 0 ...
Wait I have that check:
if (wi::popcount (nz) == 1
&& (integer_zerop (arg1)
|| wi::to_wide (arg1) == nz))
Why is that not working ...
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/111863] [14 Regression] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" since r14-1600
2023-10-18 11:44 [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" 19373742 at buaa dot edu.cn
` (6 preceding siblings ...)
2023-10-18 15:57 ` pinskia at gcc dot gnu.org
@ 2023-10-18 16:29 ` pinskia at gcc dot gnu.org
2023-10-18 16:32 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-18 16:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111863
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Oh I see the issue now, I am changing arg0 even if we don't do the thing ...
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/111863] [14 Regression] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" since r14-1600
2023-10-18 11:44 [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" 19373742 at buaa dot edu.cn
` (7 preceding siblings ...)
2023-10-18 16:29 ` pinskia at gcc dot gnu.org
@ 2023-10-18 16:32 ` pinskia at gcc dot gnu.org
2023-10-18 17:04 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-18 16:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111863
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 56141
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56141&action=edit
untested fix
This fixes the reuse of arg0 so we don't change it for the later on code.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/111863] [14 Regression] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" since r14-1600
2023-10-18 11:44 [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" 19373742 at buaa dot edu.cn
` (8 preceding siblings ...)
2023-10-18 16:32 ` pinskia at gcc dot gnu.org
@ 2023-10-18 17:04 ` pinskia at gcc dot gnu.org
2023-10-18 22:35 ` cvs-commit at gcc dot gnu.org
2023-10-18 22:36 ` pinskia at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-18 17:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111863
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 56142
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56142&action=edit
Reduced self-contained testcase
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/111863] [14 Regression] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" since r14-1600
2023-10-18 11:44 [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" 19373742 at buaa dot edu.cn
` (9 preceding siblings ...)
2023-10-18 17:04 ` pinskia at gcc dot gnu.org
@ 2023-10-18 22:35 ` cvs-commit at gcc dot gnu.org
2023-10-18 22:36 ` pinskia at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-18 22:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111863
--- Comment #11 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:b20dbddcc41120144e700c4e3ef1ec396b1c56ab
commit r14-4729-gb20dbddcc41120144e700c4e3ef1ec396b1c56ab
Author: Andrew Pinski <pinskia@gmail.com>
Date: Wed Oct 18 10:26:07 2023 -0700
Fix expansion of `(a & 2) != 1`
I had a thinko in r14-1600-ge60593f3881c72a96a3fa4844d73e8a2cd14f670
where we would remove the `& CST` part if we ended up not calling
expand_single_bit_test.
This fixes the problem by introducing a new variable that will be used
for calling expand_single_bit_test.
As afar as I know this can only show up when disabling optimization
passes as this above form would have been optimized away.
Committed as obvious after a bootstrap/test on x86_64-linux-gnu.
PR middle-end/111863
gcc/ChangeLog:
* expr.cc (do_store_flag): Don't over write arg0
when stripping off `& POW2`.
gcc/testsuite/ChangeLog:
* gcc.c-torture/execute/pr111863-1.c: New test.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/111863] [14 Regression] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" since r14-1600
2023-10-18 11:44 [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" 19373742 at buaa dot edu.cn
` (10 preceding siblings ...)
2023-10-18 22:35 ` cvs-commit at gcc dot gnu.org
@ 2023-10-18 22:36 ` pinskia at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-18 22:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111863
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-10-18 22:36 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-18 11:44 [Bug c/111863] New: Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" 19373742 at buaa dot edu.cn
2023-10-18 11:45 ` [Bug c/111863] " 19373742 at buaa dot edu.cn
2023-10-18 12:27 ` 19373742 at buaa dot edu.cn
2023-10-18 12:50 ` [Bug c/111863] [14 Regression] " rguenth at gcc dot gnu.org
2023-10-18 14:04 ` [Bug c/111863] [14 Regression] Wrong code with "-O3 -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-vrp" since r14-1600 jakub at gcc dot gnu.org
2023-10-18 15:49 ` [Bug middle-end/111863] " pinskia at gcc dot gnu.org
2023-10-18 15:51 ` pinskia at gcc dot gnu.org
2023-10-18 15:57 ` pinskia at gcc dot gnu.org
2023-10-18 16:29 ` pinskia at gcc dot gnu.org
2023-10-18 16:32 ` pinskia at gcc dot gnu.org
2023-10-18 17:04 ` pinskia at gcc dot gnu.org
2023-10-18 22:35 ` cvs-commit at gcc dot gnu.org
2023-10-18 22:36 ` 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).