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 tree-optimization/48031] [4.4/4.5 Regression] gcc.c-torture/compile/pr42956.c ICEs gcc on m68k-linux, ivopts related? Date: Thu, 10 Mar 2011 11:03:00 -0000 [thread overview] Message-ID: <bug-48031-4-8w9bSATazr@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-48031-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48031 Richard Guenther <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2011.03.10 11:02:33 CC| |ebotcazou at gcc dot | |gnu.org AssignedTo|unassigned at gcc dot |rguenth at gcc dot gnu.org |gnu.org | Ever Confirmed|0 |1 --- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-03-10 11:02:33 UTC --- First of all, confirmed with a cross. The issue seems to be with variable-length arrays: D.2079_96 = D.2025 /[ex] 2; D.2080_21 = &(*D.2050_128)[0]{lb: 0 sz: D.2079_96 * 2}.err; What happens is that we have an induction variable base of the form (unsigned int) &((struct Result *) D.2050_128)->err and end up folding the conversion to an array reference during gimplifying it here /* *(foo *)fooarrptr => (*fooarrptr)[0] */ if (TREE_CODE (TREE_TYPE (subtype)) == ARRAY_TYPE && type == TREE_TYPE (TREE_TYPE (subtype))) { tree type_domain; tree min_val = size_zero_node; sub = build_fold_indirect_ref_loc (loc, sub); type_domain = TYPE_DOMAIN (TREE_TYPE (sub)); if (type_domain && TYPE_MIN_VALUE (type_domain)) min_val = TYPE_MIN_VALUE (type_domain); return build4_loc (loc, ARRAY_REF, type, sub, min_val, NULL_TREE, NULL_TREE); } and then add a lower bound and step element in gimplify_compound_lval: if (!TREE_OPERAND (t, 3)) { tree elmt_type = TREE_TYPE (TREE_TYPE (TREE_OPERAND (t, 0))); tree elmt_size = unshare_expr (array_ref_element_size (t)); tree factor = size_int (TYPE_ALIGN_UNIT (elmt_type)); /* Divide the element size by the alignment of the element type (above). */ elmt_size = size_binop_loc (loc, EXACT_DIV_EXPR, elmt_size, factor); if (!is_gimple_min_invariant (elmt_size)) { TREE_OPERAND (t, 3) = elmt_size; tret = gimplify_expr (&TREE_OPERAND (t, 3), pre_p, post_p, is_gimple_reg, fb_rvalue); ret = MIN (ret, tret); } } A fix would be for example avoiding the folding for variable-sized element types. Another one would be to avoid putting in a operand 3 into the array-ref when the index is equal to the lower bound (but I'm not sure if that works, if the index is zero would probably work, but then a variant of the code might still ICE the same way). It's mixing VLA unaware foldings into the mids of GIMPLE which is the root of the issue though. The issue is latent on trunk. Patch for the first (and safe) idea: Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 170818) +++ gcc/fold-const.c (working copy) @@ -15554,7 +15560,8 @@ fold_indirect_ref_1 (location_t loc, tre } /* *(foo *)&fooarray => fooarray[0] */ else if (TREE_CODE (optype) == ARRAY_TYPE - && type == TREE_TYPE (optype)) + && type == TREE_TYPE (optype) + && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST) { tree type_domain = TYPE_DOMAIN (optype); tree min_val = size_zero_node; @@ -15633,7 +15640,8 @@ fold_indirect_ref_1 (location_t loc, tre /* *(foo *)fooarrptr => (*fooarrptr)[0] */ if (TREE_CODE (TREE_TYPE (subtype)) == ARRAY_TYPE - && type == TREE_TYPE (TREE_TYPE (subtype))) + && type == TREE_TYPE (TREE_TYPE (subtype)) + && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST) { tree type_domain; tree min_val = size_zero_node; Eric, can you see any issues with that and Ada?
next prev parent reply other threads:[~2011-03-10 11:03 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-03-08 10:01 [Bug target/48031] New: [4,4, 4.5 regression] " mikpe at it dot uu.se 2011-03-08 11:02 ` [Bug tree-optimization/48031] [4.4/4.5 Regression] " rguenth at gcc dot gnu.org 2011-03-08 14:23 ` mikpe at it dot uu.se 2011-03-08 21:40 ` mikpe at it dot uu.se 2011-03-09 9:22 ` rguenther at suse dot de 2011-03-09 23:37 ` mikpe at it dot uu.se 2011-03-10 9:22 ` mikpe at it dot uu.se 2011-03-10 9:34 ` rguenther at suse dot de 2011-03-10 11:03 ` rguenth at gcc dot gnu.org [this message] 2011-03-10 12:35 ` ebotcazou at gcc dot gnu.org 2011-03-10 12:36 ` rguenther at suse dot de 2011-03-10 12:46 ` ebotcazou at gcc dot gnu.org 2011-03-10 12:58 ` rguenther at suse dot de 2011-03-10 13:04 ` ebotcazou at gcc dot gnu.org 2011-03-10 13:07 ` rguenther at suse dot de 2011-03-10 13:10 ` rguenth at gcc dot gnu.org 2011-03-10 14:03 ` mikpe at it dot uu.se 2011-03-15 8:53 ` mikpe at it dot uu.se 2011-03-15 10:06 ` rguenth at gcc dot gnu.org 2011-03-28 10:22 ` rguenth at gcc dot gnu.org 2011-04-10 10:38 ` rguenth at gcc dot gnu.org 2011-04-16 11:18 ` jakub at gcc dot gnu.org 2011-04-18 14:15 ` [Bug tree-optimization/48031] [4.4 " rguenth at gcc dot gnu.org 2011-04-18 14:42 ` [Bug tree-optimization/48031] [4.4/4.5 " rguenth at gcc dot gnu.org 2011-04-18 14:55 ` [Bug tree-optimization/48031] [4.4 " rguenth at gcc dot gnu.org 2012-03-13 16:57 ` jakub 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-48031-4-8w9bSATazr@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).