From patchwork Sun Nov 19 05:35: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: 166673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1504761vqn; Sat, 18 Nov 2023 21:36:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGt1eRQ4Y4xZVvwwPlYJlO2GSAP8pjb4yTfHenu8NPHTF28bb9UUbTpDaaPIxes4L8+x3uJ X-Received: by 2002:a05:620a:f81:b0:77b:93b3:32ff with SMTP id b1-20020a05620a0f8100b0077b93b332ffmr4120599qkn.43.1700372161426; Sat, 18 Nov 2023 21:36:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372161; cv=pass; d=google.com; s=arc-20160816; b=ZzE9TzQW1D93+JqxNcWk93q0LiAvE5CplXkVEikqhJav6/MQrszIgIHTgOxHSs/KSP YqP1l5A160g0T0Lj0Ro8djvp0511ScQAUnlTgP0oqfaPXusVzBxP/pg8epDTF5dw6SDE Xzg79ahY3Yp+5vviI+iq7qfAB7xhHepYe6Glh/I1/UF5HEcvjwmMJN0FCh1lhWnUavro HUwgwsQK85vQLN9hPKXcxG2yPVG/bqD86qWfQgxZSbkFzrAUBkpa9eoKOAMek0LyH/UO XQsKpx9eut+Iw0EwVWimc7XkO7DAoyz5SQZWS3b7+nVR6Be6PNMHaK0Q8w4dQrAKZOqf TSFA== 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=7gqVqf75AKcAxNLKzyjsXQ1eoLCOtzE4APSFnec7PV0=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=ZZCg+ibQkvndORoasGcV1pdCtoVyEKN81G6UUGHKnDcJ0XnSo0f+0IN1sQjiuHpbN3 AKBm3OcdQLTfy/U3QrfvYYr3n8PLQO+j2ixEZLIxjcvBmu7T9WdsZR034um/gn2+W32+ tj4VhMfam8oEnsTvGAYuaRl53daU4OEfFS/uhG8LpyeaPrNwRsJxYeuVEiBuXOB2arFE k9TrS2sbPLrEZFq8WWkTJedlbxO1h19ejx5B5APXBM+kQxVtyZHzcBVKtfRiphBQ9FoX 1SOHUv/17xOZB/CeDnAfi3/NdlRN9BggaEF9gzK9qBubYpYANt6LgvbqcvJtbPMGaUT0 oN6Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=SawxCssJ; 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 p11-20020a05620a132b00b0077a02af559fsi4883687qkj.461.2023.11.18.21.36.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:36:01 -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=SawxCssJ; 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 B772D3858281 for ; Sun, 19 Nov 2023 05:36:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id DCA503858421 for ; Sun, 19 Nov 2023 05:35:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DCA503858421 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 DCA503858421 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::532 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372135; cv=none; b=El6yok/1V7GZzsMiAP8WlB61nC8PIXR7ZO6h9QKgTpy4NhEtkoY4gC52H0LEVd2a6KIOTPehqZF2sYUKsdbiGHuyvuMifqh61evItAEkWQltvqvb0hmoOHhCOMQzxvi0b7RNeoaqK6aElDcXR/lqKyVgcbEdvlbh/uImKVP6DfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372135; c=relaxed/simple; bh=hbwtkJS1VjXLePTuMKDG/cOzQIA5gSun80kuKHEmu+k=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=DdTtfBLOnNiHlRs1iIctiSbJgeenqW5m4+WuCeljaYRbjpt076fX576fzIY3MXLQJtVYBTJ8tI6cCm96q822wKXzy582B+9ZRDBhSswDzn3hZZJEFlb1IzrbsCJF6vo23PkrKiEmk8yOus2u0qkK8BLMiW8/mZ4sY9I9IMbzYl8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-53de8fc1ad8so4848825a12.0 for ; Sat, 18 Nov 2023 21:35:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372128; x=1700976928; 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=7gqVqf75AKcAxNLKzyjsXQ1eoLCOtzE4APSFnec7PV0=; b=SawxCssJ7rZtBekMu1zXmVCKa0R38o5DeWkMtLmgqlpo/s8fgux6exZsN6n9JamiWM F7bXa2O+fC3zg0hQSWtV3RGeVHP8oQgNWx8FzMFEF/1aJ9PlFWeQrwbiJHi9rVrtpbBS blOu7cOdFISRYDeEyQCbazt8vco/ftXfQ1PEz6e20K9sPJhZ/o9sDJVONI3I/Qik73yW QlL1VSEQbHWT82bsomzJymHbrR3DbzH+f2sMnpymOvkctZLcD1nnss/NAI8emqQYHpgg 7Ip9hk8zS6Tjzc/alQDqkWYUpcopaX+TnoK4ot0cwJH+IdZD/S3PVkHTDnV1wJau4yO6 ItxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372128; x=1700976928; 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=7gqVqf75AKcAxNLKzyjsXQ1eoLCOtzE4APSFnec7PV0=; b=BSTSQESwXcD4cmj+JwakIr7La04uYLrkuH85dQPs/9op6mn9eorVMouFat6PyRLL9d yaRNDYJK+yO0NjZaOJLCTlx0CcAcugoOXpLBQh79k5pOb3Uc1MhT6szqT4Hvv6pH4APX 3i0zjv8ziW3SEMgX3aNbVQFbVd9HhSUeqfWbTPvZ+Co9NVe7zkrKVB38819VlAyYiopl cyTfrbu+PpGDSGrn8Q3poLm6LXB5dL+J6ggS05qasr3oaQ+U6s6zgZ7xlhDX1qUFfidv zl8qzitKJPoAVOYaGtdyj/Dwcz9fHyuV2iZPnbiH2ZPR2YcI2kLzyEAoAmeOO+Dc5v9M 5Asg== X-Gm-Message-State: AOJu0YwdbxK84YFD93zKrP0YypxeZtksCe74tDGpscwkNJ31RBdupFEA KOvw+T0Oz4/BywjxX62OMTYSrOUMJ6kiGCH90CRRpQ== X-Received: by 2002:aa7:d056:0:b0:543:7256:6370 with SMTP id n22-20020aa7d056000000b0054372566370mr3458940edo.23.1700372127976; Sat, 18 Nov 2023 21:35:27 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id u12-20020a056402064c00b00548550301cesm1772910edx.48.2023.11.18.21.35.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:35:27 -0800 (PST) Date: Sun, 19 Nov 2023 05:35:21 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 01/44] testsuite: Add cases for conditional-move and conditional-add 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.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS, 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: 1782969439157432039 X-GMAIL-MSGID: 1782969439157432039 Add generic execution tests for expressions that are expected to expand to conditional-move and conditional-add operations where supported. To ensure no corner case escapes all relational operators are extensively covered for integer comparisons and all ordered operators are covered for floating-point comparisons. Unordered operators are not covered at this point as they'd require a different input data set. gcc/testsuite/ * gcc.dg/torture/addieq.c: New test. * gcc.dg/torture/addifeq.c: New test. * gcc.dg/torture/addifge.c: New test. * gcc.dg/torture/addifgt.c: New test. * gcc.dg/torture/addifle.c: New test. * gcc.dg/torture/addiflt.c: New test. * gcc.dg/torture/addifne.c: New test. * gcc.dg/torture/addige.c: New test. * gcc.dg/torture/addigeu.c: New test. * gcc.dg/torture/addigt.c: New test. * gcc.dg/torture/addigtu.c: New test. * gcc.dg/torture/addile.c: New test. * gcc.dg/torture/addileu.c: New test. * gcc.dg/torture/addilt.c: New test. * gcc.dg/torture/addiltu.c: New test. * gcc.dg/torture/addine.c: New test. * gcc.dg/torture/addleq.c: New test. * gcc.dg/torture/addlfeq.c: New test. * gcc.dg/torture/addlfge.c: New test. * gcc.dg/torture/addlfgt.c: New test. * gcc.dg/torture/addlfle.c: New test. * gcc.dg/torture/addlflt.c: New test. * gcc.dg/torture/addlfne.c: New test. * gcc.dg/torture/addlge.c: New test. * gcc.dg/torture/addlgeu.c: New test. * gcc.dg/torture/addlgt.c: New test. * gcc.dg/torture/addlgtu.c: New test. * gcc.dg/torture/addlle.c: New test. * gcc.dg/torture/addlleu.c: New test. * gcc.dg/torture/addllt.c: New test. * gcc.dg/torture/addlltu.c: New test. * gcc.dg/torture/addlne.c: New test. * gcc.dg/torture/movieq.c: New test. * gcc.dg/torture/movifeq.c: New test. * gcc.dg/torture/movifge.c: New test. * gcc.dg/torture/movifgt.c: New test. * gcc.dg/torture/movifle.c: New test. * gcc.dg/torture/moviflt.c: New test. * gcc.dg/torture/movifne.c: New test. * gcc.dg/torture/movige.c: New test. * gcc.dg/torture/movigeu.c: New test. * gcc.dg/torture/movigt.c: New test. * gcc.dg/torture/movigtu.c: New test. * gcc.dg/torture/movile.c: New test. * gcc.dg/torture/movileu.c: New test. * gcc.dg/torture/movilt.c: New test. * gcc.dg/torture/moviltu.c: New test. * gcc.dg/torture/movine.c: New test. * gcc.dg/torture/movleq.c: New test. * gcc.dg/torture/movlfeq.c: New test. * gcc.dg/torture/movlfge.c: New test. * gcc.dg/torture/movlfgt.c: New test. * gcc.dg/torture/movlfle.c: New test. * gcc.dg/torture/movlflt.c: New test. * gcc.dg/torture/movlfne.c: New test. * gcc.dg/torture/movlge.c: New test. * gcc.dg/torture/movlgeu.c: New test. * gcc.dg/torture/movlgt.c: New test. * gcc.dg/torture/movlgtu.c: New test. * gcc.dg/torture/movlle.c: New test. * gcc.dg/torture/movlleu.c: New test. * gcc.dg/torture/movllt.c: New test. * gcc.dg/torture/movlltu.c: New test. * gcc.dg/torture/movlne.c: New test. --- gcc/testsuite/gcc.dg/torture/addieq.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addifeq.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addifge.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addifgt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addifle.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addiflt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addifne.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addige.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addigeu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addigt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addigtu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addile.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addileu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addilt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addiltu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addine.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addleq.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlfeq.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlfge.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlfgt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlfle.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlflt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlfne.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlge.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlgeu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlgt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlgtu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlle.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlleu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addllt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlltu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/addlne.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movieq.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movifeq.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movifge.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movifgt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movifle.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/moviflt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movifne.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movige.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movigeu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movigt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movigtu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movile.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movileu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movilt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/moviltu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movine.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movleq.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlfeq.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlfge.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlfgt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlfle.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlflt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlfne.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlge.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlgeu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlgt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlgtu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlle.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlleu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movllt.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlltu.c | 31 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/movlne.c | 31 +++++++++++++++++++++++++++++++ 64 files changed, 1984 insertions(+) gcc-test-movcc.diff Index: gcc/gcc/testsuite/gcc.dg/torture/addieq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addieq.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +addieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y + z : y; +} + +int +main (void) +{ + if (addieq (-1, -1, 12, 23) != 35) + return 1; + if (addieq (-1, 3, 12, 23) != 12) + return 1; + if (addieq (1, 3, 12, 23) != 12) + return 1; + if (addieq (3, 3, 12, 23) != 35) + return 1; + if (addieq (5, 3, 12, 23) != 12) + return 1; + if (addieq (3, -1, 12, 23) != 12) + return 1; + if (addieq (3, 1, 12, 23) != 12) + return 1; + if (addieq (3, 5, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addifeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addifeq.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +addifeq (double w, double x, int_t y, int_t z) +{ + return w == x ? y + z : y; +} + +int +main (void) +{ + if (addifeq (-1.0, -1.0, 12, 23) != 35) + return 1; + if (addifeq (-1.0, 3.0, 12, 23) != 12) + return 1; + if (addifeq (1.0, 3.0, 12, 23) != 12) + return 1; + if (addifeq (3.0, 3.0, 12, 23) != 35) + return 1; + if (addifeq (5.0, 3.0, 12, 23) != 12) + return 1; + if (addifeq (3.0, -1.0, 12, 23) != 12) + return 1; + if (addifeq (3.0, 1.0, 12, 23) != 12) + return 1; + if (addifeq (3.0, 5.0, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addifge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addifge.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +addifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +int +main (void) +{ + if (addifge (-1.0, -1.0, 12, 23) != 35) + return 1; + if (addifge (-1.0, 3.0, 12, 23) != 12) + return 1; + if (addifge (1.0, 3.0, 12, 23) != 12) + return 1; + if (addifge (3.0, 3.0, 12, 23) != 35) + return 1; + if (addifge (5.0, 3.0, 12, 23) != 35) + return 1; + if (addifge (3.0, -1.0, 12, 23) != 35) + return 1; + if (addifge (3.0, 1.0, 12, 23) != 35) + return 1; + if (addifge (3.0, 5.0, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addifgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addifgt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +addifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +int +main (void) +{ + if (addifgt (-1.0, -1.0, 12, 23) != 12) + return 1; + if (addifgt (-1.0, 3.0, 12, 23) != 12) + return 1; + if (addifgt (1.0, 3.0, 12, 23) != 12) + return 1; + if (addifgt (3.0, 3.0, 12, 23) != 12) + return 1; + if (addifgt (5.0, 3.0, 12, 23) != 35) + return 1; + if (addifgt (3.0, -1.0, 12, 23) != 35) + return 1; + if (addifgt (3.0, 1.0, 12, 23) != 35) + return 1; + if (addifgt (3.0, 5.0, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addifle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addifle.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +addifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +int +main (void) +{ + if (addifle (-1.0, -1.0, 12, 23) != 35) + return 1; + if (addifle (-1.0, 3.0, 12, 23) != 35) + return 1; + if (addifle (1.0, 3.0, 12, 23) != 35) + return 1; + if (addifle (3.0, 3.0, 12, 23) != 35) + return 1; + if (addifle (5.0, 3.0, 12, 23) != 12) + return 1; + if (addifle (3.0, -1.0, 12, 23) != 12) + return 1; + if (addifle (3.0, 1.0, 12, 23) != 12) + return 1; + if (addifle (3.0, 5.0, 12, 23) != 35) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addiflt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addiflt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +addiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +int +main (void) +{ + if (addiflt (-1.0, -1.0, 12, 23) != 12) + return 1; + if (addiflt (-1.0, 3.0, 12, 23) != 35) + return 1; + if (addiflt (1.0, 3.0, 12, 23) != 35) + return 1; + if (addiflt (3.0, 3.0, 12, 23) != 12) + return 1; + if (addiflt (5.0, 3.0, 12, 23) != 12) + return 1; + if (addiflt (3.0, -1.0, 12, 23) != 12) + return 1; + if (addiflt (3.0, 1.0, 12, 23) != 12) + return 1; + if (addiflt (3.0, 5.0, 12, 23) != 35) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addifne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addifne.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +addifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y + z : y; +} + +int +main (void) +{ + if (addifne (-1.0, -1.0, 12, 23) != 12) + return 1; + if (addifne (-1.0, 3.0, 12, 23) != 35) + return 1; + if (addifne (1.0, 3.0, 12, 23) != 35) + return 1; + if (addifne (3.0, 3.0, 12, 23) != 12) + return 1; + if (addifne (5.0, 3.0, 12, 23) != 35) + return 1; + if (addifne (3.0, -1.0, 12, 23) != 35) + return 1; + if (addifne (3.0, 1.0, 12, 23) != 35) + return 1; + if (addifne (3.0, 5.0, 12, 23) != 35) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addige.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addige.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +addige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +int +main (void) +{ + if (addige (-1, -1, 12, 23) != 35) + return 1; + if (addige (-1, 3, 12, 23) != 12) + return 1; + if (addige (1, 3, 12, 23) != 12) + return 1; + if (addige (3, 3, 12, 23) != 35) + return 1; + if (addige (5, 3, 12, 23) != 35) + return 1; + if (addige (3, -1, 12, 23) != 35) + return 1; + if (addige (3, 1, 12, 23) != 35) + return 1; + if (addige (3, 5, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addigeu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addigeu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned int int_t; + +__attribute__ ((noinline)) int_t +addigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +int +main (void) +{ + if (addigeu (-1, -1, 12, 23) != 35) + return 1; + if (addigeu (-1, 3, 12, 23) != 35) + return 1; + if (addigeu (1, 3, 12, 23) != 12) + return 1; + if (addigeu (3, 3, 12, 23) != 35) + return 1; + if (addigeu (5, 3, 12, 23) != 35) + return 1; + if (addigeu (3, -1, 12, 23) != 12) + return 1; + if (addigeu (3, 1, 12, 23) != 35) + return 1; + if (addigeu (3, 5, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addigt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addigt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +addigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +int +main (void) +{ + if (addigt (-1, -1, 12, 23) != 12) + return 1; + if (addigt (-1, 3, 12, 23) != 12) + return 1; + if (addigt (1, 3, 12, 23) != 12) + return 1; + if (addigt (3, 3, 12, 23) != 12) + return 1; + if (addigt (5, 3, 12, 23) != 35) + return 1; + if (addigt (3, -1, 12, 23) != 35) + return 1; + if (addigt (3, 1, 12, 23) != 35) + return 1; + if (addigt (3, 5, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addigtu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addigtu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned int int_t; + +__attribute__ ((noinline)) int_t +addigtu (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +int +main (void) +{ + if (addigtu (-1, -1, 12, 23) != 12) + return 1; + if (addigtu (-1, 3, 12, 23) != 35) + return 1; + if (addigtu (1, 3, 12, 23) != 12) + return 1; + if (addigtu (3, 3, 12, 23) != 12) + return 1; + if (addigtu (5, 3, 12, 23) != 35) + return 1; + if (addigtu (3, -1, 12, 23) != 12) + return 1; + if (addigtu (3, 1, 12, 23) != 35) + return 1; + if (addigtu (3, 5, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addile.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addile.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +addile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +int +main (void) +{ + if (addile (-1, -1, 12, 23) != 35) + return 1; + if (addile (-1, 3, 12, 23) != 35) + return 1; + if (addile (1, 3, 12, 23) != 35) + return 1; + if (addile (3, 3, 12, 23) != 35) + return 1; + if (addile (5, 3, 12, 23) != 12) + return 1; + if (addile (3, -1, 12, 23) != 12) + return 1; + if (addile (3, 1, 12, 23) != 12) + return 1; + if (addile (3, 5, 12, 23) != 35) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addileu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addileu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned int int_t; + +__attribute__ ((noinline)) int_t +addileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +int +main (void) +{ + if (addileu (-1, -1, 12, 23) != 35) + return 1; + if (addileu (-1, 3, 12, 23) != 12) + return 1; + if (addileu (1, 3, 12, 23) != 35) + return 1; + if (addileu (3, 3, 12, 23) != 35) + return 1; + if (addileu (5, 3, 12, 23) != 12) + return 1; + if (addileu (3, -1, 12, 23) != 35) + return 1; + if (addileu (3, 1, 12, 23) != 12) + return 1; + if (addileu (3, 5, 12, 23) != 35) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addilt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addilt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +addilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +int +main (void) +{ + if (addilt (-1, -1, 12, 23) != 12) + return 1; + if (addilt (-1, 3, 12, 23) != 35) + return 1; + if (addilt (1, 3, 12, 23) != 35) + return 1; + if (addilt (3, 3, 12, 23) != 12) + return 1; + if (addilt (5, 3, 12, 23) != 12) + return 1; + if (addilt (3, -1, 12, 23) != 12) + return 1; + if (addilt (3, 1, 12, 23) != 12) + return 1; + if (addilt (3, 5, 12, 23) != 35) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addiltu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addiltu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned int int_t; + +__attribute__ ((noinline)) int_t +addiltu (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +int +main (void) +{ + if (addiltu (-1, -1, 12, 23) != 12) + return 1; + if (addiltu (-1, 3, 12, 23) != 12) + return 1; + if (addiltu (1, 3, 12, 23) != 35) + return 1; + if (addiltu (3, 3, 12, 23) != 12) + return 1; + if (addiltu (5, 3, 12, 23) != 12) + return 1; + if (addiltu (3, -1, 12, 23) != 35) + return 1; + if (addiltu (3, 1, 12, 23) != 12) + return 1; + if (addiltu (3, 5, 12, 23) != 35) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addine.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addine.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +addine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y + z : y; +} + +int +main (void) +{ + if (addine (-1, -1, 12, 23) != 12) + return 1; + if (addine (-1, 3, 12, 23) != 35) + return 1; + if (addine (1, 3, 12, 23) != 35) + return 1; + if (addine (3, 3, 12, 23) != 12) + return 1; + if (addine (5, 3, 12, 23) != 35) + return 1; + if (addine (3, -1, 12, 23) != 35) + return 1; + if (addine (3, 1, 12, 23) != 35) + return 1; + if (addine (3, 5, 12, 23) != 35) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addleq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addleq.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +addleq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y + z : y; +} + +int +main (void) +{ + if (addleq (-1L, -1L, 12L, 23L) != 35L) + return 1; + if (addleq (-1L, 3L, 12L, 23L) != 12L) + return 1; + if (addleq (1L, 3L, 12L, 23L) != 12L) + return 1; + if (addleq (3L, 3L, 12L, 23L) != 35L) + return 1; + if (addleq (5L, 3L, 12L, 23L) != 12L) + return 1; + if (addleq (3L, -1L, 12L, 23L) != 12L) + return 1; + if (addleq (3L, 1L, 12L, 23L) != 12L) + return 1; + if (addleq (3L, 5L, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlfeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlfeq.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +addlfeq (double w, double x, int_t y, int_t z) +{ + return w == x ? y + z : y; +} + +int +main (void) +{ + if (addlfeq (-1.0, -1.0, 12L, 23L) != 35L) + return 1; + if (addlfeq (-1.0, 3.0, 12L, 23L) != 12L) + return 1; + if (addlfeq (1.0, 3.0, 12L, 23L) != 12L) + return 1; + if (addlfeq (3.0, 3.0, 12L, 23L) != 35L) + return 1; + if (addlfeq (5.0, 3.0, 12L, 23L) != 12L) + return 1; + if (addlfeq (3.0, -1.0, 12L, 23L) != 12L) + return 1; + if (addlfeq (3.0, 1.0, 12L, 23L) != 12L) + return 1; + if (addlfeq (3.0, 5.0, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlfge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlfge.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +addlfge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +int +main (void) +{ + if (addlfge (-1.0, -1.0, 12L, 23L) != 35L) + return 1; + if (addlfge (-1.0, 3.0, 12L, 23L) != 12L) + return 1; + if (addlfge (1.0, 3.0, 12L, 23L) != 12L) + return 1; + if (addlfge (3.0, 3.0, 12L, 23L) != 35L) + return 1; + if (addlfge (5.0, 3.0, 12L, 23L) != 35L) + return 1; + if (addlfge (3.0, -1.0, 12L, 23L) != 35L) + return 1; + if (addlfge (3.0, 1.0, 12L, 23L) != 35L) + return 1; + if (addlfge (3.0, 5.0, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlfgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlfgt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +addlfgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +int +main (void) +{ + if (addlfgt (-1.0, -1.0, 12L, 23L) != 12L) + return 1; + if (addlfgt (-1.0, 3.0, 12L, 23L) != 12L) + return 1; + if (addlfgt (1.0, 3.0, 12L, 23L) != 12L) + return 1; + if (addlfgt (3.0, 3.0, 12L, 23L) != 12L) + return 1; + if (addlfgt (5.0, 3.0, 12L, 23L) != 35L) + return 1; + if (addlfgt (3.0, -1.0, 12L, 23L) != 35L) + return 1; + if (addlfgt (3.0, 1.0, 12L, 23L) != 35L) + return 1; + if (addlfgt (3.0, 5.0, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlfle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlfle.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +addlfle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +int +main (void) +{ + if (addlfle (-1.0, -1.0, 12L, 23L) != 35L) + return 1; + if (addlfle (-1.0, 3.0, 12L, 23L) != 35L) + return 1; + if (addlfle (1.0, 3.0, 12L, 23L) != 35L) + return 1; + if (addlfle (3.0, 3.0, 12L, 23L) != 35L) + return 1; + if (addlfle (5.0, 3.0, 12L, 23L) != 12L) + return 1; + if (addlfle (3.0, -1.0, 12L, 23L) != 12L) + return 1; + if (addlfle (3.0, 1.0, 12L, 23L) != 12L) + return 1; + if (addlfle (3.0, 5.0, 12L, 23L) != 35L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlflt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlflt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +addlflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +int +main (void) +{ + if (addlflt (-1.0, -1.0, 12L, 23L) != 12L) + return 1; + if (addlflt (-1.0, 3.0, 12L, 23L) != 35L) + return 1; + if (addlflt (1.0, 3.0, 12L, 23L) != 35L) + return 1; + if (addlflt (3.0, 3.0, 12L, 23L) != 12L) + return 1; + if (addlflt (5.0, 3.0, 12L, 23L) != 12L) + return 1; + if (addlflt (3.0, -1.0, 12L, 23L) != 12L) + return 1; + if (addlflt (3.0, 1.0, 12L, 23L) != 12L) + return 1; + if (addlflt (3.0, 5.0, 12L, 23L) != 35L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlfne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlfne.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +addlfne (double w, double x, int_t y, int_t z) +{ + return w != x ? y + z : y; +} + +int +main (void) +{ + if (addlfne (-1.0, -1.0, 12L, 23L) != 12L) + return 1; + if (addlfne (-1.0, 3.0, 12L, 23L) != 35L) + return 1; + if (addlfne (1.0, 3.0, 12L, 23L) != 35L) + return 1; + if (addlfne (3.0, 3.0, 12L, 23L) != 12L) + return 1; + if (addlfne (5.0, 3.0, 12L, 23L) != 35L) + return 1; + if (addlfne (3.0, -1.0, 12L, 23L) != 35L) + return 1; + if (addlfne (3.0, 1.0, 12L, 23L) != 35L) + return 1; + if (addlfne (3.0, 5.0, 12L, 23L) != 35L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlge.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +addlge (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +int +main (void) +{ + if (addlge (-1L, -1L, 12L, 23L) != 35L) + return 1; + if (addlge (-1L, 3L, 12L, 23L) != 12L) + return 1; + if (addlge (1L, 3L, 12L, 23L) != 12L) + return 1; + if (addlge (3L, 3L, 12L, 23L) != 35L) + return 1; + if (addlge (5L, 3L, 12L, 23L) != 35L) + return 1; + if (addlge (3L, -1L, 12L, 23L) != 35L) + return 1; + if (addlge (3L, 1L, 12L, 23L) != 35L) + return 1; + if (addlge (3L, 5L, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlgeu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlgeu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned long int_t; + +__attribute__ ((noinline)) int_t +addlgeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +int +main (void) +{ + if (addlgeu (-1L, -1L, 12L, 23L) != 35L) + return 1; + if (addlgeu (-1L, 3L, 12L, 23L) != 35L) + return 1; + if (addlgeu (1L, 3L, 12L, 23L) != 12L) + return 1; + if (addlgeu (3L, 3L, 12L, 23L) != 35L) + return 1; + if (addlgeu (5L, 3L, 12L, 23L) != 35L) + return 1; + if (addlgeu (3L, -1L, 12L, 23L) != 12L) + return 1; + if (addlgeu (3L, 1L, 12L, 23L) != 35L) + return 1; + if (addlgeu (3L, 5L, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlgt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +addlgt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +int +main (void) +{ + if (addlgt (-1L, -1L, 12L, 23L) != 12L) + return 1; + if (addlgt (-1L, 3L, 12L, 23L) != 12L) + return 1; + if (addlgt (1L, 3L, 12L, 23L) != 12L) + return 1; + if (addlgt (3L, 3L, 12L, 23L) != 12L) + return 1; + if (addlgt (5L, 3L, 12L, 23L) != 35L) + return 1; + if (addlgt (3L, -1L, 12L, 23L) != 35L) + return 1; + if (addlgt (3L, 1L, 12L, 23L) != 35L) + return 1; + if (addlgt (3L, 5L, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlgtu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlgtu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned long int_t; + +__attribute__ ((noinline)) int_t +addlgtu (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +int +main (void) +{ + if (addlgtu (-1L, -1L, 12L, 23L) != 12L) + return 1; + if (addlgtu (-1L, 3L, 12L, 23L) != 35L) + return 1; + if (addlgtu (1L, 3L, 12L, 23L) != 12L) + return 1; + if (addlgtu (3L, 3L, 12L, 23L) != 12L) + return 1; + if (addlgtu (5L, 3L, 12L, 23L) != 35L) + return 1; + if (addlgtu (3L, -1L, 12L, 23L) != 12L) + return 1; + if (addlgtu (3L, 1L, 12L, 23L) != 35L) + return 1; + if (addlgtu (3L, 5L, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlle.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +addlle (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +int +main (void) +{ + if (addlle (-1L, -1L, 12L, 23L) != 35L) + return 1; + if (addlle (-1L, 3L, 12L, 23L) != 35L) + return 1; + if (addlle (1L, 3L, 12L, 23L) != 35L) + return 1; + if (addlle (3L, 3L, 12L, 23L) != 35L) + return 1; + if (addlle (5L, 3L, 12L, 23L) != 12L) + return 1; + if (addlle (3L, -1L, 12L, 23L) != 12L) + return 1; + if (addlle (3L, 1L, 12L, 23L) != 12L) + return 1; + if (addlle (3L, 5L, 12L, 23L) != 35L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlleu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlleu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned long int_t; + +__attribute__ ((noinline)) int_t +addlleu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +int +main (void) +{ + if (addlleu (-1L, -1L, 12L, 23L) != 35L) + return 1; + if (addlleu (-1L, 3L, 12L, 23L) != 12L) + return 1; + if (addlleu (1L, 3L, 12L, 23L) != 35L) + return 1; + if (addlleu (3L, 3L, 12L, 23L) != 35L) + return 1; + if (addlleu (5L, 3L, 12L, 23L) != 12L) + return 1; + if (addlleu (3L, -1L, 12L, 23L) != 35L) + return 1; + if (addlleu (3L, 1L, 12L, 23L) != 12L) + return 1; + if (addlleu (3L, 5L, 12L, 23L) != 35L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addllt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addllt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +addllt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +int +main (void) +{ + if (addllt (-1L, -1L, 12L, 23L) != 12L) + return 1; + if (addllt (-1L, 3L, 12L, 23L) != 35L) + return 1; + if (addllt (1L, 3L, 12L, 23L) != 35L) + return 1; + if (addllt (3L, 3L, 12L, 23L) != 12L) + return 1; + if (addllt (5L, 3L, 12L, 23L) != 12L) + return 1; + if (addllt (3L, -1L, 12L, 23L) != 12L) + return 1; + if (addllt (3L, 1L, 12L, 23L) != 12L) + return 1; + if (addllt (3L, 5L, 12L, 23L) != 35L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlltu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlltu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned long int_t; + +__attribute__ ((noinline)) int_t +addlltu (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +int +main (void) +{ + if (addlltu (-1L, -1L, 12L, 23L) != 12L) + return 1; + if (addlltu (-1L, 3L, 12L, 23L) != 12L) + return 1; + if (addlltu (1L, 3L, 12L, 23L) != 35L) + return 1; + if (addlltu (3L, 3L, 12L, 23L) != 12L) + return 1; + if (addlltu (5L, 3L, 12L, 23L) != 12L) + return 1; + if (addlltu (3L, -1L, 12L, 23L) != 35L) + return 1; + if (addlltu (3L, 1L, 12L, 23L) != 12L) + return 1; + if (addlltu (3L, 5L, 12L, 23L) != 35L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/addlne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/addlne.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +addlne (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y + z : y; +} + +int +main (void) +{ + if (addlne (-1L, -1L, 12L, 23L) != 12L) + return 1; + if (addlne (-1L, 3L, 12L, 23L) != 35L) + return 1; + if (addlne (1L, 3L, 12L, 23L) != 35L) + return 1; + if (addlne (3L, 3L, 12L, 23L) != 12L) + return 1; + if (addlne (5L, 3L, 12L, 23L) != 35L) + return 1; + if (addlne (3L, -1L, 12L, 23L) != 35L) + return 1; + if (addlne (3L, 1L, 12L, 23L) != 35L) + return 1; + if (addlne (3L, 5L, 12L, 23L) != 35L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movieq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movieq.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +movieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +int +main (void) +{ + if (movieq (-1, -1, 12, 23) != 12) + return 1; + if (movieq (-1, 3, 12, 23) != 23) + return 1; + if (movieq (1, 3, 12, 23) != 23) + return 1; + if (movieq (3, 3, 12, 23) != 12) + return 1; + if (movieq (5, 3, 12, 23) != 23) + return 1; + if (movieq (3, -1, 12, 23) != 23) + return 1; + if (movieq (3, 1, 12, 23) != 23) + return 1; + if (movieq (3, 5, 12, 23) != 23) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movifeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movifeq.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +movifeq (double w, double x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +int +main (void) +{ + if (movifeq (-1.0, -1.0, 12, 23) != 12) + return 1; + if (movifeq (-1.0, 3.0, 12, 23) != 23) + return 1; + if (movifeq (1.0, 3.0, 12, 23) != 23) + return 1; + if (movifeq (3.0, 3.0, 12, 23) != 12) + return 1; + if (movifeq (5.0, 3.0, 12, 23) != 23) + return 1; + if (movifeq (3.0, -1.0, 12, 23) != 23) + return 1; + if (movifeq (3.0, 1.0, 12, 23) != 23) + return 1; + if (movifeq (3.0, 5.0, 12, 23) != 23) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movifge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movifge.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +movifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +int +main (void) +{ + if (movifge (-1.0, -1.0, 12, 23) != 12) + return 1; + if (movifge (-1.0, 3.0, 12, 23) != 23) + return 1; + if (movifge (1.0, 3.0, 12, 23) != 23) + return 1; + if (movifge (3.0, 3.0, 12, 23) != 12) + return 1; + if (movifge (5.0, 3.0, 12, 23) != 12) + return 1; + if (movifge (3.0, -1.0, 12, 23) != 12) + return 1; + if (movifge (3.0, 1.0, 12, 23) != 12) + return 1; + if (movifge (3.0, 5.0, 12, 23) != 23) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movifgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movifgt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +movifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +int +main (void) +{ + if (movifgt (-1.0, -1.0, 12, 23) != 23) + return 1; + if (movifgt (-1.0, 3.0, 12, 23) != 23) + return 1; + if (movifgt (1.0, 3.0, 12, 23) != 23) + return 1; + if (movifgt (3.0, 3.0, 12, 23) != 23) + return 1; + if (movifgt (5.0, 3.0, 12, 23) != 12) + return 1; + if (movifgt (3.0, -1.0, 12, 23) != 12) + return 1; + if (movifgt (3.0, 1.0, 12, 23) != 12) + return 1; + if (movifgt (3.0, 5.0, 12, 23) != 23) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movifle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movifle.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +movifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +int +main (void) +{ + if (movifle (-1.0, -1.0, 12, 23) != 12) + return 1; + if (movifle (-1.0, 3.0, 12, 23) != 12) + return 1; + if (movifle (1.0, 3.0, 12, 23) != 12) + return 1; + if (movifle (3.0, 3.0, 12, 23) != 12) + return 1; + if (movifle (5.0, 3.0, 12, 23) != 23) + return 1; + if (movifle (3.0, -1.0, 12, 23) != 23) + return 1; + if (movifle (3.0, 1.0, 12, 23) != 23) + return 1; + if (movifle (3.0, 5.0, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/moviflt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/moviflt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +moviflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +int +main (void) +{ + if (moviflt (-1.0, -1.0, 12, 23) != 23) + return 1; + if (moviflt (-1.0, 3.0, 12, 23) != 12) + return 1; + if (moviflt (1.0, 3.0, 12, 23) != 12) + return 1; + if (moviflt (3.0, 3.0, 12, 23) != 23) + return 1; + if (moviflt (5.0, 3.0, 12, 23) != 23) + return 1; + if (moviflt (3.0, -1.0, 12, 23) != 23) + return 1; + if (moviflt (3.0, 1.0, 12, 23) != 23) + return 1; + if (moviflt (3.0, 5.0, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movifne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movifne.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +movifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +int +main (void) +{ + if (movifne (-1.0, -1.0, 12, 23) != 23) + return 1; + if (movifne (-1.0, 3.0, 12, 23) != 12) + return 1; + if (movifne (1.0, 3.0, 12, 23) != 12) + return 1; + if (movifne (3.0, 3.0, 12, 23) != 23) + return 1; + if (movifne (5.0, 3.0, 12, 23) != 12) + return 1; + if (movifne (3.0, -1.0, 12, 23) != 12) + return 1; + if (movifne (3.0, 1.0, 12, 23) != 12) + return 1; + if (movifne (3.0, 5.0, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movige.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movige.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +movige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +int +main (void) +{ + if (movige (-1, -1, 12, 23) != 12) + return 1; + if (movige (-1, 3, 12, 23) != 23) + return 1; + if (movige (1, 3, 12, 23) != 23) + return 1; + if (movige (3, 3, 12, 23) != 12) + return 1; + if (movige (5, 3, 12, 23) != 12) + return 1; + if (movige (3, -1, 12, 23) != 12) + return 1; + if (movige (3, 1, 12, 23) != 12) + return 1; + if (movige (3, 5, 12, 23) != 23) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movigeu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movigeu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned int int_t; + +__attribute__ ((noinline)) int_t +movigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +int +main (void) +{ + if (movigeu (-1, -1, 12, 23) != 12) + return 1; + if (movigeu (-1, 3, 12, 23) != 12) + return 1; + if (movigeu (1, 3, 12, 23) != 23) + return 1; + if (movigeu (3, 3, 12, 23) != 12) + return 1; + if (movigeu (5, 3, 12, 23) != 12) + return 1; + if (movigeu (3, -1, 12, 23) != 23) + return 1; + if (movigeu (3, 1, 12, 23) != 12) + return 1; + if (movigeu (3, 5, 12, 23) != 23) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movigt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movigt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +movigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +int +main (void) +{ + if (movigt (-1, -1, 12, 23) != 23) + return 1; + if (movigt (-1, 3, 12, 23) != 23) + return 1; + if (movigt (1, 3, 12, 23) != 23) + return 1; + if (movigt (3, 3, 12, 23) != 23) + return 1; + if (movigt (5, 3, 12, 23) != 12) + return 1; + if (movigt (3, -1, 12, 23) != 12) + return 1; + if (movigt (3, 1, 12, 23) != 12) + return 1; + if (movigt (3, 5, 12, 23) != 23) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movigtu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movigtu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned int int_t; + +__attribute__ ((noinline)) int_t +movigtu (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +int +main (void) +{ + if (movigtu (-1, -1, 12, 23) != 23) + return 1; + if (movigtu (-1, 3, 12, 23) != 12) + return 1; + if (movigtu (1, 3, 12, 23) != 23) + return 1; + if (movigtu (3, 3, 12, 23) != 23) + return 1; + if (movigtu (5, 3, 12, 23) != 12) + return 1; + if (movigtu (3, -1, 12, 23) != 23) + return 1; + if (movigtu (3, 1, 12, 23) != 12) + return 1; + if (movigtu (3, 5, 12, 23) != 23) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movile.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movile.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +movile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +int +main (void) +{ + if (movile (-1, -1, 12, 23) != 12) + return 1; + if (movile (-1, 3, 12, 23) != 12) + return 1; + if (movile (1, 3, 12, 23) != 12) + return 1; + if (movile (3, 3, 12, 23) != 12) + return 1; + if (movile (5, 3, 12, 23) != 23) + return 1; + if (movile (3, -1, 12, 23) != 23) + return 1; + if (movile (3, 1, 12, 23) != 23) + return 1; + if (movile (3, 5, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movileu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movileu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned int int_t; + +__attribute__ ((noinline)) int_t +movileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +int +main (void) +{ + if (movileu (-1, -1, 12, 23) != 12) + return 1; + if (movileu (-1, 3, 12, 23) != 23) + return 1; + if (movileu (1, 3, 12, 23) != 12) + return 1; + if (movileu (3, 3, 12, 23) != 12) + return 1; + if (movileu (5, 3, 12, 23) != 23) + return 1; + if (movileu (3, -1, 12, 23) != 12) + return 1; + if (movileu (3, 1, 12, 23) != 23) + return 1; + if (movileu (3, 5, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movilt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movilt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +movilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +int +main (void) +{ + if (movilt (-1, -1, 12, 23) != 23) + return 1; + if (movilt (-1, 3, 12, 23) != 12) + return 1; + if (movilt (1, 3, 12, 23) != 12) + return 1; + if (movilt (3, 3, 12, 23) != 23) + return 1; + if (movilt (5, 3, 12, 23) != 23) + return 1; + if (movilt (3, -1, 12, 23) != 23) + return 1; + if (movilt (3, 1, 12, 23) != 23) + return 1; + if (movilt (3, 5, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/moviltu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/moviltu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned int int_t; + +__attribute__ ((noinline)) int_t +moviltu (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +int +main (void) +{ + if (moviltu (-1, -1, 12, 23) != 23) + return 1; + if (moviltu (-1, 3, 12, 23) != 23) + return 1; + if (moviltu (1, 3, 12, 23) != 12) + return 1; + if (moviltu (3, 3, 12, 23) != 23) + return 1; + if (moviltu (5, 3, 12, 23) != 23) + return 1; + if (moviltu (3, -1, 12, 23) != 12) + return 1; + if (moviltu (3, 1, 12, 23) != 23) + return 1; + if (moviltu (3, 5, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movine.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movine.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef int int_t; + +__attribute__ ((noinline)) int_t +movine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +int +main (void) +{ + if (movine (-1, -1, 12, 23) != 23) + return 1; + if (movine (-1, 3, 12, 23) != 12) + return 1; + if (movine (1, 3, 12, 23) != 12) + return 1; + if (movine (3, 3, 12, 23) != 23) + return 1; + if (movine (5, 3, 12, 23) != 12) + return 1; + if (movine (3, -1, 12, 23) != 12) + return 1; + if (movine (3, 1, 12, 23) != 12) + return 1; + if (movine (3, 5, 12, 23) != 12) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movleq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movleq.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +movleq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +int +main (void) +{ + if (movleq (-1L, -1L, 12L, 23L) != 12L) + return 1; + if (movleq (-1L, 3L, 12L, 23L) != 23L) + return 1; + if (movleq (1L, 3L, 12L, 23L) != 23L) + return 1; + if (movleq (3L, 3L, 12L, 23L) != 12L) + return 1; + if (movleq (5L, 3L, 12L, 23L) != 23L) + return 1; + if (movleq (3L, -1L, 12L, 23L) != 23L) + return 1; + if (movleq (3L, 1L, 12L, 23L) != 23L) + return 1; + if (movleq (3L, 5L, 12L, 23L) != 23L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlfeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlfeq.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +movlfeq (double w, double x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +int +main (void) +{ + if (movlfeq (-1.0, -1.0, 12L, 23L) != 12L) + return 1; + if (movlfeq (-1.0, 3.0, 12L, 23L) != 23L) + return 1; + if (movlfeq (1.0, 3.0, 12L, 23L) != 23L) + return 1; + if (movlfeq (3.0, 3.0, 12L, 23L) != 12L) + return 1; + if (movlfeq (5.0, 3.0, 12L, 23L) != 23L) + return 1; + if (movlfeq (3.0, -1.0, 12L, 23L) != 23L) + return 1; + if (movlfeq (3.0, 1.0, 12L, 23L) != 23L) + return 1; + if (movlfeq (3.0, 5.0, 12L, 23L) != 23L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlfge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlfge.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +movlfge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +int +main (void) +{ + if (movlfge (-1.0, -1.0, 12L, 23L) != 12L) + return 1; + if (movlfge (-1.0, 3.0, 12L, 23L) != 23L) + return 1; + if (movlfge (1.0, 3.0, 12L, 23L) != 23L) + return 1; + if (movlfge (3.0, 3.0, 12L, 23L) != 12L) + return 1; + if (movlfge (5.0, 3.0, 12L, 23L) != 12L) + return 1; + if (movlfge (3.0, -1.0, 12L, 23L) != 12L) + return 1; + if (movlfge (3.0, 1.0, 12L, 23L) != 12L) + return 1; + if (movlfge (3.0, 5.0, 12L, 23L) != 23L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlfgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlfgt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +movlfgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +int +main (void) +{ + if (movlfgt (-1.0, -1.0, 12L, 23L) != 23L) + return 1; + if (movlfgt (-1.0, 3.0, 12L, 23L) != 23L) + return 1; + if (movlfgt (1.0, 3.0, 12L, 23L) != 23L) + return 1; + if (movlfgt (3.0, 3.0, 12L, 23L) != 23L) + return 1; + if (movlfgt (5.0, 3.0, 12L, 23L) != 12L) + return 1; + if (movlfgt (3.0, -1.0, 12L, 23L) != 12L) + return 1; + if (movlfgt (3.0, 1.0, 12L, 23L) != 12L) + return 1; + if (movlfgt (3.0, 5.0, 12L, 23L) != 23L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlfle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlfle.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +movlfle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +int +main (void) +{ + if (movlfle (-1.0, -1.0, 12L, 23L) != 12L) + return 1; + if (movlfle (-1.0, 3.0, 12L, 23L) != 12L) + return 1; + if (movlfle (1.0, 3.0, 12L, 23L) != 12L) + return 1; + if (movlfle (3.0, 3.0, 12L, 23L) != 12L) + return 1; + if (movlfle (5.0, 3.0, 12L, 23L) != 23L) + return 1; + if (movlfle (3.0, -1.0, 12L, 23L) != 23L) + return 1; + if (movlfle (3.0, 1.0, 12L, 23L) != 23L) + return 1; + if (movlfle (3.0, 5.0, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlflt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlflt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +movlflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +int +main (void) +{ + if (movlflt (-1.0, -1.0, 12L, 23L) != 23L) + return 1; + if (movlflt (-1.0, 3.0, 12L, 23L) != 12L) + return 1; + if (movlflt (1.0, 3.0, 12L, 23L) != 12L) + return 1; + if (movlflt (3.0, 3.0, 12L, 23L) != 23L) + return 1; + if (movlflt (5.0, 3.0, 12L, 23L) != 23L) + return 1; + if (movlflt (3.0, -1.0, 12L, 23L) != 23L) + return 1; + if (movlflt (3.0, 1.0, 12L, 23L) != 23L) + return 1; + if (movlflt (3.0, 5.0, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlfne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlfne.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +movlfne (double w, double x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +int +main (void) +{ + if (movlfne (-1.0, -1.0, 12L, 23L) != 23L) + return 1; + if (movlfne (-1.0, 3.0, 12L, 23L) != 12L) + return 1; + if (movlfne (1.0, 3.0, 12L, 23L) != 12L) + return 1; + if (movlfne (3.0, 3.0, 12L, 23L) != 23L) + return 1; + if (movlfne (5.0, 3.0, 12L, 23L) != 12L) + return 1; + if (movlfne (3.0, -1.0, 12L, 23L) != 12L) + return 1; + if (movlfne (3.0, 1.0, 12L, 23L) != 12L) + return 1; + if (movlfne (3.0, 5.0, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlge.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +movlge (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +int +main (void) +{ + if (movlge (-1L, -1L, 12L, 23L) != 12L) + return 1; + if (movlge (-1L, 3L, 12L, 23L) != 23L) + return 1; + if (movlge (1L, 3L, 12L, 23L) != 23L) + return 1; + if (movlge (3L, 3L, 12L, 23L) != 12L) + return 1; + if (movlge (5L, 3L, 12L, 23L) != 12L) + return 1; + if (movlge (3L, -1L, 12L, 23L) != 12L) + return 1; + if (movlge (3L, 1L, 12L, 23L) != 12L) + return 1; + if (movlge (3L, 5L, 12L, 23L) != 23L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlgeu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlgeu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned long int_t; + +__attribute__ ((noinline)) int_t +movlgeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +int +main (void) +{ + if (movlgeu (-1L, -1L, 12L, 23L) != 12L) + return 1; + if (movlgeu (-1L, 3L, 12L, 23L) != 12L) + return 1; + if (movlgeu (1L, 3L, 12L, 23L) != 23L) + return 1; + if (movlgeu (3L, 3L, 12L, 23L) != 12L) + return 1; + if (movlgeu (5L, 3L, 12L, 23L) != 12L) + return 1; + if (movlgeu (3L, -1L, 12L, 23L) != 23L) + return 1; + if (movlgeu (3L, 1L, 12L, 23L) != 12L) + return 1; + if (movlgeu (3L, 5L, 12L, 23L) != 23L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlgt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +movlgt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +int +main (void) +{ + if (movlgt (-1L, -1L, 12L, 23L) != 23L) + return 1; + if (movlgt (-1L, 3L, 12L, 23L) != 23L) + return 1; + if (movlgt (1L, 3L, 12L, 23L) != 23L) + return 1; + if (movlgt (3L, 3L, 12L, 23L) != 23L) + return 1; + if (movlgt (5L, 3L, 12L, 23L) != 12L) + return 1; + if (movlgt (3L, -1L, 12L, 23L) != 12L) + return 1; + if (movlgt (3L, 1L, 12L, 23L) != 12L) + return 1; + if (movlgt (3L, 5L, 12L, 23L) != 23L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlgtu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlgtu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned long int_t; + +__attribute__ ((noinline)) int_t +movlgtu (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +int +main (void) +{ + if (movlgtu (-1L, -1L, 12L, 23L) != 23L) + return 1; + if (movlgtu (-1L, 3L, 12L, 23L) != 12L) + return 1; + if (movlgtu (1L, 3L, 12L, 23L) != 23L) + return 1; + if (movlgtu (3L, 3L, 12L, 23L) != 23L) + return 1; + if (movlgtu (5L, 3L, 12L, 23L) != 12L) + return 1; + if (movlgtu (3L, -1L, 12L, 23L) != 23L) + return 1; + if (movlgtu (3L, 1L, 12L, 23L) != 12L) + return 1; + if (movlgtu (3L, 5L, 12L, 23L) != 23L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlle.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +movlle (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +int +main (void) +{ + if (movlle (-1L, -1L, 12L, 23L) != 12L) + return 1; + if (movlle (-1L, 3L, 12L, 23L) != 12L) + return 1; + if (movlle (1L, 3L, 12L, 23L) != 12L) + return 1; + if (movlle (3L, 3L, 12L, 23L) != 12L) + return 1; + if (movlle (5L, 3L, 12L, 23L) != 23L) + return 1; + if (movlle (3L, -1L, 12L, 23L) != 23L) + return 1; + if (movlle (3L, 1L, 12L, 23L) != 23L) + return 1; + if (movlle (3L, 5L, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlleu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlleu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned long int_t; + +__attribute__ ((noinline)) int_t +movlleu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +int +main (void) +{ + if (movlleu (-1L, -1L, 12L, 23L) != 12L) + return 1; + if (movlleu (-1L, 3L, 12L, 23L) != 23L) + return 1; + if (movlleu (1L, 3L, 12L, 23L) != 12L) + return 1; + if (movlleu (3L, 3L, 12L, 23L) != 12L) + return 1; + if (movlleu (5L, 3L, 12L, 23L) != 23L) + return 1; + if (movlleu (3L, -1L, 12L, 23L) != 12L) + return 1; + if (movlleu (3L, 1L, 12L, 23L) != 23L) + return 1; + if (movlleu (3L, 5L, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movllt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movllt.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +movllt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +int +main (void) +{ + if (movllt (-1L, -1L, 12L, 23L) != 23L) + return 1; + if (movllt (-1L, 3L, 12L, 23L) != 12L) + return 1; + if (movllt (1L, 3L, 12L, 23L) != 12L) + return 1; + if (movllt (3L, 3L, 12L, 23L) != 23L) + return 1; + if (movllt (5L, 3L, 12L, 23L) != 23L) + return 1; + if (movllt (3L, -1L, 12L, 23L) != 23L) + return 1; + if (movllt (3L, 1L, 12L, 23L) != 23L) + return 1; + if (movllt (3L, 5L, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlltu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlltu.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef unsigned long int_t; + +__attribute__ ((noinline)) int_t +movlltu (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +int +main (void) +{ + if (movlltu (-1L, -1L, 12L, 23L) != 23L) + return 1; + if (movlltu (-1L, 3L, 12L, 23L) != 23L) + return 1; + if (movlltu (1L, 3L, 12L, 23L) != 12L) + return 1; + if (movlltu (3L, 3L, 12L, 23L) != 23L) + return 1; + if (movlltu (5L, 3L, 12L, 23L) != 23L) + return 1; + if (movlltu (3L, -1L, 12L, 23L) != 12L) + return 1; + if (movlltu (3L, 1L, 12L, 23L) != 23L) + return 1; + if (movlltu (3L, 5L, 12L, 23L) != 12L) + return 1; + return 0; +} Index: gcc/gcc/testsuite/gcc.dg/torture/movlne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/torture/movlne.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ + +typedef long int_t; + +__attribute__ ((noinline)) int_t +movlne (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +int +main (void) +{ + if (movlne (-1L, -1L, 12L, 23L) != 23L) + return 1; + if (movlne (-1L, 3L, 12L, 23L) != 12L) + return 1; + if (movlne (1L, 3L, 12L, 23L) != 12L) + return 1; + if (movlne (3L, 3L, 12L, 23L) != 23L) + return 1; + if (movlne (5L, 3L, 12L, 23L) != 12L) + return 1; + if (movlne (3L, -1L, 12L, 23L) != 12L) + return 1; + if (movlne (3L, 1L, 12L, 23L) != 12L) + return 1; + if (movlne (3L, 5L, 12L, 23L) != 12L) + return 1; + return 0; +} From patchwork Sun Nov 19 05:35:39 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: 166674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1504812vqn; Sat, 18 Nov 2023 21:36:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnhALSgOcG+ZIRDuhWtiMH0dP5VnWCc2tNDx36RZ4okX4YSnFBOk47Xk7kDfwEOz+8/Faa X-Received: by 2002:a05:6214:500a:b0:66d:4018:da9c with SMTP id jo10-20020a056214500a00b0066d4018da9cmr4662024qvb.9.1700372177013; Sat, 18 Nov 2023 21:36:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372176; cv=pass; d=google.com; s=arc-20160816; b=TT4FU4LXmknEAqLTXnddP9ddXXPVmuhNzz1cJl7r9FN9rHQkFo+byepbXsG/a8NIa6 9lBSDnVhAZDT/Gu//xnxhH7tqUBWaq1FJKg3r9j6Roaff1YQyHLE0ZiedcQ6YX/PJER2 Ze3MY9MQ+vnSCIosi0iGWf57jfMVQ9gCRb9lqynmdQEBQezvDEJBbCKD7bt+DUtTxiqP 51e29ZvRhBaJPIoDv3Vg0DVanWXp2CLXWSDKqcBRl91LpEE7+PyUVVndGPb50ANO0F7L eqeHxoor8V9swQidD3EfJgL+pGLbAKXidkhIO0SI2D3uTtU++68JavjrBnSc1UgIxpjl tlOA== 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=YnpkoN4ZdehIw/GkJ0Yu45d+3jOb6rXtp2G1UE3rWEA=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=nP5KR32+3gF21jTQHx04zZcb6nMXUorx6DY8NJXDpv88Csv9dZQurwIi1Xfzxy8BrY T6xziP6GbzdP4bPVb+dN7+hKqShrqkCJUkzYJaBOVU+jujzWKgWvGsYSgr65wYzLMgU/ IhmRVmB6u1rl1OwD5m+uGTGLzptqWkuHQMEDCXpbW9k6ltaXJEr7nupDyw+7i6XUA8pX G6XCTrr4gRk3WX3NkSh5bDMk4rCAXKC3E2Zhlbqv0GOq4giU080r4kvDbXQQpHt0cBSj spP98R4Bsv5zx306eXwYtrGCDqChhEen5ukCWzBiZUUs/fi0PzIvFDJAOfyHwNK4ADLF V+Tw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=Qg0oHMQp; 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 z3-20020a0cd783000000b00653589bac4fsi4827515qvi.48.2023.11.18.21.36.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:36:16 -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=Qg0oHMQp; 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 294C83857B86 for ; Sun, 19 Nov 2023 05:36:14 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 643953858436 for ; Sun, 19 Nov 2023 05:35:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 643953858436 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 643953858436 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::633 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372149; cv=none; b=PuE4LHxmFWRSPIj8IGz9uuN8f7NJVbDHkeUyH9C7yDiuZGX+BQZBlxPy/6s8Imgd3fx6APud/tQR+GUecfVaXKNF1Wi0kcsy2G8rcpTLap9C0usNVmst2OF/Cu4L4FJlfkU+swg8KB8G1p9wjvbbiLMpbmy0Ai4UdfLm64X+EXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372149; c=relaxed/simple; bh=xlDV5uhn3doKimIoAhIC5qMWublkN5lP0uu38XIC9j4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=t/uD/UN9lOhJY9AFsvUxSmgJr+5ju2chDf/e3c0lbY08W+UPM+BR64JIxmxjyfTfWXfJ8gEtcf/5lDBPyp7h2GS4xQ699z/q/JBBe0rpmmtGFPhF2CEVmAblYqJI4OmE9H2rcIUjcuQomFpwHJ088YL166fCvkiu1Khvepuu/oQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-9c2a0725825so459185566b.2 for ; Sat, 18 Nov 2023 21:35:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372144; x=1700976944; 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=YnpkoN4ZdehIw/GkJ0Yu45d+3jOb6rXtp2G1UE3rWEA=; b=Qg0oHMQpAJNfnWL2+HRwHAEbnQT4mvDbmoXQZJ74Lm/5CxV3r6dWXve8jtEqZcUiGx ytrDime+IsaaXcm6D4mklqF13gor0m/jvjpbnChkO1Pc6MKNzTKGrnS9jT7JqNuo1/zT xdc1BOuK3moBWvYSb8fzGg/h33tgs5j76Y9bT6aT8fYaHGC0J0PaWmPwn2KguZ8CDmWX Cs1xpAEha22hSLBww/tXZbB04pVKwvV1EjveQcK15keni6csUP5RfGriwJmCEgT5C0BP R51LHe8/VLCZ+Ar1WheGDi9y5185EUWfRoWCh3dIQQNwet+MCU0JXpyE/klbrQrUiD/M xj6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372144; x=1700976944; 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=YnpkoN4ZdehIw/GkJ0Yu45d+3jOb6rXtp2G1UE3rWEA=; b=PkhYONTOgXiATfnUdRKrhKlIqPqbCJ3XBY4oeSkt3MDOeraw3Qalua2TWn5/nnve1c VOhepFgVHPNLem7wFJwrdJgW3D+OEjTL/XSwH/MdZkBMCFvMuXGYw9NZ1fOEAibuWL2S 9KIDH4QA/iOjnqQLOlATrA6Zw2P2z6IZkWtoCUTkQdFfdFUnUWi6WwjL3nTLfvPIxcBx R+Xv1+QWhHZjOPDFEj5CbdAAxYsFoHXVA9911rGQxmtvw5FcAf/Pnd+cCtzJRqMO4/Wh N+OZTPYJ9znpZE73tJEX/pmExZia34nLO4BGmRfX0fuKUzT+2Vhrqjvx2HFccYDWR6HV auyA== X-Gm-Message-State: AOJu0Yz3gbcjqaYvCeNweiV3ZI1UVnjZ08b6fW+V7QJsUWvAhVLmANfZ wd5q5YeCA/oHTwGy3qcTheFc2mtSdh/neA/nVxRLjg== X-Received: by 2002:a17:907:a0d0:b0:9dd:30c8:6f33 with SMTP id hw16-20020a170907a0d000b009dd30c86f33mr3258855ejc.57.1700372143291; Sat, 18 Nov 2023 21:35:43 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id f20-20020a17090631d400b0099ce188be7fsm2523237ejf.3.2023.11.18.21.35.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:35:42 -0800 (PST) Date: Sun, 19 Nov 2023 05:35:39 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 02/44] RISC-V/testsuite: Add cases for integer SFB 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=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS, KAM_SHORT, 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: 1782969456137001540 X-GMAIL-MSGID: 1782969456137001540 Verify, for short forward branch targets and the conditional-move operations that already work as expected, that if-conversion triggers via `noce_try_cmove' already at `-mbranch-cost=1' and that extraneous instructions such as SNEZ, etc. are not present in output. Cover all integer relational operations to make sure no corner case escapes. gcc/testsuite/ * gcc.target/riscv/movdieq-sfb.c: New test. * gcc.target/riscv/movdige-sfb.c: New test. * gcc.target/riscv/movdigeu-sfb.c: New test. * gcc.target/riscv/movdigt-sfb.c: New test. * gcc.target/riscv/movdigtu-sfb.c: New test. * gcc.target/riscv/movdile-sfb.c: New test. * gcc.target/riscv/movdileu-sfb.c: New test. * gcc.target/riscv/movdilt-sfb.c: New test. * gcc.target/riscv/movdiltu-sfb.c: New test. * gcc.target/riscv/movdine-sfb.c: New test. * gcc.target/riscv/movsieq-sfb.c: New test. * gcc.target/riscv/movsige-sfb.c: New test. * gcc.target/riscv/movsigeu-sfb.c: New test. * gcc.target/riscv/movsigt-sfb.c: New test. * gcc.target/riscv/movsigtu-sfb.c: New test. * gcc.target/riscv/movsile-sfb.c: New test. * gcc.target/riscv/movsileu-sfb.c: New test. * gcc.target/riscv/movsilt-sfb.c: New test. * gcc.target/riscv/movsiltu-sfb.c: New test. * gcc.target/riscv/movsine-sfb.c: New test. --- gcc/testsuite/gcc.target/riscv/movdieq-sfb.c | 25 +++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdige-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigeu-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigt-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigtu-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdile-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdileu-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdilt-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiltu-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdine-sfb.c | 25 +++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsieq-sfb.c | 25 +++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsige-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigeu-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigt-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigtu-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsile-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsileu-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsilt-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiltu-sfb.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsine-sfb.c | 25 +++++++++++++++++++++++++ 20 files changed, 516 insertions(+) gcc-riscv-test-movcc.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdieq-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdieq-sfb.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect short forward branch assembly like: + + bne a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdige-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdige-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect short forward branch assembly like: + + blt a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bge|bgt|ble|blt)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdigeu-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigeu-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect short forward branch assembly like: + + bltu a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bgeu|bgtu|bleu|bltu)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdigt-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigt-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect short forward branch assembly like: + + ble a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bge|bgt|ble|blt)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdigtu-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigtu-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -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 short forward branch assembly like: + + bleu a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bgeu|bgtu|bleu|bltu)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdile-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdile-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect short forward branch assembly like: + + bgt a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bge|bgt|ble|bgt)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdileu-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdileu-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect short forward branch assembly like: + + bgtu a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bgeu|bgtu|bleu|bltu)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdilt-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdilt-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect short forward branch assembly like: + + bge a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bge|bgt|ble|blt)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdiltu-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiltu-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -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 short forward branch assembly like: + + bgeu a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bgeu|bgtu|bleu|bltu)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdine-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdine-sfb.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect short forward branch assembly like: + + beq a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsieq-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsieq-sfb.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect short forward branch assembly like: + + bne a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsige-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsige-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect short forward branch assembly like: + + blt a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bge|bgt|ble|blt)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsigeu-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigeu-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect short forward branch assembly like: + + bltu a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bgeu|bgtu|bleu|bltu)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsigt-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigt-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect short forward branch assembly like: + + ble a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bgt|ble)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsigtu-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigtu-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -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 short forward branch assembly like: + + bleu a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bgeu|bgtu|bleu|bltu)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsile-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsile-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect short forward branch assembly like: + + bgt a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bge|bgt|ble|blt)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsileu-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsileu-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect short forward branch assembly like: + + bgtu a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bgeu|bgtu|bleu|bltu)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsilt-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsilt-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect short forward branch assembly like: + + bge a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bge|bgt|ble|blt)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiltu-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiltu-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -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 short forward branch assembly like: + + bgeu a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:bgeu|bgtu|bleu|bltu)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsine-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsine-sfb.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect short forward branch assembly like: + + beq a0,a1,1f # movcc + mv a3,a2 +1: + mv a0,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(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ From patchwork Sun Nov 19 05:35:53 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: 166675 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1504851vqn; Sat, 18 Nov 2023 21:36:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIf3bxcb0GkOLHF9PlK9GcvRhE8R/3CEvj07/RTi0ZEoUrpBLDqwzY5SfBgOxejH0dD1kS X-Received: by 2002:a05:622a:44e:b0:403:2877:bc52 with SMTP id o14-20020a05622a044e00b004032877bc52mr4377526qtx.0.1700372188106; Sat, 18 Nov 2023 21:36:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372188; cv=pass; d=google.com; s=arc-20160816; b=f64sjDnGBwMos48Y4Xiw+P7vMAbK3nVOrbBpZjldccNP/n0CQmh2SGBfhH6P094rsI ofKwvdD5Zw8oyFGa97Is2KeGTPTUu2b7qkMrJ0nxHqUrGne/yTDfmhxTfGR8QTEd4QyX QLdCIFV7xRG+2PmWRPJsX4G/uxxzGYp3Ae/fZKd22Zg/LXLfi4dMnj03RwmN27gxrQ2C rukN3NFtVC4uNqPtfPJuo0pf2q+VjFEfZWoAz36jdyjxsOpEwWqKvJQXLHq0i+AOKs7T PATcAJBLEhzYp7V+42JM/+hZDiLm1ZumZIR6P1gVsqx6cjhIMT3+vBrhn7r8eBk7AbMo 2ypA== 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=wH4bu/jKKb89z6Fj83atKeHXx9YC0lCsp8jziKl7lB0=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=W+iwlnd58GgzD8sRM3uWwNGMe4rZM526SL2DXHi3O8JEv1zrQVJ0sjJOArNwKOjL+p MqZwdBclndFuQRS367B/NMJA7SD9f8J4V/CPVld9Sbxp0ytHeoQUQfEF0hiGzcNg8iIX eBvp6rF2aKAnw25e/pH7KMLVfHK9QvX5bRXYf4Gx4my48HJ++9+2y2PO/3r5iQ8SaPMg fSJa2vKTdGtYrT7MhwY5mpnYF79URRhkaKtxOru7NhRgQE39zCZFYEiR6aszwX5LxQOi yX2pwzdGTrHEzjHA4Q/811Fslyngdgx6eAO8W59ssAUxB6da/VTpJ8Jy8W/bwSVAGStm 5nZg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=NJzpjDT3; 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 b22-20020ac85bd6000000b0041cbf262514si5080122qtb.19.2023.11.18.21.36.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:36:28 -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=NJzpjDT3; 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 3E0053858281 for ; Sun, 19 Nov 2023 05:36:23 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id CF11D3858D33 for ; Sun, 19 Nov 2023 05:35:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CF11D3858D33 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 CF11D3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372159; cv=none; b=kKCSiLgNaoHXRmNVuaV5I9/6OHurUXvnnqeDNmZISk+kBKFBGRpy8uPNlRiQx97AzS8rz8+RrExpd/J7vLK7q6cq2sGufBnxh5BfA7Gy2fTUzvXSNY3dGtjVNgVacX5y0ZOm/nKvttteNeVRg0kZpR99Z7LuUri7HSHaoNpcB3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372159; c=relaxed/simple; bh=yrtoFFdKNu2gA+85nWHp15cFAX/pgL2gvqIZC7Tx314=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Ubj+vnfJWD45GMBMrNecuLn6z1Ljk/C8SzzU8AHxrayC2CfNRSPpp3OUvLPiIqtiRRE2joXeb+hGEXou1200DCeWq7/DSfgzJk/z4tR7F19ock3MCpD68WLBXZqF7LgTdgcG2M+EVs7lREJA/VzRIV+l7qSJMKoZsyQhPUlInPM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-9e623356e59so451131766b.0 for ; Sat, 18 Nov 2023 21:35:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372155; x=1700976955; 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=wH4bu/jKKb89z6Fj83atKeHXx9YC0lCsp8jziKl7lB0=; b=NJzpjDT3gDd+G1dCFdOu+9wmrSqoxZDOiLZKq40M4zhF3YI8GqCZnaHMBWgALrO+Pk i4Eal2q748Ef60ImXTG9egazPeejspBbsdGBnPxYQTxPVqMULu94DoD/fnftWfof+pV6 JlVXJOIfMY1dUK/1se1Rx4YPhkPz2bipQHIhZFhUmpoSskxc8Cdb/EYhqPPOPICj9+gD dt2rlWxb3z9Fqnx/yg4lLKKJbxK6eLJJviBs4YFLsvIahu2QL6+hUtr7sWaTmI8HKaBU QNGYsWYieWBySf3T9aWNRJUMDW+NrdVRh0qTyLbosflxCU3XCBFJrtvElZmvIeWVw9U+ utAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372155; x=1700976955; 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=wH4bu/jKKb89z6Fj83atKeHXx9YC0lCsp8jziKl7lB0=; b=PhcCCt9w9MM59m5Onx6O13oMv9SoFfgjWixnWfkt/G4UgCpv33EliR5FG8U+1wdgMI X74bB9eqTPCVNmJs0IttC9ssCRQbmkC0JivqkYi7hguZwsTFIrf2y026rLqSXC7QfcWE N1vXMD6SZGmRG4ofZE3BRxSZxxrk5DjlLjG0AHfKjDlFrSVoKNeFyuOXRVAQga7dJv69 NcZr/SwndfXvwbCYAckSE1wNkc6MEXHB/8sCaVFGIJOLKKBHt2+ryRPjxvf/87OAv1gm PCSkeJzBdx+wmbt1DZP7+ce61XR+qKKuDDGmGQzQi2XrUNanHp5zbf7tMbl2+fMc2v5a R0hg== X-Gm-Message-State: AOJu0YyDUogA5sa/OYUvtZ7epKGxIlCm7jeybcEpD67QZ4y4tDkBkX6i QfPdX9J9f9fVLBQLbLgr+vvgdA+IbWW5ts+68LFoWg== X-Received: by 2002:a17:906:221c:b0:9c7:5a14:ecf2 with SMTP id s28-20020a170906221c00b009c75a14ecf2mr3435615ejs.56.1700372155707; Sat, 18 Nov 2023 21:35:55 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id y20-20020a170906471400b009db53aa4f7bsm2541186ejq.28.2023.11.18.21.35.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:35:55 -0800 (PST) Date: Sun, 19 Nov 2023 05:35:53 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 03/44] RISC-V: Reorder comment on SFB patterns 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=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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: 1782969467301615028 X-GMAIL-MSGID: 1782969467301615028 Our `movcc' expander is no longer specific to short forward branch targets, so move its associated comment accordingly. gcc/ * config/riscv/riscv.md (movcc): Move comment on SFB patterns over to... (*movcc): ... here. --- gcc/config/riscv/riscv.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) gcc-riscv-sfb-comment-move.diff Index: gcc-master/gcc/config/riscv/riscv.md =================================================================== --- gcc-master.orig/gcc/config/riscv/riscv.md +++ gcc-master/gcc/config/riscv/riscv.md @@ -2655,8 +2655,6 @@ [(set_attr "type" "branch") (set_attr "mode" "none")]) -;; Patterns for implementations that optimize short forward branches. - (define_expand "movcc" [(set (match_operand:GPR 0 "register_operand") (if_then_else:GPR (match_operand 1 "comparison_operator") @@ -2671,6 +2669,8 @@ FAIL; }) +;; Patterns for implementations that optimize short forward branches. + (define_insn "*movcc" [(set (match_operand:GPR 0 "register_operand" "=r,r") (if_then_else:GPR From patchwork Sun Nov 19 05:36:03 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: 166676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1504891vqn; Sat, 18 Nov 2023 21:36:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzGwa4qSrHWSoj9a2hZ4n0DPxy0f6Ou/lnIDIqTRPsEb296OR3ahajspadFBnpCtTIp0TA X-Received: by 2002:ac8:4e81:0:b0:41e:2d41:7de2 with SMTP id 1-20020ac84e81000000b0041e2d417de2mr6226969qtp.24.1700372198405; Sat, 18 Nov 2023 21:36:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372198; cv=pass; d=google.com; s=arc-20160816; b=apnOG8cuacar21JEPVOEJODXRyf01ID4rK966d2vf765NpBbstJtNtzAqJPWqg3iz8 DZjK6yGH3nLWyU5LmUe0YNMvF4UHdWYUvcTKRzfhtodc4P57F8mCLXxRkiUENAo12ubI AK4yxm+3qpU6H21Wl4FKWSh8MJCYbPx5J86jF05zgsL4XBo+410b0NpmmavHn0VVrrEn bK8Sx2cGS5xO+od/mW+SGkCw0Tw0sB0WnecP5Gbijp+YWGlFdz829NhnWGg2PlUh0lwW ATFz0vv4t8nxyp2w7Htk9VnPTGpmRSCLmo7W1jZffjtdpx9i5jaKRpLumCJg4sLisXy2 m+lA== 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=SQCJUnl3JVJg6CUD/dwVsRYRkaoWvF+XHNpqJEfPBWE=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=j/8YkvmHlf56/6ePlvL5OV7DPv/ObQeQB0A3P75u7t80SiCM0BkN8X8ewAcS2LjQ01 zHByaR3A9b2Ns4lnoVvFxi/Gxngy5F7FrFJj5UZvnqFGZ/6HV8e2DJQP6MZJkPd9n3Cn pfjQbz8F3P+2Nb4LI5vLjN5FIvZWg5aq1ypgoAySlQcUUMdwJ7zvVHb9wzANlK243GL5 sxacINpVgHOvPI4T8UIubXhrIYp/BxwM5CEjaOO20hr1u505akq+b8L8rF+8/+1eQqc3 kfIumpEKDZN0xhnJ/0EgtwDg5D8QP2u+kuq8wTfzaMmBJkFNcGAqnDSXSXe9+vkPLW/e 1L3w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=KuSApKf0; 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 j13-20020a05622a038d00b0040b4cb9b6f9si5164627qtx.102.2023.11.18.21.36.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:36: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=KuSApKf0; 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 9403B3858037 for ; Sun, 19 Nov 2023 05:36:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 694B43857C4A for ; Sun, 19 Nov 2023 05:36:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 694B43857C4A 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 694B43857C4A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::531 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372168; cv=none; b=IMpIfKfg3HkHiunVF8lrOPHbzruTAduCAPvGQXN1s6QTPdhXcHolcyxiVU5HWbY3LA6gfK8kDwcPeuGEL8NTj+8VPxe3nAbM9RQCbWZzIthlRRbZqucsqjdeLClWBKUseSqujhORM4M5zjD+qcDSEecN2KQFxx1l5MutNemya+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372168; c=relaxed/simple; bh=2jNmEiIBJ2MoV2AR7EWAifyEkhA/M9aOZMAKSxNJXXc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=VTmS1q/5H0J7tsiaAar3/yN/iKB+WQY9/e/zsvJI3/1/mbEu/cTp69pICWoByEN5o4Fz0rzUbxD6y8V+UTvxY1he6+uH7I02cBtVEmQeV3hDpdQvUZqgj32jnqJPEgfsy3X+bwUIOzjcpKs+pbM+MiKmQ7R7B9PL/fMWXB9q+5I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-53e2308198eso4761385a12.1 for ; Sat, 18 Nov 2023 21:36:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372166; x=1700976966; 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=SQCJUnl3JVJg6CUD/dwVsRYRkaoWvF+XHNpqJEfPBWE=; b=KuSApKf0VTzvAk8foPMBzwhJsaBmSKtEq0QABMPBjB9OYFMD0pC9S3hlwPyL41oMDC Ay8rM8Htw9rGwnEDtqrJlwkdvx+MhIeeY4iF3X9dL+XR18Hu9OZjpqGG2WXiQZUXIheX zAYjqNyltFUenCccoY14YFNriZG4aDwYXeAH0wRp5084Q6sGp6WQtv6EVgPPPCZWwXRY YRuhIVX9bHTw46ZKohedVJOg9BV1Xm0pvhvsE8xnsIsb1GZYwQuVtnmTXAsAPlL69LuO mplNUe5R6dMyszLvSZE4eX476vNPoah+uivPE56LeF+O86d8dFqXHzIuLN6lSl8UYdw0 bbYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372166; x=1700976966; 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=SQCJUnl3JVJg6CUD/dwVsRYRkaoWvF+XHNpqJEfPBWE=; b=bYMWml7Ll69fnF1B4ilay3qrxFJ1dwK56HQgKt3/3R3+MIgBtZxY5XMkiQoAgL4r6N +XNGTkXXXcI1UYbwUGIbl1A+QjxF7VAQcYOLsiyr/S8fmonJbCRxnIpNwaRojmVjDRzI a93tu625mlKXVKFPVW/A44sxta0lpdmResUhfZYnFnlA1rfM8Q9TC2cG1XT5Rvd/RWW4 t/FMZXhCFFsiYvs0F0JJozwLi4cXghTc9rvMU8UMeCINhOBojshJbsGivBP1e7VUCp0O FYs6nBOmTX8uGXFqHPkrerqnY88IeM830ZdtCs24kQI5JneW5AJHQtgRvgIEW4G3RrY6 QCKg== X-Gm-Message-State: AOJu0Yx+mouVL9JfxCkq9L0OIIJ8fu2iKZ8Qjv0EQBYE/w0OwwfwawuD xr5ZC9pDfKn3awqM0wGpKm09MddyXfGZvYI7IOEGaA== X-Received: by 2002:a05:6402:14d6:b0:542:f28e:2947 with SMTP id f22-20020a05640214d600b00542f28e2947mr3041719edx.26.1700372166187; Sat, 18 Nov 2023 21:36:06 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id v4-20020aa7d644000000b0053e3d8f1d9fsm2331619edr.67.2023.11.18.21.36.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:36:05 -0800 (PST) Date: Sun, 19 Nov 2023 05:36:03 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 04/44] RISC-V: Sanitise NEED_EQ_NE_P case with `riscv_emit_int_compare' 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.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969478142015561 X-GMAIL-MSGID: 1782969478142015561 For the NEED_EQ_NE_P `riscv_emit_int_compare' is documented to only emit EQ or NE comparisons against zero, however it does not catch incorrect use where a non-equality comparison has been requested and falls through to the general case then. Add a safety guard to catch such a case then. Arguably the NEED_EQ_NE_P case would best be moved into a function of its own, but let's leave it for a separate cleanup. gcc/ * config/riscv/riscv.cc (riscv_emit_int_compare): Bail out if NEED_EQ_NE_P but the comparison is neither EQ nor NE. --- FWIW the structure of code here clearly shows the NEED_EQ_NE_P case has been bolted on as an afterthought rather than how this piece would look if written from scratch right away. Let's defer any further cleanups at this stage of the development cycle though. --- gcc/config/riscv/riscv.cc | 1 + 1 file changed, 1 insertion(+) gcc-riscv-emit-int-compare-need-eq-ne.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -3779,6 +3779,7 @@ riscv_emit_int_compare (enum rtx_code *c *op1 = const0_rtx; return; } + gcc_unreachable (); } if (splittable_const_int_operand (*op1, VOIDmode)) From patchwork Sun Nov 19 05:36:12 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: 166677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1504907vqn; Sat, 18 Nov 2023 21:36:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjiaGJ9k4FpPXHlzvDDWG66OzrXSQut38+TtnTZF5d/umZXW/k9u5n3u3w3H14aI4kp8aN X-Received: by 2002:a05:622a:489:b0:418:134f:17f4 with SMTP id p9-20020a05622a048900b00418134f17f4mr5444991qtx.22.1700372205782; Sat, 18 Nov 2023 21:36:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372205; cv=pass; d=google.com; s=arc-20160816; b=SHvKddPV+lJ8QCO89QM/3w3ae0aj8wkqFGKXSepRKlq2yHqaa6YnJgH/K6/8N2jUSp dK5X0ZPXFXrUemqaxXzQ8V48hiTbeNP+KSzbKm3m4kGBMLDLP8YAz9tcl435/npoqpIG yh8Xfd9KhuQJlBq/LLucYAOJqLqUCjubOWuNOAH6OtfO24JpEgbWnu3Wwo6UVXZMdzIJ brzHpahMQqxAjXH2bRyM1O376H6rD/EywyktkkcV8ij002OgfmDH7v0TwjeBSxH5fmfB 35tNfgmYSWGPs/9cFnCghBK9yAPPC/BBuxxcrQ/rv3LuXXrC8YsrA/1y+wwn5e+MjjmA Mo5g== 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=NXyjd7uqMS4QVcbiOSDFxXtXPOmlk8thxaaP6VwYu9U=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=HyXPzIDN7LpgfXikdyND3DOpmH4jyoptJJTIHi20mo9bWRZjYjSKTaBo1OR/2iyuaf Ig4YTECbRFdyDj4EGpN3XsSxE6/419LXHeYVkMbnXqS7c2b2qhLy4moONIr6OFfrGGl7 c+c0xT0e9ONCtxLhJQI5GhOUFE0fWQlyMyynCjB0TyV0avKbi/qzfsXFzl4vdf8L1I9M +AUF/9tL8Boh3Fyl6VYhi4LzRu/WfHORbhAoMiSUimBpAXY6MixVIPlwU/gHzH+az3RE RucdPjUkG/abSfD8GTB2R8L5UUfWNZ0ifhvBgHZMiagL0jivPWu4bXC5/AkeDqfdos8r G/Nw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=eMoXswgo; 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 b20-20020ac87fd4000000b00418225de9c2si5207210qtk.680.2023.11.18.21.36.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:36:45 -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=eMoXswgo; 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 83F37385783C for ; Sun, 19 Nov 2023 05:36:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 0B89F3857C62 for ; Sun, 19 Nov 2023 05:36:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B89F3857C62 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 0B89F3857C62 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::535 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372177; cv=none; b=eIY9/hHVuHaXwKi0JljTBTulHaaCuCysZUTNuYaFuGQoFVqKX5wAriEox0MJxzJVponC5gkGOcy6vdtRz8r2RPCmmNJp4ul1uBJH9piy7/yvOaLbch02H7n+zsKWtpcrRYbTB6bISalYZV8yoQsmXHz4BNa4Eu8mwBYHhQ2xn6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372177; c=relaxed/simple; bh=hTlpDMu0nzLU1gFomxqwENF0ne8cf06Q+ZUM5m9w0Ww=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=DlRK77Qlf67UQ4kkmc/EpLv9hKj99A/UhGiUll6LkPFUHluohkxfUd1OeXkTqr6Qj6tddgNDt46+SLI2NPgpf3QmoeIFsjPOPtKgpfDfV85NmrYF5iTnhyzyiL9FHhqDIFwJ7tdD2HPTKF3i6hPkQ09XK5Va9KX04AWyc3ENc44= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-54864b675b2so1664510a12.2 for ; Sat, 18 Nov 2023 21:36:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372175; x=1700976975; 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=NXyjd7uqMS4QVcbiOSDFxXtXPOmlk8thxaaP6VwYu9U=; b=eMoXswgof0UmPsMWUFR+fgtJrONQT01X7Zo3cdDEhzZiwnYaP0I6FddvZpU20+JUs8 yjG0EDAcP9TrktCIV6/F+O4D2ZfqEjdOL4h0OcPl5kKok92nYTfTi4cYvw53GAgwK4ii e10Fdo881NOi7LwNesEbUBLKzvm0nug/rJHYLaVpDIJrpu4uqtwE7v++VE1UjyZrzyWa AcoiBIhevoCLc9aO1btsBxNNxk80r7MSLqc0VCcqzIfI4WiEA6VYaZWKa3ZQB8l8YrCw eVuqIfu5qOK+ALk0Ve+V4tAERJPPeZRqVSAegONCAJ2bnJw2JefKk2KGoLoBMOVGX93w fkiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372175; x=1700976975; 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=NXyjd7uqMS4QVcbiOSDFxXtXPOmlk8thxaaP6VwYu9U=; b=EXQcTqbeFDkAI9sWP884DJB4hN4Ff4RgiGCRrAN6w8kXrIizn/fq628DJeTvKy6pQ5 VdnHaXAVq2ZXHcKxo5UEfYLHwv7OdWGp+Lpydj4EK2Eu1IaXzLfxGxRmBUFHF+kX7Ra/ J1D5Q7RMbfLgyjfAFcZDIyltyW7c3mlSL1MVwZ2A6QzS84H3SjBzkAkFsYE1mvyaH5uB N7j34K6gercFf7C8StaNR10G5D9cjaUFjvibgvCEpHX9IXjdiuxJ8WvYiWMYWXnFcN4V x9gsOX9H0CSobAtSf8wcAmk6F1yTPeaVKxYGHBDmC8S9yHEIU0Fdxzw86qBf5Z7E0XBu X4qw== X-Gm-Message-State: AOJu0Yyip4ZB2IP5AhqKxdqjn/oeJ2vyWnmBAZu6ApX2yZPomNbjhkea tIP8PMBX+9il4Eatli1WvUbZTgP6jwvXz0BsPTn5BQ== X-Received: by 2002:aa7:c249:0:b0:540:7e8:dd4f with SMTP id y9-20020aa7c249000000b0054007e8dd4fmr3269334edo.20.1700372174840; Sat, 18 Nov 2023 21:36:14 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id h6-20020aa7de06000000b005489ecd06f6sm340799edv.38.2023.11.18.21.36.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:36:14 -0800 (PST) Date: Sun, 19 Nov 2023 05:36:12 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 05/44] RISC-V: Fix `mode' usage in `riscv_expand_conditional_move' 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.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969486125365463 X-GMAIL-MSGID: 1782969486125365463 In `riscv_expand_conditional_move' `mode' is initialized right away from `GET_MODE (dest)', so remove needless references that refrain from using the local variable. gcc/ * config/riscv/riscv.cc (riscv_expand_conditional_move): Use `mode' for `GET_MODE (dest)' throughout. --- gcc/config/riscv/riscv.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) gcc-riscv-expand-conditional-move-mode-dest.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -3999,8 +3999,8 @@ riscv_expand_conditional_move (rtx dest, arm of the conditional move. That allows us to support more cases for extensions which are more general than SFB. But does mean we need to force CONS into a register at this point. */ - cons = force_reg (GET_MODE (dest), cons); - emit_insn (gen_rtx_SET (dest, gen_rtx_IF_THEN_ELSE (GET_MODE (dest), + cons = force_reg (mode, cons); + emit_insn (gen_rtx_SET (dest, gen_rtx_IF_THEN_ELSE (mode, cond, cons, alt))); return true; } From patchwork Sun Nov 19 05:36: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: 166678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1504965vqn; Sat, 18 Nov 2023 21:37:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoFyRALkivl7IoaeeAY627Uv1R1VQ0jHQqINr8q2ezIexouE8e1t4qW0zcWwgjWxYupoDY X-Received: by 2002:ac8:7d41:0:b0:41e:28d1:c8ff with SMTP id h1-20020ac87d41000000b0041e28d1c8ffmr6609432qtb.51.1700372221040; Sat, 18 Nov 2023 21:37:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372221; cv=pass; d=google.com; s=arc-20160816; b=IUwYgZOWwQY08aHhbjWD24TeRGOIhbknI7MaM/NFMS58bDBtGsxrAOaaWMeJK7hMwn pPYyl+16XygvMAXiWuZAs64+GLRowTr5J7bn96Oy5KcYcgQcv238WfxuGNeWnbw2WrIc ekaXdrSkjZoe6dFXyznOzFSBY3Z0CYjZZaL+5v83VTSTXR7pMA+3FWFM1A61WWmPchii yssqXBbL5ucuh9Q0wAlsRUe2RgnWQBEpxoH7ohiIKasW4CzvDf4P9KMXgTjD7lgtcyCR dREw6buJ+7HS/qvbnyWUp+RgvQUkjcgpDMJaNEAE7C77FkjWuHjOlIh6TDBY+8wI2D36 Ds+w== 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=S0kJ1UpnSfG0cSSILBX3Dq3Nl+sb6OqK64wHhs9sRyI=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=pLm+OgfTyDwkPjgPXsbG1kPK4ngOeKkrwXNR19Plb9oLrNt8rR464PvgKuX1cTSivY X7S1Bm3wI4h97CgQUwgGio8Y4Ndmxvmfj9BzoJpkCfv2uIR9uz2qtxo1jw9qEICd3e2g HDfiyJA+aGYxlaqBa0C7sa3628FbzPunP6C2WpfuhDx7FIGDSKVgH+3KG6/RLo3WHEaA 5ZkkqffJHzq6OOUo/YZoiGd/MRmdg2kJn3GFai5Y/dTcddHcNAq5Fq3QVw4NY3TJvfp9 tf70sU6A1V58/SZYsoLSzbCSAAALXciXlPd2V+nQURBZweQhGMZA2bX9v8GFjyoZgKqv VTtg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=ezbaSwtM; 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 w16-20020ac857d0000000b00419c0bf4c1bsi4883432qta.375.2023.11.18.21.37.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:37:01 -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=ezbaSwtM; 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 6734B385B516 for ; Sun, 19 Nov 2023 05:36:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id 4B2F938582B8 for ; Sun, 19 Nov 2023 05:36:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B2F938582B8 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 4B2F938582B8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372186; cv=none; b=Y7kbCbrQiyulBYWkvFXDU2onQvo+eLthacrsUXPFuXWWUyRKEDXUekKmiAZPwMcaii/uIj+Pv+ccSO9zIzAqaaXv88YhKp/gBI6iUfnvu5msHGaR+Co3jhDjV5ZmTRJDvlwvnypwJi8WpuT8DAT+gNEu7GcKMJ7oqh+OTcEgsfs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372186; c=relaxed/simple; bh=yD9jdfUy8rBfPIbhqljuiqkZxZxe/Rn4uaxsQRsGzP4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=TyfZICOPKa2NyvR/MiIgNrx0nVVIgAmlRqDqKwx/Dp1slmeub7bYm1KwI0t26sjLJXn13hn0KYoVEB/t+f4VPybJ8JEVcozxg4Gi9MlEoAeXyfYNxQt5H5ZOc5iQINQ1iORd+NhO60bcFXSLaZV3IyguWaaQ/cttdh23d+k8AFM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5437269a661so8567076a12.0 for ; Sat, 18 Nov 2023 21:36:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372184; x=1700976984; 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=S0kJ1UpnSfG0cSSILBX3Dq3Nl+sb6OqK64wHhs9sRyI=; b=ezbaSwtMLESI+9+0aLsyrgNO7lYkVn98lHEoNJx2DV+1fAxqemHSInoBzUwWQJC6bR UzybuZcW2U74rmatxFjBP8xekjFB7kRqnUzbutkUOcZAk0JdMNH6JtYNAPwm5WnzFruh oPBeOvoxVZ8tKMgnHWALxQZIGFagaulIgtsW39agru7Rz2H9Ge636zxUKXAhjqWGuOfO 2gM2WCIWH4TadPOyDDIa7DUTFiXH+/s15BSgOdYGPd2EXCxWUxcmFF8HEZ1MKk2m3PCg 4vGEPWa5+xZkBwKnOaeEdH9PJPrJuv4VCQ+L+dHzQ/TXIiT2feeaM3hlXIUbL7O+ECG7 zqrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372184; x=1700976984; 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=S0kJ1UpnSfG0cSSILBX3Dq3Nl+sb6OqK64wHhs9sRyI=; b=HqkAFsys2kzEHwVSm6fMmyhFkevv97wMmQ+7A2ODGFe95kpRNghdKCyORxVsXQ7d81 UewYyYQs2ABqJXZmnMPVjwyPVJ218vz78ZVg+DhmCm5nC6gw4DQwpg0BBygv6AC8qTUh 2jc5kInkJXUXEfU0daPld7dr4RD2KSD4xYw1xnsi8xSp4jSu5K44wUE54AgwkxZ373Op PtsRLXYBwkGnT4bDi1NahcWB9/fGvPxzh09tlPozrXx3t3a0uJvA6qDxlO5XVO0JDRid wqWvDWz5AZ/I0mSul66fMe0PvrmExwN09ezUciU5/SBFYvq/jdRbwPfC0sYHIpWY59Ev GSIA== X-Gm-Message-State: AOJu0Yx4HOr1f9XGQB3G6nddpBJ2aARm2mKgBkpVUNWkx+UwBUYlTKkm JULpF0XQfMDsm34zrHrB3mAamCKRzFmgz/QAKA5G4Q== X-Received: by 2002:a17:906:3e8a:b0:9ae:659f:4d2f with SMTP id a10-20020a1709063e8a00b009ae659f4d2fmr3089774ejj.26.1700372184101; Sat, 18 Nov 2023 21:36:24 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id g25-20020a170906349900b009fd541851f4sm160795ejb.198.2023.11.18.21.36.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:36:23 -0800 (PST) Date: Sun, 19 Nov 2023 05:36:21 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 06/44] RISC-V: Avoid repeated GET_MODE calls in `riscv_expand_conditional_move' 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.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969502172343806 X-GMAIL-MSGID: 1782969502172343806 Use `mode0' and `mode1' shorthands respectively for `GET_MODE (op0)' and `GET_MODE (op1)' to improve code readability. gcc/ * config/riscv/riscv.cc (riscv_expand_conditional_move): Use `mode0' and `mode1' for `GET_MODE (op0)' and `GET_MODE (op1)'. --- gcc/config/riscv/riscv.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) gcc-riscv-expand-conditional-move-mode-cmp.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -4007,12 +4007,15 @@ riscv_expand_conditional_move (rtx dest, else if (TARGET_ZICOND_LIKE && GET_MODE_CLASS (mode) == MODE_INT) { + machine_mode mode0 = GET_MODE (op0); + machine_mode mode1 = GET_MODE (op1); + /* The comparison must be comparing WORD_MODE objects. We must enforce that so that we don't strip away a sign_extension thinking it is unnecessary. We might consider using riscv_extend_operands if they are not already properly extended. */ - if ((GET_MODE (op0) != word_mode && GET_MODE (op0) != VOIDmode) - || (GET_MODE (op1) != word_mode && GET_MODE (op1) != VOIDmode)) + if ((mode0 != word_mode && mode0 != VOIDmode) + || (mode1 != word_mode && mode1 != VOIDmode)) return false; /* Canonicalize the comparison. It must be an equality comparison @@ -4032,9 +4035,9 @@ riscv_expand_conditional_move (rtx dest, rtx tmp = gen_reg_rtx (word_mode); /* We can support both FP and integer conditional moves. */ - if (INTEGRAL_MODE_P (GET_MODE (XEXP (op, 0)))) + if (INTEGRAL_MODE_P (mode0)) riscv_expand_int_scc (tmp, code, op0, op1, invert_ptr); - else if (FLOAT_MODE_P (GET_MODE (XEXP (op, 0))) + else if (FLOAT_MODE_P (mode0) && fp_scc_comparison (op, GET_MODE (op))) riscv_expand_float_scc (tmp, code, op0, op1); else From patchwork Sun Nov 19 05:36:31 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: 166680 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505051vqn; Sat, 18 Nov 2023 21:37:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyI3gNaZsL3CjYvD0JfG4IDhYNo4vJzS+oShTB6r9pbezSBi3Iy4mBTA//rmNPrMN9gc58 X-Received: by 2002:a05:620a:4587:b0:775:c2a1:1821 with SMTP id bp7-20020a05620a458700b00775c2a11821mr14787269qkb.26.1700372238798; Sat, 18 Nov 2023 21:37:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372238; cv=pass; d=google.com; s=arc-20160816; b=jExcdt2GDDH9QdKH6XZmcl1UogAfGFton3ILRgZ+OZov0f/P/u20asoO1b8qjcaSNv SjefkpOK1Zxz1LEPh4r2UPljursN8TArDdewX7T52v/Aq+SlpVIliVHlhROLw5waQR6t 4HyvafnQZO+Xf2vXKaBOmY0u3I0I9TwhUxzJWJkCKvMTZhWTLSB7pgsNiUrXJlUPujXM xtSRAZ9/XJP9mu/vT/7SStOkDloxM5QffOXP6GWCB2POPqP8/fgeQE6pYZ7jNG1FB2j6 pHTFHdoo3NYRJ9X5NYCnYmaeSQu4nSwc0MHTLd6USQg0QoSU9PZojn4rRV5s8yYse6KH wSSg== 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=BAObHUL+u7i7Tm1MzRpZlhj4SxaR1+F0BolaNOMaSlo=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=H0B8Fwf6khiUfXBsXfH+eyXoHL0R2jKM2JfzS+QvgN160AF0H8crcAQtpSgmsNmFHD kvBs8vRLbmEEoYVQfh193HrZk5V13DsgxUtbKUay+qQTTGaUdLvGAudx/i9l+0LjZhju hQALl8kUgIlGL+1RUifv60gOFjIN0FD3Bb6ifAzaApCS3g/3tJGgppW1c9fZXVwhtrHw 0KXMKR/ZLY9l6aYbZ5F/3Jn/oJ51u/FXDYwZhOzGlBweesF+VMnCRkVEarXd3BktfzIT fc+3S2gR+CkK6YqGTAKCxUX+WXWQF/Q1SRnKlJ2uqq9iMfAzpkEqlolGT4i9LLzc1R2i vDCQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=Z0lNExAS; 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 bj35-20020a05620a192300b00779d6c4d8c0si5622650qkb.300.2023.11.18.21.37.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:37:18 -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=Z0lNExAS; 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 066B5385BAEE for ; Sun, 19 Nov 2023 05:37:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 3AA043857C7C for ; Sun, 19 Nov 2023 05:36:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3AA043857C7C 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 3AA043857C7C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::533 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372196; cv=none; b=D1s0DSEX1SN6+2D/eay1BfPqQgCFgBD95+ibVDjvIv9YGY1BnqcEt0ASaaI8wj5+Ylk0Qmzr77I1D6Wj7VSPokZGTp+EN0dy5J+G+haEBgMoxpi9WTJxsDC8JOg7qZYau2waat6O9AWwhIKa7Ctcba+zzG3LTbdhppa/aqbZrJw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372196; c=relaxed/simple; bh=b2AQK7sZlrKjVJ8yvPhYLcBVoOxlVGXi18kLfcScaOs=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=vxZI/TRcWF26onqTmwzNDBtjQqPxlWsT2X0lZjDQBzhbwJyhS9zpdIVt7KrV+gJEn4NBfGAFLf2JB58gw7axwCFfLgtXLSOIYyoO56nvZf2g18DVGf6lW0tf4509bMrn9RD4saRvqv6K/3lQlSmsd/ZBFVvnakv5GUzOvW5TU0w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5446c9f3a77so4893712a12.0 for ; Sat, 18 Nov 2023 21:36:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372194; x=1700976994; 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=BAObHUL+u7i7Tm1MzRpZlhj4SxaR1+F0BolaNOMaSlo=; b=Z0lNExASJH1IGmtKMVDnNyPUDQGww29OLaKO0vTQ0fibTAmi+nfB3IqomFw7H8racu ERczW23m9cY7L2BP3Sm6CVaS9ssy0zVLYxn4nCuuSzNM0sf+O22geX4wpJbQ3evVCemR Wn145xyVRAE6l+xYbtwEBYMs6iBON2iSMaaooy961149SM3spMhNul53ckuy7/1ZMbQp jdm2Rkc6Ko5VjnjHXJBFFVtBdbgroFMZyTHjBGQB/BfnH1GjFaebdUShOnMYt3M+MNn/ 02pnydT6/l4jefezReYuyw+ffesIq0oAaxCKVT87CFNA5mxfL4ME6ytLmae/s5dHFk0b puIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372194; x=1700976994; 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=BAObHUL+u7i7Tm1MzRpZlhj4SxaR1+F0BolaNOMaSlo=; b=Sitm92vQwiyxXTHhJUsH9zlBDC33oFQkAePEedz7umXphJVrmBJCYVzANllcWiAMAx OM0lSQJa5gdqFAAoMM2ZiG47j1twGEqhY4OBZt3/mtYV2JstXY3V2yJfnYckPRd9U4HR /3p/oRhDduqNw1/9mxje69kLjfNgKVxew7XzmkbB0ASLu+ISGIQZjOwBAmikoRXDPCJR 9yCa547Ew75lRbmAvmUGj5at86BGzd82vAQjdpCjW93zL9t3FAxfX4BOOKhQiqvMiiO+ chm8FEQg7Hi0HUEkCNTNLO3bAO28GbcM2dxbAtVR/2SIH5NMZmuJMNVF/etO0+RF0WCC 3sCA== X-Gm-Message-State: AOJu0Yz1xjsdrHsPH1OTrBYahic4L99sMOfJb3HMWIEum+QvOwpbdjyw 7swl1nP8eqIC1id7gYue4v3mVYYwpYQRlJWFGJd7pg== X-Received: by 2002:a17:907:788f:b0:9ae:5253:175b with SMTP id ku15-20020a170907788f00b009ae5253175bmr3520588ejc.34.1700372193993; Sat, 18 Nov 2023 21:36:33 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id l5-20020a170906a40500b009cd52d08563sm2521753ejz.223.2023.11.18.21.36.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:36:33 -0800 (PST) Date: Sun, 19 Nov 2023 05:36:31 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 07/44] RISC-V: Use `nullptr' in `riscv_expand_conditional_move' 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.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969520462338361 X-GMAIL-MSGID: 1782969520462338361 Use `nullptr' for consistency rather than 0 to initialize `invert_ptr'. gcc/ * config/riscv/riscv.cc (riscv_expand_conditional_move): Use `nullptr' rather than 0 to initialize a pointer. --- gcc/config/riscv/riscv.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) gcc-riscv-expand-conditional-move-nullptr.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -4024,7 +4024,7 @@ riscv_expand_conditional_move (rtx dest, if (!equality_operator (op, VOIDmode) || op1 != CONST0_RTX (mode)) { enum rtx_code new_code = NE; - bool *invert_ptr = 0; + bool *invert_ptr = nullptr; bool invert = false; if (code == LE || code == GE) From patchwork Sun Nov 19 05:36:41 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: 166679 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505035vqn; Sat, 18 Nov 2023 21:37:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGrMLjDazk0/xriBNZjhzLJEXo+/c+o1xWndK6T3X6bArOav3EzMIBucOGmTa+zkNEXlk6J X-Received: by 2002:a05:620a:298f:b0:778:1c6e:a6f1 with SMTP id r15-20020a05620a298f00b007781c6ea6f1mr4691304qkp.57.1700372236531; Sat, 18 Nov 2023 21:37:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372236; cv=pass; d=google.com; s=arc-20160816; b=q8hiaoo/wGeRImMcwvLeJsmFw/4ABTlsZC6z5lHDYNNdShPQ2L8uay+qH24l2gIYRS Qm7sUGo3Zz+RSFyzjOYAFHE3UVwootvZGe1dBnkN7JSPxjtSTdCeSL/jEzz+4JJZLbbi JNr04Y2sa3s5ky1/R6Fapa7YnSLrkpe1COMsoW9FrSkZVy+VsESdqV9cpOz1IvoXjQ5D NzKTyY6RdZ9NjpSFBAN+8kDMCfGkGaQOKLCRtunHpbKwdkPm61iMRWIdEzFBGNymxJOv cWN69Cc2IR/7KfXFSEOWUO4VaUBcD42rwJbH7z6VSQERktdaSDBfX+M2pLoP9jsTYx6C tNiw== 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=t+f7eXhOKfyoKIWuejRcfDM+XKBGxuyvqwv0/TMklCM=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=b1302qHW1RWmHSSHa79AQrCF6O2s9pdUeP45mPRLJzbbjS3qxG24JY2ceaF7pbWUNB 300eLYunsrJVpJwaq+T6HHrLynTvZpwuaDCXWd+d/iXUgp/lbwITv+2ANNqMv09um7oz SogQOya1nEqZcK2IsuYZJR5mAkb3NKVbTpzaLef2Yt2vKhGwc0bmaNOSZL3MwtNk23qq V/d7YQ6xh1ig++wOfLgzjdZCY3UurcxXz5F3WouyhsJuP+Eh0RH/aW+mhrFAzLXMMjdD lQ+5RMVgRVbAIz6M/ZyAuHLA4hTzrRIaGhJiE6lr6Chvr1uFXvT0gpD3/72mkwyDUxfV g86Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b="IF2N/eLI"; 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 bj42-20020a05620a192a00b0076cc34b44c1si5226435qkb.292.2023.11.18.21.37.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:37:16 -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="IF2N/eLI"; 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 B2D3D3857C42 for ; Sun, 19 Nov 2023 05:37:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 38B113857B94 for ; Sun, 19 Nov 2023 05:36:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38B113857B94 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 38B113857B94 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::535 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372206; cv=none; b=waWz9mzDPGVcy5pMV8nabjm9/lRm7EGDlJGExoWPbs3PbzVJ6VaBruDf4d58sX5obYDzhjhku3B5vSiwMDp3PPLpojjRgvM8AfrvId99NhIyYgBoRa0qtPSyOiAARAEyEjI+9RAcmhW2DrUagAvnUds2h/bP0IYa+/E4hnbo7tI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372206; c=relaxed/simple; bh=ISN9526dPjG9jgjllxx3KqPFeNfVGX8IXquqoZnQyZg=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=SN2WXp6q9YyA0cSQsH6vInCTns5rxpHPkN9tGKo9kxk27taKrzqK0JuDCApCKytqCEFCIrq1Xw3KjnWiZOtwUKM45hE8QwEjmZhS+mwQD3mO8oecQJke3cH1Ti06bLPn7NkAmOx6rJLRNkZz65wHtp1PJibbsogxmLJR0mp74AU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5431614d90eso4702697a12.1 for ; Sat, 18 Nov 2023 21:36:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372204; x=1700977004; 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=t+f7eXhOKfyoKIWuejRcfDM+XKBGxuyvqwv0/TMklCM=; b=IF2N/eLIorodtOFTT7Piql0Y73kRMMC9q0IwvghNyBoiGnHgU/ZYLQ2hw05Lw3LkSv wNLFYg5ok7ulD0YC628n/h29PWGIzwSCECB5EX4Eq0uGlgdbyKjBFBKxWmqNfQL+XF94 BdNsznZKNagK5BQ/XzMNtyU6NS4gmpkcX46ZIfD0mXGx1yNV4pSS+jqnHpv8urwRD7Gs gfLfF+ANJFZy2mGwnS3QI4DldU/XGQrQwZiXrX0JOLHhA/b6SD9DtOKlUkOsWUfBKoFK OzxcR2VH5W18vWEV8HMI9AJYz6q98dkkWqrfaFsF3bv3gR1vhIz9+SrF5q+qDHMOB7qJ yQWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372204; x=1700977004; 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=t+f7eXhOKfyoKIWuejRcfDM+XKBGxuyvqwv0/TMklCM=; b=Due0AIx/iU46d6VnutvowPRDuXjvWKj4Ro1M7KpRBD/uG6dDxMrzZwcjsixzqePZh+ ZhLUHq3i7djmHWwEGPancYoflCw0vNxIFcJ5WVxWUWtHiH9A0Sbd+JxQzmVHy0qh49+v G+nveonGb3+4P5X2oClu8imVBBujM6LM+R5qrK3xuaTsYjq89j2GB/R/rMm5g3hc2pbf WfgGV6cQoa+6I1MX7njUiaeYoVTor2V94TDq80OpeD3s6tbMhuqBjSqFTd41F6CD5mJN Lp1ceTLTpDWkbgrSnDnNVkyw6d4UdAMY+0gTjqrwHMj1l5sMJ4IPCbUVneb4gGcdoYUE sPAw== X-Gm-Message-State: AOJu0YwnpYTgjNINIAThPiKQ/4etSkxe9uUSnO0WetXBJN0UsS1v4KTW 7TZV6jO78eyq4fOu4qHVkJwWgENr3EEEoT+RHqJp+g== X-Received: by 2002:a17:906:51d4:b0:9fc:1078:2615 with SMTP id v20-20020a17090651d400b009fc10782615mr1242645ejk.76.1700372203998; Sat, 18 Nov 2023 21:36:43 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id lh10-20020a170906f8ca00b009fd2028e62csm231582ejb.71.2023.11.18.21.36.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:36:43 -0800 (PST) Date: Sun, 19 Nov 2023 05:36:41 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 08/44] RISC-V: Simplify EQ vs NE selection in `riscv_expand_conditional_move' 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.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969518394434766 X-GMAIL-MSGID: 1782969518394434766 Just choose between EQ and NE at `gen_rtx_fmt_ee' invocation, removing an extraneous variable only referred once and improving code clarity. gcc/ * config/riscv/riscv.cc (riscv_expand_conditional_move): Remove extraneous variable for EQ vs NE operation selection. --- FWIW I have no idea what "We need to know where so that we can adjust it for our needs." refers to, but that would have to be for another change. --- gcc/config/riscv/riscv.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) gcc-riscv-expand-conditional-move-new-code.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -4023,10 +4023,12 @@ riscv_expand_conditional_move (rtx dest, we can then use an equality comparison against zero. */ if (!equality_operator (op, VOIDmode) || op1 != CONST0_RTX (mode)) { - enum rtx_code new_code = NE; bool *invert_ptr = nullptr; bool invert = false; + /* If riscv_expand_int_scc inverts the condition, then it will + flip the value of INVERT. We need to know where so that + we can adjust it for our needs. */ if (code == LE || code == GE) invert_ptr = &invert; @@ -4043,13 +4045,7 @@ riscv_expand_conditional_move (rtx dest, else return false; - /* If riscv_expand_int_scc inverts the condition, then it will - flip the value of INVERT. We need to know where so that - we can adjust it for our needs. */ - if (invert) - new_code = EQ; - - op = gen_rtx_fmt_ee (new_code, mode, tmp, const0_rtx); + op = gen_rtx_fmt_ee (invert ? EQ : NE, mode, tmp, const0_rtx); /* We've generated a new comparison. Update the local variables. */ code = GET_CODE (op); From patchwork Sun Nov 19 05:36:52 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: 166681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505094vqn; Sat, 18 Nov 2023 21:37:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZH3L8WI2N8lxi0/EdbAjKYchTuPuZ8orVh3WAixflRwtcQRy0Arnkl2dBBBjw7+atJ0tq X-Received: by 2002:a05:620a:1113:b0:775:73f6:1b39 with SMTP id o19-20020a05620a111300b0077573f61b39mr3767298qkk.25.1700372253285; Sat, 18 Nov 2023 21:37:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372253; cv=pass; d=google.com; s=arc-20160816; b=zeWgATz8X/zXLCIAeDNJiGjXXh0UcgAHA7GXF67JpZbrvFrI54kHUVdglRhDOENetZ FnGkVf1D9uaRQT4Q0fPcl3Vcunjjx9BXyixWvQ1Lk9dlJJjuVfUDtIGi1IRJa5ezJo+0 ovH9BiQxBlaj7ocKW4yZWeSXlYcCKjZJkIIZBiY6BQiOlA92n44lfpUfggPLdzqiW6tW hCvaQ4cuQT9cN3TgpKSP4N/00UaLnjBwV+xmfKHXzlKOrppbnOJ83cnrvZv2q83fxnc5 iFUayV12i1odv0QJClkRoq/VAOxT8rNmMkUqj8Sx1Tb/U+geQUuH/RkO8l+e/BwlPQke SlNw== 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=iP43tpg2qXJYbl4dLBzTpiAEAwJehghqWOZ+kyNUyI8=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=jLc3ldXuiGih6cZxxY9To7Nejbs7sqEsC2VqC7jIQgzxJ9dxbDmTCHkYhfgKXgF/Ft MYef89kweismSXonpy1ZMkk5C0JqI7zH3T4OciCxHiqm+8ip4RupKQwWV9HkGSMQvTmT svVAODzPq9OiGwaoAvdVVTM4g8hivrO+kA39ICbyeDJBm5W2jF9Lx8KrWCQ7iQN5oT+N 1uOy7yg/WHx2Pvv8N00OnPcBaqJpM7UCsauCKB1qravtxdHA1BAu/jvQjCr0Pysm5+yb llRNItFjRiniHZwZWkRLFZCOWTRQAfJXwejhzLPya6BNP6TTCjJ/8t3l2cLtUFtP2D/U Xmtg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=ShcdiMNL; 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 t2-20020a05620a0b0200b00778ae4e9288si4713909qkg.646.2023.11.18.21.37.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:37:33 -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=ShcdiMNL; 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 EB1D1385B527 for ; Sun, 19 Nov 2023 05:37:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 75EC9385C32C for ; Sun, 19 Nov 2023 05:36:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 75EC9385C32C 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 75EC9385C32C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::535 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372220; cv=none; b=LB2bWJDGFuoTc0msVjNYsDsEhDB0ntVr5TbA9XZ1vJ3gQkZpnQeC6C51LHW+DtPkvCIrKEgMR0BsLqIfJT9CQhw8lzkRq3Fwi2sPVe7mEgJZqzcWucBv08XSfgRVTl+andOReS4uS3g2hCKEKvawlg51iTiBixVyLAEJcpwZdGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372220; c=relaxed/simple; bh=va/+Rn6km0lOS9NNk7Cw0R5T5npDbZF4DtaMAQ+T8H8=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=bNGIoWN+XHVkF7W8jxD3e7RAf5sm5+57MeNvUdR96Z7MJFnSUWT2fwzDSTAqCXcpdmR3UxsT/2xk537sbokrmRiEEW3QxhMU2j3Ghe5N4uT4IsUDAoOLAGwdwaNG3KCKIgWT/fJLU0olszTOZC5eCLymrXcmR9wGhHNEIGSQOxw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-54394328f65so4552215a12.3 for ; Sat, 18 Nov 2023 21:36:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372216; x=1700977016; 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=iP43tpg2qXJYbl4dLBzTpiAEAwJehghqWOZ+kyNUyI8=; b=ShcdiMNL9pDLFa8EaCZ2KEqzh9do/RY7PzwWfVGe5kqWYc+xZh2IahDqprTwkGHDna VehexeDdx94tyysIz9BFhM3np8e4V8dDm6Gtf/b8r/q7YNZfLd+i0K6bNLv1aI68yrVQ nzuNcaNMcMTq9B7tg2/dJRxEPPyrFvSPLDhOQapuqJZVmLh+SJqsyhKbWnv3xqPlpoBe MHy+vnm4whP7txmmy8O7Jdywxo7JN66/pM7Pntq36FxQ9mSqYa/rLYijyyIvYOXuOeSF g+cJq2bhvR/r30ZrXPpuqGM1IQC1vJ8IExEy8nV8l5w/nBVwd9Pd5Uh5WKvI16Qqxl58 tKCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372216; x=1700977016; 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=iP43tpg2qXJYbl4dLBzTpiAEAwJehghqWOZ+kyNUyI8=; b=wq5fMaff+9YhKlJgyKftXUhRLYl4lKNWoccAapBZ05/yAoD7HZr6v4W9aEXtDGiTFQ ni7hMxPOiPKtg9tlXHUV7h7QUivPXyCezDECdNUeso+DflbyspGQ9eyhauGLm9OoAS7Y ML+137Hbi9Ynh14qccjZhw18asb5H5i7VhJFMuDirLnSPRzVQrduXHjcru7zWrKWsJfs 6+LnsZzG8Xwhrh91GLA0dwNeFrF3MG+OnSmFyYKnzglH5UbVmBZu46u2tRFlttfSvUnK DAm17Mp3P/S2MpLlNL8jKOK5r5ZtqdkmeIErzW7LwArkdw0CGe3nfseUEHUfDiI55GGN hHvw== X-Gm-Message-State: AOJu0YyojtkvPJ/1A18+aiOdSUCDFLbE6Pk6YPmleXT4tdZyWph26H91 6bxUX44Iqg5mZWTma8mSHWFxlZi/DMJ6NxZwiforrw== X-Received: by 2002:a05:6402:4408:b0:543:cc90:cb8b with SMTP id y8-20020a056402440800b00543cc90cb8bmr3565308eda.2.1700372216038; Sat, 18 Nov 2023 21:36:56 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id h11-20020a50ed8b000000b00548a3a22d66sm262522edr.41.2023.11.18.21.36.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:36:55 -0800 (PST) Date: Sun, 19 Nov 2023 05:36:52 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 09/44] RISC-V: Rework branch costing model for if-conversion 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.5 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, URIBL_BLACK 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: 1782969536171354334 X-GMAIL-MSGID: 1782969536171354334 The generic branch costing model for if-conversion assumes a fixed cost of COSTS_N_INSNS (2) for a conditional branch, and that one half of that cost comes from a preceding condition-set instruction, such as with MODE_CC targets, and then the other half of that cost is for the actual branch instruction. This is hardcoded for `if_info.original_cost' in `noce_find_if_block' and regardless of the cost set for branches via BRANCH_COST. Then `default_max_noce_ifcvt_seq_cost' instructs if-conversion to prefer a branchless sequence as costly as high as triple the BRANCH_COST value set. This is apparently to make up for the inability to accurately guess the branch penalty. Consequently for the BRANCH_COST of 3 we commonly set for tuning, if-conversion will consider branchless sequences costing 3 * 3 - 2 = 7 instruction units more than a corresponding branch sequence. For the BRANCH_COST of 4 such as with `sifive-7-series' tuning this is even worse, at 3 * 4 - 2 = 10. Effectively it means a branchless sequence will always be chosen if available, even a very inefficient one. Rework the branch costing model to better match our architecture, observing in particular that we have no preparatory instructions for branches so that the cost of a branch is naked BRANCH_COST plus any extra overhead the processing of a branch's source RTX might incur. Provide TARGET_INSN_COST and TARGET_MAX_NOCE_IFCVT_SEQ_COST handlers than that return suitable cost based on BRANCH_COST. The latter hook usually returns a value that is lower than the cost of the corresponding branched sequence. This is because we don't really want to produce a branchless sequence that is more expensive than the original branched sequence. If this turns out too conservative for some corner case, then this choice might be revisited. Then we don't want to fiddle with `noce_find_if_block' without a lot of cross-target verification, so add TARGET_NOCE_CONVERSION_PROFITABLE_P defined such that it subtracts the fixed COSTS_N_INSNS (2) cost from the cost of the original branched sequence supplied and instead adds actual branch cost calculated from the conditional branch instruction used. It is then further tweaked according to simple analysis of the replacement branchless sequence produced so as to cancel the cost of an extraneous zero extend operation produced by `noce_try_store_flag_mask' as observed with gcc/testsuite/gcc.target/riscv/pr105314.c. Tweak the testsuite accordingly and set `-mbranch-cost=' explicitly for the relevant cases so that the expected if-conversion transformation is made regardless of the default BRANCH_COST value of tuning in effect. Some of these settings will be lowered later on as deficiencies in branchless sequence generation have been fixed that lower their cost calculated by if-conversion. gcc/ * config/riscv/riscv.cc (riscv_insn_cost): New function. (riscv_max_noce_ifcvt_seq_cost): Likewise. (riscv_noce_conversion_profitable_p): Likewise. (TARGET_INSN_COST): New macro. (TARGET_MAX_NOCE_IFCVT_SEQ_COST): New macro. (TARGET_NOCE_CONVERSION_PROFITABLE_P: New macro. gcc/testsuite/ * gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_imm.c: Explicitly set the branch cost. * gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_reg.c: Likewise. * gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_reg_reg.c: Likewise. * gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_imm.c: Likewise. * gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_reg.c: Likewise. * gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_reg_reg.c: Likewise. --- FWIW I don't understand why the test cases absolutely HAD to have such overlong names guaranteed to exceed our 80 column limit in any context. It's such a pain to handle. --- gcc/config/riscv/riscv.cc | 120 ++++++++++ gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_imm.c | 4 gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_reg.c | 4 gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_reg_reg.c | 4 gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_imm.c | 4 gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_reg.c | 4 gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_reg_reg.c | 4 7 files changed, 132 insertions(+), 12 deletions(-) gcc-riscv-branch-cost.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. #include "calls.h" #include "function.h" #include "explow.h" +#include "ifcvt.h" #include "memmodel.h" #include "emit-rtl.h" #include "reload.h" @@ -3295,6 +3296,118 @@ riscv_address_cost (rtx addr, machine_mo return riscv_address_insns (addr, mode, false); } +/* Implement TARGET_INSN_COST. We factor in the branch cost in the cost + calculation for conditional branches: one unit is considered the cost + of microarchitecture-dependent actual branch execution and therefore + multiplied by BRANCH_COST and any remaining units are considered fixed + branch overhead. */ + +static int +riscv_insn_cost (rtx_insn *insn, bool speed) +{ + rtx x = PATTERN (insn); + int cost = pattern_cost (x, speed); + + if (JUMP_P (insn) + && GET_CODE (x) == SET + && GET_CODE (SET_DEST (x)) == PC + && GET_CODE (SET_SRC (x)) == IF_THEN_ELSE) + cost += COSTS_N_INSNS (BRANCH_COST (speed, false) - 1); + return cost; +} + +/* Implement TARGET_MAX_NOCE_IFCVT_SEQ_COST. Like the default implementation, + but we consider cost units of branch instructions equal to cost units of + other instructions. */ + +static unsigned int +riscv_max_noce_ifcvt_seq_cost (edge e) +{ + bool predictable_p = predictable_edge_p (e); + + if (predictable_p) + { + if (OPTION_SET_P (param_max_rtl_if_conversion_predictable_cost)) + return param_max_rtl_if_conversion_predictable_cost; + } + else + { + if (OPTION_SET_P (param_max_rtl_if_conversion_unpredictable_cost)) + return param_max_rtl_if_conversion_unpredictable_cost; + } + + return COSTS_N_INSNS (BRANCH_COST (true, predictable_p)); +} + +/* Implement TARGET_NOCE_CONVERSION_PROFITABLE_P. We replace the cost of a + conditional branch assumed by `noce_find_if_block' at `COSTS_N_INSNS (2)' + by our actual conditional branch cost, observing that our branches test + conditions directly, so there is no preparatory extra condition-set + instruction. */ + +static bool +riscv_noce_conversion_profitable_p (rtx_insn *seq, + struct noce_if_info *if_info) +{ + struct noce_if_info riscv_if_info = *if_info; + + riscv_if_info.original_cost -= COSTS_N_INSNS (2); + riscv_if_info.original_cost += insn_cost (if_info->jump, if_info->speed_p); + + /* Hack alert! When `noce_try_store_flag_mask' uses `cstore4' + to emit a conditional set operation on DImode output it comes up + with a sequence such as: + + (insn 26 0 27 (set (reg:SI 140) + (eq:SI (reg/v:DI 137 [ c ]) + (const_int 0 [0]))) 302 {*seq_zero_disi} + (nil)) + (insn 27 26 28 (set (reg:DI 139) + (zero_extend:DI (reg:SI 140))) 116 {*zero_extendsidi2_internal} + (nil)) + + because our `cstore4' pattern expands to an insn that gives + a SImode output. The output of conditional set is 0 or 1 boolean, + so it is valid for input in any scalar integer mode and therefore + combine later folds the zero extend operation into an equivalent + conditional set operation that produces a DImode output, however + this redundant zero extend operation counts towards the cost of + the replacement sequence. Compensate for that by incrementing the + cost of the original sequence as well as the maximum sequence cost + accordingly. */ + rtx last_dest = NULL_RTX; + for (rtx_insn *insn = seq; insn; insn = NEXT_INSN (insn)) + { + if (!NONDEBUG_INSN_P (insn)) + continue; + + rtx x = PATTERN (insn); + if (NONJUMP_INSN_P (insn) + && GET_CODE (x) == SET) + { + rtx src = SET_SRC (x); + if (last_dest != NULL_RTX + && GET_CODE (src) == ZERO_EXTEND + && REG_P (XEXP (src, 0)) + && REGNO (XEXP (src, 0)) == REGNO (last_dest)) + { + riscv_if_info.original_cost += COSTS_N_INSNS (1); + riscv_if_info.max_seq_cost += COSTS_N_INSNS (1); + } + last_dest = NULL_RTX; + rtx dest = SET_DEST (x); + if (COMPARISON_P (src) + && REG_P (dest) + && GET_MODE (dest) == SImode) + last_dest = dest; + } + else + last_dest = NULL_RTX; + } + + return default_noce_conversion_profitable_p (seq, &riscv_if_info); +} + /* Return one word of double-word value OP. HIGH_P is true to select the high part or false to select the low part. */ @@ -9823,6 +9936,13 @@ riscv_preferred_else_value (unsigned ifn #define TARGET_RTX_COSTS riscv_rtx_costs #undef TARGET_ADDRESS_COST #define TARGET_ADDRESS_COST riscv_address_cost +#undef TARGET_INSN_COST +#define TARGET_INSN_COST riscv_insn_cost + +#undef TARGET_MAX_NOCE_IFCVT_SEQ_COST +#define TARGET_MAX_NOCE_IFCVT_SEQ_COST riscv_max_noce_ifcvt_seq_cost +#undef TARGET_NOCE_CONVERSION_PROFITABLE_P +#define TARGET_NOCE_CONVERSION_PROFITABLE_P riscv_noce_conversion_profitable_p #undef TARGET_ASM_FILE_START #define TARGET_ASM_FILE_START riscv_file_start Index: gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_imm.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_imm.c +++ gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_imm.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-march=rv64gc_zicond -mabi=lp64d" { target { rv64 } } } */ -/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=4" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=4" { target { rv32 } } } */ /* { dg-skip-if "" { *-*-* } {"-O0" "-Og" "-Os" "-Oz"} } */ long primitiveSemantics_compare_imm_return_imm_imm_00(long a, long b) { Index: gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_reg.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_reg.c +++ gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_reg.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-march=rv64gc_zicond -mabi=lp64d" { target { rv64 } } } */ -/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=4" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=4" { target { rv32 } } } */ /* { dg-skip-if "" { *-*-* } {"-O0" "-Og" "-Os" "-Oz"} } */ long primitiveSemantics_compare_imm_return_imm_reg_00(long a, long b) { Index: gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_reg_reg.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_reg_reg.c +++ gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_reg_reg.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-march=rv64gc_zicond -mabi=lp64d" { target { rv64 } } } */ -/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=5" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=5" { target { rv32 } } } */ /* { dg-skip-if "" { *-*-* } {"-O0" "-Og" "-Os" "-Oz"} } */ long primitiveSemantics_compare_imm_return_reg_reg_00(long a, long b, long c) { Index: gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_imm.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_imm.c +++ gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_imm.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-march=rv64gc_zicond -mabi=lp64d" { target { rv64 } } } */ -/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=4" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=4" { target { rv32 } } } */ /* { dg-skip-if "" { *-*-* } {"-O0" "-Og" "-Os" "-Oz"} } */ long primitiveSemantics_compare_reg_return_imm_imm_00(long a, long b, long c) { Index: gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_reg.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_reg.c +++ gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_reg.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-march=rv64gc_zicond -mabi=lp64d" { target { rv64 } } } */ -/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=4" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=4" { target { rv32 } } } */ /* { dg-skip-if "" { *-*-* } {"-O0" "-Og" "-Os" "-Oz"} } */ long primitiveSemantics_compare_reg_return_imm_reg_00(long a, long b, long c) { Index: gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_reg_reg.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_reg_reg.c +++ gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_reg_reg.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-march=rv64gc_zicond -mabi=lp64d" { target { rv64 } } } */ -/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=5" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=5" { target { rv32 } } } */ /* { dg-skip-if "" { *-*-* } {"-O0" "-Og" "-Os" "-Oz"} } */ long primitiveSemantics_compare_reg_return_reg_reg_00(long a, long b, long c, From patchwork Sun Nov 19 05:37:06 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: 166682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505156vqn; Sat, 18 Nov 2023 21:37:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEneAah48XSZPRt6Ct00NLgi7LdEL1uv7NQzhctNHkW3Hyi9TBSWo+3VpHYTNZhqLBZ9TGr X-Received: by 2002:a05:620a:4151:b0:777:74c0:4f3b with SMTP id k17-20020a05620a415100b0077774c04f3bmr3867650qko.76.1700372269755; Sat, 18 Nov 2023 21:37:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372269; cv=pass; d=google.com; s=arc-20160816; b=GSGfNstjSeUU0HN1vO95AnxZXW4SzY+6huai1TAXrp3yJNWcsziapG4KCHSmyi+IO5 IVMtI6IAuiNxzxJKFefRr30+6LNeKuI6rDTxm+EsMpAiZHWsBaX4wRu7eQ2aXjFtOT7N ndJbMjbawOyCCH7nNOG5eep267scGBdnP6/4CEh52rq3YQncGIhPOlUbPH5elIZUlDgU Xq5z/BXIbXpoNtRFgQjFkS3PK1zlCI+S1l9GEMZccoCLsRTPJZkad3jXOZ5gRQ8E7kqg YI9Rx6+xxOtv1VcLc5hrCZeL47fxyoS3M8CVtVRDKGYdrLys9z2QvnaopZyW5CTLu33A 7+zw== 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=sA/R3lX3rfCjSqStl2XsN0vQICsaYEMWve8uhu/tjZM=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=tU1DHMuV/3Zq2z0U3S+MwDAEmMb+uRhQxI6eHa8Q4JLal8GCkd/D9wrjw/xzc2eKc9 tD1FTe/e4T0PRg5dlmlAdEool9qMAxjzqS+qUxPA4vwa/8GUP0nc4zcgMWrlHgh6kGRe +zDn5wKkANDOO+KPwB8x+1hqAy6lwniQhhTOQNxhY880hxtYR83seh1tmAnUrCWU7iQH oR0Wrg8eYFQyvqvUDlo/+xGk47R3UnrL6/7N3UFcuoB4s6/izRNmUdWU7TChyFPmyjwc GmjDpMZ0mfCk5tMJ00Pi9sdIzoSCzYO4aYOKN8WSKYcro2fxUIx4SfvqioK3o/fISwdx NhdA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=Pfo6XFih; 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 pb16-20020a05620a839000b0077893815e89si5191222qkn.541.2023.11.18.21.37.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:37:49 -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=Pfo6XFih; 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 73399385702B for ; Sun, 19 Nov 2023 05:37:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id 3E6C33857023 for ; Sun, 19 Nov 2023 05:37:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E6C33857023 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 3E6C33857023 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::529 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372237; cv=none; b=wQvFV/8fl6gfeiYrodp754fzHR5ZEDBtFoBd30zZnBQCAPMMaJL05KgrX3Uw5kZafelww3Bfn3L8T9q+O3ixJIfjn/XfSr05e4qoqgiaQ0F0+hQ9iN1jG3XsWNimeLZmQ65vGwtJfJz2qH78Bey/gVa7NCY4KPllUQ9X9a/rIwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372237; c=relaxed/simple; bh=PNJ1pshlNzN/iV8YvJ5WYknNIC+IFvQoIAzGZLH/dyM=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=LUuAzBOBKiMZhQdHmraZgIlscUR0oZRkSsbq09upjwQYN4wvypcYuyFQ6t4yHeD0peHQcmsh0nSzv/ld6fSXmp9mv829lEuLRsIlUOpo29IzGxtILuCyiNmsn+TElp8twG/BAGywMTmhX8Q36iw0ZTim1WTKwLDBaBZHGwyorWQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-53e751aeb3cso4680443a12.2 for ; Sat, 18 Nov 2023 21:37:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372231; x=1700977031; 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=sA/R3lX3rfCjSqStl2XsN0vQICsaYEMWve8uhu/tjZM=; b=Pfo6XFihbpgUTBBlRfVBTm00+mjt73ezyam6vKJXAxbQeRJXIzl437g3UxPB+T/LL5 jglwlPDN3HWYpewjtuIQp+m8smmCs7dE9VRkZMbT4O/2QqOPW8923aDGWAEyZM5xcC4o BtpoQwNnCaymbaTLwGjbUdL7tpznXH1uzVsSXlKo0EUKXCL1MOi3Kh2PoGdrG+eHru// CRyH1rgBwwfIBCogmVRgR5DEfk4bgW6EHOeCse+b4fPqNwAmnynewZvq+qhiDnctb6xa lBwrlE08CeqkXYHCzpzZZj+q6qw1f6aWCZ9//weEQ/WXzbuI/CgQBxfwZeykDypyAE6F dQ/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372231; x=1700977031; 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=sA/R3lX3rfCjSqStl2XsN0vQICsaYEMWve8uhu/tjZM=; b=UlY09lZcFzb3wNt+pyKHDTsPEKDfZVRq/47nxPceZdLEYLa9GrHmLEqAl5snrgvdK/ 5hnk5mcUdJpSPlu0QWloyUoYrrBn9TJA47sQPvb8kwrPrSeu3oq8ABRbsGH2g4vx5Sl0 NSWEjy5A3UkFELtoFN27Pj2wzyyQAK8/0xxjdGeAaE33w0YpZ6FRGt5yRJttxkuSE68v Ntf+MEWzLyHguBu98Bc3N9BY5VK8J15OwmGf/ZQShcyAgn+Uo586gWEp3/zhu7WjZqHA Q5toEg4GOt1ZnfmTNEUZapexFpb6SRRdyr8Fmm0Bxaa+PxoBD+tUpeftddF9xnG+qJP0 ymTA== X-Gm-Message-State: AOJu0YwDgqjmobM2XrpreZd5kGvezQEBP9Ikdsdnz5o0I2fw3qSUGciv lOWoc8aI6Xq5STdd98we07bISjUPPCWUGQkipTbXZw== X-Received: by 2002:a05:6402:1612:b0:548:656b:629b with SMTP id f18-20020a056402161200b00548656b629bmr2758747edv.25.1700372230800; Sat, 18 Nov 2023 21:37:10 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id ss16-20020a170907039000b0099bc2d1429csm2556869ejb.72.2023.11.18.21.37.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:37:10 -0800 (PST) Date: Sun, 19 Nov 2023 05:37:06 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 10/44] RISC-V/testsuite: Add branched cases for integer 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=1.3 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_20_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: 1782969553441573300 X-GMAIL-MSGID: 1782969553441573300 Verify, for T-Head, Ventana and Zicond targets and the integer conditional-move operations that already work as expected, 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. Cover all integer relational operations to make sure no corner case escapes. The reason to XFAIL movdibne-thead.c and movsibne-thead.c is the branchless T-Head sequence: sub a1,a0,a1 th.mveqz a2,a3,a1 mv a0,a2 ret produced rather than its original branched counterpart: beq a0,a1,.L3 mv a0,a2 ret .L3: mv a0,a3 ret at `-mbranch-cost=1', even though under this setting the latter sequence is obviously cheaper performance-wise. This is because the final move instruction in the branchless sequence is not counted towards its cost and consequently the cost of both sequences works out at 8 each, making if-conversion prefer the branchless variant. Use the XFAIL mark to keep track of these cases for future consideration. gcc/testsuite/ * gcc.target/riscv/movdibeq-thead.c: New test. * gcc.target/riscv/movdibge-ventana.c: New test. * gcc.target/riscv/movdibge-zicond.c: New test. * gcc.target/riscv/movdibgeu-ventana.c: New test. * gcc.target/riscv/movdibgeu-zicond.c: New test. * gcc.target/riscv/movdibgt-ventana.c: New test. * gcc.target/riscv/movdibgt-zicond.c: New test. * gcc.target/riscv/movdible-ventana.c: New test. * gcc.target/riscv/movdible-zicond.c: New test. * gcc.target/riscv/movdibleu-ventana.c: New test. * gcc.target/riscv/movdibleu-zicond.c: New test. * gcc.target/riscv/movdiblt-ventana.c: New test. * gcc.target/riscv/movdiblt-zicond.c: New test. * gcc.target/riscv/movdibne-thead.c: New test. * gcc.target/riscv/movsibeq-thead.c: New test. * gcc.target/riscv/movsibge-ventana.c: New test. * gcc.target/riscv/movsibge-zicond.c: New test. * gcc.target/riscv/movsibgeu-ventana.c: New test. * gcc.target/riscv/movsibgeu-zicond.c: New test. * gcc.target/riscv/movsibgt-ventana.c: New test. * gcc.target/riscv/movsibgt-zicond.c: New test. * gcc.target/riscv/movsible-ventana.c: New test. * gcc.target/riscv/movsible-zicond.c: New test. * gcc.target/riscv/movsibleu-ventana.c: New test. * gcc.target/riscv/movsibleu-zicond.c: New test. * gcc.target/riscv/movsiblt-ventana.c: New test. * gcc.target/riscv/movsiblt-zicond.c: New test. * gcc.target/riscv/movsibne-thead.c: New test. --- gcc/testsuite/gcc.target/riscv/movdibeq-thead.c | 27 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibge-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibge-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibgeu-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibgeu-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibgt-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibgt-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdible-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdible-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibleu-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibleu-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiblt-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiblt-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibne-thead.c | 29 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibeq-thead.c | 27 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibge-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibge-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibgeu-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibgeu-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibgt-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibgt-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsible-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsible-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibleu-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibleu-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiblt-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiblt-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibne-thead.c | 29 +++++++++++++++++++++ 28 files changed, 784 insertions(+) gcc-riscv-branch-cost-test-movcc-branch.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdibeq-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibeq-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + bne a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibge-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibge-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + blt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movdibge-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibge-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + blt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movdibgeu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibgeu-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=3 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + bltu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movdibgeu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibgeu-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=3 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + bltu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movdibgt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibgt-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + ble a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movdibgt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibgt-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + ble a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movdible-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdible-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movdible-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdible-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movdibleu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibleu-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=3 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgtu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movdibleu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibleu-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=3 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgtu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movdiblt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiblt-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + bge a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movdiblt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiblt-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + bge a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movdibne-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibne-thead.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branched assembly like: + + beq a0,a1,.L3 + mv a0,a2 + ret +.L3: + mv a0,a3 + ret + */ + +/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" { xfail "*-*-*" } } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" { xfail "*-*-*" } } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 { xfail "*-*-*" } } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" { xfail "*-*-*" } } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" { xfail "*-*-*" } } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibeq-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibeq-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + bne a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibge-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibge-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + blt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movsibge-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibge-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + blt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movsibgeu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibgeu-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=3 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + bltu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movsibgeu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibgeu-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + bltu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movsibgt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibgt-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + ble a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movsibgt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibgt-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + ble a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movsible-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsible-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movsible-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsible-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movsibleu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibleu-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=3 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgtu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movsibleu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibleu-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgtu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movsiblt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiblt-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + bge a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movsiblt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiblt-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + bge a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { 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/movsibne-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibne-thead.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branched assembly like: + + beq a0,a1,.L3 + mv a0,a2 + ret +.L3: + mv a0,a3 + ret + */ + +/* { dg-final { scan-rtl-dump-not "Conversion succeeded on pass \[0-9\]+\\." "ce1" { xfail "*-*-*" } } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" { xfail "*-*-*" } } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 { xfail "*-*-*" } } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" { xfail "*-*-*" } } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" { xfail "*-*-*" } } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ From patchwork Sun Nov 19 05:37:20 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: 166683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505197vqn; Sat, 18 Nov 2023 21:38:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IH2QTTg2svWCxvchjvVQ/4kYI8KVltphrnfOJofISstM2978obfFjph/bvnFFmN9U4njm7g X-Received: by 2002:a05:620a:248f:b0:77a:40ae:2e7a with SMTP id i15-20020a05620a248f00b0077a40ae2e7amr14878494qkn.24.1700372279855; Sat, 18 Nov 2023 21:37:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372279; cv=pass; d=google.com; s=arc-20160816; b=SvpQuKAgVcE072QccEbOyUDU+QCNADtanfWnAQxMgJ0tizKDFFPB8aCxwkVTdLJ0vy Ra3AnqmRVEaluoMak+0KoX56kwFnomGCgZ90rjMWxB4ZssHqvkqpBQrjCfjlkFHAH2Qb 2ml4aA1nWBEYbWknCWCXxSe7nvSnmRvPX7MXD2K7EE3c27bmI07Bp6foTtAunx8GIunc h47zxZN3UboYnRty0Tg10nY9mzibAqzLnOJFzqsGUk7qMkStUC/2hzEbGs4r3iQPtAkS Q4KrSx8t1NockyhBhBGDVwM0bXtFelO7rdMVW3L8TXpVQajWDJrakG1zLD0kb1+CABW+ PT7w== 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=HQHV33mmBf57XVrG9+e6rQQykze7ZE9YLZHdETzIYC8=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=J5Z+Y8GC1r82xqZTyYnoKVLMj8fhUxmcn9srfjGPpDbW6wnSpNZsCuQmaZGMyR0TvV yXGYgHPkIuP/w5IzoilHoa6reDOYN3UimS4mXm9b98wiGS04YqgEaB2muXZSZViU4I9w cIcDgf59X74wGtYpF9e6CSLg+5FtcJMd4MAbOQISarKW0IrLHkH6oVLrYNgTVkesH7CQ ulWe3K8MfplpMwYz79LyBIIuBS7dANJicymDwMay8wOWYlcUTXJo0AeXQZUIjXJQNdmN BePwD+lgseqgwGjcsGI/bHRLxo5KkwvlZCHYSKAf+y0de4zyJWZtMyyzlHv+LU0ycRpb 9PPw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=blsWigO1; 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 y12-20020a05622a004c00b00419856ea1casi5126996qtw.123.2023.11.18.21.37.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:37:59 -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=blsWigO1; 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 8CFBF385B80B for ; Sun, 19 Nov 2023 05:37:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 8298B3857C55 for ; Sun, 19 Nov 2023 05:37:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8298B3857C55 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 8298B3857C55 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372251; cv=none; b=E1Ff8RJ45WJPv8RsJUSf2xZPDvyYKWMSXvswd6T31gHOfZ0j8g5VQ0FYhKoBJV1BYXXUx3rz++n6A1ymlI8+NwJDKqGe1t+vXLdvcRsHAHkNTZiTd/Yz3O+8FKh9v1WFyodO8EJSanAOX3H5zEJd77GLujicu3clkOs76TQj51I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372251; c=relaxed/simple; bh=beXgI7DFyAcL1IaWXyK2uOIkJRaKBZF2fA4JCXdOFgA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=T+DZUo34tCO3DnYvTrSoh5JYfCGwCa02aRWhokwchIIzaEGcWJd220UcDdvB34CGNzYd5lH1TL4rqzsH+92eJ1lCNBLvOFgFFIDzI8X5smY7gWse0Zo+c/JOS1rp4I/vd4r/G/sbBKlMcaZ5lzKQaFU0YHodqPwx09akbqsbZyQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-9de7a43bd1aso446227366b.3 for ; Sat, 18 Nov 2023 21:37:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372245; x=1700977045; 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=HQHV33mmBf57XVrG9+e6rQQykze7ZE9YLZHdETzIYC8=; b=blsWigO1QB9A48mEuusTIdjcAlDhEAZzZeI6m/0v1MbEMEFEsobKlEBMxNLjUOqlEl hm6WbAWmVC/R39iQ84b7w3RAVPo1KHTJGIXzMEQfxUlEM/748MOPIfsUNGmgFJQE53iE UnlCECLf1Av9gp/1KIzk0HcIk0X9ZbyXocO/VBhWs+8IR4glAnhoFVMFFLHnqtoB91VZ FR/W4ZItoRhtQnosyIos31YS046wrDPWJOwsf+qyTMcK9iEt/ziWKA/H7RRj7dDSw4kU +U1FV0dK0sA4Bz5v83IQ1FOdq2jnLad0sewIG4t0FZIPGy8u/Vg+nujQ+Pa4EGk/sRtx lzqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372245; x=1700977045; 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=HQHV33mmBf57XVrG9+e6rQQykze7ZE9YLZHdETzIYC8=; b=MitO3gfhodKZK3rvgeAPL7yHSJgjfKDZ0o9b+HvtRvsWLRihCMXg5eRPJdqTcufAaq mwfQCph3GKglaZnC3dHzj9JS5G5lnMkmJdGm3TXtWwfGAkQycY9yt9Q5YGNH0bb/kPXU fD70DLChS07bN5RL9kNWEF/ohCnASBK71ZxQUcSQAWav02DDAsFTu26O/X+k13LZRHxZ 9WiG0Z+ZnGyOSA2DjeU+rGc8Kh2PAauz0Rr9HI66RuCOMcjZwvdXh2uG2kQwx849Fstx EmcccCQmh48XhtOre+4cNLrpn0hrGEXOXlTAZ+CdlFb+9HG+5A5GgKe3RPK1kKMofWGX byQQ== X-Gm-Message-State: AOJu0YwhqiJd06CbQuRr4ACVg+7AXgHMK0XvidJk0XXu92h5oU/CXkpN ScmPFPQn6XZe5NajXQ13Vk2TILdTU1hFPPcu5Tz9TQ== X-Received: by 2002:a17:907:c018:b0:9bd:bbc1:1c5f with SMTP id ss24-20020a170907c01800b009bdbbc11c5fmr3072823ejc.35.1700372244792; Sat, 18 Nov 2023 21:37:24 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id c23-20020a170906155700b009c921a8aae2sm2516283ejd.7.2023.11.18.21.37.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:37:24 -0800 (PST) Date: Sun, 19 Nov 2023 05:37:20 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 11/44] RISC-V/testsuite: Add branchless cases for integer 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.0 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: 1782969563742704055 X-GMAIL-MSGID: 1782969563742704055 Verify, for T-Head, Ventana and Zicond targets and the integer conditional-move operations that already work as expected, if-conversion to trigger via `noce_try_cmove' at the respective sufficiently high `-mbranch-cost=' settings that make branchless code sequences produced by if-conversion cheaper than their original branched equivalents, and that extraneous instructions such as SNEZ, etc. are not present in output. Cover all integer relational operations to make sure no corner case escapes. gcc/testsuite/ * gcc.target/riscv/movdieq-thead.c: New test. * gcc.target/riscv/movdige-ventana.c: New test. * gcc.target/riscv/movdige-zicond.c: New test. * gcc.target/riscv/movdigeu-ventana.c: New test. * gcc.target/riscv/movdigeu-zicond.c: New test. * gcc.target/riscv/movdigt-ventana.c: New test. * gcc.target/riscv/movdigt-zicond.c: New test. * gcc.target/riscv/movdile-ventana.c: New test. * gcc.target/riscv/movdile-zicond.c: New test. * gcc.target/riscv/movdileu-ventana.c: New test. * gcc.target/riscv/movdileu-zicond.c: New test. * gcc.target/riscv/movdilt-ventana.c: New test. * gcc.target/riscv/movdilt-zicond.c: New test. * gcc.target/riscv/movdine-thead.c: New test. * gcc.target/riscv/movsieq-thead.c: New test. * gcc.target/riscv/movsige-ventana.c: New test. * gcc.target/riscv/movsige-zicond.c: New test. * gcc.target/riscv/movsigeu-ventana.c: New test. * gcc.target/riscv/movsigeu-zicond.c: New test. * gcc.target/riscv/movsigt-ventana.c: New test. * gcc.target/riscv/movsigt-zicond.c: New test. * gcc.target/riscv/movsile-ventana.c: New test. * gcc.target/riscv/movsile-zicond.c: New test. * gcc.target/riscv/movsileu-ventana.c: New test. * gcc.target/riscv/movsileu-zicond.c: New test. * gcc.target/riscv/movsilt-ventana.c: New test. * gcc.target/riscv/movsilt-zicond.c: New test. * gcc.target/riscv/movsine-thead.c: New test. --- gcc/testsuite/gcc.target/riscv/movdieq-thead.c | 26 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdige-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdige-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigeu-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigeu-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigt-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigt-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdile-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdile-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdileu-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdileu-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdilt-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdilt-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdine-thead.c | 26 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsieq-thead.c | 26 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsige-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsige-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigeu-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigeu-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigt-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigt-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsile-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsile-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsileu-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsileu-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsilt-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsilt-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsine-thead.c | 26 ++++++++++++++++++++ 28 files changed, 776 insertions(+) gcc-riscv-branch-cost-test-movcc.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdieq-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdieq-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branchless assembly like: + + sub a0,a0,a1 + th.mvnez a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\ssub\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdige-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdige-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 int __attribute__ ((mode (DI))) int_t; + +int_t +movdige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + slt a1,a0,a1 + vt.maskc a3,a3,a1 + vt.maskcn 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdige-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdige-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 int __attribute__ ((mode (DI))) int_t; + +int_t +movdige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + slt a1,a0,a1 + czero.eqz a3,a3,a1 + czero.nez 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdigeu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigeu-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 +movdigeu (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.maskc a3,a3,a1 + vt.maskcn 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/movdigeu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigeu-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 +movdigeu (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.eqz a3,a3,a1 + czero.nez 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/movdigt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigt-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 int __attribute__ ((mode (DI))) int_t; + +int_t +movdigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + sgt 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdigt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigt-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 int __attribute__ ((mode (DI))) int_t; + +int_t +movdigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + sgt 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdile-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdile-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 int __attribute__ ((mode (DI))) int_t; + +int_t +movdile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + sgt a1,a0,a1 + vt.maskc a3,a3,a1 + vt.maskcn 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdile-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdile-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 int __attribute__ ((mode (DI))) int_t; + +int_t +movdile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + sgt a1,a0,a1 + czero.eqz a3,a3,a1 + czero.nez 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdileu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdileu-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 +movdileu (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.maskc a3,a3,a1 + vt.maskcn 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/movdileu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdileu-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 +movdileu (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.eqz a3,a3,a1 + czero.nez 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/movdilt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdilt-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 int __attribute__ ((mode (DI))) int_t; + +int_t +movdilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + slt 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdilt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdilt-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 int __attribute__ ((mode (DI))) int_t; + +int_t +movdilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + slt 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdine-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdine-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + sub a1,a0,a1 + th.mveqz a2,a3,a1 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\ssub\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movsieq-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsieq-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branchless assembly like: + + sub a0,a0,a1 + th.mvnez a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\ssub\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movsige-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsige-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 int __attribute__ ((mode (SI))) int_t; + +int_t +movsige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + slt a1,a0,a1 + vt.maskc a3,a3,a1 + vt.maskcn 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsige-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsige-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 int __attribute__ ((mode (SI))) int_t; + +int_t +movsige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + slt a1,a0,a1 + czero.eqz a3,a3,a1 + czero.nez 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsigeu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigeu-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 +movsigeu (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.maskc a3,a3,a1 + vt.maskcn 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/movsigeu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigeu-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 +movsigeu (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.eqz a3,a3,a1 + czero.nez 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/movsigt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigt-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 int __attribute__ ((mode (SI))) int_t; + +int_t +movsigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + sgt 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsigt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigt-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 int __attribute__ ((mode (SI))) int_t; + +int_t +movsigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + sgt 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsile-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsile-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 int __attribute__ ((mode (SI))) int_t; + +int_t +movsile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + sgt a1,a0,a1 + vt.maskc a3,a3,a1 + vt.maskcn 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsile-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsile-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 int __attribute__ ((mode (SI))) int_t; + +int_t +movsile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + sgt a1,a0,a1 + czero.eqz a3,a3,a1 + czero.nez 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsileu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsileu-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 +movsileu (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.maskc a3,a3,a1 + vt.maskcn 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/movsileu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsileu-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 +movsileu (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.eqz a3,a3,a1 + czero.nez 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/movsilt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsilt-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 int __attribute__ ((mode (SI))) int_t; + +int_t +movsilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + slt 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsilt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsilt-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 int __attribute__ ((mode (SI))) int_t; + +int_t +movsilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + slt 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(?:sgt|slt)\\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(?:bge|bgt|ble|blt)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsine-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsine-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + sub a1,a0,a1 + th.mveqz a2,a3,a1 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\ssub\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ From patchwork Sun Nov 19 05:37:34 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: 166685 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505228vqn; Sat, 18 Nov 2023 21:38:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IG61kBZCbTUjU5orTVIz2+V48bRQQTEB3Hrq2vGiBrCppJner8owpe7MCvfIP1VlnoaLDn+ X-Received: by 2002:a05:6870:718c:b0:1ef:aba1:1995 with SMTP id d12-20020a056870718c00b001efaba11995mr4909811oah.59.1700372290425; Sat, 18 Nov 2023 21:38:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372290; cv=pass; d=google.com; s=arc-20160816; b=DJKBMQshOqN6QPAbxWcqEqXLyBwVCndGNRVGF7pyxCwihsZ72KuliUfNjdvVlRYttU dOBwtkIF8LSwQW8O8Lvzs45QR+wcFQlMCMt4OGHDouVYfe7NmpSAMifDjWtrnPGwc+Q7 b4QvyFonjzLjfjyGfXJHxCE+3nqEXWOpDsx60fNU/MDkcBay3XdG6on/AREyv0qt2wTw SJV4FhkHqGWyKPRQIZRw5ogFx1C0V+co1QBgvL+a+L/QAP0wCnpp766PYR0uZ4VbfeNH aqxc/XCdsr3IANWNgQXmMnnqJdtZ98GNsw4B0tQTiXWgcTW5U6BxOCsEOmgvJesWFlhB 13eg== 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=IwcXvomLA85Tt4XShKZFFIwEU89rG4l1saDwn1Izo7w=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=EMel0hOh12U/BOt0BwvehQuwokqQpqhZhx96++UH5Ypp9aaSar2sPUZegJn1MzEtmd AzosFUGAIcZfL04eIej/Bnlm67T0hoDH8Vl01w5i/Mk+8Cb72vdLcrG9aQzS3JPSyWMx Rf/4WU3hA360zz1+aEC8lWKYPw90vRdlkYJyCf3lTXjziMwLiXRdlWjQrs/3I+RtgcTg z/CbtokypqbuTpnl7k8xa7rcnh0pxgJ5JKbFj3kxyOwuX9/zCDHikiLB/KUmOxcCMtQQ u8K05CrJvLgdyyFr+5GmTmFkZIeN0hHaeV9QeI88CPwxdfums+LjVY4oX95mB81QwMd8 JTOQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=F9ckVZKb; 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 g5-20020ae9e105000000b0076dabaa2929si4871311qkm.188.2023.11.18.21.38.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:38:10 -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=F9ckVZKb; 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 293843857B95 for ; Sun, 19 Nov 2023 05:38:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by sourceware.org (Postfix) with ESMTPS id 322A53858281 for ; Sun, 19 Nov 2023 05:37:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 322A53858281 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 322A53858281 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372264; cv=none; b=Ap9Rlf/jl0U2N4FgAwO0ypn+hptRhGmJIAMjCexLvG9HuKmgAvbRl0f2KbgAYiRIafdmvobW/GlOaCDdR22+IM1hjmqFjA6D3kgW0xHNDQR/CPibRhr3wU3TibVKMKVeXdNo+A513LkFHzdlOTi8pqDCoUnxcJzanFwbxUYKaIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372264; c=relaxed/simple; bh=h3o7YyX+vpvQdZbvCMrJIJWibCQZlN9qVRjtBfNntkg=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=TtHBiic9kP/vrA56u3J48FnIxk3OhqtwkzqZlqIknOkJQQj32p0wuLObNdTmBcvRbJ3DaE6Cc2rkGgWZjSBT41OhOxmBB47moz92N9Bo48i5jWWFpRISjrnZAecOJa6yaba193f8cyJ2jQHDRUweuFzsZ7hElrrUzvRVfWJRbg0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-50aab0ca90aso346115e87.0 for ; Sat, 18 Nov 2023 21:37:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372258; x=1700977058; 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=IwcXvomLA85Tt4XShKZFFIwEU89rG4l1saDwn1Izo7w=; b=F9ckVZKbGsKjSLab2xeMh7DurcLAOxLVo3zRPMBFAVq28FKAofIPRqxXda367nHwkK wzzywMT4euzOzw4CIHCXzgrm8dGcqZVwckhFGVDAXpj4sGb3e/HOORrajNnKBGuzeyPS VGwHzwbP4hvK7iweYZXXQygOvR9g+QpPoOpPuQl75UMEkHUin0HKBwelMtBz96Ete0Fp TNt5qrlpDsU3xa13i+q0elt9l71W4lqFgT2q/Q4gfEJqmQTUaEsr54MVX65l27hqY8gc jhhyo2Xqw3JLqpYqYAXrDSsRdc7kNIRsAhIlFya3ILcUDAlu6TOIjIilf7qg/M6pV7NX Rqqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372258; x=1700977058; 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=IwcXvomLA85Tt4XShKZFFIwEU89rG4l1saDwn1Izo7w=; b=dRFWZQYi9pjrGy9IW7PNdbX6CnGGLKNbuBbMYV8UvRdskQdpUbSq6mVNv7Q/IfTRI5 JA7JLchX+Z2tLw1+u3qN2nLf6eAuuiJP+d4O7d7nEhj81wKzw3iOLRnen8/X/H/Yzgii cPgSpBVPtlkhpqNOyVEc9qUb5OcbCzaao2LVJuyWl+kHPlBR2weIdIR6pe53aWPNwPQg bQ2NU9J05Evv/UFnfwL+cOlZfxV/N25bfqeLcymzJn0Zo6NCLYs0MHiIeKAsHkJoD9Na W6Nc22YxxXtTkE7Z6+VFrxAeWQrM2IEl3YWfJii+VbuAg4jiFs1O+JM5KzKilZpue9HW NJJw== X-Gm-Message-State: AOJu0YyJwKvPJa6L6ZX8FW61LLoQ8xZb3mtnxUsR6PgOgf3BlIAZmmE0 4mLU75+EzEL/+pqW2Oj5P1GhbwD3bRBgYsMQdWxqbA== X-Received: by 2002:ac2:532f:0:b0:509:5d4b:44c4 with SMTP id f15-20020ac2532f000000b005095d4b44c4mr2620971lfh.1.1700372258418; Sat, 18 Nov 2023 21:37:38 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id dk26-20020a170906f0da00b009fc0c42098csm683780ejb.173.2023.11.18.21.37.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:37:37 -0800 (PST) Date: Sun, 19 Nov 2023 05:37:34 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 12/44] RISC-V/testsuite: Add branched cases for FP 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=1.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_20_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: 1782969574486973166 X-GMAIL-MSGID: 1782969574486973166 Verify, for Ventana and Zicond targets and the ordered floating-point conditional-move operations that already work as expected, that if-conversion does *not* trigger at `-mbranch-cost=2' setting, which makes original branched code sequences cheaper than their branchless equivalents if-conversion would emit. Cover all ordered floating-point relational operations to make sure no corner case escapes. gcc/testsuite/ * gcc.target/riscv/movdibfge-ventana.c: New test. * gcc.target/riscv/movdibfge-zicond.c: New test. * gcc.target/riscv/movdibfgt-ventana.c: New test. * gcc.target/riscv/movdibfgt-zicond.c: New test. * gcc.target/riscv/movdibfle-ventana.c: New test. * gcc.target/riscv/movdibfle-zicond.c: New test. * gcc.target/riscv/movdibflt-ventana.c: New test. * gcc.target/riscv/movdibflt-zicond.c: New test. * gcc.target/riscv/movdibfne-ventana.c: New test. * gcc.target/riscv/movdibfne-zicond.c: New test. * gcc.target/riscv/movsibfge-ventana.c: New test. * gcc.target/riscv/movsibfge-zicond.c: New test. * gcc.target/riscv/movsibfgt-ventana.c: New test. * gcc.target/riscv/movsibfgt-zicond.c: New test. * gcc.target/riscv/movsibfle-ventana.c: New test. * gcc.target/riscv/movsibfle-zicond.c: New test. * gcc.target/riscv/movsibflt-ventana.c: New test. * gcc.target/riscv/movsibflt-zicond.c: New test. * gcc.target/riscv/movsibfne-ventana.c: New test. * gcc.target/riscv/movsibfne-zicond.c: New test. --- gcc/testsuite/gcc.target/riscv/movdibfge-ventana.c | 29 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibfge-zicond.c | 29 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibfgt-ventana.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibfgt-zicond.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibfle-ventana.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibfle-zicond.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibflt-ventana.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibflt-zicond.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibfne-ventana.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibfne-zicond.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfge-ventana.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfge-zicond.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfgt-ventana.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfgt-zicond.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfle-ventana.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfle-zicond.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibflt-ventana.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibflt-zicond.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfne-ventana.c | 30 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfne-zicond.c | 30 +++++++++++++++++++++ 20 files changed, 598 insertions(+) gcc-riscv-branch-cost-test-movccf-branch.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdibfge-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfge-ventana.c @@ -0,0 +1,29 @@ +/* { 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 +movdifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + fge.d a4,fa0,fa1 + mv a5,a0 + mv a0,a1 + beq a4,zero,.L2 + mv a0,a5 + */ + +/* { 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 "\\s(?:fge\\.d|fle\\.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/movdibfge-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfge-zicond.c @@ -0,0 +1,29 @@ +/* { 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 +movdifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + fge.d a4,fa0,fa1 + mv a5,a0 + mv a0,a1 + beq a4,zero,.L2 + mv a0,a5 + */ + +/* { 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 "\\s(?:fge\\.d|fle\\.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/movdibfgt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfgt-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 +movdifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + fgt.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 "\\s(?:fgt\\.d|flt\\.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/movdibfgt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfgt-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 +movdifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + fgt.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 "\\s(?:fgt\\.d|flt\\.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/movdibfle-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfle-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 +movdifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + fle.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 "\\s(?:fge\\.d|fle\\.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/movdibfle-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfle-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 +movdifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + fle.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 "\\s(?:fge\\.d|fle\\.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/movdibflt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibflt-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 +movdiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + flt.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 "\\s(?:fgt\\.d|flt\\.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/movdibflt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibflt-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 +movdiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + flt.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 "\\s(?:fgt\\.d|flt\\.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/movdibfne-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfne-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 +movdifne (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 + bne 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/movdibfne-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfne-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 +movdifne (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 + bne 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/movsibfge-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfge-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 +movsifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + fge.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 "\\s(?:fge\\.d|fle\\.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/movsibfge-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfge-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 +movsifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + fge.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 "\\s(?:fge\\.d|fle\\.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/movsibfgt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfgt-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 +movsifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + fgt.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 "\\s(?:fgt\\.d|flt\\.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/movsibfgt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfgt-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 +movsifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + fgt.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 "\\s(?:fgt\\.d|flt\\.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/movsibfle-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfle-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 +movsifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + fle.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 "\\s(?:fge\\.d|fle\\.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/movsibfle-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfle-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 +movsifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + fle.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 "\\s(?:fge\\.d|fle\\.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/movsibflt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibflt-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 +movsiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + flt.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 "\\s(?:fgt\\.d|flt\\.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/movsibflt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibflt-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 +movsiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + flt.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 "\\s(?:fgt\\.d|flt\\.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/movsibfne-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfne-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 +movsifne (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 + bne 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/movsibfne-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfne-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 +movsifne (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 + bne 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" } } */ From patchwork Sat Nov 18 16:50:43 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: 166584 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1271543vqn; Sat, 18 Nov 2023 08:51:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHDgrpTvQRlPLMSs6jCNiaA/ST4np1xvUSXWLvioBMBjGna+eehGESTBUurteUbEbuRQD1 X-Received: by 2002:a05:6808:2a02:b0:3ac:a522:5461 with SMTP id ez2-20020a0568082a0200b003aca5225461mr3315362oib.36.1700326289225; Sat, 18 Nov 2023 08:51:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700326289; cv=pass; d=google.com; s=arc-20160816; b=xWX0EYWGuW93xl/djxfXu/+jjmaJJHcnDzXS+1sPbFGbLQJbpOwpvgelRqJ55DavdU ZalEmF7TGcRTNvfiJ4ICSIRmXesq9jRe0faKeSZ1b+gd7Tn6Gn51oU0u/8hZeFSBlFNU tdWVXN2apynVK7icwfVEbKMxglCEDuqySyDrnwWC5gNduwmPoYaci7L3pkZ2w5y6Pnm9 81blhyKW/ahVCwxSxzVNP1ckJxY3ChejEDKuaos7osg1jrqGGXxwXzJVHnifOh1waM7X YTZ7J/uU/DrX+kcYHhyNwSKlSdmfUg4dyxCyGs5Zd18BdmmiB61dKhzXH2/S5zJw+Dwe gQ9Q== 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=GmD8zERWYvjGz15uJ9wpZexX00zqLJgFeyzMRyR8dU4=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=awG6rXBMmZWVxSoK8eSgDO1w1rWH/Oq6YxF3aDhqLOGSJNRZQn6yj5Gp9hdw+3hmc7 8sq22j52uw2LavrsHE208cHOU5l2ZykKDhdDHXReqmdy8dYmOTz8i9VWrkuTHTVVrVvp Zvpm5Vav5zojqvpXw4kinTAaQYQU2Sc6e/bgt4N+iGkN5AIygSfb859xZ0XnXYGG8+KI q3PfJUkbUrNRKCqjJrBmjC0QM2BL+3gH2TRsv58vkudHsn7zLu8JajM47oChT7KrxD3h RJmyWYbMJINEaMmaftuFPO6glfTaodQVAR4JURKmL+dn8ogE0cGlNvEa21q853B4MXCg mjzw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=UUuolZdb; 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 a23-20020a05620a103700b007777f01f8e7si3699455qkk.575.2023.11.18.08.51.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 08:51:29 -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=UUuolZdb; 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 E8AAF3858C2D for ; Sat, 18 Nov 2023 16:51:28 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id 396613858D1E for ; Sat, 18 Nov 2023 16:50:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 396613858D1E 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 396613858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700326259; cv=none; b=vcn2qbBbx+1bXczFa6FVn0zxTr21Bl519nxOHtFf2VepPN+RXYRMqYONMeWo4pa0TBAkG+FVLetCpNT1OzFTEao5S3xyjnvdGwxxul4AdHCC46iPmNJsBcaoZGFQ3n5PMrkHkFuyPqH9/Y8rreJ1JATKvNnIa8P3TXPBFqFRRTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700326259; c=relaxed/simple; bh=M9wfd6iMkH9cSAXAPIBPDrADCr+xc+9umVKHY/rF06I=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=jnQe5ZWP4aRy/P1nE+5ITbQGaymR59hf7OMO0xaipPa0dKP6XGlGuO9jm4zxufnDk3Mx6sICjvbU6NZ9lDU5CjJDyzGbviQmEHFKNq8V8KZDRTLWpTzhHcXlYYpAJiik6cInR7bL61YtbjuiNTuVNTFYKmvUr+O9OIAq+cBpiHY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-53e751aeb3cso4281206a12.2 for ; Sat, 18 Nov 2023 08:50:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700326252; x=1700931052; 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=GmD8zERWYvjGz15uJ9wpZexX00zqLJgFeyzMRyR8dU4=; b=UUuolZdbg1gNC2ec6zClbOEZI9NpbkymSBkAn2b/49uDewLZfa8cWlMI6Q5NkrOIsv XyR34RSi70Cu1Sl/TCt+n4KUDULu8zvhVIg+NRxWGiKoAVkn3oSzTwn0poSEIi/hwEsB Dm2USiPsjp17r/d464eHs491dYjEfzXw6KXM2RLrKnJEBym+UlIOoUdgxsToHhVx/j1p b7poNroxXqMiZd8XWT4eg3uE5t9uSmofd4g7PPQ5YJGwLgdHlH51GtHyIglw6TbftGwI V4VbdzkHnUSA4lGyMzidgS0HMajDLyKt2fFf2SVYYOzMtGro5Zr+o9Vzs8+C2J/2fJ9N 7rwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700326252; x=1700931052; 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=GmD8zERWYvjGz15uJ9wpZexX00zqLJgFeyzMRyR8dU4=; b=AAiEWUk4SswX3HrYH1cpU33UY6FCvPySQcK8daWWZuRCyuy9uoDkdqFaHmucfOgxvg GkqD4cXKvoxHVi2SrPnpGaLQ0P2yinGRWbkKKAkXrpaGvl01xv0USGD6IOy3HGR9IqVW aBNeg5Q06mkB5mg0kSIU53Q4DUTWDs+RiZzGz1DVuZgPOIK3BztJP5Ae0whDweaWBm2Y qprXRP25FzzZVH51C5D06g4GqrnFTGQL9a+hreSI8OJhJafYiA6tku4C5mt10u3Dxaon 1M2/wrhjSWiEbWAM7ilkw5LlIbS/58fkVtUsG39n5CiTpQbFW419G05RZgLdif+tCkej CQng== X-Gm-Message-State: AOJu0Yykne/W8OLaEpYN90+9X7W3Ggkl5WkUf+IkvEa99TmLvwzT3FSE Ofe522QsBKKtBkqkbSdGLIDt1NRQpLfak8rTQD6fZg== X-Received: by 2002:a17:906:27d4:b0:9be:6395:6b12 with SMTP id k20-20020a17090627d400b009be63956b12mr1671526ejc.27.1700326250799; Sat, 18 Nov 2023 08:50:50 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id a10-20020a17090640ca00b009fc22b3f619sm132452ejk.68.2023.11.18.08.50.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 08:50:50 -0800 (PST) Date: Sat, 18 Nov 2023 16:50:43 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 13/44] RISC-V/testsuite: Add branchless cases for FP 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: 1782921338788082434 X-GMAIL-MSGID: 1782921338788082434 Verify, for short forward branch, T-Head, Ventana and Zicond targets and the ordered floating-point conditional-move operations that already work as expected, that if-conversion triggers via `noce_try_cmove' at the respective sufficiently high `-mbranch-cost=' settings that make branchless code sequences produced by if-conversion cheaper than their original branched equivalents, and that extraneous instructions such as SNEZ, etc. are not present in output. Cover all ordered floating-point relational operations to make sure no corner case escapes. gcc/testsuite/ * gcc.target/riscv/movdifge-sfb.c: New test. * gcc.target/riscv/movdifge-thead.c: New test. * gcc.target/riscv/movdifge-ventana.c: New test. * gcc.target/riscv/movdifge-zicond.c: New test. * gcc.target/riscv/movdifgt-sfb.c: New test. * gcc.target/riscv/movdifgt-thead.c: New test. * gcc.target/riscv/movdifgt-ventana.c: New test. * gcc.target/riscv/movdifgt-zicond.c: New test. * gcc.target/riscv/movdifle-sfb.c: New test. * gcc.target/riscv/movdifle-thead.c: New test. * gcc.target/riscv/movdifle-ventana.c: New test. * gcc.target/riscv/movdifle-zicond.c: New test. * gcc.target/riscv/movdiflt-sfb.c: New test. * gcc.target/riscv/movdiflt-thead.c: New test. * gcc.target/riscv/movdiflt-ventana.c: New test. * gcc.target/riscv/movdiflt-zicond.c: New test. * gcc.target/riscv/movdifne-sfb.c: New test. * gcc.target/riscv/movdifne-thead.c: New test. * gcc.target/riscv/movdifne-ventana.c: New test. * gcc.target/riscv/movdifne-zicond.c: New test. * gcc.target/riscv/movsifge-sfb.c: New test. * gcc.target/riscv/movsifge-thead.c: New test. * gcc.target/riscv/movsifge-ventana.c: New test. * gcc.target/riscv/movsifge-zicond.c: New test. * gcc.target/riscv/movsifgt-sfb.c: New test. * gcc.target/riscv/movsifgt-thead.c: New test. * gcc.target/riscv/movsifgt-ventana.c: New test. * gcc.target/riscv/movsifgt-zicond.c: New test. * gcc.target/riscv/movsifle-sfb.c: New test. * gcc.target/riscv/movsifle-thead.c: New test. * gcc.target/riscv/movsifle-ventana.c: New test. * gcc.target/riscv/movsifle-zicond.c: New test. * gcc.target/riscv/movsiflt-sfb.c: New test. * gcc.target/riscv/movsiflt-thead.c: New test. * gcc.target/riscv/movsiflt-ventana.c: New test. * gcc.target/riscv/movsiflt-zicond.c: New test. * gcc.target/riscv/movsifne-sfb.c: New test. * gcc.target/riscv/movsifne-thead.c: New test. * gcc.target/riscv/movsifne-ventana.c: New test. * gcc.target/riscv/movsifne-zicond.c: New test. --- gcc/testsuite/gcc.target/riscv/movdifge-sfb.c | 26 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifge-thead.c | 25 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifge-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifge-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifgt-sfb.c | 26 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifgt-thead.c | 25 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifgt-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifgt-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifle-sfb.c | 26 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifle-thead.c | 25 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifle-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifle-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiflt-sfb.c | 26 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiflt-thead.c | 25 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiflt-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiflt-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifne-sfb.c | 27 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifne-thead.c | 25 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifne-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifne-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifge-sfb.c | 26 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifge-thead.c | 25 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifge-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifge-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifgt-sfb.c | 26 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifgt-thead.c | 25 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifgt-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifgt-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifle-sfb.c | 26 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifle-thead.c | 25 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifle-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifle-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiflt-sfb.c | 26 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiflt-thead.c | 25 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiflt-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiflt-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifne-sfb.c | 27 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifne-thead.c | 25 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifne-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifne-zicond.c | 28 ++++++++++++++++++++++ 40 files changed, 1072 insertions(+) gcc-riscv-branch-cost-test-movccf.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdifge-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifge-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect short forward branch assembly like: + + fge.d a5,fa0,fa1 + bne a5,zero,1f # movcc + mv a0,a1 +1: + */ + +/* { 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(?:fge\\.d|fle\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifge-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifge-thead.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + fge.d a5,fa0,fa1 + th.mveqz a0,a1,a5 + */ + +/* { 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(?:fge\\.d|fle\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdifge-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifge-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + fge.d a5,fa0,fa1 + vt.maskc a0,a0,a5 + vt.maskcn a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifge-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifge-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + fge.d a5,fa0,fa1 + czero.eqz a0,a0,a5 + czero.nez a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifgt-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifgt-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect short forward branch assembly like: + + fgt.d a5,fa0,fa1 + bne a5,zero,1f # movcc + mv a0,a1 +1: + */ + +/* { 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(?:fgt\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifgt-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifgt-thead.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + fgt.d a5,fa0,fa1 + th.mveqz a0,a1,a5 + */ + +/* { 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(?:fgt\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdifgt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifgt-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + fgt.d a5,fa0,fa1 + vt.maskc a0,a0,a5 + vt.maskcn a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifgt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifgt-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + fgt.d a5,fa0,fa1 + czero.eqz a0,a0,a5 + czero.nez a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifle-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifle-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect short forward branch assembly like: + + fle.d a5,fa0,fa1 + bne a5,zero,1f # movcc + mv a0,a1 +1: + */ + +/* { 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(?:fge\\.d|fle\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifle-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifle-thead.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + fle.d a5,fa0,fa1 + th.mveqz a0,a1,a5 + */ + +/* { 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(?:fge\\.d|fle\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdifle-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifle-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + fle.d a5,fa0,fa1 + vt.maskc a0,a0,a5 + vt.maskcn a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifle-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifle-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + fle.d a5,fa0,fa1 + czero.eqz a0,a0,a5 + czero.nez a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdiflt-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiflt-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect short forward branch assembly like: + + flt.d a5,fa0,fa1 + bne a5,zero,1f # movcc + mv a0,a1 +1: + */ + +/* { 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(?:fgt\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdiflt-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiflt-thead.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + flt.d a5,fa0,fa1 + th.mveqz a0,a1,a5 + */ + +/* { 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(?:fgt\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdiflt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiflt-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + flt.d a5,fa0,fa1 + vt.maskc a0,a0,a5 + vt.maskcn a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdiflt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiflt-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + flt.d a5,fa0,fa1 + czero.eqz a0,a0,a5 + czero.nez a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifne-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifne-sfb.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect short forward branch assembly like: + + feq.d a5,fa0,fa1 + bne a5,zero,1f # movcc + mv a1,a0 +1: + mv a0,a1 + */ + +/* { 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 "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifne-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifne-thead.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + feq.d a5,fa0,fa1 + th.mvnez a0,a1,a5 + */ + +/* { 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 "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdifne-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifne-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + feq.d a5,fa0,fa1 + vt.maskc a1,a1,a5 + vt.maskcn a0,a0,a5 + or a0,a0,a1 + */ + +/* { 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 "\\sfeq\\.d\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifne-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifne-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + feq.d a5,fa0,fa1 + czero.eqz a1,a1,a5 + czero.nez a0,a0,a5 + or a0,a0,a1 + */ + +/* { 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 "\\sfeq\\.d\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifge-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifge-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect short forward branch assembly like: + + fge.d a5,fa0,fa1 + bne a5,zero,1f # movcc + mv a0,a1 +1: + */ + +/* { 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(?:fge\\.d|fle\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifge-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifge-thead.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + fge.d a5,fa0,fa1 + th.mveqz a0,a1,a5 + */ + +/* { 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(?:fge\\.d|fle\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifge-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifge-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + fge.d a5,fa0,fa1 + vt.maskc a0,a0,a5 + vt.maskcn a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\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(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifge-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifge-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + fge.d a5,fa0,fa1 + czero.eqz a0,a0,a5 + czero.nez a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\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(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifgt-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifgt-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect short forward branch assembly like: + + fgt.d a5,fa0,fa1 + bne a5,zero,1f # movcc + mv a0,a1 +1: + */ + +/* { 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(?:fgt\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifgt-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifgt-thead.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + fgt.d a5,fa0,fa1 + th.mveqz a0,a1,a5 + */ + +/* { 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(?:fgt\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifgt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifgt-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + fgt.d a5,fa0,fa1 + vt.maskc a0,a0,a5 + vt.maskcn a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\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(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifgt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifgt-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + fgt.d a5,fa0,fa1 + czero.eqz a0,a0,a5 + czero.nez a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\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(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifle-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifle-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect short forward branch assembly like: + + fle.d a5,fa0,fa1 + bne a5,zero,1f # movcc + mv a0,a1 +1: + */ + +/* { 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(?:fge\\.d|fle\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifle-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifle-thead.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + fle.d a5,fa0,fa1 + th.mveqz a0,a1,a5 + */ + +/* { 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(?:fge\\.d|fle\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifle-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifle-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + fle.d a5,fa0,fa1 + vt.maskc a0,a0,a5 + vt.maskcn a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\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(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifle-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifle-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + fle.d a5,fa0,fa1 + czero.eqz a0,a0,a5 + czero.nez a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\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(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiflt-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiflt-sfb.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect short forward branch assembly like: + + flt.d a5,fa0,fa1 + bne a5,zero,1f # movcc + mv a0,a1 +1: + */ + +/* { 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(?:fgt\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiflt-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiflt-thead.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + flt.d a5,fa0,fa1 + th.mveqz a0,a1,a5 + */ + +/* { 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(?:fgt\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiflt-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiflt-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + flt.d a5,fa0,fa1 + vt.maskc a0,a0,a5 + vt.maskcn a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\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(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiflt-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiflt-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + flt.d a5,fa0,fa1 + czero.eqz a0,a0,a5 + czero.nez a5,a1,a5 + or 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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\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(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifne-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifne-sfb.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect short forward branch assembly like: + + feq.d a5,fa0,fa1 + bne a5,zero,1f # movcc + mv a1,a0 +1: + mv a0,a1 + */ + +/* { 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 "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifne-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifne-thead.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + feq.d a5,fa0,fa1 + th.mvnez a0,a1,a5 + */ + +/* { 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 "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifne-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifne-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + feq.d a5,fa0,fa1 + vt.maskc a1,a1,a5 + vt.maskcn a0,a0,a5 + or a0,a0,a1 + */ + +/* { 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 "\\sfeq\\.d\\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(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifne-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifne-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + feq.d a5,fa0,fa1 + czero.eqz a1,a1,a5 + czero.nez a0,a0,a5 + or a0,a0,a1 + */ + +/* { 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 "\\sfeq\\.d\\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(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ From patchwork Sun Nov 19 05:38:04 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: 166687 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505425vqn; Sat, 18 Nov 2023 21:39:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4FFkov59FJLEXSWdTuoGffxQOtxDbRzXhFXJIMlVvgmyPjqO8Lq8bVBEw8qP7/NZCPIWc X-Received: by 2002:a05:6214:413:b0:679:d38d:d762 with SMTP id z19-20020a056214041300b00679d38dd762mr1118153qvx.14.1700372348582; Sat, 18 Nov 2023 21:39:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372348; cv=pass; d=google.com; s=arc-20160816; b=UWpmPHb1ZrVlUFP188/17VUE+Cr86l3PbTJpNBlGFKMf7/QMsRG13JHKEvdan479MV IRQmEBH0IEfJhFY91dIixjme4gsE8zSNB8Eg5QdskNi1lKZX8BFn8OsGkzNm3XhzzLen 1FrX19IQrmLkajKMsDCP8dl9kErlhciTNXeSNLKqMBrtc2pwSGbKKEAoZWEzAScUjkQt MfYoVndwbq7N16Ch9y9U0hdGJPQHK5i0olRTWPAbBHuRjrxM7YoKBe9CFme+jftzNutp uHMz8iMs42SSYeHfnS1wvug+AnE4PjN4GxsSIXuLff4qoATqSZdLhMYhoMqeYjJirdWa QdnQ== 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=OjDw29N1YKlZMJdL+NWZL9X57R3rSi4gVEy63bC0+c8=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=LwAr6rmXrhmNsK1NnLg3zUAVmYiChxFemsCx7SJK3fv2FR1FKUEYxCMDbL8k5jOCRx g/zIJMgx2JjfkKRGSHaTbgWu+zjvc3DpLmoe7PP007UBILKvchqdcMq5E7j0ZFI9Sjv/ Aetp3znp9rM91tgLgW0p9uNBqJeztgQR97jDapijyTKPEXknfbjJVaxkBya1FPsents8 zphdtC/WJvzBT2Of/YerIRBCfwccdiKmGKnkZzU7cRB/utw1h/74mmEqRncvGfZ9m3C7 HKyOycO5TWRi65UAAxJWW8rEgzG9rpMI+p7UQjC75WapHkjEFrUegLFQP6mKEbE/QrY8 fGyQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=ANxgyvas; 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 u2-20020a0ced22000000b00671366dbfc2si4850002qvq.328.2023.11.18.21.39.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:39:08 -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=ANxgyvas; 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 7E7373860C0B for ; Sun, 19 Nov 2023 05:39:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id A165938582AC for ; Sun, 19 Nov 2023 05:38:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A165938582AC 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 A165938582AC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372289; cv=none; b=xdF3wPkPG8KSaz2HNTJBAqg3ox4MTh6EwdQinyb1zuK62ThL4SQAb0Qiuh/NCyOsz/09l6jcPDkK7uU4saPdgjLMUfcixpHjCZitu9nMUMUQ+dopSI4Z1ZO9/ASOjJqjRz9KCXZ/B8+muaY1wUjo7e0I1HPZCGOkeFzP0+D+MPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372289; c=relaxed/simple; bh=pap/JLlPdF61gIyjxpSjU8My27R0lHVfrFOfYEdHskU=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=HR+6L/ECk9sLCkdlsTK01wLFUBcsuOD6gvxfNLInEchyniNZ+yL+uucwUyemV0GS02hI5d/uQ1o5c0RZbeUWK70CcVuBLN9N8BTsCJF+83sKbbbmYn27L7oFBFiJI33wTT9ep/Afyfq+eqbupE6VEB6yjKRcKbwOuI7J5W/DyWA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-53e04b17132so4709446a12.0 for ; Sat, 18 Nov 2023 21:38:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372286; x=1700977086; 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=OjDw29N1YKlZMJdL+NWZL9X57R3rSi4gVEy63bC0+c8=; b=ANxgyvaswjn7WqCKJDGLXhb5Zz9YgqEc+PgZ8cXH+Vq5Z3gtJf0vgp0vPnfjlWQAQd G3O9VKWEm+o014VmMWccaypVpWlrPFTuimvXjx4iSIqTl7HKi9C3F/Y5fZcqs7IBH761 qp6dHNmMGDamzlX8TXBAvxy6i1csYMHq08HzL4ZvcpX11NpEh+S4DHgT1aqh8Z5e0Du6 muktym4i8OjrZwcyW/X3XUG8bRZzNx8llchj4aahrVplPALSBGO7cGfAWYoUXBYV/FpG 9S3SWkStN5aRG2DXt6VIvwi7zRFZn2Q0SdjH6umxkNU2aeeXk1UrkJ07IOiXttmEPQzN tSAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372286; x=1700977086; 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=OjDw29N1YKlZMJdL+NWZL9X57R3rSi4gVEy63bC0+c8=; b=ItV1F+ar80Y/tTkotBxBmpTcOFgr0yKx3GBnglfA0Wei6BCrDt3YIT+sZiJonbaOgk yaMkH6+a7TxCn7bfIjy1siMzl3iCBkx0Aj2MLATTNezcfUDUyzF8xRdfGn4qlWeg4Vvh ths/bkasIMGaW+zYuA5ROhqZT/Ptv3kHXSM/s9ncVSM7PQyQti4DaItV4kgqtlccbi/T S67DVutu4jzsbb6RBGm2f+6pGmlvAdxqg47J4g98/HZNN81m69WY44rTBhtp+GeHEJ1M /S6FUA+hFD32f6C5BHfEpDwB+PSNb2NU06X6FeQsXdnTTkvA2GSVYxaoiKlJWfPw5qw7 e9Gw== X-Gm-Message-State: AOJu0Ywmpwt7MchRLXNkpp9k7Cs/b7YBjHXs9mw7DOsZwlaGH0VayzlL e1ere9UDn3B7+xl2EcTORoZISzngOvm1Zr59PuoGvg== X-Received: by 2002:a17:907:1c23:b0:9e5:2b1f:13f4 with SMTP id nc35-20020a1709071c2300b009e52b1f13f4mr3585777ejc.42.1700372286359; Sat, 18 Nov 2023 21:38:06 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id l21-20020a1709061c5500b009fda665860csm49874ejg.22.2023.11.18.21.38.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:38:06 -0800 (PST) Date: Sun, 19 Nov 2023 05:38:04 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 14/44] RISC-V: Also invert the cond-move condition for GEU and LEU 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.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969635787963402 X-GMAIL-MSGID: 1782969635787963402 Update `riscv_expand_conditional_move' and handle the missing GEU and LEU operators there, avoiding an extraneous conditional set operation, such as with this output: sgtu a0,a0,a1 seqz a1,a0 czero.eqz a3,a3,a1 czero.nez a1,a2,a1 or a0,a1,a3 produced when optimizing for Zicond targets from: int movsigtu (int w, int x, int y, int z) { return w > x ? y : z; } These operators can be inverted producing optimal code such as this: sgtu a1,a0,a1 czero.nez a3,a3,a1 czero.eqz a1,a2,a1 or a0,a1,a3 which this change causes to happen. gcc/ * config/riscv/riscv.cc (riscv_expand_conditional_move): Also invert the condition for GEU and LEU. --- gcc/config/riscv/riscv.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) gcc-riscv-expand-conditional-move-geu-leu.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -4142,7 +4142,7 @@ riscv_expand_conditional_move (rtx dest, /* If riscv_expand_int_scc inverts the condition, then it will flip the value of INVERT. We need to know where so that we can adjust it for our needs. */ - if (code == LE || code == GE) + if (code == LE || code == LEU || code == GE || code == GEU) invert_ptr = &invert; /* Emit an scc like instruction into a temporary From patchwork Sun Nov 19 05:38:13 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: 166691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505554vqn; Sat, 18 Nov 2023 21:39:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpO6BVHwp85H7AIPei+O6TYlESZQaIL0J3rC8nCWETBsw1SD4yrCgGUzOHVlVRqj5POU9V X-Received: by 2002:a05:620a:6845:b0:779:e171:3356 with SMTP id ru5-20020a05620a684500b00779e1713356mr5086606qkn.53.1700372388778; Sat, 18 Nov 2023 21:39:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372388; cv=pass; d=google.com; s=arc-20160816; b=ma230QEM6dimFn2evq4i28ZytWDn9j0SGf6+HJ0BVgV18NjdrRXtttLI3Ogm7lN18g PUgAKR33xQVVg35LgDiIZxwDi1VMNP67gsadQkEJxW99HlNcg2W2b8BVifRaXIx/++oY GWJ1Io1LHORrEcpLTH7UacOxmitbFhTnA+/p4Lu+vLFQng5SKDIgqlxq6aL2V3g7dczW FLCbpracBlFN+O2IlmaCGeV9utc4h0kzFJIkey3FYygoBIZUCbOvLTnc/1zYpti/ivw/ fHix97yqGn3ZLe+Lu3cETDzbmHsxyn7DY6CVDoO7hWPd055dYdGm+3pHInbpETtup7ms RcHw== 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=bLFWeakzIYkVBjJlZ/GL7Fo4N4ZMJyp7LayAAHzEl2Y=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=e/hD3elEL5j2mNO94kFBJR2B/sl5Rp87XdWRXzyAaepDxt3duBv84zp0CuXTWOQ5ui prx9VqbGtAW6X3wK+ybMHup++DMzxpBT59QKFd3id9QrSMoP0de5vMOvlul+XjNh3uLG wmnP1SSm2pXScU94zdn8CiuEkHLLoZ6bYadigAqtRWDVlVRjmReANOqJPGSludJK2jMj JPUMaLq+MM27naoqlpC7Ix9dSToRRnD3mUJNWuoDadcUY0RMre/vS/jI6QGWQAwNerRh +vYV7PTxqg28m0o3tJrcR0XXbtJpbwDV99/ib+aN8me9qtBfxfEnzQWkyXekPwjq4Sx0 jzuw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=arplbYu9; 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 c12-20020a05620a0cec00b0077a51a904easi4679003qkj.774.2023.11.18.21.39.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:39:48 -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=arplbYu9; 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 0ED3A3861821 for ; Sun, 19 Nov 2023 05:39:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id 7A11F3858427 for ; Sun, 19 Nov 2023 05:38:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A11F3858427 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 7A11F3858427 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372299; cv=none; b=rsRPWinaos+owjEb06AzkYRuDtWdA92VLRcxW9lfRyB0R7+2+CwB872iiiZubajpI+OKCcLjZl2GEACJAnypwMOfA7U0xyE5FY64fU58OW/khCqnOalavK3ZoVFQUtO3DfIVdQjcRjFgcNBdQcZJi7qxvGtyGNOLJiOhpAPbRCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372299; c=relaxed/simple; bh=PzVk3TVtf2i5YIUVWtxof6t6BPGUS97pipxzl5ZGat0=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=dQ4H4zpAgnSEE50s1wXVqvxtZ55gzLpJ/9oK3gGvKDD4iTY3Ob7Vc/vDajStcFOaDAaOvBC1tB0JehWUMbp5MX4JV8uk0MvUbyQnnNYUryOh4dW+iSeyaThT+xK7VQlhBPIPfQET41ZRXYIc99xzOEPNHEvoVb/5wTxtLRUJjmQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-50797cf5b69so4417169e87.2 for ; Sat, 18 Nov 2023 21:38:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372296; x=1700977096; 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=bLFWeakzIYkVBjJlZ/GL7Fo4N4ZMJyp7LayAAHzEl2Y=; b=arplbYu9KQ5lHMT+cklNgex7ftSZdG54/O9bw/uz1hLhNGB7jpvXi37UDD7ZES5sIm YsqIKgIAo0oHFJPhU4UoHKG1oJY+0eO+ht/h+01tIhHttfCM0EoQf7YR8mwqi4CwYJG1 4XiPE2g1dUB1yEa+0r+QDLyfQ1pzY95ldHibH31tNvvRTB/2Af9mD+bfvAGT3NC+Ol9W vNDfNfCJW10lfCKlZ2cG9R9/XI3CChukcSZAG/lISanx7+yQsO8Fj2fFuljbpYoE5u6L vPPSpE+PtYbasgJlrUisiCM6UYBB5H/SbeAVA+ca/Abv239Dw6FxbVTu5072kr07bLiR DvWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372296; x=1700977096; 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=bLFWeakzIYkVBjJlZ/GL7Fo4N4ZMJyp7LayAAHzEl2Y=; b=a11Gdl6ODgtHJp+giXfCN5szOdoq9JbmcbkyZHgJmtZkMc+/meiLHYAe6yVo4k1rnn IG29VU8p+73GLJZ2gbAAxTga0xCoBEJ33wa/eS9vrTiIOrMxmHMGOH1/hElhWf0EDcDK l2JfHPZWUAdYW/CnyNRcIa9ctTvS9WijoHwi+/ClkcSA6qd79L8xqWIMldVlYlDvc6de 05Po521xoimOCkYBSVYG2CimKM3uXRItwV2L9yIXl9TYTVBkYTjr6ihXNFIdvSOFauLN 3j5LtNWBrqDRTbOv6eRwS9hYHANSJSCQ7qAsJlhGb6gWkrO+kO72fY75ZOAHhnItuoFz KG5Q== X-Gm-Message-State: AOJu0YztKE1eEG78OaOMaKppzGFpgR5nFs/2NDb2sYopwvNQdjIdD8qQ tA7gPU41WMQ8fYInYwVZX9iM7cY88XucDFXQfUJfUg== X-Received: by 2002:a05:6512:aca:b0:50a:a9e1:6c58 with SMTP id n10-20020a0565120aca00b0050aa9e16c58mr1669840lfu.32.1700372296020; Sat, 18 Nov 2023 21:38:16 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id dx3-20020a170906a84300b009c5c5c2c5a4sm2512229ejb.219.2023.11.18.21.38.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:38:15 -0800 (PST) Date: Sun, 19 Nov 2023 05:38:13 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 15/44] RISC-V/testsuite: Add branched 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.9 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: 1782969677676242019 X-GMAIL-MSGID: 1782969677676242019 Verify, for Ventana and Zicond targets and the GEU and LEU conditional-move operations, that if-conversion does *not* trigger at `-mbranch-cost=3' setting, which makes original branched code sequences cheaper than their branchless equivalents if-conversion would emit. gcc/testsuite/ * gcc.target/riscv/movdibgtu-ventana.c: New test. * gcc.target/riscv/movdibgtu-zicond.c: New test. * gcc.target/riscv/movdibltu-ventana.c: New test. * gcc.target/riscv/movdibltu-zicond.c: New test. * gcc.target/riscv/movsibgtu-ventana.c: New test. * gcc.target/riscv/movsibgtu-zicond.c: New test. * gcc.target/riscv/movsibltu-ventana.c: New test. * gcc.target/riscv/movsibltu-zicond.c: New test. --- gcc/testsuite/gcc.target/riscv/movdibgtu-ventana.c | 28 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibgtu-zicond.c | 28 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibltu-ventana.c | 28 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibltu-zicond.c | 28 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibgtu-ventana.c | 28 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibgtu-zicond.c | 28 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibltu-ventana.c | 28 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibltu-zicond.c | 28 +++++++++++++++++++++ 8 files changed, 224 insertions(+) gcc-riscv-expand-conditional-move-geu-leu-test-movcc-branch.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdibgtu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibgtu-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=3 -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 branched assembly like: + + bleu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movdibgtu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibgtu-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=3 -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 branched assembly like: + + bleu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movdibltu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibltu-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=3 -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 branched assembly like: + + bgeu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movdibltu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibltu-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=3 -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 branched assembly like: + + bgeu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movsibgtu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibgtu-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=3 -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 branched assembly like: + + bleu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movsibgtu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibgtu-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -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 branched assembly like: + + bleu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movsibltu-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibltu-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=3 -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 branched assembly like: + + bgeu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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/movsibltu-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibltu-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -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 branched assembly like: + + bgeu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { 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" } } */ 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" } } */ From patchwork Sun Nov 19 05:38:35 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: 166688 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505435vqn; Sat, 18 Nov 2023 21:39:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+6AEwhAQ8+Y6ApeI67nZax6756Ta1R7izSMI3TH6qnga5Ki01lda2dZxzwMFtD8Qpkybs X-Received: by 2002:ac8:5811:0:b0:421:c2ea:fbd4 with SMTP id g17-20020ac85811000000b00421c2eafbd4mr6748272qtg.32.1700372349524; Sat, 18 Nov 2023 21:39:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372349; cv=pass; d=google.com; s=arc-20160816; b=SKGZm86pKi6sZNPQ+IxH0O1rqAS5VN2f8oqxPz9SEr1eaT10NMorj1ADs7YMPfVHkV bFWbIzcgl4Tv9pzPSZ9nS3yA13LKgdF6rob/jj5vTDXqB4LrfD6rmuEEEW5Tz8vk6GzK dHBSpWahLQw+dBpWvpYxhtvA/mvVucaiIqafzNmk05BlUKTCYkz+P3kHlAVyWvbOH4+7 HsMd6KW+HpZBd+VBs5/mOqLtgaOZmvesMJCjP89vmAxPnOxteikQZKkCiquRhBv6FM84 AE5CjigFD0Kf3LF6gVVffUyUFdB9LSeo61Oz/7m7ckwraWb96ro4jt5RY2yPdFTvELWQ nMVA== 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=PQmFn7jw/8Xl/HPAMpHtYLOrGyilM6X+4eM8Kjf6W0Y=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=a8QPU9FtKUjxig+ZULLA4RqTDFo+bzhP8OjpLR0ip4WwhEdM6S+WfOGZ6UpoaLlLG7 yjxNO+iO3E3tGxKbApc2M6+CVPcmK2L+l3b8UNX8oqb2k48ZBraqkCLnshKh1MUSPVpZ DygKpARbHZ6B8OiqXd9ggnZzfBbkAj9H0e0f1XABSNls09xvwD9nUid//EJIu7Wt4NSf 3kN+nRDQekQnGkkqY1Nxd+xEGuGJZeBkNZKWtxMEkYkhsrnNyk+6zmUuK31X/g8WpMmY /hiuedjY9yF+xRrJCFPdUAyjXD6Qnfyl009wtAReqHox9LjQQYg1V/fn2bykvioHnzHy z+Rw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=BMzipZ8j; 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 d8-20020a05622a15c800b00420f1698b30si5222144qty.128.2023.11.18.21.39.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:39:09 -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=BMzipZ8j; 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 3B56A3857BA6 for ; Sun, 19 Nov 2023 05:39:05 +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 B1D603858009 for ; Sun, 19 Nov 2023 05:38:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B1D603858009 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 B1D603858009 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=1700372321; cv=none; b=sAKROruvbj9zPEXWDyRuRvb64heUGzmk25PIVsJ7VQkVAXFsL1qs3kXrUCqaNF33I92JW//ruVngZFIK+Tlr+ZbjrufiMN0Rozqp/+wujPGKvoQFADXAu3LXAR3yfdcQYO8wNsHLGVh/RF5CQ0KOvxXwqWKazUPbdX040LVM1YE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372321; c=relaxed/simple; bh=wPdbwKfz4tAfB40DPQYopFy2pQbjkZhzBTLd9s+eEB4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=gXINazBeRaON4JBLVz9WgKNLtsNFErXWzzDLQ4L2bvzJ4GUiQoXSFqpIbXikulMMs8ZqYvDt5jGI4QAHZw3rfm3rbreZ5SznelkehBqAEzX9uxNCody3qHx2DGnhbMe1g/H8auZP2VB+kjGkNt3w52+v7PjsQtbeRfyuGkoR1/M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-991c786369cso460455466b.1 for ; Sat, 18 Nov 2023 21:38:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372318; x=1700977118; 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=PQmFn7jw/8Xl/HPAMpHtYLOrGyilM6X+4eM8Kjf6W0Y=; b=BMzipZ8jpTTOOOFDYfD0VxTIQvOzBim2Vl6ygreB2jy5Y177EttSg8l6KwmjbB/n5w CT+KKtr9XaA2LQRL2brXNUGXkwdijUl8gSkPzFSGpltvD0MhPssx6SoD0RXq7DGnisTA kIJjh+8RAAMMk521ymdeZSBf/7SgdtygTvXhr1kQaPK/n7ZkBhVhubTFsLxXML/q8QtB uJOC8Q6aJq1dbehh+T9hO1itiJlSx+QCqNLIDAElRaBrWJSB3RGFd7yqGcLsukI8QI/X qKyGBJhVIsWv48YZMQTSrjChFSqItsOfDhQEuKLfdK58jjlbfKEssRy4B0xpunJLjZst scQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372318; x=1700977118; 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=PQmFn7jw/8Xl/HPAMpHtYLOrGyilM6X+4eM8Kjf6W0Y=; b=JShSAY0WM/DLk+HvIVb2MaYMiVsXfYcu8lV2jFPnJm2isxo7GvHxV6xFS21+WiUwdf rSuihd7KYMuCbnPJGeOF/Vytv1iZli4vf8CF7OwY0khi+WzfUdNBaNFPQ1MjiXJd5Pf8 Czn5IUCd8OqvQ0TyuGAnfBOylT/10O8DeHw9GneAeJ2uZAObupSy5FBAi+PsjnnRbggL Al0KsTFCivYeNNhM9Wy8SUlh/YTty4gt+TUsD5AN/6HxJhSG+vkSst/zlgDSJ6kRT5DP pF0JuLCIMKGpoRzLpficR2hwz29mzrCQObuw5hKRSc8vd0WklKz0Pqh3hWef2PVTb4MB SLmA== X-Gm-Message-State: AOJu0YxvEkpqb2bUCVpadmN5OAIT7ReSWdZhzqMhO4m9+rzlCorAhBMu 6bb6eiKdIChsmj8c558C/gc80EgeDN5KzEosB27hVQ== X-Received: by 2002:a17:907:c78d:b0:9e3:fc27:9356 with SMTP id tz13-20020a170907c78d00b009e3fc279356mr3227918ejc.51.1700372318369; Sat, 18 Nov 2023 21:38:38 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id e6-20020a170906844600b009cd1fca4d68sm2531708ejy.5.2023.11.18.21.38.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:38:38 -0800 (PST) Date: Sun, 19 Nov 2023 05:38:35 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 17/44] RISC-V: Avoid extraneous EQ or NE operation in cond-move expansion 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, URIBL_BLACK 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: 1782969637093118990 X-GMAIL-MSGID: 1782969637093118990 In the non-zero case there is no need for the conditional value used by Ventana and Zicond integer conditional operations to be specifically 1. Regardless we canonicalize it by producing an extraneous conditional-set operation, such as with the sequence below: (insn 22 6 23 2 (set (reg:DI 141) (minus:DI (reg/v:DI 135 [ w ]) (reg/v:DI 136 [ x ]))) 11 {subdi3} (nil)) (insn 23 22 24 2 (set (reg:DI 140) (ne:DI (reg:DI 141) (const_int 0 [0]))) 307 {*sne_zero_didi} (nil)) (insn 24 23 25 2 (set (reg:DI 143) (if_then_else:DI (eq:DI (reg:DI 140) (const_int 0 [0])) (const_int 0 [0]) (reg:DI 13 a3 [ z ]))) 27913 {*czero.eqz.didi} (nil)) (insn 25 24 26 2 (set (reg:DI 142) (if_then_else:DI (ne:DI (reg:DI 140) (const_int 0 [0])) (const_int 0 [0]) (reg/v:DI 137 [ y ]))) 27914 {*czero.nez.didi} (nil)) (insn 26 25 18 2 (set (reg/v:DI 138 [ z ]) (ior:DI (reg:DI 142) (reg:DI 143))) 105 {iordi3} (nil)) where insn 23 can well be removed without changing the semantics of the sequence. This is actually fixed up later on by combine and the insn does not make it to output meaning no SNEZ (or SEQZ in the reverse case) appears in the assembly produced, however it counts towards the cost of the sequence calculated by if-conversion, raising the trigger level for the branchless sequence to be chosen. Arguably to emit this extraneous operation it can be also considered rather sloppy of our backend's. Remove the check for operand 1 being constant 0 in the Ventana/Zicond case for equality comparisons then, observing that `riscv_zero_if_equal' called via `riscv_emit_int_compare' will canonicalize the comparison if required, removing the extraneous insn from output: (insn 22 6 23 2 (set (reg:DI 142) (minus:DI (reg/v:DI 135 [ w ]) (reg/v:DI 136 [ x ]))) 11 {subdi3} (nil)) (insn 23 22 24 2 (set (reg:DI 141) (if_then_else:DI (eq:DI (reg:DI 142) (const_int 0 [0])) (const_int 0 [0]) (reg:DI 13 a3 [ z ]))) 27913 {*czero.eqz.didi} (nil)) (insn 24 23 25 2 (set (reg:DI 140) (if_then_else:DI (ne:DI (reg:DI 142) (const_int 0 [0])) (const_int 0 [0]) (reg/v:DI 137 [ y ]))) 27914 {*czero.nez.didi} (nil)) (insn 25 24 18 2 (set (reg/v:DI 138 [ z ]) (ior:DI (reg:DI 140) (reg:DI 141))) 105 {iordi3} (nil)) while keeping actual assembly produced the same. Adjust branch costs across the test cases affected accordingly. gcc/ * config/riscv/riscv.cc (riscv_expand_conditional_move): Remove the check for operand 1 being constant 0 in the Ventana/Zicond case for equality comparisons. gcc/testsuite/ * gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_imm.c: Lower `-mbranch-cost=' setting. * gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_reg.c: Likewise. * gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_reg_reg.c: Likewise. * gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_imm.c: Likewise. * gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_reg.c: Likewise. * gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_reg_reg.c: Likewise. --- gcc/config/riscv/riscv.cc | 6 +++--- gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_imm.c | 4 ++-- gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_reg.c | 4 ++-- gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_reg_reg.c | 4 ++-- gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_imm.c | 4 ++-- gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_reg.c | 4 ++-- gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_reg_reg.c | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) gcc-riscv-expand-conditional-move-zicond-equality.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -4132,9 +4132,9 @@ riscv_expand_conditional_move (rtx dest, return false; /* Canonicalize the comparison. It must be an equality comparison - against 0. If it isn't, then emit an SCC instruction so that - we can then use an equality comparison against zero. */ - if (!equality_operator (op, VOIDmode) || op1 != CONST0_RTX (mode)) + of integer operands. If it isn't, then emit an SCC instruction + so that we can then use an equality comparison against zero. */ + if (!equality_operator (op, VOIDmode) || !INTEGRAL_MODE_P (mode0)) { bool *invert_ptr = nullptr; bool invert = false; Index: gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_imm.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_imm.c +++ gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_imm.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=4" { target { rv64 } } } */ -/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=4" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=3" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=3" { target { rv32 } } } */ /* { dg-skip-if "" { *-*-* } {"-O0" "-Og" "-Os" "-Oz"} } */ long primitiveSemantics_compare_imm_return_imm_imm_00(long a, long b) { Index: gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_reg.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_reg.c +++ gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_imm_reg.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=4" { target { rv64 } } } */ -/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=4" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=3" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=3" { target { rv32 } } } */ /* { dg-skip-if "" { *-*-* } {"-O0" "-Og" "-Os" "-Oz"} } */ long primitiveSemantics_compare_imm_return_imm_reg_00(long a, long b) { Index: gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_reg_reg.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_reg_reg.c +++ gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_imm_return_reg_reg.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=5" { target { rv64 } } } */ -/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=5" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=4" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=4" { target { rv32 } } } */ /* { dg-skip-if "" { *-*-* } {"-O0" "-Og" "-Os" "-Oz"} } */ long primitiveSemantics_compare_imm_return_reg_reg_00(long a, long b, long c) { Index: gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_imm.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_imm.c +++ gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_imm.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=4" { target { rv64 } } } */ -/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=4" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=3" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=3" { target { rv32 } } } */ /* { dg-skip-if "" { *-*-* } {"-O0" "-Og" "-Os" "-Oz"} } */ long primitiveSemantics_compare_reg_return_imm_imm_00(long a, long b, long c) { Index: gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_reg.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_reg.c +++ gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_imm_reg.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=4" { target { rv64 } } } */ -/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=4" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=3" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=3" { target { rv32 } } } */ /* { dg-skip-if "" { *-*-* } {"-O0" "-Og" "-Os" "-Oz"} } */ long primitiveSemantics_compare_reg_return_imm_reg_00(long a, long b, long c) { Index: gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_reg_reg.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_reg_reg.c +++ gcc/gcc/testsuite/gcc.target/riscv/zicond-primitiveSemantics_compare_reg_return_reg_reg.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=5" { target { rv64 } } } */ -/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=5" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc_zicond -mabi=lp64d -mbranch-cost=4" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mabi=ilp32f -mbranch-cost=4" { target { rv32 } } } */ /* { dg-skip-if "" { *-*-* } {"-O0" "-Og" "-Os" "-Oz"} } */ long primitiveSemantics_compare_reg_return_reg_reg_00(long a, long b, long c, From patchwork Sun Nov 19 05:38: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: 166689 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505486vqn; Sat, 18 Nov 2023 21:39:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDU97Qhhv/pGj6culV0zqLwI1SpZzfiFFRq1EwLL78QeTHDnYjOT+NVNXJ+S4vQJ+ZyvVH X-Received: by 2002:a05:620a:2803:b0:774:1d7f:2730 with SMTP id f3-20020a05620a280300b007741d7f2730mr4029961qkp.46.1700372366836; Sat, 18 Nov 2023 21:39:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372366; cv=pass; d=google.com; s=arc-20160816; b=xw5PMSDX3gZhOEEwNhH1p2PtXlxYfTt31v8m+unANrwlgiWQ0IhavxuFvn7vZV1C55 513+bu5+ldYprVjqnb6VPidV/SpC89VvVABU/mtVR9XyPq3qzJakAwi+HRQjKh+iqTkU bD2LeXwdZz4WZldao6jgUHa/+q42DsChA7NFEffX5/u8wJfptRrNBY7fezcEaIJww09H 5w/ZKpshqrT/1AszT9ni84ExOpGx2YkJLstT6iN66OIpEFFdmdzWFl+zdr2IAq6Rq7qg Rmfd59ZGKGLUUAQrD2kSp125FHSG+YtVHB5md4n4TyD7nBEOu9YyJA++Ok08WDhzxJyK 5Kgw== 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=XAdU8hiffwdVRAIsugX42yU9+0+DiXlDSHo25thmMpA=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=sm4yMj/vgie//wOQzhPqTABDxROeYHKaPGeLutLjesayYQgT3OeK0DUz36ACdxSDOb hyg6hwYLhsXPColEWy7vpTZIYfSbjHOqCAd9+4hiKzRb8pkOizNSk12v41UqfU9kk8kc 9dBKWWDQEtkOt2yTtec0LH7b7YtpupZ84TaMEWDgU0wU7zGAD2ihDF2q1h7YKbu6siD7 /6KFHH0gwlBuQtdKcig20SkWPNIOUljon0IWZ2vmG4jR4nEAQ0bBurzxI0RO2mj7Hndt tTYToV5dts21Pa2vjCSYsglyg7rF8G+TC7nuZa/PHwbF/RmRa4c1jDRe2uevBeem4wbI f75w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=eRZLInnT; 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 rv13-20020a05620a688d00b007672b5d6f96si5274771qkn.17.2023.11.18.21.39.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:39:26 -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=eRZLInnT; 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 C4C683861838 for ; Sun, 19 Nov 2023 05:39:18 +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 D6544385BC13 for ; Sun, 19 Nov 2023 05:38:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D6544385BC13 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 D6544385BC13 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=1700372334; cv=none; b=Q/CKIjXA9v0w1dE6G3VuCYHGgkEnRExCN2nxM0kD/ZxVtTzep8Z1OVztPNaRpbwSw/zbYQHnA5nKukw81JQKc3sg8lXiMGZmm0rUAEVaFPsjhek31jUBAuhdFAyblPgB02e+MF4xsJAc1ut8oUtmPfG96Y+fAclyVsCGc84m1Sw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372334; c=relaxed/simple; bh=uA+jsEOSgD8i1ZHq1RRa7RXHZYdBkCFPckKhA/d7bfM=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=e3Kmip7TT3vdoiBnEVATjYmpgy4KaB03vMUBxwDFaEZh/ZB5ow00CTayglP3a9a+T2J26QlZTPzpXs0oHQ4DxyVxFxYeHvokVTMlPMBy6AsxqL5MUoWdEtPhDB6LP+xU1mM+ekss/oCYNuZaX1ZIqGEh3lSyUZRfx1SaqfXoqKo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-9d10972e63eso450480066b.2 for ; Sat, 18 Nov 2023 21:38:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372330; x=1700977130; 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=XAdU8hiffwdVRAIsugX42yU9+0+DiXlDSHo25thmMpA=; b=eRZLInnT43IMhJYnPiTHXR4vRbUnusccw1Brly3R8HymCaUp3hNgFf/+nF+szH9eX5 0Y5Qii1HhNQuHriRMuVNoG+YEcwIvWOJo7e3lWdzNjMn0VaSo9h4ruDSl4xK13uNXuu3 9SHaReXIPbHo9K2eEYkvYjdvpOJ1ZZUqR+ge2aCNn5XjZS7PkTrwmG/ffyi1oHL11a6n oLBw6kvom1vnqN3PTrLPnnZ+DcZSOJJ/TLE/7pVicXaCYpleq8K66hTeipJhURFI/k9P G9elhJGTDPlPewaB0Qwkqujv/jk/Xs/d4mnXOJKeENPY4Od4XsRCcJ2v5ZV2qDIIaKnQ C58w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372330; x=1700977130; 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=XAdU8hiffwdVRAIsugX42yU9+0+DiXlDSHo25thmMpA=; b=vOy2MN/hzM8scNwPk0uEoTtxYHCtgOjVPBGWnO8zUrDgvy6yfUTgnuRlsbCrWPQ77y 4OJWURgPJHLMgyuRBLc2boLXJSRqmXIN/Kc1zfnG/A8S+ZtmoSyZu2jMxU3iU6AWUR5s RSxw7qtWh3EOOlyfw2gK7cEC3za3c75+wZqmLNj4eszy/GFuwdnKCmupyP0VpX33NwDg ea0XR+A7OwdGokzr+vQTAaAUcv8Qwl665mdvuy1zW8gtwQyyRISMvDKXx3nC3UtZ3pWT tgWbe6NmR5GiH0/RK6FgMyQ1X0p6IEzIc2C060npDMytAeO3cc8VHfK0dFGZzMQZqoaf Mq1A== X-Gm-Message-State: AOJu0YyMJ+ehu+ihBXuOyj+kYhScv44rD/XteYfG2SU8U2L+RThyfi14 AexxReW6uY1aCsSwInBFuiSglw8XLYgU+ogO74KFvA== X-Received: by 2002:a17:907:3c05:b0:9e5:3033:87b4 with SMTP id gh5-20020a1709073c0500b009e5303387b4mr2113972ejc.27.1700372330527; Sat, 18 Nov 2023 21:38:50 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id bo14-20020a170906d04e00b009c3f8f46c22sm2550228ejb.77.2023.11.18.21.38.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:38:49 -0800 (PST) Date: Sun, 19 Nov 2023 05:38:47 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 18/44] RISC-V/testsuite: Add branched cases for equality 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.1 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: 1782969654682635678 X-GMAIL-MSGID: 1782969654682635678 Verify, for Ventana and Zicond targets and the equality conditional-move operations, 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/movdibeq-ventana.c: New test. * gcc.target/riscv/movdibeq-zicond.c: New test. * gcc.target/riscv/movdibne-ventana.c: New test. * gcc.target/riscv/movdibne-zicond.c: New test. * gcc.target/riscv/movsibeq-ventana.c: New test. * gcc.target/riscv/movsibeq-zicond.c: New test. * gcc.target/riscv/movsibne-ventana.c: New test. * gcc.target/riscv/movsibne-zicond.c: New test. --- gcc/testsuite/gcc.target/riscv/movdibeq-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibeq-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibne-ventana.c | 30 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibne-zicond.c | 30 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibeq-ventana.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibeq-zicond.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibne-ventana.c | 30 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibne-zicond.c | 30 ++++++++++++++++++++++ 8 files changed, 232 insertions(+) gcc-riscv-expand-conditional-move-zicond-equality-test-movcc-branch.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdibeq-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibeq-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + bne a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { 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/movdibeq-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibeq-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + bne a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { 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/movdibne-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibne-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 +movdine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branched assembly like: + + beq a0,a1,.L3 + mv a0,a2 + ret +.L3: + mv a0,a3 + ret + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { 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/movdibne-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibne-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 +movdine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branched assembly like: + + beq a0,a1,.L3 + mv a0,a2 + ret +.L3: + mv a0,a3 + ret + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { 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/movsibeq-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibeq-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + bne a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { 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/movsibeq-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibeq-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + bne a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { 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/movsibne-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibne-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 +movsine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branched assembly like: + + beq a0,a1,.L3 + mv a0,a2 + ret +.L3: + mv a0,a3 + ret + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { 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/movsibne-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibne-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 +movsine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branched assembly like: + + beq a0,a1,.L3 + mv a0,a2 + ret +.L3: + mv a0,a3 + ret + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { 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" } } */ From patchwork Sun Nov 19 05:39:00 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: 166690 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505536vqn; Sat, 18 Nov 2023 21:39:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDCPwWWYE/O4xiTKQJF+0/79MsIR5JLL32Gk9WumOaCafnFKVt/IAa1w1b9DZzVc7VOVIj X-Received: by 2002:a05:6214:4105:b0:656:4a21:2c5a with SMTP id kc5-20020a056214410500b006564a212c5amr5474120qvb.9.1700372384008; Sat, 18 Nov 2023 21:39:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372383; cv=pass; d=google.com; s=arc-20160816; b=HGI7Y2ZWps2WX+ucgySAYynyrIyKRStAOl8jfP7gUgDV4M/fEmxmHNJdGXQX5scq96 G/M1Vsa+rpy2qrNhLse9i4q0Jo4VrruRf8cqd4b02D5iYte8HUHspsk+LNTruyQu0GUf f8a93uQsxXIZ4Uri5xEYKOqHrlkYMlMoEoQMNoOpr0LJXksS3YkzXAvtEmrVP2guIQH/ SkH3KybT0IvovSTwNtTp/NsTDsLlzunkN2du+drpuVJhxDhw32TuTAzEQBA2cbPlafaJ pfBv5lKMQVq6BL4OxBdS7y872SAzPLdTdrczL2wZ4dus4BBvGVU6Qb6qKS74F6p/bAYK 71yw== 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=29qcWgjpSy8xQLd7Kkc14BCxr7sI13QbeD2+s7ocqDc=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=iyMO3aKtxFPpFVkP9TLRg3KYz3gu+Ypvr1nhavSU2aVGc+4JLlfZaVwbjN+0MLSv61 RtsrGWraPpn2WZfFIlSWf8nDvDZlcfP7kr6lM5CGAB2sokLjIsKV0MfztacliV3CVp65 um4fcG0XI4QAT6AZIPxfp8J5Tr5IDidt3RZT09Kc2LmiRY4++402asrEHk4Pq+50hmIL q7titM3qVIG9xSIyUDsyVqg2T99p0figkpE8+YjKZfmRBrHQnLRXRkjH8hcjFKJv3TxC XX88AKwla6ZX8fh8u384Jf/n0+tO7GXaCNjk6GfEBRzIdZx7PJYOcQD+SEGFcvhAFl5I qeIw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=FQJlc2Cl; 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 9-20020a0562140dc900b0066d854ccbe7si5882668qvt.607.2023.11.18.21.39.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:39:43 -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=FQJlc2Cl; 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 73743385559E for ; Sun, 19 Nov 2023 05:39:31 +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 DB4D9385E00A for ; Sun, 19 Nov 2023 05:39:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB4D9385E00A 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 DB4D9385E00A 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=1700372348; cv=none; b=pSGwZiN1K9AswZ/cLK0rqofAcgmvQRfLQzqCBa/D6tfgKCDF3vdQXiDEmhrknSHBf7kVuPvsdbEHRyb3TRKKEjEURpy8/LILcnHTNh5+CCEQc6dFNxmMcDPKwKvlaHqH4fRxDw27HURAf4lrWTjTALXbyhZOWI+ulXSKO1B277I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372348; c=relaxed/simple; bh=M0MU6n/94bay0M7zc2f+bJmrbBjf9tl60VRqodzHrSA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=RozUeDT7WVEyPQCEP6uV8ReTJug3RgKQRx1GT6j9+mQXK7kudxaM+m4oJiCwKPI1qlui3GbG02QbsT/IcCIWZ6dF9BwKvPEcRkveTyrTvbpM/PYze9ZjjLawKKya/fnXuzKhutPYX6g254OC33Z5p65knTicvgZ2xnY8YS+Nvg4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-99bdeae1d0aso458244766b.1 for ; Sat, 18 Nov 2023 21:39:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372344; x=1700977144; 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=29qcWgjpSy8xQLd7Kkc14BCxr7sI13QbeD2+s7ocqDc=; b=FQJlc2ClcKR2tKWdW45ZrX2sBpPrtZi7MES5ousrnTrJipjt46jhjoEEE0mWBU0JLi VUMX9RNas0Cjq1TZgxqO1+yZCQ2wh9q0byg7sNV+bKh/Er7jH2J6xhrg1FpRa6UNk5nm UKlKKKAGCVLXx5qDzTYms/nrwCb73dcS2jD/TsXW3W8TnHoEVDirSGrWumbbDAmfABGZ YFcQFCJ0cuYNNX8F686hBxjrPz/b48usal/l/xu4pS+kGI5wUJi4Tgf88djZ6LPsx0NN jq+ohrHZM1AxjaM2EXw/TDB+nuXr2anrVv+mPIzDo3WasPCd7wBDNoy1J3VW4cmHGLba v6aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372344; x=1700977144; 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=29qcWgjpSy8xQLd7Kkc14BCxr7sI13QbeD2+s7ocqDc=; b=HUYs5BnfZsrDhrIuDRwRXgT87XhC3uyd0lr9eCLv9bLZ+stKYpdO9dVduJYjq6NbMO CJfrpycz4kCPZm/+hsWB9wt8r2XUPsNiMZqLYJQQy8zYrtVOzkTJfbgYXr8oAet+CW3e 45Rw3xKnEVu5XBYyjr2J4cXjJv23dqUIZbFrVeSJz194ZAV/T9URVYZ2R9IUeExOx2SE dY8p14ssrbUZYzpXwvDGlk/SBTGwZ2MSBd2MSWthSpH4VdlVyiuC5y+hvzMVyRwYuMc7 5gbnomlwtbrLRdDi//+h1ZvsoomJ/AXls8pN0q9VLsobSgT1z8SBoEZ641eF6cXCLF3Z wP6g== X-Gm-Message-State: AOJu0Yxj8JQS1MGwG/J3z1lZgj7Y7Z//Sx2kNMZXqQo1qtgh0gQ2OQxP ik42SaoMfmd/5PwAh23C3o46JUPNwz2oCaVqslo/Jg== X-Received: by 2002:a17:907:d50c:b0:9e2:b85e:59e2 with SMTP id wb12-20020a170907d50c00b009e2b85e59e2mr3273514ejc.32.1700372342826; Sat, 18 Nov 2023 21:39:02 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id cm41-20020a170906f5a900b009e505954becsm1338480ejd.107.2023.11.18.21.39.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:39:02 -0800 (PST) Date: Sun, 19 Nov 2023 05:39:00 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 19/44] RISC-V/testsuite: Add branchless cases for equality 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.3 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: 1782969672864226234 X-GMAIL-MSGID: 1782969672864226234 Verify, for Ventana and Zicond targets and the equality conditional-move operations, that if-conversion triggers via `noce_try_cmove' at the respective sufficiently high `-mbranch-cost=' settings that make branchless code sequences produced by if-conversion cheaper than their original branched equivalents, and that extraneous instructions such as SNEZ, etc. are not present in output. gcc/testsuite/ * gcc.target/riscv/movdieq-ventana.c: New test. * gcc.target/riscv/movdieq-zicond.c: New test. * gcc.target/riscv/movdine-ventana.c: New test. * gcc.target/riscv/movdine-zicond.c: New test. * gcc.target/riscv/movsieq-ventana.c: New test. * gcc.target/riscv/movsieq-zicond.c: New test. * gcc.target/riscv/movsine-ventana.c: New test. * gcc.target/riscv/movsine-zicond.c: New test. --- gcc/testsuite/gcc.target/riscv/movdieq-ventana.c | 28 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdieq-zicond.c | 28 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdine-ventana.c | 28 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdine-zicond.c | 28 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsieq-ventana.c | 28 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsieq-zicond.c | 28 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsine-ventana.c | 28 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsine-zicond.c | 28 +++++++++++++++++++++++ 8 files changed, 224 insertions(+) gcc-riscv-expand-conditional-move-zicond-equality-test-movcc.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdieq-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdieq-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 int __attribute__ ((mode (DI))) int_t; + +int_t +movdieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branchless assembly like: + + sub a1,a0,a1 + vt.maskc a3,a3,a1 + vt.maskcn 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 "\\ssub\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdieq-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdieq-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 int __attribute__ ((mode (DI))) int_t; + +int_t +movdieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branchless assembly like: + + sub a1,a0,a1 + czero.eqz a3,a3,a1 + czero.nez 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 "\\ssub\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdine-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdine-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + sub 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 "\\ssub\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdine-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdine-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + sub 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 "\\ssub\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsieq-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsieq-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 int __attribute__ ((mode (SI))) int_t; + +int_t +movsieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branchless assembly like: + + sub a1,a0,a1 + vt.maskc a3,a3,a1 + vt.maskcn 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 "\\ssub\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsieq-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsieq-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 int __attribute__ ((mode (SI))) int_t; + +int_t +movsieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branchless assembly like: + + sub a1,a0,a1 + czero.eqz a3,a3,a1 + czero.nez 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 "\\ssub\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsine-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsine-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=3 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + sub 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 "\\ssub\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsine-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsine-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + sub 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 "\\ssub\\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(?:beq|bne)\\s" } } */ From patchwork Sun Nov 19 05:39:13 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: 166692 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505598vqn; Sat, 18 Nov 2023 21:39:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEcZYTiw9ArmJL8p/sXykaChTYqjKKOuwaSSge8PLaM1m5ZjOTLTfz9x0rTj3e57dwPGVGg X-Received: by 2002:a05:622a:8f:b0:41c:c205:f718 with SMTP id o15-20020a05622a008f00b0041cc205f718mr5273251qtw.45.1700372399439; Sat, 18 Nov 2023 21:39:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372399; cv=pass; d=google.com; s=arc-20160816; b=SiyISqZFeqG/d73qa66wE1taJSN13JNWG31HzVt5yee5rrlhiaE1wdDW7vF+FjavN5 MrvcNAeSRNy+Oj99dMZY17O/EvZkyCqOqf6JggHugoUSz1NHTOGMVMylhT/7UYPYZUd9 Fj0UzdQgVOuPgXF+nWoPsI6UmF0/hgyRWlvY7CntyguwulBJc58HRMapON5/7+9Wpetg nok46KPlgc18H1PtRksiHFQQyJUCuOzbr21V/Fk3Rgb6LzwJdOQt8CV/8zg+1Q2g96Ig dPNp1OfLtedsHNTqJo84uNclkw2M4f+KABGuzBX0bqozaSWBc6AYGEWh3rxrzQzAQcp0 O8qw== 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=EW9xIDlH6PDka8ZcyC8Ol6tO54Vp+hf7uLlun5EjOQs=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=m6a+FQYO7xeFCzg+u/Vtwi9eO4r3w8pfnDfTgfCOaCB+0irNM5fhouwLcpiCXyAsvD TbT5E+Yc5jVyGk9myMkHnBbje1nkPlJ4kPRM9yIgC4jV5+mrk488i0anhJuN23FQvgBR FyfXQO5TIR0SHmRSC6uYkx8JspjfU5Ho5NLFiOvi6VUxoKyyQ546JDJ6VpKZlIpMDyYz MuMLTjQxVG5qFxfh8W37e0V4/R1g4CRZY7nso+GDXhoiNNbYTmyZKnLaAwRYQnVUzI7y K7b2Rv2qkZWtzag+FMiXaeb1HGDrmkSZNLKqOXr6lS9b0oGIHFWPH09aHnTOja8VJxyI /eyg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b="bJY/TtLc"; 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 c12-20020ac85a8c000000b00418221ab506si4984278qtc.161.2023.11.18.21.39.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:39:59 -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="bJY/TtLc"; 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 6BE99385DC2E for ; Sun, 19 Nov 2023 05:39:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id 8F0D33860002 for ; Sun, 19 Nov 2023 05:39:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8F0D33860002 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 8F0D33860002 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372358; cv=none; b=O3Ldw+e8cAoik8kWpHaaw7JchaHPM5vVMTC3dGeMRfimsrq0CcU2E3nPgpgVONGeyYpVl3kUR2wQAAvaYTN2IQMHpOvE2xiqN/3VQOMELDlFBKoXSGRH8trP5O34EgwREerqJe3cPihBg/9coXNHXlJB5dJdMhLLryprydTNVMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372358; c=relaxed/simple; bh=ye5FQdPYA6BdoTEThl6Lb/3bFnuYaF+di3ccl1zsXgs=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=vPjwrrETWj8lq26OVVV3SVvQrBzGAsPg1z+K56fvg65ZF+hGQOufZzwYZSZ+k5/IBUnyYy5qWVneWt5pE4BGNkRi2+Dl7dXKPq/cGMF6Kv8JFUaQJfNqQWvwQW2fRKxJq/lEgyPTRqCkD+MR7tPxSISxoVIcc+MSW2pyV/jOXPc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-9e623356e59so451260666b.0 for ; Sat, 18 Nov 2023 21:39:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372356; x=1700977156; 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=EW9xIDlH6PDka8ZcyC8Ol6tO54Vp+hf7uLlun5EjOQs=; b=bJY/TtLclG+qMVyvjfgfk8lBxYbSfO9FHPtnAp3gLcCcJsgWSbT1iM/zLJrkDGxOqL TLHhCW+4tjn76fP2Oqua6cDlZVVcEEUSAZmRXDLtIFp6kInA6ZNI79oYgEn4mIlmC6mq UjKq/M3A1olMwFqNHpSfgBiHqhcFnKjcs3kTJFXPJD+BT6jF0PE8fCv7cErqejW3b8o8 jrm1yVfe+5/DSJqczGqrLDU91VIOmFeU1VbnTpbcP2+4zyr0GASd5/bCR0/X1gx+jma8 VDHDv93l1eTcSJQjj/oOP5Oel013z2iYMh9YQcoJ9pUVj1eeI8xRV4Oi0BOj92HWS0CK 4oTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372356; x=1700977156; 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=EW9xIDlH6PDka8ZcyC8Ol6tO54Vp+hf7uLlun5EjOQs=; b=hc3n9C/Qc7k1Wo4WjXfLcO1f0H5wVFcOJindRgikciskw+e5tg3S7KA3MDvnGUy76B y6yKQhRa5LlK4rh8b+2n8j4OerrACGkIjqOyhMryzCHmCDZXomr9P/E7jRXJjeOKj9P3 K8QFozI64oXdgXkSA119e0bxvaQ1fuzCNZ2mWOcMdF/gnQAJeZvGEyXq0qMcjLQQ8i/k dX3xYIqJCMapB1CvIzhzKJwpqhAIx9Ql4OihCLj5FI6fYrWDVvGAKlI3FdsjrCTnnJB5 eXH+EhlVCYcKLzNJ8/RPZxmsTghb+f+qdHqPcoK/lS/6W7B+Q1pozzz9hqNr4lYABYm0 SQfw== X-Gm-Message-State: AOJu0YwMbJLgof2EW7qBasRqbuvSltuOytekoUpZNjHf/7WpEQQziwtQ FpZck7cAcx2uPosWMvcUVuBO5lqBfKG9I6n0dz+1gQ== X-Received: by 2002:a17:906:4947:b0:9e4:f7cb:ef18 with SMTP id f7-20020a170906494700b009e4f7cbef18mr3445343ejt.68.1700372356302; Sat, 18 Nov 2023 21:39:16 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id kk17-20020a170907767100b0099cce6f7d50sm2554573ejc.64.2023.11.18.21.39.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:39:15 -0800 (PST) Date: Sun, 19 Nov 2023 05:39:13 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 20/44] RISC-V: Also accept constants for T-Head cond-move comparison operands 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.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969689165493112 X-GMAIL-MSGID: 1782969689165493112 There is no need for the requirement for conditional-move comparison operands to be stricter for T-Head targets than for other targets and limit them to registers only. Constants will be reloaded if required just as with branches or other-target conditional-move operations and there is no extra overhead specific to the T-Head case. This enables more opportunities for a branchless sequence to be produced. gcc/ * config/riscv/riscv.cc (riscv_expand_conditional_move): Also accept constants for T-Head comparison operands. --- gcc/config/riscv/riscv.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) gcc-riscv-expand-conditional-move-thead-op.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -4097,8 +4097,8 @@ riscv_expand_conditional_move (rtx dest, && reg_or_0_operand (cons, mode) && reg_or_0_operand (alt, mode) && (GET_MODE (op) == mode || GET_MODE (op) == E_VOIDmode) - && GET_MODE (op0) == mode - && GET_MODE (op1) == mode + && (GET_MODE (op0) == mode || CONST_INT_P (op0)) + && (GET_MODE (op1) == mode || CONST_INT_P (op1)) && (code == EQ || code == NE)) need_eq_ne_p = true; From patchwork Sun Nov 19 05:39:25 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: 166693 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505631vqn; Sat, 18 Nov 2023 21:40:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCLkUO2ZOWkOJZfWoa/Lm6y5ODZ/A4RVzuOZw7zEzSWUCCqveSUuOa3/oLUsZ8vQ27q7T7 X-Received: by 2002:ad4:5b82:0:b0:66d:5c10:cab7 with SMTP id 2-20020ad45b82000000b0066d5c10cab7mr4688878qvp.46.1700372410332; Sat, 18 Nov 2023 21:40:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372410; cv=pass; d=google.com; s=arc-20160816; b=zATH6rDD3yAfXy9V0a3ktsi9Z5MsZVf363+M1eRYwAAthfBY8QQnjtHlG3dU6bVsu6 mEARVfX0yVvQfBJI1j7MZc/OlM8KqX7L94q/Z6ADWPbWYGZ/2aqJ/JesHx3XBsrs//Os cNeGHOcTW0sR7yDBT8IQoM3HXAiKbdHkYq66uvRX9L2XWAsGwCeuucwp3IxebsdQWIoz PM3jOvO+yCdRiB3Yw5/NhgNMsSXYKkCEJsLU8cpof91j6pbzyiyHaqrzUlgINfXwZc/0 xBxawPgHcvF+eLQO8c4U2pQ/ze+ht40WqU9OnqkDuwWXfoUdQBGDfXgJi5hHY1gWRfAw yjfw== 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=YjyTDr1aWa4WyyuQoJ7bfkcBVRchvdrxwgujnLJqEwo=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=VUG+HMvZESZ8YtCjILpfi4aZiGNNG3P8c7/pvzZNGRZFcDwHe4x0slHjLIVL6frU4H JJV1LZGmsNVE1yh6RCJ0w/nOx7gVu1ZrmJ/E/1vrrOtOWsPEI3qctmY56tSH8j7by8Fd +hUX5ryDT2Chnsx4V8ryvqsrg6zTR3DvV9sjfXJ1jUXq7sWcQw9S6BQIl4rGkq98lPR9 +N3lsAhCV6oD4m3VOlvV1ZsRc/z3/Zs4Wdh6/J535UC5RrLAy407WFMOYhEXa4XfQvPi AtcYmpJAQL97a4yO0aCrJuXkfxshk8RDwcKOF5UMZ9FozK4jZYMVZBrNfEmCSAT1vhr9 +Xww== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=Gyu9U3qP; 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 ee3-20020a0562140a4300b0066d0bd0bbcesi5007452qvb.420.2023.11.18.21.40.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:40:10 -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=Gyu9U3qP; 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 E73263858018 for ; Sun, 19 Nov 2023 05:40:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 300A0384F488 for ; Sun, 19 Nov 2023 05:39:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 300A0384F488 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 300A0384F488 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372370; cv=none; b=eMDaLhGtt7XF7VSECjyrstvtb44Hganm3kgwJSYOtahygL3d4Vf9s/aKpul1DB7NNaYODPMnkFBbI9RpD9l1mOYwJ6KBPeBCMp+/dvjiB6t+7OC7FLIBSCYAL28BMeVk0y+QgQhlZ4DEQ2KwqpBBIOBoEvnW1llUwy6NA5puMsg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372370; c=relaxed/simple; bh=Edv3IW7l78VBn+wvM0/jQBPsKMiGV+HjBSyCSiwBvFA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=ayNST/AESQno0zaLdScy6XT2XwAM6MEM8Q35K4HRTk126tZccn2HSArxqWg3GRiylznZxrDN6BGQxjNveHa6RIWUyoW5wAgNLo5RIb/fnYwF6UfGLxrUxoBKoowON10+lAzuiW6H9pBefWH6CEWFhR7rPVm93I9WVPcg/lS+QhY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-9becde9ea7bso875659466b.0 for ; Sat, 18 Nov 2023 21:39:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372368; x=1700977168; 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=YjyTDr1aWa4WyyuQoJ7bfkcBVRchvdrxwgujnLJqEwo=; b=Gyu9U3qPRgYFpDyyZ2Hatx3QYymycDSNru8y8WzalxxE1nQza8G5zcMf5r9eflP11g gLPvx0hxZ48F23HoUDITrq47kdRCBCSHCfZ+IyG4wBYsmZptQOs+AZNfdxyiqjiOPkmq Ps8Y4X+1+mfx/ea+vD1+ekuvbLF4HBSBzvPEAktQMpf5EBTUsh208uYbR11Qg+fsJ8Nl 42fZcsw8CScs/v9szRtEbx3O7Gu5DAcl4ggr8xdvXu/zrRlpFKN7GTmms3dXNPOrwGGG Ln5AqeAI8r18EjTwWmx8ExJMgjl7rLZVDphUABnqOLHmPXWA8rbTb/AQQOUviSw3GjBH dTyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372368; x=1700977168; 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=YjyTDr1aWa4WyyuQoJ7bfkcBVRchvdrxwgujnLJqEwo=; b=oxP2ZmvmAs6HHTYcL1L/8LSzmFxgByZiSKImz1nTgeNySf/FuqwciDFDTJZATTQSvR D9EublFOPE+02uVy0icOmEZX6ZaSO1TfDze8hSMNhXj3uJV5mH1OJsLTwclmaxHyCmVl b4Vqr6U2coQeBmXxEpoIPaH8+gDtAJKicaM+iW+6Gw0b+6uzMKedK87nV1FZR5N+Nj+f 9PrLC9Z2f37Ufk50B9SvqhtL2pKL3VrIb2lKWGnh+TFIARU466nta9UA6xfDosStKFVH Rph0AFSor8eYPUlui/KKLRLQchwFvCBG1N8g18OV5RF6tY2ivZbUu473hpJkY0drGHTK ZXsw== X-Gm-Message-State: AOJu0Yx1yEWBJUlIPNsmSfvsqnnoHrcqExORmVfc3U/HzNXM6zVzrEO1 r5EHLOr6oXmiQov2hNxAZZeFNuirEaL84O8iw/y6eA== X-Received: by 2002:a17:906:11e:b0:9e5:1db7:3199 with SMTP id 30-20020a170906011e00b009e51db73199mr4085985eje.4.1700372367904; Sat, 18 Nov 2023 21:39:27 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id bo12-20020a170906d04c00b009d268e3b801sm2543208ejb.37.2023.11.18.21.39.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:39:27 -0800 (PST) Date: Sun, 19 Nov 2023 05:39:25 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 21/44] RISC-V: Also accept constants for T-Head cond-move data input operands 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.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969700235836828 X-GMAIL-MSGID: 1782969700235836828 There is no need for the requirement for conditional-move data input operands to be stricter for T-Head targets than for short forward branch targets and limit them to registers only. They are keyed according to the `sfb_alu_operand' predicate, which lets certain constants through. Such constants are already forced into a register for the `cons' operand in the analogous short forward branch case and we can force them for the `alt' operand and T-Head as well. This enables more opportunities for a branchless sequence to be produced. gcc/ * config/riscv/riscv.cc (riscv_expand_conditional_move): Also accept constants for T-Head data input operands. --- gcc/config/riscv/riscv.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) gcc-riscv-expand-conditional-move-thead-alt.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -4094,8 +4094,6 @@ riscv_expand_conditional_move (rtx dest, if (TARGET_XTHEADCONDMOV && GET_MODE_CLASS (mode) == MODE_INT - && reg_or_0_operand (cons, mode) - && reg_or_0_operand (alt, mode) && (GET_MODE (op) == mode || GET_MODE (op) == E_VOIDmode) && (GET_MODE (op0) == mode || CONST_INT_P (op0)) && (GET_MODE (op1) == mode || CONST_INT_P (op1)) @@ -4113,6 +4111,8 @@ riscv_expand_conditional_move (rtx dest, cases for extensions which are more general than SFB. But does mean we need to force CONS into a register at this point. */ cons = force_reg (mode, cons); + /* With XTheadCondMov we need to force ALT into a register too. */ + alt = force_reg (mode, alt); emit_insn (gen_rtx_SET (dest, gen_rtx_IF_THEN_ELSE (mode, cond, cons, alt))); return true; From patchwork Sun Nov 19 05:40:03 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: 166694 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505706vqn; Sat, 18 Nov 2023 21:40:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmGsKzdR4QgfItR/i1zmqJcp9p+/9ZVQDpzw+lBwMXByUnr6DqAG1EuwF/eyQAIARhzkh+ X-Received: by 2002:a05:620a:8007:b0:777:326d:83de with SMTP id ee7-20020a05620a800700b00777326d83demr4499230qkb.56.1700372432024; Sat, 18 Nov 2023 21:40:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372432; cv=pass; d=google.com; s=arc-20160816; b=mDNWRS94odbO8gBLIPRulKwtZoZMVGUw9O4QCQdxe+MiT7+WV+jNHzSKTL88jtfU5e ITfnZ2nyoDHZ0n8R30IXCjLr4g2RN/bgbqQ3xGY2E6H3TuSydF+9br/kFqlbl7O8cyPF M7jKtwhY6lPcIoPAvoFkIDpQG6aZaSh4nPl+HhOA1m7vDsdTk2xTjdnyiuDyym+V29ZN zmD076ooRjM1QJ/G7Tg/j8WuIeIZ90+1wfoOYM0+qUbqDj3yFJwQ3iTxKbZPbPOrgdf3 cjBPSa+m7HjU8cT+ydaa/U9xHG44NgEYFJaJUq82Y1mYZ5V01WPnVXAQErEE6DkKbC1U uulw== 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=V9Px6vKIy8MDU4iw0UgQYRADuU9oUJCS1OBbpJwDd/k=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=p3dZPgzsf5biSP4jbzWRjA+n/5ZlQ1ft4Ka5MiaG0FsiYOTvp9wa6UFMMa5leIYcws OnqCVwCIjPe5l58wdZxLGYQc3sATfV+VMzvFr+GserP0XiZoKKBwmRq93J25JSy8WS/e zaMKBEWca1hGFrlXWa+y4CFye0Y68KIzV0sv6JN3PDsLnfmW4/uGACfL61pCGuV5ulnr G/eQ1SiPswk+dJz0wl4A4bM1hCYCUx+vnAYXQojlCFZVDtaRHEU0pp/ZimjnKwPqWW3A Ru9Imm9faaMazBeBOfgiu6XLawlaWxmS61mn8FOwqjVuKAHV8hU+Sjw8L5fgJy/XQhQE OEiQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=JHaVCk97; 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 br38-20020a05620a462600b00775bfe3a8f7si5191768qkb.410.2023.11.18.21.40.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:40:32 -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=JHaVCk97; 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 C6D3F38582A3 for ; Sun, 19 Nov 2023 05:40:31 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 54C92385840D for ; Sun, 19 Nov 2023 05:40:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 54C92385840D 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 54C92385840D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372409; cv=none; b=eLRru8YDo7vVA0jBUWH5AbscB2eV1aGQj37i6FlsBmSCSP1nQ7vMpZO0BbkKv2BFVF+cI9NI+O4ZbaKw7ryRpOW4rwQBgcXkFzLiie2Iin3m9cCJgt+8c7heLcI42K9dkvzPE6X9uWQLL2KsJlT+C35HOgfbJBbML2UZlN8Gqpc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372409; c=relaxed/simple; bh=hBkp645S3jveTqUl4tANojSFkdrif+163c/8/zIHKyw=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=OJouvXYGZSILNI5ZJFVd69ftssr3kM4PeOtxvYeltLS99dqKj47+2Cz8dHHDVFKcnKtDIMhY/cLlSWStTidg1q4l46wmm+acBIkrRRz/W+uYXavWg5DbGMO9VgjD1jLBk4G3JiiQY38QjZ4CWka4aUS++1a9FXFi+z3+YYzf0Ks= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-9e62ab773f1so460271266b.0 for ; Sat, 18 Nov 2023 21:40:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372406; x=1700977206; 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=V9Px6vKIy8MDU4iw0UgQYRADuU9oUJCS1OBbpJwDd/k=; b=JHaVCk97UaBdGuzHZliWWAd7LEVlEYTyHYYxnEQLaZey+wGIlHfIziATIwcCTuEt4V LHr1c48ei+TQwi2525YTr4JMz5eCq3Ki5b8CtIZkPuowyVeDqWcNQAy3IQ3fuzixBNGC VqPQIaOfRdwlrzNwzORTmQcCc1Dpz/ND5V+Lqy2iYpF1uVMB/peJWNJoio3Ur06ndKAR iNhqdvx4ATGET3yVFKyrQ9dtGMHfYBhW0djh4Zj+XSy5Uo7Cx+eeGChlIdVaN7uLCCub me1mD6OwwZlAu8M3tJpeWV7ou3qxyn3zwZj1vJsdxrlzYyzfYBMBEbuTnVcGtzGebrmF 596w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372406; x=1700977206; 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=V9Px6vKIy8MDU4iw0UgQYRADuU9oUJCS1OBbpJwDd/k=; b=akkrwatPJzsIUQJG/MsEXb8PB3+wlX458k+2EmJE2xRizin3/e4VwFXIzhfybBfZ0l PlZ/iX+GAiGODyno0T7yKXf40zrIFliYKDAHYx0wxBerNvPkUi5FkEwrcqx7OreoYsR/ nSQ49g/L9jkZsFZowtMhAUjVWmeRvze7bBweICUJgi1SL59KlOOnCceDSe7fyuSIRhPM hsXOPg8H0C3El2Twnc5t/fGeEGCzrVUrXF8U0BeQ5MzbdKn4Cl4wXFlFEJvszYF2SuU7 Au7zUX7pdnVZKxDavKNMtn97D8epQfX41+s1p6iooo0Jckzz8zYtRptPmkF/QIDgPiMc Pzfw== X-Gm-Message-State: AOJu0Yw9pKw7ftC0fmi8gRLwZECFBvyLfGitGqs0EFC0U8NwwB+NgGXs 5IHWDLpc0xaZdDF8vCxSzRg1KUTvtThGUnzzTdzjvw== X-Received: by 2002:a17:906:dfe2:b0:9bd:9bfe:e40b with SMTP id lc2-20020a170906dfe200b009bd9bfee40bmr2808779ejc.75.1700372405994; Sat, 18 Nov 2023 21:40:05 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id h19-20020a170906585300b00982a92a849asm2546076ejs.91.2023.11.18.21.40.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:40:05 -0800 (PST) Date: Sun, 19 Nov 2023 05:40:03 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 22/44] RISC-V: Fold all the cond-move variants together 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, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969723333943123 X-GMAIL-MSGID: 1782969723333943123 Code in `riscv_expand_conditional_move' for Ventana and Zicond targets seems like bolted on as an afterthought rather than properly merged so as to handle all the cases together. Fold the existing code pieces together then (observing that for short forward branch targets no integer comparisons need to be canonicalized), letting T-Head targets produce branchless sequences for all the integer comparisons rather than for equality ones only, and preparing for the handling of floating-point comparisons here across all conditional-move targets. gcc/ * config/riscv/riscv.cc (riscv_expand_conditional_move): Unify conditional-move handling across all the relevant targets. --- gcc/config/riscv/riscv.cc | 58 +++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 33 deletions(-) gcc-riscv-expand-conditional-move-sfb-alu-thead.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -4090,35 +4090,9 @@ riscv_expand_conditional_move (rtx dest, rtx_code code = GET_CODE (op); rtx op0 = XEXP (op, 0); rtx op1 = XEXP (op, 1); - bool need_eq_ne_p = false; - - if (TARGET_XTHEADCONDMOV - && GET_MODE_CLASS (mode) == MODE_INT - && (GET_MODE (op) == mode || GET_MODE (op) == E_VOIDmode) - && (GET_MODE (op0) == mode || CONST_INT_P (op0)) - && (GET_MODE (op1) == mode || CONST_INT_P (op1)) - && (code == EQ || code == NE)) - need_eq_ne_p = true; - - if (need_eq_ne_p - || (TARGET_SFB_ALU && GET_MODE (op0) == word_mode)) - { - riscv_emit_int_compare (&code, &op0, &op1, need_eq_ne_p); - rtx cond = gen_rtx_fmt_ee (code, GET_MODE (op0), op0, op1); - /* The expander is a bit loose in its specification of the true - arm of the conditional move. That allows us to support more - cases for extensions which are more general than SFB. But - does mean we need to force CONS into a register at this point. */ - cons = force_reg (mode, cons); - /* With XTheadCondMov we need to force ALT into a register too. */ - alt = force_reg (mode, alt); - emit_insn (gen_rtx_SET (dest, gen_rtx_IF_THEN_ELSE (mode, - cond, cons, alt))); - return true; - } - else if (TARGET_ZICOND_LIKE - && GET_MODE_CLASS (mode) == MODE_INT) + if ((TARGET_ZICOND_LIKE && GET_MODE_CLASS (mode) == MODE_INT) + || TARGET_SFB_ALU || TARGET_XTHEADCONDMOV) { machine_mode mode0 = GET_MODE (op0); machine_mode mode1 = GET_MODE (op1); @@ -4132,9 +4106,11 @@ riscv_expand_conditional_move (rtx dest, return false; /* Canonicalize the comparison. It must be an equality comparison - of integer operands. If it isn't, then emit an SCC instruction + of integer operands, or with SFB it can be any comparison of + integer operands. If it isn't, then emit an SCC instruction so that we can then use an equality comparison against zero. */ - if (!equality_operator (op, VOIDmode) || !INTEGRAL_MODE_P (mode0)) + if ((!TARGET_SFB_ALU && !equality_operator (op, VOIDmode)) + || !INTEGRAL_MODE_P (mode0)) { bool *invert_ptr = nullptr; bool invert = false; @@ -4166,10 +4142,26 @@ riscv_expand_conditional_move (rtx dest, op1 = XEXP (op, 1); } + if (TARGET_SFB_ALU || TARGET_XTHEADCONDMOV) + { + riscv_emit_int_compare (&code, &op0, &op1, !TARGET_SFB_ALU); + rtx cond = gen_rtx_fmt_ee (code, GET_MODE (op0), op0, op1); + + /* The expander is a bit loose in its specification of the true + arm of the conditional move. That allows us to support more + cases for extensions which are more general than SFB. But + does mean we need to force CONS into a register at this point. */ + cons = force_reg (mode, cons); + /* With XTheadCondMov we need to force ALT into a register too. */ + alt = force_reg (mode, alt); + emit_insn (gen_rtx_SET (dest, gen_rtx_IF_THEN_ELSE (mode, cond, + cons, alt))); + return true; + } /* 0, reg or 0, imm */ - if (cons == CONST0_RTX (mode) - && (REG_P (alt) - || (CONST_INT_P (alt) && alt != CONST0_RTX (mode)))) + else if (cons == CONST0_RTX (mode) + && (REG_P (alt) + || (CONST_INT_P (alt) && alt != CONST0_RTX (mode)))) { riscv_emit_int_compare (&code, &op0, &op1, true); rtx cond = gen_rtx_fmt_ee (code, GET_MODE (op0), op0, op1); From patchwork Sun Nov 19 05:40:13 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: 166695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505774vqn; Sat, 18 Nov 2023 21:40:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHu1nKyEYLu0H5VS9vps8DR3cup71i99HSKwV3mALR5HsOfCSzggOtxvug41g6dnld7k0mV X-Received: by 2002:a05:6214:2a8c:b0:66d:3a0f:97a with SMTP id jr12-20020a0562142a8c00b0066d3a0f097amr4894939qvb.6.1700372448693; Sat, 18 Nov 2023 21:40:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372448; cv=pass; d=google.com; s=arc-20160816; b=u+Jb+LDVZRSAyhgIjw6EEBqAeNNfF0Kro5D5TC4q3viBiYMJgFWWhuG1VEgU2vIDHX 4dPlJD7Ndxyu+F8Xgv2C91gpgMq5g6d2+DLhBIutEoXHNeIGSMkDEskr+XdTfFmsNq2e tghSkjmApRXXAV7BoK2bNHmNg7r0A02z0qp4q/MPM3R3HUt/Yt1qzCZJOR6kWSdStmjT V/0KI5qG3LosSZtnix5vgK/9dzsGkzyJeI8v+X88XcUvRr2iRXAlvFvmlr8zK12+39Q6 zLiJxoZjlRIe5Iql7lP4iajF0ya+bwszXXGoO3F73egKgn1E79pf+wSd4dRkS0cGyNau aiow== 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=O2esi0UqCtWQf99izEsZMI6GfHGOARP6gIXrZWFQDCY=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=FszTPnEsN7lyt2Ijcjx69pV7QbMQFua7waw8uYWNUJVvZcH95RL+60yfJTOU3nxO7N W+BCeKtd/bvlZjeVlGdsFyKLV/q96wTLBL6AqKUEMV3gPNjzEtxsTogQyh7/w8jl1C4l /CdDIqR42mSHpH+EMTL6TPY9DmHVN1vAhuyA4LPe5SgCNN4To7I0sDVUgY+qF7eGZKAc RauofNe1pYPnxQ9N3P42yIz0yaBC33zyirS31AZ9l2E9zEC7A0x6N1MqrYjrJqt5ewdB vrtxFwLzbiio2vw5qi+JAAgQBsCJvM6AhacmE2CgBj4+2EqGLu6p3tS/SXWXbdgtQk0c qr3w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=E+8e6g19; 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 d7-20020a0cc687000000b0064f4b37f21dsi5012406qvj.118.2023.11.18.21.40.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:40:48 -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=E+8e6g19; 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 73A32385800A for ; Sun, 19 Nov 2023 05:40:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id 04A8F3858C2D for ; Sun, 19 Nov 2023 05:40:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04A8F3858C2D 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 04A8F3858C2D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372422; cv=none; b=P9RqTWWTXXnfG/1ZxDedCgVSFv/5SB+tnH782h1VlPE7dSmEfApWZ3+8xTmQskyFvW4MBfp4EJUwbc5w0QGzigDXmb6z+Atuh7jIu/imYBu0wEd4NF0OKNEWLiI68fZlVsyNh1YX1sYLGdWMO4t0JW2iTA+W+eL6CIlyGPRK+2s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372422; c=relaxed/simple; bh=Z1St/HloOUafKLtjbHXj6OiUvqoA7bm2tbum+KUldFI=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=HVKTJS0lPE6Qh9U9vk3kKRi+PC4EbQHQBUEuEA7Ri5AXTIpu7A0bGHZaaavl2LLwuHerPzhuvd2AyMhnEnSUVudLYGVOMQoCt6cx+sWtx/tfwt2wDo/sE3Hcm0ZE58GpnbWin5hUGcyEKXi+jkRsBPcrV8aPz7WHQBwwmhl6cVU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-543456dbd7bso8512015a12.1 for ; Sat, 18 Nov 2023 21:40:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372417; x=1700977217; 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=O2esi0UqCtWQf99izEsZMI6GfHGOARP6gIXrZWFQDCY=; b=E+8e6g19w4ojW8Q/LbEVifDv5Hdes0496D+Lslr9H9LloNPRtW9wA9QiIAD15mb7Zo hP2Rub1Kc4uBKD1+rUcIyMKYp3Cav1Xmf1tOAITIwD3AL7lfSF5/gA+SUH8EP3G6P1ag JdYkgMJLCvfFfcizq/myJTwX9OmW5VpLX5iIXTe1X+3bR1CuR5QfyPmbYtlbp2pw8d/T H46uEciZfeGu+h5eF8A1CdTk4Qxz6k8Blw/6aDKAgehmE19xb6lXVA1/q6rn4phPc+w+ FCQQaPSDJ3xRrXG7i4/B4+c/RC37lXaQ5NKFu7GRRknsLieHWaQWwRE8/vH+oYg3rmWg 6Vfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372417; x=1700977217; 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=O2esi0UqCtWQf99izEsZMI6GfHGOARP6gIXrZWFQDCY=; b=m7hf92n9VBjt8cA9SN7q6XCSWWFOEz1qstwXf4nfUW0dkv7p533XLX2lGYnAhx2EcH mnNE04xYL31I5kikWgZHu+hrjkFMvm1lpZAackPqL/GOJ+//2184ZLynIaKBsmotDumD /7C5pu0pRoLty0IICK4mc62/SfCYnf7xP7qnjqRHSgdB5eBLSvXe9qrc5QvVA4ADFmMN ttwML+0EaOpCajT6xX+ennsp1XXsJ2PwG3fOHNd3BwfinfHDDljTY1hfm2ToMWXYxY8/ y0BPoQ4sDy3R5hQ65y17z7jUm2yX7reGmNnTfCV/aHaBFxorUlv/AVjOHwF8Ac1dsyZy Xxug== X-Gm-Message-State: AOJu0Yxb3+FysTkSrzY4tSxkiS8XuB0UbHyBr9W5iaWGFkG42gRYxdec JckKrlKfxNxahfEK37u6XhBst5b1I7TRp6Lcbb4JUw== X-Received: by 2002:a17:906:10d9:b0:9ef:b466:abe0 with SMTP id v25-20020a17090610d900b009efb466abe0mr3828272ejv.8.1700372417647; Sat, 18 Nov 2023 21:40:17 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id t9-20020a170906178900b009fd83a7362csm100103eje.70.2023.11.18.21.40.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:40:17 -0800 (PST) Date: Sun, 19 Nov 2023 05:40:13 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 23/44] RISC-V/testsuite: Add branched cases for T-Head non-equality cond moves 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.8 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: 1782969740812503228 X-GMAIL-MSGID: 1782969740812503228 Verify, for T-Head targets and the non-equality integer conditional-move operations, that if-conversion does *not* trigger at `-mbranch-cost=1' setting, which makes original branched code sequences cheaper than their branchless equivalents if-conversion would emit. gcc/testsuite/ * gcc.target/riscv/movdibge-thead.c: New test. * gcc.target/riscv/movdibgeu-thead.c: New test. * gcc.target/riscv/movdibgt-thead.c: New test. * gcc.target/riscv/movdibgtu-thead.c: New test. * gcc.target/riscv/movdible-thead.c: New test. * gcc.target/riscv/movdibleu-thead.c: New test. * gcc.target/riscv/movdiblt-thead.c: New test. * gcc.target/riscv/movdibltu-thead.c: New test. * gcc.target/riscv/movsibge-thead.c: New test. * gcc.target/riscv/movsibgeu-thead.c: New test. * gcc.target/riscv/movsibgt-thead.c: New test. * gcc.target/riscv/movsibgtu-thead.c: New test. * gcc.target/riscv/movsible-thead.c: New test. * gcc.target/riscv/movsibleu-thead.c: New test. * gcc.target/riscv/movsiblt-thead.c: New test. * gcc.target/riscv/movsibltu-thead.c: New test. --- gcc/testsuite/gcc.target/riscv/movdibge-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibgeu-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibgt-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibgtu-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdible-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibleu-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiblt-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibltu-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibge-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibgeu-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibgt-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibgtu-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsible-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibleu-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiblt-thead.c | 27 +++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibltu-thead.c | 27 +++++++++++++++++++++++ 16 files changed, 432 insertions(+) gcc-riscv-expand-conditional-move-sfb-alu-thead-test-movcc-branch.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdibge-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibge-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + blt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibgeu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibgeu-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + bltu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibgt-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibgt-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + ble a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibgtu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibgtu-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -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 branched assembly like: + + bleu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdible-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdible-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibleu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibleu-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgtu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdiblt-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiblt-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + bge a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibltu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibltu-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -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 branched assembly like: + + bgeu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibge-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibge-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + blt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibgeu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibgeu-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + bltu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibgt-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibgt-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + ble a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibgtu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibgtu-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -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 branched assembly like: + + bleu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsible-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsible-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibleu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibleu-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgtu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiblt-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiblt-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + bge a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibltu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibltu-thead.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -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 branched assembly like: + + bgeu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:th\\.mveqz|th\\.mvnez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ From patchwork Sun Nov 19 05:40:26 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: 166697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505893vqn; Sat, 18 Nov 2023 21:41:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIOuYLl/vXBeFrOTUn3uZFCIEQcGH6fPGcNuKy8zuMIeUyJ8Th12xeWZXAq6gw8pJ2GmCH X-Received: by 2002:ac8:5984:0:b0:418:1565:ed49 with SMTP id e4-20020ac85984000000b004181565ed49mr5515039qte.41.1700372472909; Sat, 18 Nov 2023 21:41:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372472; cv=pass; d=google.com; s=arc-20160816; b=m0mHJAtRr3KESzbRpq+nmtUMCis9NNn5rOoAcD0P8TxOIwV74h1yFLU9GEmrwhO4SL wbQmZLaZowDhm1hDNgBMf4jsKrmKsHtrmYcFmT3VoMRPbN939AAlLhaFCK62sGW86WpB GF9QkvDeo5DnZiCR9BI7DR+ivpZmMaO6NVNi4n2uU7E9gGiDPH4j3d0gVKCKKjW+SDrD YFNDC2wfOkYGa3tldI0SRgD/KHVfaj5ANGi3VbRvll8ibo49PByTUYFgfFtrjD+sXGXf ucXlRSYuKUxIhIcwW3mfHp++gXo2Ac8xsUT4XhtxFngTKE+j/IQHz6T+1GvX9cs1wLcF PIAQ== 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=Ihcsds6TrFe2prwTePdIXqyasJa9hy3iwG1SxklU8gE=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=Vhx3Exg32WAYj0jzo9zHnpsC40cECh2BqLtKN/D62uTj3JFxRDUATF90XP0rC3dk83 8U1ObDyKKAoqM6krcpov2SQ2zcNz2QJiatM9gk32vj/vYmBkr1kSX3KPQvU2zG+uClse XTXPxTfjW1Tuuc5kqq84N7N2piIU39uQaTSH0KpBJbvvVQ6FcTS9cV2NLErbvCJpk5Ro W9cm/DJlwwTcUQqKNSQ0gyRqalB7sM7YA3MZug42dd/bGQyeYL9tNAF9syizhwdx4aZk 7ZqsDlPj5tG8e+87tEYb7qc1P9SActhti/MQ+dzUeXzBS3zMXE9cqXLteJnYx4GpRgnc t+ow== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=AzjoKrWa; 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 o16-20020a05622a045000b0041983479612si5036224qtx.628.2023.11.18.21.41.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:41:12 -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=AzjoKrWa; 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 A28FD3857C5B for ; Sun, 19 Nov 2023 05:41:12 +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 17703385829B for ; Sun, 19 Nov 2023 05:40:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 17703385829B 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 17703385829B 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=1700372435; cv=none; b=xDldfcIsZEF0wEfbdwqhSPJ3qw1O00UPFhyNzu5+X6N7Y3VEOFahbjepWtbEtygucLr/4wzkgFQN5kVKNreySGzINeNGxJQirRkpR4CrTiuk3UFUrZE8g951+cE48V0VJhRTeBjK3PXDqhYcE8T9kyQF3teGHt6vwbS6Rt+COig= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372435; c=relaxed/simple; bh=L+ihn/IeX8OaZR87sTWw64dmBURxTZ+UU4xv7J3mqtI=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=aZ4yE7XK92KSIOiYouzne+evx5Rc6S+H6S3cYWVHjU5wMnr9ugwWWouSN4+Gav8S0AYqi7w0th9xKWmjZva4bQ1jPzYNFQhxPP9MbH7WlTCEhC566qn+/g9frBVrMtKMDhdPZZBHkbwU+qAzcYGTetyg4jQmFuYq7pKZsw+/p/I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-9e1fb7faa9dso457149866b.2 for ; Sat, 18 Nov 2023 21:40:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372431; x=1700977231; 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=Ihcsds6TrFe2prwTePdIXqyasJa9hy3iwG1SxklU8gE=; b=AzjoKrWahRUsfWrG5tpKS9qLAA/Yc+2u2/2zRCCJyjekLUvjnh0hx0LRUMC1btsjvG dAlEyw0N95SGe2Eovgt8bjjeqvN5LtzYR87LkaerLIDszwmFQ1Qi5Z1FV5ECDKjotxLJ XNj70k4QTPgbC+p+2TH1+ufvdX5z6lNzM9+k9Y1PU0q1KOfv6dFKMl+2MyNXtIqTBI3K INdopfyQvFmAFb7j1Uh3RuT03sSH9DgxNt9REHCpC9I4eYsRmzV4dWq8/WTUG6/bpP5c AaJtGx/WRv2CrYfDCEBdp4XtTn8fo76bx3wgBfpdkdbL2VMWtGvSI0cXBDYXD1e0btXC za2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372431; x=1700977231; 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=Ihcsds6TrFe2prwTePdIXqyasJa9hy3iwG1SxklU8gE=; b=gZsV+9tGEKSy5ltx1uUhyFw7wiiCwfMKOCdLP2cKtiP4qyxYNxExi5LmByriU6b5vK Lmbel6Sf0m8S5+Wprv58peik1ARAk3jPiqThTX9gVooVv/jWoEgiahcJIW/jTd4RZh39 gHkDM1jjHSm10/vcfWrKkSeUE+KyUCTU24907mUDiU3aaWp3LWmqiUAP+4I1sPzNddxS 0OkPL8k6pM8UkLi/6gYbspkda/TqPkumqw5WiT0fYJEgmFr6SD3sQdbidHNTx+uXkjtb C6Q6S4Nm6tI5GXx2vHl0puxjJ+lp/EAyjNaKeNXeO60q+aEenSSup1d4+AjbRtSrr3Iz LT8A== X-Gm-Message-State: AOJu0Yz/J1Cf9nuwYECCBSDqdk8ychpQ9O1qptIPXZZfruHsrrV9wvkY /Srm0TBnItGhSmghme37pRZ7hK7rWQCJxQG3stqg6w== X-Received: by 2002:a17:907:3f22:b0:9e6:4156:af4f with SMTP id hq34-20020a1709073f2200b009e64156af4fmr3697582ejc.55.1700372430844; Sat, 18 Nov 2023 21:40:30 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id e9-20020a170906374900b009e6298fc683sm2525947ejc.41.2023.11.18.21.40.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:40:30 -0800 (PST) Date: Sun, 19 Nov 2023 05:40:26 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 24/44] RISC-V/testsuite: Add branchless cases for T-Head non-equality cond moves 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.3 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: 1782969766086038227 X-GMAIL-MSGID: 1782969766086038227 Verify, for T-Head targets and the non-equality integer conditional-move operations, that if-conversion triggers via `noce_try_cmove' at `-mbranch-cost=2' setting, which makes branchless code sequences produced by if-conversion cheaper than their original branched equivalents, and that extraneous instructions such as SNEZ, etc. are not present in output. gcc/testsuite/ * gcc.target/riscv/movdige-thead.c: New test. * gcc.target/riscv/movdigeu-thead.c: New test. * gcc.target/riscv/movdigt-thead.c: New test. * gcc.target/riscv/movdigtu-thead.c: New test. * gcc.target/riscv/movdile-thead.c: New test. * gcc.target/riscv/movdileu-thead.c: New test. * gcc.target/riscv/movdilt-thead.c: New test. * gcc.target/riscv/movdiltu-thead.c: New test. * gcc.target/riscv/movsige-thead.c: New test. * gcc.target/riscv/movsigeu-thead.c: New test. * gcc.target/riscv/movsigt-thead.c: New test. * gcc.target/riscv/movsigtu-thead.c: New test. * gcc.target/riscv/movsile-thead.c: New test. * gcc.target/riscv/movsileu-thead.c: New test. * gcc.target/riscv/movsilt-thead.c: New test. * gcc.target/riscv/movsiltu-thead.c: New test. --- gcc/testsuite/gcc.target/riscv/movdige-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigeu-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigt-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigtu-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdile-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdileu-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdilt-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiltu-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsige-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigeu-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigt-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigtu-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsile-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsileu-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsilt-thead.c | 26 ++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiltu-thead.c | 26 ++++++++++++++++++++++++ 16 files changed, 416 insertions(+) gcc-riscv-expand-conditional-move-sfb-alu-thead-test-movcc.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdige-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdige-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + slt a0,a0,a1 + th.mvnez a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgt|slt)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdigeu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigeu-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + sltu a0,a0,a1 + th.mvnez a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdigt-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigt-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + sgt a0,a0,a1 + th.mveqz a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgt|slt)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdigtu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigtu-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -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 a0,a0,a1 + th.mveqz a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdile-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdile-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + sgt a0,a0,a1 + th.mvnez a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgt|slt)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdileu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdileu-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + sgtu a0,a0,a1 + th.mvnez a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdilt-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdilt-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + slt a0,a0,a1 + th.mveqz a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgt|slt)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdiltu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiltu-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -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 a0,a0,a1 + th.mveqz a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movsige-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsige-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + slt a0,a0,a1 + th.mvnez a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgt|slt)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movsigeu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigeu-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + sltu a0,a0,a1 + th.mvnez a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movsigt-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigt-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + sgt a0,a0,a1 + th.mveqz a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgt|slt)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movsigtu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigtu-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -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 a0,a0,a1 + th.mveqz a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movsile-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsile-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + sgt a0,a0,a1 + th.mvnez a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgt|slt)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movsileu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsileu-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + sgtu a0,a0,a1 + th.mvnez a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movsilt-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsilt-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + slt a0,a0,a1 + th.mveqz a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgt|slt)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movsiltu-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiltu-thead.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=2 -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 a0,a0,a1 + th.mveqz a2,a3,a0 + mv a0,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:sgtu|sltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ From patchwork Sun Nov 19 05:40:38 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: 166696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1505876vqn; Sat, 18 Nov 2023 21:41:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUF3qaEqPF2LDl4SC/BcwWpL6EdgujoLXJ1tdmpRTQDdIO8vCa7UcpkEdITsNHzYFH6jBr X-Received: by 2002:a05:620a:170b:b0:76e:f3a3:4ac6 with SMTP id az11-20020a05620a170b00b0076ef3a34ac6mr4565096qkb.35.1700372469840; Sat, 18 Nov 2023 21:41:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372469; cv=pass; d=google.com; s=arc-20160816; b=BvKz2qjKSGoJga0MBS5FlFHpLexqQcPdV8uYq5kVKCTbxD4XMV8UvmjRvEHcHeRU52 SdgJrWgBfZbiVtycDg7ySbhoERUMEq+LVDdu0T0Bj2WAlg9g6ooVmhNQO55jtXDlKa/G cEyRdsJEUhoPqGf1GnKMVvzNm5LcjXA9synhoaHrO+LJiHQntcZ4l93LAMP449ti0Rua pK8+YDlYtVpqOoiEfUvhr8OTUR3+2S0k6m1yaXCIGleFTvWB13Gwecoh0pYCydkQGMkH IWTnvE05q80nkSbhPcAI6nzrDRJ7QlQBEKaouDMJa0Mz47Gl4iP2voJsvqV2tvz3ynPV 91pQ== 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=fq1snlkJ7HKvncs6p7IE4ISoXcX/56VK7CKbDpqrX8I=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=Ivr8QMoVcXyaPI3UdRs7ARt3FSqiVKpu1JfBZnW9/mHOACpkjMQz03bd5hv5MSkU0J lWCEEL53/j85pG2LK78phcmEJ1gNn2LAa0jlZIem2o8fMFvYItgGHWU8RXpGkoCc9cnq rzYJVvEt72KTclIZ/5eXV1tCfAY0n73Ik4fgNkE7tPEtRq2XNRPUJF0w8OxSdTxGcmI7 n7iZeqvKd0f9lnxdO+eOvs/z8rQAHWkfN04wJmjuuvKap4z99QYrC+GvId+fNpQob9sw KtJP/uO16X1M6TKGFuqKBJ9sIzwntPQaoUJGEbkcvxaNzNK8kg6jeexx0fM4899JsmCx 2FMA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=E0hvlkTC; 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 bk17-20020a05620a1a1100b00778b173f525si4995279qkb.397.2023.11.18.21.41.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:41:09 -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=E0hvlkTC; 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 9B84D385801C for ; Sun, 19 Nov 2023 05:41:09 +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 BDC03385842C for ; Sun, 19 Nov 2023 05:40:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BDC03385842C 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 BDC03385842C 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=1700372444; cv=none; b=fTeAmKEOBHoZisKVq+tn5R90e/nJkkwcvfi0Lplo+nHt40mFvjo8jXDcDSqXJajzYav1TY7zAEeoU6YEm42T7bm3YpQjji2WpVQMLmKFBl1YKMarYyE9HPPYi1C6eqnD9GPi/YPDKTOFV6iyAhcqt90lkk1vCKWYi6NAPN3xUAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372444; c=relaxed/simple; bh=v+EyRWWJgoJJfFcYu3XlU/CsMM59D/sun1OuWNO1xJ8=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=kHnYthEExhwS7yf4o2jw9S0w7Fr4SCnDYRbprbs5m0F8OflbQhXny9fG/U4JfOZl1eWSSCYc/3Mjcl+L+gtL7t2xjCufLFxez8vNNLC8aEYtwFeyxxKCm8nJkmnN3vgbRJnr6Hn00UXMwLbasxtbNEiHmeVaZHMp1rj+Jay0wbo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-50aaaf6e58fso411484e87.2 for ; Sat, 18 Nov 2023 21:40:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372441; x=1700977241; 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=fq1snlkJ7HKvncs6p7IE4ISoXcX/56VK7CKbDpqrX8I=; b=E0hvlkTC5lH5aPorFkhLhCWKFiltxQWVQsYatr3j3tKFvs/iPZghpjusyQk/XgO3ew lkemJRKIGGkSR9cxvVa9pjK59aiTzxFdUTEasiBSV4qrOyd2qHIkdhNijOGKXECQUOSs iCXiSvOOWiPZ4lLvq2pAc9soF+UZuorInh07j4kW4dNXRCmzYwGOpCM3gNmdsES0dr4T p3dgoek/5MP6k5heP5D7CUVpbY5SAjJRgZ1F3a7O/Hi/UaC0YE7FY1mu3THy8yebJbAF o/VPyuHbWi2yI4O6+5MhgyvQH3PHDO2NqbKgr1X4kUpGtTbkvICqDOABF9muhvhL2ZjH XZyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372441; x=1700977241; 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=fq1snlkJ7HKvncs6p7IE4ISoXcX/56VK7CKbDpqrX8I=; b=DJ+Q/Pjj5XyW0/lsTjpFmcpVoCwK9uLz8RM1PCkCQvCyhn7d8Ec+O3o3fIY8chvIBP ijnqVW2bivePB+MZzsfwck2/hUvZuRK558Ivpq4Y+0j0VD2ZFN62OUx5p6mq50UDyST6 ZHmv0N4EBhS2bUuzYZTR0kdTOgUEGelGw294pvi6L9sxo7ZOWJavLiLA0IwbXZ4T664w hDldvYzMEsHGkN0evFbLqlA8SNFJw/yyd9Tkp2BeEdQLf2KA2pB9dxF9dE6D78qTfCtD ZtKFO4c66LlmcDdeoDsieFNvNvt1UKPt18+ce0cChRZfRTraj1iZrxsauZiy0/4RJXqj mjLQ== X-Gm-Message-State: AOJu0YwKR//wIebVAVX32YV/Kv5s8InWbxh5PhslRC7/ajHZYNDeTzac qykT5gVf2FVi++GYVrYkDbUgL1q7WrA/aBiNAqby5w== X-Received: by 2002:ac2:5159:0:b0:509:38df:1e77 with SMTP id q25-20020ac25159000000b0050938df1e77mr2810210lfd.10.1700372441269; Sat, 18 Nov 2023 21:40:41 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id hh10-20020a170906a94a00b009b2ca104988sm2545757ejb.98.2023.11.18.21.40.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:40:40 -0800 (PST) Date: Sun, 19 Nov 2023 05:40:38 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 25/44] RISC-V: Implement `riscv_emit_unary' helper 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, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969762883208270 X-GMAIL-MSGID: 1782969762883208270 Add a `riscv_emit_unary' helper for unary operations, complementing `riscv_emit_binary'. gcc/ * config/riscv/riscv-protos.h (riscv_emit_unary): New prototype. * config/riscv/riscv.cc (riscv_emit_unary): New function. --- gcc/config/riscv/riscv-protos.h | 1 + gcc/config/riscv/riscv.cc | 8 ++++++++ 2 files changed, 9 insertions(+) gcc-riscv-emit-unary.diff Index: gcc/gcc/config/riscv/riscv-protos.h =================================================================== --- gcc.orig/gcc/config/riscv/riscv-protos.h +++ gcc/gcc/config/riscv/riscv-protos.h @@ -134,6 +134,7 @@ riscv_zcmp_valid_stack_adj_bytes_p (HOST extern void riscv_expand_int_scc (rtx, enum rtx_code, rtx, rtx, bool *invert_ptr = 0); extern void riscv_expand_float_scc (rtx, enum rtx_code, rtx, rtx); extern void riscv_expand_conditional_branch (rtx, enum rtx_code, rtx, rtx); +extern rtx riscv_emit_unary (enum rtx_code code, rtx dest, rtx x); extern rtx riscv_emit_binary (enum rtx_code code, rtx dest, rtx x, rtx y); #endif extern bool riscv_expand_conditional_move (rtx, rtx, rtx, rtx); Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -1703,6 +1703,14 @@ riscv_emit_set (rtx target, rtx src) return target; } +/* Emit an instruction of the form (set DEST (CODE X)). */ + +rtx +riscv_emit_unary (enum rtx_code code, rtx dest, rtx x) +{ + return riscv_emit_set (dest, gen_rtx_fmt_e (code, GET_MODE (dest), x)); +} + /* Emit an instruction of the form (set DEST (CODE X Y)). */ rtx From patchwork Sun Nov 19 05:40:48 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: 166698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506000vqn; Sat, 18 Nov 2023 21:41:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDYD7j0S6zyWyUdeD4IoIcAZ4/4hXBQwnORR7/a0nVTXQz7wNzGl6njbmS/B5eiwC21Hl4 X-Received: by 2002:a05:620a:124d:b0:774:274a:b85d with SMTP id a13-20020a05620a124d00b00774274ab85dmr4056731qkl.70.1700372499699; Sat, 18 Nov 2023 21:41:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372499; cv=pass; d=google.com; s=arc-20160816; b=yNJ039VKUXSv+zWTMTBgtoaooxLiYyQEttVVPy4k5Phinmq3Z1pnrRuBcKZXhovgk5 bggvOhCntJ83L1BE1qdcx7A3L9pqxYYmmC6ZP/r0Y2+tDnlsqUn4LIwzgrq+sicjUIy1 FnfcTpXw+1H3fWXrj74BbKA19DaDoFXxBPWI02rlDdXBdXLa0hWYOE19haqFjteMGBfC UYOdvGOmD9nIOpCI3JDYM1Iw3Rt22kXMGiUQGcbQ0AtuMXG8E8yIKU3pwG4vTkHCWhiv UO5J7i4FjCh6Qude9JrLAwQv8GKMcCDapxKHvELgUxR/eJdH0Q3JNNegHeV0BPRltk5T JbMw== 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=GG8R1oPq7Bda2jiTTfin2OR2zq4NChlVRI3+Je73Dhw=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=MleQn0/EEa2EgB7YrA3SVgxUTeCNiXO3umksiEBVk+/gUnOipfxGW2p1YBhcy9QzWV SCCrDY2oS9N/vgTxUVEoSBq5UgQp28jyt/s399EloWdZLq7xDWDYu3XLIIq2U6TvA3ED fe/oI9rF1NjeFm1ImGFtxbOVL6Mesu9ze8Ai7HMaorap3fXDaEs2RIQ4fKS86tSM0OaW rgyeqs4rQJ1IXJrDMDS75bBq9R/VMtbRO/wbW+2ORgAFG88yzdjYpw7J9+rETOe51x+S aNPETGXqHWFeSB1ANKl+a2aPOddzokgw39oYCNuf0g8xqD4+D4vsXAOYtt/XgrCyhHv9 glhQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=PTNdA9w3; 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 u17-20020a05620a455100b0076db12d14c2si4991550qkp.719.2023.11.18.21.41.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:41: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=PTNdA9w3; 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 7465338582A7 for ; Sun, 19 Nov 2023 05:41:39 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 00E7F385842C for ; Sun, 19 Nov 2023 05:40:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 00E7F385842C 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 00E7F385842C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372455; cv=none; b=YkuhiERbZZX/5YGVFZShY6GnmZY2NK4EptxwwG2vHDLTJ5naWzmxYp2bfwAidXAUTytycCqA7bUHmI7vH+9/rARDvUmOoSv+coh6MAY0SHmh+Bk07SrHzkOwboJH0Skx1BOdslXhqbyM3CuhmbRDwRua5WukEkgotdZFERQ/gNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372455; c=relaxed/simple; bh=nbe6IDZnYdE+KWXaqcPm109AxyKREJ3lPfGg4T5jP10=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=R7O3KgeW09vgWwreLAlZpjJ1lwEacqlaO/jKawEJgBQD23bKhif38PD3kxcxM4weeCIwE0a79uo0SXhYyZoZfVQCPe1az4MVFvVToVEg3/qDdaXcFCTSgtixQZDGPqhKu4ZAvHNwZMDvSb70pDmkjQkhdqdE4kDFBqiWj1acSDc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-9db6cf8309cso435804766b.0 for ; Sat, 18 Nov 2023 21:40:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372452; x=1700977252; 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=GG8R1oPq7Bda2jiTTfin2OR2zq4NChlVRI3+Je73Dhw=; b=PTNdA9w3+GQsz5PU/ol7jelYYxUGwNhKw7/6ahG/7JOkTiYM90gpDu3y6lMswAM+X4 1UasWdzaP2UaRrAs6O8PnJI9Kl3Mh8oes2eH8L63opyoj8irickrotNjf9960BWzpMb3 +kNWdj00Lpfcz99CAIRdfA2oP39/8EnxrBA+QnBTx3XmiDivcRXCpFhFy0dFPnfETPGt T05SpqCOpXWLHXlgDt5+SFqbTJjj4Z/E/paTcR8b6WZRgGiG1MfICHrmkFSaXPMpEqML wZa744EQ8b2BTiXKSrWOJbb8E6vsbUlRrSt0QajXvhm6ECBgxPnmhD4V9Nh7ukxE5k+a HCpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372452; x=1700977252; 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=GG8R1oPq7Bda2jiTTfin2OR2zq4NChlVRI3+Je73Dhw=; b=lJG3EOJTMNdXPXTE7jo0xz6pzOANPxYHA2qa1vPOhjNy9pKWtvp8LdpDyZJRk+1EB2 iV/6kKeFMZmY65LOdYYXVJxigGyZ0cqZj6pimETarsCMWiYs3bl5Kdl4yF8fHgdHLIOg E/PECPAp9pzlvgTyQLWigqR2Q9V5PjFRVQmUv/bjKtWpWOfhIa6VLIXT2dtP2aptMfKJ m5PxKwuZFoL8Eew63JEAoNeLfYkZxnSGq17Q3eVzBcj4I67pEKp5PDroVsrel9TGHgP1 xk3wU2cF9+OuIQd8hhgEMF7w99/bJIPBwmcMlLqS955ElKrY/FzrkwtFDupBaDdoJHSR EPGQ== X-Gm-Message-State: AOJu0YzBfbTVfQh9LCnKvLjnVKyIMd4zI0jlMyczpoU3owtO1hqycd+q boG9rL3vfq9Dwi7USGYjazAPmjBxCzwYAAyEPhi9Dw== X-Received: by 2002:a17:906:73d0:b0:9c7:5a01:ffe7 with SMTP id n16-20020a17090673d000b009c75a01ffe7mr2598653ejl.12.1700372451609; Sat, 18 Nov 2023 21:40:51 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id cm7-20020a170906f58700b009e5e1710ae7sm1325575ejd.191.2023.11.18.21.40.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:40:51 -0800 (PST) Date: Sun, 19 Nov 2023 05:40:48 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 26/44] RISC-V: Add `movMODEcc' implementation for generic targets 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, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969794364202350 X-GMAIL-MSGID: 1782969794364202350 Provide RTL expansion of conditional-move operations for generic targets using a suitable sequence of base integer machine instructions according to cost evaluation by if-conversion. Add `-mmovcc' command line option to enable this transformation, off by default. For the generic sequences small immediates as per the `arith_operand' predicate are cost-equivalent to registers as we can use them as input, alternative to a register, to the respective AND[I] machine operations, however we need to reject immediates fulfilling `lui_operand', because they would require reloading into a register, making the operation more costly. Therefore add `movcc_operand' predicate and use it accordingly. There is a need to adjust zbs-bext-02.c, which can also serve as emitted code example, because with certain compilation options an AND operation can now legitimately appear in output despite BEXT having been produced as expected, such as with `-march=rv64gc -O2': foo: mv a3,a0 li a5,0 mv a0,a1 li a2,64 li a1,1 .L3: sll a4,a1,a5 and a4,a4,a3 addiw a5,a5,1 beq a4,zero,.L2 addiw a0,a0,1 .L2: bne a5,a2,.L3 ret vs `-march=rv64gc_zbs -O2': foo: mv a4,a0 li a5,0 mv a0,a1 li a3,64 .L3: bext a2,a4,a5 beq a2,zero,.L2 addiw a0,a0,1 .L2: addiw a5,a5,1 bne a5,a3,.L3 ret and then with `-march=rv64gc -mmovcc -mbranch-cost=7': foo: mv a6,a0 li a4,0 mv a0,a1 li a7,1 li a1,64 .L3: sll a5,a7,a4 and a5,a5,a6 snez a5,a5 neg a5,a5 not a2,a5 addiw a3,a0,1 and a5,a5,a3 and a0,a2,a0 addiw a4,a4,1 or a0,a5,a0 bne a4,a1,.L3 ret vs `-march=rv64gc_zbs -mmovcc -mbranch-cost=7': foo: mv a6,a0 li a4,0 mv a0,a1 li a1,64 .L3: bext a5,a6,a4 neg a5,a5 not a2,a5 addiw a3,a0,1 and a5,a5,a3 and a0,a2,a0 addiw a4,a4,1 or a0,a5,a0 bne a4,a1,.L3 ret However BEXT is supposed to replace an SLL operation so adjust the test case to reject SLL rather than AND, letting the test case pass even with `/-mmovcc/-mbranch-cost=7' specified as DejaGNU test flags (and in the absence of target-specific conditional-move operations enabled either by default or with other test flags). gcc/ * config/riscv/predicates.md (movcc_operand): New predicate. * config/riscv/riscv.cc (riscv_expand_conditional_move): Handle generic targets. * config/riscv/riscv.md (movcc): Likewise. * config/riscv/riscv.opt (mmovcc): New option. * doc/invoke.texi (Option Summary): Document it. gcc/testsuite/ * gcc.target/riscv/zbs-bext-02.c: Adjust to reject SLL rather than AND. --- gcc/config/riscv/predicates.md | 6 +++ gcc/config/riscv/riscv.cc | 41 ++++++++++++++++++++++----- gcc/config/riscv/riscv.md | 7 ++-- gcc/config/riscv/riscv.opt | 4 ++ gcc/doc/invoke.texi | 9 +++++ gcc/testsuite/gcc.target/riscv/zbs-bext-02.c | 2 - 6 files changed, 58 insertions(+), 11 deletions(-) gcc-riscv-movcc.diff Index: gcc/gcc/config/riscv/predicates.md =================================================================== --- gcc.orig/gcc/config/riscv/predicates.md +++ gcc/gcc/config/riscv/predicates.md @@ -41,6 +41,12 @@ (ior (match_operand 0 "arith_operand") (match_operand 0 "lui_operand"))) +(define_predicate "movcc_operand" + (if_then_else (match_test "TARGET_SFB_ALU || TARGET_XTHEADCONDMOV + || TARGET_ZICOND_LIKE") + (match_operand 0 "sfb_alu_operand") + (match_operand 0 "arith_operand"))) + (define_predicate "const_csr_operand" (and (match_code "const_int") (match_test "IN_RANGE (INTVAL (op), 0, 31)"))) Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -4099,7 +4099,9 @@ riscv_expand_conditional_move (rtx dest, rtx op0 = XEXP (op, 0); rtx op1 = XEXP (op, 1); - if ((TARGET_ZICOND_LIKE && GET_MODE_CLASS (mode) == MODE_INT) + if (((TARGET_ZICOND_LIKE + || (arith_operand (cons, mode) && arith_operand (alt, mode))) + && (GET_MODE_CLASS (mode) == MODE_INT)) || TARGET_SFB_ALU || TARGET_XTHEADCONDMOV) { machine_mode mode0 = GET_MODE (op0); @@ -4113,6 +4115,15 @@ riscv_expand_conditional_move (rtx dest, || (mode1 != word_mode && mode1 != VOIDmode)) return false; + /* In the fallback generic case use MODE rather than WORD_MODE for + the output of the SCC instruction, to match the mode of the NEG + operation below. The output of SCC is 0 or 1 boolean, so it is + valid for input in any scalar integer mode. */ + rtx tmp = gen_reg_rtx ((TARGET_ZICOND_LIKE + || TARGET_SFB_ALU || TARGET_XTHEADCONDMOV) + ? word_mode : mode); + bool invert = false; + /* Canonicalize the comparison. It must be an equality comparison of integer operands, or with SFB it can be any comparison of integer operands. If it isn't, then emit an SCC instruction @@ -4121,7 +4132,6 @@ riscv_expand_conditional_move (rtx dest, || !INTEGRAL_MODE_P (mode0)) { bool *invert_ptr = nullptr; - bool invert = false; /* If riscv_expand_int_scc inverts the condition, then it will flip the value of INVERT. We need to know where so that @@ -4129,11 +4139,9 @@ riscv_expand_conditional_move (rtx dest, if (code == LE || code == LEU || code == GE || code == GEU) invert_ptr = &invert; - /* Emit an scc like instruction into a temporary - so that we can use an EQ/NE comparison. */ - rtx tmp = gen_reg_rtx (word_mode); - - /* We can support both FP and integer conditional moves. */ + /* Emit an SCC-like instruction into a temporary so that we can + use an EQ/NE comparison. We can support both FP and integer + conditional moves. */ if (INTEGRAL_MODE_P (mode0)) riscv_expand_int_scc (tmp, code, op0, op1, invert_ptr); else if (FLOAT_MODE_P (mode0) @@ -4149,6 +4157,8 @@ riscv_expand_conditional_move (rtx dest, op0 = XEXP (op, 0); op1 = XEXP (op, 1); } + else if (!TARGET_ZICOND_LIKE && !TARGET_SFB_ALU && !TARGET_XTHEADCONDMOV) + riscv_expand_int_scc (tmp, code, op0, op1, &invert); if (TARGET_SFB_ALU || TARGET_XTHEADCONDMOV) { @@ -4166,6 +4176,23 @@ riscv_expand_conditional_move (rtx dest, cons, alt))); return true; } + else if (!TARGET_ZICOND_LIKE) + { + if (invert) + std::swap (cons, alt); + + rtx reg1 = gen_reg_rtx (mode); + rtx reg2 = gen_reg_rtx (mode); + rtx reg3 = gen_reg_rtx (mode); + rtx reg4 = gen_reg_rtx (mode); + + riscv_emit_unary (NEG, reg1, tmp); + riscv_emit_binary (AND, reg2, reg1, cons); + riscv_emit_unary (NOT, reg3, reg1); + riscv_emit_binary (AND, reg4, reg3, alt); + riscv_emit_binary (IOR, dest, reg2, reg4); + return true; + } /* 0, reg or 0, imm */ else if (cons == CONST0_RTX (mode) && (REG_P (alt) Index: gcc/gcc/config/riscv/riscv.md =================================================================== --- gcc.orig/gcc/config/riscv/riscv.md +++ gcc/gcc/config/riscv/riscv.md @@ -2658,9 +2658,10 @@ (define_expand "movcc" [(set (match_operand:GPR 0 "register_operand") (if_then_else:GPR (match_operand 1 "comparison_operator") - (match_operand:GPR 2 "sfb_alu_operand") - (match_operand:GPR 3 "sfb_alu_operand")))] - "TARGET_SFB_ALU || TARGET_XTHEADCONDMOV || TARGET_ZICOND_LIKE" + (match_operand:GPR 2 "movcc_operand") + (match_operand:GPR 3 "movcc_operand")))] + "TARGET_SFB_ALU || TARGET_XTHEADCONDMOV || TARGET_ZICOND_LIKE + || TARGET_MOVCC" { if (riscv_expand_conditional_move (operands[0], operands[1], operands[2], operands[3])) Index: gcc/gcc/config/riscv/riscv.opt =================================================================== --- gcc.orig/gcc/config/riscv/riscv.opt +++ gcc/gcc/config/riscv/riscv.opt @@ -460,6 +460,10 @@ misa-spec= Target RejectNegative Joined Enum(isa_spec_class) Var(riscv_isa_spec) Init(TARGET_DEFAULT_ISA_SPEC) Set the version of RISC-V ISA spec. +mmovcc +Target Var(TARGET_MOVCC) +Enable conditional moves unconditionally. + minline-atomics Target Var(TARGET_INLINE_SUBWORD_ATOMIC) Init(1) Always inline subword atomic operations. Index: gcc/gcc/doc/invoke.texi =================================================================== --- gcc.orig/gcc/doc/invoke.texi +++ gcc/gcc/doc/invoke.texi @@ -1242,6 +1242,7 @@ See RS/6000 and PowerPC Options. -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} -mstack-protector-guard-offset=@var{offset} -mcsr-check -mno-csr-check +-mmovcc -mno-movcc -minline-atomics -mno-inline-atomics -minline-strlen -mno-inline-strlen -minline-strcmp -mno-inline-strcmp @@ -29586,6 +29587,14 @@ Do or don't use smaller but slower prolo library function calls. The default is to use fast inline prologues and epilogues. +@opindex mmovcc +@item -mmovcc +@itemx -mno-movcc +Do or don't produce branchless conditional-move code sequences even with +targets that do not have specific instructions for conditional operations. +If enabled, sequences of ALU operations are produced using base integer +ISA instructions where profitable. + @opindex minline-atomics @item -minline-atomics @itemx -mno-inline-atomics Index: gcc/gcc/testsuite/gcc.target/riscv/zbs-bext-02.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/zbs-bext-02.c +++ gcc/gcc/testsuite/gcc.target/riscv/zbs-bext-02.c @@ -15,4 +15,4 @@ foo(const long long B, int a) /* { dg-final { scan-assembler-times "bext\t" 1 } } */ /* { dg-final { scan-assembler-not {\mbset} } } */ -/* { dg-final { scan-assembler-not {\mand} } } */ +/* { dg-final { scan-assembler-not {\msll} } } */ From patchwork Sun Nov 19 05:40:59 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: 166701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506118vqn; Sat, 18 Nov 2023 21:42:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IESOsOgdhD/MSZQa4s+9kAL6Q8tdvmhcSmldJOb2SxuW5/UbN2nKVGD4CSy/VHAouqoPAOX X-Received: by 2002:a05:620a:14b4:b0:77a:b77:bcb3 with SMTP id x20-20020a05620a14b400b0077a0b77bcb3mr4587680qkj.5.1700372531256; Sat, 18 Nov 2023 21:42:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372531; cv=pass; d=google.com; s=arc-20160816; b=gJu76PVNt9W0RkyKMiOT02wptdkzjRBLcUbFjjLzvsXNo1P5uUSDEw2wqymAjzl5dE qCG1r5+FHQzNlfgEAnbTeyWUCEO4/K0AN4OyF0eGSAZnVQe23bnbyS6kDlBAFODo6Ph6 RR7VUU2n2gRvtAJ7pbDAMazOuRDfXyN+gxvtIJ/czxy5vy/pRPP5iMACZ3pR9DHzUViL zmbdLk6EmYJqAQPRmOB5lStZgmmpVSI0KZJYvC8goQ81w8XvhXb8C6pAafrIoK8GSJr2 +4SBREE9rbKrTwxitoysrwyN+IEf10dMyKFZEopAelZc2X5eulAxhtKwmuqD2JtzoQPX Co4A== 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=Sefd/aY3ngEECz9vj1PjH/sEyvDmaXKfi2HwJJK6QNs=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=OvppC5GSG53slfaJ+jqz5eGym/hvTXqkUcjhCdvMj5+4L3LxlGsIITWQijzQXgovT6 BMcop2CntSXNVl6nZJdZl5qa2pkTTdex2ZZdyj2u1/OteasH8YUU/YLBE30mOz+TSAlD Zg41FbxpEbUqfn3ePpRsA/NyUJHtTQP1yvqKSEJGPRzkj60nl0wzblw9JG0nPeTOI6Fn qTCCRwtTTMHnXumxZ3o1+ISL/W+AGOfaMgwL3iqSM4sXizDKzYJeCabJPGu93oJpUZxF f2iKY/c7ombw+bqIXuiIVuvko29ClZNetn038L6mpa2vUEKjsifwAv9fc1r+mKE1Nx/H 2I/A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=hlKuaeLg; 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 pz9-20020a05620a640900b0077a40cddc00si5166977qkn.174.2023.11.18.21.42.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:42:11 -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=hlKuaeLg; 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 09116385800C for ; Sun, 19 Nov 2023 05:42:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id A420D3858001 for ; Sun, 19 Nov 2023 05:41:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A420D3858001 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 A420D3858001 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372468; cv=none; b=DF9qUlKdNwb4xnhpsms8iVgxZ09Ex5yh0e1GEOIi0TChq+3o7ZhgA5LqY1Z/7lzQ0YR8TUD/T0L8R+3g42z6hpUcL3FjN4YJZGnEaYFp/qHZm1ineuZk/DedwIU4DJlGkn7GdyqsonMGowMOOXBD9pQ7aVBDN44dpRjb11wqJqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372468; c=relaxed/simple; bh=Wg9FvtqD2pJxx2MnYMQujM+t5j8ZDyJvANr6qUNUBpg=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=cvHug+CLxtpHhm3SfR3JvlNXgfk7Q56yWUlj/SfcSJymiF0Fb48srReb492hXFkL+jYw01GEtETlt+dNhH8tQqyPCvwsQ52BurxpbEFXtvHbJu/JIRikJIaZGRQij0vZc9PIym1RoVI+HXImCbviZeJ6L2hVE1uxmS//v4riQ/o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-9db6cf8309cso435813766b.0 for ; Sat, 18 Nov 2023 21:41:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372463; x=1700977263; 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=Sefd/aY3ngEECz9vj1PjH/sEyvDmaXKfi2HwJJK6QNs=; b=hlKuaeLgnkEK3H4p9LLPGVeZPX6Djh1Tk76y4HRR+GtgXKkbwx7gf4FmUxlL+qK1V2 9PguqWJxAzmHxjRFPaskvOnYaID3D3a5UXtwLJiUFvzBjWO8OOlvvScHsFUfS6BBelSk zoD7WsxDj/DyoBZz7qo22tLjUmxsOvWPKCUsMCizpzEUZnj/9TQZb0SBSENJGLlqVd7Y atYl3IG4V4zbgrc33tiM8OC1Ef5XhsSB2I16281ae+zvh4ykSNFfr6uR1+4dx8K/kcko 6FNcOzdVAwvfXvJr/Sce8+YdzbFMdYksR07xI87PigkFIPPgQdW4udkAtWAk+2wicFbj oBQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372463; x=1700977263; 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=Sefd/aY3ngEECz9vj1PjH/sEyvDmaXKfi2HwJJK6QNs=; b=R8i/syqprEK6fn1+CeJOk2WjU3iEZOCGVcTSOb8umUMIZxyraz5rUr40TBxxJtwiwO KBvsXP8AZGKGMrzYHLRUc5Sy5yyjdCi1W2wU5xuYUgQkKSPzwA7wU5dIs7Un6CQ746Bb nACc+7NOQf6TIMdW1SBteYT5xGCa4qzbo9M5OiZ7ehnioISb7Ti2RJyxO3AFtyaUZ+V4 iRLfyVYrCWXqszR1MzXPlqb/kESBvC7h35SpK4SCJMjp85XvQHXRg36MK9ZF+z93yN23 jg/qpArps5gMbM8ZlNsU/XyAlsJ0Bh52l7ExkQDI7TGIU9ZLUzxRSQqWxO0/ivYbZva9 tBhA== X-Gm-Message-State: AOJu0Yw8twnDofHIftkRY5hhDxEwOSdsJLgDgwpxLqRBtPi06PyUPOKv mCMwtOf8pj9q2wVkQ/yyNAEpfAk/sFPBszH3FAjpyw== X-Received: by 2002:a17:906:2088:b0:9d3:ccf0:761e with SMTP id 8-20020a170906208800b009d3ccf0761emr3061282ejq.49.1700372463312; Sat, 18 Nov 2023 21:41:03 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id p20-20020a170906a01400b009adc77fe164sm2537789ejy.66.2023.11.18.21.41.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:41:02 -0800 (PST) Date: Sun, 19 Nov 2023 05:40:59 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 27/44] RISC-V/testsuite: Add branched cases for generic integer cond moves 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.1 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_20_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: 1782969827442744256 X-GMAIL-MSGID: 1782969827442744256 Verify, for generic integer conditional-move operations, if-conversion *not* to trigger at the respective sufficiently low `-mbranch-cost=' settings that make original branched code sequences cheaper than their branchless equivalents if-conversion would emit. Cover all integer relational operations to make sure no corner case escapes. gcc/testsuite/ * gcc.target/riscv/movdibeq.c: New test. * gcc.target/riscv/movdibge.c: New test. * gcc.target/riscv/movdibgeu.c: New test. * gcc.target/riscv/movdibgt.c: New test. * gcc.target/riscv/movdibgtu.c: New test. * gcc.target/riscv/movdible.c: New test. * gcc.target/riscv/movdibleu.c: New test. * gcc.target/riscv/movdiblt.c: New test. * gcc.target/riscv/movdibltu.c: New test. * gcc.target/riscv/movdibne.c: New test. * gcc.target/riscv/movsibeq.c: New test. * gcc.target/riscv/movsibge.c: New test. * gcc.target/riscv/movsibgeu.c: New test. * gcc.target/riscv/movsibgt.c: New test. * gcc.target/riscv/movsibgtu.c: New test. * gcc.target/riscv/movsible.c: New test. * gcc.target/riscv/movsibleu.c: New test. * gcc.target/riscv/movsiblt.c: New test. * gcc.target/riscv/movsibltu.c: New test. * gcc.target/riscv/movsibne.c: New test. --- gcc/testsuite/gcc.target/riscv/movdibeq.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibge.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibgeu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibgt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibgtu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdible.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibleu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiblt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibltu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibne.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibeq.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibge.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibgeu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibgt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibgtu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsible.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibleu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiblt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibltu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibne.c | 28 ++++++++++++++++++++++++++++ 20 files changed, 524 insertions(+) gcc-riscv-test-movcc-branch-generic.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdibeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibeq.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=6 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + bne a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibge.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=5 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + blt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibgeu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibgeu.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=5 -mmovcc -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + bltu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibgt.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=5 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + ble a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibgtu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibgtu.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=5 -mmovcc -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 branched assembly like: + + bleu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdible.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdible.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=5 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibleu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibleu.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=5 -mmovcc -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgtu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdiblt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiblt.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=5 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + bge a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibltu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibltu.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=5 -mmovcc -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 branched assembly like: + + bgeu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdibne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibne.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=5 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branched assembly like: + + beq a0,a1,.L3 + mv a0,a2 + ret +.L3: + mv a0,a3 + ret + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibeq.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=6 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=6 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branched assembly like: + + bne a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibge.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + blt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibgeu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibgeu.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsigeu (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + bltu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibgt.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + ble a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibgtu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibgtu.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -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 branched assembly like: + + bleu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsible.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsible.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgt a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibleu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibleu.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsileu (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + bgtu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiblt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiblt.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + bge a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibltu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibltu.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -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 branched assembly like: + + bgeu a0,a1,.L2 + mv a3,a2 +.L2: + mv a0,a3 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsibne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibne.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=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branched assembly like: + + beq a0,a1,.L3 + mv a0,a2 + ret +.L3: + mv a0,a3 + ret + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ From patchwork Sun Nov 19 05:41:12 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: 166699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506024vqn; Sat, 18 Nov 2023 21:41:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxRS8W1FeEzdn+k5l0oZEO7Go7ms0XEp1Uesq622AVpdqY9EL5c7XdQe8hXC3ZiSRG5s4C X-Received: by 2002:a05:622a:1c4:b0:419:6cde:86c3 with SMTP id t4-20020a05622a01c400b004196cde86c3mr4729146qtw.3.1700372506700; Sat, 18 Nov 2023 21:41:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372506; cv=pass; d=google.com; s=arc-20160816; b=bJqdnjne8IKJIRz0NEysWFkZAaq70MhO0p1bsPREjVbXtR+2jdzFQK2S7EilqopDTz b/rG5Y5lyySuhYIXqlajAo5f75iWxZaM2pa/MG02oBvUv9nHLtgwFyRVXHcyGMvKqspU mAKPLvn2adFLkXAbaSFvLTwaiI97qea505L985V+LUZoYd+vAmlCuxExaz2lC7z9kMks R05YJrZL+f0JvhwP7E8asSZ5jZvTMyUfijjjLyWaWKUZQN2IIInVNOdFZpw8r8Jm+f4K RSHzG6162eWpMRzA60sWdbojEawcqV4GEXcZrCBLR1AGWJ+MXZdn73XO4m6NFgd1iIAy 5k2w== 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=lbqVnJmJA+hLoDrcBPT/9REGkr6W0pfcdKjj8w1WvbY=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=M9b5NdAdrsMjSXMqs6DFRQHxooOU91taf4N5XbomGhiZvLmzxrDMyqyHE8q81UhzVf obfni3F9G/LPVlFrzogb67OrDniwmz8qhcrQ8+bG8mrpwwuzvEu+bmSreu0RWC6J8TV9 /hJ+Dw7JG/iUB5BF3b/fLm2J9GGjmkMpWPK4ok4q9ZVKwPOwhiYXSyUi2v+c8yLgDG0+ Q0cEicH6QkaND4u7pCRTNiU/UAaS97pQMmg+dSS9QD6qIAH8JNaYrMAp6EXRNcyJuNY+ poSI9mFxLz6WU4ou6yDpjItZrz88bJVj3N1mkjPT7KPwMk0S68SYx7myL18DB6Wl1L0c 2aog== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=btVILgyq; 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 t3-20020a05622a01c300b004136d6ed0ddsi4978096qtw.545.2023.11.18.21.41.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:41:46 -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=btVILgyq; 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 CCDFA385802B for ; Sun, 19 Nov 2023 05:41:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id DEB8A3857C7E for ; Sun, 19 Nov 2023 05:41:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DEB8A3857C7E 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 DEB8A3857C7E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372481; cv=none; b=WqBMFnizismBQC6+1lhXUiGV16oQbZiSXXZ4xmzNKKXpIYJg+UdBnrfeDOJP1mhwMiz+vDecFNWCO2XHkWCBKFnR4EjSDxK+soGr+M/IDzpsTjEM9DypUznUaP6KwgckRPKojtYdD9PcIzvC3ZpexepvhKGDYp+VRPFgc4511uw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372481; c=relaxed/simple; bh=roeMatjJRUkLOBu6ntJNAjPZBhGwmKSKeXBGoOih3To=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=JNp5YFl30CJdkzoCFE667k4m2rdB0HXaWiUjGzbhXfznMhG+goOmH1uDoISjDqYXJX6OJBQ5YTlE7d5CDXGhRhcuybl9tnNIHqmNuN/V8B6g289yQvnSGro7cwqSDhQgMUqaxmBRUy94bHEJ5thN6eAMc/7lwWRTYI/HZuMcxJk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-53e08e439c7so4721838a12.0 for ; Sat, 18 Nov 2023 21:41:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372476; x=1700977276; 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=lbqVnJmJA+hLoDrcBPT/9REGkr6W0pfcdKjj8w1WvbY=; b=btVILgyq0FB9OC67nhWqpefqkbhVU0aQCMgRzPuR+u2GMcjPpdPlYXem4VViAH6vNE BZ/Zr7Wmx2VcbAsLAaroJk8fT1nJKnnsJIeFOu51Kw3oVaJEx4jMx1cg/fy3fetFmIw8 zlga78zUFHxmKn2Unrh+cKwsZFNB7Ew/8QcwksbOtaA4wZuitF1uZwak7XOOlBN+EV2X +q/B6djjPi0PvabetzxEEMgTC+3cKIes/0J9ll41Q3wptLDGrt07pzAleBXJMDygtxES Fr3ZL6AvJXN0OYlE5orkOUNI4eJzAhrWUFWIVsFUZevx+KrYj7iNe/SHsBfKLOuVhM9W o0ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372476; x=1700977276; 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=lbqVnJmJA+hLoDrcBPT/9REGkr6W0pfcdKjj8w1WvbY=; b=N5Z/biuajyMFTdvOn36LDU+UajWRLWP4BnIIJ9gfBPc385l62cv+jj4Off/4S+HxZH kQ6NIo/7c6g1i2MKekmVfWWwcGDAYnE2rbOSIWRlZhF0mcgO6rDbmj7BNjh/WZTmL5hR ekLBoek1/VpAJwY6BQM1l9ptnRKA/4BLi0KaQDJmpEkv0WKbpHktEQ9xhVHflIYdZwT2 CCGOLiRW5Z+HOf5n2C8tL8JlBhzHxCnRmX8FkfFTsWwAQdjoa0udvKgX0AEWS7fnZWdr wkfRNQ249rJAjvYGoQdw6p8tCTfXIu/Ed+/jb+geG0gYBtKAjFug+IXsa5Ye7XaNl23V MYzQ== X-Gm-Message-State: AOJu0Yw0FL074BjnrRUSRnl78lbkzfriUsgqivYqNyxCqARn3Gr3ND/v Qo9GOjMI2W5hjQ4rYW1JznPopEPWPjVNI70TS3KhsQ== X-Received: by 2002:a50:fb95:0:b0:548:4898:e928 with SMTP id e21-20020a50fb95000000b005484898e928mr2620546edq.32.1700372476554; Sat, 18 Nov 2023 21:41:16 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id a16-20020a50e710000000b00532eba07773sm2281538edn.25.2023.11.18.21.41.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:41:16 -0800 (PST) Date: Sun, 19 Nov 2023 05:41:12 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 28/44] RISC-V/testsuite: Add branchless cases for generic integer cond moves 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.3 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_20_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: 1782969801701716246 X-GMAIL-MSGID: 1782969801701716246 Verify, for generic integer conditional-move operations, if-conversion to trigger via `noce_try_cmove' 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. gcc/testsuite/ * gcc.target/riscv/movdieq.c: New test. * gcc.target/riscv/movdige.c: New test. * gcc.target/riscv/movdigeu.c: New test. * gcc.target/riscv/movdigt.c: New test. * gcc.target/riscv/movdigtu.c: New test. * gcc.target/riscv/movdile.c: New test. * gcc.target/riscv/movdileu.c: New test. * gcc.target/riscv/movdilt.c: New test. * gcc.target/riscv/movdiltu.c: New test. * gcc.target/riscv/movdine.c: New test. * gcc.target/riscv/movsieq.c: New test. * gcc.target/riscv/movsige.c: New test. * gcc.target/riscv/movsigeu.c: New test. * gcc.target/riscv/movsigt.c: New test. * gcc.target/riscv/movsigtu.c: New test. * gcc.target/riscv/movsile.c: New test. * gcc.target/riscv/movsileu.c: New test. * gcc.target/riscv/movsilt.c: New test. * gcc.target/riscv/movsiltu.c: New test. * gcc.target/riscv/movsine.c: New test. --- gcc/testsuite/gcc.target/riscv/movdieq.c | 29 +++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdige.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigeu.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigt.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdigtu.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdile.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdileu.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdilt.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiltu.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdine.c | 29 +++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsieq.c | 29 +++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsige.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigeu.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigt.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsigtu.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsile.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsileu.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsilt.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiltu.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsine.c | 29 +++++++++++++++++++++++++++++ 20 files changed, 564 insertions(+) gcc-riscv-test-movcc-generic.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdieq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdieq.c @@ -0,0 +1,29 @@ +/* { 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=7 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branchless assembly like: + + sub a5,a0,a1 + snez a5,a5 + neg a5,a5 + and a3,a5,a3 + not a5,a5 + and a5,a5,a2 + or a0,a3,a5 + */ + +/* { 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 "\\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/movdige.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdige.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=6 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + slt a1,a0,a1 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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(?: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/movdigeu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigeu.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=6 -mmovcc -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdigeu (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 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdigt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigt.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=6 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + sgt a1,a0,a1 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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(?: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/movdigtu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdigtu.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=6 -mmovcc -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 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdile.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdile.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=6 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + sgt a1,a0,a1 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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(?: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/movdileu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdileu.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=6 -mmovcc -fdump-rtl-ce1" } */ + +typedef unsigned int __attribute__ ((mode (DI))) int_t; + +int_t +movdileu (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 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdilt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdilt.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=6 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + slt a1,a0,a1 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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(?: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/movdiltu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiltu.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=6 -mmovcc -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 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdine.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdine.c @@ -0,0 +1,29 @@ +/* { 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=6 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + sub a5,a0,a1 + seqz a5,a5 + neg a5,a5 + and a3,a5,a3 + not a5,a5 + and a5,a5,a2 + or a0,a3,a5 + */ + +/* { 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 "\\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/movsieq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsieq.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=7 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=7 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y : z; +} + +/* Expect branchless assembly like: + + sub a5,a0,a1 + snez a5,a5 + neg a5,a5 + and a3,a5,a3 + not a5,a5 + and a5,a5,a2 + or a0,a3,a5 + */ + +/* { 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 "\\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/movsige.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsige.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=6 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=6 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + slt a1,a0,a1 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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(?: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/movsigeu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigeu.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=6 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=6 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsigeu (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 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsigt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigt.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=6 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=6 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + sgt a1,a0,a1 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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(?: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/movsigtu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsigtu.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=6 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=6 -mmovcc -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 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsile.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsile.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=6 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=6 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + sgt a1,a0,a1 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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(?: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/movsileu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsileu.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=6 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=6 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef unsigned int __attribute__ ((mode (SI))) int_t; + +int_t +movsileu (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 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsilt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsilt.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=6 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=6 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + slt a1,a0,a1 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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(?: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/movsiltu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiltu.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=6 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=6 -mmovcc -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 + neg a1,a1 + and a3,a1,a3 + not a1,a1 + and a1,a1,a2 + or a0,a3,a1 + */ + +/* { 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-not "\\s(?:seqz|snez)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:bgeu|bgtu|bleu|bltu)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsine.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsine.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=6 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=6 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + sub a5,a0,a1 + seqz a5,a5 + neg a5,a5 + and a3,a5,a3 + not a5,a5 + and a5,a5,a2 + or a0,a3,a5 + */ + +/* { 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 "\\ssub\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:seqz|snez)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ From patchwork Sun Nov 19 05:41: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: 166704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506321vqn; Sat, 18 Nov 2023 21:42:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHo7mNUN6sRgVVkPWY4gZxucBNBQ1D0X2sbYWuufFAl59Pp3zkpVWl1sXBwuvidubWDt8So X-Received: by 2002:a05:620a:4148:b0:77b:d0b9:239c with SMTP id k8-20020a05620a414800b0077bd0b9239cmr5547947qko.2.1700372574142; Sat, 18 Nov 2023 21:42:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372574; cv=pass; d=google.com; s=arc-20160816; b=aRyR0m35jXdBEyQZg723prIkQRUpQJM69CPz9ZxJHCCn/l8nOvihq5uYSCJPSOJD2R QFJ4dQg0Mxw/XPjeNXU3VcnzZzbi8J9KDP07d9+oDckX5NlDWHqUs/5aOEZHhAvUggHm sQ3kBQyh7ZQskegP+QCRlM7Eb7EahhBDL92W0yB3v3kBWau3ekRmwU5QtKGW++DvPdoZ +CGPK2Es8FoQWCpudDKDOK3FMkYI+tN31jpbaFKEW40xGCBbnLA/wcCTDWh6H8OMws42 p6a5zizLzeNI35bTe8b8mSm610hYTM+s+JK4YS4ljtiXinxlqhI/YKh5dyLqN8t8+gV1 aM9g== 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=8IChBDQyNqs9L/5jI7kXNuu2heirprWAAjtNHKLHBJw=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=U/pivaGqPW/6XnLdmGbd10IwOkpMx40z2VnujS7iBT6NzY2dl1XCZUJ8qtm5HAGeqf WYZxMm1raNmNH7y4HCaThkZr93vFEtEmzdKWELmC8PsZH5by0A0UVcY/OD6PxX6tHx9j ajPs9nJCGGu8F4LY6dgiMXmBOVI5LV+Oob1QSdxeNv5Bp7Qy/B38n9LzLLg6pWX1C4Yp QPe7MsDA8oNiPUStu1ddL4rW0FCD+EVPgBeijOrgSnW4yzqLOjl+GtlrrtgmvpMKI/qW abGs9/nZtk5sb7/x08TvtgFKTsbw3jJ1OLJn5YbCdoV//n17ccc9Jy2TF62iqQ6L7omU t1eQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=hfD1R5qb; 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 qr21-20020a05620a391500b00779f2fca0f5si5169617qkn.695.2023.11.18.21.42.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:42:54 -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=hfD1R5qb; 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 9E360385840E for ; Sun, 19 Nov 2023 05:42:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id BDD57385828D for ; Sun, 19 Nov 2023 05:41:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BDD57385828D 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 BDD57385828D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372489; cv=none; b=Uc/Xl/8kWB7rHXKjC8VnlOkfAJLhtEZzrSZ/Nz2U5z6dhgA9nEET0WCQzVEf1a6NdkkpBMN/3P7i6FZAWV0J42RYarLfP2Bh13KD3Xat+WeVwMF4nEg1z0xBJ4+ZfMDT1HtsjAhMvaU4Sx406WwYTA6cdRaNOHtFxaHX1/Ngn10= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372489; c=relaxed/simple; bh=/WjzrJZrFnId7fr8PHu0QTYZsEpSLmVAs5d4D5BuzS0=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=q90WqueyoNyR04LSHeIN40CxIFh0vKpEF3BHcyIEBPT2HW+BZhaDhY4mDmB1bsLCQbpgoku2+XccuhWhHH+z9wTbEKweIybwwWmGvkI9oeiQzQYH8jIvwm+86Fno0gtUo/RnHfRNgRCh3c4/Y3dFidv5/d0Fg+XklYqb6//VxPQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-9db6cf8309cso435828666b.0 for ; Sat, 18 Nov 2023 21:41:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372486; x=1700977286; 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=8IChBDQyNqs9L/5jI7kXNuu2heirprWAAjtNHKLHBJw=; b=hfD1R5qbAi/pB0b5zb5TMdCCSWXQT/zYzktorqT+oVsF3mHO1AKiAYLgwTkaDKl1X5 1yL6iuTqcJr0BtowYCIVT44TngKb0dEV8Xde+mAmOVEHXEU/ti/l+7Vx7wkeqyw8qK4o fuo4ZxpZWgW+w/SmQP7wyYFDYlSaw+jWaaBj+ukYtb7HwjVhfA3bS0IpissamTCxl66U bWZrlHS/ns8O8sJliXgKkKE18U/mn2TYvhkbGFagpXY+Pl93NMSkOXdCg8zPi162uC0X P2XLJXXBfSUEmuCjnukzeDqvupta80yRHqqgFaOi39RZm5P3+0hwAmDIsm981axdJ09O 2vRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372486; x=1700977286; 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=8IChBDQyNqs9L/5jI7kXNuu2heirprWAAjtNHKLHBJw=; b=s/049elAZD2x5Z5plqeTIA+/ZG9z1kS75UHBcYLEPDYtNYbKAIQx9jL9sa4jCJQA3a nWqigKIhVGXsVZKWH1tIgy34FtlFE2IfcPeczfIXl6iIi1cqEGwMY8OAFP7fJAogWqF/ QbPUy00vNkdR7/g1CtDOLXBTP5RciznKW0ICSOvJ+KBhjUaQuSl/tG9PXMb7Qmkg26lV FOzKXnKGWzx9HOd1FlyByZ3N6NvHgZHy6AEStd/xxb2BYdbPmUzvHJ7/GN98fLT9dLyf +K8AKt0cTVBn7CxKLL87c0pWSqtDdzZlJ/ed5fWTebD39s2ShIhBTxUjDN9Nc61UrRs8 XPQQ== X-Gm-Message-State: AOJu0Yy4fPWzTa1IIaY91h9GPYTR/hFUlR7iaGQ/7LPSL5xFnVmmdE+S dvYlUpuIXrgqL6FXKgEaAkhbRE+2iF+Av7oYkbAk+g== X-Received: by 2002:a17:906:1017:b0:9fd:b304:c7a3 with SMTP id 23-20020a170906101700b009fdb304c7a3mr53160ejm.44.1700372486544; Sat, 18 Nov 2023 21:41:26 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id s23-20020a170906bc5700b009fca9f39e98sm412712ejv.26.2023.11.18.21.41.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:41:26 -0800 (PST) Date: Sun, 19 Nov 2023 05:41:24 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 29/44] RISC-V: Add `addMODEcc' implementation for generic targets 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=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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: 1782969872083049004 X-GMAIL-MSGID: 1782969872083049004 Provide RTL expansion of conditional-add operations for generic targets using a suitable sequence of base integer machine instructions according to cost evaluation by if-conversion. Use existing `-mmovcc' command line option to enable this transformation. gcc/ * config/riscv/riscv.md (addcc): New expander. --- gcc/config/riscv/riscv.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) Index: gcc/gcc/config/riscv/riscv.md =================================================================== --- gcc.orig/gcc/config/riscv/riscv.md +++ gcc/gcc/config/riscv/riscv.md @@ -2655,6 +2655,8 @@ [(set_attr "type" "branch") (set_attr "mode" "none")]) +;; Conditional move and add patterns. + (define_expand "movcc" [(set (match_operand:GPR 0 "register_operand") (if_then_else:GPR (match_operand 1 "comparison_operator") @@ -2670,6 +2672,45 @@ FAIL; }) +(define_expand "addcc" + [(match_operand:GPR 0 "register_operand") + (match_operand 1 "comparison_operator") + (match_operand:GPR 2 "arith_operand") + (match_operand:GPR 3 "arith_operand")] + "TARGET_MOVCC" +{ + rtx cmp = operands[1]; + rtx cmp0 = XEXP (cmp, 0); + rtx cmp1 = XEXP (cmp, 1); + machine_mode mode0 = GET_MODE (cmp0); + + /* We only handle word mode integer compares for now. */ + if (INTEGRAL_MODE_P (mode0) && mode0 != word_mode) + FAIL; + + enum rtx_code code = GET_CODE (cmp); + rtx reg0 = gen_reg_rtx (mode); + rtx reg1 = gen_reg_rtx (mode); + rtx reg2 = gen_reg_rtx (mode); + bool invert = false; + + if (INTEGRAL_MODE_P (mode0)) + riscv_expand_int_scc (reg0, code, cmp0, cmp1, &invert); + else if (FLOAT_MODE_P (mode0) && fp_scc_comparison (cmp, GET_MODE (cmp))) + riscv_expand_float_scc (reg0, code, cmp0, cmp1); + else + FAIL; + + if (invert) + riscv_emit_binary (PLUS, reg1, reg0, constm1_rtx); + else + riscv_emit_unary (NEG, reg1, reg0); + riscv_emit_binary (AND, reg2, reg1, operands[3]); + riscv_emit_binary (PLUS, operands[0], reg2, operands[2]); + + DONE; +}) + ;; Patterns for implementations that optimize short forward branches. (define_insn "*movcc" From patchwork Sun Nov 19 05:41:33 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: 166700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506094vqn; Sat, 18 Nov 2023 21:42:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqzxMbrgrI1cNHwwd0bzIPQ6nWEIeQQIMKr5hDA0fgfa6RqoDZ8yfnimQ70WxOHA+aHf1F X-Received: by 2002:ac8:7c4d:0:b0:400:a2b8:1c97 with SMTP id o13-20020ac87c4d000000b00400a2b81c97mr5415746qtv.17.1700372525764; Sat, 18 Nov 2023 21:42:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372525; cv=pass; d=google.com; s=arc-20160816; b=lw/pFtqYrUbNnGR/JQsu2DhH3mZE6YBV8KvHnWCjIQwhe9DYtaOBSsg1m8IYU/zohy EjAR2SOOYU8/HWP82KDJ7iIhtCRSsOWtFQj9NqbhIKF7ZA/3kEktfWSR/lO14rLk82gL /v7nlNjbmMcTFDEJhJMaeeXRh500N/TSabzSBih0cNRLV80O4U26uq0xRj/WAXT4oLFx LHKMaE2RWUFP+UF3C8gY/z0CZNE46KbQTeKqKWfPSCyBeOfohRJGEAgmyUGQA+DolxEJ g/eUQv0HSH1JFw2Vz8zxiB5j0VNezzMfYWII10y4zkEOmiZScZOAHJtfD0eD3R1EX10Y 1Kbg== 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=z1u1EolHyezT3Rj/p1S6KCWedsg36rnuPa2xYDe7iDw=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=ts/YO+XJBfiXnVPwrnDs6DTNWkOU+pP1sYH14Xn/wxq0ZI5uclHX0ZoRcCjOyfFDyJ 4B9zlbObuYsi5DgUgseWDLWHmmF+yjiNsVmg1fbYqpK7wa0G5SBFbuMeP5RK2j/rdUwn ohkXKqa2PPjSWY5OC9PYhc7cHLl09XFs9sqQSe+4QXV3GqewutmvObx/tftP8Y1oK4xa PIW41asfxxtz810psF9OAATPrqi8PZSB0sOsk8ygcTfcI46a24SFWXZHtUwVixI57rzs VjuT55rO517bbNHtu7p/QBC5cxd71gAWiekIbKaAPWOWBshclwVdahC1HJ7uzWV6dqBN DUAQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=YzuesD6d; 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 14-20020ac8590e000000b0041cde9ed1adsi5024131qty.742.2023.11.18.21.42.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:42:05 -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=YzuesD6d; 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 74CD33858437 for ; Sun, 19 Nov 2023 05:42:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 5FED63858281 for ; Sun, 19 Nov 2023 05:41:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5FED63858281 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 5FED63858281 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::531 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372502; cv=none; b=c9nam9Lh1Dml6gqsScfpsAxGCbkc0c/XCnpIxuJgpGpTT1ywlwgH6mmTMj7+mQbuS+JLSr4pCCicMbZ3cf8YlvcBR5OJ16Z7uCguhwwkGwlz5bv1k1jDjZVbgX10XEyFPB17gKHCxawuJJVmzotgRtQoTg4EPumXjRb99LwWjTk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372502; c=relaxed/simple; bh=3GhgT2LVv5D5GMpPUMpC0k7VKD1t9L2YxXZ6ci/ZRb8=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=kNG7FQFmiKveajOrNKeczTdbKv5Qy5JGRlJQcn5r011Mnt10h217zbZ01GgCzNr8eTAkPX8QhyQFnIkSJAg7rR8i2DMTpsNlWB3fWjXUMtt8H00RCHPwsk/1I5KTL0gbI66HNZNCj9moEGwl4G5jANaS9ISGTvIbRXmm4w2UfyY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-544455a4b56so4568198a12.1 for ; Sat, 18 Nov 2023 21:41:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372497; x=1700977297; 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=z1u1EolHyezT3Rj/p1S6KCWedsg36rnuPa2xYDe7iDw=; b=YzuesD6dbOBkRGRQEv8WpHg288uG5ogFlQMgtfly+huQH04gujHIc6X5sY32IDIfwp gMyMxCham3xX/Kv7ulrDPFAf66PLa2LbdjqFCq2T72GTcbN982qoLWdzhWTlLcTCoKie 3paqPjJ0L2GGYMlXdxCYAkhPv7xENYKiV1JeBwmuGYJ/AO1hrjRBCwfYbaGLjSzbWWHd 1dFi6/Qmp5sMs+Cl6Sz+h8GCDgRxB08NbRtxWzDe/tvDqWWEm9cd5B7WO9lMxUVNk9e2 Mw0QqlTBZXEKp50jmK8lPdL2vKyM8epzHKrz0j3vOyQQdad+2T2JXJldU9ovMXhL3wwq GvhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372497; x=1700977297; 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=z1u1EolHyezT3Rj/p1S6KCWedsg36rnuPa2xYDe7iDw=; b=cT7IX+wdVRY9VhO5qbnqjdbZeiZjgsTlyiI8rZrT2dOc/XxvlKf3Snk+d41Go6gY3s 2b/Y0yNKDEKmEIDnah8WwVnp2Griw6/feZgToRFTY0GUowyYMStEECAD5WxcY1YkdTrM OT10ycHp8/Sob7pGcuW5PuxCe3yThCRGKTuODGiyRW3vMRYzRDyL6pfGAgOvhf2ehdRM cinq0r52wDe746NHzqIgVk/qLccxqUgnntew9vb0IVzhYR1w2as1k/ZtJ8Q1VUsXLSo0 mr3VrNyf2cQrx5Fd3HgfT2fAd+6vNhacdoJDS1XupSmHF2gMJQrN/Ed4ajVqGqfejuAT IMBA== X-Gm-Message-State: AOJu0YzGlqWXTspWAIVzxTdorjLk/Tp/A5364zG3KNe8YAoXAXZmoNFB Hh2R2S26TkDZ5RMlISRvIjxUUKrVDdIfpwVkMcankg== X-Received: by 2002:a05:6402:2044:b0:532:bc4d:9076 with SMTP id bc4-20020a056402204400b00532bc4d9076mr2767094edb.19.1700372496991; Sat, 18 Nov 2023 21:41:36 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id s13-20020a056402014d00b00548a185fe5esm295718edu.24.2023.11.18.21.41.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:41:36 -0800 (PST) Date: Sun, 19 Nov 2023 05:41:33 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 30/44] RISC-V/testsuite: Add branched 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.9 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: 1782969821775204988 X-GMAIL-MSGID: 1782969821775204988 Verify, for generic integer conditional-add operations, if-conversion *not* to trigger at the respective sufficiently low `-mbranch-cost=' settings that make original branched code sequences cheaper than their branchless equivalents if-conversion would emit. Cover all integer relational operations to make sure no corner case escapes. gcc/testsuite/ * gcc.target/riscv/adddibeq.c: New test. * gcc.target/riscv/adddibge.c: New test. * gcc.target/riscv/adddibgeu.c: New test. * gcc.target/riscv/adddibgt.c: New test. * gcc.target/riscv/adddibgtu.c: New test. * gcc.target/riscv/adddible.c: New test. * gcc.target/riscv/adddibleu.c: New test. * gcc.target/riscv/adddiblt.c: New test. * gcc.target/riscv/adddibltu.c: New test. * gcc.target/riscv/adddibne.c: New test. * gcc.target/riscv/addsibeq.c: New test. * gcc.target/riscv/addsibge.c: New test. * gcc.target/riscv/addsibgeu.c: New test. * gcc.target/riscv/addsibgt.c: New test. * gcc.target/riscv/addsibgtu.c: New test. * gcc.target/riscv/addsible.c: New test. * gcc.target/riscv/addsibleu.c: New test. * gcc.target/riscv/addsiblt.c: New test. * gcc.target/riscv/addsibltu.c: New test. * gcc.target/riscv/addsibne.c: New test. --- gcc/testsuite/gcc.target/riscv/adddibeq.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddibge.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddibgeu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddibgt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddibgtu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddible.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddibleu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddiblt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddibltu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddibne.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibeq.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibge.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibgeu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibgt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibgtu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsible.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibleu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsiblt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibltu.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibne.c | 28 ++++++++++++++++++++++++++++ 20 files changed, 524 insertions(+) gcc-riscv-test-addcc-branch-generic.diff Index: gcc/gcc/testsuite/gcc.target/riscv/adddibeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibeq.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 +adddieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y + z : y; +} + +/* Expect branched assembly like: + + bne a0,a1,.L2 + add a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddibge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibge.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 +adddige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +/* Expect branched assembly like: + + blt a0,a1,.L2 + add a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddibgeu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibgeu.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 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 branched assembly like: + + bltu a0,a1,.L2 + add a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddibgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibgt.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 +adddigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +/* Expect branched assembly like: + + ble a0,a1,.L2 + add a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddibgtu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibgtu.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 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 branched assembly like: + + bleu a0,a1,.L2 + add a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddible.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddible.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 +adddile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +/* Expect branched assembly like: + + bgt a0,a1,.L2 + add a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddibleu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibleu.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 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 branched assembly like: + + bgtu a0,a1,.L2 + add a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddiblt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddiblt.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 +adddilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +/* Expect branched assembly like: + + bge a0,a1,.L2 + add a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddibltu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibltu.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 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 branched assembly like: + + bgeu a0,a1,.L2 + add a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/adddibne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibne.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=3 -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 branched assembly like: + + beq a0,a1,.L3 + add a0,a2,a3 + ret +.L3: + mv a0,a2 + ret + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\ssub\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsibeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibeq.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 +addsieq (int_t w, int_t x, int_t y, int_t z) +{ + return w == x ? y + z : y; +} + +/* Expect branched assembly like: + + bne a0,a1,.L2 + addw a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sub|subw)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsibge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibge.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 +addsige (int_t w, int_t x, int_t y, int_t z) +{ + return w >= x ? y + z : y; +} + +/* Expect branched assembly like: + + blt a0,a1,.L2 + add[w] a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsibgeu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibgeu.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 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 branched assembly like: + + bltu a0,a1,.L2 + add[w] a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsibgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibgt.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 +addsigt (int_t w, int_t x, int_t y, int_t z) +{ + return w > x ? y + z : y; +} + +/* Expect branched assembly like: + + ble a0,a1,.L2 + add[w] a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsibgtu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibgtu.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 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 branched assembly like: + + bleu a0,a1,.L2 + add[w] a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsible.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsible.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 +addsile (int_t w, int_t x, int_t y, int_t z) +{ + return w <= x ? y + z : y; +} + +/* Expect branched assembly like: + + bgt a0,a1,.L2 + add[w] a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsibleu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibleu.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 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 branched assembly like: + + bgtu a0,a1,.L2 + add[w] a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsiblt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsiblt.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 +addsilt (int_t w, int_t x, int_t y, int_t z) +{ + return w < x ? y + z : y; +} + +/* Expect branched assembly like: + + bge a0,a1,.L2 + add[w] a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bge|bgt|ble|blt)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgt|slt)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsibltu.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibltu.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 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 branched assembly like: + + bgeu a0,a1,.L2 + add[w] a2,a2,a3 +.L2: + mv a0,a2 + */ + +/* { 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 "\\s(?:bgeu|bgtu|bleu|bltu)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sgtu|sltu)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/addsibne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibne.c @@ -0,0 +1,28 @@ +/* { 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 +addsine (int_t w, int_t x, int_t y, int_t z) +{ + return w != x ? y + z : y; +} + +/* Expect branched assembly like: + + beq a0,a1,.L3 + add[w] a0,a2,a3 + ret +.L3: + mv a0,a2 + ret + */ + +/* { 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 "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:sub|subw)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ 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 } } } */ From patchwork Sun Nov 19 05:42:01 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: 166706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506507vqn; Sat, 18 Nov 2023 21:43:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEa0mTx79Y1A91ixBXsb31ONfR2tIWu5oZkpyoPLUUy+W+GOZ3FQvGTYIQDSHvKlPHSUfXI X-Received: by 2002:a05:620a:1113:b0:775:73f6:1b39 with SMTP id o19-20020a05620a111300b0077573f61b39mr3774581qkk.25.1700372616008; Sat, 18 Nov 2023 21:43:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372615; cv=pass; d=google.com; s=arc-20160816; b=SbhVtmrSXyJqMegx9PnxuF4I6YjR/G2VvSdv27HogN0mirfHwQLZIB4zfaoFCxgPCE tWoUjTt9ihWXghLwgsF9BN40fCGRYse3iwwcbkDy4xJWh8k4jm3aiHdp8/W5ZAcuL1Sp UCfND7519npS+NcR6HehBEN9HiQppH+pinDNoa7NAdWQGj46epieetjMD/GkaN/p+Mmw VSDwe7v2HXEVRs6jJYge/xpcf3lx08VmusqZDb6ucAuQvpMSzNzDeQBBW4rs6fagRnEv y4FvxivuLQ6LzB2iQgB7czvL7fDxb8ZCdFV2mUBZ4UBe4Bguf7/K3Ti3d+t/ccFcF4xr 0v/A== 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=IHiDSe6k13+UCxLMdZ2AUiFd5tNFwlo8zmS6YX7mjFg=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=DPZ6FmC2Nich/Jq5bM7Lq/9tJ6NvK9NxJS6PLVxRaiUiF7uMKC9cEqHGFakK9kzOmv KUrwdadZDxkKcFiW+9/zJl6AOb1+pTe4oFqCAEckVgtdrmDumEbCzk1KH2vrP7nZdA5b Tyu7F9s81d1zCXq5Vciz8B/o95xjiaiF7jY/C1kvM6dZQFPh+wp1iXDdCm/Q0S8V3fhI e2vu7yjzGjajXY14tW0sWKpftsXDWElhDkrvC1v/m4aDHohHroHVvreJiBA0fuQaw6p/ /C9664k2YzCdahoawxISfCx8KyHhA3TwvjjtGzQbJ4TN7c1NoSieZ+MfAExCuz4OcmaY EFnQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=cI15e8ow; 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 bj7-20020a05620a190700b00774184acfeesi5018591qkb.297.2023.11.18.21.43.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:43:35 -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=cI15e8ow; 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 8B568385C33F for ; Sun, 19 Nov 2023 05:43:26 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 0298F3858D37 for ; Sun, 19 Nov 2023 05:42:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0298F3858D37 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 0298F3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::533 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372527; cv=none; b=DogebzXnXS3b/CzbVBkzfRa6RDp67djeYZIffNW4kmq1QSjGG8amQWZIE5AE3oy/fNGEeomSpMM18D64y+n+GbGOYykGC2Vv3Ms3B35eRkv7faoqVjAMks27uq/RSTmr277T3LJwSYNt5uPsaHG+YPnNn3JSG7scg/vgzY+L1AM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372527; c=relaxed/simple; bh=TVcG3RrVfixIqzsRW/TQoCyzXOC4oT5U7gRnW4leEZo=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Qhiz8rOa+mBmGvBqzOZJLOeb6jJ926EDKTu7AiyGiwCsJu1VGnfwb7TQE1/iPX0GVW19H0Tkmys4pgoKAy/FSeMIHd8XnwYY1GRPmCxYYhxBsJeHMc/R9IZozmUFdkeqpjpuCN8sriHvNrplMoQHS36UuP3U4OR3ewcHM8ffwfY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5437d60fb7aso4828351a12.3 for ; Sat, 18 Nov 2023 21:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372524; x=1700977324; 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=IHiDSe6k13+UCxLMdZ2AUiFd5tNFwlo8zmS6YX7mjFg=; b=cI15e8owzuXPsq0c9pddEGe0+vKqkz8MTi+UECJZBqMYG2FuTgNifMDSX63/uDaNii BCGzzmfKYZMtI1J2e17b3jBanL0mgdxGLNsxo6jTtmXueaGyv8JP46ntXWKievT5FddC sAjVs1FUXhc+x9EdeDu/1HlJul0kJscyYn0FomtQ5TgGQJXV16V8CjgzUOiinYtnO8UA QJx6Mvx0B2v3XA3xOC00+03amoCHjPAxsEoEYbhO71NXcYQntL851COVaQG1dnM+C5wt XGczsaEFgJ3rhiCylbhHlVOFN58L/nuEY2k5GQVwSMvUxwxCdktgW4mbD78r8/yMtd1K iCnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372524; x=1700977324; 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=IHiDSe6k13+UCxLMdZ2AUiFd5tNFwlo8zmS6YX7mjFg=; b=Cx33Z98XB9SOsOaM2g49uFouXTeN48Tigtyw6GUJ9pT3EwvfCp5UObGOy64OFWsen+ 3yiQ3xAAlPc/B/S2WzwUPHKP28iXiePXqW8wvv+uSZ+2q8fkXw2FnHEvYki4IeL/PC5v w5wsP9g7twr97SnsbKLgn6ZB+T6PH3kbO20vCcQEs1OFlyN5gOf46Uxyih2cPJsjvNXr McMHJNkPS5nppt8xanADcrHjZ9dyB9/UrF+hXTr5AA8CB4urzaZV7U99oj8UCREBUtHL 1tYjAfaLJa2pZ/IPRWIBtjPlYVrFO6bL6jGdfuilDKBUrzpVuZhLHDhCM4KQRNgjQ1/o ANrQ== X-Gm-Message-State: AOJu0YxyC5sssAwiKlmP/cPmy3fFM9CwlscDlTfXZf8jh55XunEh7rKG 05A0zFxTSszzHsz4guHGLhnBX7xnAhpoYaPZ5EAFhQ== X-Received: by 2002:a17:906:738d:b0:9c7:5186:de1a with SMTP id f13-20020a170906738d00b009c75186de1amr3163869ejl.8.1700372523871; Sat, 18 Nov 2023 21:42:03 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id c5-20020a170906694500b009e6624afecbsm2545629ejs.63.2023.11.18.21.42.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:42:03 -0800 (PST) Date: Sun, 19 Nov 2023 05:42:01 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 32/44] RISC-V: Only use SUBREG if applicable in `riscv_expand_float_scc' 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.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969916190529304 X-GMAIL-MSGID: 1782969916190529304 A subsequent change to enable the processing of conditional moves on a floating-point condition by `riscv_expand_conditional_move' will cause `riscv_expand_float_scc' to be called for word-mode target RTX with RV64 targets. In that case an invalid insn such as: (insn 25 24 0 (set (reg:DI 141) (subreg:SI (reg:DI 143) 0)) -1 (nil)) would be produced, which would crash the compiler later on. Since the output operand of the SET operation to be produced already has the same mode as the input operand does, just omit the use of SUBREG and assign directly. gcc/ * config/riscv/riscv.cc (riscv_expand_float_scc): Suppress the use of SUBREG if the conditional-set target is word-mode. --- gcc/config/riscv/riscv.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) gcc-riscv-expand-float-scc-subreg.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -4071,7 +4071,9 @@ riscv_expand_float_scc (rtx target, enum riscv_emit_float_compare (&code, &op0, &op1); rtx cmp = riscv_force_binary (word_mode, code, op0, op1); - riscv_emit_set (target, lowpart_subreg (SImode, cmp, word_mode)); + if (GET_MODE (target) != word_mode) + cmp = lowpart_subreg (GET_MODE (target), cmp, word_mode); + riscv_emit_set (target, cmp); } /* Jump to LABEL if (CODE OP0 OP1) holds. */ From patchwork Sun Nov 19 05:42:13 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: 166703 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506271vqn; Sat, 18 Nov 2023 21:42:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGIJEBfB3wYgW/bI1O1jCjbITrwWE8lonjELAelO/W8YbIqy60+I3p3WWi4d0CjLyk+jrgK X-Received: by 2002:ad4:5bcc:0:b0:676:3b5a:4d81 with SMTP id t12-20020ad45bcc000000b006763b5a4d81mr4226514qvt.23.1700372563723; Sat, 18 Nov 2023 21:42:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372563; cv=pass; d=google.com; s=arc-20160816; b=d3kD41u7minqoQkvqlVwXDqlmxvv/1mi17T5BJ0FsvLFxOG54tJX5bXDMLt29r1SrG pturje+uHw9tLccaiMEQ7akGNIKvXPyvJupMNAF17fGvvvZKhKR3+7tlKGXl0PSJpCnx dlx/zKswj8pt1YIKT6C23vb5oqNtYQzkSCu58PMb/RPv9ElGgnyhaWW+T8zScprXt5rv yHy0F41gaj8RRyw2+wwJjt3Jof5FgyziBv6tkLar2j+nfOxaTUmJ9/d5KMCtwS6CgosV KvQwKS5zSGtlffa4ZvQNtE74CnIAz+5HRKwSIzI4SLZWKNM6SR1hc/jAGWoh2samVg03 qkSQ== 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=C3UwKJkUEpp5yGdGyQXasV6+qCwwP6V4FEWcQO9m2bA=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=JM7bHknemI0BgYQIkykIWOEXoCDNxX3nKeW/Su2OEPuSYBqZUmYcp73afBd0ZolfUX l1G+tCrwbcMckpbFIyaH5X2WZXwskVFaQ3SU29owVJyS2nJvRgIMUONvxTZnl2+ZRCbs zFov6PumGrY1wI7JkVUUd1N2ZlprQr3akTgVV+zhBPiwCWJFHZ0uyxaKGdS2Bg5JJNyb RL1f5orq/tRo3k72gpreEBzVVLrogCdyqN5OADIcznPyPsSBpieRTUZOXCEQrTlmBvPE 2qJGNLinOpzO0OOHmtXTx++T3ho9+B0qfg16zlpNaixR/F0se7JWsZduJH0LPQrlkWJg UggA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b="Ror//xOd"; 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 l14-20020ad4444e000000b0066d0a15a2ffsi4888423qvt.322.2023.11.18.21.42.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:42:43 -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="Ror//xOd"; 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 D63CD3857833 for ; Sun, 19 Nov 2023 05:42:39 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id 99A7838582AC for ; Sun, 19 Nov 2023 05:42:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 99A7838582AC 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 99A7838582AC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::631 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372538; cv=none; b=I02z3Y4RxVyW2/+xO2kpzrhp4honGxnjq0SRLOAQUR0lTuRKsNMY5WR+H+8qRn19kutYi4bqEQ9KCWW1e0uzqRcKTr/qhkaQlcOHhlN7e4Ad2CG/tYz/6KmWBiZtESA/oiNqWR3RyvssH/E2YXZmG7NFipFj7MKLejWt51MHzOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372538; c=relaxed/simple; bh=0oeAcOqmZ1DV2kcVPHOg0SvA13KaFlu7BpqcuMkGiYA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=NUcx9Rifjsx5cSbTkGRdbKiuR0QSBWPb8c+oI/5N56FgcGImLZekPLcJYMy+jJ1x0ftIhIWVc4YD/uRgtuVLaEWbCMyLPCZSfsNLwhtIP2zVSHlJpIb98D9r2eQKybnvZpbh0qG2QXMpSgE8x1Nvpxfq0s6/ckFFwh/l6kpY5mo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-9db6cf8309cso435863966b.0 for ; Sat, 18 Nov 2023 21:42:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372535; x=1700977335; 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=C3UwKJkUEpp5yGdGyQXasV6+qCwwP6V4FEWcQO9m2bA=; b=Ror//xOdnWABmtUqTF3uH4WWl/5CezpAgw8+JHTWqqt5WZiJ4MN+iJm/fl28zWaMyp Yz+R+LtjiS4CSOqRUhziSxrRJI/Q59VrAR8vVbZ2azyyV01iRdogmvEjZuj7iGfXZn2F LNn90xOE5KW5sFO12lfGUDjTM7sYFaf/P77I/9EK1mDQmlnVM62mgacw6nTBhUsU6CUF mQhzj70d4hTu+ZPWqLZyGVBtblrNxZM0I/VF+5w1nfrlGaaSsVH6xf41iBcKrPi6ZqB4 IU/xW5rhyKwdKIM7velSTnmQdMBzVd5eq9L/2v6ep2DSDoLCrdR78PtwhAllWmWFGErw fQgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372535; x=1700977335; 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=C3UwKJkUEpp5yGdGyQXasV6+qCwwP6V4FEWcQO9m2bA=; b=cDJwKvJWL7EB4JogG9aWXc1sT4mDf5NjVL0GHpkhMZ1YzGk8Ag3uZzDcmmc62kAAnr ZT+00rzn6RF4oIXjujJt+VnqWmq+ehLe+3tPt7V03S+ccfwLb9MiUhxIvo1cs7oPRZ/B Y06csMVG091Cxahl5ZEMS1dz6Ao1iulkq1A9Xd36XZN/ozkZrcEIZSKIoLGAJDdhrPva KKOYx+ZGJS1fhKHCI/XewG3KLNarEmb9ZmpDLaztWMtfgn5knwS5atAZkaAwVY9cPren nae1fqrdNK4tPUNZL4P6SduG4xnkJqPxrTPynLpH3T1JRAK865LdfkJZynHybQV6YS+S 6bRw== X-Gm-Message-State: AOJu0Yx0c3VhgKNbs9VxsNg7Azt79399RcVGYf70DGkbHD88ix4SdKkC mdY45zwoyDccrEW4nEo4T7zpqgXTDYLIJJ5Q/sBOLg== X-Received: by 2002:a17:906:170c:b0:9a5:9f3c:9615 with SMTP id c12-20020a170906170c00b009a59f3c9615mr2926873eje.63.1700372535456; Sat, 18 Nov 2023 21:42:15 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id g15-20020a170906538f00b0099ce025f8ccsm2528674ejo.186.2023.11.18.21.42.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:42:15 -0800 (PST) Date: Sun, 19 Nov 2023 05:42:13 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 33/44] RISC-V: Also allow FP conditions in `riscv_expand_conditional_move' 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.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969861589643256 X-GMAIL-MSGID: 1782969861589643256 In `riscv_expand_conditional_move' we only let integer conditions through at the moment, even though code has already been prepared to handle floating-point conditions as well. Lift this restriction and only bail out if a non-word-mode integer condition has been requested, as we cannot handle this specific case owing to machine instruction set restriction. We already take care of the non-integer, non-floating-point case later on. gcc/ * config/riscv/riscv.cc (riscv_expand_conditional_move): Don't bail out in floating-point conditions. --- gcc/config/riscv/riscv.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) gcc-riscv-expand-conditional-move-fp.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -4109,12 +4109,12 @@ riscv_expand_conditional_move (rtx dest, machine_mode mode0 = GET_MODE (op0); machine_mode mode1 = GET_MODE (op1); - /* The comparison must be comparing WORD_MODE objects. We must - enforce that so that we don't strip away a sign_extension + /* An integer comparison must be comparing WORD_MODE objects. We + must enforce that so that we don't strip away a sign_extension thinking it is unnecessary. We might consider using riscv_extend_operands if they are not already properly extended. */ - if ((mode0 != word_mode && mode0 != VOIDmode) - || (mode1 != word_mode && mode1 != VOIDmode)) + if ((INTEGRAL_MODE_P (mode0) && mode0 != word_mode) + || (INTEGRAL_MODE_P (mode1) && mode1 != word_mode)) return false; /* In the fallback generic case use MODE rather than WORD_MODE for From patchwork Sun Nov 19 05:42:23 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: 166705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506399vqn; Sat, 18 Nov 2023 21:43:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEm2H4Xcxpw3TYtzsImP6Xo6Gu/j7KnJKkuMNm/bkSnMHek3pTdyExcFdR0zErllRJlS8L X-Received: by 2002:a37:e30b:0:b0:778:9156:3f07 with SMTP id y11-20020a37e30b000000b0077891563f07mr4482548qki.24.1700372588152; Sat, 18 Nov 2023 21:43:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372588; cv=pass; d=google.com; s=arc-20160816; b=e+PmcXtGKVr/vTjgFRs9RDYr4ngdFgJPhzKI2vWzbVJ6iBag8MFA3pG3QwD+xQGwk7 GN4Aj3558j2sstOeM1b8xAZ8ilHqc51jvC+ZgRgRivxDsfeRUcmf2iqkZKyBD4hD4ITK DhlEFGOeLCrUf0MpZ2iQZo2uXsQlK9lAVbUNaDNV+AHwe7A8UMnHYehDFyrzb7z8Q6a9 5Iqz6BdvOwotKvkWiDWJFE5ejtHgklE4a8wFaCdTXg//b8Wex5Q9NYJahJebyZ/+2iNk J4r/dbKG2CuqGQwPYRSvQRSyWQGo2hFerE+WSU4WRVyesLqW0NBnsRScC/hBAd7m2Xas T3WA== 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=WBlkH6jdvvIUNyy3q57kksjGPTtI7uD0BHfXKnKMgjE=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=TvvC6j/1xMKOsZDlEM2RogewlOmBqAGjUzxEZU6wn50hut+ZtqAhOKq82DIz24+egl fKogAA8/Wdo37M6Dn6aAqNh0osJFrgn89SSBu5DLta8Tab5cHdcMKu91GahF4VEKvoAS X5Fu6KC/1NoUxexvEGal5OrxHttPlLFnNgj7P1s4qS5VbPJXXtvqimJjIB9KVTt83a39 EY3ljyFusOTyj6Fpkkvn2FPUrFbvwbyVtfUgL5kwvZzLLGOUUzFa8ViKHwxPljdbHxuW 3ji0iIgtBF7rD5Dn7MovIWaVdCFxTzefu3hVUaHgYkjtpznK1zbQjVawyT5+EwTCKDBX /kzg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=UyWPyOfc; 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 u15-20020a05620a084f00b0077bd90edd73si4756194qku.766.2023.11.18.21.43.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:43:08 -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=UyWPyOfc; 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 E31E63858C2D for ; Sun, 19 Nov 2023 05:43:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 105C03857B87 for ; Sun, 19 Nov 2023 05:42:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 105C03857B87 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 105C03857B87 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372554; cv=none; b=lpliEJCr5iHmZ7PqchYVjQPh2FQNUS9dxl8XMSOHhE20UGGfGTetZ80nDbVR1gJCeAMLbJWQitf6pMeFBYG1Lvg/w5vq0DWuJoA+MRFVYpeC0ccXqh/x5prFgJEMGXyjyie6mMWtA1OWn5YZA0qq0SUZxTo3lORZtdjTiGU5dEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372554; c=relaxed/simple; bh=1Yg48cuUoxarAaY/U2LO0J6lBHZamp7AvEu9qQDU87I=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=iBywHBkryimhnT0M+XWKVuUyUMk7JFPZ10CbF4SQABjiqIQj97oyFZ/K4nHVK+WRexai11Z2YN41xH5Hdq32V4YA4ky7XQM+WICQLLfXuSidyckxDMeXomw1P2XBzZv+e3xA5vcjZlX+QVwcX/7U1Apz6ZZnFqhKjoz7nIOKyZU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5098e423ba2so4680612e87.2 for ; Sat, 18 Nov 2023 21:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372548; x=1700977348; 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=WBlkH6jdvvIUNyy3q57kksjGPTtI7uD0BHfXKnKMgjE=; b=UyWPyOfcHNReDYCKS4cBfUINzA+g6vMbBF2MW4xaC+nLneL+dnWvUJJcZn85Di8n7s FLJXqU2YKotI5o6zsBlAYeP0hgzF2fVO5gzZckESzTOA/7gK7uOjxiqrtQc3jFDSQCOA +t/y1uFoQ5JF0bT9GspVgoXEtrnyGYF4ms5PRChUOIet841IaZ2aXsA+wNoKrwfDDiw4 Q+FXblbJiywwl24aOfX+hwrUjGPq1j67JFeBc0qT5RfZGB9+7ycfa0WaXQfLw+CC7t6q bqGdM0srAPG+QOPABT8IOpvuu9IAeBp7l1smQzHifxVzKUHboq1mflTUVMB5b5Mi3pda czlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372548; x=1700977348; 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=WBlkH6jdvvIUNyy3q57kksjGPTtI7uD0BHfXKnKMgjE=; b=k2aV5auORsONuzazGm9T4nPS+fWpmNoqi+WBpJ1U8cCO6y53jP+rTA0kNVnfjhbpeQ tJbmdA4pKJzF2BRop15vJCTRR85TGDZ5UgDVQB1MaGZk8Tj08GuvM1Gl2eEewBEl7jSo VpZxFpYY7Twk65WiuRCxzyuf5zw7Xl1gqZTVyIVIjozBGnrl7CUNBwLc7Dzuozid9Bhx cT3P5qjeszhJqwPcDshyoN0/AG21J9Dw82nRfplX2E07EDVLmOxPfbFuzHxDfCWKnntu aR6tiWQiT1tMKrbg8JvN5qUiZKNpCKwbStcZ4yGVUgfAEDwWed8JpVBpggcjIfgS+YLU J/Xw== X-Gm-Message-State: AOJu0YyBrr7S5iYSez6aR/OgSn7oeJb9QnMyNdWP3BCZ1Qv45CtAAS8N itPyov6TQT4EuOb6HS6F6e0Ecvyf1V3c0OGlLWNmqg== X-Received: by 2002:ac2:4919:0:b0:509:7b72:318d with SMTP id n25-20020ac24919000000b005097b72318dmr2832990lfi.30.1700372548308; Sat, 18 Nov 2023 21:42:28 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id lv9-20020a170906bc8900b009fd4cb4aa61sm177295ejb.199.2023.11.18.21.42.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:42:27 -0800 (PST) Date: Sun, 19 Nov 2023 05:42:23 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 34/44] RISC-V: Provide FP conditional-branch instructions for if-conversion 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, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969887305296933 X-GMAIL-MSGID: 1782969887305296933 Do not expand floating-point conditional-branch RTL instructions right away that use a comparison operation that is either directly available as a machine conditional-set instruction or is NE, which can be emulated by EQ. This is so that if-conversion sees them in their original form and can produce fewer operations tried in a branchless code sequence compared to when such an instruction has been already converted to a sequence of a floating-point conditional-set RTL instruction followed by an integer conditional-branch RTL instruction. Split any floating-point conditional-branch RTL instructions still remaining after reload then. Adjust the testsuite accordingly: since the middle end uses the inverse condition internally, an inverse conditional-set instruction may make it to assembly output and also `cond_move_process_if_block' will be used by if-conversion rather than `noce_process_if_block', because the latter function not yet been updated to handle inverted conditions. gcc/ * config/riscv/predicates.md (ne_operator): New predicate. * config/riscv/riscv.cc (riscv_insn_cost): Handle branches on a floating-point condition. * config/riscv/riscv.md (@cbranch4): Rename expander to... (@cbranch4): ... this. Only expand the RTX via `riscv_expand_conditional_branch' for `!signed_order_operator' operators, otherwise let it through. (*cbranch4, *cbranch4): New insns and splitters. gcc/testsuite/ * gcc.target/riscv/movdifge-sfb.c: Reject "if-conversion succeeded through" rather than accepting it. * gcc.target/riscv/movdifge-thead.c: Likewise. * gcc.target/riscv/movdifge-ventana.c: Likewise. * gcc.target/riscv/movdifge-zicond.c: Likewise. * gcc.target/riscv/movdifgt-sfb.c: Likewise. * gcc.target/riscv/movdifgt-thead.c: Likewise. * gcc.target/riscv/movdifgt-ventana.c: Likewise. * gcc.target/riscv/movdifgt-zicond.c: Likewise. * gcc.target/riscv/movdifle-sfb.c: Likewise. * gcc.target/riscv/movdifle-thead.c: Likewise. * gcc.target/riscv/movdifle-ventana.c: Likewise. * gcc.target/riscv/movdifle-zicond.c: Likewise. * gcc.target/riscv/movdiflt-sfb.c: Likewise. * gcc.target/riscv/movdiflt-thead.c: Likewise. * gcc.target/riscv/movdiflt-ventana.c: Likewise. * gcc.target/riscv/movdiflt-zicond.c: Likewise. * gcc.target/riscv/movsifge-sfb.c: Likewise. * gcc.target/riscv/movsifge-thead.c: Likewise. * gcc.target/riscv/movsifge-ventana.c: Likewise. * gcc.target/riscv/movsifge-zicond.c: Likewise. * gcc.target/riscv/movsifgt-sfb.c: Likewise. * gcc.target/riscv/movsifgt-thead.c: Likewise. * gcc.target/riscv/movsifgt-ventana.c: Likewise. * gcc.target/riscv/movsifgt-zicond.c: Likewise. * gcc.target/riscv/movsifle-sfb.c: Likewise. * gcc.target/riscv/movsifle-thead.c: Likewise. * gcc.target/riscv/movsifle-ventana.c: Likewise. * gcc.target/riscv/movsifle-zicond.c: Likewise. * gcc.target/riscv/movsiflt-sfb.c: Likewise. * gcc.target/riscv/movsiflt-thead.c: Likewise. * gcc.target/riscv/movsiflt-ventana.c: Likewise. * gcc.target/riscv/movsiflt-zicond.c: Likewise. * gcc.target/riscv/smax-ieee.c: Also accept FLT.D. * gcc.target/riscv/smaxf-ieee.c: Also accept FLT.S. * gcc.target/riscv/smin-ieee.c: Also accept FGT.D. * gcc.target/riscv/sminf-ieee.c: Also accept FGT.S. --- gcc/config/riscv/predicates.md | 3 gcc/config/riscv/riscv.cc | 22 +++-- gcc/config/riscv/riscv.md | 89 +++++++++++++++++++--- gcc/testsuite/gcc.target/riscv/movdifge-sfb.c | 2 gcc/testsuite/gcc.target/riscv/movdifge-thead.c | 2 gcc/testsuite/gcc.target/riscv/movdifge-ventana.c | 2 gcc/testsuite/gcc.target/riscv/movdifge-zicond.c | 2 gcc/testsuite/gcc.target/riscv/movdifgt-sfb.c | 2 gcc/testsuite/gcc.target/riscv/movdifgt-thead.c | 2 gcc/testsuite/gcc.target/riscv/movdifgt-ventana.c | 2 gcc/testsuite/gcc.target/riscv/movdifgt-zicond.c | 2 gcc/testsuite/gcc.target/riscv/movdifle-sfb.c | 2 gcc/testsuite/gcc.target/riscv/movdifle-thead.c | 2 gcc/testsuite/gcc.target/riscv/movdifle-ventana.c | 2 gcc/testsuite/gcc.target/riscv/movdifle-zicond.c | 2 gcc/testsuite/gcc.target/riscv/movdiflt-sfb.c | 2 gcc/testsuite/gcc.target/riscv/movdiflt-thead.c | 2 gcc/testsuite/gcc.target/riscv/movdiflt-ventana.c | 2 gcc/testsuite/gcc.target/riscv/movdiflt-zicond.c | 2 gcc/testsuite/gcc.target/riscv/movsifge-sfb.c | 2 gcc/testsuite/gcc.target/riscv/movsifge-thead.c | 2 gcc/testsuite/gcc.target/riscv/movsifge-ventana.c | 2 gcc/testsuite/gcc.target/riscv/movsifge-zicond.c | 2 gcc/testsuite/gcc.target/riscv/movsifgt-sfb.c | 2 gcc/testsuite/gcc.target/riscv/movsifgt-thead.c | 2 gcc/testsuite/gcc.target/riscv/movsifgt-ventana.c | 2 gcc/testsuite/gcc.target/riscv/movsifgt-zicond.c | 2 gcc/testsuite/gcc.target/riscv/movsifle-sfb.c | 2 gcc/testsuite/gcc.target/riscv/movsifle-thead.c | 2 gcc/testsuite/gcc.target/riscv/movsifle-ventana.c | 2 gcc/testsuite/gcc.target/riscv/movsifle-zicond.c | 2 gcc/testsuite/gcc.target/riscv/movsiflt-sfb.c | 2 gcc/testsuite/gcc.target/riscv/movsiflt-thead.c | 2 gcc/testsuite/gcc.target/riscv/movsiflt-ventana.c | 2 gcc/testsuite/gcc.target/riscv/movsiflt-zicond.c | 2 gcc/testsuite/gcc.target/riscv/smax-ieee.c | 2 gcc/testsuite/gcc.target/riscv/smaxf-ieee.c | 2 gcc/testsuite/gcc.target/riscv/smin-ieee.c | 2 gcc/testsuite/gcc.target/riscv/sminf-ieee.c | 2 39 files changed, 134 insertions(+), 52 deletions(-) gcc-riscv-cbranch-split.diff Index: gcc/gcc/config/riscv/predicates.md =================================================================== --- gcc.orig/gcc/config/riscv/predicates.md +++ gcc/gcc/config/riscv/predicates.md @@ -333,6 +333,9 @@ (define_predicate "modular_operator" (match_code "plus,minus,mult,ashift")) +(define_predicate "ne_operator" + (match_code "ne")) + (define_predicate "equality_operator" (match_code "eq,ne")) Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -3308,7 +3308,9 @@ riscv_address_cost (rtx addr, machine_mo calculation for conditional branches: one unit is considered the cost of microarchitecture-dependent actual branch execution and therefore multiplied by BRANCH_COST and any remaining units are considered fixed - branch overhead. */ + branch overhead. Branches on a floating-point condition incur an extra + instruction cost as they will be split into an FCMP operation followed + by a branch on an integer condition. */ static int riscv_insn_cost (rtx_insn *insn, bool speed) @@ -3316,11 +3318,19 @@ riscv_insn_cost (rtx_insn *insn, bool sp rtx x = PATTERN (insn); int cost = pattern_cost (x, speed); - if (JUMP_P (insn) - && GET_CODE (x) == SET - && GET_CODE (SET_DEST (x)) == PC - && GET_CODE (SET_SRC (x)) == IF_THEN_ELSE) - cost += COSTS_N_INSNS (BRANCH_COST (speed, false) - 1); + if (JUMP_P (insn)) + { + if (GET_CODE (x) == PARALLEL) + x = XVECEXP (x, 0, 0); + if (GET_CODE (x) == SET + && GET_CODE (SET_DEST (x)) == PC + && GET_CODE (SET_SRC (x)) == IF_THEN_ELSE) + { + cost += COSTS_N_INSNS (BRANCH_COST (speed, false) - 1); + if (FLOAT_MODE_P (GET_MODE (XEXP (XEXP (SET_SRC (x), 0), 0)))) + cost += COSTS_N_INSNS (1); + } + } return cost; } Index: gcc/gcc/config/riscv/riscv.md =================================================================== --- gcc.orig/gcc/config/riscv/riscv.md +++ gcc/gcc/config/riscv/riscv.md @@ -2750,20 +2750,89 @@ DONE; }) -(define_expand "@cbranch4" - [(set (pc) - (if_then_else (match_operator 0 "fp_branch_comparison" - [(match_operand:ANYF 1 "register_operand") - (match_operand:ANYF 2 "register_operand")]) - (label_ref (match_operand 3 "")) - (pc)))] +(define_expand "@cbranch4" + [(parallel [(set (pc) + (if_then_else (match_operator 0 "fp_branch_comparison" + [(match_operand:ANYF 1 "register_operand") + (match_operand:ANYF 2 "register_operand")]) + (label_ref (match_operand 3 "")) + (pc))) + (clobber (match_operand 4 ""))])] "TARGET_HARD_FLOAT || TARGET_ZFINX" { - riscv_expand_conditional_branch (operands[3], GET_CODE (operands[0]), - operands[1], operands[2]); - DONE; + if (!signed_order_operator (operands[0], GET_MODE (operands[0]))) + { + riscv_expand_conditional_branch (operands[3], GET_CODE (operands[0]), + operands[1], operands[2]); + DONE; + } + operands[4] = gen_reg_rtx (TARGET_64BIT ? DImode : SImode); }) +(define_insn_and_split "*cbranch4" + [(set (pc) + (if_then_else (match_operator 1 "fp_native_comparison" + [(match_operand:ANYF 2 "register_operand" "f") + (match_operand:ANYF 3 "register_operand" "f")]) + (label_ref (match_operand 0 "")) + (pc))) + (clobber (match_operand:X 4 "register_operand" "=r"))] + "TARGET_HARD_FLOAT || TARGET_ZFINX" + "#" + "&& reload_completed" + [(set (match_dup 4) + (match_op_dup:X 1 [(match_dup 2) (match_dup 3)])) + (set (pc) + (if_then_else (ne:X (match_dup 4) (const_int 0)) + (label_ref (match_operand 0)) + (pc)))] + "" + [(set_attr "type" "branch") + (set (attr "length") + (if_then_else (and (le (minus (match_dup 0) (pc)) + (const_int 4084)) + (le (minus (pc) (match_dup 0)) + (const_int 4096))) + (const_int 8) + (if_then_else (and (le (minus (match_dup 0) (pc)) + (const_int 1048564)) + (le (minus (pc) (match_dup 0)) + (const_int 1048576))) + (const_int 12) + (const_int 16))))]) + +(define_insn_and_split "*cbranch4" + [(set (pc) + (if_then_else (match_operator 1 "ne_operator" + [(match_operand:ANYF 2 "register_operand" "f") + (match_operand:ANYF 3 "register_operand" "f")]) + (label_ref (match_operand 0 "")) + (pc))) + (clobber (match_operand:X 4 "register_operand" "=r"))] + "TARGET_HARD_FLOAT || TARGET_ZFINX" + "#" + "&& reload_completed" + [(set (match_dup 4) + (eq:X (match_dup 2) (match_dup 3))) + (set (pc) + (if_then_else (eq:X (match_dup 4) (const_int 0)) + (label_ref (match_operand 0)) + (pc)))] + "" + [(set_attr "type" "branch") + (set (attr "length") + (if_then_else (and (le (minus (match_dup 0) (pc)) + (const_int 4084)) + (le (minus (pc) (match_dup 0)) + (const_int 4096))) + (const_int 8) + (if_then_else (and (le (minus (match_dup 0) (pc)) + (const_int 1048564)) + (le (minus (pc) (match_dup 0)) + (const_int 1048576))) + (const_int 12) + (const_int 16))))]) + (define_insn_and_split "*branch_on_bit" [(set (pc) (if_then_else Index: gcc/gcc/testsuite/gcc.target/riscv/movdifge-sfb.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdifge-sfb.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdifge-sfb.c @@ -20,7 +20,7 @@ movdifge (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifge-thead.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdifge-thead.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdifge-thead.c @@ -18,7 +18,7 @@ movdifge (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifge-ventana.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdifge-ventana.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdifge-ventana.c @@ -20,7 +20,7 @@ movdifge (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskc\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskcn\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifge-zicond.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdifge-zicond.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdifge-zicond.c @@ -20,7 +20,7 @@ movdifge (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifgt-sfb.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdifgt-sfb.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdifgt-sfb.c @@ -20,7 +20,7 @@ movdifgt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifgt-thead.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdifgt-thead.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdifgt-thead.c @@ -18,7 +18,7 @@ movdifgt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifgt-ventana.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdifgt-ventana.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdifgt-ventana.c @@ -20,7 +20,7 @@ movdifgt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskc\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskcn\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifgt-zicond.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdifgt-zicond.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdifgt-zicond.c @@ -20,7 +20,7 @@ movdifgt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifle-sfb.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdifle-sfb.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdifle-sfb.c @@ -20,7 +20,7 @@ movdifle (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifle-thead.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdifle-thead.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdifle-thead.c @@ -18,7 +18,7 @@ movdifle (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifle-ventana.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdifle-ventana.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdifle-ventana.c @@ -20,7 +20,7 @@ movdifle (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskc\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskcn\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifle-zicond.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdifle-zicond.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdifle-zicond.c @@ -20,7 +20,7 @@ movdifle (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdiflt-sfb.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdiflt-sfb.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdiflt-sfb.c @@ -20,7 +20,7 @@ movdiflt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdiflt-thead.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdiflt-thead.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdiflt-thead.c @@ -18,7 +18,7 @@ movdiflt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdiflt-ventana.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdiflt-ventana.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdiflt-ventana.c @@ -20,7 +20,7 @@ movdiflt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskc\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskcn\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdiflt-zicond.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movdiflt-zicond.c +++ gcc/gcc/testsuite/gcc.target/riscv/movdiflt-zicond.c @@ -20,7 +20,7 @@ movdiflt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifge-sfb.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsifge-sfb.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsifge-sfb.c @@ -20,7 +20,7 @@ movsifge (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifge-thead.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsifge-thead.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsifge-thead.c @@ -18,7 +18,7 @@ movsifge (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifge-ventana.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsifge-ventana.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsifge-ventana.c @@ -20,7 +20,7 @@ movsifge (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskc\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskcn\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifge-zicond.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsifge-zicond.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsifge-zicond.c @@ -20,7 +20,7 @@ movsifge (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifgt-sfb.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsifgt-sfb.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsifgt-sfb.c @@ -20,7 +20,7 @@ movsifgt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifgt-thead.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsifgt-thead.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsifgt-thead.c @@ -18,7 +18,7 @@ movsifgt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifgt-ventana.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsifgt-ventana.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsifgt-ventana.c @@ -20,7 +20,7 @@ movsifgt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskc\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskcn\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifgt-zicond.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsifgt-zicond.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsifgt-zicond.c @@ -20,7 +20,7 @@ movsifgt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifle-sfb.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsifle-sfb.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsifle-sfb.c @@ -20,7 +20,7 @@ movsifle (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifle-thead.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsifle-thead.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsifle-thead.c @@ -18,7 +18,7 @@ movsifle (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifle-ventana.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsifle-ventana.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsifle-ventana.c @@ -20,7 +20,7 @@ movsifle (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskc\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskcn\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifle-zicond.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsifle-zicond.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsifle-zicond.c @@ -20,7 +20,7 @@ movsifle (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiflt-sfb.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsiflt-sfb.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsiflt-sfb.c @@ -20,7 +20,7 @@ movsiflt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiflt-thead.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsiflt-thead.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsiflt-thead.c @@ -18,7 +18,7 @@ movsiflt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ /* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiflt-ventana.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsiflt-ventana.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsiflt-ventana.c @@ -20,7 +20,7 @@ movsiflt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskc\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\svt\\.maskcn\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiflt-zicond.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/movsiflt-zicond.c +++ gcc/gcc/testsuite/gcc.target/riscv/movsiflt-zicond.c @@ -20,7 +20,7 @@ movsiflt (double w, double x, int_t y, i */ /* { 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-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ /* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 1 } } */ /* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 1 } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/smax-ieee.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/smax-ieee.c +++ gcc/gcc/testsuite/gcc.target/riscv/smax-ieee.c @@ -10,4 +10,4 @@ smax (double x, double y) /* { dg-final { scan-assembler-not "\t(call|tail)\tfmax\t" } } */ /* { dg-final { scan-assembler-not "\tfmax\\.d\t" } } */ -/* { dg-final { scan-assembler "\tfge\\.d\t" } } */ +/* { dg-final { scan-assembler "\t(fge\\.d|flt\\.d)\t" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/smaxf-ieee.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/smaxf-ieee.c +++ gcc/gcc/testsuite/gcc.target/riscv/smaxf-ieee.c @@ -10,4 +10,4 @@ smaxf (float x, float y) /* { dg-final { scan-assembler-not "\t(call|tail)\tfmaxf\t" } } */ /* { dg-final { scan-assembler-not "\tfmax\\.s\t" } } */ -/* { dg-final { scan-assembler "\tfge\\.s\t" } } */ +/* { dg-final { scan-assembler "\t(fge\\.s|flt\\.s)\t" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/smin-ieee.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/smin-ieee.c +++ gcc/gcc/testsuite/gcc.target/riscv/smin-ieee.c @@ -10,4 +10,4 @@ smin (double x, double y) /* { dg-final { scan-assembler-not "\t(call|tail)\tfmin\t" } } */ /* { dg-final { scan-assembler-not "\tfmin\\.d\t" } } */ -/* { dg-final { scan-assembler "\tfle\\.d\t" } } */ +/* { dg-final { scan-assembler "\t(fgt\\.d|fle\\.d)\t" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/sminf-ieee.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/riscv/sminf-ieee.c +++ gcc/gcc/testsuite/gcc.target/riscv/sminf-ieee.c @@ -10,4 +10,4 @@ sminf (float x, float y) /* { dg-final { scan-assembler-not "\t(call|tail)\tfminf\t" } } */ /* { dg-final { scan-assembler-not "\tfmin\\.s\t" } } */ -/* { dg-final { scan-assembler "\tfle\\.s\t" } } */ +/* { dg-final { scan-assembler "\t(fgt\\.s|fle\\.s)\t" } } */ From patchwork Sun Nov 19 05:42:37 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: 166708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506550vqn; Sat, 18 Nov 2023 21:43:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IH77Hvz98ny60tImQFR089K6nXpe9osSTij3b5FEsKNBTFtOkPMquRn8WHGtAf4L+xoZMpa X-Received: by 2002:a05:620a:5237:b0:76c:ea67:38e4 with SMTP id dc55-20020a05620a523700b0076cea6738e4mr5248938qkb.12.1700372632390; Sat, 18 Nov 2023 21:43:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372632; cv=pass; d=google.com; s=arc-20160816; b=ZESS7bQtoDivjGqFLP8ixCjOCDwfH9Lp20d+rVXaUMkCLdpuG863mGxZBajTQV/7vx 3BWH3AiVXzrmrFsm7MhFSkbnP7r8PPaGTyibRfSUSEePfreg696IMAEbGjMsrwPtDHFJ TIYgAFKiL2WlKvJEfX2F9T4CXHqBe6F5SyCU5Ttf0dmyeqqpIbJkSjRqNIwsFkt2FfPC g9gr8PXl4h88omY+vU59sE32OysPJRhqb8u8m8mqkJhWl5JIvfDz7dyeMf8NZlpYozFM KPqiNtxhjwBP5JxbfQAdUUn2bdGuT49lrP7dyXltlmINKdQRJg7M5dbRO24gyPGUsPza aMvg== 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=kX1Drrn7DLJVjSndEmo9/4eLYNECZJhrr3HKms+85mQ=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=VKVNq0duIqwy9m2hrURs+OKw+d94IY2BhlrHE3oyEDhDRPWRrEFlv+rW9HhPw37rsD Z3Ic0BD6YpqB264+znDN/SmgX2GxFSRL/ASxmZKH61sB9uxxcPd+nMdR1ZnejEbdyvks HiHEReyADqGw1l/1NWO5hpsHPbIqk2DOuvi+W6QlOtsbxqNCp8g5d5VboRrRv9Ku31uu wAXZcqHgcAJYvsiPpf0GuRNtEipnMenvIno5PuoD3r1GCFiLfkaEEdHUJIkmWmppDXaY Bhsqk7QRwagQFug72zHULqLkvyf4VZ6K05UPHC0Jll7EtaUoWW+enj8P3NTwy8VoxNoE xevw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=OlaStFNP; 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 oq8-20020a05620a610800b0076762f87d06si4570444qkn.784.2023.11.18.21.43.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:43:52 -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=OlaStFNP; 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 BC885385B53C for ; Sun, 19 Nov 2023 05:43:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id C54E83858432 for ; Sun, 19 Nov 2023 05:42:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C54E83858432 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 C54E83858432 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::529 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372563; cv=none; b=PMPgsm6/c7l5Tnxf+evWo7idCMsYICdsJ3DD/jjNDtXpP0XppdrZ2wWGMVi16/aISPEhAdXOrCEu2Tn7mC8t4X0yomAVqWcojIaRJka9588TOCpFnsTb8+NIsuHwbJHb4p2NOqBV4uBG3zNTzhx/LKk3M3xJvmO392wCvHeSsfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372563; c=relaxed/simple; bh=z/HiTSwamZ1rQFa5AwuZzHaaeos7X8n7jdUAZcaB6M4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=RvEHksG4B1768eC6tLcdLGOhXo8THYegQMfFXslq4csDDZZ1ohfkt/nn3mafmUzEiyIo317P9lkQZQU0Q6TiJaBjYhkZKWIIjDy5534lnBrJXYUf4hFYSNDBv5ymYn8D0+xCd6Set8pu2cdgL5rwAVlEaYxXyZ4YuU32SgW0QIc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-53e04b17132so4711391a12.0 for ; Sat, 18 Nov 2023 21:42:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372560; x=1700977360; 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=kX1Drrn7DLJVjSndEmo9/4eLYNECZJhrr3HKms+85mQ=; b=OlaStFNPyjY4xSTZsGhz0LJJOrFYzLOsQ68QlbLDd/ulg7qQtEUB0eMZ+aii2qKxwC bjeEx4455+08tCFOadtngUA0IHtAjDWM23c1O4J627rHqe2kaTUvhlv8sOfuro1hMxBg Z1723Rl5b94al7WKmNh0y9bsKzgE7hoIfuEzcWm+tshYGDsGuabax+NTACC4gERllRbE 3Acoz6u8daYOfSejCXJQ82lfi4HwFRp/08EIXCAgwJ39ma6n2IlrUCUKBDvRmqpdCoyV 3bC/hg+0DUOo02yw4WZbm0admSgO16zfkjz3syxnpSmUNw0+C0Ruf/GRgCeG6r1yB0vA 94sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372560; x=1700977360; 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=kX1Drrn7DLJVjSndEmo9/4eLYNECZJhrr3HKms+85mQ=; b=gkXyZw1gZB9jOh64XX/hBIe70CiZV91c911HiXVRmsQBbYT/zCC2HAFoIOu+o005dr auU/IpYgYNwSe/VmKB7du3h0o+eo0uz3N5wMONQB/Es6NOjGeM5bQi/opWYmUvw8eGXq xUTwta+rtBp4J/xV0g18jVpVsXbvOWs8F0R9ALw0oNnNpCOGXvQ2M8USF5fy3hu/zte1 5RqSdaOb7gk8sIFKEL4QuDnSmiWCrDcUUE1vKC8Lj5fWcic9N4tYlqQXpWEarhmYqqat 5mCqhbCXe5ni1nACnaQhKxwPRroJ6rGwXEYdVvUk1jeGYuW2lWWeqeYK22hdkmgDfiKc Y3Ww== X-Gm-Message-State: AOJu0Yz7ffT8leoa/lmTHQfp6ysqmgQ8whewyRQd0VCQpJz1H4QFVyFR tc/7OobfII8+oT1A/8TFef40wy9Ki/5WjS6ZDGzaZQ== X-Received: by 2002:a17:907:11c9:b0:9be:30c2:b8fd with SMTP id va9-20020a17090711c900b009be30c2b8fdmr2685606ejb.66.1700372560517; Sat, 18 Nov 2023 21:42:40 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id rs15-20020a170907036f00b009e62bb0439bsm2525676ejb.212.2023.11.18.21.42.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:42:40 -0800 (PST) Date: Sun, 19 Nov 2023 05:42:37 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 35/44] RISC-V: Avoid extraneous integer comparison for FP comparisons 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.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969933248908875 X-GMAIL-MSGID: 1782969933248908875 We have floating-point coditional-set machine instructions for a subset of FP comparisons, so avoid going through a comparison against constant zero in `riscv_expand_float_scc' where not necessary, preventing an extraneous RTL instruction from being produced that counts against the cost of the replacement branchless code sequence in if-conversion, e.g.: (insn 29 6 30 2 (set (reg:DI 142) (ge:DI (reg/v:DF 135 [ w ]) (reg/v:DF 136 [ x ]))) 297 {*cstoredfdi4} (nil)) (insn 30 29 31 2 (set (reg:DI 143) (ne:DI (reg:DI 142) (const_int 0 [0]))) 319 {*sne_zero_didi} (nil)) (insn 31 30 32 2 (set (reg:DI 141) (reg:DI 143)) 206 {*movdi_64bit} (nil)) (insn 32 31 33 2 (set (reg:DI 144) (neg:DI (reg:DI 141))) 15 {negdi2} (nil)) (insn 33 32 34 2 (set (reg:DI 145) (and:DI (reg:DI 144) (reg/v:DI 137 [ y ]))) 102 {*anddi3} (nil)) (insn 34 33 35 2 (set (reg:DI 146) (not:DI (reg:DI 144))) 111 {one_cmpldi2} (nil)) (insn 35 34 36 2 (set (reg:DI 147) (and:DI (reg:DI 146) (reg/v:DI 138 [ z ]))) 102 {*anddi3} (nil)) (insn 36 35 21 2 (set (reg/v:DI 138 [ z ]) (ior:DI (reg:DI 145) (reg:DI 147))) 105 {iordi3} (nil)) where the second insn effectively just copies its input. This now gets simplified to: (insn 29 6 30 2 (set (reg:DI 141) (ge:DI (reg/v:DF 135 [ w ]) (reg/v:DF 136 [ x ]))) 297 {*cstoredfdi4} (nil)) (insn 30 29 31 2 (set (reg:DI 142) (neg:DI (reg:DI 141))) 15 {negdi2} (nil)) (insn 31 30 32 2 (set (reg:DI 143) (and:DI (reg:DI 142) (reg/v:DI 137 [ y ]))) 102 {*anddi3} (nil)) (insn 32 31 33 2 (set (reg:DI 144) (not:DI (reg:DI 142))) 111 {one_cmpldi2} (nil)) (insn 33 32 34 2 (set (reg:DI 145) (and:DI (reg:DI 144) (reg/v:DI 138 [ z ]))) 102 {*anddi3} (nil)) (insn 34 33 21 2 (set (reg/v:DI 138 [ z ]) (ior:DI (reg:DI 143) (reg:DI 145))) 105 {iordi3} (nil)) lowering the cost of the code sequence produced (even though combine would swallow the second insn anyway). We still need to produce a comparison against constant zero where the instruction following a floating-point coditional-set operation is a branch, so add canonicalization to `riscv_expand_conditional_branch' instead. gcc/ * config/riscv/riscv.cc (riscv_emit_float_compare) : Handle separately. : Return operands supplied as is. (riscv_emit_binary): Call `riscv_emit_binary' directly rather than going through a temporary register for word-mode targets. (riscv_expand_conditional_branch): Canonicalize the comparison if not against constant zero. --- gcc/config/riscv/riscv.cc | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) gcc-riscv-emit-float-compare-fcmp.diff Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -4029,9 +4029,10 @@ riscv_emit_float_compare (enum rtx_code #undef UNORDERED_COMPARISON case NE: - fp_code = EQ; *code = EQ; - /* Fall through. */ + *op0 = riscv_force_binary (word_mode, EQ, cmp_op0, cmp_op1); + *op1 = const0_rtx; + break; case EQ: case LE: @@ -4039,8 +4040,9 @@ riscv_emit_float_compare (enum rtx_code case GE: case GT: /* We have instructions for these cases. */ - *op0 = riscv_force_binary (word_mode, fp_code, cmp_op0, cmp_op1); - *op1 = const0_rtx; + *code = fp_code; + *op0 = cmp_op0; + *op1 = cmp_op1; break; case LTGT: @@ -4080,10 +4082,14 @@ riscv_expand_float_scc (rtx target, enum { riscv_emit_float_compare (&code, &op0, &op1); - rtx cmp = riscv_force_binary (word_mode, code, op0, op1); - if (GET_MODE (target) != word_mode) - cmp = lowpart_subreg (GET_MODE (target), cmp, word_mode); - riscv_emit_set (target, cmp); + machine_mode mode = GET_MODE (target); + if (mode != word_mode) + { + rtx cmp = riscv_force_binary (word_mode, code, op0, op1); + riscv_emit_set (target, lowpart_subreg (mode, cmp, word_mode)); + } + else + riscv_emit_binary (code, target, op0, op1); } /* Jump to LABEL if (CODE OP0 OP1) holds. */ @@ -4096,6 +4102,13 @@ riscv_expand_conditional_branch (rtx lab else riscv_emit_int_compare (&code, &op0, &op1); + if (FLOAT_MODE_P (GET_MODE (op0))) + { + op0 = riscv_force_binary (word_mode, code, op0, op1); + op1 = const0_rtx; + code = NE; + } + rtx condition = gen_rtx_fmt_ee (code, VOIDmode, op0, op1); emit_jump_insn (gen_condjump (condition, label)); } From patchwork Sun Nov 19 05:42:48 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: 166710 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506640vqn; Sat, 18 Nov 2023 21:44:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEiosDNlJHtBupqBzyXwcV7YIKt0cJQ+jA+k9psD4BrNvNxIPi/SkXRxj8jlwVlAbU7t61Q X-Received: by 2002:a05:620a:4011:b0:775:aaf7:903f with SMTP id h17-20020a05620a401100b00775aaf7903fmr4258142qko.67.1700372659192; Sat, 18 Nov 2023 21:44:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372659; cv=pass; d=google.com; s=arc-20160816; b=vsnv+TjYhv+yQ0kGENa4NZtYkzFKNIOvZ0liaRghsm6OLkNu145OEqSegUtcHg3vU6 x4bfE4rcsCG6AH7EnOPAgEMPtIaVoDBdd6y2aopYbQQv6KsYCJvqg4ZDlQI8Z5uMpZ5j roTWzMxLclXuEtb/0oXubTRa1LznkcBwjYsX5UTHLheqWXaWyeMhFCJlXZjG62YD+31e fsORRlRENlEM1Xn31mrPenSrcaFFxHvA5o7+bS9Nf0fHRpo8v52yz0u27doGI6C+ylre Rsun+Hgm43fSBMvF1H1nTuA1bFYt/fnLxQP8ixfOL3dNwsBrROanlsiI/34M58QpMvo4 MqdQ== 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=9l55n7xXwAAmZ1myNky/Jdlmd/FjOKbfSYZxJxaN8z4=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=bPTeJtcpN/wjLjFTaRoqSe+5olVSmxhu6XwRQfrHFcxTF4MWHp+uUmkX1Ld6NjI1BU IfywLhP1/rd+SdupIx+pi96yV/EQu5gLEkGJ9GFEFNbyY1TTgYvZ22Hq8y6DLFPbdkm8 eZBP3My+ayWb4urKUuJ42of2QKt/mP48KxS5agy7nto315oNJfmAu7lHbMk3LGt42BSU HydL4Gt+zBs4Phwr1wUpVaMKQpIxK9Xzi550EXHMTzuMMLyInjLDwGa7bWcTfQ5O3FUT rAwMqPTFY5esgHgMKup4N+XwcWI3z7d3AhQWvKRHTw5NjtplZhwu1fMeH50aVhf8X3g9 ZsLw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=aGBS9Hzm; 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 h8-20020a05620a400800b00779db6b77dcsi5050102qko.353.2023.11.18.21.44.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:44:19 -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=aGBS9Hzm; 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 5B10C3861874 for ; Sun, 19 Nov 2023 05:43:58 +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 9AEDF385782A for ; Sun, 19 Nov 2023 05:42:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9AEDF385782A 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 9AEDF385782A 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=1700372575; cv=none; b=knK9Yid0uXDhUYRI3dDwcSUhFt1wHCRxUZeh7sA9rl33bu90kmX4vtTW1NnbsUbENBpLxIeBv05gQO4O6Si9L+kJgag2w2w4h5g/EIQDS1fTp1MqEzBb6Eru0txy7GQKJjQBefTUUptUb+AuYU+Q4EPNUbv9J8fD+l4Bsfka1k8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372575; c=relaxed/simple; bh=qv7NM368is88aXF4NNWbjjAW9uXSL+JHfAsEb8D+U2Y=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=TUNJe6tUkLe7C9hfv2sF9J9/dJVh2qeR/5nkasLoeWVMD9eei3O3ZFWgo+IwtvoDaWpucLw0Oc4jP3LoKgLjRiz0qrAez9HwzmYbAg4ZpofNu7m++L8H+E25dpJTa+rPJxvMcTYhY2gvCKijDHTU/Iskn35yyW97pLuNL7WW4g4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-9d242846194so451526366b.1 for ; Sat, 18 Nov 2023 21:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372571; x=1700977371; 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=9l55n7xXwAAmZ1myNky/Jdlmd/FjOKbfSYZxJxaN8z4=; b=aGBS9HzmIOqK6+eDxmdK4GHLP04ku2HiQutPytrcAIdOaWiVR2ROCrsClwkTVlU9gc 0QicFm1J9lJZzRqd0SknsGZe5Qr6mV9bJaOslTr3A+2oIXlZW9PovSb/n6ZjBJHkx4Mm JmKcEls9zPsp9Njv4nQWWlE0Dn8Alc/epiHhsRho0aQ9ZIcLovEhULN5kpRVIbPOu9TD uzM/UAPSoGYRGO7pTnxgYhDIzzJEqhK7Y6LSuXGfxGIXuxxC5eio7sgNj4U6m319Lc7t UxQWtZPMROTzIW1mNe3wjXFqmNhYqpjg0Ahb2smhZQbT5gG16tVvsBAaKII3JJn4vDV8 vvNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372571; x=1700977371; 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=9l55n7xXwAAmZ1myNky/Jdlmd/FjOKbfSYZxJxaN8z4=; b=WbmIA1cQmO8utXsIAj/Aa9iBXYxJp57lbyOmMBDNp6bmZ1YNViArIGWqHqrvdnKI1O B2UALEciGcYaEhlAVflrV2oE/l79yqpre4Z8WStQv5QFAx9kYdI9TsmfWdpXe2c+0g5f aqrO8PcVzar1D1J+V8cu7+1RDF/JGPhhiTNrqok85aZPTxC6lFq7SwQoADS+KNQeQpf6 9vQepHfuWDg5Wa3A1yyKMoIEULDxmz4/HMmoIUF7nS8GgFBYcdZIWupI6Y/+gfRHqDwW YTNEJeAxtuyRGOpD7qWJxtP6Bn9YD9Kr6a7AyVAjGxngeqC57s6ngusJuzYXq8me1aqj az9w== X-Gm-Message-State: AOJu0YxcqajCCEk3/ULGr0IQQToh39r0mzurpc+Ch4XQ8XcM2TTw0xES wcPJGRCVNWneKTxnsQ2V9jlcim/igYt8ud5uhjJYwA== X-Received: by 2002:a17:907:1ca1:b0:9d3:8d1e:ced with SMTP id nb33-20020a1709071ca100b009d38d1e0cedmr3618938ejc.34.1700372571325; Sat, 18 Nov 2023 21:42:51 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id lz2-20020a170906fb0200b0099d798a6bb5sm2564280ejb.67.2023.11.18.21.42.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:42:50 -0800 (PST) Date: Sun, 19 Nov 2023 05:42:48 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 36/44] RISC-V/testsuite: Add branched cases for generic FP cond moves 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: 1782969961463762973 X-GMAIL-MSGID: 1782969961463762973 Verify, for generic floating-point conditional-move operations that have a corresponding conditional-set machine instruction, that if-conversion does *not* trigger at `-mbranch-cost=4' setting, which makes original branched code sequences cheaper than their branchless equivalents if-conversion would emit. Cover all the relevant floating-point relational operations to make sure no corner case escapes. gcc/testsuite/ * gcc.target/riscv/movdibfge.c: New test. * gcc.target/riscv/movdibfgt.c: New test. * gcc.target/riscv/movdibfle.c: New test. * gcc.target/riscv/movdibflt.c: New test. * gcc.target/riscv/movdibfne.c: New test. * gcc.target/riscv/movsibfge.c: New test. * gcc.target/riscv/movsibfgt.c: New test. * gcc.target/riscv/movsibfle.c: New test. * gcc.target/riscv/movsibflt.c: New test. * gcc.target/riscv/movsibfne.c: New test. --- gcc/testsuite/gcc.target/riscv/movdibfge.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibfgt.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibfle.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibflt.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdibfne.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfge.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfgt.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfle.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibflt.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsibfne.c | 28 ++++++++++++++++++++++++++++ 10 files changed, 280 insertions(+) gcc-riscv-test-movccf-branch-generic.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdibfge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfge.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 +movdifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + fge.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 "\\s(?:fge\\.d|fle\\.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/movdibfgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfgt.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 +movdifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + fgt.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 "\\s(?:fgt\\.d|flt\\.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/movdibfle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfle.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 +movdifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + fle.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 "\\s(?:fge\\.d|fle\\.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/movdibflt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibflt.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 +movdiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + flt.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 "\\s(?:fgt\\.d|flt\\.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/movdibfne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdibfne.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 +movdifne (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 + bne 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/movsibfge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfge.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 +movsifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branched assembly like: + + fge.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 "\\s(?:fge\\.d|fle\\.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/movsibfgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfgt.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 +movsifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branched assembly like: + + fgt.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 "\\s(?:fgt\\.d|flt\\.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/movsibfle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfle.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 +movsifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branched assembly like: + + fle.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 "\\s(?:fge\\.d|fle\\.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/movsibflt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibflt.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 +movsiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branched assembly like: + + flt.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 "\\s(?:fgt\\.d|flt\\.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/movsibfne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsibfne.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 +movsifne (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 + bne 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" } } */ From patchwork Sun Nov 19 05:43:00 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: 166707 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506520vqn; Sat, 18 Nov 2023 21:43:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQg8nKNGe2ubZpLqi7w6qgEibAATaHiu0GeLtwfJSCu0rgHnSgqdm1KIkMSZA85SSUQpNr X-Received: by 2002:ac8:7d4c:0:b0:417:a645:982f with SMTP id h12-20020ac87d4c000000b00417a645982fmr5978830qtb.29.1700372621949; Sat, 18 Nov 2023 21:43:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372621; cv=pass; d=google.com; s=arc-20160816; b=BrwN0KhmCJCy8R00kkQm/tyq8joUUhtpNOcUab0EWsHh8YILoSQKK6MbVBUpXgbXG6 bs9V38GbzJ2tRqYSjfdMc6W7rfdKqzIwbAZ08gIi9LTOZVbDjSkK/583/zd7xF5h4Wpz QT/W/8hZnex5LzXtWKhEFxxIF3+yigd9v2QbwFsUibk+GfQtA0OGWM/NMrOFLLK/SpI4 oqUceZj5Q+dl+cSEczsTgIk7EHg5Q8sCKmOFJNIj0R6h7CZEQn1BT41vJb1ODUN3SWAZ tGKStW9yF68B/Y5HdXS8mJjP8OnqwzfFwsKdvbVFA9Tq3W5OS9tyG4aETOCClARhKRfa rcjQ== 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=AmgNErL555hhv7re1CYajmaXmasG54BeDOGCUN5GlDg=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=SJP36XGGcV5A86/NX48qWJ1I3Qq9eimpT2mK5XSJRNvaS3WcDMuP5AxRIymzwIB3DT KCIcRX3aMjoNZltrdDrzNT10ey+094DGnLfo/dR4KY6HGRNUJmeEOLBPV9V4pn8QKW6y FVgZ/NvCoK9kz4YOfbddQYq3/taOJKYGYqEK3Vju1XgujnLprZaHs8/l5/w33CmAQch8 U43qleG7Xa6qNFjzcuWIjEpYIJir43E4OboMFaNmGeWbv0+4kiY4jj3DeM3mgBqgX7vy DQJumAr/4KxBn9ZBALRF+9gJZmB+ez6K1uIWoAp4DPBo8iDDN8KXl+f67qXuLDDl10aD p/yg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=BJ7lwg8F; 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 o18-20020a05622a009200b00419578c5b2fsi5105210qtw.281.2023.11.18.21.43.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:43:41 -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=BJ7lwg8F; 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 1312B3857024 for ; Sun, 19 Nov 2023 05:43:31 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 49F2F3858425 for ; Sun, 19 Nov 2023 05:43:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49F2F3858425 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 49F2F3858425 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372586; cv=none; b=Pi3aZcui12QDbJZsMtInGiwKwftZbudC25RgKzru8BgzYZATv5zgYtgk/vIF8nr7adTEQe87puEzscF7tV/j+y5FpQEWUx1DkQU/5BNFUDIyZRkFsD+t5UAsd4c8ItnabSIskpiWVnzUnmeIjolyPRXET9ZzofE2ef+zS3IzJgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372586; c=relaxed/simple; bh=jOALj8mUkgm1/EN4SdDZUlTyaVNC9XVYIWH0sF8zzd0=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=b1s4mJb/5aJzo9/n/TflM3CeswTZKfJRhjMyaSz31mWWjv8L9IR2cyUtdA6fIJ13fVBZc71UA8GgsvDGqWqkFBAeCOtjL8Kg1CytzVxpza3w1ll/WxunkHAOlYF4X2Vq72Xo7kp1YGb7IHnSELEKyu4vr58csn79Z+Uyxsnssuk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-9fcfd2a069aso21154766b.1 for ; Sat, 18 Nov 2023 21:43:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372583; x=1700977383; 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=AmgNErL555hhv7re1CYajmaXmasG54BeDOGCUN5GlDg=; b=BJ7lwg8F3HGTqYqHfp0rS8gIv6Q73ms3R/UhEH4+ZMkP1m5xL5unW1L1qGXajMpcwj uS/Ope3RkfZSB//YWjfdCSV2YaAu39wZKku9As5Mu9KMbxOvziitcbbQrJr166m05sqX LG5NpAYbHv1JCTN5aymd9+CONdQCwlp535Ued3/a58sIGx/ZqxrHTZV4PNOUY2pxzqOf gHcdAqlx/eOWzaiVUZo5xE4H9pz1HiqujjIigRZpOWBwy47kgPTF3anYY220FabX1ozC TYJ/W4M4XTtucLoUh2BSb0B0mYdblvpekBfpdruJhdbh67EmH74ejE6EvQ+IaCa6Svsz cb9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372583; x=1700977383; 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=AmgNErL555hhv7re1CYajmaXmasG54BeDOGCUN5GlDg=; b=B7Hf4avaM66kCdUCbPIngWYPfVjV1Hh0TPwxz5UI/PwVcjXvHv6LDDFnyVaXmW5/Id u2WQV5Fk/7EJxhOAbZMN8MqLX51palqHWd00sqlfv5Gt50TuRavnje345Vw8qmVtmZPR JhQzKgt3EYT9WzWKZCnkIo3P7+dTBDcr3bUr3FklH8fUgmIWsJ5FNZQZ0ok4LW/ul8xF h+eccFVNqqW/kvEdo11gT2f8hfGbMw2PikxFAZ+BoDb2O3/UsU1S+8UVA3kEdwFYLMKG 5yjjJGeafP/GtaD54orOMuufLQhi5HyZQFyTbNAAhbufQy2OxcABK2kmOeuyHfBbmyNA HRZw== X-Gm-Message-State: AOJu0YyOxh78rWd+YzjgBoiFr13bffxatKIw0wVGNTO6/LKBQumaCUrM nfR+jivitJDsq0FtpCy1ySKZ22+6dwmHn9+VBqskzQ== X-Received: by 2002:a17:907:940d:b0:9da:b1f1:ef47 with SMTP id dk13-20020a170907940d00b009dab1f1ef47mr3819230ejc.30.1700372583095; Sat, 18 Nov 2023 21:43:03 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id q6-20020a1709066b0600b009dd701bb916sm2535652ejr.213.2023.11.18.21.43.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:43:02 -0800 (PST) Date: Sun, 19 Nov 2023 05:43:00 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 37/44] RISC-V/testsuite: Add branchless cases for generic FP cond moves 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.0 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: 1782969922680679284 X-GMAIL-MSGID: 1782969922680679284 Verify, for generic floating-point conditional-move operations that have a corresponding conditional-set machine instruction, that if-conversion triggers (via `cond_move_convert_if_block', which doesn't report) at `-mbranch-cost=5' 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. gcc/testsuite/ * gcc.target/riscv/movdifge.c: New test. * gcc.target/riscv/movdifgt.c: New test. * gcc.target/riscv/movdifle.c: New test. * gcc.target/riscv/movdiflt.c: New test. * gcc.target/riscv/movdifne.c: New test. * gcc.target/riscv/movsifge.c: New test. * gcc.target/riscv/movsifgt.c: New test. * gcc.target/riscv/movsifle.c: New test. * gcc.target/riscv/movsiflt.c: New test. * gcc.target/riscv/movsifne.c: New test. --- gcc/testsuite/gcc.target/riscv/movdifge.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifgt.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifle.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdiflt.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifne.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifge.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifgt.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifle.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsiflt.c | 28 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifne.c | 28 ++++++++++++++++++++++++++++ 10 files changed, 280 insertions(+) gcc-riscv-test-movccf-generic.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdifge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifge.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=5 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + fge.d a5,fa0,fa1 + neg a5,a5 + and a0,a5,a0 + not a5,a5 + and a5,a5,a1 + or a0,a0,a5 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifgt.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=5 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + fgt.d a5,fa0,fa1 + neg a5,a5 + and a0,a5,a0 + not a5,a5 + and a5,a5,a1 + or a0,a0,a5 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifle.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=5 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + fle.d a5,fa0,fa1 + neg a5,a5 + and a0,a5,a0 + not a5,a5 + and a5,a5,a1 + or a0,a0,a5 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdiflt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdiflt.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=5 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + flt.d a5,fa0,fa1 + neg a5,a5 + and a0,a5,a0 + not a5,a5 + and a5,a5,a1 + or a0,a0,a5 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifne.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=5 -mmovcc -fdump-rtl-ce1" } */ + +typedef int __attribute__ ((mode (DI))) int_t; + +int_t +movdifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + feq.d a5,fa0,fa1 + neg a5,a5 + and a1,a5,a1 + not a5,a5 + and a0,a5,a0 + or a0,a1,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifge.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=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifge (double w, double x, int_t y, int_t z) +{ + return w >= x ? y : z; +} + +/* Expect branchless assembly like: + + fge.d a5,fa0,fa1 + neg a5,a5 + and a0,a5,a0 + not a5,a5 + and a5,a5,a1 + or a0,a0,a5 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifgt.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=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifgt (double w, double x, int_t y, int_t z) +{ + return w > x ? y : z; +} + +/* Expect branchless assembly like: + + fgt.d a5,fa0,fa1 + neg a5,a5 + and a0,a5,a0 + not a5,a5 + and a5,a5,a1 + or a0,a0,a5 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifle.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=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifle (double w, double x, int_t y, int_t z) +{ + return w <= x ? y : z; +} + +/* Expect branchless assembly like: + + fle.d a5,fa0,fa1 + neg a5,a5 + and a0,a5,a0 + not a5,a5 + and a5,a5,a1 + or a0,a0,a5 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fge\\.d|fle\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsiflt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsiflt.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=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsiflt (double w, double x, int_t y, int_t z) +{ + return w < x ? y : z; +} + +/* Expect branchless assembly like: + + flt.d a5,fa0,fa1 + neg a5,a5 + and a0,a5,a0 + not a5,a5 + and a5,a5,a1 + or a0,a0,a5 + */ + +/* { dg-final { scan-rtl-dump-times "Conversion succeeded on pass 1\\." 1 "ce1" } } */ +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded through" "ce1" } } */ +/* { dg-final { scan-assembler-times "\\s(?:fgt\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifne.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=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ + +typedef int __attribute__ ((mode (SI))) int_t; + +int_t +movsifne (double w, double x, int_t y, int_t z) +{ + return w != x ? y : z; +} + +/* Expect branchless assembly like: + + feq.d a5,fa0,fa1 + neg a5,a5 + and a1,a5,a1 + not a5,a5 + and a0,a5,a0 + or a0,a1,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_cmove" 1 "ce1" } } */ +/* { dg-final { scan-assembler-times "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ From patchwork Sun Nov 19 05:43:09 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: 166709 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506561vqn; Sat, 18 Nov 2023 21:43:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFyrp4+NcYui/fMsszJagWungRr1xsOsnyjLYXsIZ7k8hSJ3Ru/fLsaNH0UaAlp3dVWPmyk X-Received: by 2002:a05:6214:2122:b0:66d:2852:6f17 with SMTP id r2-20020a056214212200b0066d28526f17mr5885660qvc.14.1700372636652; Sat, 18 Nov 2023 21:43:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372636; cv=pass; d=google.com; s=arc-20160816; b=PROOvagdsdTkRuq5JTdmQmKlgB8hVDFCs08O6rpJM+cGh3w4wLTh/S9DNoEqHDnT1P HhJKndnMPizSSh4/3RaUB20QcwGAPn8f6OG3oUZeUdPDvYTnwE9nRDH+6+7ct+QCjEaW uavxTyYQfdi91vHe4J9Wh4cWkwtriZiWMv5KqOWZThJSHi5LNJpkNUmVuvf48B+dXFKE DwfEq53aaXdkNpMPMb2Cn2W/Ya5BqY2nVP1hHqfQG+Qt4kuCHoTM+2kQmJI+FlMQ5W3r baU+VAPrZYqhfMsMQ4d5d7aWzmCJl8GlSbsvMP/7SxYS41PaQzAoju7gcqNuN5zbdVLN WW+Q== 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=GPul54jWhxChkbymuL8OcV4ISHDBefbRN/Cl36Lngnk=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=DehKpgJPOuYrk4vTO8LtabGBpLbvVBiRlla6ts2EvU5AUPxB4F6cPOl0CLWp1fNGWf smcZE6IS1Nz/wFst81k1qsQaoliMEzYpkZ4U53dJSm/5U5G9kU22/jRN2CGYa43izrcm mhAhroplaZWwS+4pDDyqMeDyyK9weJYbAaTlWkRdF5BK2bEEh1dt9bBc2SSs4V1f6D1b bdUt5wmwciRkmlHBWSjSptEmGRxxe8UNnyMy2gtE/3OlWcd2fR444GajTjlP/Yw6Icu/ s6zKwhgoPO6WxZ1L0b7yzZp8KmzaPBrIY//AfjdmN0b+//ZFbFCeHMLxXWkukk0ff8qR 5r8Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b="DyQ6/8cm"; 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 ef20-20020a0562140a7400b00670de8563e9si4846044qvb.444.2023.11.18.21.43.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:43:56 -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="DyQ6/8cm"; 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 E9F3E3853545 for ; Sun, 19 Nov 2023 05:43:41 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id B184F38582AE for ; Sun, 19 Nov 2023 05:43:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B184F38582AE 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 B184F38582AE Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372597; cv=none; b=urRxeXYnx1BidB6LNTnmM5ESKrBVn8F0Wk2j2zARjI84NYHeFDmUBa4OeJ3lH2c01N2LQouQQosQ0VtsLG86I+xEmi3dDX5QDW19FjWeffwRo0sTT5VwMV28NuuzyHZFmHS7RTsUC9FaO5zyR9Qv/UsptpnI20CBRVo4hUsW6m8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372597; c=relaxed/simple; bh=3uu91j+4zoPNsexhbbOrMNjE4sJiu+tSgZdE8T/QF4w=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=vkOk6ymlarr5pm1u2BAIc1IZfZTu1ZeEtLj67jqphHiqE39dafLB1TFi+Kkrz/clK8q6XsnGb1WzAsP6CuENuHLYpMhHAjlTWt6aJnjGolzSVK9yNLupKDsWED1hzwPusMRmteDg9qxU592aoV4fyqUP3lqBQ7+RRBo6WkqPu5w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5441ba3e53cso4489168a12.1 for ; Sat, 18 Nov 2023 21:43:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372593; x=1700977393; 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=GPul54jWhxChkbymuL8OcV4ISHDBefbRN/Cl36Lngnk=; b=DyQ6/8cmFtKDXqzw6l36ZYZqKBUj3xQmkKjy5w55SBf+q+Knboja//DtSfw/Llnx3g 1Rbq9D9zoFtJH5nrzKstyRJACfd5yiVeJBt8WkmC0Qahs3/TXeoO6mrW6POm6PBVUWzS D0D1/1CTdDFPvc1TKW0qltnH6MsyvWLSREU9HmPGcVORFZ4VOW3kE8pcIv5B5srNExiv Q7/zKDYuGd9jmARe1cIBlT7tug9hquLO4BUrpp+ngAbUpvj3XSPggjbV2lPJxHi81qXt 2ebKNsc6zwGhG4hbSxd8+VZYtrX7fbrcBB3n34SGVG54Z3zB9My4z2Y53aTZA2xiT9S+ OmoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372593; x=1700977393; 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=GPul54jWhxChkbymuL8OcV4ISHDBefbRN/Cl36Lngnk=; b=Vh5lddacTFCQCKp3ig6f8ryZWm7U4G6a5E8cSpUbl7AdacC6qdsqH3tMZ2h3rF9xl4 eOcQzkJRccDnt1efnWjZ3iEoEGXQH0dRjDalji++i8/dFRfODYpzhhhikrHuMKu+6jAD bYeASzjcy5gefQRs8GH/AYNZj3W5kNyATh2OXA0k4IwLNNnD86ako808Cs/5WL4Jwyz8 cX3IQc5yrhLdy4FqNlPut9X8VdapFPlDUv6lO4gGNz4eOjRtyAxrY9dlMH5wQwRgvfTO ToshPTEWt/JXl3C3AcYk4wJUN7ZDwpqJDIYUqoSvB8FyA1Yl8dux4FsO+L8tzC5gHN9+ sUnQ== X-Gm-Message-State: AOJu0YyOtzabBifkkxUrGd4ZZ+3wdVcsxezLur9TIgrwmtQc4UAC/k1P loFiDfmbKTio94KReyAgwKjhygCq/jMlFHzVn3FojA== X-Received: by 2002:aa7:d602:0:b0:540:e588:8243 with SMTP id c2-20020aa7d602000000b00540e5888243mr2957640edr.20.1700372593391; Sat, 18 Nov 2023 21:43:13 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id a24-20020aa7d918000000b0054897d70ce1sm484658edr.71.2023.11.18.21.43.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:43:12 -0800 (PST) Date: Sun, 19 Nov 2023 05:43:09 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 38/44] RISC-V/testsuite: Add branched 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=0.8 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: 1782969937361395865 X-GMAIL-MSGID: 1782969937361395865 Verify, for generic floating-point conditional-add operations that have a corresponding conditional-set machine instruction, that if-conversion does *not* trigger at `-mbranch-cost=2' setting, which makes original branched code sequences cheaper than their branchless equivalents if-conversion would emit. Cover all the relevant floating-point relational operations to make sure no corner case escapes. gcc/testsuite/ * gcc.target/riscv/adddibfeq.c: New test. * gcc.target/riscv/adddibfge.c: New test. * gcc.target/riscv/adddibfgt.c: New test. * gcc.target/riscv/adddibfle.c: New test. * gcc.target/riscv/adddibflt.c: New test. * gcc.target/riscv/addsibfeq.c: New test. * gcc.target/riscv/addsibfge.c: New test. * gcc.target/riscv/addsibfgt.c: New test. * gcc.target/riscv/addsibfle.c: New test. * gcc.target/riscv/addsibflt.c: New test. --- gcc/testsuite/gcc.target/riscv/adddibfeq.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddibfge.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddibfgt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddibfle.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/adddibflt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibfeq.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibfge.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibfgt.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibfle.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibflt.c | 26 ++++++++++++++++++++++++++ 10 files changed, 260 insertions(+) gcc-riscv-test-addccf-branch-generic.diff Index: gcc/gcc/testsuite/gcc.target/riscv/adddibfeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibfeq.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=2 -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 branched assembly like: + + feq.d a5,fa0,fa1 + beq a5,zero,.L2 + add a0,a0,a1 +.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/adddibfge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibfge.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=2 -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 branched assembly like: + + fge.d a5,fa0,fa1 + beq a5,zero,.L2 + add a0,a0,a1 +.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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.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/adddibfgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibfgt.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=2 -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 branched assembly like: + + fgt.d a5,fa0,fa1 + beq a5,zero,.L2 + add a0,a0,a1 +.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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.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/adddibfle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibfle.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=2 -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 branched assembly like: + + fle.d a5,fa0,fa1 + beq a5,zero,.L2 + add a0,a0,a1 +.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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.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/adddibflt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibflt.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=2 -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 branched assembly like: + + flt.d a5,fa0,fa1 + beq a5,zero,.L2 + add a0,a0,a1 +.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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.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/addsibfeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibfeq.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=2 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -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 branched assembly like: + + feq.d a5,fa0,fa1 + beq a5,zero,.L2 + add[w] a0,a0,a1 +.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/addsibfge.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibfge.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=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -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 branched assembly like: + + fge.d a5,fa0,fa1 + beq a5,zero,.L2 + add[w] a0,a0,a1 +.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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.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/addsibfgt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibfgt.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=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -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 branched assembly like: + + fgt.d a5,fa0,fa1 + beq a5,zero,.L2 + add[w] a0,a0,a1 +.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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.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/addsibfle.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibfle.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=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -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 branched assembly like: + + fle.d a5,fa0,fa1 + beq a5,zero,.L2 + addw a0,a0,a1 +.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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.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/addsibflt.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibflt.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=2 -mmovcc -ffinite-math-only -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -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 branched assembly like: + + flt.d a5,fa0,fa1 + beq a5,zero,.L2 + addw a0,a0,a1 +.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 "\\s(?:fge\\.d|fgt\\.d|fle\\.d|flt\\.d)\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ 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 } } } */ From patchwork Sun Nov 19 05:43:34 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: 166711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506665vqn; Sat, 18 Nov 2023 21:44:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWqyDlAJjuy+w47m5B9CTCdCIoBH5kvsY8j2PrDDMQNLBHxr/aJKOdOwJ7ldV6kXYqeSrV X-Received: by 2002:a05:622a:1488:b0:41e:54b4:347c with SMTP id t8-20020a05622a148800b0041e54b4347cmr4728290qtx.43.1700372667106; Sat, 18 Nov 2023 21:44:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372667; cv=pass; d=google.com; s=arc-20160816; b=tmclo2Sw0GASQuwj8Rdyg+AvenCfvegtrupKR7cxSofVL7CDG2IEUZHdmJ5bR+uoxT BPAgpJUIzKc0hI2tS3/zBTTe+F1OYjjVcIhgU1S6BqD2hkA1X8To/bxI+yaY0m7SvCqs SsdKdgxHXNAssT0DENu75rXIh9NvT8K8DpyDokKzXGr1stwbT9SsyDbvxJS1VM9FpPhf BoaZFPiI2SjHbk2uGnw14nrB+CwGO+cQd8/aOCzwtXau4qPMZ+ZDFGZT47S2ueA/n37X fik8yFpEIBFQnIk7K25TfL1RGkGLhhuA+aofCPKdfqUFVk+csSC84qRi+QDGgFFahLeL ZQZA== 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=2edoIH4bbRSESTvYgZHtG6W+yn31nmFlz6JqqA9uPzs=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=X/YvduTAPq0EJsYgqX4Q1Uta1vvbzuR0zZ7B9T33ixById5aLCA4nWGFZ4FguICh0F /rvbasAXk0hE7wUlLo8r/RQrPVCZJ+7avns5CpQOgx0uKrWGvSbq0vEfL3OGYJrqo/Wl qXoRW4VA6bxKC6hWnBKXisk3ISQKDARcsJVlo+lHdYO0EMVEnnOeB3WSHXhYchkd7E+B eAbONaE3IWaF9ik1m3I3A8PHrX5eQX4dJH8tUSwYa9cXMBuoKjDAecdSbEqAvWHG14we 5CTyllNE05RBfaZMTUracI6OLcas3NUzRLHPFQljuOAZJdPSGJYJhVkyt1fGvi+qCfJV Ouxg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b="cOP7b5f/"; 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 b21-20020ac85bd5000000b00421a18c755esi5154710qtb.189.2023.11.18.21.44.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:44:27 -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="cOP7b5f/"; 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 8A0523861803 for ; Sun, 19 Nov 2023 05:44:04 +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 B00F5385C405 for ; Sun, 19 Nov 2023 05:43:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B00F5385C405 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 B00F5385C405 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=1700372620; cv=none; b=mCRnuIxICQBVlJcQHcWC1pgnviWguhI9xpw3hmE3lMngRux+UrvWbmaZkFvwdsdD8w/CAddi5p6+VIetNhZDfeCbsh/fwwgAU/xdks2egdaViz/IpMiYqk7m2OtP2w06gEdkxYqy7wmcoyuSoPO8UBR1CBSBnQnm5kq5nyW+tss= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372620; c=relaxed/simple; bh=pTuhKbGCN0BcOQCpv0CuTAhCZQxdxh9d/Dl1SQNJGmw=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=tCvrEt2j5PWI80HDytbvKbET6nH2s9uN0kmFLhekn3vcRGJcazfaik7juUWv716bm8G8L6KxiD6JGOgUugcEgBReg/5elxFzOSKGHin3cZoA9AQkzEMkwfZLsSaIHXFHVT1bXqt1uIwNRAv3tPhy+xeJOU8xQ4Xl/mK3PCU9m2w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-9c2a0725825so459538066b.2 for ; Sat, 18 Nov 2023 21:43:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372617; x=1700977417; 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=2edoIH4bbRSESTvYgZHtG6W+yn31nmFlz6JqqA9uPzs=; b=cOP7b5f/7FyWcm46z90tcC59RFqhZqpt5PxnEHsvq0KIg5MAqN2ra+p9sOZxR2asJX +t/SDTzYrjHGONnuXzX1FCope2C2nnasdLkuL7PXvGMAtQSKCOjYeuq5idCEESiXxUtn Fp7Np/SPern0v9SO78P1iuP277tRbZEY/14NvrNRLbivyesl6hFC/gDbmsiOG61uPAQb O+4uqGG1C4apizD7OQ9d8JP1hc/TC2U8SVmnTXWV+ifmauIi+LaE8W6kwTBoeES+mGEe wkt9jEmutRfO0A1DTNHsl37ieVDVpxSt91GEUucBWMyg9yCEz+4vFhLhgRCVuHh13Ojl 07jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372617; x=1700977417; 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=2edoIH4bbRSESTvYgZHtG6W+yn31nmFlz6JqqA9uPzs=; b=SnUEeAyXiU6GdOL8DP/1YhZF/ocISbaFqPpRrYEUYj2n2PrgvT0cblj0o2LxN/MV3f AD30YIhOjvjeIAi+hULAQ9ySZEiijw2HKDN3N/5mew9d8f3KVoge2vnT2hSW06d/iUjs YJTlNWUMAUhTpXP/8sU8+Cwj8CcaAguGsciebweQkYMRzEvSdFvOW5IFEG1xy45sW6Lh VCdN4jcfB+j2yE2w0HHTGVXDDuEvNL/Yulqdx86PixOCoPpVYbIgbXznwQRkOtuP8TCc piVrqk5ocxF05ZSrL35Mx9u1uV2ZA8GMEhnjlCFOmYGODEGYNpY+oQ1P9SUCDi2hBplW Fw2w== X-Gm-Message-State: AOJu0YwFKGHDUy0JIUEbzJe8bafU+oyH0guaMj3jlFz5wPwdkpmng9Fh 9gCvmHW/UFCXa9bQq3heFZEqD8PHMiCtBIrW0nu79A== X-Received: by 2002:a17:906:210:b0:9f7:b852:f807 with SMTP id 16-20020a170906021000b009f7b852f807mr2707778ejd.9.1700372617404; Sat, 18 Nov 2023 21:43:37 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id t9-20020a170906178900b009fd83a7362csm102167eje.70.2023.11.18.21.43.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:43:37 -0800 (PST) Date: Sun, 19 Nov 2023 05:43:34 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 40/44] RISC-V: Handle FP NE operator via inversion in cond-operation expansion 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.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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: 1782969969652313977 X-GMAIL-MSGID: 1782969969652313977 We have no FNE.fmt machine instructions, but we can emulate them for the purpose of conditional-move and conditional-add operations by using the respective FEQ.fmt instruction and then swapping the data input operands or complementing the mask for the conditional addend respectively, so update our handlers accordingly. gcc/ * config/riscv/riscv-protos.h (riscv_expand_float_scc): Add `invert_ptr' parameter. * config/riscv/riscv.cc (riscv_emit_float_compare): Add NE inversion handling. (riscv_expand_float_scc): Pass `invert_ptr' through to `riscv_emit_float_compare'. (riscv_expand_conditional_move): Pass `&invert' to `riscv_expand_float_scc'. * config/riscv/riscv.md (addcc): Likewise. --- gcc/config/riscv/riscv-protos.h | 3 ++- gcc/config/riscv/riscv.cc | 23 +++++++++++++++-------- gcc/config/riscv/riscv.md | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) gcc-riscv-emit-float-compare-ne.diff Index: gcc/gcc/config/riscv/riscv-protos.h =================================================================== --- gcc.orig/gcc/config/riscv/riscv-protos.h +++ gcc/gcc/config/riscv/riscv-protos.h @@ -132,7 +132,8 @@ riscv_zcmp_valid_stack_adj_bytes_p (HOST #ifdef RTX_CODE extern void riscv_expand_int_scc (rtx, enum rtx_code, rtx, rtx, bool *invert_ptr = 0); -extern void riscv_expand_float_scc (rtx, enum rtx_code, rtx, rtx); +extern void riscv_expand_float_scc (rtx, enum rtx_code, rtx, rtx, + bool *invert_ptr = nullptr); extern void riscv_expand_conditional_branch (rtx, enum rtx_code, rtx, rtx); extern rtx riscv_emit_unary (enum rtx_code code, rtx dest, rtx x); extern rtx riscv_emit_binary (enum rtx_code code, rtx dest, rtx x, rtx y); Index: gcc/gcc/config/riscv/riscv.cc =================================================================== --- gcc.orig/gcc/config/riscv/riscv.cc +++ gcc/gcc/config/riscv/riscv.cc @@ -3965,7 +3965,8 @@ riscv_emit_int_compare (enum rtx_code *c /* Like riscv_emit_int_compare, but for floating-point comparisons. */ static void -riscv_emit_float_compare (enum rtx_code *code, rtx *op0, rtx *op1) +riscv_emit_float_compare (enum rtx_code *code, rtx *op0, rtx *op1, + bool *invert_ptr = nullptr) { rtx tmp0, tmp1, cmp_op0 = *op0, cmp_op1 = *op1; enum rtx_code fp_code = *code; @@ -4029,10 +4030,15 @@ riscv_emit_float_compare (enum rtx_code #undef UNORDERED_COMPARISON case NE: - *code = EQ; - *op0 = riscv_force_binary (word_mode, EQ, cmp_op0, cmp_op1); - *op1 = const0_rtx; - break; + fp_code = EQ; + if (invert_ptr != nullptr) + *invert_ptr = !*invert_ptr; + else + { + cmp_op0 = riscv_force_binary (word_mode, fp_code, cmp_op0, cmp_op1); + cmp_op1 = const0_rtx; + } + gcc_fallthrough (); case EQ: case LE: @@ -4078,9 +4084,10 @@ riscv_expand_int_scc (rtx target, enum r /* Like riscv_expand_int_scc, but for floating-point comparisons. */ void -riscv_expand_float_scc (rtx target, enum rtx_code code, rtx op0, rtx op1) +riscv_expand_float_scc (rtx target, enum rtx_code code, rtx op0, rtx op1, + bool *invert_ptr) { - riscv_emit_float_compare (&code, &op0, &op1); + riscv_emit_float_compare (&code, &op0, &op1, invert_ptr); machine_mode mode = GET_MODE (target); if (mode != word_mode) @@ -4171,7 +4178,7 @@ riscv_expand_conditional_move (rtx dest, riscv_expand_int_scc (tmp, code, op0, op1, invert_ptr); else if (FLOAT_MODE_P (mode0) && fp_scc_comparison (op, GET_MODE (op))) - riscv_expand_float_scc (tmp, code, op0, op1); + riscv_expand_float_scc (tmp, code, op0, op1, &invert); else return false; Index: gcc/gcc/config/riscv/riscv.md =================================================================== --- gcc.orig/gcc/config/riscv/riscv.md +++ gcc/gcc/config/riscv/riscv.md @@ -2697,7 +2697,7 @@ if (INTEGRAL_MODE_P (mode0)) riscv_expand_int_scc (reg0, code, cmp0, cmp1, &invert); else if (FLOAT_MODE_P (mode0) && fp_scc_comparison (cmp, GET_MODE (cmp))) - riscv_expand_float_scc (reg0, code, cmp0, cmp1); + riscv_expand_float_scc (reg0, code, cmp0, cmp1, &invert); else FAIL; 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" } } */ From patchwork Sun Nov 19 05:43:56 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: 166714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506808vqn; Sat, 18 Nov 2023 21:45:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAvvnw9Tv7M7dXv6Sg42xWmdjvXeWfXEwCTBaVZ8va4qe6IvGE7S1fju59ivHqZpaTd7jE X-Received: by 2002:ac8:5a45:0:b0:41e:204b:f931 with SMTP id o5-20020ac85a45000000b0041e204bf931mr5941738qta.42.1700372703269; Sat, 18 Nov 2023 21:45:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372703; cv=pass; d=google.com; s=arc-20160816; b=MkS2AiSyAnpm4bFYop2nQXyzcpBL3riF95S8MyXDVNXlHWFr48ebdnT/QRBSvCvh/J vfTmiOAI4mUC0zumrmKb6OFXeMEsi0pfVgWxQhOYpPeSRPe+62ga+5joDZcuLmlg+469 EelfLck087r77vhcDjj4HtBe2T2a53lwhG6aL4hZGWvbTHR3JDTnnYF35yEnVKemg47M MQthh2l7Tkc93gIDWQ39gDkCEwwSt5h6zYMhgbBO1u8w5EzEpAztUMt5ma4FuyCHixc/ aUUvFqd23X4nxKPP1w05Rmc7exDAa/VWr74OjlTt4XJwZyl7ecJ6281JiylFrLcRIooH CQuQ== 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=tEWIBFac95t6b01lycmnDI4hegZEL/OcDyksw8+EEFo=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=Avys/uyGN0YEUGEDe2lGKU6GVmR4S/GA7YU4bwETeK1XNKgngglVY8e/KkKLFSG1HS MOJjytEa2CoV2xvBkzFCzpGCbIqwJ9yraXrUdsdh/d500eMlNjiLl1IgFUbvOVNN+N3k iJgbXnBOXSGCBokgNHwf7bUYa9PXxohHZt57mvBKiSnFoXNKr30t22o1FNN7slIYelAw f0EKIpZuVUeaOCCUSU9Hfa5cXchA7gpfgRpqEXxBkINC71A5u2CUlOq+KzHpJ4cciIZR OP+CuortTMSYoGFtXLB5bH1F81jhXikMBgImIOefFKl9tcDM2UcOWnnToimkv6m+23Dy u8ZA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=fFUy8n67; 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 n16-20020ac85a10000000b004181a080726si5098138qta.659.2023.11.18.21.45.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:45:03 -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=fFUy8n67; 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 C1A31385AE75 for ; Sun, 19 Nov 2023 05:44:28 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 85D39386075C for ; Sun, 19 Nov 2023 05:44:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 85D39386075C 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 85D39386075C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::531 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372643; cv=none; b=B7hpMl5j3wMjud8xWNuRS2NzqpzzE1y7WxU8uMujFk3GAiktixMG2eyCkbQn2jFX3N+ONwbZ+UP4xOe07kyA0XFq9c0gZWRvKWj9RKRt81dod+C9eDNwgTmlDWFVk+zVRWYxBpUT3nAtj+NlqfARQyCsQiJsc2neJnoPv1f/q30= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372643; c=relaxed/simple; bh=8cVz95x77k3X4jGf+rNnYrnOGC9CVHbPL2Bt3ePhIJI=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=NHGuyDAOlz4G7WxVSX1OjkWg7pJQVhKbEYzxmlBRrSptI3Jw1tdMcXzGFcmLnrUnqPk5kGriMbpmIzM4R6c2UmV/cjTiOw1k4SaN/wiBcQyHtJ4FhrUNnCNnlBSnjWzsCbCnJTv99qC+ciPiwpMiXi1ToyS8fFEBUr6TTmR58S8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-53de8fc1ad8so4852326a12.0 for ; Sat, 18 Nov 2023 21:44:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372639; x=1700977439; 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=tEWIBFac95t6b01lycmnDI4hegZEL/OcDyksw8+EEFo=; b=fFUy8n67lXFk5ySLdXZXEdhLV3N5fNOy9pvDHK4OtOnY8ztbbAak+1Q1L06FPVEBfa D9z0eJtQIuqw8e9AYmyG/LIRF4omDwJEyUHwbxhweiTgzDQm7VTXXYUCBLmMkI901+Cn fQi2VZHu70JbQR2N0p6jSlBmRne8bnbSMisAq7YflZCkSRT6Z2h+QDjrCXFJxUwdPljN Y4298VNbt78hPy04IZVvyLvNIMXTf8z1nEsDqLfpmE5/xXlsKrWdtNJlp0P30jWdHqMF vs3Y6UCKCWjwtGKe78MbEeqch7Kniegmua7pDEJkdmMB/nHiHGDHv2bvnbdPkcmp7QAh O0gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372639; x=1700977439; 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=tEWIBFac95t6b01lycmnDI4hegZEL/OcDyksw8+EEFo=; b=Q6kc8RPeMZOn/idci/Hd7DrSB8VVrBVbGzc8bs2rAgH5uOw5Qalr5P7O3SYnnsjqAi 8icX9BMa6aY7t6dN0BSKgancNTuDPlhvI6c5F2a8VDfPedt8+NmeKUt+qXj9pbCzBPWl 4x7BkItbkAsRL7S/WF1/G2rEgWpMHvdIh0pWWupcJMNWOjjKxN88XzaaOqVkGjNoNnJV wsdPMRm2/iSHQg/9tj72frHr+gQY73JYLmhoi1Gurmecc6QOq9UGvlKemFmBbwZWNxRj gcDbV3VpMJaMmfp48oSGwh1CRG9ZbehpxGpkMb8bBI2eyQHUGR4h3qyUcVzoDravN+N8 n6uQ== X-Gm-Message-State: AOJu0YxAIuTxu5a0yciGTuTGKN/qHoGYRdbPX+M97O1SIW/ttoaJR8Nb MN9jnev5oFT8rKpJvK5/1T+hIgy3LvL4Wk0T8VUA/A== X-Received: by 2002:aa7:df0b:0:b0:53f:a377:7287 with SMTP id c11-20020aa7df0b000000b0053fa3777287mr3235203edy.18.1700372639234; Sat, 18 Nov 2023 21:43:59 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id q11-20020a056402040b00b00530bc7cf377sm2249889edv.12.2023.11.18.21.43.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:43:58 -0800 (PST) Date: Sun, 19 Nov 2023 05:43:56 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 42/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.1 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: 1782969990111586039 X-GMAIL-MSGID: 1782970007917814586 Verify, for the floating-point NE conditional-move operation, that if-conversion triggers via `noce_try_cmove' at the respective sufficiently high `-mbranch-cost=' settings that make branchless code sequences produced by if-conversion cheaper than their original branched equivalents, and that extraneous instructions such as SNEZ, etc. are not present in output. gcc/testsuite/ * gcc.target/riscv/movdifeq-sfb.c: New test. * gcc.target/riscv/movdifeq-thead.c: New test. * gcc.target/riscv/movdifeq-ventana.c: New test. * gcc.target/riscv/movdifeq-zicond.c: New test. * gcc.target/riscv/movdifeq.c: New test. * gcc.target/riscv/movsifeq-sfb.c: New test. * gcc.target/riscv/movsifeq-thead.c: New test. * gcc.target/riscv/movsifeq-ventana.c: New test. * gcc.target/riscv/movsifeq-zicond.c: New test. * gcc.target/riscv/movsifeq.c: New test. --- gcc/testsuite/gcc.target/riscv/movdifeq-sfb.c | 27 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifeq-thead.c | 25 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifeq-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifeq-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movdifeq.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifeq-sfb.c | 27 +++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifeq-thead.c | 25 +++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifeq-ventana.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifeq-zicond.c | 28 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/movsifeq.c | 28 ++++++++++++++++++++++ 10 files changed, 272 insertions(+) gcc-riscv-test-movccne-generic.diff Index: gcc/gcc/testsuite/gcc.target/riscv/movdifeq-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifeq-sfb.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -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 short forward branch assembly like: + + feq.d a5,fa0,fa1 + beq a5,zero,1f # movcc + mv a1,a0 +1: + mv a0,a1 + */ + +/* { 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 "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifeq-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifeq-thead.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target rv64 } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -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 branchless assembly like: + + feq.d a5,fa0,fa1 + th.mveqz a0,a1,a5 + */ + +/* { 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 "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\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/movdifeq-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifeq-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=3 -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 branchless assembly like: + + feq.d a5,fa0,fa1 + vt.maskcn a1,a1,a5 + vt.maskc a0,a0,a5 + or a0,a0,a1 + */ + +/* { 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 "\\sfeq\\.d\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifeq-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifeq-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=3 -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 branchless assembly like: + + feq.d a5,fa0,fa1 + czero.nez a1,a1,a5 + czero.eqz a0,a0,a5 + or a0,a0,a1 + */ + +/* { 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 "\\sfeq\\.d\\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(?:beq|bne)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movdifeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movdifeq.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=5 -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 branchless assembly like: + + feq.d a5,fa0,fa1 + neg a5,a5 + and a0,a5,a0 + not a5,a5 + and a5,a5,a1 + or a0,a0,a5 + */ + +/* { 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 "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifeq-sfb.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifeq-sfb.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-7-series -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-7-series -mbranch-cost=1 -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 short forward branch assembly like: + + feq.d a5,fa0,fa1 + beq a5,zero,1f # movcc + mv a1,a0 +1: + mv a0,a1 + */ + +/* { 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 "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:beq|bne)\\s\[^\\s\]+\\s# movcc\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifeq-thead.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifeq-thead.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ +/* { dg-options "-march=rv64gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_xtheadcondmov -mtune=thead-c906 -mbranch-cost=1 -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 branchless assembly like: + + feq.d a5,fa0,fa1 + th.mveqz a0,a1,a5 + */ + +/* { 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 "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-times "\\s(?:th\\.mveqz|th\\.mvnez)\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifeq-ventana.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifeq-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=3 -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 branchless assembly like: + + feq.d a5,fa0,fa1 + vt.maskcn a1,a1,a5 + vt.maskc a0,a0,a5 + or a0,a0,a1 + */ + +/* { 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 "\\sfeq\\.d\\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(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifeq-zicond.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifeq-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=3 -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zicond -mtune=rocket -mbranch-cost=3 -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 branchless assembly like: + + feq.d a5,fa0,fa1 + czero.nez a1,a1,a5 + czero.eqz a0,a0,a5 + or a0,a0,a1 + */ + +/* { 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 "\\sfeq\\.d\\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(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ Index: gcc/gcc/testsuite/gcc.target/riscv/movsifeq.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/movsifeq.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=5 -mmovcc -fdump-rtl-ce1" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc -mtune=sifive-5-series -mbranch-cost=5 -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 branchless assembly like: + + feq.d a5,fa0,fa1 + neg a5,a5 + and a0,a5,a0 + not a5,a5 + and a5,a5,a1 + or a0,a0,a5 + */ + +/* { 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 "\\sfeq\\.d\\s" 1 } } */ +/* { dg-final { scan-assembler-not "\\s(?:beq|bne)\\s" } } */ +/* { dg-final { scan-assembler-not "\\s(?:seqz|snez)\\s" } } */ From patchwork Sun Nov 19 05:44:07 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: 166715 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1506893vqn; Sat, 18 Nov 2023 21:45:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhXMvTjcxW6mpI2xtnyYG+1NRpbhv7lolHO31TdA8QZoQC39ssZKmqYY05RJYnBB0BGk4s X-Received: by 2002:ad4:5cc6:0:b0:677:9190:13bd with SMTP id iu6-20020ad45cc6000000b00677919013bdmr6397046qvb.10.1700372718156; Sat, 18 Nov 2023 21:45:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700372718; cv=pass; d=google.com; s=arc-20160816; b=rYkTeecmdAsZPN1loGEGMXwSMOipNOgzta/u7e1LeOaR4csbnAyrHjp1oReUs3Y7JQ 5bNgfZUByAY9rbeEEFUT2KkMKKEdiqjx4x4irLVSyw9kjZP6JDzcw0W3xZMwhEb74bVP PAqrCJGYoXPwSzhFcnPgEPTyXQr1i+N1UAqzOAzzmO7X3yF1Qndu7e3qdJWgrEGvjbft zZ/NWtytqwStQSpiCh9gnhEqk6gPv63PqAejqhyQZSs+xqw1hizgZExvPomV5KVkIlMh GNlpO7FD0G3WkiGYiYyYcFXeDGsdbTVF6aeEw/9GpYp/7uPfAGFvEVF6D0uPEDzwI/KB vHPg== 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=9z1D1R+lw6s5FeHvkKFF3kLrU6zg9GKEbDDMNq0C9x0=; fh=dp1z4I3tVhinwswv7IAFxpunWK+Ws/fGQfmox9vHv3I=; b=ZJFoxSCgiYkrnCLCY3p04TNPudFUeKTT3Xl8cdCpJLRE42EJG3VKaE3X3x66ZJsVpa jQe3Dz48JmOK8nhVV3Jgi3a9JRVuzKkUInmOwqLYGWYqzd2vZFJLpDYshLcNKSe6XAyq 5vIulKVFsWE3u3WdonuQ5xXTUfXRuTkL+wLt75rIu0lX76ZMLKGpJLbu0jvopverN/xT ezw0A2YRFzlr4zgk5luuZojyOg2jnNK4xprCA1I7urZsCHpugLSwZ+10zwYmPFYINBht S8jkBX8q23jGgS0BfAR0TIfaW+ny8hQYaJwLf3GsJNimj6DB8QsHqfrOh1gDwsRrYRj4 5NQA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=WdgckF6N; 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 i18-20020a0cfcd2000000b006709501a673si4910370qvq.199.2023.11.18.21.45.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 21:45:18 -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=WdgckF6N; 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 B1CD6386183A for ; Sun, 19 Nov 2023 05:44:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id 2F02A38654B2 for ; Sun, 19 Nov 2023 05:44:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F02A38654B2 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 2F02A38654B2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372652; cv=none; b=nfRChWNR9aSanqT/05BzZNh1hX+GZ8IIUaZRNEmJV2iB2r1qQroQt9KxO7+hNrFLTgbbp0zdvcsIOesHJl8w9YxaKT6ILWEHGohoRz16tTKJpahpcDNRn8W7oUAkHfjrPjTCzKVL6r/c7z5JC0Kxo7sr3QEV9m4K5cWss8DfQtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700372652; c=relaxed/simple; bh=fIFdWAnuZ+ky7Vu5cnxFJoY8PszuXY8Tb03G2MRy/6A=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Z3WSmWB41zZOBxFkwx7wpi7ktVprpdjqOrBQqyXUalQEzPRxIOBM6LvbAG6/Sg7IUBiI9x0ERDauOd6TemUUjyVuFaj2AoNeO0RGR7XH03JQrbvBJClNXVa3ftMwPIlfci1tPIS4WnZY0lpsd38WlB+BDJ7RuZxV9ubmw3DJKgA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-53e04b17132so4712038a12.0 for ; Sat, 18 Nov 2023 21:44:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700372650; x=1700977450; 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=9z1D1R+lw6s5FeHvkKFF3kLrU6zg9GKEbDDMNq0C9x0=; b=WdgckF6NGzrbtCQImYS3WBl9uRl9Ky0A760q0BQ99knMQXJIQ3j8tjOVvXWMY16xS1 yo57TOomoo4jK9odcit85Jzn7TYct7fOCvHR9zXKFm3SB/4Z7bPrOMtQaPdpQVK6rhao /BezxLWUUdBisJ/vOQYDEjCcPasDBtXkFgaL05GK2tTB6jslP0G1+e8T8Bg9fXhGXRLw 5Fe0bc6viC08ElYpQJZfOITdOAQzN2TD7uy5TAL7MB7IjLZvfNB3stwab0E51Lo/jhh8 GtE1pziknIRYRg3vQ+Lxhm1y9jTAKoNS1y1XxH8mIv1oentnFlnwwpibU1FUwxLTp5JW Mo4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700372650; x=1700977450; 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=9z1D1R+lw6s5FeHvkKFF3kLrU6zg9GKEbDDMNq0C9x0=; b=hnaIjM7jGACnljxqISgXGDOoetyDc74yi3ZoAztVI+vWvtc6WkUHiSs26jtA0GLv9s ZEuljiFoUQbwVrB5EmcVuNOCkhRMdW4RpPl/uGt6y6WLvcbHPEmrGjGqaGUDPhdIUQ7F BiHA3EAWC3j39MrkB+rx8LFKWRcPa0IdZka1AJu6jVHEUn/HiurfIxebkwu1lrszqd9g X8Dom5qz0fKy/KVGWx3H/EqWx0BVF8a1AdJKAbhFcyax4mEsXzpCfCYLJaMDYPAbaDjQ ia4WGuJN9c0ibm1Xlx3m8r7IrG4B55ufajx2Wt0AG8gUYsMaB2Uc1o/poJT5LLFqnEeI r6vQ== X-Gm-Message-State: AOJu0Yxcp5jXJMmw5NWIwtJc5b0U5oDn1P2ohddb1P45zQR2s4J6oFal PtTj/8i0zxW1j0hke8eD1L/LxuJtMiAb44ujq8x70g== X-Received: by 2002:aa7:d981:0:b0:548:a0e8:4e51 with SMTP id u1-20020aa7d981000000b00548a0e84e51mr553652eds.39.1700372649923; Sat, 18 Nov 2023 21:44:09 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id k16-20020a17090632d000b009ddaf5ebb6fsm2559970ejk.177.2023.11.18.21.44.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Nov 2023 21:44:09 -0800 (PST) Date: Sun, 19 Nov 2023 05:44:07 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt Subject: [PATCH 43/44] RISC-V/testsuite: Add branched 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.1 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: 1782970023333455285 X-GMAIL-MSGID: 1782970023333455285 Verify, for the generic floating-point NE conditional-add operation, that if-conversion does *not* trigger at `-mbranch-cost=2' setting, which makes original branched code sequences cheaper than their branchless equivalents if-conversion would emit. gcc/testsuite/ * gcc.target/riscv/adddibfne.c: New test. * gcc.target/riscv/addsibfne.c: New test. --- gcc/testsuite/gcc.target/riscv/adddibfne.c | 26 ++++++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/addsibfne.c | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) gcc-riscv-test-addccne-branch-generic.diff Index: gcc/gcc/testsuite/gcc.target/riscv/adddibfne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/adddibfne.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=2 -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 branched assembly like: + + feq.d a5,fa0,fa1 + bne a5,zero,.L2 + add a0,a0,a1 +.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/addsibfne.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.target/riscv/addsibfne.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=2 -mmovcc -fdump-rtl-ce1" { target { rv32 } } } */ +/* { dg-options "-march=rv64gc -mtune=sifive-5-series -mbranch-cost=2 -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 branched assembly like: + + feq.d a5,fa0,fa1 + bne a5,zero,.L2 + add[w] a0,a0,a1 +.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" } } */ 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 } } } */