From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21682 invoked by alias); 1 Feb 2015 00:47:22 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 21669 invoked by uid 89); 1 Feb 2015 00:47:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 01 Feb 2015 00:47:19 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YHih1-0005UL-Ra from joseph_myers@mentor.com ; Sat, 31 Jan 2015 16:47:16 -0800 Received: from digraph.polyomino.org.uk (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Sun, 1 Feb 2015 00:47:14 +0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.82) (envelope-from ) id 1YHigz-0006Iz-6W; Sun, 01 Feb 2015 00:47:13 +0000 Date: Sun, 01 Feb 2015 00:47:00 -0000 From: Joseph Myers To: Jeff Law CC: Subject: Re: [RFC][PR target/39726 P4 regression] match.pd pattern to do type narrowing In-Reply-To: <54CC560B.8080200@redhat.com> Message-ID: References: <54CC560B.8080200@redhat.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-SW-Source: 2015-02/txt/msg00001.txt.bz2 On Fri, 30 Jan 2015, Jeff Law wrote: > +/* If we are testing a single bit resulting from a binary > + operation in precision P1 where the operands were widened > + precision P2 and the tested bit is the sign bit for > + precision P2. Rewrite so the binary operation is in > + precision P2. */ To avoid introducing undefined behavior, if the operation is arithmetic rather than bitwise and the original type with precision P2 is signed then you need to convert the operands to the corresponding unsigned type. (I'm not sure how you avoid needing to convert the final result back to the original type of the expression to avoid type mismatches in the containing expression, but such a conversion back to the original type would need to be a zero-extension not a sign-extension and so for that I'd suppose the inner type should be unsigned even for bitwise operations. -- Joseph S. Myers joseph@codesourcery.com