[PATCH][GCC] Algorithmic optimization in match and simplify

Andre Vieira Andre.SimoesDiasVieira@arm.com
Tue Sep 1 13:40:00 GMT 2015


Hi Marc,

On 28/08/15 19:07, Marc Glisse wrote:
> (not a review, I haven't even read the whole patch)
>
> On Fri, 28 Aug 2015, Andre Vieira wrote:
>
>> 2015-08-03  Andre Vieira  <andre.simoesdiasvieira@arm.com>
>>
>>   * match.pd: Added new patterns:
>>     ((X {&,<<,>>} C0) {|,^} C1) {^,|} C2)
>>     (X {|,^,&} C0) {<<,>>} C1 -> (X {<<,>>} C1) {|,^,&} (C0 {<<,>>} C1)
>
> +(for op0 (rshift rshift lshift lshift bit_and bit_and)
> + op1 (bit_ior bit_xor bit_ior bit_xor bit_ior bit_xor)
> + op2 (bit_xor bit_ior bit_xor bit_ior bit_xor bit_ior)
>
> You can nest for-loops, it seems clearer as:
> (for op0 (rshift lshift bit_and)
>    (for op1 (bit_ior bit_xor)
>         op2 (bit_xor bit_ior)

Will do, thank you for pointing it out.
>
> +(simplify
> + (op2:c
> +  (op1:c
> +   (op0 @0 INTEGER_CST@1) INTEGER_CST@2) INTEGER_CST@3)
>
> I suspect you will want more :s (single_use) and less :c (canonicalization
> should put constants in second position).
>
I can't find the definition of :s (single_use). GCC internals do point 
out that canonicalization does put constants in the second position, 
didnt see that first. Thank you for pointing it out.

> +	C1 = wi::bit_and_not (C1,C2);
>
> Space after ','.
>
Will do.

> Having wide_int_storage in many places is surprising, I can't find similar
> code anywhere else in gcc.
>
>

I tried looking for examples of something similar, I think I ended up 
using wide_int because I was able to convert easily to and from it and 
it has the "mask" and "wide_int_to_tree" functions. I welcome any 
suggestions on what I should be using here for integer constant 
transformations and comparisons.

BR,
Andre



More information about the Gcc-patches mailing list