From patchwork Sun Nov 19 05:44:17 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: 166716 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506907vqn; Sat, 18 Nov 2023 21:45:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoE7zOJNia58B57Oniom7AQdsP7TiuIRQ09H1p+rH2K71hbLssi6VtOR/1i+MrbUJE+ilk X-Received: by 2002:a05:6214:292:b0:66d:59a4:a2f3 with SMTP id l18-20020a056214029200b0066d59a4a2f3mr14472285qvv.14.1700372720004; Sat, 18 Nov 2023 21:45:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372719; cv=pass; d=google.com; s=arc-20160816; b=q9qU5/4S47Vgmz0eAby5LZn0OF4oDUGdS9jk4k4KHj0UGOlHcoPqG68btLAjc4kgok leDCP+jN4sNhZqSqAW3u2HfDfLf4FmsDIM11j+c99g+CKk9a/5IvW64jHYsCbCTcyqdF Ejp1IMbAbkLxF1wqdwq88WTj+pXW3MfCBZmsd+TNwA+roWCYtOzNGj5+5iU6RUI7vBiN MzvA+LIxtGZn2s0Z3f41eWADQ+ohPPd/h/sl6G1gvXIuyL+jPi+y/ToOki20SXz6X1z6 jmbcHQH+Ct/86c0EHLa795PLSqlOemdVN/lak46/oTbIvvF3HvMfOf8hteDAqjf4y0hg Gb/g== 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=rRe/PQT5aP4N1DNtWTJlcs/CgOjuq+fsTFsfSDrvBSM=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=a1pfPakOHKzpuMYADKEL3n8+XKFsoljBaWG5qHDW91httdN1wqKY4HCRFgKC1QPiK2 7RDR2kWoTbQmXXXlYx2CKd/l4s6BQ3b0dqnTOwoXKy1STvgCxJatFv2kMZVmVBJnbyD0 pDkJGfjGdKaaG1rNaaOS0n6od3C4KnuIGSCsMFwqJCJ3UyEQ4mSWnixUR8O1x+4bZe0n Ku1eIAcC9lOCBb1J4hiqyIzNeXuEb8NxLeuyTqrfoUaUMm+hNXzZ8i8Z/HVeL1eZP5rt tm+ZaHL0zX7F1/BvUhvqS/O8az2gWrOT1qPVwhWZnxegJDyCYo7ELKGMi2ElvaUS7Cxc lOAw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=FWRdGrek; 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 r13-20020a0cf80d000000b00678e7ff706csi1843132qvn.171.2023.11.18.21.45.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:45:19 -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=FWRdGrek; 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 2752F3858289 for ; Sun, 19 Nov 2023 05:44:47 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id A69BD385C6E0 for ; Sun, 19 Nov 2023 05:44:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A69BD385C6E0 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 A69BD385C6E0 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::634 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372663; cv=none; b=FS6aZWNIfLfBEJA7XIClbzR8uzgRbIj4lBo6ttWjz8cMKCU4mUcZ1Txyy/2EWTDnI9Qump7xeqjWxuGnTtHKcgRdzur8AiMVV1m8JWbHWeKYh/hy0OTJkDwzOgaD+FkPaDtjWZlkkBrivQ0IIvsqu2gjTw7F5K31yTT0YGLCDKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372663; c=relaxed/simple; bh=Q+hHx3UjDc9BI/nyTA67PwprrMjUU/KEtCjgZ9iQq60=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=NACOAUaCElrCK7iFd1mhtSCUMQCjjCi0hb2zAityveiyPjVhWyELw6IPByreuVhCE8R/Kl1nXrrDeYO58nRd18GHw/edeK9NiSwx9rSNgtW0UKQmWviK9bApZJeoOMgoXKpw8ZMGj9tJNx+A/jpf1HJDIxdTMjGucZxrFz4MRho= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-9e1021dbd28so457915866b.3 for ; Sat, 18 Nov 2023 21:44:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372660; x=1700977460; 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=rRe/PQT5aP4N1DNtWTJlcs/CgOjuq+fsTFsfSDrvBSM=; b=FWRdGrekjORbIMTk3IZ0QBqSmBjwQoMyZjccAedx3gZfgfYspicTTyxYhLjmChrdyP GCBqd99uLr3oEd46ucTQ1IL81bhCVMUsKKfgOV/WQPthvLXDfnL/D8YBpALH4f6KdqgP BQRx/KZmaKTVTijru2TKpHWAvl2KUMUNhwVaY+n7cG/vhhAEil0uxRkt3gUuYNuyjNgB cHdZVEjHJpMXdrAaZ8AfrUO4OpfL7KMtPjuX3fd30XeLD9JibIo86mNPAtiq4/LlvCsN DTOxgx+9L5TvMP8FXbs/X9h0k6EFbk935yiZ55t7Q8bHhm/QHtotQjsKyDRN9fIRzJ5i i27A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372660; x=1700977460; 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=rRe/PQT5aP4N1DNtWTJlcs/CgOjuq+fsTFsfSDrvBSM=; b=VmX2ircvsiQxfOS+F+GJ6NZvyqNlWOBf6GSRju8HZdCSetoWquSOfwFK95xQucPOzX HyMargKbE2rVdctH8+IaDEX6jCvMVOKzSNr6Nk/7OaCo4Kk/XVd9T6OX67GUTvr/ns+a OhFwvW/YVrOQkINoaPIuNRHcFac7hpU2bloTDjpdWfb7rFFb772xUCYW2cTrmNh0fVDQ 6SDqzKl+h+bW9RRVLblpUxyPTu4xWoi6qZVQM2Av5b/9ssdfnqlrvSbcgV5xmFQx1qKu xmOEV+iCUy+cKEfYL9IIP3kwuu5ngAPbXJsQyRcl4eBiYCsDqUs0tNhpeYRuWp5++2AC UMBg== X-Gm-Message-State: AOJu0YxMfE53YU5vAnn4n/GxU8N+YZiRwp99ATc0bsnAm5llq4WZTYsk fmTQQpG6ioYsqrenOa3RMsHDF5oPXvyOMRbRuwvYRA== X-Received: by 2002:a17:906:414a:b0:9dd:9380:bb15 with SMTP id l10-20020a170906414a00b009dd9380bb15mr2763823ejk.50.1700372660572; Sat, 18 Nov 2023 21:44:20 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id g12-20020a1709061c8c00b009a1a5a7ebacsm2508473ejh.201.2023.11.18.21.44.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:44:20 -0800 (PST) Date: Sun, 19 Nov 2023 05:44:17 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 44/44] RISC-V/testsuite: Add branchless cases for FP NE cond-add operation 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.2 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: 1782970025257721839 X-GMAIL-MSGID: 1782970025257721839 Verify, for the generic floating-point NE conditional-add operation, that if-conversion triggers via `noce_try_addcc' at `-mbranch-cost=3' setting, which makes branchless code sequences emitted by if-conversion cheaper than their original branched equivalents, and that extraneous instructions such as SNEZ, etc. are not present in output. The reason to XFAIL the SImode test for RV64 targets is GCC thinks it has to sign-extend addends, which causes if-conversion to give up. gcc/testsuite/ * gcc.target/riscv/adddifne.c: New test. * gcc.target/riscv/addsifne.c: New test. --- gcc/testsuite/gcc.target/riscv/adddifne.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsifne.c | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) gcc-riscv-test-addccne-generic.diff Index: gcc/gcc/testsuite/gcc.target/riscv/adddifne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddifne.c @@ -0,0 +1,26 @@ +/* { 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=3 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +adddifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y + z : y; +} + +/* Expect branchless assembly like: + + feq.d a5,fa0,fa1 + addi a5,a5,-1 + and a5,a5,a1 + add a0,a5,a0 + */ + +/* { 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_addcc" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsifne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsifne.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=3 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=3 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +addsifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y + z : y; +} + +/* Expect branchless assembly like: + + feq.d a5,fa0,fa1 + addi[w] a5,a5,-1 + and a5,a5,a1 + add[w] a0,a5,a0 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" { xfail rv64 } } } */ +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through noce_try_addcc" 1 "ce1" { xfail rv64 } } } */ +/* { dg-final { scan-assembler-times "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" { xfail rv64 } } } */