From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 8A8ED3858D20 for ; Thu, 31 Aug 2023 13:51:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8A8ED3858D20 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-x62e.google.com with SMTP id d9443c01a7336-1c0d0bf18d6so6601325ad.0 for ; Thu, 31 Aug 2023 06:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693489887; x=1694094687; 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=CCIIRv3lKFoD8HPnmS3rt0qnK4c1JCFf4jJc+7DI2ok=; b=WEq1mORMBfWIQUF2Y+46ebV2g/Iqy6kt/m/ifcqdS9z94cw/yi9vNqj97XVq3c1lxl DpYwCGtrFYgRlVpkbY5AwUEcr4Wagd/ZjKRq1Ppl6oBWzLyPZzzTWD1r7hT80eGYbKdr 6Pp73j3oORcy6nfImOSNrGVG59LliQ2WGfGL4j13VhTts0K+vy0LeZCVEPn+Ci7GUehU yebEKEEnJ+9OqV4NXtyCGGs/uWVjX6v9BUeKpo/u8FkDIKbzqOlfRh2wThD9u/n5Tq30 4YpaTpu7jc2sWH0SaYmD0P//HBVB+wxO8U4EdeASW9R8fCcZkvKx8AaHYwwIvdkWcK80 YIdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693489887; x=1694094687; 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=CCIIRv3lKFoD8HPnmS3rt0qnK4c1JCFf4jJc+7DI2ok=; b=j3UgMmaqvIwrqoGfJ7Kv92/vVUkDRPj1h5EawV5/FHlrfIZLwKCrR53ZxEV4y6mI1x fwqvKOPDuRbnYHWNXgAgWz+11vTmXUpUnFO9QJIVLXduHrV4ToTeWtIaGdrbNjKZMHwA JJbqS2AL9telE4Fr7Rn9XY9DG+dWyseFPKTRz5/dVvRqZ5zS4GApW4EmgrarmilfQg88 XqPuSqPh9PK0k894QwS3rFuA90d77JtbG4c88cDZn7uCf2+5FyTCah7XbIUyuo1ivUga KsYyY3PAsQ4tvo+tboA1NArvIBHeUhls/DPf291lozHoysxVEV8EfVqCDaThi1TldIRN nDCQ== X-Gm-Message-State: AOJu0Ywu8fOd3ZggixRlVAea60JvJusCg+Shj6jLnIK40+/xjgBblixb a4jQQvgBiMS8BbZ6FHQHL4I= X-Google-Smtp-Source: AGHT+IHSqWxqztR393V9OAybp3h8yLQIAwG8Frfmknhg/YGlwWRU7XsbmgsGpTs7WvCHV0ug+u2ogg== X-Received: by 2002:a17:902:a414:b0:1c1:ecff:a637 with SMTP id p20-20020a170902a41400b001c1ecffa637mr4578887plq.15.1693489887394; Thu, 31 Aug 2023 06:51:27 -0700 (PDT) Received: from [172.31.0.23] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id ik21-20020a170902ab1500b001b9f032bb3dsm1310184plb.3.2023.08.31.06.51.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 31 Aug 2023 06:51:26 -0700 (PDT) Message-ID: <2b3c7a2a-6e7f-78f9-7453-c2f91ea40b4a@gmail.com> Date: Thu, 31 Aug 2023 07:51:25 -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> From: Jeff Law In-Reply-To: <20230830215708.369610-1-vineetg@rivosinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,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/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. 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. > > and matches define_insn "*czero.nez..opt2" > > | (insn 41 20 38 3 (set (reg/v:DI 136 [ x ]) > | (if_then_else:DI (ne (reg/v:DI 134 [ a ]) > | (const_int 0 [0])) > | (reg/v:DI 136 [ x ]) > | (reg/v:DI 134 [ a ]))) {*czero.nez.didi.opt2} > > The corresponding asm pattern generates > czero.nez x, x, a ; %0, %2, %1 > implying > "x = (a != 0) ? 0 : a" I get this from the RTL pattern: x = (a != 0) ? x : a x = (a != 0) ? x : 0 I think you got the arms reversed. > > which is not what the pattern semantics are. > > Essentially "(a != 0) ? x : a" cannot be expressed with CZERO.nez Agreed, but I think you goof'd earlier :-) Jeff