Patchwork [middle-end] : Fix PR 43057, [LTO] fold check: original tree changed by fold

login
register
mail settings
Submitter Uros Bizjak
Date Nov. 20, 2010, 7:03 p.m.
Message ID <AANLkTinHQ=OmmyPAV6fpHiFAsOxtyn69nH1mU0-RYQOa@mail.gmail.com>
Download mbox | patch
Permalink /patch/72358/
State New
Headers show

Comments

Uros Bizjak - Nov. 20, 2010, 7:03 p.m.
Hello!

Attached patch fixes PR 43057 by unsharing arg0 argument.

2010-11-20  Uros Bizjak  <ubizjak@gmail.com>

	PR middle-end/43057
	* fold-const.c (fold_ternary_loc) <COND_EXPR>: Unshare arg0 when
	converting A ? 1 : 0 to A.

Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu
{,-m32}. FWIW, "--enable-checking=all" bootstrap is still running and
it already compiled up to stage-2 gcc/dse.o. I will leave the
bootstrap overnight to see if it breaks (it probably won't).

OK for mainline and 4.5?

Uros.
Richard Guenther - Nov. 21, 2010, 6:43 p.m.
On Sat, Nov 20, 2010 at 8:03 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> Hello!
>
> Attached patch fixes PR 43057 by unsharing arg0 argument.
>
> 2010-11-20  Uros Bizjak  <ubizjak@gmail.com>
>
>        PR middle-end/43057
>        * fold-const.c (fold_ternary_loc) <COND_EXPR>: Unshare arg0 when
>        converting A ? 1 : 0 to A.
>
> Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu
> {,-m32}. FWIW, "--enable-checking=all" bootstrap is still running and
> it already compiled up to stage-2 gcc/dse.o. I will leave the
> bootstrap overnight to see if it breaks (it probably won't).
>
> OK for mainline and 4.5?

Ok.

Thanks,
Richard.

> Uros.
>

Patch

Index: fold-const.c
===================================================================
--- fold-const.c	(revision 166974)
+++ fold-const.c	(working copy)
@@ -13415,7 +13415,7 @@  fold_ternary_loc (location_t loc, enum t
 	     a COND, which will recurse.  In that case, the COND_EXPR
 	     is probably the best choice, so leave it alone.  */
 	  && type == TREE_TYPE (arg0))
-	return pedantic_non_lvalue_loc (loc, arg0);
+	return pedantic_non_lvalue_loc (loc, unshare_expr (arg0));
 
       /* Convert A ? 0 : 1 to !A.  This prefers the use of NOT_EXPR
 	 over COND_EXPR in cases such as floating point comparisons.  */