From patchwork Sun Nov 19 05:41:47 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: 166702 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506236vqn; Sat, 18 Nov 2023 21:42:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IExBlg+S72ikS7BBCZKoxbM4EbKAuIP6r2YUaEwmPmzknZUrXIwToqa2YoJYeln5qSaRBPJ X-Received: by 2002:a05:620a:2990:b0:76e:889d:855d with SMTP id r16-20020a05620a299000b0076e889d855dmr4757857qkp.67.1700372558469; Sat, 18 Nov 2023 21:42:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372558; cv=pass; d=google.com; s=arc-20160816; b=CX3ehaqXwXCkf0y6Yjmh/U4cueUKF/P41v5rovQvp2bE30qCIaDYc8PtD3UpVngYSp fGoU+kFyrIWFo7wfBvgnjCKsdwsRrJXaZgfMdxMtjeFLvYr/TcXH+eJAxIQortHo8RUT bHL3gIowCCGoBuc9MW6KE/Pz97LU0/u1iWwLO4rxllCgQVbVsGqMZnjjKm7moaAWw0DP YOJUYn8DicOzYRMnjwONR0pyz391FW6VH/IiTvMyefwQkVDWwntm/v99RZ/lFYRk5nLR iLt1yyuxfqmjhKw6Z/RU+feh6fTFET30ZUHE7NsPCkE8nXcq/A5GnVBB+oQ9CRJk/F3k EFhQ== 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=PBKx7XTkCPT1ILll/iI9omNk9EMGJ4J/Hv/wKfwg5KI=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=Ng+mmLev4GEXhYhJPNT2h/0KRkgognw7THtHtgk2s2R9JUVppP6bQ8Ct8jSJTabhEA dMBPNy1alhZ1FM/8T8+hl9fyLzXOnNOrutpRADl8x2MclHeUHFIeNROUKYAzeixl5eyn dmLrGcRud4ro1HKoXedGh9prlhKMN8HIqQpncTGvmA6LRJ2qabtBN3ffeM0UH8Wv5MTh iJGxARcfDHPAQJfa98Y3Y/VALYeZTrLqnm1ZeBdg72DycAZmw8DiAxA/pQNMPfrOvwiP MouH1s39IdDUbsBlOLTbqhZ9u6Pvhxaz4GXjmQ2mFpF3SW3hooKO1aa5aapLKSxIR/yH VvEQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=AFZ9QqFl; 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 c1-20020a05620a11a100b0077bcbb62af2si4885018qkk.650.2023.11.18.21.42.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:42:38 -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=AFZ9QqFl; 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 3D0223858282 for ; Sun, 19 Nov 2023 05:42:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id D28DA3857B82 for ; Sun, 19 Nov 2023 05:41:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D28DA3857B82 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 D28DA3857B82 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372516; cv=none; b=sL9VuAQuoKjVvHhBcuV/+6z8C5tgvBuLvFkx7zvzym7hveFYQ1XSDnW9HsZZtSFKMcw14WMAIDo9Q0/pylQTbf3lbEP+8GpligMyqfoi/sFrsHpaUiy91oiWuE1mDO0OqEMN1Rvjdp9xRdtk0heqM0ZeWCQyMk+jASy3PCBmBbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372516; c=relaxed/simple; bh=fVD3AruquWCpoCuDU10frZFUcVu3N7aq8jxg02OefTs=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=hL0/OMcEALCzfD+kewzBQvHpTOfjrchqVyfl5bEABFIcLLlFyQnZ6l1v68wYuMRF083vuxVauNS6ciLacg0kJmZbSJLC2Jn0Bn3g9uSTOYAUqWR51MEHS7IbWMatiafMI8DafpI78or6RS3Sc86IXVm38AewD1Q9SGK6tVF1wAM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-9e4675c7a5fso447763966b.0 for ; Sat, 18 Nov 2023 21:41:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372511; x=1700977311; 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=PBKx7XTkCPT1ILll/iI9omNk9EMGJ4J/Hv/wKfwg5KI=; b=AFZ9QqFlWjO0C93Bu3ka+danudWd+5dlufwZXvBheBahY8kutaG+VVvFG0TtAvqav3 RD/ozswgYhCY15l2+0EuaJtdEvHaER/ZFdjW4Vu33vkvyuf0Mf03h3lEjmL8yDMGzR3k DAD/7uHXktopgf0Wpaf5EZ178NBpDRDHcGRnEuzyXahpE4p+uLITlKUQlF5LVDj23YYC WUx6onbmcIOYuy5t/g80pK6L0aapuwf3TvjdFLweE+CgbR8dFO2lZCBiRTjABXYmT67w Lm38sMkMFemWjyLPQEiLkJoc/dShVhkEebOPI7+V263h8XSf0EEVVH04qrhBk+p18F0Z TyjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372511; x=1700977311; 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=PBKx7XTkCPT1ILll/iI9omNk9EMGJ4J/Hv/wKfwg5KI=; b=Ekj6FciFRSdQsYBxmXYB3H3R+SW8TM6yR+881GcMaPvhvFxWbBD3EKpJ/CAl1kaHnk B2Vby0dbWd4rwk1U2aG1AUMmQaIP5pPc9llUg5dMVRMknlLDUze9IVvo92O3lutq/BxO 5HJRqVCpCX3eO9y3maLqNFaRS23/c0+iAhsyXHZ63EsJV2mumg6LTxveceV5zWPKMnPv KLGzQX43xkzCHoqYVDIDLP+kI2P7cY3x+S/0hdnLP0BQ3cyOxHWI5kZDP2E1SAsuHel4 wNdbkX3vPQX1miNxJTz/lnFtHO5uqQV8S0XWdFbFAwotHA6klQe97NcDYn33W2cGtZJy MX+g== X-Gm-Message-State: AOJu0YxxCGYZVyinD+wqrJ8dVcxeC0oNo4GeGVCm8fWBbsRq8ABcXFj0 SMH7+nBLbqzQmaeF8Cp5nK1d/GYukSyb1YeHQP5hQg== X-Received: by 2002:a17:907:8692:b0:9c6:3c94:69de with SMTP id qa18-20020a170907869200b009c63c9469demr3026086ejc.53.1700372511493; Sat, 18 Nov 2023 21:41:51 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id p20-20020a170906a01400b009adc77fe164sm2538283ejy.66.2023.11.18.21.41.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:41:51 -0800 (PST) Date: Sun, 19 Nov 2023 05:41:47 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 31/44] RISC-V/testsuite: Add branchless cases for generic integer 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=0.7 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-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: 1782969856209208012 X-GMAIL-MSGID: 1782969856209208012 Verify, for generic integer conditional-add operations, if-conversion to trigger via `noce_try_addcc' at the respective sufficiently high `-mbranch-cost=' settings that make branchless code sequences produced by if-conversion cheaper than their original branched equivalents, and, where applicable, that extraneous instructions such as SNEZ, etc. are not present in output. Cover all integer relational operations to make sure no corner case escapes. 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/adddieq.c: New test. * gcc.target/riscv/adddige.c: New test. * gcc.target/riscv/adddigeu.c: New test. * gcc.target/riscv/adddigt.c: New test. * gcc.target/riscv/adddigtu.c: New test. * gcc.target/riscv/adddile.c: New test. * gcc.target/riscv/adddileu.c: New test. * gcc.target/riscv/adddilt.c: New test. * gcc.target/riscv/adddiltu.c: New test. * gcc.target/riscv/adddine.c: New test. * gcc.target/riscv/addsieq.c: New test. * gcc.target/riscv/addsige.c: New test. * gcc.target/riscv/addsigeu.c: New test. * gcc.target/riscv/addsigt.c: New test. * gcc.target/riscv/addsigtu.c: New test. * gcc.target/riscv/addsile.c: New test. * gcc.target/riscv/addsileu.c: New test. * gcc.target/riscv/addsilt.c: New test. * gcc.target/riscv/addsiltu.c: New test. * gcc.target/riscv/addsine.c: New test. --- gcc/testsuite/gcc.target/riscv/adddieq.c | 27 +++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddige.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddigeu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddigt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddigtu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddile.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddileu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddilt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddiltu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddine.c | 27 +++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsieq.c | 27 +++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsige.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsigeu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsigt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsigtu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsile.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsileu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsilt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsiltu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsine.c | 27 +++++++++++++++++++++++++++ 20 files changed, 524 insertions(+) gcc-riscv-test-addcc-generic.diff Index: gcc/gcc/testsuite/gcc.target/riscv/adddieq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddieq.c @@ -0,0 +1,27 @@ +/* { 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=5 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +adddieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y + z : y; +} + +/* Expect branchless assembly like: + + sub a1,a0,a1 + seqz a1,a1 + neg a1,a1 + and a1,a1,a3 + add a0,a1,a2 + */ + +/* { 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 "\\ssub\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:seqz|snez)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddige.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddige.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=4 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +adddige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +/* Expect branchless assembly like: + + slt a1,a0,a1 + addi a1,a1,-1 + and a1,a1,a3 + add a0,a1,a2 + */ + +/* { 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(?:sgt|slt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddigeu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddigeu.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=4 -mmovcc -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +adddigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +/* Expect branchless assembly like: + + sltu a1,a0,a1 + addi a1,a1,-1 + and a1,a1,a3 + add a0,a1,a2 + */ + +/* { 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(?:sgtu|sltu)\\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/adddigt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddigt.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=4 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +adddigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +/* Expect branchless assembly like: + + sgt a1,a0,a1 + neg a1,a1 + and a1,a1,a3 + add a0,a1,a2 + */ + +/* { 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(?:sgt|slt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddigtu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddigtu.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=4 -mmovcc -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +adddigtu (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +/* Expect branchless assembly like: + + sgtu a1,a0,a1 + neg a1,a1 + and a1,a1,a3 + add a0,a1,a2 + */ + +/* { 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(?:sgtu|sltu)\\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/adddile.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddile.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=4 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +adddile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +/* Expect branchless assembly like: + + sgt a1,a0,a1 + addi a1,a1,-1 + and a1,a1,a3 + add a0,a1,a2 + */ + +/* { 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(?:sgt|slt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddileu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddileu.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=4 -mmovcc -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +adddileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +/* Expect branchless assembly like: + + sgtu a1,a0,a1 + addi a1,a1,-1 + and a1,a1,a3 + add a0,a1,a2 + */ + +/* { 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(?:sgtu|sltu)\\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/adddilt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddilt.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=4 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +adddilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +/* Expect branchless assembly like: + + slt a1,a0,a1 + neg a1,a1 + and a1,a1,a3 + add a0,a1,a2 + */ + +/* { 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(?:sgt|slt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddiltu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddiltu.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=4 -mmovcc -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +adddiltu (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +/* Expect branchless assembly like: + + sltu a1,a0,a1 + neg a1,a1 + and a1,a1,a3 + add a0,a1,a2 + */ + +/* { 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(?:sgtu|sltu)\\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/adddine.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddine.c @@ -0,0 +1,27 @@ +/* { 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 +adddine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y + z : y; +} + +/* Expect branchless assembly like: + + sub a1,a0,a1 + snez a1,a1 + neg a1,a1 + and a1,a1,a3 + add a0,a1,a2 + */ + +/* { 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 "\\ssub\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:seqz|snez)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsieq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsieq.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +addsieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y + z : y; +} + +/* Expect branchless assembly like: + + sub[w] a1,a0,a1 + seqz a1,a1 + neg[w] a1,a1 + and a1,a1,a3 + add[w] a0,a1,a2 + */ + +/* { 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(?:sub|subw)\\s" 1 { xfail rv64 } } } */ +/* { dg-final { scan-assembler-times "\\s(?:seqz|snez)\\s" 1 { xfail rv64 } } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" { xfail rv64 } } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsige.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsige.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=4 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=4 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +addsige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +/* Expect branchless assembly like: + + slt a1,a0,a1 + addi[w] a1,a1,-1 + and a1,a1,a3 + add[w] a0,a1,a2 + */ + +/* { 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(?:sgt|slt)\\s" 1 { xfail rv64 } } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bge|bgt|ble|blt)\\s" { xfail rv64 } } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsigeu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsigeu.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=4 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=4 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +addsigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +/* Expect branchless assembly like: + + sltu a1,a0,a1 + addi[w] a1,a1,-1 + and a1,a1,a3 + add[w] a0,a1,a2 + */ + +/* { 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(?:sgtu|sltu)\\s" 1 { xfail rv64 } } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" { xfail rv64 } } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsigt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsigt.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=4 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=4 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +addsigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +/* Expect branchless assembly like: + + sgt a1,a0,a1 + neg[w] a1,a1 + and a1,a1,a3 + add[w] a0,a1,a2 + */ + +/* { 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(?:sgt|slt)\\s" 1 { xfail rv64 } } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bge|bgt|ble|blt)\\s" { xfail rv64 } } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsigtu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsigtu.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=4 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=4 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +addsigtu (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +/* Expect branchless assembly like: + + sgtu a1,a0,a1 + neg[w] a1,a1 + and a1,a1,a3 + add[w] a0,a1,a2 + */ + +/* { 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(?:sgtu|sltu)\\s" 1 { xfail rv64 } } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" { xfail rv64 } } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsile.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsile.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=4 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=4 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +addsile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +/* Expect branchless assembly like: + + sgt a1,a0,a1 + addi[w] a1,a1,-1 + and a1,a1,a3 + add[w] a0,a1,a2 + */ + +/* { 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(?:sgt|slt)\\s" 1 { xfail rv64 } } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bge|bgt|ble|blt)\\s" { xfail rv64 } } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsileu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsileu.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=4 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=4 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +addsileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +/* Expect branchless assembly like: + + sgtu a1,a0,a1 + addi[w] a1,a1,-1 + and a1,a1,a3 + add[w] a0,a1,a2 + */ + +/* { 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(?:sgtu|sltu)\\s" 1 { xfail rv64 } } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" { xfail rv64 } } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsilt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsilt.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=4 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=4 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +addsilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +/* Expect branchless assembly like: + + slt a1,a0,a1 + neg[w] a1,a1 + and a1,a1,a3 + add[w] a0,a1,a2 + */ + +/* { 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(?:sgt|slt)\\s" 1 { xfail rv64 } } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bge|bgt|ble|blt)\\s" { xfail rv64 } } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsiltu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsiltu.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=4 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=4 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +addsiltu (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +/* Expect branchless assembly like: + + sltu a1,a0,a1 + neg[w] a1,a1 + and a1,a1,a3 + add[w] a0,a1,a2 + */ + +/* { 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(?:sgtu|sltu)\\s" 1 { xfail rv64 } } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" { xfail rv64 } } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsine.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsine.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=4 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=4 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +addsine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y + z : y; +} + +/* Expect branchless assembly like: + + sub[w] a1,a0,a1 + snez a1,a1 + neg[w] a1,a1 + and a1,a1,a3 + add[w] a0,a1,a2 + */ + +/* { 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(?:sub|subw)\\s" 1 { xfail rv64 } } } */ +/* { dg-final { scan-assembler-times "\\s(?:seqz|snez)\\s" 1 { xfail rv64 } } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" { xfail rv64 } } } */