From patchwork Fri Aug 30 11:44:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 271240 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 5EC062C00BC for ; Fri, 30 Aug 2013 21:45:01 +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 :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=ucSx9Ni5NneTcvsWEL6wIDGavhGj14npWCMJK24nniOBsob4jqR9c RB37Q913SmzL8PLRfhPr+78A7ZgTBtkz4/slVWL9XUJZuTzXqM/nOEJ1tw66hlI3 5w8b17x7HR+Sc6MTo+ojgTx41W3qCUS2g70WVor3dwNQisFhi7ugnU= 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 :from:to:subject:message-id:mime-version:content-type; s= default; bh=zedJb441YL44fF4mCpBHE6RZ+9o=; b=AhCzdWXqjVE7cuoqmV2V OCk0iwXOhF7eBT5LHM0+00kYFx3aRmy5/FWC3aFEVIcf5lguRTfGXgvV4QZc4ZeK oBMNrQyGpLgp22U3b6qFopBBUU5vcDr4cT0ihBKBUQIsbeMA/10nAFJfeD5FHIjr k5KKiUE+O6Ys1k52ryg/VMo= Received: (qmail 3585 invoked by alias); 30 Aug 2013 11:44:55 -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 3576 invoked by uid 89); 30 Aug 2013 11:44:54 -0000 Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 30 Aug 2013 11:44:54 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RDNS_NONE autolearn=no version=3.3.2 X-HELO: mx2.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 892A2A52BF for ; Fri, 30 Aug 2013 13:44:52 +0200 (CEST) Date: Fri, 30 Aug 2013 13:44:51 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix overflow test in fold_single_bit_test Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 As noted by Kenny and Joern. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2013-08-30 Richard Biener * fold-const.c (fold_single_bit_test): Fix overflow test. Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 202100) +++ gcc/fold-const.c (working copy) @@ -6634,10 +6634,10 @@ fold_single_bit_test (location_t loc, en not overflow, adjust BITNUM and INNER. */ if (TREE_CODE (inner) == RSHIFT_EXPR && TREE_CODE (TREE_OPERAND (inner, 1)) == INTEGER_CST - && TREE_INT_CST_HIGH (TREE_OPERAND (inner, 1)) == 0 + && host_integerp (TREE_OPERAND (inner, 1), 1) && bitnum < TYPE_PRECISION (type) - && 0 > compare_tree_int (TREE_OPERAND (inner, 1), - bitnum - TYPE_PRECISION (type))) + && (TREE_INT_CST_LOW (TREE_OPERAND (inner, 1)) + < (unsigned) (TYPE_PRECISION (type) - bitnum))) { bitnum += TREE_INT_CST_LOW (TREE_OPERAND (inner, 1)); inner = TREE_OPERAND (inner, 0);