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 target/53090] suboptimal ivopt
Date: Wed, 02 Apr 2014 11:50:00 -0000	[thread overview]
Message-ID: <bug-53090-4-Qa5d0yOzGF@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-53090-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #4)
> Sth like
> 
> Index: gcc/c-family/c-common.c
> ===================================================================
> --- gcc/c-family/c-common.c     (revision 209018)
> +++ gcc/c-family/c-common.c     (working copy)
> @@ -4415,19 +4415,21 @@ pointer_int_sum (location_t loc, enum tr
>  
>    /* Convert the integer argument to a type the same size as sizetype
>       so the multiply won't overflow spuriously.  */
> +  enum tree_code code = MULT_EXPR;
>    if (TYPE_PRECISION (TREE_TYPE (intop)) != TYPE_PRECISION (sizetype)
>        || TYPE_UNSIGNED (TREE_TYPE (intop)) != TYPE_UNSIGNED (sizetype))
> -    intop = convert (c_common_type_for_size (TYPE_PRECISION (sizetype),
> -                                            TYPE_UNSIGNED (sizetype)),
> intop);
> +    code = WIDEN_MULT_EXPR;
>  
>    /* Replace the integer argument with a suitable product by the object
> size.
>       Do this multiplication as signed, then convert to the appropriate type
>       for the pointer operation and disregard an overflow that occurred only
>       because of the sign-extension change in the latter conversion.  */
>    {
> -    tree t = build_binary_op (loc,
> -                             MULT_EXPR, intop,
> -                             convert (TREE_TYPE (intop), size_exp), 1);
> +    tree t = fold_build2_loc (loc, code,
> +                             c_common_type_for_size (TYPE_PRECISION
> (sizetype),
> +                                                     TYPE_UNSIGNED
> (sizetype)),
> +                             intop,
> +                             convert (TREE_TYPE (intop), size_exp));
>      intop = convert (sizetype, t);
>      if (TREE_OVERFLOW_P (intop) && !TREE_OVERFLOW (t))
>        intop = build_int_cst_wide (TREE_TYPE (intop), TREE_INT_CST_LOW
> (intop),
> 
> 
> but then you notice that for example SCEV doesn't handle WIDEN_MULT_EXPR.

But for example SCEV could be teached to _create_ the WIDEN_MULT_EXPRs
in the first place ... thus analyze for example _14 instead of as

(set_scalar_evolution
  instantiated_below = 4
  (scalar = _14)
  (scalar_evolution = {perm_9(D) + (sizetype) ((long unsigned int) j_5 * 4), +,
18446744073709551612}_1))

as

(set_scalar_evolution
  instantiated_below = 4
  (scalar = _14)
  (scalar_evolution = {perm_9(D) + (sizetype) (j_5 w* 4), +,
18446744073709551612}_1))


      parent reply	other threads:[~2014-04-02 11:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23 17:36 [Bug middle-end/53090] New: " xinliangli at gmail dot com
2012-04-23 17:38 ` [Bug middle-end/53090] " xinliangli at gmail dot com
2014-03-29 11:04 ` [Bug target/53090] " amker.cheng at gmail dot com
2014-04-02 11:17 ` rguenth at gcc dot gnu.org
2014-04-02 11:34 ` rguenth at gcc dot gnu.org
2014-04-02 11:50 ` rguenth at gcc dot gnu.org [this message]

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-53090-4-Qa5d0yOzGF@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).