[Bug rtl-optimization/98334] Failure to optimally optimize add loop to mul

2023-02-17 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98334

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |13.0

--- Comment #7 from Andrew Pinski  ---
(In reply to Jakub Jelinek from comment #5)
> Fixed at the RTL level, keeping open for the GIMPLE optimization.

For the testcase in comment #1 this is recorded as PR 94782.

For the original testcase in comment #0, I don't know when it was fixed on the
trunk but in sccp we get now:

final value replacement:
  result_2 = PHI 
 with expr: (int) n_4(D) * i_6(D)
 final stmt:
  result_2 = _1 * i_6(D);

instead of:

final value replacement:
  result_2 = PHI 
 with expr: (int) (n_3(D) + 4294967295) * i_6(D) + i_6(D)
 final stmt:
  result_2 = _9 + i_6(D);

[Bug rtl-optimization/98334] Failure to optimally optimize add loop to mul

2022-05-27 Thread roger at nextmovesoftware dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98334

Roger Sayle  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||roger at nextmovesoftware dot 
com
 Resolution|--- |FIXED

--- Comment #6 from Roger Sayle  ---
This is now fully optimized at the tree level too.
int f (int i, unsigned int n)
{
  int result;
  int _1;

   [local count: 118111600]:
  _1 = (int) n_3(D);
  result_2 = _1 * i_6(D);
  return result_2;

}

[Bug rtl-optimization/98334] Failure to optimally optimize add loop to mul

2021-01-05 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98334

Jakub Jelinek  changed:

   What|Removed |Added

 Status|ASSIGNED|NEW
   Assignee|jakub at gcc dot gnu.org   |unassigned at gcc dot 
gnu.org

--- Comment #5 from Jakub Jelinek  ---
Fixed at the RTL level, keeping open for the GIMPLE optimization.

[Bug rtl-optimization/98334] Failure to optimally optimize add loop to mul

2021-01-05 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98334

--- Comment #4 from CVS Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:4615cde5d7ef281d4b554df411f82ad707f0a54d

commit r11-6456-g4615cde5d7ef281d4b554df411f82ad707f0a54d
Author: Jakub Jelinek 
Date:   Tue Jan 5 10:57:52 2021 +0100

simplify-rtx: Optimize (x - 1) * y + y [PR98334]

We don't try to optimize for signed x, y (int) (x - 1U) * y + y
into x * y, we can't do that with signed x * y, because the former
is well defined for INT_MIN and -1, while the latter is not.
We could perhaps optimize it during isel or some very late optimization
where we'd turn magically flag_wrapv, but we don't do that yet.

This patch optimizes it in simplify-rtx.c, such that we can optimize
it during combine.

2021-01-05  Jakub Jelinek  

PR rtl-optimization/98334
* simplify-rtx.c (simplify_context::simplify_binary_operation_1):
Optimize (X - 1) * Y + Y to X * Y or (X + 1) * Y - Y to X * Y.

* gcc.target/i386/pr98334.c: New test.

[Bug rtl-optimization/98334] Failure to optimally optimize add loop to mul

2021-01-04 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98334

--- Comment #3 from Richard Biener  ---
I think turning (int) (y - 1U) * x + x into unsigned mult is OK even early.

[Bug rtl-optimization/98334] Failure to optimally optimize add loop to mul

2020-12-17 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98334

Jakub Jelinek  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org
   Last reconfirmed||2020-12-17
 Ever confirmed|0   |1
 Status|UNCONFIRMED |ASSIGNED

--- Comment #2 from Jakub Jelinek  ---
Created attachment 49787
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49787=edit
gcc11-pr98334.patch

Untested fix.