From patchwork Thu Mar 28 17:27:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 1917498 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=J+g7qY3s; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V59VC5m2xz1yYR for ; Fri, 29 Mar 2024 04:28:02 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 325853858409 for ; Thu, 28 Mar 2024 17:28:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id B62BE3858D1E for ; Thu, 28 Mar 2024 17:27:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B62BE3858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B62BE3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711646861; cv=none; b=YG4j3Xad1llghX8SZzeLzYPN6zpHcGpvZDvs73mSXm3139uJRzWjivGBPq97nJCxqG5DTQqW6akFMxfdqFJ+H5gOW/8lrFxBYdqtinjr1/98uw1C9D1HXqGwrDlAHVFe/OImJqGHTIpndb5pJG8T72wb9nyYGyM5t3FGjYDSYeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711646861; c=relaxed/simple; bh=sswA/jLRbqbEKpoXwCcXaDeaWSDtQeJT/tWUVKPkrYw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=DiCBu40reVE6jQgQm258i64mMZ3Oxdyl5ZI/gKM5CGSkls7G3G33LnUz8NWDvpotIU1HPe3zSD0r7leXGsiyvWfCtMw/ppMFss0cDHz2r5QxDPVlfTADoeGhIA7pfeEGQxriEKWq1n+ahhKRm4ueoMUncutz4z3p3Cru5lh/d64= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1e223025ccbso4018305ad.3 for ; Thu, 28 Mar 2024 10:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1711646857; x=1712251657; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pmMCDHkgyGunzlA6P5Xwz5a1Laruj82vrPZFHkaWraE=; b=J+g7qY3sYTW4wCqTDaSR3C6NXPi1L+fmo/OEtqJPw0XYiXHD8nj0NgHLvnFIip00ui THnvGO625GUvwtPtOcw63sOuysDlWTOE6OalR4TPn1ENBVxlz4XPy4L6AljBLkKnNxN2 UiHG9O5nyyYHw1dBZgM9xji099vMvxhv5PiGcL3ALo9BN+Ykqujj3kSFypKPVNcKBQsg dVJWn2503c3LHjWcKCsmeWZCPgN5S+CAwM17MflNUKtuzyN7c7TXsHwbKqbiO02Wj2fh MKUrLCpFf8IHwxx7wYzh5B5KWBddBfnF2VcAhFSQGsJWOj//a6NPs3ohgPzXFZwQzTuH PDPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711646857; x=1712251657; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pmMCDHkgyGunzlA6P5Xwz5a1Laruj82vrPZFHkaWraE=; b=bHVlPxNHk7hFXwi0kXnrMTI94Zz9lXEDjamX7TZLr5CGIfZoCRckWk3Ins9uNZQKaM x9EVijQUHanNwgX125GnOb98qFzwB1RCBg/Mk6TjemhMoEm7t5JzZ0zx9vwPAwZE2vlp Wqm7aTraJzouThermokwFmq38c36/2S7smKv/E/nc5ahzi7x4y6VYBN3P55DCHrMs0lT kj930YN2dWDyiFiDVSt8w6ofbUz4ci7vGHa4qPhlctJaJNAVl04P8bm1DIN6XuPXnyMM 4tmmiauxH173dXyCzm52r8ENiu1hNThaQ7WCZhet3PbhuAfB30d+jqIv10+WiSaaLdmO ydAw== X-Gm-Message-State: AOJu0YwvKdq8mKzW9OEYjmjELIdmuMGFb5GbsJ6tYeYbaZAeqi5qEP0v IGL5ElFleC6V1h2QkEHmjdBuXJ4h6zzzqLmxrzYFgG3NeAHLqQO9QJQFCIRdlksXrjmO8fJ0Q4o QYWc= X-Google-Smtp-Source: AGHT+IFUE/rU59JjjPJLHtTttOsFDXnuU5DW0QPQLvE9/VosIDKfnYxOWGPmbOflSw4lYxsMMNxTrA== X-Received: by 2002:a17:903:1cb:b0:1e0:ccf7:b94d with SMTP id e11-20020a17090301cb00b001e0ccf7b94dmr107106plh.49.1711646857441; Thu, 28 Mar 2024 10:27:37 -0700 (PDT) Received: from vineet-framework.hq.rivosinc.com ([12.44.203.122]) by smtp.gmail.com with ESMTPSA id p7-20020a170902780700b001e0a2cf62e2sm1881463pll.131.2024.03.28.10.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 10:27:37 -0700 (PDT) From: Vineet Gupta To: gcc-patches@gcc.gnu.org Cc: Vineet Gupta Subject: [COMMITTED] RISC-V: testsuite: ensure vtype is call clobbered Date: Thu, 28 Mar 2024 10:27:35 -0700 Message-Id: <20240328172735.1024040-1-vineetg@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <2d6165fd-e62e-439f-8d61-3e2b7e866143@gmail.com> References: <2d6165fd-e62e-439f-8d61-3e2b7e866143@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, LIKELY_SPAM_BODY, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Per classic Vector calling convention ABI, vtype is call clobbered, so ensure gcc regenerates a VSETVLI in following cases: - after a function call. - after an inline asm fragment which clobbers vtype. ATM gcc seems to be doing the right thing, but a test can never hurt. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/vtype-call-clobbered.c: New Test. Signed-off-by: Vineet Gupta --- .../riscv/rvv/vtype-call-clobbered.c | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/vtype-call-clobbered.c diff --git a/gcc/testsuite/gcc.target/riscv/rvv/vtype-call-clobbered.c b/gcc/testsuite/gcc.target/riscv/rvv/vtype-call-clobbered.c new file mode 100644 index 000000000000..be9f312aa508 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/vtype-call-clobbered.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O2" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ + +#include "riscv_vector.h" + +extern void can_clobber_vtype(); + +static inline void v_loop (void * restrict in, void * restrict out, int n) +{ + for (int i = 0; i < n; i++) + { + vuint8mf8_t v = *(vuint8mf8_t*)(in + i); + *(vuint8mf8_t*)(out + i) = v; + } +} + +/* Two V instructions back-back. + Only 1 vsetvli insn. */ +void +vec1 (void * restrict in, void * restrict out1, void * restrict out2, int n) +{ + v_loop(in, out1, n); + v_loop(in, out2, n); +} + +/* Two V instructions seperated by a function call. + Both need to have a corresponding vsetvli insn. */ +void +vec2 (void * restrict in, void * restrict out1, void * restrict out2, int n) +{ + v_loop(in, out1, n); + can_clobber_vtype(); + v_loop(in, out2, n); +} + +/* Two V instructions seperated by an inline asm with vtype clobber. + Both need to have a corresponding vsetvli insn. */ +void +vec3 (void * restrict in, void * restrict out1, void * restrict out2, int n) +{ + v_loop(in, out1, n); + asm volatile("":::"vtype"); + v_loop(in, out2, n); +} + +/* { dg-final { scan-assembler-times {vsetvli} 5 } } */