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/50955] [4.7 Regression] IVopts incorrectly rewrite the address of a global memory access into a local form.
Date: Wed, 02 Nov 2011 13:10:00 -0000	[thread overview]
Message-ID: <bug-50955-4-bppe7jDa0O@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-50955-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50955

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-11-02 13:09:40 UTC ---
It looks like IVOPTs fails to consider a candidate for the use inquestion
and thus, after choosing the final IV set ends up rewriting that use into
this stupid form (instead of using candidate 0).  The use is

use 3
  generic
  in statement vect_p.60_223 = PHI <vect_p.60_224(16), vect_p.63_222(5)>

  at position
  type vector(8) unsigned char *
  base batmp.61_221 + 1
  step 8
  base object (void *) batmp.61_221
  is a biv
  related candidates

but costs say:

Use 3:
  cand  cost    compl.  depends on
  0     8       1        inv_expr:0
  1     4       1        inv_expr:1
  2     4       1        inv_expr:0
  3     4       1        inv_expr:1
  4     4       1        inv_expr:2

Initial set of candidates:
  cost: 24 (complexity 4)
  cand_cost: 10
  cand_use_cost: 10 (complexity 4)
  candidates: 0, 4
   use:0 --> iv_cand:4, cost=(2,1)
   use:1 --> iv_cand:4, cost=(2,1)
   use:2 --> iv_cand:4, cost=(2,1)
   use:3 --> iv_cand:4, cost=(4,1)
   use:4 --> iv_cand:0, cost=(0,0)
  invariants 7

Selected IV set:
candidate 0 (important)
  var_before ivtmp.107_150
  var_after ivtmp.107_256
  incremented before exit test
  type unsigned int
  base 0
  step 1
candidate 4 (important)
  var_before ivtmp.110_241
  var_after ivtmp.110_146
  incremented before exit test
  type unsigned int
  base (unsigned int) (&p1 + 8)
  step 8
  base object (void *) &p1

so expressing use 3 with candidate 4 is cheaper than with candidate 0...

Now, for address-uses we have

  if (address_p)
    {
      /* Do not try to express address of an object with computation based
         on address of a different object.  This may cause problems in rtl
         level alias analysis (that does not expect this to be happening,
         as this is illegal in C), and would be unlikely to be useful
         anyway.  */
      if (use->iv->base_object
          && cand->iv->base_object
          && !operand_equal_p (use->iv->base_object, cand->iv->base_object, 0))
        return infinite_cost;

in cost calculation, but in this case it's a nonlinear use, and we have

(gdb) call debug_generic_expr (use->iv->base_object)
(void *) batmp.61_221
(gdb) call debug_generic_expr (cand->iv->base_object)
(void *) &p1


  parent reply	other threads:[~2011-11-02 13:10 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-02  5:12 [Bug tree-optimization/50955] New: " duyuehai at gmail dot com
2011-11-02  5:19 ` [Bug tree-optimization/50955] " duyuehai at gmail dot com
2011-11-02  9:42 ` [Bug tree-optimization/50955] [4.7 Regression] " rguenth at gcc dot gnu.org
2011-11-02 12:50 ` rguenth at gcc dot gnu.org
2011-11-02 13:10 ` rguenth at gcc dot gnu.org [this message]
2011-11-02 13:33 ` rguenth at gcc dot gnu.org
2011-11-03  6:25 ` duyuehai at gmail dot com
2011-11-03  7:52 ` rguenther at suse dot de
2011-11-03  8:07 ` rakdver at kam dot mff.cuni.cz
2011-11-03  8:19 ` rguenth at gcc dot gnu.org
2011-12-06 13:56 ` rguenth at gcc dot gnu.org
2012-01-31 10:51 ` rguenth at gcc dot gnu.org
2012-01-31 14:24 ` rguenth at gcc dot gnu.org
2012-02-06 13:43 ` rguenth at gcc dot gnu.org
2012-02-06 13:44 ` rguenth at gcc dot gnu.org
2013-08-16  4:19 ` pinskia at gcc dot gnu.org
2013-08-16  7:02 ` pinskia at gcc dot gnu.org
2013-08-28  8:33 ` rguenther at suse dot de
2013-12-18  9:42 ` rguenther at suse dot de
2013-12-18 10:24 ` amker.cheng at gmail dot com
2013-12-19  9:57 ` rguenth at gcc dot gnu.org
2015-08-28  9:16 ` amker 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-50955-4-bppe7jDa0O@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: link
Be 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).