On Tue, Aug 2, 2011 at 6:14 AM, Kai Tietz <ktiet...@googlemail.com> wrote:
> 2011/8/2 Richard Guenther <richard.guent...@gmail.com>:
>> On Tue, Aug 2, 2011 at 12:17 PM, Kai Tietz <ktiet...@googlemail.com> wrote:
>>> Hello,
>>>
>>> this patch removes in forward-propagation useless comparisons X != 0
>>> and X != ~0 for boolean-typed X.  For one-bit precision typed X we
>>> simplifiy X == 0 (and X != ~0) to ~X, and for X != 0 (and X == ~0) to
>>> X.
>>> For none one-bit precisione typed X, we simplify here X == 0 -> X ^ 1,
>>> and for X != 0 -> X.  We can do this as even for Ada - which has only
>>> boolean-type with none-one-bit precision - the truth-value is one.
>>
>> This isn't a simplification but a canonicalization and thus should be
>> done by fold_stmt instead (we are not propagating anything after all).
>> In fact, fold_stmt should do parts of this already by means of its
>> canonicalizations via fold.
>
> Well, it simplifies and canonicalizes.  But to put this into
> gimple-fold looks better.
>
>>> Additionally this patch changes for function
>>> forward_propagate_comparison the meaning of true-result.  As this
>>> result wasn't used and it is benefitial to use this propagation also
>>
>> which is a bug - for a true return value we need to set cfg_changed to true.
>
> I addressed this in my updated patch (see below)
>
>>> in second loop in function ssa_forward_propagate_and_combine, it
>>> returns true iff statement was altered.  Additionally this function
>>> handles now the boolean-typed simplifications.
>>
>> why call it twice?  How should that be "beneficial"?  I think that
>> forward_propagate_into_comparison should instead fold the changed
>> statement.
>
> Well, due missing fold_stmt call, there were still none-converted
> comparisons. I've added here the call to fold_stmt_inplace, and it
> solved the issue.
>
>>> For the hunk in gimple.c for function canonicalize_cond_expr_cond:
>>> This change seems to show no real effect, but IMHO it makes sense to
>>> add here the check for cast from boolean-type to be consitant.
>>
>> Probably yes.
>>
>> Thanks,
>> Richard.
>
>
> 2011-08-02  Kai Tietz  <kti...@redhat.com>
>
>       * gimple.c (canonicalize_cond_expr_cond): Handle cast from boolean-type.
>       (ssa_forward_propagate_and_combine): Interprete result of
>       forward_propagate_comparison.
>       * gcc/gimple-fold.c (fold_gimple_assign): Add canonicalization for
>       boolean-typed operands for comparisons.
>
> 2011-08-02  Kai Tietz  <kti...@redhat.com>
>
>        * gcc.dg/tree-ssa/forwprop-15.c: New testcase.
>
> Regression tested and bootstrapped for all languages (including Ada
> and Obj-C++).  Ok for apply?
>

It caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49947


-- 
H.J.

Reply via email to