+2004-07-30 Richard Henderson <rth@redhat.com>
+
+ * gimplify.c (gimplify_expr) <case CONST_DECL>: Don't replace
+ with DECL_INITIAL if fb_lvalue.
+ * tree-gimple.c (is_gimple_id): Add CONST_DECL.
+ * tree-pretty-print.c (dump_decl_name): Dump unnamed CONST_DECL
+ with <Cxxx>.
+ * tree-ssa-ccp.c (maybe_fold_stmt_indirect): Fold CONST_DECL.
+
2004-07-30 Diego Novillo <dnovillo@redhat.com>
* tree-ssa-alias.c (compute_points_to_and_addr_escape): If a
+2004-07-30 Richard Henderson <rth@redhat.com>
+
+ * trans-expr.c (gfc_conv_expr_reference): Create a CONST_DECL
+ for TREE_CONSTANTs.
+
2004-07-25 Richard Henderson <rth@redhat.com>
* trans-decl.c (gfc_build_function_decl): Set DECL_ARTIFICIAL
gfc_conv_expr (se, expr);
/* Create a temporary var to hold the value. */
- var = gfc_create_var (TREE_TYPE (se->expr), NULL);
- gfc_add_modify_expr (&se->pre, var, se->expr);
+ if (TREE_CONSTANT (se->expr))
+ {
+ var = build_decl (CONST_DECL, NULL, TREE_TYPE (se->expr));
+ DECL_INITIAL (var) = se->expr;
+ pushdecl (var);
+ }
+ else
+ {
+ var = gfc_create_var (TREE_TYPE (se->expr), NULL);
+ gfc_add_modify_expr (&se->pre, var, se->expr);
+ }
gfc_add_block_to_block (&se->pre, &se->post);
/* Take the address of that value. */
break;
case CONST_DECL:
- *expr_p = DECL_INITIAL (*expr_p);
+ /* If we require an lvalue, such as for ADDR_EXPR, retain the
+ CONST_DECL node. Otherwise the decl is replacable by its
+ value. */
+ /* ??? Should be == fb_lvalue, but ADDR_EXPR passes fb_either. */
+ if (fallback & fb_lvalue)
+ ret = GS_ALL_DONE;
+ else
+ *expr_p = DECL_INITIAL (*expr_p);
break;
case DECL_EXPR:
+2004-07-30 Richard Henderson <rth@redhat.com>
+
+ * gfortran.fortran-torture/execute/intrinsic_rrspacing.f90: Fix
+ write to constant argument.
+ * gfortran.fortran-torture/execute/intrinsic_scale.f90: Likewise.
+
2004-07-30 Richard Henderson <rth@redhat.com>
* gfortran.fortran-torture/execute/intrinsic_nearest.f90: Disable
call test_real8(33.0_8)
call test_real8(-33.0_8)
end
-subroutine test_real4(x)
- real x,y
+subroutine test_real4(orig)
+ real x,y,orig
integer p
+ x = orig
p = 24
y = abs (x * 2.0 ** (- exponent (x))) * (2.0 ** p)
x = rrspacing(x)
if (abs (x - y) .gt. abs(x * 1e-6)) call abort
end
-subroutine test_real8(x)
- real*8 x,y,t
+subroutine test_real8(orig)
+ real*8 x,y,t,orig
integer p
+ x = orig
p = 53
y = abs (x * 2.0 ** (- exponent (x))) * (2.0 ** p)
x = rrspacing(x)
call test_real8 (33.0_8, -4)
call test_real8 (-33._8, 4)
end
-subroutine test_real4 (x, i)
- real x,y
+subroutine test_real4 (orig, i)
+ real x,y,orig
integer i
+ x = orig
y = x * (2.0 ** i)
x = scale (x, i)
if (abs (x - y) .gt. abs(x * 1e-6)) call abort
end
-subroutine test_real8 (x, i)
- real*8 x,y
+subroutine test_real8 (orig, i)
+ real*8 x,y,orig
integer i
+ x = orig
y = x * (2.0 ** i)
x = scale (x, i)
if (abs (x - y) .gt. abs(x * 1e-6)) call abort
return (is_gimple_variable (t)
|| TREE_CODE (t) == FUNCTION_DECL
|| TREE_CODE (t) == LABEL_DECL
+ || TREE_CODE (t) == CONST_DECL
/* Allow string constants, since they are addressable. */
|| TREE_CODE (t) == STRING_CST);
}
pp_printf (buffer, "<L" HOST_WIDE_INT_PRINT_DEC ">",
LABEL_DECL_UID (node));
else
- pp_printf (buffer, "<D%u>", DECL_UID (node));
+ {
+ char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
+ pp_printf (buffer, "<%c%u>", c, DECL_UID (node));
+ }
}
}
/* Strip the ADDR_EXPR. */
base = TREE_OPERAND (base, 0);
+ /* Fold away CONST_DECL to its value, if the type is scalar. */
+ if (TREE_CODE (base) == CONST_DECL
+ && is_gimple_min_invariant (DECL_INITIAL (base)))
+ return DECL_INITIAL (base);
+
/* Try folding *(&B+O) to B[X]. */
t = maybe_fold_offset_to_array_ref (base, offset, TREE_TYPE (expr));
if (t)