------- Comment #5 from rguenth at gcc dot gnu dot org  2007-01-31 23:24 -------
negate_expr_p says it can negate -4 (which has the overflow flag set), but
negate_expr refuses to, because of the overflow flag.

We get there from

#69 0x080d1145 in gfc_conv_loop_setup (loop=0xbf9d6b4c)
    at /home/richard/src/trunk/gcc/fortran/trans-array.c:3219
3219              tmp = fold_build2 (TRUNC_DIV_EXPR, gfc_array_index_type,
(gdb) list
3214                 with start = 0, this simplifies to
3215                 last = end / step;
3216                 for (i = 0; i<=last; i++){...};  */
3217              tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
3218                                 loop->to[n], loop->from[n]);
3219              tmp = fold_build2 (TRUNC_DIV_EXPR, gfc_array_index_type,
3220                                 tmp, info->stride[n]);
3221              loop->to[n] = gfc_evaluate_now (tmp, &loop->pre);
3222              /* Make the loop variable start at 0.  */
3223              loop->from[n] = gfc_index_zero_node;
(gdb) call debug_tree (tmp)
 <plus_expr 0xb7c48f0c
    type <integer_type 0xb7be02d8 int4 public SI
        size <integer_cst 0xb7bd1330 constant invariant 32>
        unit size <integer_cst 0xb7bd1168 constant invariant 4>
        align 32 symtab 0 alias set -1 canonical type 0xb7be02d8 precision 32
min <integer_cst 0xb7bd12e8 -2147483648> max <integer_cst 0xb7bd1300
2147483647>
        pointer_to_this <pointer_type 0xb7be0d00>>

    arg 0 <minus_expr 0xb7c48ee8 type <integer_type 0xb7be02d8 int4>

        arg 0 <nop_expr 0xb7c44e60 type <integer_type 0xb7be02d8 int4>
            arg 0 <var_decl 0xb7bdcb00 n>>
        arg 1 <var_decl 0xb7c4b210 D.1106 type <integer_type 0xb7be02d8 int4>
            used ignored SI file
/Users/eschnett/Calpha/arrangements/LSUThorns/SummationByParts/src/Dissipation_4_3_min_err_coeff.F90
line 445 size <integer_cst 0xb7bd1330 32> unit size <integer_cst 0xb7bd1168 4>
            align 32 context <function_decl 0xb7c3c9a0 set_hmatrix>>>
    arg 1 <integer_cst 0xb7c477b0 type <integer_type 0xb7be02d8 int4> constant
invariant public overflow -4>>

which has the overflow flag already set, created from

3217              tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
3218                                 loop->to[n], loop->from[n]);

(gdb) call debug_generic_expr (loop->to[n])
(int4) ((<unnamed type>) n + 0x0fffffffc)
(gdb) call debug_generic_expr (loop->from[n])
D.1106

which we fold in reassociation where we finally end up calling
associate_trees with code == PLUS_EXPR
(gdb) call debug_generic_expr (t1)
(int4) n - D.1106
(gdb) call debug_generic_expr (t2)
0x0fffffffc

and returning via
1413          return build2 (code, type, fold_convert (type, t1),
1414                         fold_convert (type, t2));

will cause (int4)0x0fffffffc to have the overflow flag set.


-- 


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

Reply via email to