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: 1865627 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=embecosm.com header.i=@embecosm.com header.a=rsa-sha256 header.s=google header.b=IF2N/eLI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SXzsm18TDz1yS4 for ; Sun, 19 Nov 2023 16:37:00 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 976A2385843A for ; Sun, 19 Nov 2023 05:36:56 +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-Google-Smtp-Source: AGHT+IFYvAnz7NG2n5IeYDBpGHXdANFZbaUqYnud2a8TA/akUNSGh7U7qGSjti2C17WNM3ET1F/MUA== 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+incoming=patchwork.ozlabs.org@gcc.gnu.org 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);