From patchwork Sat Feb 12 09:02:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 51080 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5FB1F385803A for ; Sat, 12 Feb 2022 09:03:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5FB1F385803A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1644656590; bh=MkMLnyJcW2gOcp1ocY5/tUW7rBnZTyHS7jhOrBvv4Tk=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=B0FQEwDSzABrMyQQjLp3OgfZzdCYr006dmD4donF1DIuI1Vc4nVffpLGrsuTl+DPe VBbRp004pbifcT224TI/bnAyApa/tHvs2l6FgUEAmbNKQLaFApVjhcHGCm1ISfERjS 21w6iTfWDBBhTXWcdrx4G65zNrLFj2MrA9mtBh5Q= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 9EFD4385843B for ; Sat, 12 Feb 2022 09:02:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9EFD4385843B Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-351-zZ65OspHPmqjcj6LOobemA-1; Sat, 12 Feb 2022 04:02:35 -0500 X-MC-Unique: zZ65OspHPmqjcj6LOobemA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85F3A835B47; Sat, 12 Feb 2022 09:02:34 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2162A6C1B7; Sat, 12 Feb 2022 09:02:33 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 21C92VcF057775 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 12 Feb 2022 10:02:31 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 21C92Uix057774; Sat, 12 Feb 2022 10:02:30 +0100 Date: Sat, 12 Feb 2022 10:02:30 +0100 To: Uros Bizjak Subject: [PATCH] i386: Fix up cvtsd2ss splitter [PR104502] Message-ID: <20220212090230.GY2646553@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! The following testcase ICEs, because AVX512F is enabled, AVX512VL is not, and the cvtsd2ss insn has %xmm0-15 as output operand and %xmm16-31 as input operand. For output operand %xmm16+ the splitter just gives up in such case, but for such input it just emits vmovddup which requires AVX512VL if either operand is EXT_REX_SSE_REG_P (when it is 128-bit). The following patch fixes it by treating that case like the pre-SSE3 output != input case - move the input to output and do everything on the output reg which is known to be < %xmm16. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2022-02-12 Jakub Jelinek PR target/104502 * config/i386/i386.md (cvtsd2ss splitter): If operands[1] is xmm16+ and AVX512VL isn't available, move operands[1] to operands[0] first. * gcc.target/i386/pr104502.c: New test. Jakub --- gcc/config/i386/i386.md.jj 2022-01-18 11:58:59.142988343 +0100 +++ gcc/config/i386/i386.md 2022-02-11 16:19:48.399518508 +0100 @@ -4838,8 +4838,8 @@ (define_split movddup is available. */ if (REG_P (operands[1])) { - if (!TARGET_SSE3 - && REGNO (operands[0]) != REGNO (operands[1])) + if ((!TARGET_SSE3 && REGNO (operands[0]) != REGNO (operands[1])) + || (EXT_REX_SSE_REG_P (operands[1]) && !TARGET_AVX512VL)) { rtx tmp = lowpart_subreg (DFmode, operands[0], SFmode); emit_move_insn (tmp, operands[1]); --- gcc/testsuite/gcc.target/i386/pr104502.c.jj 2022-02-11 16:28:12.880556460 +0100 +++ gcc/testsuite/gcc.target/i386/pr104502.c 2022-02-11 16:29:42.358321630 +0100 @@ -0,0 +1,31 @@ +/* PR target/104502 */ +/* { dg-do compile { target fstack_protector } } */ +/* { dg-options "-O -flive-range-shrinkage -march=barcelona -fstack-protector-all -mavx512f" } */ + +typedef char __attribute__((__vector_size__ (8))) U; +typedef int __attribute__((__vector_size__ (8))) A; +typedef int __attribute__((__vector_size__ (16))) B; +typedef int __attribute__((__vector_size__ (32))) C; +typedef int __attribute__((__vector_size__ (64))) D; +typedef __float128 __attribute__((__vector_size__ (32))) F; + +char s; +U u; +A a; +int i; +C c; +double d; + +U +foo (U u0, A a0, B b0, B b1, C c0, C c1, C c2, C c3, A a1, A a2, F f0) +{ + C ca = c |= (short) (float) d; + C cb = c0 + c1 + c2 + c3 + ca + (C) f0; + U ua = s << (u & 4); + B ba = ((union {C a; B b;}) cb).b + b0 + b1; + U ub = ((union {B a; U b;}) ba).b + + u0 + u + ua + (U) a + (U) a + (U) a0 + (U) a1 + (U) a2; + long long u64_r = i + d; + char u8_r = u64_r; + return ub + u8_r; +}