On 07/29/2016 09:35 AM, Bin Cheng wrote:
Hi,
This is prerequisite patch for fixing PR34114 which reveals a weakness of GCC 
in analyzing niter for loop with NE_EXPR exit condition.  For such loops, we 
quite often need to check if delta (final - start) of loop range is multiple of 
IV's step.  This patch proves multiple_of_p (top, bottom) for more cases:
  1) Handle (X + 4294967293) as (X - 3) if the expression is of unsigned int 
type.  At the moment it's not recognized because (4294967293 % 3 != 0)
  2) Handle top var if it's defined as:
       top = (X & ~(bottom - 1) ; bottom is power of 2
  3) Handle top var if it's defined as:
       Y = X % bottom
       top = X - Y

Bootstrap and test on x86_64 and AArch64 along with next patch.  Is it OK?

Thanks,
bin

2016-07-27  Bin Cheng  <bin.ch...@arm.com>

        * fold-const.c (multiple_of_p): Improve MULT_EXPR, PLUS_EXPR,
        PLUS_EXPR case.  Handle SSA_NAME case.

OK.

Note that it would seem that this is an ideal kind of behaviorial change to test in the new unit testing framework. See the code inside the #if CHECKING_P at the bottom of fold-const.c.

Essentially you can build up the appropriate tree nodes and pass them to multiple_of_p, then test the result -- without having to find/create C code that will trigger your code.

I'm not requiring it for this change, but I might start for this kind of change in the future :-) In the mean time, consider adding the tests, you may find that they're a great way to verify behavior of these low level folders and similar routines.

Jeff

Reply via email to