This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: new sign/zero extension elimination pass


On Sun, Oct 31, 2010 at 18:55, Tom de Vries <tom@codesourcery.com> wrote:
>> DU and UD-chains are quadratic, and the reaching definitions problem has
>> very big solutions too, so they are rarely the right solution
>> (unfortunately).
>
> thanks, I overlooked that completely.

No problem, I discovered it the hard way (and had to rewrite fwprop's
dataflow to work around it).

>> In addition, I wonder if this pass wouldn't introduce new undefined
>> overflows, which would be a correctness problem.
>
> The pass assumes wraparound overflow for plus and minus. The documentation of
> the rtl operator 'plus' states that 'plus wraps round modulo the width of m'
> (similar for 'minus'). I interpreted this independently from -fwrapv and
> -fstrict-overflow, am I wrong there?

I think you're right, as Joseph confirmed.  There is one occurrence of
flag_wrapv in simplify-rtx.c and zero in combine.c, so this means that
indeed RTL treats PLUS/MINUS as wrapping.  I remember seeing more but
my memory must be at fault.  Since it's so limited, the one occurrence
that is there should be removed.

>> ?If you're going for a rewrite, I'd do it on tree-SSA so that:
>>
>> 1) you can use unsigned math to avoid undefined overflow;
>>
>> 2) SSA will provide you with cheap DU/UD.
>>
>> Hopefully, only simple redundancies will remain after expand, and fwprop
>> can take care of these using Andrew's patch.
>
> I see your point about the cheap DU/UD. I think the answer whether to do it in
> tree-SSA or RTL depends on the answer to my previous question. If going to
> tree-SSA allows us to catch more cases, we should do that.

If you can fix the performance issues that Eric has without a rewrite,
and if it's not quadratic, I would have no problem at all with RTL.

If you need a rewrite, tree-SSA could be a better match if only for
DU/UD and ability to use the propagation engine.  The only thing I'd
be wary of, is vectorization failures because of the more complex
trees.  (But then it may even turn out to _improve_ vectorization.

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]