public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/49959] New: ABS pattern is not recognized
@ 2011-08-03 12:25 enkovich.gnu at gmail dot com
2011-08-03 12:50 ` [Bug tree-optimization/49959] " rguenth at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: enkovich.gnu at gmail dot com @ 2011-08-03 12:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49959
Summary: ABS pattern is not recognized
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: enkovich.gnu@gmail.com
Created attachment 24900
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24900
Simple test where ABS pattern is not recognized
Here is optimization opportunity for ABS pattern recognizer which does not
catch all cases.
Here is a simple test for ABS computation:
#define ABS(X) (((X)>0)?(X):-(X))
int
test_abs(int *cur)
{
unsigned long sad = 0;
sad = ABS(cur[0]);
return sad;
}
GIMPLE for the test is good (phase optimized):
test_abs (int * cur)
{
int D.2783;
int D.2782;
<bb 2>:
D.2782_3 = *cur_2(D);
D.2783_4 = ABS_EXPR <D.2782_3>;
return D.2783_4;
}
Now try to make a minor change in test:
#define ABS(X) (((X)>0)?(X):-(X))
int
test_abs(int *cur)
{
unsigned long sad = 0;
sad += ABS(cur[0]);
return sad;
}
GIMPLE becomes worse:
test_abs (int * cur)
{
int D.2788;
int D.2787;
int D.2783;
long unsigned int iftmp.0;
<bb 2>:
D.2783_4 = *cur_3(D);
if (D.2783_4 > 0)
goto <bb 3>;
else
goto <bb 4>;
<bb 3>:
iftmp.0_6 = (long unsigned int) D.2783_4;
goto <bb 5>;
<bb 4>:
D.2787_8 = -D.2783_4;
iftmp.0_9 = (long unsigned int) D.2787_8;
<bb 5>:
# iftmp.0_1 = PHI <iftmp.0_6(3), iftmp.0_9(4)>
D.2788_11 = (int) iftmp.0_1;
return D.2788_11;
}
Compiler used for tests:
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/export/gcc-build
--enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.7.0 20110707 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O2' '-S' '-mtune=generic'
'-march=x86-64'
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/49959] ABS pattern is not recognized
2011-08-03 12:25 [Bug middle-end/49959] New: ABS pattern is not recognized enkovich.gnu at gmail dot com
@ 2011-08-03 12:50 ` rguenth at gcc dot gnu.org
2012-01-21 8:21 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-08-03 12:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49959
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.08.03 12:49:46
Component|middle-end |tree-optimization
Ever Confirmed|0 |1
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-03 12:49:46 UTC ---
Confirmed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/49959] ABS pattern is not recognized
2011-08-03 12:25 [Bug middle-end/49959] New: ABS pattern is not recognized enkovich.gnu at gmail dot com
2011-08-03 12:50 ` [Bug tree-optimization/49959] " rguenth at gcc dot gnu.org
@ 2012-01-21 8:21 ` pinskia at gcc dot gnu.org
2021-07-06 8:21 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-21 8:21 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49959
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-21 08:03:40 UTC ---
If we had a pass which was able to convert:
<bb 3>:
iftmp.0_6 = (long unsigned int) D.1708_4;
goto <bb 5>;
<bb 4>:
D.1712_8 = -D.1708_4;
iftmp.0_9 = (long unsigned int) D.1712_8;
<bb 5>:
# iftmp.0_1 = PHI <iftmp.0_6(3), iftmp.0_9(4)>
Into:
<bb 3>:
goto <bb 5>;
<bb 4>:
D.1712_8 = -D.1708_4;
<bb 5>:
# t_N = PHI<D.1708_4(3), D.1712_8(4)>
iftmp.0_1 = (long unsigned int)t_n;
And then PHIOPT would recognize it. So this is really the code commoning.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/49959] ABS pattern is not recognized
2011-08-03 12:25 [Bug middle-end/49959] New: ABS pattern is not recognized enkovich.gnu at gmail dot com
2011-08-03 12:50 ` [Bug tree-optimization/49959] " rguenth at gcc dot gnu.org
2012-01-21 8:21 ` pinskia at gcc dot gnu.org
@ 2021-07-06 8:21 ` pinskia at gcc dot gnu.org
2021-11-17 10:11 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-06 8:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49959
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|NEW |ASSIGNED
Severity|normal |enhancement
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=59424
Keywords| |missed-optimization
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I have a fix.
This is related to PR 59424 (part of that fixes this one).
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/49959] ABS pattern is not recognized
2011-08-03 12:25 [Bug middle-end/49959] New: ABS pattern is not recognized enkovich.gnu at gmail dot com
` (2 preceding siblings ...)
2021-07-06 8:21 ` pinskia at gcc dot gnu.org
@ 2021-11-17 10:11 ` pinskia at gcc dot gnu.org
2023-05-07 4:49 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-17 10:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49959
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note Pre is able to remove the casts since GCC 8.
So the original testcase is fixed but if you change it to:
#define ABS(X) (((X)>0)?(X):-(X))
unsigned long
test_abs(int *cur)
{
unsigned long sad = 0;
sad += ABS(cur[0]);
return sad;
}
We still have the same issue as before.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/49959] ABS pattern is not recognized
2011-08-03 12:25 [Bug middle-end/49959] New: ABS pattern is not recognized enkovich.gnu at gmail dot com
` (3 preceding siblings ...)
2021-11-17 10:11 ` pinskia at gcc dot gnu.org
@ 2023-05-07 4:49 ` pinskia at gcc dot gnu.org
2023-05-08 7:38 ` cvs-commit at gcc dot gnu.org
2023-05-08 7:41 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-07 4:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49959
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 55016
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55016&action=edit
Patch
For some reason it didn't make it to the mailing list yet. Will figure out why
in a few. patches 2 and 3 did make it though.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/49959] ABS pattern is not recognized
2011-08-03 12:25 [Bug middle-end/49959] New: ABS pattern is not recognized enkovich.gnu at gmail dot com
` (4 preceding siblings ...)
2023-05-07 4:49 ` pinskia at gcc dot gnu.org
@ 2023-05-08 7:38 ` cvs-commit at gcc dot gnu.org
2023-05-08 7:41 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-08 7:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49959
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:
https://gcc.gnu.org/g:69f1a8af45d8a42003c21489019ddfb01d88d30d
commit r14-573-g69f1a8af45d8a42003c21489019ddfb01d88d30d
Author: Andrew Pinski <apinski@marvell.com>
Date: Wed Apr 26 14:55:46 2023 -0700
PHIOPT: Add diamond bb form to factor_out_conditional_conversion
So the function factor_out_conditional_conversion already supports
diamond shaped bb forms, just need to be called for such a thing.
harden-cond-comp.c needed to be changed as we would optimize out the
conversion now and that causes the compare hardening not needing to
split the block which it was testing. So change it such that there
would be no chance of optimization.
Also add two testcases that showed the improvement. PR 103771 is
solved in ifconvert also for the vectorizer but now it is solved
in a general sense.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR tree-optimization/49959
PR tree-optimization/103771
gcc/ChangeLog:
* tree-ssa-phiopt.cc (pass_phiopt::execute): Support
Diamond shapped bb form for factor_out_conditional_conversion.
gcc/testsuite/ChangeLog:
* c-c++-common/torture/harden-cond-comp.c: Change testcase
slightly to avoid the new phiopt optimization.
* gcc.dg/tree-ssa/abs-2.c: New test.
* gcc.dg/tree-ssa/pr103771.c: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/49959] ABS pattern is not recognized
2011-08-03 12:25 [Bug middle-end/49959] New: ABS pattern is not recognized enkovich.gnu at gmail dot com
` (5 preceding siblings ...)
2023-05-08 7:38 ` cvs-commit at gcc dot gnu.org
@ 2023-05-08 7:41 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-08 7:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49959
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
Target Milestone|--- |14.0
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-05-08 7:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-03 12:25 [Bug middle-end/49959] New: ABS pattern is not recognized enkovich.gnu at gmail dot com
2011-08-03 12:50 ` [Bug tree-optimization/49959] " rguenth at gcc dot gnu.org
2012-01-21 8:21 ` pinskia at gcc dot gnu.org
2021-07-06 8:21 ` pinskia at gcc dot gnu.org
2021-11-17 10:11 ` pinskia at gcc dot gnu.org
2023-05-07 4:49 ` pinskia at gcc dot gnu.org
2023-05-08 7:38 ` cvs-commit at gcc dot gnu.org
2023-05-08 7:41 ` 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).