From patchwork Mon May 13 16:39:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 243441 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 "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B4BE32C008A for ; Tue, 14 May 2013 02:40:24 +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:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=QtRmH4KGNcWOzuMrCPADV3yU54JEd eohy9p/UFx+EQ9saxq16ZxGxVN/FO9cv0YkwGSjQ6XpG2whB72isir0p6XiGTgOO PFhqopY03vAvgWcewnkPkvJvHhzYhdU2pRtxGwE6fFFmnb8Y0dIShq9KhiUIARyk 6X5kTdYmLxXVdY= 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:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=gnBfj581/IzcRCxhMiwvd0e3LiQ=; b=A/m 6acGSrpfXhiWsKN3OCyCyDHl5IU20TFJjH/YIdydnhvR89WT7bFz4JJ28lIlVqHb g1UCI54hnKGss5mUoEuyMFpIitnCd9/fcVNmZQyhHYcZo3q0MBrYFyv4t7MibYOI Ugx0kgI9/eOhXw4o2NLB4ZFwQQgj8BoNLMb8N5ZU= Received: (qmail 19083 invoked by alias); 13 May 2013 16:40:19 -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 19074 invoked by uid 89); 13 May 2013 16:40:18 -0000 X-Spam-SWARE-Status: No, score=-6.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 13 May 2013 16:40:18 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4DGeBMt023553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 May 2013 12:40:14 -0400 Received: from zalov.cz (vpn-60-18.rdu2.redhat.com [10.10.60.18]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4DGe1l4006048 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 13 May 2013 12:40:06 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r4DGe04i008430; Mon, 13 May 2013 18:40:00 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r4DGdwI6008429; Mon, 13 May 2013 18:39:58 +0200 Date: Mon, 13 May 2013 18:39:57 +0200 From: Jakub Jelinek To: Eric Botcazou , Richard Henderson Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix up WIDEN_MULT_EXPR (PR middle-end/57251) Message-ID: <20130513163957.GA1377@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi! On the following testcase, the widen multiplies etc. is introduced so late that no forwprop or ccp follows it. The WIDEN_MULT_EXPR tries hard not to use widening multiply if both arguments are INTEGER_CSTs, but if they are e.g. SSA_NAMEs that expand_normal into CONST_INT, we can still ICE. The following patch attempts to handle those cases. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.8? 2013-05-13 Jakub Jelinek PR middle-end/57251 * expr.c (expand_expr_real_2) : Handle the case when both op0 and op1 have VOIDmode. * gcc.dg/torture/pr57251.c: New test. Jakub --- gcc/expr.c.jj 2013-05-07 10:27:07.000000000 +0200 +++ gcc/expr.c 2013-05-13 12:01:49.339087536 +0200 @@ -8390,6 +8390,15 @@ expand_expr_real_2 (sepops ops, rtx targ else expand_operands (treeop0, treeop1, NULL_RTX, &op1, &op0, EXPAND_NORMAL); + /* op0 and op1 might still be constant, despite the above + != INTEGER_CST check. Handle it. */ + if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode) + { + op0 = convert_modes (innermode, mode, op0, true); + op1 = convert_modes (innermode, mode, op1, false); + return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1, + target, unsignedp)); + } goto binop3; } } @@ -8412,6 +8421,19 @@ expand_expr_real_2 (sepops ops, rtx targ { expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, EXPAND_NORMAL); + /* op0 and op1 might still be constant, despite the above + != INTEGER_CST check. Handle it. */ + if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode) + { + widen_mult_const: + op0 = convert_modes (innermode, mode, op0, zextend_p); + op1 + = convert_modes (innermode, mode, op1, + TYPE_UNSIGNED (TREE_TYPE (treeop1))); + return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1, + target, + unsignedp)); + } temp = expand_widening_mult (mode, op0, op1, target, unsignedp, this_optab); return REDUCE_BIT_FIELD (temp); @@ -8424,9 +8446,14 @@ expand_expr_real_2 (sepops ops, rtx targ op0 = expand_normal (treeop0); if (TREE_CODE (treeop1) == INTEGER_CST) op1 = convert_modes (innermode, mode, - expand_normal (treeop1), unsignedp); + expand_normal (treeop1), + TYPE_UNSIGNED (TREE_TYPE (treeop1))); else op1 = expand_normal (treeop1); + /* op0 and op1 might still be constant, despite the above + != INTEGER_CST check. Handle it. */ + if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode) + goto widen_mult_const; temp = expand_binop (mode, other_optab, op0, op1, target, unsignedp, OPTAB_LIB_WIDEN); hipart = gen_highpart (innermode, temp); --- gcc/testsuite/gcc.dg/torture/pr57251.c.jj 2013-05-13 11:46:34.937151578 +0200 +++ gcc/testsuite/gcc.dg/torture/pr57251.c 2013-05-13 11:54:23.070414122 +0200 @@ -0,0 +1,12 @@ +/* PR middle-end/57251 */ +/* { dg-do compile } */ +/* { dg-options "-ftracer" } */ + +short a, b; +int +f (void) +{ + long long i = 2; + a ? f () ? : 0 : b--; + b &= i *= a |= 0; +}