public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111724] New: [Regression] Missed optimizations probably because of too early arithmetic optimization
@ 2023-10-08 7:55 652023330028 at smail dot nju.edu.cn
2023-10-09 9:53 ` [Bug tree-optimization/111724] " rguenth at gcc dot gnu.org
2023-10-09 10:34 ` 652023330028 at smail dot nju.edu.cn
0 siblings, 2 replies; 3+ messages in thread
From: 652023330028 at smail dot nju.edu.cn @ 2023-10-08 7:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111724
Bug ID: 111724
Summary: [Regression] Missed optimizations probably because of
too early arithmetic optimization
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 (probably because of too early arithmetic
optimization) that GCC may have missed. We would greatly appreicate if you can
take a look and let us know what you think.
Given the following code:
https://godbolt.org/z/8EW8fx78K
int n;
void func(int w, int a, int b){
for(int i=0;i<w;i++){
n += (a+a)+(b+b);
b += b;
}
}
`a+a` is a loop invariant. But gcc-trunk -O3:
func(int, int, int):
push {r4, lr}
subs lr, r0, #0
ble .L1
movw r4, #:lower16:.LANCHOR0
movt r4, #:upper16:.LANCHOR0
mov ip, #0
ldr r0, [r4]
.L3:
adds r3, r1, r2
add ip, ip, #1
lsls r2, r2, #1
cmp lr, ip
add r0, r0, r3, lsl #1
bne .L3
str r0, [r4]
From original(tree):
(void) (n = (a + b) * 2 + n) >>>>>;
This leads to:
_1 = a_11(D) + b_18;
_2 = _1 * 2;
_4 = _2 + n_lsm.4_7;
So, it looks like the missed LICM is due to too early arithmetic optimization.
On gcc-6.4, it works as expected.
We found that this also affects other optimizations, such as common
subexpression elimination. We can provide examples if required.
Thank you very much for your time and effort! We look forward to hearing from
you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-09 10:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-08 7:55 [Bug tree-optimization/111724] New: [Regression] Missed optimizations probably because of too early arithmetic optimization 652023330028 at smail dot nju.edu.cn
2023-10-09 9:53 ` [Bug tree-optimization/111724] " rguenth at gcc dot gnu.org
2023-10-09 10:34 ` 652023330028 at smail dot nju.edu.cn
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).