From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96177 invoked by alias); 23 Nov 2017 21:02:35 -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 96158 invoked by uid 89); 23 Nov 2017 21:02:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KB_WAM_FROM_NAME_SINGLEWORD,SPF_HELO_PASS,T_RP_MATCHES_RCVD 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 ESMTP; Thu, 23 Nov 2017 21:02:33 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 527EFC056827; Thu, 23 Nov 2017 21:02:32 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-247.ams2.redhat.com [10.36.116.247]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D64D960BF3; Thu, 23 Nov 2017 21:02:31 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id vANL2S3Y001822; Thu, 23 Nov 2017 22:02:29 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id vANL2OU1001821; Thu, 23 Nov 2017 22:02:24 +0100 Date: Thu, 23 Nov 2017 21:22:00 -0000 From: Jakub Jelinek To: Segher Boessenkool , David Edelsohn , Will Schmidt Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix powerpc* ICE with vec builtins with -mno-altivec (PR target/82848) Message-ID: <20171123210224.GV14653@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2017-11/txt/msg02168.txt.bz2 Hi! With -mno-altivec -mno-vsx -mno-fold-gimple we error on __builtin_vec* builtins used when corresponding ISA is not enabled. When folding gimple, in some cases we get away with it (e.g. when folding the builtin to PLUS_EXPR on the generic vectors), because tree-vect-generic.c lowers those into scalar piecewise operations, but e.g. in case of FMA_EXPR tree-vect-generic.c isn't doing anything, expects that FMA_EXPR is actually used only if supported, I think similarly for various vector widening operations etc. One option is not to fold into gimple only those builtins where we know it will not work on generic vectors; my preference is to not fold any builtin which would be rejected at expansion time, so user get at least consistent diagnostics. Usually people are using the altivec.h etc. headers that error if the ISA is not enabled, so this will only affect people that use the builtins directly. Bootstrapped/regtested on powerpc64{,le}-linux, ok for trunk? 2017-11-23 Jakub Jelinek PR target/82848 * config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Don't fold builtins not enabled in the currently selected ISA. --- gcc/config/rs6000/rs6000.c.jj 2017-11-23 10:29:01.000000000 +0100 +++ gcc/config/rs6000/rs6000.c 2017-11-23 10:30:54.930019590 +0100 @@ -16143,6 +16143,12 @@ rs6000_gimple_fold_builtin (gimple_stmt_ if (!gimple_call_lhs (stmt) && !rs6000_builtin_valid_without_lhs (fn_code)) return false; + /* Don't fold invalid builtins, let rs6000_expand_builtin diagnose it. */ + HOST_WIDE_INT mask = rs6000_builtin_info[uns_fncode].mask; + bool func_valid_p = (rs6000_builtin_mask & mask) == mask; + if (!func_valid_p) + return false; + switch (fn_code) { /* Flavors of vec_add. We deliberately don't expand --- gcc/testsuite/gcc.target/powerpc/pr82848.c.jj 2017-11-23 10:34:14.670471607 +0100 +++ gcc/testsuite/gcc.target/powerpc/pr82848.c 2017-11-23 10:36:22.754841465 +0100 @@ -0,0 +1,13 @@ +/* PR target/82848 */ +/* { dg-do compile } */ +/* { dg-options "-mno-altivec -mno-vsx -Wno-psabi" } */ + +#define C 3.68249351546114573519399405666776E-44f +#define vector __attribute__ ((altivec (vector__))) + +vector float +foo (vector float a) +{ + vector float b = __builtin_vec_madd (b, a, (vector float) { C, C, C, C }); /* { dg-error "requires the '-maltivec' option" } */ + return b; +} Jakub