From patchwork Wed Jun 11 21:35:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 358914 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B8F851400A7 for ; Thu, 12 Jun 2014 07:35:46 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:subject; q=dns; s=default; b=Yr0ILFcVLbznW2N NB5MqmYYMSD7WQDzYOzfNP7vF4zPhz3rYSYlQO/dSm/X+oXMsfqKV8+bNprvl3l0 1fbpGwLEM/VapCsAeXQzUggCWjoLrnyUD8SZEVQkv4CVz8h9v4EajB7hiXx8A/t0 7Sejaf9syvF81yAE89K6FjlVnPvw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:subject; s=default; bh=lIn18vJCXQCbg1MRUrjJL iBmWDM=; b=txTYc/A6y6cA8eN08TolPs4QYN+bLurFZXUyiBpiG4uMIr3ww8MDs u4U7h/zIfgvbHWPLgywK2Wk3oCuExTi+l1h65jFj7VWQ+q6w/gJcduGx1PCj0WUW VSNsScY6Ej1wqg39lEi3OwHlP36y3g779anboyFUmDE3Z4HXisdhxw= Received: (qmail 29203 invoked by alias); 11 Jun 2014 21:35:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 29193 invoked by uid 89); 11 Jun 2014 21:35:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Jun 2014 21:35:37 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5BLZatQ014079 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 11 Jun 2014 17:35:36 -0400 Received: from greed.delorie.com ([10.3.113.17]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5BLZZKg014867 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 11 Jun 2014 17:35:36 -0400 Received: from greed.delorie.com (greed.delorie.com [127.0.0.1]) by greed.delorie.com (8.14.4/8.14.4) with ESMTP id s5BLZYa8030282; Wed, 11 Jun 2014 17:35:34 -0400 Received: (from dj@localhost) by greed.delorie.com (8.14.4/8.14.4/Submit) id s5BLZYFj030281; Wed, 11 Jun 2014 17:35:34 -0400 Date: Wed, 11 Jun 2014 17:35:34 -0400 Message-Id: <201406112135.s5BLZYFj030281@greed.delorie.com> From: DJ Delorie To: gcc-patches@gcc.gnu.org Subject: fix math wrt volatile-bitfields vs C++ model X-IsSubscribed: yes If the combined bitfields are exactly the size of the mode, the logic for detecting range overflow is flawed - it calculates an ending "position" that's the position of the first bit in the next field. In the case of "short" for example, you get "16 > 15" without this patch (comparing size to position), and "15 > 15" with (comparing position to position). Ok to apply? * expmed.c (strict_volatile_bitfield_p): Fix off-by-one error. Index: expmed.c =================================================================== --- expmed.c (revision 211479) +++ expmed.c (working copy) @@ -472,13 +472,13 @@ strict_volatile_bitfield_p (rtx op0, uns && bitnum % GET_MODE_ALIGNMENT (fieldmode) + bitsize > modesize)) return false; /* Check for cases where the C++ memory model applies. */ if (bitregion_end != 0 && (bitnum - bitnum % modesize < bitregion_start - || bitnum - bitnum % modesize + modesize > bitregion_end)) + || bitnum - bitnum % modesize + modesize - 1 > bitregion_end)) return false; return true; } /* Return true if OP is a memory and if a bitfield of size BITSIZE at