public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112545] New: [14 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25
@ 2023-11-15 12:50 theodort at inf dot ethz.ch
2023-11-15 13:43 ` [Bug tree-optimization/112545] " rguenth at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: theodort at inf dot ethz.ch @ 2023-11-15 12:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112545
Bug ID: 112545
Summary: [14 Regression] Size regression when using -Os
starting with r14-569-g21e2ef2dc25
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: theodort at inf dot ethz.ch
Target Milestone: ---
https://godbolt.org/z/hcq8sKhvP
Given the following code:
static struct {
int a;
int b;
} c;
static int d, e, g;
static short f, i;
static void h(unsigned short j) {
c.a = i;
if (!(((j) >= 1) && ((j) <= 65535))) {
__builtin_unreachable();
}
}
int main1() {
d = 6;
for (; d != -7; d--) {
h(d ^ d < (0 <= 6));
if (d >= 12)
if (e) {
for (; f; ++f) g = c.b;
if (g) e = 0;
}
}
}
gcc-trunk -Os generates significantly more complex code:
main1:
movl e(%rip), %ecx
movl $6, %eax
xorl %edi, %edi
xorl %r8d, %r8d
movl c+4(%rip), %r10d
movl g(%rip), %esi
xorl %r9d, %r9d
movl $6, d(%rip)
movw f(%rip), %dx
.L2:
cmpl $-7, %eax
je .L31
xorl %r11d, %r11d
testl %eax, %eax
setle %r11b
cmpw %ax, %r11w
jne .L3
testb %r8b, %r8b
je .L4
movl %eax, d(%rip)
.L4:
testb %dil, %dil
je .L5
movl %ecx, e(%rip)
.L5:
xorl %ecx, %ecx
movw %dx, f(%rip)
movl %ecx, c(%rip)
movl %esi, g(%rip)
.L3:
cmpl $11, %eax
jle .L6
testl %ecx, %ecx
je .L6
.L7:
testw %dx, %dx
je .L32
incl %edx
movl %r10d, %esi
movb $1, %r9b
jmp .L7
.L32:
testl %esi, %esi
je .L6
movb $1, %dil
xorl %ecx, %ecx
.L6:
decl %eax
movb $1, %r8b
jmp .L2
.L31:
testb %r8b, %r8b
je .L10
movl $-7, d(%rip)
testb %dil, %dil
je .L11
movl %ecx, e(%rip)
.L11:
xorl %eax, %eax
movl %eax, c(%rip)
.L12:
testb %r9b, %r9b
je .L13
movw %dx, f(%rip)
movl %esi, g(%rip)
jmp .L13
.L10:
testb %dil, %dil
je .L12
movl %ecx, e(%rip)
jmp .L12
.L13:
xorl %eax, %eax
ret
than gcc-13.2.0 -Os:
main1:
movl $-7, d(%rip)
xorl %eax, %eax
movl %eax, c(%rip)
ret
Bisects to r14-569-g21e2ef2dc25
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112545] [14 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25
2023-11-15 12:50 [Bug tree-optimization/112545] New: [14 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25 theodort at inf dot ethz.ch
@ 2023-11-15 13:43 ` rguenth at gcc dot gnu.org
2023-11-15 16:26 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-11-15 13:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112545
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112545] [14 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25
2023-11-15 12:50 [Bug tree-optimization/112545] New: [14 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25 theodort at inf dot ethz.ch
2023-11-15 13:43 ` [Bug tree-optimization/112545] " rguenth at gcc dot gnu.org
@ 2023-11-15 16:26 ` pinskia at gcc dot gnu.org
2024-03-07 21:01 ` law at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-15 16:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112545
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2023-11-15
Status|UNCONFIRMED |NEW
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The first difference is that the trunk deletes:
_6 = (int) _5;
From ccp2.
And then in forwprop2 changes:
```
_4 = _2 ^ _3;
_5 = (short unsigned int) _4;
_6 = (int) _5;
c.a = 0;
if (_5 == 0)
```
into:
```
c.a = 0;
if (_2 == _3)
```
Which is correct.
The problem DOM/ranger missed the above. It understood the ^ code for some
reason but not the == code.
And then does not remove the better ranges.
Someone who knows the ranger more than I do should look into it.
Anyways here is the code which shows my change just exposed the missed
optimization (13.2 also misses the issue):
```
static struct {
int a;
int b;
} c;
static int d, e, g;
static short f, i;
int main1() {
d = 6;
for (; d != -7; d--) {
c.a = i;
_Bool t = d <= 0;
signed short tt = d;
signed short ttt = t;
if (tt == ttt)
__builtin_unreachable();
//h(d ^ d < (0 <= 6));
if (d >= 12)
if (e) {
for (; f; ++f) g = c.b;
if (g) e = 0;
}
}
}
```
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112545] [14 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25
2023-11-15 12:50 [Bug tree-optimization/112545] New: [14 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25 theodort at inf dot ethz.ch
2023-11-15 13:43 ` [Bug tree-optimization/112545] " rguenth at gcc dot gnu.org
2023-11-15 16:26 ` pinskia at gcc dot gnu.org
@ 2024-03-07 21:01 ` law at gcc dot gnu.org
2024-03-09 5:04 ` law at gcc dot gnu.org
2024-05-07 7:42 ` [Bug tree-optimization/112545] [14/15 " rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-07 21:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112545
Jeffrey A. Law <law at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |law at gcc dot gnu.org
Priority|P3 |P2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112545] [14 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25
2023-11-15 12:50 [Bug tree-optimization/112545] New: [14 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25 theodort at inf dot ethz.ch
` (2 preceding siblings ...)
2024-03-07 21:01 ` law at gcc dot gnu.org
@ 2024-03-09 5:04 ` law at gcc dot gnu.org
2024-05-07 7:42 ` [Bug tree-optimization/112545] [14/15 " rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-09 5:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112545
--- Comment #2 from Jeffrey A. Law <law at gcc dot gnu.org> ---
This looks like a missed case for singletons.
_1 = d.9_28 <= 0;
_2 = (signed short) _1;
_3 = (signed short) d.9_28;
c.a = 0;
if (_2 == _3)
goto <bb 4>; [0.00%]
else
goto <bb 5>; [100.00%]
Back substituting the condition is:
(d.9_28 <= 0) == d.9_28
d.9_28 <= 0 has a range [0,1]
The only value that can make that expression true is if d.9_28 has the value 0.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112545] [14/15 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25
2023-11-15 12:50 [Bug tree-optimization/112545] New: [14 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25 theodort at inf dot ethz.ch
` (3 preceding siblings ...)
2024-03-09 5:04 ` law at gcc dot gnu.org
@ 2024-05-07 7:42 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-07 7:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112545
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|14.0 |14.2
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 14.1 is being released, retargeting bugs to GCC 14.2.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-05-07 7:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15 12:50 [Bug tree-optimization/112545] New: [14 Regression] Size regression when using -Os starting with r14-569-g21e2ef2dc25 theodort at inf dot ethz.ch
2023-11-15 13:43 ` [Bug tree-optimization/112545] " rguenth at gcc dot gnu.org
2023-11-15 16:26 ` pinskia at gcc dot gnu.org
2024-03-07 21:01 ` law at gcc dot gnu.org
2024-03-09 5:04 ` law at gcc dot gnu.org
2024-05-07 7:42 ` [Bug tree-optimization/112545] [14/15 " rguenth 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).