public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/61734] New: Regression in ABS_EXPR recognition
@ 2014-07-07 13:31 enkovich.gnu at gmail dot com
  2014-07-07 14:27 ` [Bug middle-end/61734] [4.10 Regression] " rguenth at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: enkovich.gnu at gmail dot com @ 2014-07-07 13:31 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-07-29 16:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-07 13:31 [Bug tree-optimization/61734] New: Regression in ABS_EXPR recognition enkovich.gnu at gmail dot com
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

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