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

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).