public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Will Schmidt <will_schmidt@vnet.ibm.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
	       GCC Patches <gcc-patches@gcc.gnu.org>,
	       David Edelsohn <dje.gcc@gmail.com>,
	       Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Subject: Re: [PATCH, rs6000] Fold vector absolutes in GIMPLE
Date: Wed, 31 May 2017 14:02:00 -0000	[thread overview]
Message-ID: <1496239010.15163.194.camel@brimstone.rchland.ibm.com> (raw)
In-Reply-To: <CAFiYyc0zuReke-nrhq1aNMp1X33Avf6ttC+iAM6dyoOb4zt10Q@mail.gmail.com>

On Tue, 2017-05-30 at 09:00 +0200, Richard Biener wrote:
> On Mon, May 29, 2017 at 2:21 PM, Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> > On Mon, May 29, 2017 at 01:35:22PM +0200, Richard Biener wrote:
> >> >> What's the documented behavior for vec_abs with respect to an
> >> >argument
> >> >> of value INT_MIN?
> >> >
> >> >The documentation says:
> >> >
> >> >     "For integer vectors, the arithmetic is modular."
> >>
> >> This means that folding as ABS_EXPR is not safe for !TYPE_OVERFLOW_WRAPS
> >> Integral vector types.
> >
> > Is it still fine if TYPE_OVERFLOW_UNDEFINED?  So essentially always
> > except with -ftrapv?
> 
> The docs say it needs to wrap so the correct check is TYPE_OVERFLOW_WRAPS.
> It's not fine with TYPE_OVERFLOW_UNDEFINED as we will conclude the result
> can never be INT_MIN while the spec says it can.

Ok, thanks for the review.

So it looks like I should bail with something like: 
    ...
    case VSX_BUILTIN_XVABSDP:
      {
	arg0 = gimple_call_arg (stmt, 0);
	lhs = gimple_call_lhs (stmt);
	if (TYPE_OVERFLOW_WRAPS(TREE_TYPE(arg1))
	   return false;
	...

How can I test this scenario?  At a glance, a testcase snippet doesn't
appear to error out.  Am I quietly losing an overflow indicator?

vector signed int
test1_min (vector signed int x)
{
  vector signed int y = {INT_MIN,INT_MIN,INT_MIN,INT_MIN};
  return vec_abs (y);
}

generates gimple code:
  y = { -2147483648, -2147483648, -2147483648, -2147483648 };
  D.2579 = __builtin_altivec_abs_v4si (y);
or after folding:
  y = { -2147483648, -2147483648, -2147483648, -2147483648 };
  D.2579 = ABS_EXPR <y>;




> 
> Richard.
> 
> >
> >
> > Segher
> 


  reply	other threads:[~2017-05-31 13:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26 17:19 Will Schmidt
2017-05-29  8:39 ` Richard Biener
2017-05-29 10:29   ` Segher Boessenkool
2017-05-29 11:55     ` Richard Biener
2017-05-29 12:23       ` Segher Boessenkool
2017-05-30  7:05         ` Richard Biener
2017-05-31 14:02           ` Will Schmidt [this message]
2017-05-31 14:04             ` Richard Biener
2017-05-31 14:06               ` Ramana Radhakrishnan

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=1496239010.15163.194.camel@brimstone.rchland.ibm.com \
    --to=will_schmidt@vnet.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    --cc=segher@kernel.crashing.org \
    --cc=wschmidt@linux.vnet.ibm.com \
    /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).