From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119551 invoked by alias); 12 Aug 2015 18:32:55 -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 119542 invoked by uid 89); 12 Aug 2015 18:32:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f178.google.com Received: from mail-wi0-f178.google.com (HELO mail-wi0-f178.google.com) (209.85.212.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 12 Aug 2015 18:32:50 +0000 Received: by wicne3 with SMTP id ne3so229659764wic.1 for ; Wed, 12 Aug 2015 11:32:47 -0700 (PDT) X-Received: by 10.194.78.230 with SMTP id e6mr70519262wjx.43.1439404367599; Wed, 12 Aug 2015 11:32:47 -0700 (PDT) Received: from android-4c5a376a18c0e957.fritz.box (p4FE9C1A6.dip0.t-ipconnect.de. [79.233.193.166]) by smtp.gmail.com with ESMTPSA id s1sm9512743wix.13.2015.08.12.11.32.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Aug 2015 11:32:47 -0700 (PDT) User-Agent: K-9 Mail for Android In-Reply-To: <55CB8B51.5080908@redhat.com> References: <55C33636.7020907@sfr.fr> <55CA51C4.3050601@redhat.com> <20150812110724.GB403@x4> <55CB4B40.6040902@sfr.fr> <55CB7C0C.7030203@redhat.com> <55CB8B51.5080908@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Subject: Re: [Patch] sext_hwi: Avoid left shift of negative value undefined behaviour From: Richard Biener Date: Wed, 12 Aug 2015 18:32:00 -0000 To: Jeff Law ,Mikael Morin ,Markus Trippelsdorf CC: gcc-patches Message-ID: <21C33A3D-9976-4632-ACCC-082F2D618ED5@gmail.com> X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00650.txt.bz2 On August 12, 2015 8:07:13 PM GMT+02:00, Jeff Law wrote: >On 08/12/2015 11:12 AM, Richard Biener wrote: > >> >> Prec is almost never a constant and is heavily used from wide-int. >> >> We are not exploiting this undefined ness in C so I object to making >this so much slower. >> >> Can we instead do what we do for abs_hwi and add a checking assert so >we can move the tests to the callers that misbehave instead? >Given that ISO C++ is moving away from making shifting 1 into the sign >bit undefined behaviour, maybe we should make UBSan less strict in its >warning. That may eliminate the need for Mikael's patch. We can also use an logical left shift followed by an arithmetic right shift. Or is the latter invoking undefined behaviour as well in some cases we hit? Richard. >jeff