public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/54245] New: [4.8 regression] incorrect optimisation
@ 2012-08-13 16:26 mans at mansr dot com
  2012-08-13 17:20 ` [Bug tree-optimization/54245] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: mans at mansr dot com @ 2012-08-13 16:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54245

             Bug #: 54245
           Summary: [4.8 regression] incorrect optimisation
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mans@mansr.com


Created attachment 28007
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28007
Test case

Since r190220 the attached test is compiled incorrectly at -O1 and higher.


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

* [Bug tree-optimization/54245] [4.8 regression] incorrect optimisation
  2012-08-13 16:26 [Bug tree-optimization/54245] New: [4.8 regression] incorrect optimisation mans at mansr dot com
@ 2012-08-13 17:20 ` jakub at gcc dot gnu.org
  2012-08-13 19:29 ` wschmidt at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-08-13 17:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54245

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |wschmidt at gcc dot gnu.org
   Target Milestone|---                         |4.8.0

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-08-13 17:19:40 UTC ---
Confirmed.  slsr replaces:
  D.2219_3 = *row_2(D);
  D.2220_4 = (int) D.2219_3;
  a1_5 = D.2220_4 * 22725;
  D.2222_6 = MEM[(short int *)row_2(D) + 4B];
  D.2223_7 = (int) D.2222_6;
  D.2224_8 = D.2223_7 * 21407;
  a0_9 = D.2224_8 + a1_5;
  D.2225_10 = D.2223_7 * 8867;
- a1_11 = a1_5 + D.2225_10;
+ slsr.4_25 = D.2222_6 * 12540;
+ slsr.5_26 = (int) slsr.4_25;
+ a1_11 = a0_9 - slsr.5_26;

The multiplication is newly performed in short int, supposedly that is the
problem here.  Anyway, while the number of multiplications in the end is the
same, with slsr the code sequence is also 3 insns/4 bytes longer on x86_64.


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

* [Bug tree-optimization/54245] [4.8 regression] incorrect optimisation
  2012-08-13 16:26 [Bug tree-optimization/54245] New: [4.8 regression] incorrect optimisation mans at mansr dot com
  2012-08-13 17:20 ` [Bug tree-optimization/54245] " jakub at gcc dot gnu.org
@ 2012-08-13 19:29 ` wschmidt at gcc dot gnu.org
  2012-08-14 12:34 ` wschmidt at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2012-08-13 19:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54245

William J. Schmidt <wschmidt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-08-13
         AssignedTo|unassigned at gcc dot       |wschmidt at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #2 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-08-13 19:29:06 UTC ---
I'll take a look.  Might be a day or two as my queue is kind of full.


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

* [Bug tree-optimization/54245] [4.8 regression] incorrect optimisation
  2012-08-13 16:26 [Bug tree-optimization/54245] New: [4.8 regression] incorrect optimisation mans at mansr dot com
  2012-08-13 17:20 ` [Bug tree-optimization/54245] " jakub at gcc dot gnu.org
  2012-08-13 19:29 ` wschmidt at gcc dot gnu.org
@ 2012-08-14 12:34 ` wschmidt at gcc dot gnu.org
  2012-08-15 13:28 ` wschmidt at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2012-08-14 12:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54245

--- Comment #3 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-08-14 12:34:24 UTC ---
I'm putting together a for-now patch that disables the optimization when a
widening cast produces the stride.  In the long run this can be re-enabled so
long as we can retain the original cast and base the new multiply on that value
rather than doing it in the smaller type.  This is a bit subtle to get right so
I plan to defer that work until I have more time to concentrate on it.

I.e., there are two problems in this example: we did the multiply in a smaller
type and we introduced an extra cast that wasn't necessary if we were smart
enough (causing the longer sequence as Jakub noted).  The replacement would be
ok with a little re-design.


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

* [Bug tree-optimization/54245] [4.8 regression] incorrect optimisation
  2012-08-13 16:26 [Bug tree-optimization/54245] New: [4.8 regression] incorrect optimisation mans at mansr dot com
                   ` (2 preceding siblings ...)
  2012-08-14 12:34 ` wschmidt at gcc dot gnu.org
@ 2012-08-15 13:28 ` wschmidt at gcc dot gnu.org
  2012-08-15 13:29 ` wschmidt at gcc dot gnu.org
  2012-08-15 13:29 ` wschmidt at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2012-08-15 13:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54245

--- Comment #4 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-08-15 13:27:38 UTC ---
Author: wschmidt
Date: Wed Aug 15 13:27:29 2012
New Revision: 190412

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190412
Log:
gcc:

2012-08-15  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

    PR tree-optimization/54245
    * gimple-ssa-strength-reduction.c (legal_cast_p_1): New function.
    (legal_cast_p): Split out logic to legal_cast_p_1.
    (analyze_increments): Avoid introducing multiplies in smaller types.


gcc/testsuite:

2012-08-15  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

    PR tree-optimization/54245
    * gcc.dg/tree-ssa/pr54245.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr54245.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gimple-ssa-strength-reduction.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug tree-optimization/54245] [4.8 regression] incorrect optimisation
  2012-08-13 16:26 [Bug tree-optimization/54245] New: [4.8 regression] incorrect optimisation mans at mansr dot com
                   ` (3 preceding siblings ...)
  2012-08-15 13:28 ` wschmidt at gcc dot gnu.org
@ 2012-08-15 13:29 ` wschmidt at gcc dot gnu.org
  2012-08-15 13:29 ` wschmidt at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2012-08-15 13:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54245

William J. Schmidt <wschmidt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #4 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-08-15 13:27:38 UTC ---
Author: wschmidt
Date: Wed Aug 15 13:27:29 2012
New Revision: 190412

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190412
Log:
gcc:

2012-08-15  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

    PR tree-optimization/54245
    * gimple-ssa-strength-reduction.c (legal_cast_p_1): New function.
    (legal_cast_p): Split out logic to legal_cast_p_1.
    (analyze_increments): Avoid introducing multiplies in smaller types.


gcc/testsuite:

2012-08-15  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

    PR tree-optimization/54245
    * gcc.dg/tree-ssa/pr54245.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr54245.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gimple-ssa-strength-reduction.c
    trunk/gcc/testsuite/ChangeLog

--- Comment #5 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-08-15 13:28:49 UTC ---
Fixed.


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

* [Bug tree-optimization/54245] [4.8 regression] incorrect optimisation
  2012-08-13 16:26 [Bug tree-optimization/54245] New: [4.8 regression] incorrect optimisation mans at mansr dot com
                   ` (4 preceding siblings ...)
  2012-08-15 13:29 ` wschmidt at gcc dot gnu.org
@ 2012-08-15 13:29 ` wschmidt at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2012-08-15 13:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54245

William J. Schmidt <wschmidt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #5 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-08-15 13:28:49 UTC ---
Fixed.


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

end of thread, other threads:[~2012-08-15 13:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-13 16:26 [Bug tree-optimization/54245] New: [4.8 regression] incorrect optimisation mans at mansr dot com
2012-08-13 17:20 ` [Bug tree-optimization/54245] " jakub at gcc dot gnu.org
2012-08-13 19:29 ` wschmidt at gcc dot gnu.org
2012-08-14 12:34 ` wschmidt at gcc dot gnu.org
2012-08-15 13:28 ` wschmidt at gcc dot gnu.org
2012-08-15 13:29 ` wschmidt at gcc dot gnu.org
2012-08-15 13:29 ` wschmidt 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).