From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc33.google.com (mail-oo1-xc33.google.com [IPv6:2607:f8b0:4864:20::c33]) by sourceware.org (Postfix) with ESMTPS id 4F8D53856DCA for ; Mon, 20 Nov 2023 07:10:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F8D53856DCA 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 4F8D53856DCA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700464254; cv=none; b=EQgs5+XbHcejRbXotKFrv3Rg57syouTvXL1pttELADNjXsODMHJ3siORJJ20v5Ta5p6nG9VhOmPqaBmvVcicPNsQpqAxU1djieowXkhxHiUztkVWh5Im29ZeJ3XzPQV/Of2Yzi00IAxMshQRe1jkJqaAh2qtSg4YmR/T9EBCk/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700464254; c=relaxed/simple; bh=J3Qw8T1dDoSz3ZKKOwyq5es9tr1OKhIYxBVN/hF/T4g=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=PBiyhyKM2G6LeNiMoFQz7JXte0580mJsnuTxiZUt/jUV7J2zLKtkW1tlSbZlhb0PtaY7iAMoQLa/4HTIENWEWTbWG/HdV+6Bfv9No9GAnhxuo8XKxT4s4C0/ePk9Y8GiuFquUd/XtiBcsL9Vxt5l346N3cZPJfqoKqL8NeAugus= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-5842a94feb2so2402584eaf.0 for ; Sun, 19 Nov 2023 23:10:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700464252; x=1701069052; 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=GkQztqkyUTSQk1q3UQO9Lml/8KHjycuEoZO8JqfL8qs=; b=DxFgovDB5DghSw+3D1uOVFMGFs6fz/jGK26bOC9YpOwC+OtVj2QbjiOT/npYe2cSY5 INYHwkNpCeXSoq7Q4nd4olMsZPYg2rZfodqbzk60a/BSpQlIOKOQT2izcubEppIty5ss m5v/OhUbk5f7NjUbKBMCxX2nDEUaaByYlgxf52FuGWkEOyeWlcoY0+BrNVwVpd8tc2ZF DbwawSbgS2MJiPv8wNDZTlpWxc3CJNAbDmWFTGw8xkVDa+bOTvLLw64plDKyb0gX6eQI Rg2FhqKLFox2wHzKjBd9oBjn+3SWdlUMkWfezz7nXlTdpWmAWOngK2XsR1Nbh7PwojcE nCaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700464252; x=1701069052; 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=GkQztqkyUTSQk1q3UQO9Lml/8KHjycuEoZO8JqfL8qs=; b=njU4yfbvyj3ewGotSOYEp9/Fo51ZFqF9jycTVJRRNcfAh+Nb+1vYmWArTfGzDwEhs1 2Ljo/gc110tWxE7nWcPyTM7u9s/p/SCvu20lXYNUvGpUXSYciuFF5jmTReEG+xPYBmov QUQhPD9BBXvDSZ89Gx55Qz7PP5XrFQQ0Cp5oAvEFgWe6xPCh95g55qv9yg6QDXW1Oeig H1uEsS5bBIqVQMS2kNndAYAGUmXRy9mLgmy8V6ZNYk8cbFBs+P11s61+rcQCogFEWEF6 eaZCRjwACxtKGjwmo8tsvfXfuxMJNuWOamuj3nub15plY7skoAuhk7PDX+pb/gzEOIdV bGSA== X-Gm-Message-State: AOJu0YwLWzqg5iWylRhJn6ojfRe2K8PtbovYfPaMSpJRiP3aelYGDghU hxDrtJxtEVifIa/aubktlug= X-Google-Smtp-Source: AGHT+IGfhq9yP8fkQglP3HhJ58/+cKukDTzZ5IhZZUgY4pWZY77Gtz0t0mfnVVBmNVyZNF4tQShxdQ== X-Received: by 2002:a4a:9214:0:b0:58a:81e8:a04b with SMTP id f20-20020a4a9214000000b0058a81e8a04bmr5710117ooh.9.1700464252559; Sun, 19 Nov 2023 23:10:52 -0800 (PST) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id d5-20020a4aaa85000000b0058737149513sm1273295oon.24.2023.11.19.23.10.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Nov 2023 23:10:52 -0800 (PST) Message-ID: Date: Mon, 20 Nov 2023 00:10:51 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/4] [ifcvt] if convert x=c ? y&z : y by RISC-V Zicond like insns Content-Language: en-US To: Fei Gao , gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com References: <20231030072523.26818-1-gaofei@eswincomputing.com> <20231030072523.26818-5-gaofei@eswincomputing.com> From: Jeff Law In-Reply-To: <20231030072523.26818-5-gaofei@eswincomputing.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,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 List-Id: On 10/30/23 01:25, Fei Gao wrote: > diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc > index 6e341fc4d4b..cfa9bc4b850 100644 > --- a/gcc/ifcvt.cc > +++ b/gcc/ifcvt.cc > @@ -2911,7 +2911,7 @@ noce_try_sign_mask (struct noce_if_info *if_info) > static bool > noce_cond_zero_binary_op_supported (enum rtx_code op) > { > - if (op == PLUS || op == MINUS || op == IOR || op == XOR) > + if (op == PLUS || op == MINUS || op == IOR || op == XOR || op == AND) > return true; Include ASHIFT, LSHIFTRT, ASHIFTRT, ROTATE, ROTATERT. That should pick up that critical conditional-shift-by-6 in leela. > + if (opcode == AND) > + { > + tmp > + = expand_simple_binop (mode, AND, common, z, NULL_RTX, 0, OPTAB_DIRECT); OPTAB_WIDEN here I think. > + if (!tmp) > + { > + end_sequence (); > + return FALSE; > + } > > - /* If we have x = c ? x + z : x, use a new reg to avoid modifying x */ > - if (common && rtx_equal_p (common, if_info->x)) > - target = gen_reg_rtx (mode); > - else > - target = if_info->x; > + target = noce_emit_czero (if_info, czero_code, common, if_info->x); > + if (!target) > + { > + end_sequence (); > + return FALSE; Please try to be consistent with upper/lower case. In your prior patches you used lower case for true/false. In this patch you're using upper case. Lower case seems to be the standard in that file, so use lower case. > + } > > - target = noce_emit_czero (if_info, czero_code, z, target); > - if (!target) > - { > - end_sequence (); > - return false; > + target = expand_simple_binop (mode, IOR, tmp, target, if_info->x, 0, > + OPTAB_DIRECT); > } > + else > + { > + /* If we have x = c ? x + z : x, use a new reg to avoid modifying x */ > + if (common && rtx_equal_p (common, if_info->x)) > + target = gen_reg_rtx (mode); > + else > + target = if_info->x; As noted before you may not be able to generate a new register when ifcvt is run after register allocation. Your code needs to handle that correctly. > + > + target = noce_emit_czero (if_info, czero_code, z, target); > + if (!target) > + { > + end_sequence (); > + return false; > + } > > - target = expand_simple_binop (mode, opcode, common, target, if_info->x, 0, > - OPTAB_DIRECT); > + target = expand_simple_binop (mode, opcode, common, target, if_info->x, 0, > + OPTAB_DIRECT); OPTAB_WIDEN. And the usual comments about avoiding explicit registers in the tests. I would suggest you try to handle this case as well, I don't think it's handled by your current code: long eq2 (long a, long b) { if (a == 0) return b; return 0; } There's probably also a negated version of that to be handled as well. Overall I think we can go forward with your patches after things are fixed. I'm inclined to wait until after Maciej has integrated his changes before actually committing them. While I don't expect problems, I wouldn't want Maciej to have to respin a 40+ patch series. Note that while we transition to stage3 development today, your patch was posted while we were in stage1, so you've met the deadline. We just need to get the updates done relatively soon rather than having it drag late into stage3. Jeff