From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 597623858D35 for ; Mon, 24 Jun 2024 22:25:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 597623858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 597623858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719267933; cv=none; b=NAZevCI1Rj19qz93UKaRgq6koYnfyafazELkm612um18kLwKvVKbd2/RvvdgGlCVOIpb1zFr9jaoGfM/ZCJ8AsNaQip0dibvOGaJjYkwb1HLqdkShdmcLjB0K9AnWAH4EUfWvJ1t8ztGA3qLM9eHjTJ54IyuVuN3wSbg2bOcqSM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719267933; c=relaxed/simple; bh=V5Kl+Kk/UP+ZZqWEUNeuwYnSOv9ucu1uDFbd4sxL8s4=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=JjJSPDZUhUAOG4iAEvzICfWmze33mtmMxpKHnStHQfzD5w1ejIt1UOzvAqPEsQv2P3B+8EZbyX9i+zCQq2gG+tWhdKKWXbJCfjs3K2fGeX84N6/ISYE0VQoQErUV+urQ/K6plOiENhwk/vdqeJISIuKTZT4q14nnk2JFoanMCIs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719267931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V5Kl+Kk/UP+ZZqWEUNeuwYnSOv9ucu1uDFbd4sxL8s4=; b=cXKxSO8I80+3FFV2ee+r6yR8OHGW4rmHRga8gw+ABQNPPHDUvMxgWnDTgY803C7cos9SeX NjGxIw/7H2EwdTkyOZV0iWIkYoc0y8FGrnhbFNiMImcYTCYG0s9Q6h1WGy22Rfquru+IHn XvLnUg/3+/Ibgiler53lydrRxrwSW6s= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-101-ZbsPgbTvPLegnHQ-G0z2Ug-1; Mon, 24 Jun 2024 18:25:29 -0400 X-MC-Unique: ZbsPgbTvPLegnHQ-G0z2Ug-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-79bc1479961so524665685a.3 for ; Mon, 24 Jun 2024 15:25:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719267929; x=1719872729; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=V5Kl+Kk/UP+ZZqWEUNeuwYnSOv9ucu1uDFbd4sxL8s4=; b=unu+o8DDiUweSUBtpeD8wMWOVnYDwqTVqtFKqZtMZosi/PT2sT/V0PnBzSHdwLsybQ yx8EQ4lTRWJquied4GwLDU9IhV1H11x1h3VYi+qlxMPjOMBpB3NX3pxHq8VxAV4uplRk qz2bGY/bRxMcCuO7ZwN0STkJPG8aTlX7woB0olRAIJV6FiRWp112vlxTeXuPB3PVI18o Kw9hjH/ogZMXdzyOgxyeWnVodANgXncBUK3G9nNVqXkQPYwWiIF751W5K80dF3kXHFJn IN3q1/6ydWod7SYTkvnBpWLsyQXxqp568RDlczJv92x5TteelqH+fMK4LF6UBBmmCbxH UGtw== X-Forwarded-Encrypted: i=1; AJvYcCVHn5FtxrL14O/Jh5MrbJxv2K1AHJ9oHn8uGFa9/lsCbQxDc4nNQQHCyIHkaCUrbs1/1J7pIw4CkqLeWAU5xVk= X-Gm-Message-State: AOJu0Yz2wZWTz+d3YTb0gWc76pL6qhuGuNbxT7tYw1XcubMKD30H8k9z PDCDPycuyTSCNED6AapECnYkI1Oyib95jA+KBLnSvs77/oWRDLo6Ok/GEySnEk+QfbxVNkrgCnY rHU7ILGIi6N/Zxa2HswoxBAkiD0k45QTTY46Wl+UqFnuE X-Received: by 2002:a05:620a:28d6:b0:796:2f2e:b547 with SMTP id af79cd13be357-79be47b9b9cmr794512185a.51.1719267928812; Mon, 24 Jun 2024 15:25:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxChcUNC2sLymw2aecrEO3PFkVYjsvMJXr8LxdoKZ3MYzsHw8xxflnP3sW/XXm4el2i6QClg== X-Received: by 2002:a05:620a:28d6:b0:796:2f2e:b547 with SMTP id af79cd13be357-79be47b9b9cmr794510985a.51.1719267928428; Mon, 24 Jun 2024 15:25:28 -0700 (PDT) Received: from t14s.localdomain (c-76-28-97-5.hsd1.ma.comcast.net. [76.28.97.5]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce89a381sm351259585a.3.2024.06.24.15.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 15:25:28 -0700 (PDT) Message-ID: <12dba2b6f5a9bf95ca3208d65b988e78aee6415a.camel@redhat.com> Subject: Re: [PATCH 10/52] jit: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE From: David Malcolm To: "Kewen.Lin" Cc: gcc-patches@gcc.gnu.org, jit@gcc.gnu.org, Richard Biener , Joseph Myers Date: Mon, 24 Jun 2024 18:25:26 -0400 In-Reply-To: References: <7c9b2ed53cee1c8c7d5b47abbf963acc2bf5a62e.1717134752.git.linkw@linux.ibm.com> <24355f0ad35a6ce7619be47c0f6cd69624d250cf.camel@redhat.com> User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 Fri, 2024-06-14 at 10:16 +0800, Kewen.Lin wrote: > Hi David, >=20 > on 2024/6/13 21:44, David Malcolm wrote: > > On Sun, 2024-06-02 at 22:01 -0500, Kewen Lin wrote: > > > Joseph pointed out "floating types should have their mode, > > > not a poorly defined precision value" in the discussion[1], > > > as he and Richi suggested, the existing macros > > > {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE will be replaced with a > > > hook mode_for_floating_type.=C2=A0 Unlike the other FEs, for the > > > uses in recording::memento_of_get_type::get_size, since > > > {float,{,long_}double}_type_node haven't been initialized > > > yet, this is to replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE > > > with calling hook targetm.c.mode_for_floating_type. > > >=20 > > > [1] > > > https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html > > >=20 > > > gcc/jit/ChangeLog: > > >=20 > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* jit-recording.cc > > > (recording::memento_of_get_type::get_size): Update > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0macros {FLOAT,DOUBLE,= LONG_DOUBLE}_TYPE_SIZE by calling > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0targetm.c.mode_for_fl= oating_type with > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0TI_{FLOAT,DOUBLE,LONG= _DOUBLE}_TYPE. > > > --- > > > =C2=A0gcc/jit/jit-recording.cc | 12 ++++++++---- > > > =C2=A01 file changed, 8 insertions(+), 4 deletions(-) > > >=20 > > > diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc > > > index 68a2e860c1f..7719b898e57 100644 > > > --- a/gcc/jit/jit-recording.cc > > > +++ b/gcc/jit/jit-recording.cc > > > @@ -21,7 +21,7 @@ along with GCC; see the file COPYING3.=C2=A0 If not > > > see > > > =C2=A0#include "config.h" > > > =C2=A0#include "system.h" > > > =C2=A0#include "coretypes.h" > > > -#include "tm.h" > > > +#include "target.h" > > > =C2=A0#include "pretty-print.h" > > > =C2=A0#include "toplev.h" > > > =C2=A0 > > > @@ -2353,6 +2353,7 @@ size_t > > > =C2=A0recording::memento_of_get_type::get_size () > > > =C2=A0{ > > > =C2=A0=C2=A0 int size; > > > +=C2=A0 machine_mode m; > > > =C2=A0=C2=A0 switch (m_kind) > > > =C2=A0=C2=A0=C2=A0=C2=A0 { > > > =C2=A0=C2=A0=C2=A0=C2=A0 case GCC_JIT_TYPE_VOID: > > > @@ -2399,13 +2400,16 @@ recording::memento_of_get_type::get_size > > > () > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 size =3D 128; > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > =C2=A0=C2=A0=C2=A0=C2=A0 case GCC_JIT_TYPE_FLOAT: > > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 size =3D FLOAT_TYPE_SIZE; > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 m =3D targetm.c.mode_for_floating_typ= e (TI_FLOAT_TYPE); > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 size =3D GET_MODE_PRECISION (m).to_co= nstant (); > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > =C2=A0=C2=A0=C2=A0=C2=A0 case GCC_JIT_TYPE_DOUBLE: > > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 size =3D DOUBLE_TYPE_SIZE; > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 m =3D targetm.c.mode_for_floating_typ= e (TI_DOUBLE_TYPE); > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 size =3D GET_MODE_PRECISION (m).to_co= nstant (); > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > =C2=A0=C2=A0=C2=A0=C2=A0 case GCC_JIT_TYPE_LONG_DOUBLE: > > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 size =3D LONG_DOUBLE_TYPE_SIZE; > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 m =3D targetm.c.mode_for_floating_typ= e > > > (TI_LONG_DOUBLE_TYPE); > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 size =3D GET_MODE_PRECISION (m).to_co= nstant (); > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > > > =C2=A0=C2=A0=C2=A0=C2=A0 case GCC_JIT_TYPE_SIZE_T: > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 size =3D MAX_BITS_PER_WORD; > >=20 > > [CCing jit mailing list] > >=20 > > Thanks for the patch; sorry for the delay in responding. > >=20 > > Did your testing include jit?=C2=A0 Note that --enable-languages=3Dall > > does > > *not* include it (due to it needing --enable-host-shared). >=20 > Thanks for the hints!=C2=A0 Yes, as noted in the cover letter, I did test > jit. > Initially I used TYPE_PRECISION ({float,{long_,}double_type_node) to > replace these just like what I proposed for the other FE changes, but > the > testing showed some failures on test-combination.c etc., by looking > into > them, I realized that this call > recording::memento_of_get_type::get_size > can happen before when we set up those type nodes.=C2=A0 Then I had to us= e > the > current approach with the new hook, it made all failures gone (no > regressions).=C2=A0 btw, test result comparison showed some more lines > with > "NA->PASS: test-threads.c.exe", since it's positive, I didn't look > into > it. >=20 > >=20 > > The jit::recording code runs=C2=A0*very* early - before toplev::main.= =C2=A0 > > For > > example, a call to gcc_jit_type_get_size can trigger the above code > > path before toplev::main has run. > >=20 > > target.h says each target should have a: > >=20 > > =C2=A0 struct gcc_target targetm =3D TARGET_INITIALIZER; > >=20 > > Has targetm.c.mode_for_floating_type been initialized enough by > > that > > static initialization?=C2=A0=20 >=20 > It depends on how to define "enough".=C2=A0 The hook has been initialized > as you pointed out, I just debugged it and confirmed target specific > hook was called as expected (rs6000_c_mode_for_floating_type on > Power) > when this jit::recording function gets called.=C2=A0 If "enough" refers t= o > something like command line options, it's not ready. >=20 > > Could the mode_for_floating_type hook be > > relying on some target-specific dynamic initialization that hasn't > > run > > yet?=C2=A0 (e.g. taking account of command-line options?) > >=20 >=20 > Yes, it could.=C2=A0 Like rs6000 port, the hook checks > rs6000_long_double_type_size > for long double (it's related to command line option -mlong-double-x) > and > some other targets like i386, also would like to check > TARGET_LONG_DOUBLE_64 > and TARGET_LONG_DOUBLE_128.=C2=A0 But I think it isn't worse than before, > without > this change (with the previous macro), we used to define the macro > with > the things related to this command line options, which are still not > ready. >=20 > #define LONG_DOUBLE_TYPE_SIZE rs6000_long_double_type_size >=20 > I debugged the code, jit::recording will see > rs6000_long_double_type_size > with the static initialized value zero, it means that the function=20 > recording::memento_of_get_type::get_size would get zero byte size for > the > type (I assume that it's unexpected for the code?).=C2=A0 With this new > hook, > although it can provide not exact type size (can be off from the one > specified by command line), it returns a reasonable size (comparing > with > the zero size).=C2=A0 From this perspective, it's slightly better? >=20 > +=C2=A0 if (ti =3D=3D TI_LONG_DOUBLE_TYPE) > +=C2=A0=C2=A0=C2=A0 return rs6000_long_double_type_size =3D=3D FLOAT_PREC= ISION_TFmode ? > TFmode > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 : > DFmode; Thanks for looking into it. Given the various points you make above, the patch is OK. Thanks Dave