From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79879 invoked by alias); 20 Nov 2015 19:58:19 -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 79864 invoked by uid 89); 20 Nov 2015 19:58:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_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 (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 20 Nov 2015 19:58:18 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 1C695C062C96; Fri, 20 Nov 2015 19:58:16 +0000 (UTC) Received: from [10.10.116.60] (ovpn-116-60.rdu2.redhat.com [10.10.116.60]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAKJwFBh017964; Fri, 20 Nov 2015 14:58:15 -0500 To: Richard Biener Cc: gcc-patches List , Ramana Radhakrishnan From: Jason Merrill Subject: RFA: PATCH to match.pd for c++/68385 Message-ID: <564F7B57.4060703@redhat.com> Date: Fri, 20 Nov 2015 19:58:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000206090201040700000501" X-SW-Source: 2015-11/txt/msg02531.txt.bz2 This is a multi-part message in MIME format. --------------000206090201040700000501 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 673 In this bug, we hit the (A & sign-bit) != 0 -> A < 0 transformation. Because of delayed folding, the operands aren't fully folded yet, so we have NOP_EXPRs around INTEGER_CSTs, and so calling wi::only_sign_bit_p ICEs. We've been seeing several similar bugs, where code calls integer_zerop and therefore assumes that they have an INTEGER_CST, but in fact integer_zerop does STRIP_NOPS. This patch changes the pattern to only match if the operand is actually an INTEGER_CST. Alternatively we could call tree_strip_nop_conversions on the operand, but I would expect that to have issues when the conversion changes the signedness of the type. OK if testing passes? --------------000206090201040700000501 Content-Type: text/x-patch; name="68385.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="68385.patch" Content-length: 778 commit e7b45ed6775c88c6d48c5863738ba0db2e38fc5e Author: Jason Merrill Date: Fri Nov 20 14:40:35 2015 -0500 PR c++/68385 * match.pd: Don't assume that integer_pow2p implies INTEGER_CST. diff --git a/gcc/match.pd b/gcc/match.pd index e86cc8b..1981ae7 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2232,6 +2232,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && (TYPE_PRECISION (TREE_TYPE (@0)) == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (@0)))) && element_precision (@2) >= element_precision (@0) + && TREE_CODE (@1) == INTEGER_CST && wi::only_sign_bit_p (@1, element_precision (@0))) (with { tree stype = signed_type_for (TREE_TYPE (@0)); } (ncmp (convert:stype @0) { build_zero_cst (stype); }))))) --------------000206090201040700000501--