[PATCH] Improve x % y to x VRP optimization (PR tree-optimization/79408)

Marc Glisse marc.glisse@inria.fr
Sun Feb 12 07:14:00 GMT 2017


On Sun, 12 Feb 2017, Marc Glisse wrote:

> On Tue, 7 Feb 2017, Jakub Jelinek wrote:
>
>> 	* tree-vrp.c (simplify_div_or_mod_using_ranges): If op1 is not
>> 	constant, but SSA_NAME with a known integer range, use the minimum
>> 	of that range instead of op1 to determine if modulo can be replaced
>> 	with its first operand.
>
> Would it make sense to use something like the operand_less_p helper so we 
> would also handle an INTEGER_CST lhs?

Oops, operand_less_p is just a helper for compare_values_warnv and even 
that one doesn't seem to use ranges, so there may not already be a nice 
function we can call (?). The idea remains that reusing such code would 
help handle more cases (it may even handle a few symbolic cases).

> unsigned f(unsigned x){
>  if(x<42)return 18;
>  return 33%x;
> }

-- 
Marc Glisse



More information about the Gcc-patches mailing list