From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id 0DC5938618B3 for ; Fri, 27 Oct 2023 22:39:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0DC5938618B3 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0DC5938618B3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::22d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698446379; cv=none; b=GFoudi47bbl8QQTYVByHWXpuRu5Q7EaGg4c74KucqOA1Zx+hkZ+L7pcvs/nQj8cD7fHzoHt50bdAarwXa/8gx/1CtuK6TKvJGoyNiqeHSBhJEyZ+CWYYuUWkOoErPXkE0kQNbpgsN/nF7SeF6c4Bna1+4XDAwL7zqhimSm93I8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698446379; c=relaxed/simple; bh=S9ABAPjDeTKfCCz4wmevSjuQi2ql6gVln68h99ObBrc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=f/lEUuWC/58vGHIj7ixE3GadvsGldEu/nAQwvZJpVL4W8bo3DjVFvAdIZ0BDJw6LinqoTLKnTH3Jolqno7GrZHeG85+S5/28p3Gpt9F+bCQQs0rpvMg0MUfCYzyZKvmLQAnlfp12G4MSIggB5GQzBupiDozfjb7Wk9cZpCU4VRQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3b4145e887bso1494883b6e.3 for ; Fri, 27 Oct 2023 15:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1698446377; x=1699051177; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=HXMi6kev5iv6IhGPSqmhYZwPFOy5r+JbOaJgORPn8gM=; b=SlRrjCEvC55zApeigKdIJs8zTUP2UbASaGBcrZqIbm7SqVYK+oWCHEM270W8CnH72w SSp+xnZggEK4NEUzPM46DBELJQI2BROWkQ5ZjP3EDSG0aBvtoOJZXVhU/3PG3DVQLBmm vJpI67pi0JQmQn8ehP9nb4iFrq7D5baYRYFc4yHIVacpTgYzw4R3b2y7hCIdr2078ozP 73rt7BVw54LxUekHeZ5aj6jqEGDkEr9+72sN5w201zB8GoNpYFs7eCpX2wohjqXcANhF 9GkR9PE1dftxfH/Il04Iclz7UympdPu1ZyFFN4hiC02+5k5wb955HyGJ/0mcwGnbqlLI r3Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698446377; x=1699051177; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HXMi6kev5iv6IhGPSqmhYZwPFOy5r+JbOaJgORPn8gM=; b=MuLlRFmcL7a9UCWU35gB6KIuB4A5yub0Lb1Fv/A6A8TS9DjRpErgeX8RFVwL0Nb8s1 iCac478zpegkjABXLjzLo7GqgCNoTPxK2yUwMQG9bK4aMq7clncVG4i8/bNiqwkKP7xM wfhiQY/abG7mlOpKrt86b0hpVsDIR30Q/Ksx2jvNfIMBffNQPlQC6q2hydgBnhEc1cRk uqE3d8kyuAm1Gp/1pnTk0RnL8SVsEUNr3hutCSaGiGSNC+W88xwx+BdEoKn8FVFXmQd+ y0ODwqW1DWQldZxcj8n7YINATBztBx2ONHGkRGBR3C1YpVDWb+3w7JFZZrvssb4CECZf hCZw== X-Gm-Message-State: AOJu0YwufhS7QeCgBoKz/jb9eyPK+nPAsUwhfkt5xcGMTzjhj9exVsFt +rnwdSIEQOYWpmny2+4GvfJXMg== X-Google-Smtp-Source: AGHT+IErchGzsKKVchMtsppCIm1ExT8NKAh6RikPdq42PSMh6ZGMHrPmbxMHdJyCucvkEp3rJvEDRg== X-Received: by 2002:a54:4590:0:b0:3a7:5a6:e0b1 with SMTP id z16-20020a544590000000b003a705a6e0b1mr4053483oib.10.1698446377367; Fri, 27 Oct 2023 15:39:37 -0700 (PDT) Received: from [192.168.50.117] (c-98-210-197-24.hsd1.ca.comcast.net. [98.210.197.24]) by smtp.gmail.com with ESMTPSA id 13-20020aca0d0d000000b003ae540759a0sm457150oin.40.2023.10.27.15.39.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Oct 2023 15:39:36 -0700 (PDT) Message-ID: <1f218675-3196-4b51-b08a-bb122501c306@rivosinc.com> Date: Fri, 27 Oct 2023 15:39:35 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 4/4] ree: Improve ree pass for rs6000 target using defined ABI interfaces To: Bernhard Reutner-Fischer , Ajit Agarwal Cc: gcc-patches@gcc.gnu.org, Jeff Law , Richard Biener , Segher Boessenkool , Peter Bergner , gnu-toolchain References: <32ca6e0e-ef68-4d4d-b864-c586a688b2c7@linux.ibm.com> <22541c92-a967-4e66-96b3-e4ad5011cd24@rivosinc.com> <20231023161027.362c626b@nbbrfq.loc> <8da41716-1111-4550-95dd-de41a402101e@linux.ibm.com> <4077DE16-87DA-4DDE-B119-6B516944B632@gmail.com> <7379c85b-178c-4196-a929-129052245165@linux.ibm.com> <20231027191612.068c67ee@nbbrfq.loc> Content-Language: en-US From: Vineet Gupta In-Reply-To: <20231027191612.068c67ee@nbbrfq.loc> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,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 10/27/23 10:16, Bernhard Reutner-Fischer wrote: > On Wed, 25 Oct 2023 16:41:07 +0530 > Ajit Agarwal wrote: > >> On 25/10/23 2:19 am, Vineet Gupta wrote: >>> On 10/24/23 13:36, rep.dot.nop@gmail.com wrote: >>>>>>>> As said, I don't see why the below was not cleaned up before the V1 submission. >>>>>>>> Iff it breaks when manually CSEing, I'm curious why? >>>>>> The function below looks identical in v12 of the patch. >>>>>> Why didn't you use common subexpressions? >>>>>> ba >>>>> Using CSE here breaks aarch64 regressions hence I have reverted it back >>>>> not to use CSE, >>>> Just for my own education, can you please paste your patch perusing common subexpressions and an assembly diff of the failing versus working aarch64 testcase, along how you configured that failing (cross-?)compiler and the command-line of a typical testcase that broke when manually CSEing the function below? >>> I was meaning to ask this before, but what exactly is the CSE issue, manually or whatever. > If nothing else it would hopefully improve the readability. > >>> >> Here is the abi interface where I CSE'D and got a mail from automated regressions run that aarch64 >> test fails. > We already concluded that this failure was obviously a hiccup on the > testers, no problem. > >> +static inline bool >> +abi_extension_candidate_return_reg_p (int regno) >> +{ >> + return targetm.calls.function_value_regno_p (regno); >> +} > But i was referring to abi_extension_candidate_p :) > > your v13 looks like this: > > +static bool > +abi_extension_candidate_p (rtx_insn *insn) > +{ > + rtx set = single_set (insn); > + machine_mode dst_mode = GET_MODE (SET_DEST (set)); > + rtx orig_src = XEXP (SET_SRC (set), 0); > + > + if (!FUNCTION_ARG_REGNO_P (REGNO (orig_src)) > + || abi_extension_candidate_return_reg_p (REGNO (orig_src))) > + return false; > + > + /* Return FALSE if mode of destination and source is same. */ > + if (dst_mode == GET_MODE (orig_src)) > + return false; > + > + machine_mode mode = GET_MODE (XEXP (SET_SRC (set), 0)); > + bool promote_p = abi_target_promote_function_mode (mode); > + > + /* Return FALSE if promote is false and REGNO of source and destination > + is different. */ > + if (!promote_p && REGNO (SET_DEST (set)) != REGNO (orig_src)) > + return false; > + > + return true; > +} > > and i suppose it would be easier to read if phrased something like > > static bool > abi_extension_candidate_p (rtx_insn *insn) > { > rtx set = single_set (insn); > rtx orig_src = XEXP (SET_SRC (set), 0); > unsigned int src_regno = REGNO (orig_src); > > /* Not a function argument reg or is a function values return reg. */ > if (!FUNCTION_ARG_REGNO_P (src_regno) > || abi_extension_candidate_return_reg_p (src_regno)) > return false; > > rtx dst = SET_DST (set); > machine_mode src_mode = GET_MODE (orig_src); > > /* Return FALSE if mode of destination and source is the same. */ > if (GET_MODE (dst) == src_mode) > return false; > > /* Return FALSE if the FIX THE COMMENT and REGNO of source and destination > is different. */ > if (!abi_target_promote_function_mode_p (src_mode) > && REGNO (dst) != src_regno) > return false; > > return true; > } > > so no, that's not exactly better. > > Maybe just do what the function comment says (i did not check the "not > promoted" part, but you get the idea): > > ^L > > /* Return TRUE if > reg source operand is argument register and not return register, > mode of source and destination operand are different, > if not promoted REGNO of source and destination operand are the same. */ > static bool > abi_extension_candidate_p (rtx_insn *insn) > { > rtx set = single_set (insn); > rtx orig_src = XEXP (SET_SRC (set), 0); > > if (FUNCTION_ARG_REGNO_P (REGNO (orig_src)) > && !abi_extension_candidate_return_reg_p (REGNO (orig_src)) > && GET_MODE (SET_DST (set)) != GET_MODE (orig_src) > && abi_target_promote_function_mode_p (GET_MODE (orig_src)) > && REGNO (SET_DST (set)) == REGNO (orig_src)) > return true; > > return false; > } This may have been my doing as I asked to split out the logic as some of the conditions merit more commentary. e.g. why does the mode need to be same But granted this is the usual coding style in gcc and the extra comments could still be added before the big if -Vineet > > I think this is much easier to actually read (and that's why good > function comments are important). In the end it's not important and > just personal preference. > Either way, I did not check the plausibility of the logic therein. > >> >> I have not done any assembly diff as myself have not cross compiled with aarch64. > fair enough.