From patchwork Sat Nov 20 19:03:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [middle-end] : Fix PR 43057, [LTO] fold check: original tree changed by fold Date: Sat, 20 Nov 2010 09:03:10 -0000 From: Uros Bizjak X-Patchwork-Id: 72358 Message-Id: To: gcc-patches@gcc.gnu.org Hello! Attached patch fixes PR 43057 by unsharing arg0 argument. 2010-11-20 Uros Bizjak PR middle-end/43057 * fold-const.c (fold_ternary_loc) : 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. 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. */