public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/105990] New: Dead code elimination failed at -O3
@ 2022-06-15 13:35 crazylht at gmail dot com
2022-06-15 13:39 ` [Bug tree-optimization/105990] " crazylht at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: crazylht at gmail dot com @ 2022-06-15 13:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105990
Bug ID: 105990
Summary: Dead code elimination failed at -O3
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: crazylht at gmail dot com
Target Milestone: ---
static struct { int a; } b, c;
static int d = -1;
void foo();
int main() {
if (b.a)
d = 2 | (b.a <= 0);
for (; b.a; b.a++)
c = b;
if (!d)
foo();
}
foo() can be eliminated since d would never be zero.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/105990] Dead code elimination failed at -O3
2022-06-15 13:35 [Bug tree-optimization/105990] New: Dead code elimination failed at -O3 crazylht at gmail dot com
@ 2022-06-15 13:39 ` crazylht at gmail dot com
2022-06-16 13:32 ` Painololo at protonmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: crazylht at gmail dot com @ 2022-06-15 13:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105990
--- Comment #1 from Hongtao.liu <crazylht at gmail dot com> ---
Another case
static short a;
static int b;
void foo(void);
void bar9_(void);
int main() {
char c;
b = a = 23;
for (; b <= 1;)
a = 1;
bar9_();
c = a >= 18 || 2 > 2 >> a ? 1 : 1 << a;
if (c == 0)
foo();
}
foo() also can be eliminated.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/105990] Dead code elimination failed at -O3
2022-06-15 13:35 [Bug tree-optimization/105990] New: Dead code elimination failed at -O3 crazylht at gmail dot com
2022-06-15 13:39 ` [Bug tree-optimization/105990] " crazylht at gmail dot com
@ 2022-06-16 13:32 ` Painololo at protonmail dot com
2022-06-21 1:38 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Painololo at protonmail dot com @ 2022-06-16 13:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105990
John Klein <Painololo at protonmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Painololo at protonmail dot com
--- Comment #2 from John Klein <Painololo at protonmail dot com> ---
Thanks for the decision.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/105990] Dead code elimination failed at -O3
2022-06-15 13:35 [Bug tree-optimization/105990] New: Dead code elimination failed at -O3 crazylht at gmail dot com
2022-06-15 13:39 ` [Bug tree-optimization/105990] " crazylht at gmail dot com
2022-06-16 13:32 ` Painololo at protonmail dot com
@ 2022-06-21 1:38 ` pinskia at gcc dot gnu.org
2023-08-07 20:56 ` [Bug ipa/105990] " pinskia at gcc dot gnu.org
2023-10-25 22:19 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-21 1:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105990
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Last reconfirmed| |2022-06-21
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think the first and second cases are different issues.
In the first case (even if we remove the struct), we can't figure out that b
does not change from 0.
Because we only have a trivial pass which detects read-onlyness. That is it
only checks if b was read-only and not if b could have been written to if b was
read-only.
The second case I didn't analyzed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug ipa/105990] Dead code elimination failed at -O3
2022-06-15 13:35 [Bug tree-optimization/105990] New: Dead code elimination failed at -O3 crazylht at gmail dot com
` (2 preceding siblings ...)
2022-06-21 1:38 ` pinskia at gcc dot gnu.org
@ 2023-08-07 20:56 ` pinskia at gcc dot gnu.org
2023-10-25 22:19 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-07 20:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105990
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Hongtao.liu from comment #1)
> foo() also can be eliminated.
This one is similar to PR 105832 really.
```
_2 = (int) a.2_1;
_3 = 2 >> _2;
if (_3 == 2)
goto <bb 4>; [34.00%]
else
goto <bb 6>; [66.00%]
<bb 4> [local count: 182536112]:
_4 = 1 << _2;
iftmp.1_10 = (char) _4;
if (iftmp.1_10 == 0)
goto <bb 5>; [33.00%]
else
goto <bb 6>; [67.00%]
```
`(2 >> _2) == 2` could be optimized to just `_2 == 0`.
And then `_4` becomes `1` and then the conditional is optimized away and such.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug ipa/105990] Dead code elimination failed at -O3
2022-06-15 13:35 [Bug tree-optimization/105990] New: Dead code elimination failed at -O3 crazylht at gmail dot com
` (3 preceding siblings ...)
2023-08-07 20:56 ` [Bug ipa/105990] " pinskia at gcc dot gnu.org
@ 2023-10-25 22:19 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-25 22:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105990
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> `(2 >> _2) == 2` could be optimized to just `_2 == 0`.
> And then `_4` becomes `1` and then the conditional is optimized away and
> such.
Filed that as PR 112090 . Leaving this open for the IPA issue with recording
the store values possible.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-10-25 22:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 13:35 [Bug tree-optimization/105990] New: Dead code elimination failed at -O3 crazylht at gmail dot com
2022-06-15 13:39 ` [Bug tree-optimization/105990] " crazylht at gmail dot com
2022-06-16 13:32 ` Painololo at protonmail dot com
2022-06-21 1:38 ` pinskia at gcc dot gnu.org
2023-08-07 20:56 ` [Bug ipa/105990] " pinskia at gcc dot gnu.org
2023-10-25 22: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).