From patchwork Sun Nov 19 05:38:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 166686 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505385vqn; Sat, 18 Nov 2023 21:38:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHq4hLfdEpuP0ktpxthGYXIETH9PLuPOzhNdQmYQLvnoEIuPW8NNqDNolWSfx4zEtd86dGP X-Received: by 2002:a05:622a:148e:b0:418:152d:bf6 with SMTP id t14-20020a05622a148e00b00418152d0bf6mr5252802qtx.26.1700372334505; Sat, 18 Nov 2023 21:38:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372334; cv=pass; d=google.com; s=arc-20160816; b=NjDmjPTQQv95EYwfmg7O5yIXIx7KxeC7iwQ5tDDEJgqp/nK7r++IhXVjtjxI1+wUpO Cu0KR6oDUpvyHRPXSp6zfMOyZ8amLIAv+jY8QA7Ewt2KL3Vdb60O4TQWGQ1zAmbWYtJb q0+gxBsTX7f/RP1EyH+NjmUTC8dALfbsoZqeqXFzmjCQ+M5LUI2OyvabkMav/kvsn9/7 sH+SyhcNh0qR21i3581WaOuN9X6eDxRuCIleBwG6fMir6bTXyf7a4px95Gn0LQ47IhCt /lyzBPyolxLSEgv5u1oOrX4JgcRrgHXrl+Mv38cxD0n51QtYsW4V5utAg63Cs9IcCia5 BJyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=SNE/fMtFqp8U2T5v+2iWcQYm6jIcJRjN0/wTJ9tFqlc=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=qfsk2GpV/6W83FiIDRHUMad9FjX6BQdYgmwO0nxUmJYb+LMiI2itMQyIz2JVJqPUOc ilfzJEJmjbfJYnITcyOTvIeZ6s/Yq/t33gMf06mktmhkd7rEbibi6HxTS2aRfE/Cc36G Y+Dx4qiv9ZDSr9qduwDY5wEAxaQZbppkfwRMZeS76TXKVyPJ+9HlN/kFdEC/e4SsmDWw 5Z+z6fEVq6s9iTqhP5tsZfLRQK7ijT899uH5PFTi8ZoWZ3D3c41X0hVqbxnwTlv4Jq+i aEwvxao4BM+g4CENdsrJk5horg4ur1T2tOLGaPfWi4q7E2/jTpF7RRTqPUNl+USbV+Gy d6xw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=MC1V7z7M; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id z7-20020a05622a060700b00417ce695031si5035914qta.258.2023.11.18.21.38.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:38:54 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=MC1V7z7M; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9DC16385BADA for ; Sun, 19 Nov 2023 05:38:53 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 90A273857C60 for ; Sun, 19 Nov 2023 05:38:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 90A273857C60 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 90A273857C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372310; cv=none; b=ZHGqcLOlyXgKo3Hy8LKvomPj2t79OxVArP/c+VmZONm654hdWOJ92ziJ3fUNx6Lal9UX8kGC5AwIfQJcTGXW3iys+zMH9wXco5qPdUpU4Bsqqut1ZXuaX6sYz72FFqnv+ZDyvsfQfId3/xcKgJCSVAQ8DSFi55TAUnmRJ8DfztU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372310; c=relaxed/simple; bh=x1e0hr/BqXMSyszxut0cvDgsnV2a45GexzfrLIXImio=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=oLr1UloEX48KiLlgLKOyDmhUlHsfi7DV5h3U4gHjPVM1QGIaOnzRLu0cU3c/XX3cD42GZW73YW6fDY8PGh9yn1T1AoG0kgRxUNxBXQrQx62KzExCbRaY2NcTY0s2MQi+ZnX+tlx18350Uyiuc7XrqpMIo1h7Lfd29Q1m/xxtPl4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-9e62ab773f1so460201766b.0 for ; Sat, 18 Nov 2023 21:38:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372307; x=1700977107; darn=gcc.gnu.org; h=mime-version:user-agent:references:message-id:in-reply-to:subject :cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=SNE/fMtFqp8U2T5v+2iWcQYm6jIcJRjN0/wTJ9tFqlc=; b=MC1V7z7Mo8HG213wZU0IV8mtMyjU54bnHnowAEMyCJAlmNaOJRTMymUn1OU5SdmjtS WljW1SS57TY/jtpynyAIQJSY6kEILUJzRuQAqW52TyJTCprmVRT+JcVEju9UHvwt+AsZ ZecAv+xPhN5FDB/tvymP0funG8Izf+aJ40T0EDPfMN3qhl9Z/4aXVYiFu0EKG9h3yFdM InpYqcvhEnEVWgtKYS71DgslzXKcE2xUOa66tc+cVf+g/JydXIsNJz7qa5nykBGYwQpq KEsMAhbjGaQxX13F0efa2SbR+NMBP3ek4lrcSI9Pbgn5oSBQcp9kVs1CYc2TAHAcd5zw NLDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372307; x=1700977107; h=mime-version:user-agent:references:message-id:in-reply-to:subject :cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SNE/fMtFqp8U2T5v+2iWcQYm6jIcJRjN0/wTJ9tFqlc=; b=PnGkvzTSQEbrrry2ttJ9K42FWIYHGHgE6ouw6DKrkmqe9UkTmxAEd4jKB1DgFntAQW wq1Nmb0PWa57R5ULFMY2j86scQ2niJfnFPf5tlrZyEMDeTfgTAzREuqEPGd8oQ+mIJhb Zve7aZ6Xa7FuMKNGfiL7Fi62s4FnUePAeazGRzxAKBnwewBULFP+qhaDIq8Q3Sv5kYxv gjrnrIl/Aws3O4MnR0R5zPV8hNPMeHcUqoFkhfW8AZr3lhlZxcOVouf7dqXmOIGROEnC z2TWEOI8m8MHkd840NOz9f/N+azO37k8ykob+DM7Y1t8EZvrortFS6nYIliA9n3n9gIz vLdg== X-Gm-Message-State: AOJu0YzyXbsM25jDnJ/bfqrls7qEXf+a+TSWk4WKjcx/GYM4G+HZ+uJi bv2ehzC/QCmpoQBD3fwev6a3ZNVn5UgUSvcUR3GNKA== X-Received: by 2002:a17:907:9722:b0:9be:21dc:8a9a with SMTP id jg34-20020a170907972200b009be21dc8a9amr3281367ejc.39.1700372307218; Sat, 18 Nov 2023 21:38:27 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id h4-20020a1709063c0400b009e67c32050dsm2534274ejg.44.2023.11.18.21.38.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:38:26 -0800 (PST) Date: Sun, 19 Nov 2023 05:38:24 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 16/44] RISC-V/testsuite: Add branchless cases for GEU and LEU cond-move operations In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS, KAM_SHORT, LIKELY_SPAM_BODY, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782969620901701192 X-GMAIL-MSGID: 1782969620901701192 Verify, for Ventana and Zicond targets and the GEU and LEU conditional-move operations, that if-conversion triggers via `noce_try_cmove' at `-mbranch-cost=4' setting, which makes branchless code sequences produced by if-conversion cheaper than their original branched equivalents, and that extraneous instructions such as SEQZ, etc. are not present in output. gcc/testsuite/ * gcc.target/riscv/movdigtu-ventana.c: New test. * gcc.target/riscv/movdigtu-zicond.c: New test. * gcc.target/riscv/movdiltu-ventana.c: New test. * gcc.target/riscv/movdiltu-zicond.c: New test. * gcc.target/riscv/movsigtu-ventana.c: New test. * gcc.target/riscv/movsigtu-zicond.c: New test. * gcc.target/riscv/movsiltu-ventana.c: New test. * gcc.target/riscv/movsiltu-zicond.c: New test. --- gcc/testsuite/gcc.target/riscv/movdigtu-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigtu-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiltu-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiltu-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigtu-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigtu-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiltu-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiltu-zicond.c | 28 ++++++++++++++++++++++ 8 files changed, 224 insertions(+) gcc-riscv-expand-conditional-move-geu-leu-test-movcc.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdigtu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigtu-ventana.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xventanacondops -mtune=rocket -mbranch-cost=4 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdigtu (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + sgtu a1,a0,a1 + vt.maskcn a3,a3,a1 + vt.maskc a1,a2,a1 + or a0,a1,a3 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through noce_try_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\svt\\.maskc\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\svt\\.maskcn\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdigtu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigtu-zicond.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_zicond -mtune=rocket -mbranch-cost=4 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdigtu (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + sgtu a1,a0,a1 + czero.nez a3,a3,a1 + czero.eqz a1,a2,a1 + or a0,a1,a3 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through noce_try_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdiltu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiltu-ventana.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xventanacondops -mtune=rocket -mbranch-cost=4 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdiltu (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + sltu a1,a0,a1 + vt.maskcn a3,a3,a1 + vt.maskc a1,a2,a1 + or a0,a1,a3 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through noce_try_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\svt\\.maskc\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\svt\\.maskcn\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdiltu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiltu-zicond.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_zicond -mtune=rocket -mbranch-cost=4 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdiltu (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + sltu a1,a0,a1 + czero.nez a3,a3,a1 + czero.eqz a1,a2,a1 + or a0,a1,a3 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through noce_try_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsigtu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigtu-ventana.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xventanacondops -mtune=rocket -mbranch-cost=4 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsigtu (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + sgtu a1,a0,a1 + vt.maskcn a3,a3,a1 + vt.maskc a1,a2,a1 + or a0,a1,a3 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through noce_try_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\svt\\.maskc\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\svt\\.maskcn\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsigtu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigtu-zicond.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_zicond -mtune=rocket -mbranch-cost=4 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=4 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsigtu (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + sgtu a1,a0,a1 + czero.nez a3,a3,a1 + czero.eqz a1,a2,a1 + or a0,a1,a3 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through noce_try_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiltu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiltu-ventana.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xventanacondops -mtune=rocket -mbranch-cost=4 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsiltu (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + sltu a1,a0,a1 + vt.maskcn a3,a3,a1 + vt.maskc a1,a2,a1 + or a0,a1,a3 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through noce_try_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\svt\\.maskc\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\svt\\.maskcn\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiltu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiltu-zicond.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_zicond -mtune=rocket -mbranch-cost=4 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=4 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsiltu (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + sltu a1,a0,a1 + czero.nez a3,a3,a1 + czero.eqz a1,a2,a1 + or a0,a1,a3 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through noce_try_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */