This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 06/15] rs6000: Use rldiwi in constant construction
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, David Edelsohn <dje dot gcc at gmail dot com>
- Date: Wed, 12 Aug 2015 21:43:46 -0500
- Subject: Re: [PATCH 06/15] rs6000: Use rldiwi in constant construction
- Authentication-results: sourceware.org; auth=none
- References: <1439341904-9345-1-git-send-email-rth at redhat dot com> <1439341904-9345-7-git-send-email-rth at redhat dot com> <20150812140251 dot GH4711 at gate dot crashing dot org> <55CB6C87 dot 2000802 at redhat dot com>
On Wed, Aug 12, 2015 at 08:55:51AM -0700, Richard Henderson wrote:
> On 08/12/2015 07:02 AM, Segher Boessenkool wrote:
> > On Tue, Aug 11, 2015 at 06:11:35PM -0700, Richard Henderson wrote:
> >> @@ -8173,6 +8173,13 @@ genimm_ppc::exam_search (HOST_WIDE_INT c, int budget)
> >> if (exam_mask (-1, c, sub_budget))
> >> return true;
> >>
> >> + /* If the two halves are equal, use an insert. */
> >> + if (c >> 32 == test && exam_sub (test, sub_budget))
> >> + {
> >> + opN (VEC_DUPLICATE, 0xffffffffu); /* RLDIMI */
> >> + return true;
> >> + }
> >
> > Does this work for c with the high bit set? I think you need
> > to cast it to unsigned HOST_WIDE_INT first?
>
> Indeed, a sign-extension works better. It means the base constant will use
> LIS+ORIS without trying to create an unsigned version.
Patch 8/15 changes this so that "test" is assigned the sign-extended low
32 bits right before this code; that should work just fine.
> If you're talking about ubsan sort of restrictions on shifting signed
> constants... I choose to totally ignore that.
Good plan. We rely on arithmetic shifts rounding towards negative
infinity, and so does the rest of the world.
> Certainly no where else in gcc
> has been audited for that, beginning with hwint.h itself.
Yes. And there are much worse problems, like many things not working
right if your HOST_WIDE_INT would happen to be more than 64 bits; we
cannot really shake those out because there is no actual system to
test that on -- but it also doesn't actually matter, because there is
no system to run it on :-)
Segher