This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC][PR target/39726 P4 regression] match.pd pattern to do type narrowing
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 11 Feb 2015 17:13:43 +0000
- Subject: Re: [RFC][PR target/39726 P4 regression] match.pd pattern to do type narrowing
- Authentication-results: sourceware.org; auth=none
- References: <54CC560B dot 8080200 at redhat dot com> <alpine dot DEB dot 2 dot 10 dot 1502010039210 dot 23456 at digraph dot polyomino dot org dot uk> <54CDBDC6 dot 3050000 at redhat dot com> <alpine dot DEB dot 2 dot 10 dot 1502021655230 dot 20528 at digraph dot polyomino dot org dot uk> <54CFBC2E dot 2040602 at redhat dot com> <54D076BC dot 9080504 at redhat dot com> <alpine dot DEB dot 2 dot 10 dot 1502031204440 dot 11494 at digraph dot polyomino dot org dot uk> <54DAFA05 dot 5050804 at redhat dot com>
On Tue, 10 Feb 2015, Jeff Law wrote:
> I think the way to go is to always convert the inner operands to an unsigned
> type. In fact, everything except the outer convert should be using an
> unsigned type of the same size/precision as @0's type. The outer convert
> should, of course, be the final type.
>
> That avoids all the concerns about sign bit propagation from the narrow type
> into the wider final type.
Subject of course to allowing for the cases where the original expression
uses sign-extension (signed narrow type), the mask is consistent with this
(sign bit of narrow type and all higher bits set, e.g. -128), and the
operation is bitwise not arithmetic, if you want to optimize those as
well.
--
Joseph S. Myers
joseph@codesourcery.com