public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vekumar at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/64946] [AArch64] gcc.target/aarch64/vect-abs-compile.c - "abs" vectorization fails for char/short types
Date: Thu, 26 Feb 2015 16:42:00 -0000	[thread overview]
Message-ID: <bug-64946-4-IHCl0qnzvR@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-64946-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64946

--- Comment #9 from vekumar at gcc dot gnu.org ---
This match.pd pattern vectorizes the PR but works only with -fwrapv.

(simplify
 ( convert (abs (convert@1 @0)))
 ( if (INTEGRAL_TYPE_P (type)
      /* We check for type compatibility between @0 and @1 below,
         so there's no need to check that @1/@3 are integral types.  */
      && INTEGRAL_TYPE_P (TREE_TYPE (@0))
      && INTEGRAL_TYPE_P (TREE_TYPE (@1))
      /* The precision of the type of each operand must match the
         precision of the mode of each operand, similarly for the
         result.  */
      && (TYPE_PRECISION (TREE_TYPE (@0))
          == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (@0))))
      && (TYPE_PRECISION (TREE_TYPE (@1))
          == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (@1))))
      && TYPE_PRECISION (type) == GET_MODE_PRECISION (TYPE_MODE (type))
      /* The inner conversion must be a widening conversion.  */
      && TYPE_PRECISION (TREE_TYPE (@1)) > TYPE_PRECISION (TREE_TYPE (@0))
      && ((GENERIC
           && (TYPE_MAIN_VARIANT (TREE_TYPE (@0))
               == TYPE_MAIN_VARIANT (type)))
          || (GIMPLE
              && types_compatible_p (TREE_TYPE (@0), type))))
   (if (TYPE_OVERFLOW_WRAPS (TREE_TYPE (@0)))
    (abs @0))))

For default cases (when no -fwrapv is given), doing ABSE_EXPR(shorttype) will
invoke undefined behaviour when value is -32678. similarly for signed char min.

As per Richard suggestion we need to move to a new tree code ABSU_EXPR to do
this type of folding optimization.


  parent reply	other threads:[~2015-02-26 15:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-05 13:05 [Bug tree-optimization/64946] New: For Aarch64, vectorization with "abs" instruction is not hapenning with vector elements of char/short type vekumar at gcc dot gnu.org
2015-02-05 13:13 ` [Bug tree-optimization/64946] " vekumar at gcc dot gnu.org
2015-02-05 14:00 ` [Bug tree-optimization/64946] [AArch64] gcc.target/aarch64/vect-abs-compile.c - "abs" vectorization fails for char/short types jgreenhalgh at gcc dot gnu.org
2015-02-26  8:48 ` vekumar at gcc dot gnu.org
2015-02-26  9:09 ` pinskia at gcc dot gnu.org
2015-02-26  9:32 ` pinskia at gcc dot gnu.org
2015-02-26  9:43 ` vekumar at gcc dot gnu.org
2015-02-26  9:56 ` rguenther at suse dot de
2015-02-26 10:07 ` pinskia at gcc dot gnu.org
2015-02-26 16:42 ` vekumar at gcc dot gnu.org [this message]
2015-05-15 14:37 ` ramana at gcc dot gnu.org
2021-06-03  3:35 ` pinskia 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-64946-4-IHCl0qnzvR@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).