From patchwork Mon Sep 5 17:14:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 665937 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 3sSbv44rFNz9vF0 for ; Tue, 6 Sep 2016 03:14:40 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=GO1UwmeJ; 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=YeX+6orh251VvIYwFECIzzapXxWTT ztvnbCuS4E85oztjsUJ8dp5ixOvoBZekXjNW+thacTYcI+XnjDA+d/RsIYMQYI4s ytYbI0ZsGbVYBkQwdkcQAt6DAhMz4TLFjq3ZOM76Ulurb6V+1Zu7Y0NOkLtFrzJY 3lD1XbiGOvw4fg= 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=aeBooDG49x1+gfnOaTsQA79MT5s=; b=GO1 UwmeJCAOinw7e7mo8Zzcnfns2CV1cPahHyfRxBLsNockhb+GhhpTXk3j3AKrxMsv PAMTYq8YcfzLymIzvY/VzL/WSL0CQYvrbsnNho4BAZhw+p5RQvoJECbeu56y4PDb y55Lfb2o2fgSAutRACxs9LIzafUkb8Ga1FAqNF1s= Received: (qmail 65093 invoked by alias); 5 Sep 2016 17:14: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 65081 invoked by uid 89); 5 Sep 2016 17:14:31 -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, KAM_LAZY_DOMAIN_SECURITY, MEDICAL_SUBJECT, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 spammy=decl_mode, BLKmode, const0_rtx, *-*-* 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; Mon, 05 Sep 2016 17:14:30 +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 7EBE43B707; Mon, 5 Sep 2016 17:14:29 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-43.brq.redhat.com [10.40.204.43]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u85HERvS028894 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 5 Sep 2016 13:14:29 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u85HEQQF023138; Mon, 5 Sep 2016 19:14:27 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u85HEQYD023137; Mon, 5 Sep 2016 19:14:26 +0200 Date: Mon, 5 Sep 2016 19:14:26 +0200 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH, i386] Fix ICE with a md builtin call (PR target/69255) Message-ID: <20160905171426.GV14857@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! As the testcase shows, if we want to diagnose a md builtin not enabled in the current ISA, we call error and then return const0_rtx. That isn't a good choice if the result is BLKmode, which can happen for vector modes that aren't enabled in the current ISA. In that case, returning target is better. In the PR I've also mentioned DECL_MODE issues, but looking at expr.c, I see there: /* DECL_MODE might change when TYPE_MODE depends on attribute target settings for VECTOR_TYPE_P that might switch for the function. */ if (currently_expanding_to_rtl && code == VAR_DECL && MEM_P (decl_rtl) && VECTOR_TYPE_P (type) && exp && DECL_MODE (exp) != mode) decl_rtl = change_address (decl_rtl, TYPE_MODE (type), 0); else decl_rtl = copy_rtx (decl_rtl); so we should be fine. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-09-05 Jakub Jelinek PR target/69255 * config/i386/i386.c (ix86_expand_builtin): For builtin with unsupported or unknown ISA, return target if non-NULL, instead of const0_rtx. * gcc.target/i386/pr69255-1.c: New test. * gcc.target/i386/pr69255-2.c: New test. * gcc.target/i386/pr69255-3.c: New test. Jakub --- gcc/config/i386/i386.c.jj 2016-09-02 18:18:10.000000000 +0200 +++ gcc/config/i386/i386.c 2016-09-05 12:41:03.341382125 +0200 @@ -36107,7 +36107,7 @@ ix86_expand_builtin (tree exp, rtx targe error ("%qE needs isa option %s", fndecl, opts); free (opts); } - return const0_rtx; + return target ? target : const0_rtx; } switch (fcode) --- gcc/testsuite/gcc.target/i386/pr69255-1.c.jj 2016-09-05 12:50:29.455307440 +0200 +++ gcc/testsuite/gcc.target/i386/pr69255-1.c 2016-09-05 12:50:06.000000000 +0200 @@ -0,0 +1,16 @@ +/* PR target/69255 */ +/* { dg-do compile } */ +/* { dg-options "-mno-avx512f" } */ + +#pragma GCC target "avx512vl" +#pragma GCC target "no-avx512vl" +__attribute__ ((__vector_size__ (32))) long long a; +__attribute__ ((__vector_size__ (16))) int b; + +void +foo (const long long *p) +{ + a = __builtin_ia32_gather3siv4di (a, p, b, 1, 1); /* { dg-error "needs isa option -m32 -mavx512vl" } */ +} + +/* { dg-warning "AVX vector return without AVX enabled changes the ABI" "" { target *-*-* } 13 } */ --- gcc/testsuite/gcc.target/i386/pr69255-2.c.jj 2016-09-05 12:50:32.931264038 +0200 +++ gcc/testsuite/gcc.target/i386/pr69255-2.c 2016-09-05 12:49:57.000000000 +0200 @@ -0,0 +1,14 @@ +/* PR target/69255 */ +/* { dg-do compile } */ +/* { dg-options "-mno-avx512f" } */ + +#pragma GCC target "avx512vl" +#pragma GCC target "" +__attribute__ ((__vector_size__ (32))) long long a; +__attribute__ ((__vector_size__ (16))) int b; + +void +foo (const long long *p) +{ + __builtin_ia32_gather3siv4di (a, p, b, 1, 1); /* { dg-error "needs isa option -m32 -mavx512vl" } */ +} --- gcc/testsuite/gcc.target/i386/pr69255-3.c.jj 2016-09-05 12:50:35.951226330 +0200 +++ gcc/testsuite/gcc.target/i386/pr69255-3.c 2016-09-05 12:49:13.000000000 +0200 @@ -0,0 +1,16 @@ +/* PR target/69255 */ +/* { dg-do compile } */ +/* { dg-options "-mno-avx512f" } */ + +#pragma GCC target "avx512vl" +#pragma GCC target "" +__attribute__ ((__vector_size__ (32))) long long a; +__attribute__ ((__vector_size__ (16))) int b; + +void +foo (const long long *p, __attribute__ ((__vector_size__ (32))) long long *q) +{ + *q = __builtin_ia32_gather3siv4di (a, p, b, 1, 1); /* { dg-error "needs isa option -m32 -mavx512vl" } */ +} + +/* { dg-warning "AVX vector return without AVX enabled changes the ABI" "" { target *-*-* } 13 } */