From patchwork Mon Jul 11 19:28:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 647040 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 3rpFWt2cXjz9s5w for ; Tue, 12 Jul 2016 05:28:58 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=P/GToUO0; dkim-atps=neutral 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=htZTNVWTiZDGNEADXxnsmoglF2kQa cdvI6nlXPc64Frk9pO3j2WsRv68Lqe1v0NTCQkLaB9p2UpKDMA6bYh0UgWk/YtJF gjHr+sfBH1Vp/OyUTmqYhBnbBztz4+jiWdWONWvEvLjXq0o7I/8CTzfuFq+jZG+x cB963n+XHiJOVs= 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=PNFYcAqp4pDJ+TUErj7LXV1oEqw=; b=P/G ToUO0EBVa+nVxj7tP4ja09bjxclDmoLhs0DNZocvfO+jH4Tgtp59hULm+rLDGrb1 KKNZZ7hifbYbw7QjrGFQuhBnjsY6OYsgvE6buALrVJwM65bs+3keqNN67W/rz0A3 O7kTEKhgmxM8RGz90mQpw5K6sfy0MGSkTUaeAtu0= Received: (qmail 122100 invoked by alias); 11 Jul 2016 19:28:51 -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 122090 invoked by uid 89); 11 Jul 2016 19:28:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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; Mon, 11 Jul 2016 19:28:49 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 602CEC04B31D; Mon, 11 Jul 2016 19:28:48 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-98.brq.redhat.com [10.40.204.98]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6BJSkWm012966 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 11 Jul 2016 15:28:47 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u6BJSico029340; Mon, 11 Jul 2016 21:28:45 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u6BJShQj029339; Mon, 11 Jul 2016 21:28:43 +0200 Date: Mon, 11 Jul 2016 21:28:43 +0200 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix SLP vectorization ICE (PR tree-optimization/71823) Message-ID: <20160711192843.GO7387@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi! vect_get_vec_defs handles only one or two arguments, for ternary ops like fma vectorizable_operation calls vect_get_vec_defs on the first two arguments, and then did vec_oprnds2.create (1); vec_oprnds2.quick_push (vect_get_vec_def_for_operand (op2, stmt)); which is what vect_get_vec_defs does, but only for loop vectorization. The following patch uses vect_get_vec_defs again so that it does what it did before for loop vectorization, but additionally handles properly slp vectorization. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/6.2? 2016-07-11 Jakub Jelinek PR tree-optimization/71823 * tree-vect-stmts.c (vectorizable_operation): Use vect_get_vec_defs to get vec_oprnds2 from op2. * gcc.dg/vect/pr71823.c: New test. Jakub --- gcc/tree-vect-stmts.c.jj 2016-07-07 20:40:43.000000000 +0200 +++ gcc/tree-vect-stmts.c 2016-07-11 12:05:52.501823209 +0200 @@ -5362,11 +5362,8 @@ vectorizable_operation (gimple *stmt, gi vect_get_vec_defs (op0, NULL_TREE, stmt, &vec_oprnds0, NULL, slp_node, -1); if (op_type == ternary_op) - { - vec_oprnds2.create (1); - vec_oprnds2.quick_push (vect_get_vec_def_for_operand (op2, - stmt)); - } + vect_get_vec_defs (op2, NULL_TREE, stmt, &vec_oprnds2, NULL, + slp_node, -1); } else { --- gcc/testsuite/gcc.dg/vect/pr71823.c.jj 2016-07-11 12:07:41.687485519 +0200 +++ gcc/testsuite/gcc.dg/vect/pr71823.c 2016-07-11 12:08:42.449741939 +0200 @@ -0,0 +1,14 @@ +/* PR tree-optimization/71823 */ +/* { dg-do compile } */ +/* { dg-additional-options "-mfma" { target i?86-*-* x86_64-*-* } } */ + +float a[4], b[4]; + +int +main () +{ + int i; + for (i = 0; i < 4; ++i) + b[i] = __builtin_fma (1024.0f, 1024.0f, a[i]); + return 0; +}