From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by sourceware.org (Postfix) with ESMTPS id 726563860758 for ; Sun, 19 Nov 2023 19:44:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 726563860758 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 726563860758 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c32 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700423085; cv=none; b=JNh7jk+ARmYQHciPViVVVyr4NagxdUWXdB2813DAleuNvCbg8wYn5ab9s07TGAaDmL5hI1dSkaoufPoRN3jE9KRA2KKUKv8y8jCVnZmuUzX3+L8U9KnKNqPRwJ9c42sa3Pcqn9JbzAp5NKcStvqDEgOnyhGo9IrdU0l6jggipGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700423085; c=relaxed/simple; bh=si98as7akoAL+v7Q5sQ1qfzXCg5BOU7J6wOEHF/hYXE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=icwOPOrOL52c97TZ8qPbCb5gKzNM0APwkqb06tKK9QQAwPcz1jofjGch48fFSXdoTb/VYaAR9LgLzNQLAnQwVVtam200u8uGrHapbJHQyHrTo+4NtLPEv6ukqdzJhHsMDRqrZ+R68QPpVjqQZkrTGAETyMtxgj3JU79sbf/DSIY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-58a01a9fad0so1849184eaf.1 for ; Sun, 19 Nov 2023 11:44:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700423084; x=1701027884; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=XnRRm9TTu6p/qNRCuWXH9oX2dwtvgmf4mPnT3k0Wpfg=; b=HN5i5LbFsOjy+mHqv4v+RXMtaWzEyWJpW0qSBYhuetNADPW3djY+zQQ0Rgz/4wM/Go Il/kUJuhSccsMxc8VuLrMLcfZh3vcYNQ3+bxlYDWIvnWQpoY0ssFfJesSvTfp2CtIvyi DpCxnRUsC8gwKPBLuuQSbZZqUGbxC8Kva7Hd9aqQlf765WRJnGh18bMMEEbC3ehxUssc V/1DzJCEr7c77MsfgP3oh8Fgg6gCO3QBMCS1WK16GrYvaHCGD/uGY0eg5HnF5f5eMR4G EbHveGjrvE9pCWnrMrjdH9D//AmWWNHwim3TN87FJRvMSMj67vEN2II42L+9CL4SHszb iQjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700423084; x=1701027884; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XnRRm9TTu6p/qNRCuWXH9oX2dwtvgmf4mPnT3k0Wpfg=; b=QjwRn/NQI3/yl5ur1lPHOkhqcnSYY92UHEjFV4jAqxKX9BBT+aEb5eI132LuvDJvZ5 dkudf9MJUtGyp9Zt//8KGSXnlMBn1UErFY61EdBjPAzCjLBzYk0gbBltsW8NpaV17cyX MnB9+ZqGuYopvRY1gdFMnUuXNbeBs8hd6AYq99HCsWhiYL6MyAOAt8n2D+SfIhHjdEhG yspbZFjF1mVDY/rsNL0zMj4H0KHUVuO3udalWm+SGH7H6PR6/TR4hUKQozd3PqlYjsIi u+6X1UxCQxhJe1pDi5zoNscIBeI4HbfQ9BrMmNreTZLrXRkfnCjaFhLBtElsBlRMGuJf kl7A== X-Gm-Message-State: AOJu0YwbETDMZeK7a/upaLUJgCLjZn/L7VRydu3I4MZRY2mIHRv6wPz1 OQ5qcf+2iB+XeKgD/gwrD+Y= X-Google-Smtp-Source: AGHT+IFdC+PRvWBWibzER+k7X2Fg0JvZjP4wQ9ssWnDIRGxC4CjmnqGvOgNYtngckiiCXL8X8N+g6g== X-Received: by 2002:a05:6870:514a:b0:1f4:d404:e41b with SMTP id z10-20020a056870514a00b001f4d404e41bmr2431451oak.12.1700423083704; Sun, 19 Nov 2023 11:44:43 -0800 (PST) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id bd28-20020a056871b31c00b001eb0e8b75cdsm1074561oac.10.2023.11.19.11.44.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Nov 2023 11:44:43 -0800 (PST) Message-ID: Date: Sun, 19 Nov 2023 12:44:42 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 35/44] RISC-V: Avoid extraneous integer comparison for FP comparisons Content-Language: en-US To: "Maciej W. Rozycki" , gcc-patches@gcc.gnu.org Cc: Andrew Waterman , Jim Wilson , Kito Cheng , Palmer Dabbelt References: From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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 List-Id: On 11/18/23 22:42, Maciej W. Rozycki wrote: > 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. OK jeff