public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/100942] New: ccmp is not used if the value is used later
@ 2021-06-07 7:51 pinskia at gcc dot gnu.org
2023-12-12 1:18 ` [Bug middle-end/100942] " pinskia at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-07 7:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100942
Bug ID: 100942
Summary: ccmp is not used if the value is used later
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Target: aarch64-linux-gnu
Take:
void foo(void);
int f1(int a, int b)
{
int c = a == 0 || b == 0;
if (c) foo();
return c;
}
------ CUT -----
Right now we produce at -O2:
stp x29, x30, [sp, -32]!
cmp w0, 0
mov x29, sp
str x19, [sp, 16]
cset w19, eq
cmp w1, 0
cset w0, eq
orr w19, w19, w0
cbnz w19, .L8
mov w0, w19
ldr x19, [sp, 16]
ldp x29, x30, [sp], 32
ret
Notice how we have cmp/cset/cmp/cset/orr.
This is a (much) reduced testcase from Xalan in SPEC 2k6.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/100942] ccmp is not used if the value is used later
2021-06-07 7:51 [Bug middle-end/100942] New: ccmp is not used if the value is used later pinskia at gcc dot gnu.org
@ 2023-12-12 1:18 ` pinskia at gcc dot gnu.org
2023-12-12 3:40 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-12 1:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100942
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Last reconfirmed| |2023-12-12
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I have a fix.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/100942] ccmp is not used if the value is used later
2021-06-07 7:51 [Bug middle-end/100942] New: ccmp is not used if the value is used later pinskia at gcc dot gnu.org
2023-12-12 1:18 ` [Bug middle-end/100942] " pinskia at gcc dot gnu.org
@ 2023-12-12 3:40 ` pinskia at gcc dot gnu.org
2023-12-12 8:23 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-12 3:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100942
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 56860
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56860&action=edit
Patch which I am testing
Patch which I am testing. Will be doing some benchmarking too.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/100942] ccmp is not used if the value is used later
2021-06-07 7:51 [Bug middle-end/100942] New: ccmp is not used if the value is used later pinskia at gcc dot gnu.org
2023-12-12 1:18 ` [Bug middle-end/100942] " pinskia at gcc dot gnu.org
2023-12-12 3:40 ` pinskia at gcc dot gnu.org
@ 2023-12-12 8:23 ` pinskia at gcc dot gnu.org
2024-01-23 17:43 ` cvs-commit at gcc dot gnu.org
2024-01-24 18:29 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-12 8:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100942
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
URL| |https://gcc.gnu.org/piperma
| |il/gcc-patches/2023-Decembe
| |r/640289.html
Keywords| |patch
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-December/640289.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/100942] ccmp is not used if the value is used later
2021-06-07 7:51 [Bug middle-end/100942] New: ccmp is not used if the value is used later pinskia at gcc dot gnu.org
` (2 preceding siblings ...)
2023-12-12 8:23 ` pinskia at gcc dot gnu.org
@ 2024-01-23 17:43 ` cvs-commit at gcc dot gnu.org
2024-01-24 18:29 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-23 17:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100942
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsandifo@gcc.gnu.org>:
https://gcc.gnu.org/g:06ee648e9bb8c121fbd93659f81d3380dba8be09
commit r14-8372-g06ee648e9bb8c121fbd93659f81d3380dba8be09
Author: Andrew Pinski <quic_apinski@quicinc.com>
Date: Tue Jan 23 17:42:51 2024 +0000
aarch64/expr: Use ccmp when the outer expression is used twice [PR100942]
Ccmp is not used if the result of the and/ior is used by both
a GIMPLE_COND and a GIMPLE_ASSIGN. This improves the code generation
here by using ccmp in this case.
Two changes is required, first we need to allow the outer statement's
result be used more than once.
The second change is that during the expansion of the gimple, we need
to try using ccmp. This is needed because we don't use expand the ssa
name of the lhs but rather expand directly from the gimple.
A small note on the ccmp_4.c testcase, we should be able to get slightly
better than with this patch but it is one extra instruction compared to
before.
PR target/100942
gcc/ChangeLog:
* ccmp.cc (ccmp_candidate_p): Add outer argument.
Allow if the outer is true and the lhs is used more
than once.
(expand_ccmp_expr): Update call to ccmp_candidate_p.
* expr.h (expand_expr_real_gassign): Declare.
* expr.cc (expand_expr_real_gassign): New function, split out
from...
(expand_expr_real_1): ...here.
* cfgexpand.cc (expand_gimple_stmt_1): Use
expand_expr_real_gassign.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/ccmp_3.c: New test.
* gcc.target/aarch64/ccmp_4.c: New test.
* gcc.target/aarch64/ccmp_5.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Co-Authored-By: Richard Sandiford <richard.sandiford@arm.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/100942] ccmp is not used if the value is used later
2021-06-07 7:51 [Bug middle-end/100942] New: ccmp is not used if the value is used later pinskia at gcc dot gnu.org
` (3 preceding siblings ...)
2024-01-23 17:43 ` cvs-commit at gcc dot gnu.org
@ 2024-01-24 18:29 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-24 18:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100942
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|--- |14.0
Status|ASSIGNED |RESOLVED
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed. Thanks Richard S. for taking the patch the rest of the way.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-01-24 18:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07 7:51 [Bug middle-end/100942] New: ccmp is not used if the value is used later pinskia at gcc dot gnu.org
2023-12-12 1:18 ` [Bug middle-end/100942] " pinskia at gcc dot gnu.org
2023-12-12 3:40 ` pinskia at gcc dot gnu.org
2023-12-12 8:23 ` pinskia at gcc dot gnu.org
2024-01-23 17:43 ` cvs-commit at gcc dot gnu.org
2024-01-24 18:29 ` 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).