public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/57702] New: Reassoc missed optimizations
@ 2013-06-24 18:18 jakub at gcc dot gnu.org
  2013-06-25  7:17 ` [Bug tree-optimization/57702] " jakub at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-06-24 18:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57702
           Summary: Reassoc missed optimizations
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org

On:

int f1 (int x, int y) { x += y; return x + 3 * y; }
unsigned int f2 (unsigned int x, unsigned int y) { x += y; return x + 3 * y; }
int f3 (int x, int y) { x += 7 * y; return x + 12 * y; }
unsigned int f4 (unsigned int x, unsigned int y) { x += 7 * y; return x + 12 *
y; }

reassoc optimizes only the f4 function into x += 19 * y; at the tree level, and
at the RTL level combiner happens to optimize it except for f3, which has more
insns than f4.  I don't see why not optimizing this even for signed types would
be problematic, as long as the multiplication is performed in the same signed
type and all terms have the same sign (with different sizes the optimization
could remove undefined overflow, but I don't see how it could introduce it).

When things are vectorized the RTL optimizations will hardly help though.


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

* [Bug tree-optimization/57702] Reassoc missed optimizations
  2013-06-24 18:18 [Bug tree-optimization/57702] New: Reassoc missed optimizations jakub at gcc dot gnu.org
@ 2013-06-25  7:17 ` jakub at gcc dot gnu.org
  2013-12-17 23:04 ` ktietz at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-06-25  7:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Another example:
unsigned int foo (unsigned int x, unsigned int y)
{
  x += y;
  x += y;
  x += y;
  x += y;
  x += y;
  return x;
}

Seems for the x += 7 * y; x += 12 * y; case it is undistribute_ops_list that
performs this optimization.  For non-wrapping integers we give up very early,
can_reassociate_p returns false and we don't try anything, perhaps with care we
could try at least undistribution, provided that we are very careful not to
reorder anything, only undistribute adjacent operations.  For unsigned
integers,
we give up because we never consider an SSA_NAME to be 1 * SSA_NAME for the
purposes of undistribution.


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

* [Bug tree-optimization/57702] Reassoc missed optimizations
  2013-06-24 18:18 [Bug tree-optimization/57702] New: Reassoc missed optimizations jakub at gcc dot gnu.org
  2013-06-25  7:17 ` [Bug tree-optimization/57702] " jakub at gcc dot gnu.org
@ 2013-12-17 23:04 ` ktietz at gcc dot gnu.org
  2021-07-20  2:42 ` pinskia at gcc dot gnu.org
  2021-07-20  6:55 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ktietz at gcc dot gnu.org @ 2013-12-17 23:04 UTC (permalink / raw)
  To: gcc-bugs

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

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ktietz at gcc dot gnu.org

--- Comment #3 from Kai Tietz <ktietz at gcc dot gnu.org> ---
Looks tp me like a duplicate of 45218


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

* [Bug tree-optimization/57702] Reassoc missed optimizations
  2013-06-24 18:18 [Bug tree-optimization/57702] New: Reassoc missed optimizations jakub at gcc dot gnu.org
  2013-06-25  7:17 ` [Bug tree-optimization/57702] " jakub at gcc dot gnu.org
  2013-12-17 23:04 ` ktietz at gcc dot gnu.org
@ 2021-07-20  2:42 ` pinskia at gcc dot gnu.org
  2021-07-20  6:55 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-20  2:42 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2013-06-25 00:00:00         |2021-7-19

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
f2:
  _1 = y_3(D) * 3;
  _7 = _1 + x_2(D);
  _5 = y_3(D) + _7;

f4:
  _9 = y_3(D) * 19;
  _6 = x_4(D) + _9;

foo:
  _9 = y_2(D) * 5;
  x_7 = x_1(D) + _9;

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

* [Bug tree-optimization/57702] Reassoc missed optimizations
  2013-06-24 18:18 [Bug tree-optimization/57702] New: Reassoc missed optimizations jakub at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-07-20  2:42 ` pinskia at gcc dot gnu.org
@ 2021-07-20  6:55 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-20  6:55 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |\
           Severity|normal                      |enhancement

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

end of thread, other threads:[~2021-07-20  6:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-24 18:18 [Bug tree-optimization/57702] New: Reassoc missed optimizations jakub at gcc dot gnu.org
2013-06-25  7:17 ` [Bug tree-optimization/57702] " jakub at gcc dot gnu.org
2013-12-17 23:04 ` ktietz at gcc dot gnu.org
2021-07-20  2:42 ` pinskia at gcc dot gnu.org
2021-07-20  6:55 ` 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).