From patchwork Sun Nov 19 05:43:21 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: 166712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506698vqn; Sat, 18 Nov 2023 21:44:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/eegwJ+iMGuXM9PrQct/2DBFca8Zfz7sIvMyqFR5X4d4r7LBRqbu+kFGmzOSRhWQDzaYb X-Received: by 2002:a05:622a:44e:b0:417:fa13:a8f7 with SMTP id o14-20020a05622a044e00b00417fa13a8f7mr6805769qtx.4.1700372679967; Sat, 18 Nov 2023 21:44:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372679; cv=pass; d=google.com; s=arc-20160816; b=vuyn7xjB450TyZxJQolRp/aNCx0WASAzfaveo9VsJn6SUOzaMobLxog+zOLpLI/jXj pSpAr8wcqeVgKEb2WneZsnhFWlbPJY+Q5DpEh3urrz5nngMts+c/XnfBmFSy2aQptG/U f/nQgw0W8wEKDHttL/gqIoKm+koDBWlEV7YSTtgLh59NBEtCJozTJqJfagddhtdYeWC1 Kl369+XlqyX7FiM8oWmXLyvD8oR14bNqNXDn9+2L/8LXRXM8xmLan77U28vv+LWFTIeR 7b7nucB2ZBgym/IVDMkddOtrM9Q7NSQOyCv3Gp9zxHXZY6BcRjQ3AyWn3OPN8MaZSw31 RhWQ== 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=8iDOY1YNRm5eXqkNJdM5+mAKQE1tA68xuITENMsY6Rs=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=Ve67Ing6v8ScFpc7HOWmSR/AtcwEdm98eIc+5h+fDZMir+EhW7ol9q4RjZGSchLNYE ycpf1kAUIKFEFNZHstoVguoMVblo+y5Y9BK2aM9bJGxwRH3MgSN8QwaYvvAM0CzBGT9I YGlL94WiJ9CWLhzndWmqWPs1BdK7AyF1/GuG8s56i5MfCR3ntQemhWsQe99sPbTfpwgK K+QE8Hj9nO/Ezh44CILjacvEt8/321UEzLWqgDOvN5qr5w6p6A1G83v7YQ2bdBYexwOg Vwmf7tni75sx2NzsJ77Pv2CxJhtaR8FR11/m6QBhWAqjatTSewOoxTuEDsrOhwOiEHEy JRIg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b="RVokkfd/"; 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 e6-20020ac85986000000b004181d34928esi4871214qte.373.2023.11.18.21.44.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:44:39 -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="RVokkfd/"; 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 78B47385AE54 for ; Sun, 19 Nov 2023 05:44:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id B4B1E3857C4F for ; Sun, 19 Nov 2023 05:43:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4B1E3857C4F 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 B4B1E3857C4F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372609; cv=none; b=YKHYWtUkNZdY/9y1i93Bo6szuq14I0e3vJS6vdmGGr8hMV8LXmLTMCCZY7yC56esmLTE4l5rpVX+9w19Yw6RCKC+LCMNtqYfrIEI98M0pG8EfoqLZzEEF7YX+Zu1L6FdHK/8R8Q0lbiHeHQaLyktKv9DZpY9OKEiWd+tMz1k+EI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372609; c=relaxed/simple; bh=LsiIUcFxHYJ1aX5vC4u4cfSTZYMSAibfy964lvVf+V4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=RkaHXmNumXJ+fxV++SUdvFmj162pHD/ocZ+iqI7YOkO9VMXUa8ELVrmtzi6mTAIZ5mb71JQ1Fa27Xt/fQCFAwIkpqPm8EW17vGPnOjM/WtL4GTkZLyCvuc0FshnQf9x21dTODCwx4zJs0/xoN2f7ZORxUK3L1uYxZaHM4zAYj/4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-507ad511315so4709790e87.0 for ; Sat, 18 Nov 2023 21:43:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372605; x=1700977405; 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=8iDOY1YNRm5eXqkNJdM5+mAKQE1tA68xuITENMsY6Rs=; b=RVokkfd/ra6BMYRm8OQzP4e05DHjRIrAw7spO4079z3AuNj5AAUdY+Xjdy66TD1U62 IkvWpHPe5QJ8gS4815kSc1cGXj1NaTix2K5tFiDvb724bjpnv90JGaGWJeQGJnXwiGBh ws7LhMIm+La1+g/ZjCi4OBjppzi8sBD0jCDLWXHZA4OZZLEcYfGmdhcGQ1S16FlKYN84 QQcPxsLGYbMLc7xsnWAJ/zaVK00kuGZ1bEQp8RA4TNvvGeDWU2+I0j6QwU+7vw3bE0IM hWheexMvxIhlgH8EpL+XAwJxpTIXR7YUMBr6o9gGtz8qHyNpuHEA4OeVfufL50cufbRn p5Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372605; x=1700977405; 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=8iDOY1YNRm5eXqkNJdM5+mAKQE1tA68xuITENMsY6Rs=; b=HfyP17i6p65XlV3Whe7S5Pf+TYY5IHzwBgOaDlRgFrBvjiORZOdh8Akh8KVA6cfguc b6/ajCebe22IETFrzKoio/s5970n7OZVOivgiFbDxLTMxNrRuPsHrxcalmrkb/8ZZTcP 0LhLp3h1jtKaB5qBQF8nq6z8XUG8ltg5SkZXv2Ki/IDgc+vaufzBKsTGIo19izq8gdj7 QnF9LpIBLE9fF8ZMHbt9LRbUAKS8ALeIghaYw0hYfYPfERBRVrURSYhetS0/zZ1gOlWW r+KNtx4xdoFMY+aSkWFmxOmEI0ne5rgtZj6d+S/qviVkS9TiYioBFRwwR0IOcenpP6Q7 3UMw== X-Gm-Message-State: AOJu0Yw76cccL631+OW7m9G1qnhiRch1lAfnP9Uf4EEDbFE8trSiETiF DKHfqMzdoHtkKuta9tzjKyOB9frD4QUUFuRqtdBJkA== X-Received: by 2002:a19:4357:0:b0:500:9bbf:da17 with SMTP id m23-20020a194357000000b005009bbfda17mr2844323lfj.51.1700372605214; Sat, 18 Nov 2023 21:43:25 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id f11-20020a17090624cb00b0099cb0a7098dsm2592706ejb.19.2023.11.18.21.43.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:43:24 -0800 (PST) Date: Sun, 19 Nov 2023 05:43:21 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 39/44] RISC-V/testsuite: Add branchless cases for generic FP cond adds 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=1.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_10_SHORT_WORD_LINES, 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-Level: * 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: 1782969983492249692 X-GMAIL-MSGID: 1782969983492249692 Verify, for generic floating-point conditional-add operations that have a corresponding conditional-set machine instruction, 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 SImode tests for RV64 targets is the compiler thinks it has to sign-extend addends, which causes if-conversion to give up. gcc/testsuite/ * gcc.target/riscv/adddifeq.c: New test. * gcc.target/riscv/adddifge.c: New test. * gcc.target/riscv/adddifgt.c: New test. * gcc.target/riscv/adddifle.c: New test. * gcc.target/riscv/adddiflt.c: New test. * gcc.target/riscv/addsifeq.c: New test. * gcc.target/riscv/addsifge.c: New test. * gcc.target/riscv/addsifgt.c: New test. * gcc.target/riscv/addsifle.c: New test. * gcc.target/riscv/addsiflt.c: New test. --- gcc/testsuite/gcc.target/riscv/adddifeq.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddifge.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddifgt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddifle.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddiflt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsifeq.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsifge.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsifgt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsifle.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsiflt.c | 26 ++++++++++++++++++++++++++ 10 files changed, 260 insertions(+) gcc-riscv-test-addccf-generic.diff Index: gcc/gcc/testsuite/gcc.target/riscv/adddifeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddifeq.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 +adddifeq (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 + neg a5,a5 + 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/adddifge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddifge.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 -ffinite-math-only -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +adddifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +/* Expect branchless assembly like: + + fge.d a5,fa0,fa1 + neg a5,a5 + 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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.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/adddifgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddifgt.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 -ffinite-math-only -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +adddifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +/* Expect branchless assembly like: + + fgt.d a5,fa0,fa1 + neg a5,a5 + 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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.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/adddifle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddifle.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 -ffinite-math-only -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +adddifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +/* Expect branchless assembly like: + + fle.d a5,fa0,fa1 + neg a5,a5 + 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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.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/adddiflt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddiflt.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 -ffinite-math-only -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +adddiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +/* Expect branchless assembly like: + + flt.d a5,fa0,fa1 + neg a5,a5 + 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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.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/addsifeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsifeq.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 +addsifeq (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 + neg[w] a5,a5 + 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 } } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsifge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsifge.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 -ffinite-math-only -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=3 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +addsifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +/* Expect branchless assembly like: + + fge.d a5,fa0,fa1 + neg[w] a5,a5 + 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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" { xfail rv64 } } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsifgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsifgt.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 -ffinite-math-only -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=3 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +addsifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +/* Expect branchless assembly like: + + fgt.d a5,fa0,fa1 + neg[w] a5,a5 + 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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" { xfail rv64 } } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsifle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsifle.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 -ffinite-math-only -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=3 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +addsifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +/* Expect branchless assembly like: + + fle.d a5,fa0,fa1 + neg[w] a5,a5 + 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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" { xfail rv64 } } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsiflt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsiflt.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 -ffinite-math-only -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=3 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +addsiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +/* Expect branchless assembly like: + + flt.d a5,fa0,fa1 + neg[w] a5,a5 + 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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" { xfail rv64 } } } */