>> 1. Dataflow framework to propagate bitwise register properties.
>>   (Integrated with the current dataflow framework.)
>> 2. Forward bitwise dataflow analysis: constant bit propagation.
>> 3. Backward bitwise dataflow analysis: dead bit propagation.
>> 4. Target applications: improve dce and see.  (Others?)

>>   For each instruction I in the function body
>>     For each register R in instruction I
>>       def_constant_bits(I, R) = collect constants from AND/OR/...
>> operations.

There's already nonzero_bits (i.e. maybe nonzero) and
num_sign_bit_copies in rtlanal.c.  You can add to this one_bits and it
should be enough to do the simplifications you want.

You can get initial info from those routines, do the dataflow.  Then
there are rtx_hooks members to get a REG's nonzero bits/# of sign bit
copies (and you can add one for one_bits): just set them to a function
in your pass that returns info from the dataflow.  Then you can walk
through all the functions, recursively simplifying the RHS of each set
(you can look at propagate_rtx in fwprop.c for an example of
"simplifying the RHS").  The code in simplify-rtx.c will take care of
using the nonzero_bits (et al.) information; other optimizations can be
added there.

Do not forget to check the cost of the replacement, otherwise your pass
might end up doing constant propagation (for constants, all zero and one
bits are known!!!).

Paolo

Reply via email to