From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe2c.google.com (mail-vs1-xe2c.google.com [IPv6:2607:f8b0:4864:20::e2c]) by sourceware.org (Postfix) with ESMTPS id 0304A3858413 for ; Wed, 19 Jul 2023 17:27:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0304A3858413 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cs.washington.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.washington.edu Received: by mail-vs1-xe2c.google.com with SMTP id ada2fe7eead31-440bc794fcdso2326555137.3 for ; Wed, 19 Jul 2023 10:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1689787661; x=1692379661; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qmL94A/pF8+9K01d8oQdn9rtDTq6nAD/ojKHbbLk0Iw=; b=djLbBpI9bxrmtAkWDT3OSkSr+lBsuQGDR+85gMBi4aZ+iczRnzbx1s5wEexgcsPhdq UJyKvL2tPU8gQp1h+q1vHIqXsQVO1esByiPdPU14mHlRM89Ki8XF7bY5mPKxWKWZ0IdR VKeg4Rw7/awnAy1y4yiw3GX1f0PVF5SUka2ck= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689787661; x=1692379661; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qmL94A/pF8+9K01d8oQdn9rtDTq6nAD/ojKHbbLk0Iw=; b=QNgxbjEJibeoiHBQu9cgQ5Py27N7A2tZ9BArJ7tnyJp5OLO6m0Q5W+U3xoTtx6e2/K 3uBJb4mJ8sI/sF7cwPFLBHDKhOnShn8K8NQI/C7ZK7OVwtKn7co3CHQQZPlGDCnLlo+n /eKj/24khFvzFL374eSm1VQ91KLkzo331tZNPIM6c1wdDphqglWFjbVcTjCiJBH/7xaK 5mmREhHW90QG3oE9UPKQgd44UMjqG5rXRAI2umzqSJIYAGLBQcTZqmfmrYr+FUwygtdL ODXA4U8te038QOGqgn2RWDApT4p5Vin20PMEzSedJwIqr3dNb6ud8r7p5yJLXlFsNYhM IWkQ== X-Gm-Message-State: ABy/qLbWmi8FJOa0GBBJbqqn3lWH1My2azCywErP5pE9RrbsUYaF9gmO JZAPhBN+fwmO5AJ+63QHvAuOjdNWJw10OhF+NMsYOA== X-Google-Smtp-Source: APBJJlFF30wJkuNtfJkcM0xuLlCq6tURaFLsBi8/AnZebhmlHe2wnFZSM35fOBBlBjCLsvyhhdcyFcpXXwMsuaegOsU= X-Received: by 2002:a67:fd62:0:b0:440:981b:3840 with SMTP id h2-20020a67fd62000000b00440981b3840mr2177415vsa.31.1689787661293; Wed, 19 Jul 2023 10:27:41 -0700 (PDT) MIME-Version: 1.0 References: <20230718233301.28677-1-kmatsui@gcc.gnu.org> In-Reply-To: From: Ken Matsui Date: Wed, 19 Jul 2023 10:27:25 -0700 Message-ID: Subject: Re: [PATCH 0/8] Tweak predicate macros in tree To: Richard Biener Cc: Ken Matsui , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 Wed, Jul 19, 2023 at 12:08=E2=80=AFAM Richard Biener wrote: > > On Wed, Jul 19, 2023 at 1:34=E2=80=AFAM Ken Matsui via Gcc-patches > wrote: > > > > This patch series tweaks predicate macros in tree.h to make the code mo= re > > readable. TYPE_REF_P is moved to tree.h and used for INDIRECT_TYPE_P an= d > > TYPE_REF_IS_LVALUE. TYPE_PTR_P is also moved to tree.h and used for > > INDIRECT_TYPE_P. POINTER_TYPE_P in tree.h is replaced with INDIRECT_TYP= E_P > > since it is ambiguous. TYPE_REF_IS_LVALUE is defined in tree.h through > > TYPE_REF_P and TYPE_REF_IS_RVALUE. The same behavior codes with those > > predicate macros are replaced for clarity. > > > > These works were all the way up to implementing __is_lvalue_reference > > built-in trait and optimizing the is_lvalue_reference trait. However, t= hose > > changes were dropped since I did not observe any performance improvemen= ts. > > For those who are interested in the benchmark results, they can be foun= d > > below: > > > > 1. is_lvalue_reference > > > > https://github.com/ken-matsui/gcc-benches/blob/main/is_lvalue_reference= .md#tue-jul-18-033708-pm-pdt-2023 > > > > Time: +1.35432% > > Peak Memory Usage: -0.103283% > > Total Memory Usage: No difference > > > > 2. is_lvalue_reference_v > > > > https://github.com/ken-matsui/gcc-benches/blob/main/is_lvalue_reference= _v.md#tue-jul-18-034236-pm-pdt-2023 > > > > Time: No difference > > Peak Memory Usage: -0.426872% > > Total Memory Usage: -0.677638% > > > > Ken Matsui (8): > > c++, tree: Move TYPE_REF_P to tree.h > > gcc: Use TYPE_REF_P > > c++, tree: Move TYPE_PTR_P to tree.h > > c++, tree: Move INDIRECT_TYPE_P to tree.h > > gcc: Use INDIRECT_TYPE_P instead of POINTER_TYPE_P > > No, please not. Definitely not. The tree code of POINTER_TYPE_P is > POINTER_TYPE so the predicate name is exactly correct. > REFERENCE_TYPE_P would be the canonical predicate for REFERENCE_TYPE, > not TYPE_REF_P. > > I don't think the C++ frontend should be the one to decide about middle-e= nd > tree predicate macros. > Hi Richard, Thank you for your review! This is because of the comment, which states that POINTER_TYPE_P should be renamed to INDIRECT_TYPE_P. /* Nonzero if TYPE represents a pointer or reference type. (It should be renamed to INDIRECT_TYPE_P.) Keep these checks in ascending code order. */ #define POINTER_TYPE_P(TYPE) \ (TREE_CODE (TYPE) =3D=3D POINTER_TYPE || TYPE_REF_P (TYPE)) Also, INDIRECT_TYPE_P is equivalent to POINTER_TYPE_P. #define INDIRECT_TYPE_P(NODE) \ (TYPE_PTR_P (NODE) || TYPE_REF_P (NODE)) #define TYPE_PTR_P(NODE) \ (TREE_CODE (NODE) =3D=3D POINTER_TYPE) IMHO, POINTER_TYPE_P and TYPE_PTR_P are confusing since POINTER_TYPE_P involves TYPE_REF_P but TYPE_PTR_P does not. If this renaming is still incorrect, I think we should at least remove the comment in POINTER_TYPE_P. Could you please confirm whether or not this patch is correct? Thank you! Sincerely, Ken > > tree: Remove POINTER_TYPE_P > > tree: Define TYPE_REF_IS_LVALUE > > c++, lto: Use TYPE_REF_IS_LVALUE > > > > gcc/ada/gcc-interface/ada-tree.h | 2 +- > > gcc/ada/gcc-interface/decl.cc | 6 +- > > gcc/ada/gcc-interface/trans.cc | 16 +-- > > gcc/ada/gcc-interface/utils.cc | 12 +- > > gcc/ada/gcc-interface/utils2.cc | 14 +- > > gcc/alias.cc | 12 +- > > gcc/analyzer/analyzer.cc | 4 +- > > gcc/analyzer/call-details.h | 2 +- > > gcc/analyzer/call-summary.cc | 2 +- > > gcc/analyzer/checker-event.cc | 4 +- > > gcc/analyzer/constraint-manager.cc | 2 +- > > gcc/analyzer/engine.cc | 4 +- > > gcc/analyzer/program-state.cc | 2 +- > > gcc/analyzer/region-model-manager.cc | 6 +- > > gcc/analyzer/region-model.cc | 6 +- > > gcc/analyzer/sm.cc | 4 +- > > gcc/analyzer/svalue.cc | 2 +- > > gcc/analyzer/varargs.cc | 2 +- > > gcc/asan.cc | 4 +- > > gcc/builtins.cc | 24 ++-- > > gcc/c-family/c-ada-spec.cc | 2 +- > > gcc/c-family/c-attribs.cc | 32 ++--- > > gcc/c-family/c-common.cc | 41 +++--- > > gcc/c-family/c-omp.cc | 8 +- > > gcc/c-family/c-pretty-print.cc | 4 +- > > gcc/c-family/c-ubsan.cc | 10 +- > > gcc/c-family/c-warn.cc | 34 ++--- > > gcc/c/c-decl.cc | 8 +- > > gcc/c/c-parser.cc | 4 +- > > gcc/c/c-typeck.cc | 40 +++--- > > gcc/c/gimple-parser.cc | 8 +- > > gcc/calls.cc | 2 +- > > gcc/cfgexpand.cc | 6 +- > > gcc/cgraph.cc | 2 +- > > gcc/cgraphunit.cc | 2 +- > > gcc/config/aarch64/aarch64-builtins.cc | 2 +- > > gcc/config/aarch64/aarch64-sve-builtins.cc | 2 +- > > gcc/config/aarch64/aarch64.cc | 6 +- > > gcc/config/arc/arc.cc | 2 +- > > gcc/config/arm/arm-builtins.cc | 6 +- > > gcc/config/arm/arm-mve-builtins.cc | 2 +- > > gcc/config/avr/avr.cc | 6 +- > > gcc/config/epiphany/epiphany.cc | 2 +- > > gcc/config/gcn/gcn-tree.cc | 2 +- > > gcc/config/gcn/gcn.cc | 6 +- > > gcc/config/i386/i386-builtins.cc | 2 +- > > gcc/config/i386/i386-options.cc | 2 +- > > gcc/config/i386/i386.cc | 10 +- > > gcc/config/m32c/m32c.cc | 2 +- > > gcc/config/m68k/m68k.cc | 4 +- > > gcc/config/mips/mips.cc | 2 +- > > gcc/config/mn10300/mn10300.cc | 2 +- > > gcc/config/msp430/msp430.cc | 2 +- > > gcc/config/nios2/nios2.cc | 2 +- > > gcc/config/pa/pa.cc | 4 +- > > gcc/config/pru/pru-passes.cc | 2 +- > > gcc/config/pru/pru.cc | 2 +- > > gcc/config/rs6000/rs6000-builtin.cc | 4 +- > > gcc/config/rs6000/rs6000-c.cc | 10 +- > > gcc/config/rs6000/rs6000.cc | 4 +- > > gcc/config/s390/s390-c.cc | 2 +- > > gcc/config/s390/s390.cc | 12 +- > > gcc/config/sparc/sparc.cc | 2 +- > > gcc/convert.cc | 4 +- > > gcc/cp/class.cc | 4 +- > > gcc/cp/constexpr.cc | 8 +- > > gcc/cp/coroutines.cc | 4 +- > > gcc/cp/cp-gimplify.cc | 2 +- > > gcc/cp/cp-tree.h | 12 -- > > gcc/cp/decl.cc | 5 +- > > gcc/cp/init.cc | 5 +- > > gcc/cp/method.cc | 5 +- > > gcc/cp/pt.cc | 8 +- > > gcc/cp/semantics.cc | 18 +-- > > gcc/cp/tree.cc | 2 +- > > gcc/cp/typeck.cc | 4 +- > > gcc/d/d-attribs.cc | 6 +- > > gcc/d/d-builtins.cc | 2 +- > > gcc/d/d-codegen.cc | 12 +- > > gcc/d/d-convert.cc | 12 +- > > gcc/d/expr.cc | 10 +- > > gcc/d/intrinsics.cc | 12 +- > > gcc/dojump.cc | 4 +- > > gcc/dwarf2out.cc | 2 +- > > gcc/emit-rtl.cc | 2 +- > > gcc/expmed.cc | 2 +- > > gcc/expr.cc | 22 +-- > > gcc/fold-const.cc | 58 ++++---- > > gcc/fortran/trans-array.cc | 36 ++--- > > gcc/fortran/trans-decl.cc | 32 ++--- > > gcc/fortran/trans-expr.cc | 106 +++++++------- > > gcc/fortran/trans-intrinsic.cc | 28 ++-- > > gcc/fortran/trans-io.cc | 8 +- > > gcc/fortran/trans-openmp.cc | 88 ++++++------ > > gcc/fortran/trans-stmt.cc | 14 +- > > gcc/fortran/trans-types.cc | 8 +- > > gcc/fortran/trans.cc | 14 +- > > gcc/function-abi.cc | 2 +- > > gcc/function.cc | 6 +- > > gcc/gimple-array-bounds.cc | 6 +- > > gcc/gimple-expr.cc | 8 +- > > gcc/gimple-fold.cc | 20 +-- > > gcc/gimple-loop-versioning.cc | 4 +- > > gcc/gimple-low.cc | 2 +- > > gcc/gimple-pretty-print.cc | 4 +- > > gcc/gimple-range-cache.cc | 4 +- > > gcc/gimple-range-fold.cc | 2 +- > > gcc/gimple-range-infer.cc | 2 +- > > gcc/gimple-range-path.cc | 4 +- > > gcc/gimple-ssa-isolate-paths.cc | 6 +- > > gcc/gimple-ssa-nonnull-compare.cc | 4 +- > > gcc/gimple-ssa-sprintf.cc | 4 +- > > gcc/gimple-ssa-store-merging.cc | 6 +- > > gcc/gimple-ssa-strength-reduction.cc | 22 +-- > > gcc/gimple-ssa-warn-access.cc | 8 +- > > gcc/gimple-ssa-warn-restrict.cc | 6 +- > > gcc/gimple.cc | 10 +- > > gcc/gimplify.cc | 44 +++--- > > gcc/go/go-gcc.cc | 2 +- > > gcc/godump.cc | 4 +- > > gcc/graphite-isl-ast-to-gimple.cc | 8 +- > > gcc/graphite-sese-to-poly.cc | 2 +- > > gcc/ipa-cp.cc | 4 +- > > gcc/ipa-devirt.cc | 8 +- > > gcc/ipa-free-lang-data.cc | 8 +- > > gcc/ipa-icf-gimple.cc | 2 +- > > gcc/ipa-icf.cc | 6 +- > > gcc/ipa-modref-tree.cc | 2 +- > > gcc/ipa-modref.cc | 8 +- > > gcc/ipa-param-manipulation.cc | 4 +- > > gcc/ipa-polymorphic-call.cc | 6 +- > > gcc/ipa-prop.cc | 28 ++-- > > gcc/ipa-sra.cc | 4 +- > > gcc/jit/dummy-frontend.cc | 2 +- > > gcc/langhooks.cc | 2 +- > > gcc/lto-streamer-out.cc | 4 +- > > gcc/lto/lto-common.cc | 10 +- > > gcc/lto/lto-lang.cc | 2 +- > > gcc/lto/lto-symtab.cc | 2 +- > > gcc/m2/gm2-gcc/m2expr.cc | 12 +- > > gcc/m2/gm2-gcc/m2tree.cc | 2 +- > > gcc/m2/gm2-gcc/m2treelib.cc | 2 +- > > gcc/m2/m2pp.cc | 4 +- > > gcc/match.pd | 48 +++---- > > gcc/objc/objc-act.cc | 32 ++--- > > gcc/objc/objc-encoding.cc | 2 +- > > gcc/objc/objc-gnu-runtime-abi-01.cc | 4 +- > > gcc/objc/objc-next-runtime-abi-01.cc | 4 +- > > gcc/objc/objc-next-runtime-abi-02.cc | 6 +- > > gcc/omp-expand.cc | 156 ++++++++++----------- > > gcc/omp-general.cc | 10 +- > > gcc/omp-low.cc | 45 +++--- > > gcc/omp-oacc-neuter-broadcast.cc | 8 +- > > gcc/omp-offload.cc | 2 +- > > gcc/omp-simd-clone.cc | 28 ++-- > > gcc/pointer-query.cc | 12 +- > > gcc/predict.cc | 4 +- > > gcc/range-op.cc | 4 +- > > gcc/rust/backend/rust-tree.cc | 2 +- > > gcc/rust/rust-gcc.cc | 2 +- > > gcc/sese.cc | 2 +- > > gcc/tree-affine.cc | 12 +- > > gcc/tree-cfg.cc | 38 ++--- > > gcc/tree-chrec.cc | 14 +- > > gcc/tree-chrec.h | 4 +- > > gcc/tree-core.h | 2 +- > > gcc/tree-data-ref.cc | 18 +-- > > gcc/tree-dfa.cc | 2 +- > > gcc/tree-if-conv.cc | 4 +- > > gcc/tree-inline.cc | 10 +- > > gcc/tree-nested.cc | 8 +- > > gcc/tree-object-size.cc | 10 +- > > gcc/tree-outof-ssa.cc | 2 +- > > gcc/tree-pretty-print.cc | 8 +- > > gcc/tree-profile.cc | 2 +- > > gcc/tree-scalar-evolution.cc | 8 +- > > gcc/tree-sra.cc | 2 +- > > gcc/tree-ssa-address.cc | 6 +- > > gcc/tree-ssa-alias.cc | 18 +-- > > gcc/tree-ssa-ccp.cc | 22 +-- > > gcc/tree-ssa-copy.cc | 4 +- > > gcc/tree-ssa-dom.cc | 2 +- > > gcc/tree-ssa-dse.cc | 2 +- > > gcc/tree-ssa-forwprop.cc | 6 +- > > gcc/tree-ssa-ifcombine.cc | 2 +- > > gcc/tree-ssa-loop-ch.cc | 2 +- > > gcc/tree-ssa-loop-ivopts.cc | 44 +++--- > > gcc/tree-ssa-loop-manip.cc | 10 +- > > gcc/tree-ssa-loop-niter.cc | 40 +++--- > > gcc/tree-ssa-loop-split.cc | 10 +- > > gcc/tree-ssa-phiopt.cc | 2 +- > > gcc/tree-ssa-phiprop.cc | 2 +- > > gcc/tree-ssa-reassoc.cc | 14 +- > > gcc/tree-ssa-sccvn.cc | 6 +- > > gcc/tree-ssa-strlen.cc | 10 +- > > gcc/tree-ssa-structalias.cc | 14 +- > > gcc/tree-ssa-threadedge.cc | 2 +- > > gcc/tree-ssa-uninit.cc | 10 +- > > gcc/tree-ssa.cc | 2 +- > > gcc/tree-ssanames.cc | 22 +-- > > gcc/tree-stdarg.cc | 6 +- > > gcc/tree-streamer-in.cc | 2 +- > > gcc/tree-streamer-out.cc | 2 +- > > gcc/tree-tailcall.cc | 8 +- > > gcc/tree-vect-data-refs.cc | 4 +- > > gcc/tree-vect-loop-manip.cc | 2 +- > > gcc/tree-vect-loop.cc | 4 +- > > gcc/tree-vect-stmts.cc | 18 +-- > > gcc/tree-vrp.cc | 6 +- > > gcc/tree.cc | 64 ++++----- > > gcc/tree.h | 30 ++-- > > gcc/ubsan.cc | 18 +-- > > gcc/value-pointer-equiv.cc | 4 +- > > gcc/value-pointer-equiv.h | 2 +- > > gcc/value-query.cc | 12 +- > > gcc/value-range.h | 6 +- > > gcc/var-tracking.cc | 6 +- > > gcc/varasm.cc | 10 +- > > gcc/vr-values.cc | 6 +- > > 219 files changed, 1139 insertions(+), 1148 deletions(-) > > > > -- > > 2.41.0 > >