public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/32073] Loop unrolling does not exploit VRP for loop bound
       [not found] <bug-32073-4@http.gcc.gnu.org/bugzilla/>
@ 2021-11-28  3:59 ` pinskia at gcc dot gnu.org
  2024-03-17  1:13 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-28  3:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note there is a few things here that can be improved even more.
With a slightly different testcase:
void short_loop(int* __restrict dest, int* __restrict src, int count) {
  // same happens for assert(count <= 4) and if(count > 4) exit(-1)
  if(count > 4)
    count = 4;

  for(int i=0; i < count; i++)
    dest[i] = src[i] + 1;
}

In VRP2 we have:
  _5 = MIN_EXPR <count_10(D), 4>;
  if (count_10(D) > 0)
    goto <bb 3>; [80.00%]
  else
    goto <bb 9>; [20.00%]

  <bb 3> [local count: 171798694]:
  _23 = (unsigned int) _5;
  niters.4_24 = _5 > 0 ? _23 : 1;

Which we don't optimize niters.4_24 to just _23.

Without the +1 we optimize the above to memcpy (and still have the above issue
too) and the expansion there needs help (which I thought I filed as another bug
but I can't find it).
There might be other issues where the vectorizer and such don't see that the
count <= 4 and count >= 1.

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

* [Bug tree-optimization/32073] Loop unrolling does not exploit VRP for loop bound
       [not found] <bug-32073-4@http.gcc.gnu.org/bugzilla/>
  2021-11-28  3:59 ` [Bug tree-optimization/32073] Loop unrolling does not exploit VRP for loop bound pinskia at gcc dot gnu.org
@ 2024-03-17  1:13 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-17  1:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.9.0
             Status|NEW                         |RESOLVED

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 4.9.0.

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

* [Bug tree-optimization/32073] Loop unrolling does not exploit VRP for loop bound
  2007-05-24 17:45 [Bug c++/32073] New: " scovich at gmail dot com
@ 2007-05-24 21:48 ` rguenth at gcc dot gnu dot org
  0 siblings, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-05-24 21:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2007-05-24 22:48 -------
VRP information is not preserved over optimization passes, so loop unrolling
does not know about it.  But VRP recognizes that count is <= 4.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org, rakdver at gcc dot gnu
                   |                            |dot org
             Status|UNCONFIRMED                 |NEW
          Component|c++                         |tree-optimization
     Ever Confirmed|0                           |1
           Keywords|                            |missed-optimization
   Last reconfirmed|0000-00-00 00:00:00         |2007-05-24 22:48:10
               date|                            |


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


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

end of thread, other threads:[~2024-03-17  1:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-32073-4@http.gcc.gnu.org/bugzilla/>
2021-11-28  3:59 ` [Bug tree-optimization/32073] Loop unrolling does not exploit VRP for loop bound pinskia at gcc dot gnu.org
2024-03-17  1:13 ` pinskia at gcc dot gnu.org
2007-05-24 17:45 [Bug c++/32073] New: " scovich at gmail dot com
2007-05-24 21:48 ` [Bug tree-optimization/32073] " rguenth at gcc dot gnu dot 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).