On 07/27/2015 03:25 AM, Richard Biener wrote:
On Mon, Jul 27, 2015 at 5:41 AM, Michael Collison
<michael.colli...@linaro.org> wrote:
This patch is designed to optimize end of loop conditions involving of the
form
  i < x && i < y into i < min (x, y). Loop condition involving '>' are
handled similarly using max(x,y).
As an example:

#define N 1024

int  a[N], b[N], c[N];

void add (unsignedint  m, unsignedint  n)
{
   unsignedint  i, bound = (m < n) ? m : n;
   for  (i = 0; i < m && i < n; ++i)
     a[i] = b[i] + c[i];
}


Performed bootstrap and make check on: x86_64_unknown-linux-gnu,
arm-linux-gnueabihf, and aarch64-linux-gnu.
Okay for trunk?

So this works only for && that has been lowered to non-CFG form
(I suppose phiopt would catch that?  If not, ifcombine would be the
place to implement it I guess).
phiopt is supposed to be generating MIN/MAX expressions for us. If it isn't it'd be good to see any testcases where it isn't.

I think that raises a general question though. Does it make more sense to capture MIN/MAX (and others) in phiopt or in the match.pd framework?

Jeff

Reply via email to