[patch tree-optimization]: Try to do type sinking on comparisons

Richard Guenther richard.guenther@gmail.com
Tue Jun 28 09:18:00 GMT 2011


On Mon, Jun 27, 2011 at 8:52 PM, Kai Tietz <ktietz@redhat.com> wrote:
> Hello,
>
> this patch tries to sink conversions for comparisons patterns:
> a) (type) X cmp (type) Y => x cmp y.
> b) (type) X cmp CST => x cmp ((type-x) CST).
> c) CST cmp (type) X => ((type-x) CST) cmp x.
>
> This patch just allows type sinking for the case that type-precision of type is wider or equal to type-precision of type-x. Or if type and type-x have same signess and CST fits into type-x. For cmp operation is == or !=, we allow also that type and type-x have different signess, as long as CST fits into type-x without truncation.
>
> ChangeLog
>
> 2011-06-27  Kai Tietz  <ktietz@redhat.com>
>
>        * tree-ssa-forwprop.c (forward_propagate_into_comparision):
>        Sink types within comparison operands, if suitable.
>
> Bootstrapped and regression tested for x86_64-pc-linux-gnu. Ok for apply?

Hmm, why does fold_widened_comparison and fold_sign_changed_comparison
not handle these cases?  We already dispatch to fold in this function,
so this is a case where we'd want fold to be improved.  You didn't add
testcases - do you have some that are not handled by fold already?

Thanks,
Richard.

> Regards,
> Kai
>



More information about the Gcc-patches mailing list