public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "enkovich.gnu at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/49959] New: ABS pattern is not recognized
Date: Wed, 03 Aug 2011 12:25:00 -0000	[thread overview]
Message-ID: <bug-49959-4@http.gcc.gnu.org/bugzilla/> (raw)

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'


             reply	other threads:[~2011-08-03 12:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-03 12:25 enkovich.gnu at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-49959-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).