public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111561] New: Missed optimization of available expression in if condition
@ 2023-09-24 3:38 652023330028 at smail dot nju.edu.cn
2023-09-24 3:42 ` [Bug tree-optimization/111561] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: 652023330028 at smail dot nju.edu.cn @ 2023-09-24 3:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111561
Bug ID: 111561
Summary: Missed optimization of available expression in if
condition
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: 652023330028 at smail dot nju.edu.cn
Target Milestone: ---
Hello, we found some optimizations (regarding Available Expression in If
condition) that GCC may have missed. We would greatly appreicate if you can
take a look and let us know what you think.
Here are two examples:
Example 1:
https://godbolt.org/z/vjWM5c93j
Given the following code:
```c++
extern int var_26;
extern int var_29;
void test(int var_1, int var_2, int var_3) {
var_29 = (var_1 + var_2) ? var_1 : var_2; //line 4
var_26 = var_1 + (var_2 + var_3); //can be replaced with the value at line
4
}
```
We note that `var_1+var_2` at line 5 in the test code can be replaced with the
value at line 4, but gcc-trunk -O3 does not:
```asm
test(int, int, int):
mov eax, edi
add eax, esi
mov eax, edi
cmove eax, esi
add esi, edx
add esi, edi
mov DWORD PTR var_29[rip], eax
mov DWORD PTR var_26[rip], esi
ret
```
Example 2:
https://godbolt.org/z/31d8v453v
Given the following code:
```c++
extern int var_24;
extern int var_25;
void test(int var_0, int var_1, int var_12) {
var_24 = (var_1 + var_12 + var_0) ? 1 : 2;
var_25 = var_12 + var_0;
}
```
We note that `var_12+var_0` at line 5 in the test code can be replaced with the
value at line 4, but gcc-trunk -O3 does not:
```asm
test(int, int, int):
add esi, edx
xor eax, eax
add esi, edi
sete al
add edx, edi
add eax, 1
mov DWORD PTR var_25[rip], edx
mov DWORD PTR var_24[rip], eax
ret
```
Thank you very much for your time and effort! We look forward to hearing from
you.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/111561] Missed optimization of available expression in if condition
2023-09-24 3:38 [Bug tree-optimization/111561] New: Missed optimization of available expression in if condition 652023330028 at smail dot nju.edu.cn
@ 2023-09-24 3:42 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-24 3:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111561
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Same issue as PR 111560 really.
*** This bug has been marked as a duplicate of bug 111560 ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-24 3:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-24 3:38 [Bug tree-optimization/111561] New: Missed optimization of available expression in if condition 652023330028 at smail dot nju.edu.cn
2023-09-24 3:42 ` [Bug tree-optimization/111561] " 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).