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 tree-optimization/61734] New: Regression in ABS_EXPR recognition
Date: Mon, 07 Jul 2014 13:31:00 -0000	[thread overview]
Message-ID: <bug-61734-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61734

            Bug ID: 61734
           Summary: Regression in ABS_EXPR recognition
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: enkovich.gnu at gmail dot com

Recently a performance regression occurred in tests heavily using ABS
computation (observed on x86 and ARM targets).  It is caused by missing
ABS_EXPR recognition which results in sub-optimal code.

Problem appeared after this commit:

commit 32ce9a5c4208411361402f60e672c4830da0bc8f
Author: ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue May 27 19:54:46 2014 +0000

        * fold-const.c (fold_comparison): Clean up and extend X +- C1 CMP C2
        to X CMP C2 -+ C1 transformation to EQ_EXPR/NE_EXPR.
        Add X - Y CMP 0 to X CMP Y transformation.
        (fold_binary_loc) <EQ_EXPR/NE_EXPR>: Remove same transformations.


    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210979
138bc75d-0d04-0410-961f-82ee72b054a4


Here is a simple test (tested on linux-x86_64):
>cat test.i
unsigned long test (unsigned char a, unsigned char b, unsigned long sum)
{
  sum += ((a - b) > 0 ? (a - b) : -(a - b));
  return sum;
}
>gcc-exp-build/bin/gcc test.i -m32 -O2 -fdump-tree-gimple -c
>cat test.i.004t.gimple
test (unsigned char a, unsigned char b, long unsigned int sum)
{
  long unsigned int iftmp.0;
  int D.1720;
  int D.1721;
  int D.1724;
  int D.1726;
  long unsigned int D.1727;

  D.1720 = (int) a;
  D.1721 = (int) b;
  if (D.1720 > D.1721) goto <D.1722>; else goto <D.1723>;
  <D.1722>:
  D.1720 = (int) a;
  D.1721 = (int) b;
  D.1724 = D.1720 - D.1721;
  iftmp.0 = (long unsigned int) D.1724;
  goto <D.1725>;
  <D.1723>:
  D.1721 = (int) b;
  D.1720 = (int) a;
  D.1726 = D.1721 - D.1720;
  iftmp.0 = (long unsigned int) D.1726;
  <D.1725>:
  sum = iftmp.0 + sum;
  D.1727 = sum;
  return D.1727;
}


With older compiler I have:

>gcc-ref-build/bin/gcc test.i -m32 -O2 -fdump-tree-gimple -c
>cat test.i.004t.gimple
test (unsigned char a, unsigned char b, long unsigned int sum)
{
  int D.1719;
  int D.1720;
  int D.1721;
  int D.1722;
  long unsigned int D.1723;
  long unsigned int D.1724;

  D.1719 = (int) a;
  D.1720 = (int) b;
  D.1721 = D.1719 - D.1720;
  D.1722 = ABS_EXPR <D.1721>;
  D.1723 = (long unsigned int) D.1722;
  sum = D.1723 + sum;
  D.1724 = sum;
  return D.1724;
}


BTW both compilers generate ABS_EXPR when -O0 is used instead of -O2.  Both
compilers fail to generate ABS_EXPR when -m64 is used instead of -m32.


             reply	other threads:[~2014-07-07 13:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-07 13:31 enkovich.gnu at gmail dot com [this message]
2014-07-07 14:27 ` [Bug middle-end/61734] [4.10 Regression] " rguenth at gcc dot gnu.org
2014-07-07 15:27 ` ebotcazou at gcc dot gnu.org
2014-07-08  8:21 ` jakub at gcc dot gnu.org
2014-07-08  9:43 ` ebotcazou at gcc dot gnu.org
2014-07-08 10:18 ` jakub at gcc dot gnu.org
2014-07-08 11:46 ` glisse at gcc dot gnu.org
2014-07-22 16:41 ` ebotcazou at gcc dot gnu.org
2014-07-28  8:55 ` ebotcazou at gcc dot gnu.org
2014-07-28  8:57 ` ebotcazou at gcc dot gnu.org
2014-07-29 11:49 ` enkovich.gnu at gmail dot com
2014-07-29 15:17 ` ebotcazou at gcc dot gnu.org
2014-07-29 15:41 ` enkovich.gnu at gmail dot com
2014-07-29 16:23 ` ebotcazou 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-61734-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).