[PATCH] Make CCP "complete"
Richard Guenther
rguenther@suse.de
Fri Aug 15 11:24:00 GMT 2008
On Thu, 14 Aug 2008, Eric Botcazou wrote:
> > 2008-08-12 Richard Guenther <rguenther@suse.de>
> >
> > * tree.h (maybe_fold_offset_to_address): Declare.
> > * tree-ssa-ccp.c (surely_varying_stmt_p): Fix typo in last commit.
> > (ccp_fold): Handle pointer conversions the same as fold_stmt.
> > Likewise for POINTER_PLUS_EXPR.
> > (maybe_fold_offset_to_reference): Enable disabled code.
> > (maybe_fold_offset_to_address): New function.
> > (fold_stmt_r): Use it.
> > (fold_gimple_assign): Likewise.
> > * gimplify.c (gimplify_conversion): Use maybe_fold_offset_to_address.
> > (gimplify_expr): Likewise.
>
> This breaks Ada, switch-c.adb:Scan_Front_End_Switches is miscompiled at -O0.
>
> String slicing doesn't work anymore, testcase attached, compile with -gnatp.
>
> We used to have in .gimple:
>
> D.2082 = s.P_ARRAY;
> D.2084 = &VIEW_CONVERT_EXPR<character[D.2040:D.2042]>(*D.2082)
> [first.8 ...]{lb: D.2081 sz: 1};
> D.2085 = (character[(long int) <PLACEHOLDER_EXPR struct
> string___XUP>.P_BOUNDS->LB0:(long int) <PLACEHOLDER_EXPR struct
> string___XUP>.P_BOUNDS->UB0] *) D.2084;
> D.2080.P_ARRAY = D.2085;
>
> Now we have:
>
> D.2081 = s.P_ARRAY;
> D.2080.P_ARRAY = D.2081;
I am testing the following.
Richard.
2008-08-15 Richard Guenther <rguenther@suse.de>
* tree-ssa-ccp.c (maybe_fold_offset_to_reference): Do not
strip components for unknown size accesses.
Index: gcc/tree-ssa-ccp.c
===================================================================
*** gcc/tree-ssa-ccp.c (revision 139097)
--- gcc/tree-ssa-ccp.c (working copy)
*************** maybe_fold_offset_to_reference (tree bas
*** 1976,1981 ****
--- 1976,1982 ----
&size, &maxsize);
gcc_assert (newbase);
if (size == maxsize
+ && size != -1
&& !(sub_offset & (BITS_PER_UNIT - 1)))
{
base = newbase;
More information about the Gcc-patches
mailing list