This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/49959] New: ABS pattern is not recognized
- From: "enkovich.gnu at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 3 Aug 2011 12:25:36 +0000
- Subject: [Bug middle-end/49959] New: ABS pattern is not recognized
- Auto-submitted: auto-generated
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'