public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/68027] New: conditional statement and unnecessary register assignment
@ 2015-10-20 5:24 SztfG at yandex dot ru
2015-10-20 5:30 ` [Bug middle-end/68027] " SztfG at yandex dot ru
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: SztfG at yandex dot ru @ 2015-10-20 5:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68027
Bug ID: 68027
Summary: conditional statement and unnecessary register
assignment
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: SztfG at yandex dot ru
Target Milestone: ---
C source code:
int a1(int);
int a2(int);
int a3(int);
int test1(int a)
{
if (a > 100) return a1(a);
else if (a < 100) return a2(a);
return a3(a);
}
-----------------------------------
Assembly output:
test1:
.LFB0:
.cfi_startproc
cmpl $100, %edi
jg .L5
jne .L6
movl $100, %edi # no need to do this, eax is equal $100 at this
point
jmp a3
.p2align 4,,10
.p2align 3
.L6:
jmp a2
.p2align 4,,10
.p2align 3
.L5:
jmp a1
.cfi_endproc
-----------------------------------
Tested on http://gcc.godbolt.org/ : gcc versions 4.4.7 - 5.2.0 have this
problem.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/68027] conditional statement and unnecessary register assignment
2015-10-20 5:24 [Bug middle-end/68027] New: conditional statement and unnecessary register assignment SztfG at yandex dot ru
@ 2015-10-20 5:30 ` SztfG at yandex dot ru
2015-10-20 8:00 ` [Bug tree-optimization/68027] " rguenth at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: SztfG at yandex dot ru @ 2015-10-20 5:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68027
--- Comment #1 from SztfG at yandex dot ru ---
># no need to do this, eax is equal $100 at this point
I mean edi. after this part:
cmpl $100, %edi
jg .L5
jne .L6
if it passed this jg jne instruction without conditional jump, edi shoud be 100
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/68027] conditional statement and unnecessary register assignment
2015-10-20 5:24 [Bug middle-end/68027] New: conditional statement and unnecessary register assignment SztfG at yandex dot ru
2015-10-20 5:30 ` [Bug middle-end/68027] " SztfG at yandex dot ru
@ 2015-10-20 8:00 ` rguenth at gcc dot gnu.org
2015-10-20 8:28 ` SztfG at yandex dot ru
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-20 8:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68027
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-10-20
Component|middle-end |tree-optimization
Version|unknown |5.2.0
Ever confirmed|0 |1
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. It's VRP doing this constant propagation and uncprop not undoing
it.
When we do not need to spill 'a' then re-using 'a' would be better but the
optimization is supposed to catch the more frequent case where we'd have to
spill 'a'.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/68027] conditional statement and unnecessary register assignment
2015-10-20 5:24 [Bug middle-end/68027] New: conditional statement and unnecessary register assignment SztfG at yandex dot ru
2015-10-20 5:30 ` [Bug middle-end/68027] " SztfG at yandex dot ru
2015-10-20 8:00 ` [Bug tree-optimization/68027] " rguenth at gcc dot gnu.org
@ 2015-10-20 8:28 ` SztfG at yandex dot ru
2015-10-20 17:37 ` SztfG at yandex dot ru
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: SztfG at yandex dot ru @ 2015-10-20 8:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68027
--- Comment #3 from SztfG at yandex dot ru ---
btw why nobody confirm my old reported bug about stack-allocated array missed
optimization https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66152 ?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/68027] conditional statement and unnecessary register assignment
2015-10-20 5:24 [Bug middle-end/68027] New: conditional statement and unnecessary register assignment SztfG at yandex dot ru
` (2 preceding siblings ...)
2015-10-20 8:28 ` SztfG at yandex dot ru
@ 2015-10-20 17:37 ` SztfG at yandex dot ru
2021-08-10 18:20 ` [Bug tree-optimization/68027] uncprop should work on more than PHI nodes pinskia at gcc dot gnu.org
2021-08-10 18:22 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: SztfG at yandex dot ru @ 2015-10-20 17:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68027
--- Comment #4 from SztfG at yandex dot ru ---
I think this can be optimized in this way:
cmpl $100, %edi
jg a1
jne a2
jmp a3
without any label jumps
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/68027] uncprop should work on more than PHI nodes
2015-10-20 5:24 [Bug middle-end/68027] New: conditional statement and unnecessary register assignment SztfG at yandex dot ru
` (3 preceding siblings ...)
2015-10-20 17:37 ` SztfG at yandex dot ru
@ 2021-08-10 18:20 ` pinskia at gcc dot gnu.org
2021-08-10 18:22 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-10 18:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68027
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|conditional statement and |uncprop should work on more
|unnecessary register |than PHI nodes
|assignment |
Severity|normal |enhancement
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
tree-ssa-uncprop.c does some of this but only handles PHI nodes currrently.
Note ICC and MSVC generate the code without the move while GCC and clang both
do the move.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/68027] uncprop should work on more than PHI nodes
2015-10-20 5:24 [Bug middle-end/68027] New: conditional statement and unnecessary register assignment SztfG at yandex dot ru
` (4 preceding siblings ...)
2021-08-10 18:20 ` [Bug tree-optimization/68027] uncprop should work on more than PHI nodes pinskia at gcc dot gnu.org
@ 2021-08-10 18:22 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-10 18:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68027
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to SztfG from comment #4)
> I think this can be optimized in this way:
>
> cmpl $100, %edi
> jg a1
> jne a2
> jmp a3
Note that is a different bug and should be filed seperately. Something about
conditional tail calls. I thought there was a bug filed for that case but I
can't seem to find it.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-08-10 18:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-20 5:24 [Bug middle-end/68027] New: conditional statement and unnecessary register assignment SztfG at yandex dot ru
2015-10-20 5:30 ` [Bug middle-end/68027] " SztfG at yandex dot ru
2015-10-20 8:00 ` [Bug tree-optimization/68027] " rguenth at gcc dot gnu.org
2015-10-20 8:28 ` SztfG at yandex dot ru
2015-10-20 17:37 ` SztfG at yandex dot ru
2021-08-10 18:20 ` [Bug tree-optimization/68027] uncprop should work on more than PHI nodes pinskia at gcc dot gnu.org
2021-08-10 18:22 ` 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).