From patchwork Fri Aug 9 14:35:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 266046 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 ECFA82C008E for ; Sat, 10 Aug 2013 00:35:42 +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:mime-version:content-type; q=dns; s=default; b=JW3pa/MrpmHpsULNXlbE+jwtCm+VVL3OARs32e5DEQ09OYHLgT hmF8NuYA1FUq/qAEkgk0EfRRQcxkup8Yg4TKNXkJz1CxkiQ811bkF8M0kzDyZ32a H2ZpvYX2d2hAyfsG+sf4qmGQHmNX9Gr5Ff11ZneOTuTzfEw94tgST3bTI= 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:mime-version:content-type; s= default; bh=HMMQs3zCfiq/85fUjlw+lMDMFZs=; b=H99BECewp9WVzHVKY2/B zkmU6Efv7LyEEYSMGPcpcvE0bY3JgfcIzitL8klrqGhjI/L3TTLE9z1CoUiEa/qf TYK8EPMwif9LPhNjYUs54IHSv45kP5zZxvmztb3MW3dYWHz1FfziNwplCCcadZDA z1tMsxBjs/pRPMF19rHrWn8= Received: (qmail 26186 invoked by alias); 9 Aug 2013 14:35:32 -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 26155 invoked by uid 89); 9 Aug 2013 14:35:31 -0000 X-Spam-SWARE-Status: No, score=-5.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RDNS_NONE, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.1 Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 09 Aug 2013 14:35:30 +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 (8.14.4/8.14.4) with ESMTP id r79EZMLq002371 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 9 Aug 2013 10:35:23 -0400 Received: from redhat.com (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r79EZJRl001445 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 9 Aug 2013 10:35:21 -0400 Date: Fri, 9 Aug 2013 16:35:18 +0200 From: Marek Polacek To: GCC Patches Cc: Marc Glisse Subject: [PATCH] Fix PR57980 Message-ID: <20130809143518.GH17022@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) In this PR the problem was that when dealing with the gimple assign in the tailcall optimization, we, when the rhs operand is of a vector type, need to create -1 also of a vector type, but build_int_cst doesn't create vectors (ICEs). Instead, we should use build_minus_one_cst because that can create even the VECTOR_TYPE constant (and, it can create even REAL_TYPE/COMPLEX_TYPE), as suggested by Marc. Regtested/bootstrapped on x86_64-linux, ok for trunk and 4.8? 2013-08-09 Marek Polacek Marc Glisse PR tree-optimization/57980 * tree-tailcall.c (process_assignment): Call build_minus_one_cst when creating -1 constant. * gcc.dg/pr57980.c: New test. Marek --- gcc/tree-tailcall.c.mp 2013-08-09 16:07:55.778616996 +0200 +++ gcc/tree-tailcall.c 2013-08-09 16:08:00.068635823 +0200 @@ -326,11 +326,7 @@ process_assignment (gimple stmt, gimple_ return true; case NEGATE_EXPR: - if (FLOAT_TYPE_P (TREE_TYPE (op0))) - *m = build_real (TREE_TYPE (op0), dconstm1); - else - *m = build_int_cst (TREE_TYPE (op0), -1); - + *m = build_minus_one_cst (TREE_TYPE (op0)); *ass_var = dest; return true; @@ -339,11 +335,7 @@ process_assignment (gimple stmt, gimple_ *a = fold_build1 (NEGATE_EXPR, TREE_TYPE (non_ass_var), non_ass_var); else { - if (FLOAT_TYPE_P (TREE_TYPE (non_ass_var))) - *m = build_real (TREE_TYPE (non_ass_var), dconstm1); - else - *m = build_int_cst (TREE_TYPE (non_ass_var), -1); - + *m = build_minus_one_cst (TREE_TYPE (non_ass_var)); *a = fold_build1 (NEGATE_EXPR, TREE_TYPE (non_ass_var), non_ass_var); } --- gcc/testsuite/gcc.dg/pr57980.c.mp 2013-08-09 16:07:25.967485356 +0200 +++ gcc/testsuite/gcc.dg/pr57980.c 2013-08-09 16:07:17.967450526 +0200 @@ -0,0 +1,19 @@ +/* PR tree-optimization/57980 */ +/* { dg-do compile } */ +/* { dg-options "-O -foptimize-sibling-calls" } */ + +typedef int V __attribute__ ((vector_size (sizeof (int)))); +extern V f (void); + +V +bar (void) +{ + return -f (); +} + +V +foo (void) +{ + V v = { }; + return v - f (); +}