2011/5/15 Eric Botcazou <[email protected]>:
>> Well, I mean by artificial here, that gimplification is done via
>> gimplify_expr API. As FE and ME have here different assumptions. The
>> ME uses internally most boolean_type_node and IMHO it should be the
>> variant used there. As this conversation to a single boolean_type
>> (with recast to result FE's boolean type on demand) has some
>> advantages on optimization passes. Additionally it simplifies logic
>> in passes on types. For example there are some expressions, which are
>> in general unexpected in ME as they are transformed in gimplification
>> (like TRUTH_ANDIF/ORIF_EXPR). By adding tree manual, you might cause
>> the same issue as for the logical-expression showing up now.
>
> OK, then that's definitely not the case for Ada, so the comment is incorrect.
Yes, I will adjust comment here about ADA. Code for ADA looks sane.
Just one nit I saw in trans.c, which might be a cause here.
>> Well, this patch might be an alternative, but I see here potential
>> issues in such none-gimplified expressions for comparision and logical
>> not, which not necessariily have BOOLEAN_TYPE. See here the code for
>> fold_truth_not (and some other places) in fold-const. So I think, as
>> long as we have here external gimplication it is more save to check
>> just for integral-kind.
>
> Note that, even without "external gimplication", we still have integral types
> down to the tree-cfg.c check. Take ACATS c52103x at -O0. The Ada FE hands
> over a valid TRUTH_AND_EXPR, i.e. (BOOLEAN_TYPE, BOOLEAN_TYPE, BOOLEAN_TYPE)
> but the gimplifier builds a (BOOLEAN_TYPE, INTEGER_TYPE, BOOLEAN_TYPE) as it
> strips, then adds, then re-strips a cast to BOOLEAN_TYPE in gimplify_expr.
With this patch (which would describe why it gimplifier sees
integer-type nodes here):
Index: gcc/gcc/ada/gcc-interface/trans.c
===================================================================
--- gcc.orig/gcc/ada/gcc-interface/trans.c 2011-05-12
20:06:01.000000000 +0200
+++ gcc/gcc/ada/gcc-interface/trans.c 2011-05-15 15:33:32.305516200 +0200
@@ -7101,7 +7110,7 @@ convert_with_check (Entity_Id gnat_type,
{
/* Ensure GNU_EXPR only gets evaluated once. */
tree gnu_input = gnat_protect_expr (gnu_result);
- tree gnu_cond = integer_zero_node;
+ tree gnu_cond = boolean_false_node;
tree gnu_in_lb = TYPE_MIN_VALUE (gnu_in_basetype);
tree gnu_in_ub = TYPE_MAX_VALUE (gnu_in_basetype);
tree gnu_out_lb = TYPE_MIN_VALUE (gnu_base_type);
I was able to do a bootstrap for ada and run 'make check-ada' without
seeing gimplification errors.
The only failure I see in testrun is 'cxg2001.adb' test with 'GCC
error: in compensate_edge, at reg-stach.c:2781' Error detect around
cxg2001.adb:322:5. But well, this bug seems to me unrelated here to
gimplication. But maybe I am wrong here.
Regards,
Kai