From patchwork Wed Feb 12 06:32:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1236643 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-519382-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=KuTez3NS; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PJFweU2n; 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 48HVGS4GB5z9s29 for ; Wed, 12 Feb 2020 17:33:50 +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:content-transfer-encoding; q=dns; s=default; b=I01 BWYIx6ZDE5xqmq1iuiCWzlLFb8r4RiNuKxSXuFbfwYrMnN9lyZbOrYUA5c8z/FDW ZZBTosc0toF+95V1GwYhvcx3QaF2KsZTdPtCeZ1qUXqPoepw4uHvHw86TVPAFdJW 2zU3vC4vbLDGm2PO7xuJIL2+u5GL3ZVj5XXHKE/o= 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:content-transfer-encoding; s=default; bh=OgT+ST7GE RFFoCOpa3I5o8I0LQs=; b=KuTez3NSAp65bztSQJmOMt4CboleQc6Z+rOgzjg5p I7Mdi7SE6iCA1L4q0FNPMmwAQxl1JF3V5nkrYrphR1fIV2I9J0JQobHe09OMXS5M mhgGr5t3k8hjkx5FkW21dVDHeUXETQL4PYpuAMMJxV65wk3fX91h6vImDAyhMLq+ Kc= Received: (qmail 66511 invoked by alias); 12 Feb 2020 06:33:41 -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 66503 invoked by uid 89); 12 Feb 2020 06:33:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=mas, sk:avx512f, 0v, sk:avx512b X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Feb 2020 06:33:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581489218; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tAamqN8UTbDOq4OQ4QnGj+W/NVfniN5NAOos8OiEA0o=; b=PJFweU2nXXukwqbiLcaDZ79us/x9lmtB+OU/ovKs8oc3gTKYnabssSx+mDDorC7K0uYiOQ IodPhQNO6tSjGMPvx4Tol/aX70Crz4+9N0HVjJfgwQX829/IAf/AYAViu0eY6RE5v8NFT1 xqmvj9thU3357FjmI0kGUu7PdoXEYKA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-21-HfJmy62hOtCDoYK96rR0ig-1; Wed, 12 Feb 2020 01:33:32 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 40D1B800D50; Wed, 12 Feb 2020 06:33:31 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-51.ams2.redhat.com [10.36.116.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C777F87B34; Wed, 12 Feb 2020 06:33:30 +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 01C6WsqW016262; Wed, 12 Feb 2020 07:33:14 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 01C6WTNE016255; Wed, 12 Feb 2020 07:32:29 +0100 Date: Wed, 12 Feb 2020 07:32:28 +0100 From: Jakub Jelinek To: Uros Bizjak , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Fix k*shift* intrinsics [PR93673] Message-ID: <20200212063228.GW17695@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-IsSubscribed: yes Hi! As mentioned in the PR, the intrinsics allow counts from 0 to 255, but we actually reject values from 128 to 255. That is because QImode CONST_INTs can be only -128 to 127. Fixed by using const_0_to_255_operand and adjusting the modes for those predicate to HImode instead of QImode (the IL actually contains the CONST_INT which has VOIDmode). Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Another option would be to drop the modes from match_operand with const_0_to_255_operand. 2020-02-12 Jakub Jelinek PR target/93673 * config/i386/sse.md (k): Use HImode instead of QImode for last operand and use const_0_to_255_operand predicate instead of immediate_operand. (avx512dq_fpclass, avx512dq_vmfpclass, vgf2p8affineinvqb_, vgf2p8affineqb_): Use HImode instead of QImode for const_0_to_255_operand predicated operands. * gcc.target/i386/avx512f-pr93673.c: New test. * gcc.target/i386/avx512dq-pr93673.c: New test. * gcc.target/i386/avx512bw-pr93673.c: New test. Jakub --- gcc/config/i386/sse.md.jj 2020-02-10 22:44:15.235205656 +0100 +++ gcc/config/i386/sse.md 2020-02-11 13:35:37.768477721 +0100 @@ -1650,7 +1650,7 @@ (define_insn "k" [(set (match_operand:SWI1248_AVX512BWDQ 0 "register_operand" "=k") (any_lshift:SWI1248_AVX512BWDQ (match_operand:SWI1248_AVX512BWDQ 1 "register_operand" "k") - (match_operand:QI 2 "immediate_operand" "n"))) + (match_operand:HI 2 "const_0_to_255_operand" "n"))) (unspec [(const_int 0)] UNSPEC_MASKOP)] "TARGET_AVX512F" "k\t{%2, %1, %0|%0, %1, %2}" @@ -22016,7 +22016,7 @@ (define_insn "avx512dq_fpclass 0 "register_operand" "=k") (unspec: [(match_operand:VF_AVX512VL 1 "vector_operand" "vm") - (match_operand:QI 2 "const_0_to_255_operand" "n")] + (match_operand:HI 2 "const_0_to_255_operand" "n")] UNSPEC_FPCLASS))] "TARGET_AVX512DQ" "vfpclass\t{%2, %1, %0|%0, %1, %2}"; @@ -22030,7 +22030,7 @@ (define_insn "avx512dq_vmfpclass (unspec: [(match_operand:VF_128 1 "nonimmediate_operand" "vm") - (match_operand:QI 2 "const_0_to_255_operand" "n")] + (match_operand:HI 2 "const_0_to_255_operand" "n")] UNSPEC_FPCLASS) (const_int 1)))] "TARGET_AVX512DQ" @@ -22637,7 +22637,7 @@ (define_insn "vgf2p8affineinvqb_ + +void +foo (__mmask16 *b) +{ + b[0] = _kshiftli_mask16 (b[0], 0); + b[1] = _kshiftri_mask16 (b[1], 0); + b[2] = _kshiftli_mask16 (b[2], 1); + b[3] = _kshiftri_mask16 (b[3], 1); + b[4] = _kshiftli_mask16 (b[4], 15); + b[5] = _kshiftri_mask16 (b[5], 15); + b[6] = _kshiftli_mask16 (b[6], 0x7f); + b[7] = _kshiftri_mask16 (b[7], 0x7f); + b[8] = _kshiftli_mask16 (b[8], 0xff); + b[9] = _kshiftri_mask16 (b[9], 0xff); +} --- gcc/testsuite/gcc.target/i386/avx512dq-pr93673.c.jj 2020-02-11 13:45:34.956534896 +0100 +++ gcc/testsuite/gcc.target/i386/avx512dq-pr93673.c 2020-02-11 13:45:56.990205434 +0100 @@ -0,0 +1,20 @@ +/* PR target/93673 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512dq" } */ + +#include + +void +foo (__mmask8 *a) +{ + a[0] = _kshiftli_mask8 (a[0], 0); + a[1] = _kshiftri_mask8 (a[1], 0); + a[2] = _kshiftli_mask8 (a[2], 1); + a[3] = _kshiftri_mask8 (a[3], 1); + a[4] = _kshiftli_mask8 (a[4], 7); + a[5] = _kshiftri_mask8 (a[5], 7); + a[6] = _kshiftli_mask8 (a[6], 0x7f); + a[7] = _kshiftri_mask8 (a[7], 0x7f); + a[8] = _kshiftli_mask8 (a[8], 0xff); + a[9] = _kshiftri_mask8 (a[9], 0xff); +} --- gcc/testsuite/gcc.target/i386/avx512bw-pr93673.c.jj 2020-02-11 13:46:13.558957690 +0100 +++ gcc/testsuite/gcc.target/i386/avx512bw-pr93673.c 2020-02-11 13:46:29.406720723 +0100 @@ -0,0 +1,30 @@ +/* PR target/93673 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512bw" } */ + +#include + +void +foo (__mmask32 *c, __mmask64 *d) +{ + c[0] = _kshiftli_mask32 (c[0], 0); + c[1] = _kshiftri_mask32 (c[1], 0); + c[2] = _kshiftli_mask32 (c[2], 1); + c[3] = _kshiftri_mask32 (c[3], 1); + c[4] = _kshiftli_mask32 (c[4], 31); + c[5] = _kshiftri_mask32 (c[5], 31); + c[6] = _kshiftli_mask32 (c[6], 0x7f); + c[7] = _kshiftri_mask32 (c[7], 0x7f); + c[8] = _kshiftli_mask32 (c[8], 0xff); + c[9] = _kshiftri_mask32 (c[9], 0xff); + d[0] = _kshiftli_mask64 (d[0], 0); + d[1] = _kshiftri_mask64 (d[1], 0); + d[2] = _kshiftli_mask64 (d[2], 1); + d[3] = _kshiftri_mask64 (d[3], 1); + d[4] = _kshiftli_mask64 (d[4], 63); + d[5] = _kshiftri_mask64 (d[5], 63); + d[6] = _kshiftli_mask64 (d[6], 0x7f); + d[7] = _kshiftri_mask64 (d[7], 0x7f); + d[8] = _kshiftli_mask64 (d[8], 0xff); + d[9] = _kshiftri_mask64 (d[9], 0xff); +}