From patchwork Sun Nov 19 05:43:45 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: 166713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506726vqn; Sat, 18 Nov 2023 21:44:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRgXxS/b58IxUE6gkc/pKOXZ0ps0938z8zlBzA4FhAHcfJR6ggUvTFX4QxIodShQHW++qc X-Received: by 2002:a05:6214:2524:b0:66d:1219:f2ab with SMTP id gg4-20020a056214252400b0066d1219f2abmr4673575qvb.8.1700372686396; Sat, 18 Nov 2023 21:44:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372686; cv=pass; d=google.com; s=arc-20160816; b=RN9sfrZkvsok4Im/OFSuq77XNmTaaJU4DYoAnXXMpUabteoq0scgXUA78meqa/FlJr OSJOPD4j4BSXfQGqVdles8BSe7Z+3Y6wTMgvk26fo02HhsG6Fn2puiDzz1tT5hYT0a7I rVud7afY2z16QtRbeG+X8fH3F7AwLQ7uojf3aVxKCUz6IomtDZvkzcLTP+uFZd9xb8jN H0fBY9FJ8bf5bXQsKRYRo4hF/NhzaQIezv7oL6AkbPe6bfIgC2+ei0s6PZVkSzR6PiWy TCdRYKs0moSm0f/x9hwGt9FMwkkz9gyjEfWSqfjVBJPa2Z/6ERvKxFPqYrWAhfacr+Cj 83yQ== 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=0g1h3mrxF0Pm60tuTZFU5QZJVj2+yrIwM8xrn4qO8/o=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=mW+9NfP8e5a6u5rYi3usqvBgMMQHKwiwpQHZxJGXQMXyoeD+zLfEjzg9lzXQpLri9H cLFeFt/nBHoFavTFlJLEVsQxAVr+2EtVHKtcSTCrLu8bnV8Lye8UJMmjnfooQWPfQJat eJw1oMNBku2y6u2kJ+L9F/Ox40v0qqTwq1MvLp3koMa5PERc04fo7PsMyV0IvXRuB2Mp DR+dZZn4TUfBY2JRynvlJp0iFIud383j5gz7ovxyWk4BNMpDpz6Mj4CF36JJ8RYua/qs YWxZuhIZq9XHv+YnFx84i/WNCL8Oe5VkYvNIZVSrBfGcL7cZi0LEcA7q9JDkdzBDLvf/ A/qA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=Lb1RCN3W; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id px23-20020a056214051700b006561f4b120asi4943499qvb.52.2023.11.18.21.44.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:44:46 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=Lb1RCN3W; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 26C00385AE41 for ; Sun, 19 Nov 2023 05:44:18 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id 4202E386075A for ; Sun, 19 Nov 2023 05:43:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4202E386075A 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 4202E386075A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372632; cv=none; b=hD6BtY3MSNnFjq08t+McpDqw8Cx0gjoTq7WnYxAWDrTNSVR00j/IDjHNi473Pj0MB1UeDrDWsGWq+LuJXwCDUAcdG++1Y0tvu6N+Y6DpLFy66yIu4A3c3xJ+jkLCj9hXzVUFiNpNjKn8A25u+T2dYy5co1kPhT0sWJppdIDvysw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372632; c=relaxed/simple; bh=P5sWYMWbPlk/12y6mu3499WDYY+RrqbHtkUMMmADzdQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=VgltbreUYztE2y5FMfLbTeEna3aJchKtrGp+xc7IUzmeqEfNLn5eFFfNVwx08/b8ewRsmeEif3d9PkTLxcZaKPrYk23XG314NjQsGnoXb6dw6JpGT77HFJd1O2NUgVg45gukT6W0U3ED3bams8fAQrJfXwxkJYMvClWfAoGhm3I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-53e08e439c7so4723030a12.0 for ; Sat, 18 Nov 2023 21:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372629; x=1700977429; 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=0g1h3mrxF0Pm60tuTZFU5QZJVj2+yrIwM8xrn4qO8/o=; b=Lb1RCN3WeUi9hXXc+qkneBld+zkkQgibNMwuVgFes8MpCvcEnSfk2pj+NUhySj4dx9 JskzT5O6r8nBz/j4LatihndSVKEsh4h4N8pLWrDg+zhD+lQYNY70xMtWghUZQsW5iQ2Z js1dcGpfmMy3sTbIMNlb5PHZ1wwtzmPghWbGfO/aBqz0ZOZDDuvbcH20CnF1LBYNUCVC ZO6uVPaOXmRWr9/tpdDpPvRKhUDxJrAHzUVw9mVTiwmXkGP4P2Lw7qHnp9RDymzcOjH2 J6OktGSZ6yXLynq1OJklJKggwy4LFfCzkp4cpkQ8iXUJR5wa+tBlIYmZ7Y9fakNpHTkd rXsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372629; x=1700977429; 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=0g1h3mrxF0Pm60tuTZFU5QZJVj2+yrIwM8xrn4qO8/o=; b=FwShB41VA72B6NVfW6nIEW0wOleQvoNMW7K/giAJLwmN+oz+3GJwVXOwMGV5SercJ+ xcGRBF6OdgDNtC/kNCdgy0g3n5Kai0fZcE4+9420DXTg2tsyl7MCFOmaztmlA9tDFA3s lk4ZLMpZphQiNVCXHiAR9ETkCKtBw7O7ctWJdhnmhpxgrjRHiSLV88kcc/P+HIPir5SO Nuqi2Ep0stZfL9xygk1+O4+Ly00qRG8WaoaxI7lI1FPgnUaQxjC0DHDtsnv8qtfLnFL9 eVWM4Trw7i7833alH35OlEvHDo7g+uML4kx8ytQb1UczDRJaW4yWXbZVDC1NxORtiMrY 31jw== X-Gm-Message-State: AOJu0YxuDF7HqGm6A+hpSChVjNarjppvM0oBo2NeXDPTgrRNCbwzAim8 dLTSRSHBbKpjGD1+MGhrJpkc22H23vk+6H4/C6gkTA== X-Received: by 2002:aa7:d648:0:b0:543:5364:33b4 with SMTP id v8-20020aa7d648000000b00543536433b4mr2746999edr.11.1700372628996; Sat, 18 Nov 2023 21:43:48 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id d23-20020a50fe97000000b005484c7e30d8sm2062802edt.1.2023.11.18.21.43.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:43:48 -0800 (PST) Date: Sun, 19 Nov 2023 05:43:45 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 41/44] RISC-V/testsuite: Add branched cases for FP NE 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, SCC_5_SHORT_WORD_LINES, 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: 1782969990111586039 X-GMAIL-MSGID: 1782969990111586039 Verify, for generic, Ventana and Zicond targets and the floating-point NE conditional-move operation, that if-conversion does *not* trigger at the respective sufficiently low `-mbranch-cost=' settings that make original branched code sequences cheaper than their branchless equivalents if-conversion would emit. gcc/testsuite/ * gcc.target/riscv/movdibfeq-ventana.c: New test. * gcc.target/riscv/movdibfeq-zicond.c: New test. * gcc.target/riscv/movdibfeq.c: New test. * gcc.target/riscv/movsibfeq-ventana.c: New test. * gcc.target/riscv/movsibfeq-zicond.c: New test. * gcc.target/riscv/movsibfeq.c: New test. --- gcc/testsuite/gcc.target/riscv/movdibfeq-ventana.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibfeq-zicond.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibfeq.c | 28 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfeq-ventana.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfeq-zicond.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfeq.c | 28 +++++++++++++++++++ 6 files changed, 176 insertions(+) gcc-riscv-test-movccne-branch-generic.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdibfeq-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfeq-ventana.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xventanacondops -mtune=rocket -mbranch-cost=2 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifeq (double w, double x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + feq.d a4,fa0,fa1 + mv a5,a0 + mv a0,a1 + beq a4,zero,.L2 + mv a0,a5 +.L2: + */ + +/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\svt\\.maskc\\s" } } */ +/* { dg-final { scan-assembler-not "\\svt\\.maskcn\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibfeq-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfeq-zicond.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_zicond -mtune=rocket -mbranch-cost=2 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifeq (double w, double x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + feq.d a4,fa0,fa1 + mv a5,a0 + mv a0,a1 + beq a4,zero,.L2 + mv a0,a5 +.L2: + */ + +/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\sczero\\.eqz\\s" } } */ +/* { dg-final { scan-assembler-not "\\sczero\\.nez\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibfeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfeq.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=4 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifeq (double w, double x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + feq.d a4,fa0,fa1 + mv a5,a0 + mv a0,a1 + beq a4,zero,.L2 + mv a0,a5 +.L2: + */ + +/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibfeq-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfeq-ventana.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xventanacondops -mtune=rocket -mbranch-cost=2 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifeq (double w, double x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + feq.d a4,fa0,fa1 + mv a5,a0 + mv a0,a1 + beq a4,zero,.L2 + mv a0,a5 +.L2: + */ + +/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\svt\\.maskc\\s" } } */ +/* { dg-final { scan-assembler-not "\\svt\\.maskcn\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibfeq-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfeq-zicond.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_zicond -mtune=rocket -mbranch-cost=2 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=2 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifeq (double w, double x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + feq.d a4,fa0,fa1 + mv a5,a0 + mv a0,a1 + beq a4,zero,.L2 + mv a0,a5 +.L2: + */ + +/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\sczero\\.eqz\\s" } } */ +/* { dg-final { scan-assembler-not "\\sczero\\.nez\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibfeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfeq.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=4 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=4 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifeq (double w, double x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + feq.d a4,fa0,fa1 + mv a5,a0 + mv a0,a1 + beq a4,zero,.L2 + mv a0,a5 +.L2: + */ + +/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */