public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/78115] Missed optimization for "int modulo 2^31"
       [not found] <bug-78115-4@http.gcc.gnu.org/bugzilla/>
@ 2021-07-21  1:11 ` pinskia at gcc dot gnu.org
  2021-11-15  9:01 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-21  1:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
We get now:
  if (num_2(D) < 0)
    goto <bb 3>; [41.00%]
  else
    goto <bb 4>; [59.00%]

  <bb 3> [local count: 440234144]:
  num_3 = num_2(D) - -2147483648;

  <bb 4> [local count: 1073741824]:
  # num_1 = PHI <num_2(D)(2), num_3(3)>

So something like (psedu code):
(simplify
 (cond (lt @0 integer_zerop) (minus @0 INTEGER_CST@1) @0)
 (if (TYPE_SIGN (type) == SIGNED && @1 == type_min(type))
  (bit_and @0 type_max(type))))

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

* [Bug middle-end/78115] Missed optimization for "int modulo 2^31"
       [not found] <bug-78115-4@http.gcc.gnu.org/bugzilla/>
  2021-07-21  1:11 ` [Bug middle-end/78115] Missed optimization for "int modulo 2^31" pinskia at gcc dot gnu.org
@ 2021-11-15  9:01 ` pinskia at gcc dot gnu.org
  2023-05-24  7:57 ` pinskia at gcc dot gnu.org
  2023-06-07 15:18 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-15  9:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |103216
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The patch which I posted for PR 103216 will fix this one too:
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584411.html

in phiopt4:
COND_EXPR in block 2 and PHI in block 4 converted to straightline code.
Merging blocks 2 and 4
fix_loop_structure: fixing up loops for function
int mod31 (int num)
{
  _Bool _5;
  int _6;
  int _7;
  int _8;

  <bb 2> [local count: 1073741824]:
  _5 = num_2(D) < 0;
  _6 = (int) _5;
  _7 = num_2(D) & -2147483648;
  _8 = num_2(D) & 2147483647;
  return _8;

}


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103216
[Bug 103216] missed optimization, phiopt/vrp?

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

* [Bug middle-end/78115] Missed optimization for "int modulo 2^31"
       [not found] <bug-78115-4@http.gcc.gnu.org/bugzilla/>
  2021-07-21  1:11 ` [Bug middle-end/78115] Missed optimization for "int modulo 2^31" pinskia at gcc dot gnu.org
  2021-11-15  9:01 ` pinskia at gcc dot gnu.org
@ 2023-05-24  7:57 ` pinskia at gcc dot gnu.org
  2023-06-07 15:18 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-24  7:57 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |90087
                 CC|                            |nok.raven at gmail dot com

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 90087 has been marked as a duplicate of this bug. ***


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90087
[Bug 90087] Suboptimal codegen for x < 0 ? x - INT_MIN : x

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

* [Bug middle-end/78115] Missed optimization for "int modulo 2^31"
       [not found] <bug-78115-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2023-05-24  7:57 ` pinskia at gcc dot gnu.org
@ 2023-06-07 15:18 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-07 15:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
What this needs above and beyond PR 103216 is supporting `x ? a - b : a`.

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

end of thread, other threads:[~2023-06-07 15:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-78115-4@http.gcc.gnu.org/bugzilla/>
2021-07-21  1:11 ` [Bug middle-end/78115] Missed optimization for "int modulo 2^31" pinskia at gcc dot gnu.org
2021-11-15  9:01 ` pinskia at gcc dot gnu.org
2023-05-24  7:57 ` pinskia at gcc dot gnu.org
2023-06-07 15:18 ` 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).