From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 494503858D20 for ; Fri, 1 Sep 2023 13:13:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 494503858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1bc83a96067so14941475ad.0 for ; Fri, 01 Sep 2023 06:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693573982; x=1694178782; 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=IkggsT8Ln8Rgwh2BSx5z8vwe3e7hXQQsoMkiOUAFE34=; b=e7CFV3uCzpTXafePbeE3IFgRrimuZ0xSP8IamS7GeLARGaJ26swd6DNjk0t1chBILn BNWchItIG8Nba4EG4nGM17YO+xYLNEiDTQdu04BfPOzYiRWW1ly8aoFE4pkZ2oJ7BaEY hl8h/4BRgN5A+b6x3q6iwsB+oYeWQgwfhKTKukfJNK2PSGIUIbtRnclDRc5JgcTXOAPf MSRR88YGpXRpQkSL4BzMyZ6r5UD6kZODqirgIFTMfaH1qCHdE4QNwJGakz5tWuiXZSr9 9bbua9kaCXsjjPHJM4FCPbxokA+KOXHwOYN3L4oBUO2FKuOaSGvwzjTPhSEB3OnuCS3L eO0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693573982; x=1694178782; 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=IkggsT8Ln8Rgwh2BSx5z8vwe3e7hXQQsoMkiOUAFE34=; b=JRng7FWOIlOFkMIkUUE9aJFefDW/2P/mO3g9E4gsevPdE60OUaAwnglYVBDFWt0OuM gu/TSy1crvR9sbzqVNVC6lZR44DJOlE5HqVYlffqvWDjmPj1/58NeoNFDIBbHM/SwCoS jxCf3NI0FmO6kRD26YahX5BCBOU5zq+5LQ789yhjLy0PDROm7Z/LctCnuMHBq2/i75lb CtRxJvGaCymoqsy+xuUm1s4tNDxJUxsm8JqTtmVaCiqbMQBcZhmtbU7Y6GYjY2C7iWun 91Z4e7Z81iS6O5YFYkJ7kXAWi+/tjlI1rzyBoUws5BOyZaXpc2b0HHw/BNRrjgsIO4e1 C+OQ== X-Gm-Message-State: AOJu0YzVUVVMH9ZMpdf9BYWDCPStzLLLaljutKtHHFGe+gxBiShV0/cW qxEKuP31pGwDfmAi0dC4i4M= X-Google-Smtp-Source: AGHT+IHjVdqqqWU4Z7xGhnXG01bY1E2lwy0+XiF4/fnOhP85mAY2SBGYkxuMJlaAvB2xK0P3bD1tTw== X-Received: by 2002:a17:902:dad2:b0:1be:f2a1:22d8 with SMTP id q18-20020a170902dad200b001bef2a122d8mr3102292plx.14.1693573982158; Fri, 01 Sep 2023 06:13:02 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id g22-20020a1709029f9600b001b8622c1ad2sm2983608plq.130.2023.09.01.06.13.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Sep 2023 06:13:01 -0700 (PDT) Message-ID: Date: Fri, 1 Sep 2023 07:13:00 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] RISC-V: zicond: remove bogus opt2 pattern Content-Language: en-US To: Vineet Gupta , gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, Palmer Dabbelt , gnu-toolchain@rivosinc.com References: <20230830215708.369610-1-vineetg@rivosinc.com> <2b3c7a2a-6e7f-78f9-7453-c2f91ea40b4a@gmail.com> From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham 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 8/31/23 11:57, Vineet Gupta wrote: > > > On 8/31/23 06:51, Jeff Law wrote: >> >> >> On 8/30/23 15:57, Vineet Gupta wrote: >>> This was tripping up gcc.c-torture/execute/pr60003.c at -O1 since the >>> pattern semantics can't be expressed by zicond instructions. >>> >>> This involves test code snippet: >>> >>>        if (a == 0) >>>     return 0; >>>        else >>>     return x; >>>      } >>> >>> which is equivalent to:  "x = (a != 0) ? x : a" >> Isn't it >> >> x = (a == 0) ? 0 : x >> >> Which seems like it ought to fit zicond just fine. > > Logically they are equivalent, but .... > >> >> If we take yours; >> >> x = (a != 0) ? x : a >> >> And simplify with the known value of a on the false arm we get: >> >> x = (a != 0 ) ? x : 0; >> >> Which is equivalent to >> >> x = (a == 0) ? 0 : x; >> >> So ISTM this does fit zicond just fine. > > I could very well be mistaken, but define_insn is a pattern match and > opt2 has *ne* so the expression has to be in != form and thus needs to > work with that condition. No ? My point was that x = (a != 0) ? x : 0 is equivalent to x = (a == 0) ? 0 : x You can invert the condition and swap the arms and get the same semantics. Thus if one can be supported, so can the other as they're functionally equivalent. It may be the at we've goof'd something in handling the inverted case, but conceptually we ought to be able to handle both. I don't doubt you've got a failure, but it's also the case that I'm not seeing the same failure when I turn on zicond and run the execute.exp tests. So clearly there's a difference somewhere in what we're doing. So perhaps we should start with comparing assembly output for the test in question. Can you pass yours along, I'll diff them this afternoon and see what we find. jeff