public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/61010] [4.8/4.9/4.10 Regression] Infinite recursion in fold Date: Wed, 30 Apr 2014 10:43:00 -0000 [thread overview] Message-ID: <bug-61010-4-s3SGbAvnsP@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-61010-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61010 --- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- Like Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 209928) +++ gcc/fold-const.c (working copy) @@ -11426,7 +11426,6 @@ fold_binary_loc (location_t loc, { double_int c1, c2, c3, msk; int width = TYPE_PRECISION (type), w; - bool try_simplify = true; c1 = tree_to_double_int (TREE_OPERAND (arg0, 1)); c2 = tree_to_double_int (arg1); @@ -11463,20 +11462,7 @@ fold_binary_loc (location_t loc, } } - /* If X is a tree of the form (Y * K1) & K2, this might conflict - with that optimization from the BIT_AND_EXPR optimizations. - This could end up in an infinite recursion. */ - if (TREE_CODE (TREE_OPERAND (arg0, 0)) == MULT_EXPR - && TREE_CODE (TREE_OPERAND (TREE_OPERAND (arg0, 0), 1)) - == INTEGER_CST) - { - tree t = TREE_OPERAND (TREE_OPERAND (arg0, 0), 1); - double_int masked = mask_with_tz (type, c3, tree_to_double_int (t)); - - try_simplify = (masked != c1); - } - - if (try_simplify && c3 != c1) + if (c3 != c1) return fold_build2_loc (loc, BIT_IOR_EXPR, type, fold_build2_loc (loc, BIT_AND_EXPR, type, TREE_OPERAND (arg0, 0), @@ -11866,16 +11852,25 @@ fold_binary_loc (location_t loc, && TREE_CODE (arg0) == MULT_EXPR && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) { + double_int darg1 = tree_to_double_int (arg1); double_int masked - = mask_with_tz (type, tree_to_double_int (arg1), + = mask_with_tz (type, darg1, tree_to_double_int (TREE_OPERAND (arg0, 1))); if (masked.is_zero ()) return omit_two_operands_loc (loc, type, build_zero_cst (type), arg0, arg1); - else if (masked != tree_to_double_int (arg1)) - return fold_build2_loc (loc, code, type, op0, - double_int_to_tree (type, masked)); + else if (masked != darg1) + { + /* Avoid the transform if arg1 is a mask of some + mode which allows further optimizations. */ + int pop = darg1.popcount (); + if (!(pop >= BITS_PER_UNIT + && exact_log2 (pop) != -1 + && double_int::mask (pop) == darg1)) + return fold_build2_loc (loc, code, type, op0, + double_int_to_tree (type, masked)); + } } /* For constants M and N, if M == (1LL << cst) - 1 && (N & M) == M,
next prev parent reply other threads:[~2014-04-30 10:43 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-04-30 2:02 [Bug tree-optimization/61010] New: ICE in gcc.c ishiura-compiler at ml dot kwansei.ac.jp 2014-04-30 2:28 ` [Bug middle-end/61010] " pinskia at gcc dot gnu.org 2014-04-30 6:00 ` mpolacek at gcc dot gnu.org 2014-04-30 8:21 ` ktkachov at gcc dot gnu.org 2014-04-30 9:06 ` ktkachov at gcc dot gnu.org 2014-04-30 9:29 ` [Bug middle-end/61010] [4.8/4.9/4.10 Regression] Infinite recursion in fold rguenth at gcc dot gnu.org 2014-04-30 10:13 ` rguenth at gcc dot gnu.org 2014-04-30 10:18 ` rguenth at gcc dot gnu.org 2014-04-30 10:43 ` rguenth at gcc dot gnu.org 2014-04-30 10:43 ` rguenth at gcc dot gnu.org [this message] 2014-05-05 9:24 ` [Bug middle-end/61010] [4.8/4.9 " rguenth at gcc dot gnu.org 2014-05-05 9:24 ` rguenth at gcc dot gnu.org 2014-05-22 9:01 ` rguenth at gcc dot gnu.org 2014-05-28 12:47 ` [Bug middle-end/61010] [4.8 " rguenth at gcc dot gnu.org 2014-09-09 13:18 ` rguenth at gcc dot gnu.org 2014-09-09 13:18 ` rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-61010-4-s3SGbAvnsP@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).