From patchwork Mon Feb 12 21:53:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 872454 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-473116-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="pRmbGXYj"; dkim-atps=neutral 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 3zgLTS0ZvSz9t2x for ; Tue, 13 Feb 2018 09:49:47 +1100 (AEDT) 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=hp4G6SSYXRekOZAMBQzZbeP2NWZD9 6kCLh2PlqrmfGcKG7nW8ZiA/SPDfV7ObgRp8OOLIH/KpGuSrzxf11V7xZasgUl/d JHlvnqWeci8qXBzZRFOvuaMwqm/rRDJiKq8qTxvW9cQPteHgtqzuzdIBxQ4j6e9+ OOqi0VCtdOZSNk= 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=DJaIM2SRQw+HmuIzJvQw/h5h7wU=; b=pRm bGXYjPshDMVFqQ2kNklCA6fD1dQUzK+dgBZxPfDc58ij3PrMf7Ony7UZsBLYKh/q iujOvdpNQdPwfGdMcSKor2fqZfKZAcgC8Tq20flEKTh8aq2oOhBIGi76eW1C6YlI jDrt8ALE7Qmgoxi6rqVrV1klsYoU7Am2OcwoCg4U= Received: (qmail 76524 invoked by alias); 12 Feb 2018 22:49:30 -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 76498 invoked by uid 89); 12 Feb 2018 22:49:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Feb 2018 22:49:28 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18C2A40201A0 for ; Mon, 12 Feb 2018 22:49:23 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-85.brq.redhat.com [10.40.204.85]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB672100857A for ; Mon, 12 Feb 2018 22:49:22 +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 w1CLruUE001187; Mon, 12 Feb 2018 22:53:56 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w1CLrtEJ001186; Mon, 12 Feb 2018 22:53:55 +0100 Date: Mon, 12 Feb 2018 22:53:55 +0100 From: Jakub Jelinek To: Uros Bizjak , Kirill Yukhin Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix ISA masks for wmmintrin.h builtins (PR target/84335) Message-ID: <20180212215355.GK5867@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) X-IsSubscribed: yes Hi! While the documentation only mentions AES resp. PCLMUL CPUIDs for these intrinsics, they use and return V2DImode vectors and V2DImode is only in VALID_SSE2_REG_MODE and VALID_AVX512VL_128_REG_MODE, so without -msse2 we can't create registers with that mode. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? This isn't really backportable to older branches, unless r256281 is backported too. 2018-02-12 Jakub Jelinek PR target/84335 * config/i386/i386.c (ix86_init_mmx_sse_builtins): Pass OPTION_MASK_ISA_AES | OPTION_MASK_ISA_SSE2 instead of OPTION_MASK_ISA_AES as first argument to def_builtin_const for AES builtins. Pass OPTION_MASK_ISA_PCLMUL | OPTION_MASK_ISA_SSE2 instead of OPTION_MASK_ISA_PCLMUL as first argument to def_builtin_const for __builtin_ia32_pclmulqdq128 builtin. * config/i386/wmmintrin.h: If __SSE2__ is not defined, enable it temporarily for AES and PCLMUL builtins. * gcc.target/i386/pr84335.c: New test. Jakub --- gcc/config/i386/i386.c.jj 2018-02-09 06:44:38.737804246 +0100 +++ gcc/config/i386/i386.c 2018-02-12 16:29:11.731233919 +0100 @@ -31282,21 +31282,28 @@ ix86_init_mmx_sse_builtins (void) VOID_FTYPE_UNSIGNED_UNSIGNED, IX86_BUILTIN_MWAIT); /* AES */ - def_builtin_const (OPTION_MASK_ISA_AES, "__builtin_ia32_aesenc128", + def_builtin_const (OPTION_MASK_ISA_AES | OPTION_MASK_ISA_SSE2, + "__builtin_ia32_aesenc128", V2DI_FTYPE_V2DI_V2DI, IX86_BUILTIN_AESENC128); - def_builtin_const (OPTION_MASK_ISA_AES, "__builtin_ia32_aesenclast128", + def_builtin_const (OPTION_MASK_ISA_AES | OPTION_MASK_ISA_SSE2, + "__builtin_ia32_aesenclast128", V2DI_FTYPE_V2DI_V2DI, IX86_BUILTIN_AESENCLAST128); - def_builtin_const (OPTION_MASK_ISA_AES, "__builtin_ia32_aesdec128", + def_builtin_const (OPTION_MASK_ISA_AES | OPTION_MASK_ISA_SSE2, + "__builtin_ia32_aesdec128", V2DI_FTYPE_V2DI_V2DI, IX86_BUILTIN_AESDEC128); - def_builtin_const (OPTION_MASK_ISA_AES, "__builtin_ia32_aesdeclast128", + def_builtin_const (OPTION_MASK_ISA_AES | OPTION_MASK_ISA_SSE2, + "__builtin_ia32_aesdeclast128", V2DI_FTYPE_V2DI_V2DI, IX86_BUILTIN_AESDECLAST128); - def_builtin_const (OPTION_MASK_ISA_AES, "__builtin_ia32_aesimc128", + def_builtin_const (OPTION_MASK_ISA_AES | OPTION_MASK_ISA_SSE2, + "__builtin_ia32_aesimc128", V2DI_FTYPE_V2DI, IX86_BUILTIN_AESIMC128); - def_builtin_const (OPTION_MASK_ISA_AES, "__builtin_ia32_aeskeygenassist128", + def_builtin_const (OPTION_MASK_ISA_AES | OPTION_MASK_ISA_SSE2, + "__builtin_ia32_aeskeygenassist128", V2DI_FTYPE_V2DI_INT, IX86_BUILTIN_AESKEYGENASSIST128); /* PCLMUL */ - def_builtin_const (OPTION_MASK_ISA_PCLMUL, "__builtin_ia32_pclmulqdq128", + def_builtin_const (OPTION_MASK_ISA_PCLMUL | OPTION_MASK_ISA_SSE2, + "__builtin_ia32_pclmulqdq128", V2DI_FTYPE_V2DI_V2DI_INT, IX86_BUILTIN_PCLMULQDQ128); /* RDRND */ --- gcc/config/i386/wmmintrin.h.jj 2018-01-03 10:20:05.953535684 +0100 +++ gcc/config/i386/wmmintrin.h 2018-02-12 16:25:32.526060590 +0100 @@ -32,9 +32,9 @@ /* AES */ -#ifndef __AES__ +#if !defined(__AES__) || !defined(__SSE2__) #pragma GCC push_options -#pragma GCC target("aes") +#pragma GCC target("aes,sse2") #define __DISABLE_AES__ #endif /* __AES__ */ @@ -101,9 +101,9 @@ _mm_aeskeygenassist_si128 (__m128i __X, /* PCLMUL */ -#ifndef __PCLMUL__ +#if !defined(__PCLMUL__) || !defined(__SSE2__) #pragma GCC push_options -#pragma GCC target("pclmul") +#pragma GCC target("pclmul,sse2") #define __DISABLE_PCLMUL__ #endif /* __PCLMUL__ */ --- gcc/testsuite/gcc.target/i386/pr84335.c.jj 2018-02-12 16:37:55.304353911 +0100 +++ gcc/testsuite/gcc.target/i386/pr84335.c 2018-02-12 16:37:33.230351025 +0100 @@ -0,0 +1,10 @@ +/* PR target/84335 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -maes -mno-sse2" } */ +typedef long long V __attribute__ ((__vector_size__ (16))); + +V +foo (V *a, V *b) +{ + return __builtin_ia32_aesenc128 (*a, *b); /* { dg-error "needs isa option" } */ +}