From yjn@yjn-systems.com Sun Nov 1 02:51:58 2026 From: yjn@yjn-systems.com (York Jasper Niebuhr) Date: Sun, 1 Nov 2026 03:51:58 +0100 Subject: [PATCH 0/2] Preserve semantic origins through C constant folding Message-ID: <20261101025158.271216-1-yjn@yjn-systems.com> This series introduces a mechanism for preserving the semantic origins of C constant expressions which would usually be lost to frontend folding, and new BPF CO-RE capabilities that consume them. The C language frontend folds expressions such as __builtin_offsetof (struct S, field) or enum constants to raw integer constants, with no remaining association to field or enum identities. The BPF backend must retrieve such information to generate CO-RE relocations. Until now, BPF had to rely on custom builtins and copied integer constant keys in side-maps to funnel semantic intent through the C frontend. With deferred constants... * The BPF backend can automatically generate relocations for offsetof expressions that refer to offsets of structs marked with the "preserve_access_index" attribute, without the need to use a dedicated builtin function. * The BPF backend can recover the identity of the enum value handed to __builtin_preserve_enum_value without a side-map. * BPF supports a new "preserve_enum_values" attribute for enum types. When set, all occurrences of enumerators of that type automatically get corresponding relocations during BPF lowering, without the need to use a builtin everywhere. This is basically the enum equivalent to "preserve_access_index". * Other consumers, such as Selfpatch-SLR (in development) [1] can get the information they need to instrument all dependencies on field offsets or enum values. Patch 1 of this series introduces the entirely opt-in deferred constant mechanism into the C frontend. It adds a DEFERRED_CST_EXPR to represent expressions with otherwise constant semantics while postponing their final evaluation. If a struct type is explicitly marked for constant deferral (e.g. in a PLUGIN_FINISH_TYPE callback), fold_offsetof returns DEFERRED_CST_EXPRs instead of INTEGER_CST nodes for matching offset expressions. If an enum type is marked for constant deferral, its enumerators' occurrences are also resolved to DEFERRED_CST_EXPRs instead of their INTEGER_CST initial values. Patch 2 implements a BPF consumer of deferred constants that provides the improvements/features mentioned above. I'm open to any suggestions or change requests, though I am no BPF wizard, so it would be lovely to get some BPF people involved with that part of this series. Thanks, Jasper [1] https://lore.kernel.org/lkml/20261025031011.183364-1-yjn@yjn-systems.com/ York Jasper Niebuhr (2): c: deferred constant expressions bpf: CO-RE consumer of deferred constants gcc/Makefile.in | 4 +- gcc/c-family/c-common.cc | 109 ++- gcc/c/c-fold.cc | 173 +++++ gcc/c/c-typeck.cc | 55 +- gcc/config/bpf/bpf-passes.def | 1 + gcc/config/bpf/bpf-protos.h | 3 + gcc/config/bpf/bpf.cc | 24 + gcc/config/bpf/core-builtins.cc | 637 ++++++++++++++++-- gcc/deferred-cst.cc | 403 +++++++++++ gcc/deferred-cst.h | 54 ++ gcc/gimple-expr.cc | 5 + gcc/gimple.cc | 3 +- gcc/gimplify.cc | 5 + gcc/internal-fn.cc | 18 + gcc/internal-fn.def | 6 + gcc/passes.def | 1 + .../gcc.dg/plugin/deferred_cst-test.c | 80 +++ .../gcc.dg/plugin/deferred_cst_plugin.cc | 619 +++++++++++++++++ gcc/testsuite/gcc.dg/plugin/plugin.exp | 1 + .../gcc.target/bpf/core-auto-drain-1.c | 29 + .../gcc.target/bpf/core-auto-enum-value-1.c | 33 + .../gcc.target/bpf/core-auto-field-offset-1.c | 36 + gcc/tree-pass.h | 1 + gcc/tree-pretty-print.cc | 7 + gcc/tree.def | 10 + gcc/varasm.cc | 5 +- 26 files changed, 2253 insertions(+), 69 deletions(-) create mode 100644 gcc/deferred-cst.cc create mode 100644 gcc/deferred-cst.h create mode 100644 gcc/testsuite/gcc.dg/plugin/deferred_cst-test.c create mode 100644 gcc/testsuite/gcc.dg/plugin/deferred_cst_plugin.cc create mode 100644 gcc/testsuite/gcc.target/bpf/core-auto-drain-1.c create mode 100644 gcc/testsuite/gcc.target/bpf/core-auto-enum-value-1.c create mode 100644 gcc/testsuite/gcc.target/bpf/core-auto-field-offset-1.c -- 2.43.0 From yjn@yjn-systems.com Sun Nov 1 02:53:37 2026 From: yjn@yjn-systems.com (York Jasper Niebuhr) Date: Sun, 1 Nov 2026 03:53:37 +0100 Subject: [PATCH 1/2] c: deferred constant expressions In-Reply-To: <20261101025158.271216-1-yjn@yjn-systems.com> References: <20261101025158.271216-1-yjn@yjn-systems.com> Message-ID: <20261101025337.271337-1-yjn@yjn-systems.com> Add an opt-in mechanism for preserving select semantic origins of constant expressions through C frontend folding. Normally, enum constants and field offsets lose their source-level identity when the C frontend folds them to INTEGER_CST nodes. Introduce DEFERRED_CST_EXPR to represent expressions which retain most of normal constant semantics while postponing their final evaluation. Consumers can mark RECORD_TYPE and ENUMERAL_TYPE nodes for constant deferral through the deferred-cst interface. Marking a type has no effect on the type's C semantics; it only causes selected constants originating from that type to retain their identity during folding. For marked enum types, references to enumerators are represented using a deferred enum-value expression which retains the originating CONST_DECL. For marked record types, fold_offsetof preserves field offsets using a deferred field-offset expression which retains the originating FIELD_DECL. If not types are marked for constant deferral, absolutely no DEFERRED_CST_EXPRs are ever generated! c_fully_fold propagates deferred constants through otherwise constant, side-effect-free expressions. Const-ness checks in static initializers permit deferred constants. It is the responsibility of the consumer that marked types for constant deferral to instrument all DEFERRED_CST_EXPRs before an IPA barrier pass that runs right after all_lowering_passes. Deferred constants may never survive beyond this lifetime boundary. Signed-off-by: York Jasper Niebuhr --- gcc/Makefile.in | 4 +- gcc/c-family/c-common.cc | 109 ++- gcc/c/c-fold.cc | 173 +++++ gcc/c/c-typeck.cc | 55 +- gcc/deferred-cst.cc | 403 ++++++++++++ gcc/deferred-cst.h | 54 ++ gcc/gimple-expr.cc | 5 + gcc/gimple.cc | 3 +- gcc/gimplify.cc | 5 + gcc/internal-fn.cc | 18 + gcc/internal-fn.def | 6 + gcc/passes.def | 1 + .../gcc.dg/plugin/deferred_cst-test.c | 80 +++ .../gcc.dg/plugin/deferred_cst_plugin.cc | 619 ++++++++++++++++++ gcc/testsuite/gcc.dg/plugin/plugin.exp | 1 + gcc/tree-pass.h | 1 + gcc/tree-pretty-print.cc | 7 + gcc/tree.def | 10 + gcc/varasm.cc | 5 +- 19 files changed, 1541 insertions(+), 18 deletions(-) create mode 100644 gcc/deferred-cst.cc create mode 100644 gcc/deferred-cst.h create mode 100644 gcc/testsuite/gcc.dg/plugin/deferred_cst-test.c create mode 100644 gcc/testsuite/gcc.dg/plugin/deferred_cst_plugin.cc diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 19e35f6149b..28816c2dc7d 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1481,6 +1481,7 @@ OBJS = \ dce.o \ ddg.o \ debug.o \ + deferred-cst.o \ hierarchical_discriminator.o \ dep-fusion.o \ df-core.o \ @@ -3191,6 +3192,7 @@ GTFILES = $(CPPLIB_H) $(srcdir)/input.h $(srcdir)/coretypes.h \ $(srcdir)/internal-fn.h \ $(srcdir)/calls.cc \ $(srcdir)/analyzer/analyzer-language.cc \ + $(srcdir)/deferred-cst.cc \ @all_gtfiles@ # Compute the list of GT header files from the corresponding C sources, @@ -4207,7 +4209,7 @@ PLUGIN_HEADERS = $(TREE_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ lcm.h cfgloopmanip.h file-prefix-map.h builtins.def $(INSN_ATTR_H) \ pass-instances.def params.list $(srcdir)/../include/gomp-constants.h \ $(EXPR_H) $(srcdir)/analyzer/*.h $(srcdir)/diagnostics/*.h \ - $(srcdir)/text-art/*.h $(srcdir)/topics/*.h + $(srcdir)/text-art/*.h $(srcdir)/topics/*.h deferred-cst.h # generate the 'build fragment' b-header-vars s-header-vars: Makefile diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index 6380bec4515..ed69ffa2b9b 100644 --- a/gcc/c-family/c-common.cc +++ b/gcc/c-family/c-common.cc @@ -57,6 +57,7 @@ along with GCC; see the file COPYING3. If not see #include "gcc-rich-location.h" #include "gcc-urlifier.h" #include "diagnostics/diagnostics-selftests.h" +#include "deferred-cst.h" cpp_reader *parse_in; /* Declared in c-pragma.h. */ @@ -7215,13 +7216,33 @@ c_common_to_target_charset (HOST_WIDE_INT c) return uc; } +/* Helper for fold_offsetof_internal. Add OFFSET to the ACCUMULATOR + tree. */ +static void +accumulate_offset (tree *accumulator, tree offset) +{ + gcc_assert (accumulator); + gcc_assert (offset); + + offset = convert (sizetype, offset); + + if (*accumulator == NULL_TREE) + *accumulator = offset; + else + *accumulator = size_binop_loc ( + input_location, PLUS_EXPR, *accumulator, offset); +} + /* Fold an offsetof-like expression. EXPR is a nested sequence of component references with an INDIRECT_REF of a constant at the bottom; much like the traditional rendering of offsetof as a macro. TYPE is the desired type of - the whole expression. Return the folded result. */ + the whole expression. Return the folded result. NON_CST is set to the + sum of all non-constant portions of the offset. DEFERRED is set to the + deferred constant portion of the offset. */ -tree -fold_offsetof (tree expr, tree type, enum tree_code ctx) +static tree +fold_offsetof_internal (tree expr, tree type, enum tree_code ctx, tree *non_cst, + tree *deferred) { tree base, off, t; tree_code code = TREE_CODE (expr); @@ -7231,10 +7252,12 @@ fold_offsetof (tree expr, tree type, enum tree_code ctx) return expr; case REALPART_EXPR: - return fold_offsetof (TREE_OPERAND (expr, 0), type, code); + return fold_offsetof_internal (TREE_OPERAND (expr, 0), type, code, non_cst, + deferred); case IMAGPART_EXPR: - base = fold_offsetof (TREE_OPERAND (expr, 0), type, code); + base = fold_offsetof_internal (TREE_OPERAND (expr, 0), type, code, non_cst, + deferred); if (base == error_mark_node) return base; off = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (TREE_OPERAND (expr, 0)))); @@ -7259,7 +7282,8 @@ fold_offsetof (tree expr, tree type, enum tree_code ctx) return convert (type, TREE_OPERAND (expr, 0)); case COMPONENT_REF: - base = fold_offsetof (TREE_OPERAND (expr, 0), type, code); + base = fold_offsetof_internal (TREE_OPERAND (expr, 0), type, code, + non_cst, deferred); if (base == error_mark_node) return base; @@ -7270,13 +7294,21 @@ fold_offsetof (tree expr, tree type, enum tree_code ctx) "member %qD", t); return error_mark_node; } - off = size_binop_loc (input_location, PLUS_EXPR, DECL_FIELD_OFFSET (t), - size_int (tree_to_uhwi (DECL_FIELD_BIT_OFFSET (t)) - / BITS_PER_UNIT)); + if (deferred_cst_type_p (DECL_CONTEXT (t))) + { + off = deferred_cst_call_ifn_field_offset (EXPR_LOCATION (expr), t); + accumulate_offset (deferred, off); + return base; + } + else + off = size_binop_loc (input_location, PLUS_EXPR, DECL_FIELD_OFFSET (t), + size_int (tree_to_uhwi (DECL_FIELD_BIT_OFFSET (t)) + / BITS_PER_UNIT)); break; case ARRAY_REF: - base = fold_offsetof (TREE_OPERAND (expr, 0), type, code); + base = fold_offsetof_internal (TREE_OPERAND (expr, 0), type, code, + non_cst, deferred); if (base == error_mark_node) return base; @@ -7328,13 +7360,26 @@ fold_offsetof (tree expr, tree type, enum tree_code ctx) t = convert (sizetype, t); off = size_binop (MULT_EXPR, TYPE_SIZE_UNIT (TREE_TYPE (expr)), t); + + /* For classification as cst/non-cst, the array index has to be + fully folded. */ + off = c_fully_fold (off, false, NULL); + + if (off == error_mark_node) + return off; + + if (!TREE_CONSTANT (off)) + { + accumulate_offset (non_cst, off); + return base; + } break; case COMPOUND_EXPR: /* Handle static members of volatile structs. */ t = TREE_OPERAND (expr, 1); gcc_checking_assert (VAR_P (get_base_address (t))); - return fold_offsetof (t, type); + return fold_offsetof_internal (t, type, ERROR_MARK, non_cst, deferred); default: gcc_unreachable (); @@ -7344,6 +7389,48 @@ fold_offsetof (tree expr, tree type, enum tree_code ctx) return size_binop (PLUS_EXPR, base, convert (type, off)); return fold_build_pointer_plus (base, off); } + +/* Like fold_offsetof_internal, but integrates deferred constant components + into the result. If such components exist, the result is wrapped in a + DEFERRED_CST_EXPR node. */ + +tree +fold_offsetof (tree expr, tree type, enum tree_code ctx) +{ + tree res = NULL_TREE; + tree non_cst = NULL_TREE; + tree deferred = NULL_TREE; + tree cst = fold_offsetof_internal (expr, type, ctx, &non_cst, &deferred); + + res = cst; + + if (res == error_mark_node) + return res; + + /* DEFERRED_CST_EXPRs contain only ordinary constants and deferred + constant components. */ + if (deferred != NULL_TREE) + { + if (POINTER_TYPE_P (type)) + res = fold_build_pointer_plus (res, convert (sizetype, deferred)); + else + res = size_binop (PLUS_EXPR, res, convert (type, deferred)); + + res = deferred_cst_build_expr (res); + } + + /* Runtime-dependent terms are added only after the deferred + boundary has been constructed. */ + if (non_cst != NULL_TREE) + { + if (POINTER_TYPE_P (type)) + res = fold_build_pointer_plus (res, convert (type, non_cst)); + else + res = size_binop (PLUS_EXPR, res, convert (type, non_cst)); + } + + return res; +} /* *PTYPE is an incomplete array. Complete it with a domain based on INITIAL_VALUE. If INITIAL_VALUE is not present, use 1 if DO_DEFAULT diff --git a/gcc/c/c-fold.cc b/gcc/c/c-fold.cc index 40e8ae79727..0988f00ce93 100644 --- a/gcc/c/c-fold.cc +++ b/gcc/c/c-fold.cc @@ -26,9 +26,11 @@ along with GCC; see the file COPYING3. If not see #include "c-tree.h" #include "intl.h" #include "gimplify.h" +#include "deferred-cst.h" static tree c_fully_fold_internal (tree expr, bool, bool *, bool *, bool, bool); +static tree c_fully_fold_deferred_cst_internal (tree expr); /* If DISABLE is true, stop issuing warnings. This is used when parsing code that we know will not be executed. This function may @@ -123,6 +125,7 @@ c_fully_fold (tree expr, bool in_init, bool *maybe_const, bool lval) } ret = c_fully_fold_internal (expr, in_init, maybe_const, &maybe_const_itself, false, lval); + ret = c_fully_fold_deferred_cst_internal (ret); if (eptype) ret = fold_convert_loc (loc, eptype, ret); *maybe_const &= maybe_const_itself; @@ -718,6 +721,176 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, return ret; } +/* Return true if CODE is an operation which may be absorbed into a + DEFERRED_CST_EXPR. */ + +static bool +deferred_cst_operator_p (enum tree_code code) +{ + switch (TREE_CODE_CLASS (code)) + { + case tcc_unary: + case tcc_binary: + case tcc_comparison: + return true; + + default: + break; + } + + switch (code) + { + case COND_EXPR: + case VEC_COND_EXPR: + return true; + + default: + return false; + } +} + +/* Internal helper for c_fully_fold. Fold surrounding constant + operations into DEFERRED_CST_EXPR nodes. + + An operation is absorbed when: + + - its tree code is explicitly supported by + deferred_cst_operator_p; + - every operand is constant-like; and + - at least one operand is a DEFERRED_CST_EXPR. + + Existing deferred wrappers are removed when an operation is absorbed, + giving a single outer DEFERRED_CST_EXPR. For example: + + DEFERRED_CST_EXPR (A) + 1 + -> DEFERRED_CST_EXPR (A + 1) + + (DEFERRED_CST_EXPR (A) + 1) * 2 + -> DEFERRED_CST_EXPR ((A + 1) * 2) + + DEFERRED_CST_EXPR (A) + DEFERRED_CST_EXPR (B) + -> DEFERRED_CST_EXPR (A + B) + + DEFERRED_CST_EXPR (C) ? 1 : 2 + -> DEFERRED_CST_EXPR (C ? 1 : 2) + + An operation involving a nonconstant operand is not absorbed: + + X + DEFERRED_CST_EXPR (A) + -> X + DEFERRED_CST_EXPR (A) */ + +static tree +c_fully_fold_deferred_cst_internal (tree expr) +{ + if (expr == NULL_TREE) + return NULL_TREE; + + enum tree_code code = TREE_CODE (expr); + + /* The true constants inside deferred constants can be folded here, + while the deferred components are represented as calls to + internal functions and thus can not and should not be folded + here. */ + if (code == DEFERRED_CST_EXPR) + { + tree old_inner = TREE_OPERAND (expr, 0); + + bool maybe_const_operands = true; + bool maybe_const_itself = true; + + tree inner + = c_fully_fold_internal (old_inner, false, + &maybe_const_operands, + &maybe_const_itself, + false, false); + + if (inner == old_inner) + return expr; + + return deferred_cst_build_expr (inner); + } + + /* Unsupported operations form a boundary for deferred folding. */ + if (!deferred_cst_operator_p (code)) + return expr; + + int nops = TREE_OPERAND_LENGTH (expr); + + /* Every currently-supported operator has at most three operands. */ + gcc_assert (nops >= 1 && nops <= 3); + + tree ops[3]; + bool changed = false; + bool has_deferred = false; + bool all_constant = true; + bool has_side_effects = false; + + for (int i = 0; i < nops; ++i) + { + tree old_op = TREE_OPERAND (expr, i); + tree op = c_fully_fold_deferred_cst_internal (old_op); + + ops[i] = op; + + if (op != old_op) + changed = true; + + if (TREE_CODE (op) == DEFERRED_CST_EXPR) + has_deferred = true; + else if (!TREE_CONSTANT (op)) + all_constant = false; + + if (TREE_SIDE_EFFECTS (op)) + has_side_effects = true; + } + + /* There is no deferred expression directly participating in this + operation, or there are non-constant operands or operands with + side effects involved, so the operation itself must not become + deferred. + + We may nevertheless need to propagate a transformation made in one + of the operands. */ + if (!has_deferred || !all_constant || has_side_effects) + { + if (!changed) + return expr; + + tree copy = copy_node (expr); + for (int i = 0; i < nops; i++) + TREE_OPERAND (copy, i) = ops[i]; + + return copy; + } + + /* Every operand is constant-like and at least one operand is + deferred. Move this complete operation inside one deferred + wrapper. */ + + tree inner = copy_node (expr); + for (int i = 0; i < nops; i++) + { + bool op_deferred_cst = ops[i] != NULL_TREE + && TREE_CODE (ops[i]) == DEFERRED_CST_EXPR; + TREE_OPERAND (inner, i) = op_deferred_cst + ? TREE_OPERAND (ops[i], 0) : ops[i]; + } + + bool maybe_const_operands = true; + bool maybe_const_itself = true; + + /* The true constants inside deferred constants can be folded here, + while the deferred components are represented as calls to + internal functions and thus can not and should not be folded + here. */ + inner = c_fully_fold_internal (inner, false, + &maybe_const_operands, + &maybe_const_itself, + false, false); + + return deferred_cst_build_expr (inner); +} + /* Fold X for consideration by one of the warning functions when checking whether an expression has a constant value. */ diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 2d020085833..6813ec8d202 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see #include "realmpfr.h" #include "tree-pretty-print-markup.h" #include "gcc-urlifier.h" +#include "deferred-cst.h" /* Possible cases of implicit conversions. Used to select diagnostic messages and control folding initializers in convert_for_assignment. */ @@ -2293,6 +2294,17 @@ c_size_in_bytes (const_tree type) / BITS_PER_UNIT)); } +/* Return true if INIT is a valid deferred constant initializer. */ +static bool +deferred_constant_initializer_p (tree init) +{ + if (!init || !deferred_cst_present_p (init)) + return false; + + return initializer_constant_valid_p (init, TREE_TYPE (init)) + != NULL_TREE; +} + /* Return either DECL or its known constant value (if it has one). */ tree @@ -2307,7 +2319,8 @@ decl_constant_value_1 (tree decl, bool in_init) /* This is invalid if initial value is not constant. If it has either a function call, a memory reference, or a variable, then re-evaluating it could give different results. */ - && TREE_CONSTANT (DECL_INITIAL (decl)) + && (TREE_CONSTANT (DECL_INITIAL (decl)) + || deferred_constant_initializer_p (DECL_INITIAL (decl))) /* Check for cases where this is sub-optimal, even though valid. */ && (in_init || TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR)) return DECL_INITIAL (decl); @@ -3865,6 +3878,33 @@ mark_decl_used (tree ref, bool address) } } +/* Return true if DECL is a literal of an enum type that is marked for + constant deferral. */ +static bool +deferred_cst_enum_literal_p (tree decl) +{ + if (TREE_CODE (decl) != CONST_DECL) + return false; + + tree enum_type = TREE_TYPE (decl); + + return (enum_type + && TREE_CODE (enum_type) == ENUMERAL_TYPE + && deferred_cst_type_p (enum_type)); +} + +/* Build a deferred constant for the enumeration constant DECL. */ +static tree +deferred_cst_build_enum_literal (tree decl) +{ + tree call + = deferred_cst_call_ifn_enum_value (DECL_SOURCE_LOCATION (decl), decl); + + gcc_assert (call != error_mark_node); + + return deferred_cst_build_expr (call); +} + /* Build an external reference to identifier ID. FUN indicates whether this will be used for a function call. LOC is the source @@ -3938,8 +3978,13 @@ build_external_ref (location_t loc, tree id, bool fun, tree *type) inform (DECL_SOURCE_LOCATION (ref), "enum constant defined here"); } - ref = DECL_INITIAL (ref); - TREE_CONSTANT (ref) = 1; + if (deferred_cst_enum_literal_p (ref)) + ref = deferred_cst_build_enum_literal (ref); + else + { + ref = DECL_INITIAL (ref); + TREE_CONSTANT (ref) = 1; + } } /* C99 6.7.4p3: An inline definition of a function with external linkage ... shall not contain a reference to an identifier with @@ -10269,7 +10314,9 @@ digest_init (location_t init_loc, tree decl, tree type, tree init, /* Check to see if we have already given an error message. */ if (inside_init == error_mark_node) ; - else if (require_constant && !TREE_CONSTANT (inside_init)) + else if (require_constant + && !TREE_CONSTANT (inside_init) + && !deferred_constant_initializer_p (inside_init)) { error_init (init_loc, "initializer element is not constant"); inside_init = error_mark_node; diff --git a/gcc/deferred-cst.cc b/gcc/deferred-cst.cc new file mode 100644 index 00000000000..261cd189e91 --- /dev/null +++ b/gcc/deferred-cst.cc @@ -0,0 +1,403 @@ +/* Deferred constant expression support for GCC. + Copyright (C) 2026 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "stringpool.h" +#include "fold-const.h" +#include "internal-fn.h" +#include "attribs.h" +#include "tree-pass.h" +#include "context.h" +#include "cgraph.h" +#include "function.h" +#include "cfg.h" +#include "basic-block.h" +#include "gimple.h" +#include "gimple-iterator.h" +#include "gimple-walk.h" +#include "diagnostic.h" + +#include "deferred-cst.h" + +struct deferred_cst_type_hasher : ggc_cache_ptr_hash +{ + static hashval_t + hash (tree t) + { + return htab_hash_pointer (t); + } +}; + +/* Set of types marked for constant deferral. */ +static GTY((cache)) hash_table *deferred_cst_types; + +/* Weak mappings from unique STRING_CST tokens used as arguments to + IFN_DEFERRED_CST_* calls to the tree associated with that call. + + IFN_DEFERRED_CST_FIELD_OFFSET (field_offset_decls) + Maps to the FIELD_DECL of the field whose offset the call + represents. + + IFN_DEFERRED_CST_ENUM_VALUE (enum_value_decls) + Maps to the CONST_DECL of the enum literal whose value the call + represents. */ +static GTY((cache)) tree_cache_map *field_offset_decls; +static GTY((cache)) tree_cache_map *enum_value_decls; + +/* Used only to make STRING_CST contents unique. The actual string + values have no semantic meaning; the STRING_CST nodes themselves + are the metadata tokens. */ +static unsigned HOST_WIDE_INT next_token = 0; + +static bool +markable_type_p (tree type) +{ + if (!type) + return false; + + switch (TREE_CODE (type)) + { + case RECORD_TYPE: + case ENUMERAL_TYPE: + return true; + default: + return false; + } +} + +void +deferred_cst_mark_type (tree type) +{ + type = TYPE_MAIN_VARIANT (type); + + if (!markable_type_p (type)) + internal_error ( + "attempted to mark unsupported type for constant deferral"); + + if (!deferred_cst_types) + deferred_cst_types + = hash_table::create_ggc (13); + + tree *slot = deferred_cst_types->find_slot (type, INSERT); + if (*slot == NULL_TREE) + *slot = type; +} + +bool +deferred_cst_type_p (tree type) +{ + type = TYPE_MAIN_VARIANT (type); + return (deferred_cst_types + && deferred_cst_types->find (type) != NULL); +} + +tree +deferred_cst_build_expr (tree expr) +{ + return build1_loc (EXPR_LOCATION (expr), DEFERRED_CST_EXPR, + TREE_TYPE (expr), expr); +} + +/* Create a unique STRING_CST to use as a metadata token. */ +static tree +make_token () +{ + char buf[64]; + + int len = snprintf (buf, sizeof (buf), + "__deferred_cst_token_" HOST_WIDE_INT_PRINT_UNSIGNED, + next_token++); + + gcc_assert (len > 0); + gcc_assert ((unsigned int) len < sizeof (buf)); + + /* Include the trailing NUL. */ + unsigned int string_len = len + 1; + + tree token = build_string (string_len, buf); + + TREE_TYPE (token) + = build_array_type_nelts (char_type_node, string_len); + + return token; +} + +/* Generate a new key token and store VALUE under that token in MAP. + If MAP was not yet allocated, allocate it. */ +static tree +register_ifn_entry (tree_cache_map **map, tree value) +{ + if (!map) + return NULL_TREE; + + tree token = make_token (); + + if (!*map) + *map = tree_cache_map::create_ggc (); + + bool existed = (*map)->put (token, value); + + /* Every token create above should be unique. */ + gcc_assert (!existed); + + return token; +} + +/* Look up the value associated with TOKEN in MAP. */ +static tree +lookup_ifn_entry (tree_cache_map **map, tree token) +{ + if (!token || !map || !*map) + return NULL_TREE; + + tree *slot = (*map)->get (token); + return slot ? *slot : NULL_TREE; +} + +/* Create a call to IFN_DEFERRED_CST_FIELD_OFFSET for the physical, + addressable FIELD whose byte offset is deferred. + + FIELD must not be a bit-field. Callers handling bit-fields must pass + DECL_BIT_FIELD_REPRESENTATIVE (field). + + Internally, these call hold the field declarations in a side-map + keyed by tokens used as call arguments. */ +tree +deferred_cst_call_ifn_field_offset (location_t loc, tree field) +{ + if (!field || TREE_CODE (field) != FIELD_DECL || DECL_BIT_FIELD (field)) + return error_mark_node; + + tree token = register_ifn_entry (&field_offset_decls, field); + return build_call_expr_internal_loc (loc, + IFN_DEFERRED_CST_FIELD_OFFSET, + sizetype, 1, token); +} + +tree +deferred_cst_ifn_field_offset_field (tree token) +{ + return lookup_ifn_entry (&field_offset_decls, token); +} + +/* Create a call to IFN_DEFERRED_CST_ENUM_VALUE for an enum value + declaration DECL. */ +tree +deferred_cst_call_ifn_enum_value (location_t loc, tree decl) +{ + if (!decl || TREE_CODE (decl) != CONST_DECL) + return error_mark_node; + + tree enum_type = TREE_TYPE (decl); + + if (!enum_type || TREE_CODE (enum_type) != ENUMERAL_TYPE) + return error_mark_node; + + tree init_type = TREE_TYPE (DECL_INITIAL (decl)); + + tree token = register_ifn_entry (&enum_value_decls, decl); + return build_call_expr_internal_loc (loc, + IFN_DEFERRED_CST_ENUM_VALUE, + init_type, 1, token); +} + +tree +deferred_cst_ifn_enum_value_decl (tree token) +{ + return lookup_ifn_entry (&enum_value_decls, token); +} + +static tree +find_deferred_cst_node (tree *tp, int *walk_subtrees, void *) +{ + tree node = *tp; + + if (!node) + return NULL_TREE; + + switch (TREE_CODE (node)) + { + case DEFERRED_CST_EXPR: + *walk_subtrees = 0; + return node; + + default: + break; + } + + /* Declarations and types are metadata here. Do not walk into their + contexts, types, or initializers. */ + if (DECL_P (node) || TYPE_P (node)) + *walk_subtrees = 0; + + return NULL_TREE; +} + +bool +deferred_cst_present_p (tree expr) +{ + if (!expr) + return false; + + tree root = expr; + + return walk_tree_without_duplicates ( + &root, + find_deferred_cst_node, + NULL) + != NULL_TREE; +} + +/* Walker to go through functions and initializers. ICE if + DEFERRED_CST_EXPR is encountered. */ +static tree +deferred_cst_barrier_walk (tree *tp, int *walk_subtrees, void *) +{ + tree node = *tp; + + if (!node) + return NULL_TREE; + + if (TYPE_P (node) || DECL_P (node)) + { + *walk_subtrees = 0; + return NULL_TREE; + } + + if (TREE_CODE (node) == DEFERRED_CST_EXPR) + internal_error ("unresolved deferred constant reached barrier"); + + return NULL_TREE; +} + +static void +deferred_cst_barrier_function (function *fn) +{ + basic_block bb; + + FOR_EACH_BB_FN (bb, fn) + { + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); + !gsi_end_p (gsi); + gsi_next (&gsi)) + { + gimple *stmt = gsi_stmt (gsi); + + for (unsigned int i = 0; i < gimple_num_ops (stmt); ++i) + { + tree *operand = gimple_op_ptr (stmt, i); + + if (!operand || !*operand) + continue; + + walk_tree (operand, + deferred_cst_barrier_walk, + NULL, + NULL); + } + } + } +} + +static tree +deferred_cst_barrier_init (tree init) +{ + if (!init) + return init; + + walk_tree (&init, deferred_cst_barrier_walk, NULL, NULL); + return init; +} + +static void +deferred_cst_barrier_functions () +{ + cgraph_node *node; + + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node) + { + function *fn = DECL_STRUCT_FUNCTION (node->decl); + gcc_assert (fn); + + push_cfun (fn); + deferred_cst_barrier_function (fn); + pop_cfun (); + } +} + +static void +deferred_cst_barrier_inits () +{ + varpool_node *vnode; + + FOR_EACH_VARIABLE (vnode) + { + tree decl = vnode->decl; + tree init = DECL_INITIAL (decl); + + if (!init || init == error_mark_node) + continue; + + tree clean_init = deferred_cst_barrier_init (init); + if (clean_init != init) + DECL_INITIAL (decl) = clean_init; + } +} + +namespace { + +const pass_data pass_data_deferred_cst_barrier = +{ + SIMPLE_IPA_PASS, + "deferred-cst-barrier", + OPTGROUP_NONE, + TV_NONE, + 0, 0, 0, 0, 0 +}; + +class pass_deferred_cst_barrier : public simple_ipa_opt_pass +{ +public: + pass_deferred_cst_barrier (gcc::context *ctxt) + : simple_ipa_opt_pass (pass_data_deferred_cst_barrier, ctxt) + {} + + unsigned int execute (function *) final override; +}; + +unsigned int +pass_deferred_cst_barrier::execute (function *) +{ + deferred_cst_barrier_functions (); + deferred_cst_barrier_inits (); + return 0; +} + +} // anonymous namespace + +simple_ipa_opt_pass * +make_pass_deferred_cst_barrier (gcc::context *ctxt) +{ + return new pass_deferred_cst_barrier (ctxt); +} + +#include "gt-deferred-cst.h" diff --git a/gcc/deferred-cst.h b/gcc/deferred-cst.h new file mode 100644 index 00000000000..85e65f6854f --- /dev/null +++ b/gcc/deferred-cst.h @@ -0,0 +1,54 @@ +/* Deferred constant expression support for GCC. + Copyright (C) 2026 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef GCC_DEFERRED_CST_H +#define GCC_DEFERRED_CST_H + +/* Mark a record or enum TYPE for constant deferral. */ +extern void deferred_cst_mark_type (tree type); + +/* Return true if TYPE is marked for constant deferral. */ +extern bool deferred_cst_type_p (tree type); + +/* Build a DEFERRED_CST_EXPR around EXPR. */ +extern tree deferred_cst_build_expr (tree expr); + +/* Return true if EXPR contains a DEFERRED_CST_EXPR. */ +extern bool deferred_cst_present_p (tree expr); + +/* Create a call to IFN_DEFERRED_CST_FIELD_OFFSET for the physical + FIELD whose byte offset is deferred. + + FIELD must not be a bit-field. Callers handling bit-fields must pass + DECL_BIT_FIELD_REPRESENTATIVE (field). */ +extern tree deferred_cst_call_ifn_field_offset (location_t loc, tree field); + +/* Get the FIELD_DECL associated with the argument TOKEN to a call of + IFN_DEFERRED_CST_FIELD_OFFSET. */ +extern tree deferred_cst_ifn_field_offset_field (tree token); + +/* Create a call to IFN_DEFERRED_CST_ENUM_VALUE for an enum value + declaration DECL. */ +extern tree deferred_cst_call_ifn_enum_value (location_t loc, tree decl); + +/* Get the CONST_DECL associated with the argument TOKEN to a call of + IFN_DEFERRED_CST_ENUM_VALUE. */ +extern tree deferred_cst_ifn_enum_value_decl (tree token); + +#endif diff --git a/gcc/gimple-expr.cc b/gcc/gimple-expr.cc index fcc31b99390..acb4b59e371 100644 --- a/gcc/gimple-expr.cc +++ b/gcc/gimple-expr.cc @@ -844,6 +844,11 @@ is_gimple_val (tree t) || TREE_CODE (t) == OMP_TARGET_DEVICE_MATCHES) return true; + /* Technically, deferred constant expressions act as min invariants, + but they do not survice to where that would be relevant. */ + if (TREE_CODE (t) == DEFERRED_CST_EXPR) + return true; + return (is_gimple_variable (t) || is_gimple_min_invariant (t)); } diff --git a/gcc/gimple.cc b/gcc/gimple.cc index 2295f353472..7f3c0734a23 100644 --- a/gcc/gimple.cc +++ b/gcc/gimple.cc @@ -2574,7 +2574,8 @@ get_gimple_rhs_num_ops (enum tree_code code) || (SYM) == WITH_SIZE_EXPR \ || (SYM) == SSA_NAME \ || (SYM) == OMP_NEXT_VARIANT \ - || (SYM) == OMP_TARGET_DEVICE_MATCHES) ? GIMPLE_SINGLE_RHS \ + || (SYM) == OMP_TARGET_DEVICE_MATCHES \ + || (SYM) == DEFERRED_CST_EXPR) ? GIMPLE_SINGLE_RHS \ : GIMPLE_INVALID_RHS), #define END_OF_BASE_TREE_CODES (unsigned char) GIMPLE_INVALID_RHS, diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index 94d71d71fc2..84820380ac5 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -20705,6 +20705,11 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, ret = GS_ALL_DONE; break; + case DEFERRED_CST_EXPR: + /* DEFERRED_CST_EXPRs act as min invariants. */ + ret = GS_ALL_DONE; + break; + case CONST_DECL: /* If we require an lvalue, such as for ADDR_EXPR, retain the CONST_DECL node. Otherwise the decl is replaceable by its diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc index 40fe58dc4f6..e04b95cbbb6 100644 --- a/gcc/internal-fn.cc +++ b/gcc/internal-fn.cc @@ -4322,6 +4322,24 @@ expand_reduc_sbool_optab_fn (internal_fn fn, gcall *stmt, direct_optab optab) assign_call_lhs (lhs, lhs_rtx, &ops[0]); } +/* IFN_DEFERRED_CST_FIELD_OFFSET should not survice GIMPLE. */ + +void +expand_DEFERRED_CST_FIELD_OFFSET (internal_fn, gcall *) +{ + internal_error ("%qs reached RTL expansion", + "IFN_DEFERRED_CST_FIELD_OFFSET"); +} + +/* IFN_DEFERRED_CST_ENUM_VALUE should not survive GIMPLE. */ + +void +expand_DEFERRED_CST_ENUM_VALUE (internal_fn, gcall *) +{ + internal_error ("%qs reached RTL expansion", + "IFN_DEFERRED_CST_ENUM_VALUE"); +} + /* Expanders for optabs that can use expand_direct_optab_fn. */ #define expand_unary_optab_fn(FN, STMT, OPTAB) \ diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def index 7feb236d802..dfb7bd2e034 100644 --- a/gcc/internal-fn.def +++ b/gcc/internal-fn.def @@ -649,6 +649,12 @@ DEF_INTERNAL_FN (BITINTTOFLOAT, ECF_PURE | ECF_LEAF, ". R . ") DEF_INTERNAL_OPTAB_FN (BIT_ANDN, ECF_CONST, andn, binary) DEF_INTERNAL_OPTAB_FN (BIT_IORN, ECF_CONST, iorn, binary) +/* Deferred constant functions. */ +DEF_INTERNAL_FN (DEFERRED_CST_FIELD_OFFSET, ECF_CONST | ECF_LEAF | ECF_NOTHROW, + NULL) +DEF_INTERNAL_FN (DEFERRED_CST_ENUM_VALUE, ECF_CONST | ECF_LEAF | ECF_NOTHROW, + NULL) + #undef DEF_INTERNAL_WIDENING_OPTAB_FN #undef DEF_INTERNAL_SIGNED_COND_FN #undef DEF_INTERNAL_COND_FN diff --git a/gcc/passes.def b/gcc/passes.def index 9095c134f49..e981dbb412d 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. If not see /* Interprocedural optimization passes. */ INSERT_PASSES_AFTER (all_small_ipa_passes) + NEXT_PASS (pass_deferred_cst_barrier); /* auto_profile_offline uses dwarf_name hook that only works before free_lang_data. */ NEXT_PASS (pass_ipa_auto_profile_offline); diff --git a/gcc/testsuite/gcc.dg/plugin/deferred_cst-test.c b/gcc/testsuite/gcc.dg/plugin/deferred_cst-test.c new file mode 100644 index 00000000000..fb73510881d --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/deferred_cst-test.c @@ -0,0 +1,80 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ + +/* { dg-final { scan-file deferred-cst.out "\\\[var\\\] var_aggregate\\.nested\\.y -- \\(offsetof\\(struct S, c\\) \\+ \\(E::E_C \\* 4\\)\\)" } } */ +/* { dg-final { scan-file deferred-cst.out "\\\[var\\\] var_aggregate\\.x -- E::E_B" } } */ +/* { dg-final { scan-file deferred-cst.out "\\\[var\\\] var_enum -- E::E_B" } } */ +/* { dg-final { scan-file deferred-cst.out "\\\[var\\\] var_offset -- offsetof\\(struct S, b\\)" } } */ +/* { dg-final { scan-file deferred-cst.out "\\\[fun\\\] test_enum -- E::E_B" } } */ +/* { dg-final { scan-file deferred-cst.out "\\\[fun\\\] test_expression -- \\(offsetof\\(struct S, c\\) \\+ \\(E::E_C \\* 4\\)\\)" } } */ +/* { dg-final { scan-file deferred-cst.out "\\\[fun\\\] test_offset -- offsetof\\(struct S, b\\)" } } */ + +#include + +#define __dc __attribute__((defer_constants)) + +struct S +{ + int a, b, c; +} __dc; + +enum E +{ + E_A = 1, + E_B = 1, + E_C = 2 +} __dc; + + +/* Basic field-offset preservation. */ + +size_t +test_offset (void) +{ + return offsetof (struct S, b); +} + + +/* Basic enumerator preservation. Use E_B so that its identity cannot be + reconstructed from its numeric value. */ + +int +test_enum (void) +{ + return E_B; +} + + +/* Propagation through a non-trivial constant expression, including both + kinds of deferred leaf. */ + +size_t +test_expression (void) +{ + return offsetof (struct S, c) + E_C * 4; +} + + +/* Deferred constants in scalar static initializers. */ + +static int var_enum = E_B; + +static size_t var_offset = offsetof (struct S, b); + + +/* Deferred constants recursively contained in an aggregate initializer. */ + +struct aggregate +{ + int x; + struct + { + size_t y; + } nested; +}; + +static struct aggregate var_aggregate = +{ + .x = E_B, + .nested.y = offsetof (struct S, c) + E_C * 4 +}; diff --git a/gcc/testsuite/gcc.dg/plugin/deferred_cst_plugin.cc b/gcc/testsuite/gcc.dg/plugin/deferred_cst_plugin.cc new file mode 100644 index 00000000000..575f59bd85b --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/deferred_cst_plugin.cc @@ -0,0 +1,619 @@ +/* Test plugin for deferred constant expressions. + Copyright (C) 2026 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +int plugin_is_GPL_compatible; + +static const char *output_file = "deferred-cst.out"; + +enum class context_kind +{ + variable, + function +}; + +struct deferred_report +{ + context_kind kind; + std::string context; + std::string expression; +}; + +static std::vector reports; + +static tree +check_defer_constants_attribute (tree *node, tree name, tree args, int flags, bool *no_add_attrs) +{ + if (!node || !*node) + return NULL_TREE; + + tree type = *node; + + switch (TREE_CODE (type)) + { + case RECORD_TYPE: + case ENUMERAL_TYPE: + deferred_cst_mark_type (type); + break; + default: + error ("%'defer_constants%' attribute on invalid type"); + *no_add_attrs = true; + } + + return NULL_TREE; +} + +static struct attribute_spec defer_constants_attribute = { + "defer_constants", 0, 0, false, false, false, false, + check_defer_constants_attribute, NULL +}; + +void +on_register_attributes (void *plugin_data, void *user_data) +{ + register_attribute (&defer_constants_attribute); +} + +/* Small stable printer for deferred constant expressions. + + The intentionally supported grammar is: + + EXPR := + LEAF + | (EXPR + EXPR) + | (EXPR - EXPR) + | (EXPR * EXPR) + + LEAF := + INTEGER + | offsetof(TYPE, FIELD) + | ENUM::VALUE + + Every non-leaf expression is parenthesized. */ + +/* Return a stable printable name for DECL. + + For tests we require declarations involved in deferred constants to have + names. */ +static const char * +decl_name (tree decl) +{ + gcc_assert (decl); + gcc_assert (DECL_P (decl)); + gcc_assert (DECL_NAME (decl)); + + return IDENTIFIER_POINTER (DECL_NAME (decl)); +} + +/* Append the name of a record/enum type. + + Prefer TYPE_NAME's declaration/name. Tests using this plugin should use + named types rather than anonymous types, since the textual format is + deliberately intended to be stable. */ +static void +append_type_name (std::string &out, tree type) +{ + gcc_assert (type); + + tree name = TYPE_NAME (type); + + if (name && TREE_CODE (name) == TYPE_DECL) + name = DECL_NAME (name); + + gcc_assert (name && TREE_CODE (name) == IDENTIFIER_NODE); + + out += IDENTIFIER_POINTER (name); +} + +/* Print an INTEGER_CST without relying on host integer width. */ +static void +append_integer_cst (std::string &out, tree t) +{ + gcc_assert (TREE_CODE (t) == INTEGER_CST); + + char *p = print_generic_expr_to_str (t); + + /* INTEGER_CSTs appearing in the test grammar should print as a simple + integer. */ + gcc_assert (p); + out += p; + free (p); +} + +/* Print a deferred field-offset IFN. */ +static void +append_field_offset (std::string &out, tree call) +{ + gcc_assert (TREE_CODE (call) == CALL_EXPR); + gcc_assert (CALL_EXPR_IFN (call) == IFN_DEFERRED_CST_FIELD_OFFSET); + gcc_assert (call_expr_nargs (call) == 1); + + tree token = CALL_EXPR_ARG (call, 0); + tree field = deferred_cst_ifn_field_offset_field (token); + + gcc_assert (field); + gcc_assert (TREE_CODE (field) == FIELD_DECL); + + tree record = DECL_CONTEXT (field); + + gcc_assert (record); + gcc_assert (TREE_CODE (record) == RECORD_TYPE); + + out += "offsetof(struct "; + + append_type_name (out, record); + out += ", "; + out += decl_name (field); + out += ")"; +} + +/* Print a deferred enum-value IFN. */ +static void +append_enum_value (std::string &out, tree call) +{ + gcc_assert (TREE_CODE (call) == CALL_EXPR); + gcc_assert (CALL_EXPR_IFN (call) == IFN_DEFERRED_CST_ENUM_VALUE); + gcc_assert (call_expr_nargs (call) == 1); + + tree token = CALL_EXPR_ARG (call, 0); + tree decl = deferred_cst_ifn_enum_value_decl (token); + + gcc_assert (decl); + gcc_assert (TREE_CODE (decl) == CONST_DECL); + + tree enum_type = TREE_TYPE (decl); + + gcc_assert (enum_type); + gcc_assert (TREE_CODE (enum_type) == ENUMERAL_TYPE); + + append_type_name (out, enum_type); + out += "::"; + out += decl_name (decl); +} + +/* Print one internal-function leaf. */ +static void +append_deferred_ifn (std::string &out, tree call) +{ + gcc_assert (TREE_CODE (call) == CALL_EXPR); + gcc_assert (CALL_EXPR_FN (call) == NULL_TREE); + + switch (CALL_EXPR_IFN (call)) + { + case IFN_DEFERRED_CST_FIELD_OFFSET: + append_field_offset (out, call); + return; + + case IFN_DEFERRED_CST_ENUM_VALUE: + append_enum_value (out, call); + return; + + default: + /* The test consumer intentionally understands only the deferred + constant IFNs. */ + gcc_unreachable (); + } +} + +/* Append EXPR in the stable test grammar. + + Nested DEFERRED_CST_EXPR wrappers are transparent. */ +static void +append_deferred_expr (std::string &out, tree expr) +{ + gcc_assert (expr); + + while (CONVERT_EXPR_P (expr)) + { + gcc_assert (TREE_OPERAND (expr, 0)); + expr = TREE_OPERAND (expr, 0); + } + + switch (TREE_CODE (expr)) + { + case DEFERRED_CST_EXPR: + append_deferred_expr (out, TREE_OPERAND (expr, 0)); + return; + + case INTEGER_CST: + append_integer_cst (out, expr); + return; + + case CALL_EXPR: + append_deferred_ifn (out, expr); + return; + + case PLUS_EXPR: + case MINUS_EXPR: + case MULT_EXPR: + { + const char *op; + + switch (TREE_CODE (expr)) + { + case PLUS_EXPR: + op = " + "; + break; + + case MINUS_EXPR: + op = " - "; + break; + + case MULT_EXPR: + op = " * "; + break; + + default: + gcc_unreachable (); + } + + out += "("; + append_deferred_expr (out, TREE_OPERAND (expr, 0)); + out += op; + append_deferred_expr (out, TREE_OPERAND (expr, 1)); + out += ")"; + return; + } + + default: + /* If the core starts propagating a new operation into deferred + constants, force the test consumer to be updated explicitly. */ + debug_tree (expr); + internal_error ("unsupported expression in deferred constant test " + "consumer"); + } +} + +/* Record one outermost DEFERRED_CST_EXPR. */ +static void +record_deferred_expr (context_kind kind, const std::string &context, tree expr) +{ + gcc_assert (TREE_CODE (expr) == DEFERRED_CST_EXPR); + + std::string text; + append_deferred_expr (text, expr); + + reports.push_back ({ kind, context, text }); +} + +static tree +function_tree_walker (tree *tp, int *walk_subtrees, void *data) +{ + tree t = *tp; + + if (!t) + return NULL_TREE; + + if (TREE_CODE (t) != DEFERRED_CST_EXPR) + return NULL_TREE; + + const char *fn_name = static_cast (data); + + record_deferred_expr (context_kind::function, fn_name, t); + + *walk_subtrees = 0; + return NULL_TREE; +} + +static void +scan_function (cgraph_node *node) +{ + gcc_assert (node); + gcc_assert (node->decl); + + if (!node->has_gimple_body_p ()) + return; + + const char *name = decl_name (node->decl); + + push_cfun (DECL_STRUCT_FUNCTION (node->decl)); + + basic_block bb; + FOR_EACH_BB_FN (bb, cfun) + { + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); + !gsi_end_p (gsi); + gsi_next (&gsi)) + { + gimple *stmt = gsi_stmt (gsi); + + for (unsigned i = 0; i < gimple_num_ops (stmt); ++i) + { + tree op = gimple_op (stmt, i); + + if (!op || !deferred_cst_present_p (op)) + continue; + + walk_tree (&op, function_tree_walker, + const_cast (name), NULL); + } + } + } + + pop_cfun (); +} + +/* Append ".field" or "[index]" for one CONSTRUCTOR element. + + FIELD_DECL indices give us struct/union paths. INTEGER_CST indices give + us array paths. */ +static std::string +constructor_element_context (const std::string &parent, tree index) +{ + std::string result = parent; + + if (!index) + return result; + + if (TREE_CODE (index) == FIELD_DECL) + { + result += "."; + result += decl_name (index); + return result; + } + + if (TREE_CODE (index) == INTEGER_CST) + { + result += "["; + append_integer_cst (result, index); + result += "]"; + return result; + } + + debug_tree (index); + internal_error ("unsupported constructor index in deferred constant " + "test consumer"); +} + +static void +scan_initializer (tree init, const std::string &context) +{ + if (!init) + return; + + if (TREE_CODE (init) == DEFERRED_CST_EXPR) + { + record_deferred_expr (context_kind::variable, context, init); + return; + } + + if (TREE_CODE (init) == CONSTRUCTOR) + { + unsigned HOST_WIDE_INT ix; + tree index; + tree value; + + FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (init), + ix, index, value) + { + std::string child + = constructor_element_context (context, index); + scan_initializer (value, child); + } + + return; + } + + /* A deferred expression can also be nested below some tree which is not + itself a CONSTRUCTOR. Walk that tree, retaining the same initializer + context. */ + if (deferred_cst_present_p (init)) + { + struct initializer_walk_data + { + const std::string *context; + } data = { &context }; + + auto walker = [] (tree *tp, int *walk_subtrees, void *opaque) -> tree + { + tree t = *tp; + + if (!t) + return NULL_TREE; + + if (TREE_CODE (t) != DEFERRED_CST_EXPR) + return NULL_TREE; + + initializer_walk_data *d + = static_cast (opaque); + + record_deferred_expr (context_kind::variable, *d->context, t); + *walk_subtrees = 0; + return NULL_TREE; + }; + + walk_tree (&init, walker, &data, NULL); + } +} + +static void +scan_static_initializers () +{ + varpool_node *node; + + FOR_EACH_VARIABLE (node) + { + tree decl = node->decl; + + if (!decl) + continue; + + tree init = DECL_INITIAL (decl); + + if (!init || init == error_mark_node) + continue; + + /* Externals don't have a definition whose initializer belongs to this + compilation unit. */ + if (DECL_EXTERNAL (decl)) + continue; + + if (!deferred_cst_present_p (init)) + continue; + + scan_initializer (init, decl_name (decl)); + } +} + +static const char * +context_kind_name (context_kind kind) +{ + switch (kind) + { + case context_kind::function: + return "fun"; + + case context_kind::variable: + return "var"; + } + + gcc_unreachable (); +} + +static bool +report_less (const deferred_report &a, const deferred_report &b) +{ + if (a.kind != b.kind) + return a.kind < b.kind; + + if (a.context != b.context) + return a.context < b.context; + + return a.expression < b.expression; +} + +static void +emit_reports () +{ + /* Don't make tests depend on cgraph/varpool traversal order. */ + std::sort (reports.begin (), reports.end (), report_less); + + FILE *out = fopen (output_file, "w"); + if (!out) + fatal_error (UNKNOWN_LOCATION, + "cannot open %s", + output_file); + + for (const deferred_report &report : reports) + fprintf (out, "[%s] %s -- %s\n", + context_kind_name (report.kind), + report.context.c_str (), + report.expression.c_str ()); + + fclose (out); +} + +namespace { + +const pass_data pass_data_deferred_cst_test = +{ + SIMPLE_IPA_PASS, + "deferred-cst-test", + OPTGROUP_NONE, + TV_NONE, + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0 /* todo_flags_finish */ +}; + +class pass_deferred_cst_test : public simple_ipa_opt_pass +{ +public: + pass_deferred_cst_test (gcc::context *ctxt) + : simple_ipa_opt_pass (pass_data_deferred_cst_test, ctxt) + {} + + unsigned int execute (function *) final override + { + reports.clear (); + + scan_static_initializers (); + + cgraph_node *node; + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node) + scan_function (node); + + emit_reports (); + + fflush (stdout); + fflush (stderr); + + /* This plugin is a testsuite consumer of deferred constants. It + intentionally leaves the constants unresolved, so stop compilation + successfully after observing them rather than allowing them to escape + their supported lifetime. */ + exit (EXIT_SUCCESS); + + gcc_unreachable (); + } +}; + +} /* anonymous namespace */ + +int +plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) +{ + /* Don't allow output from earlier invocation to satisfy tests. */ + unlink (output_file); + + if (!plugin_default_version_check (version, &gcc_version)) + { + error ("incompatible GCC/plugin versions: plugin built for GCC %s, " + "loaded by GCC %s", + gcc_version.basever, version->basever); + return 1; + } + + register_callback (plugin_info->base_name, PLUGIN_ATTRIBUTES, + on_register_attributes, NULL); + + static struct register_pass_info pass_info; + pass_info.pass = new pass_deferred_cst_test (g); + pass_info.reference_pass_name = "deferred-cst-barrier"; + pass_info.ref_pass_instance_number = 1; + pass_info.pos_op = PASS_POS_INSERT_BEFORE; + + register_callback (plugin_info->base_name, + PLUGIN_PASS_MANAGER_SETUP, + NULL, &pass_info); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp index deef8e8570c..660d1548730 100644 --- a/gcc/testsuite/gcc.dg/plugin/plugin.exp +++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp @@ -201,6 +201,7 @@ set plugin_test_list [list \ cpython-plugin-test-PyList_New.c \ cpython-plugin-test-PyLong_FromLong.c } \ { progress_notifications_plugin.cc } \ + { deferred_cst_plugin.cc deferred_cst-test.c } \ ] foreach plugin_test $plugin_test_list { diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index a3b35e009e0..939e9a4aed9 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -512,6 +512,7 @@ extern gimple_opt_pass *make_pass_coroutine_early_expand_ifns (gcc::context *ctx extern gimple_opt_pass *make_pass_adjust_alignment (gcc::context *ctxt); /* IPA Passes */ +extern simple_ipa_opt_pass *make_pass_deferred_cst_barrier (gcc::context *ctxt); extern simple_ipa_opt_pass *make_pass_ipa_lower_emutls (gcc::context *ctxt); extern simple_ipa_opt_pass *make_pass_ipa_function_and_variable_visibility (gcc::context *ctxt); extern simple_ipa_opt_pass *make_pass_ipa_strub_mode (gcc::context *ctxt); diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc index 9655870cfc8..5ccc5cd57e8 100644 --- a/gcc/tree-pretty-print.cc +++ b/gcc/tree-pretty-print.cc @@ -4452,6 +4452,13 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, } break; + case DEFERRED_CST_EXPR: + pp_string (pp, "DEFERRED_CST_EXPR <"); + dump_generic_node (pp, TREE_OPERAND (node, 0), + spc, flags, false); + pp_character (pp, '>'); + break; + case OMP_TARGET_DEVICE_MATCHES: pp_string (pp, "OMP_TARGET_DEVICE_MATCHES <"); dump_generic_node (pp, OMP_TARGET_DEVICE_MATCHES_SELECTOR (node), spc, diff --git a/gcc/tree.def b/gcc/tree.def index c11ad1abf24..76108bf4c3d 100644 --- a/gcc/tree.def +++ b/gcc/tree.def @@ -1626,6 +1626,16 @@ DEFTREECODE (TARGET_OPTION_NODE, "target_option_node", tcc_exceptional, 0) Operand 2 is additional data. */ DEFTREECODE (ANNOTATE_EXPR, "annotate_expr", tcc_expression, 3) +/* DEFERRED_CST_EXPR. + Operand 0 is an expression with deferred const-ness. + Such expressions are not known constants during frontend execution + but may act like compile-time constants to some parts of code + generation. + For example, DEFERRED_CST_EXPRs may wrap offsetof-like expressions + or enum literals to prevent semantic meaning from being lost during + constant folding in language frontends. */ +DEFTREECODE (DEFERRED_CST_EXPR, "deferred_cst_expr", tcc_expression, 1) + /* Local variables: mode:c diff --git a/gcc/varasm.cc b/gcc/varasm.cc index 7ce5032a6cb..8ac38c9a270 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -62,6 +62,7 @@ along with GCC; see the file COPYING3. If not see #include "opts.h" #include "recog.h" #include "gimple-expr.h" +#include "deferred-cst.h" /* The (assembler) name of the first globally-visible object output. */ extern GTY(()) const char *first_global_object_name; @@ -5058,7 +5059,8 @@ initializer_constant_valid_p_1 (tree value, tree endtype, tree *cache) switch (TREE_CODE (value)) { case CONSTRUCTOR: - if (constructor_static_from_elts_p (value)) + if (constructor_static_from_elts_p (value) + || deferred_cst_present_p (value)) { unsigned HOST_WIDE_INT idx; tree elt; @@ -5107,6 +5109,7 @@ initializer_constant_valid_p_1 (tree value, tree endtype, tree *cache) case STRING_CST: case COMPLEX_CST: case RAW_DATA_CST: + case DEFERRED_CST_EXPR: return null_pointer_node; case ADDR_EXPR: -- 2.43.0 From yjn@yjn-systems.com Sun Nov 1 02:54:38 2026 From: yjn@yjn-systems.com (York Jasper Niebuhr) Date: Sun, 1 Nov 2026 03:54:38 +0100 Subject: [PATCH 2/2] bpf: CO-RE consumer of deferred constants In-Reply-To: <20261101025158.271216-1-yjn@yjn-systems.com> References: <20261101025158.271216-1-yjn@yjn-systems.com> Message-ID: <20261101025438.271424-1-yjn@yjn-systems.com> Use deferred constants to preserve semantic information required for BPF CO-RE relocations. Mark enum types for deferred enum values and record types carrying "preserve_access_index" for deferred field offsets. Deferred constants encountered during BPF lowering are either turned into CO-RE relocations or resolved to their ordinary compile-time values when no relocation is requested. Add a "preserve_enum_values" attribute for enum types. Enumerators of a type carrying this attribute automatically generate BPF_RELO_ENUMVAL_VALUE relocations. Remove the bpf_enum_mappings workaround in favor of direct enum identity recovery from deferred cst arguments to __builtin_preserve_enum_value. For record types carrying "preserve_access_index", deferred field offsets originating from offsetof expressions are converted into BPF_RELO_FIELD_BYTE_OFFSET relocations. BPF CO-RE relocations can not currently be emitted for static data. Add an IPA pass which resolves deferred constants in static initializers before the generic deferred-constant barrier. Initializers which would require CO-RE relocations are diagnosed. Support for such initializers could be added in the future by generating relocated runtime initialization code, for cases such as: struct task_struct { ... int x; ... } __attribute__((preserve_access_index)); static size_t OFF_X = offsetof (struct task_struct, x); Signed-off-by: York Jasper Niebuhr --- gcc/config/bpf/bpf-passes.def | 1 + gcc/config/bpf/bpf-protos.h | 3 + gcc/config/bpf/bpf.cc | 24 + gcc/config/bpf/core-builtins.cc | 637 ++++++++++++++++-- .../gcc.target/bpf/core-auto-drain-1.c | 29 + .../gcc.target/bpf/core-auto-enum-value-1.c | 33 + .../gcc.target/bpf/core-auto-field-offset-1.c | 36 + 7 files changed, 712 insertions(+), 51 deletions(-) create mode 100644 gcc/testsuite/gcc.target/bpf/core-auto-drain-1.c create mode 100644 gcc/testsuite/gcc.target/bpf/core-auto-enum-value-1.c create mode 100644 gcc/testsuite/gcc.target/bpf/core-auto-field-offset-1.c diff --git a/gcc/config/bpf/bpf-passes.def b/gcc/config/bpf/bpf-passes.def index eb0e9837d3a..eb0507fbec0 100644 --- a/gcc/config/bpf/bpf-passes.def +++ b/gcc/config/bpf/bpf-passes.def @@ -18,3 +18,4 @@ . */ INSERT_PASS_BEFORE (pass_lower_omp, 1, pass_lower_bpf_core); +INSERT_PASS_BEFORE (pass_deferred_cst_barrier, 1, pass_bpf_deferred_static); diff --git a/gcc/config/bpf/bpf-protos.h b/gcc/config/bpf/bpf-protos.h index eee260b799b..db1e379577b 100644 --- a/gcc/config/bpf/bpf-protos.h +++ b/gcc/config/bpf/bpf-protos.h @@ -36,6 +36,9 @@ const char *bpf_output_move (rtx *operands, const char *templ); class gimple_opt_pass; gimple_opt_pass *make_pass_lower_bpf_core (gcc::context *ctxt); +class simple_ipa_opt_pass; +simple_ipa_opt_pass *make_pass_bpf_deferred_static (gcc::context *ctxt); + bool bpf_expand_cpymem (rtx *, bool); bool bpf_expand_setmem (rtx *); diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc index d852e2fbd70..06fd34ff542 100644 --- a/gcc/config/bpf/bpf.cc +++ b/gcc/config/bpf/bpf.cc @@ -138,6 +138,25 @@ bpf_handle_preserve_access_index_attribute (tree *node, tree name, return NULL_TREE; } +/* Handle preserve_enum_values attribute, which can be applied to + enums. Just warn for non-enumeration types. */ + +static tree +bpf_handle_preserve_enum_values_attribute (tree *node, tree name, + tree args ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED, + bool *no_add_attrs) +{ + if (TREE_CODE (*node) != ENUMERAL_TYPE) + { + warning (OPT_Wattributes, + "%qE attribute only applies to enumeration types", name); + *no_add_attrs = true; + } + + return NULL_TREE; +} + /* Target-specific attributes. */ TARGET_GNU_ATTRIBUTES (bpf_attribute_table, @@ -155,6 +174,11 @@ TARGET_GNU_ATTRIBUTES (bpf_attribute_table, { "preserve_access_index", 0, -1, false, true, false, true, bpf_handle_preserve_access_index_attribute, NULL }, + /* CO-RE supoort: attribute to mark that all occurrences of values + of the declared enum should be recorded. */ + { "preserve_enum_values", 0, 0, false, true, false, true, + bpf_handle_preserve_enum_values_attribute, NULL }, + /* Support for `naked' function attribute. */ { "naked", 0, 1, false, false, false, false, bpf_handle_fndecl_attribute, NULL } diff --git a/gcc/config/bpf/core-builtins.cc b/gcc/config/bpf/core-builtins.cc index a5c973cd385..9930026119e 100644 --- a/gcc/config/bpf/core-builtins.cc +++ b/gcc/config/bpf/core-builtins.cc @@ -42,6 +42,9 @@ along with GCC; see the file COPYING3. If not see #include "tree-pass.h" #include "plugin.h" #include "gimplify.h" +#include "gimplify-me.h" +#include "cgraph.h" +#include "deferred-cst.h" #include "ctfc.h" #include "btf.h" @@ -356,6 +359,45 @@ is_attr_preserve_access (tree t) return false; } +/* Like is_attr_preserve_access, but FIELD is a FIELD_DECL. Returns + true if FIELD belongs to a struct type with the + PRESERVE_ACCESS_INDEX attribute. */ + +static bool +is_attr_preserve_access_field (tree field) +{ + gcc_assert (field && TREE_CODE (field) == FIELD_DECL); + + tree type = DECL_FIELD_CONTEXT (field); + + return (type + && TREE_CODE (type) == RECORD_TYPE + && lookup_attribute ("preserve_access_index", + TYPE_ATTRIBUTES (type))); +} + +/* Handling for __attribute__((preserve_enum_values)) for BPF CO-RE support. + + This attribute marks an enum type as "preserve", so that every use + of its values should be recorded and replayed by the BPF loader; + This is just the same functionality as __builtin_preserve_enum_value, + but in the form of an attribute for an entire enumeral type. */ + +/* True if DECL is a literal of an enumeral type which is marked with the + PRESERVE_ENUM_VALUES attribute. */ + +static bool +is_attr_preserve_enum_values (tree decl) +{ + gcc_assert (TREE_CODE (decl) == CONST_DECL); + + tree type = TREE_TYPE (decl); + gcc_assert (TREE_CODE (type) == ENUMERAL_TYPE); + + return lookup_attribute ("preserve_enum_values", + TYPE_ATTRIBUTES (type)) != NULL_TREE; +} + static tree root_for_core_field_info (tree node) { @@ -812,7 +854,6 @@ process_field_expr (struct cr_builtins *data) return ret; } -static GTY(()) hash_map *bpf_enum_mappings; tree enum_value_type = NULL_TREE; static int @@ -832,6 +873,74 @@ get_index_for_enum_value (tree type, tree expr) return -1; } +static bool +deferred_enum_value_call_p (tree expr) +{ + return (expr + && TREE_CODE (expr) == CALL_EXPR + && CALL_EXPR_IFN (expr) == IFN_DEFERRED_CST_ENUM_VALUE); +} + +static tree +enum_decl_from_deferred_call (tree call) +{ + if (!deferred_enum_value_call_p (call) + || call_expr_nargs (call) != 1) + return NULL_TREE; + + tree decl + = deferred_cst_ifn_enum_value_decl (CALL_EXPR_ARG (call, 0)); + + if (!decl + || TREE_CODE (decl) != CONST_DECL + || TREE_CODE (TREE_TYPE (decl)) != ENUMERAL_TYPE) + return NULL_TREE; + + return decl; +} + +static bool +deferred_field_offset_call_p (tree expr) +{ + return (expr + && TREE_CODE (expr) == CALL_EXPR + && CALL_EXPR_IFN (expr) == IFN_DEFERRED_CST_FIELD_OFFSET); +} + +static tree +field_decl_from_deferred_call (tree call) +{ + if (!deferred_field_offset_call_p (call) + || call_expr_nargs (call) != 1) + return NULL_TREE; + + tree field + = deferred_cst_ifn_field_offset_field (CALL_EXPR_ARG (call, 0)); + + if (!field || TREE_CODE (field) != FIELD_DECL) + return NULL_TREE; + + return field; +} + +/* Helper for pack_enum_value to retrieve the CONST_DECL for an enum + value that is given as argument to __builtin_preserve_enum_value. + + ENUM_VALUE is expected to be a DEFERRED_CST_EXPR wrapping only a + call to IFN_DEFERRED_CST_ENUM_VALUE, resembling a builtin parameter + that is only a canonical enum value (no complex expressions). + + Returns NULL_TREE on failure. */ + +static tree +deferred_cst_canonical_enum_value_decl (tree enum_value) +{ + if (!enum_value || TREE_CODE (enum_value) != DEFERRED_CST_EXPR) + return NULL_TREE; + + return enum_decl_from_deferred_call (TREE_OPERAND (enum_value, 0)); +} + /* Pack helper for the __builtin_preserve_enum_value. */ static struct cr_local @@ -842,9 +951,8 @@ pack_enum_value (tree *args, enum btf_core_reloc_kind kind, ret.reloc_decision = REPLACE_CREATE_RELOCATION; ret.fail = false; - tree *result = NULL; tree tmp = args[0]; - tree enum_value = args[1]; + tree deferred_enum_value = args[1]; tree type = NULL_TREE; /* Deconstructing "*(typeof (enum_type) *) enum_value" to collect both the @@ -859,33 +967,25 @@ pack_enum_value (tree *args, enum btf_core_reloc_kind kind, ret.fail = true; } - if (TREE_CODE (enum_value) != INTEGER_CST) - goto pack_enum_value_fail; - - result = bpf_enum_mappings->get (enum_value); - if (result == NULL) - goto pack_enum_value_fail; - - tmp = *result; - - if (TREE_CODE (tmp) != CONST_DECL) + tree enum_value + = deferred_cst_canonical_enum_value_decl (deferred_enum_value); + if (enum_value == NULL_TREE) { -pack_enum_value_fail: bpf_error ("invalid enum value argument for enum value builtin"); ret.fail = true; } else { - ret.reloc_data.expr = tmp; + ret.reloc_data.expr = enum_value; if (kind == BPF_RELO_ENUMVAL_VALUE) - ret.reloc_data.default_value = enum_value; + ret.reloc_data.default_value = DECL_INITIAL (enum_value); else ret.reloc_data.default_value = integer_one_node; } - if (ret.fail == false ) + if (ret.fail == false) { - int index = get_index_for_enum_value (type, tmp); + int index = get_index_for_enum_value (type, enum_value); if (index == -1 || index >= (1 << 16)) { bpf_error ("enum value in CO-RE builtin cannot be represented"); @@ -1101,10 +1201,15 @@ read_kind (tree kind, char max_value, char enum_offset) if (kind == NULL_TREE) goto invalid_kind_arg_error; - if (TREE_CODE (kind) != CONST_DECL - && TREE_CODE (kind) == NOP_EXPR) + if (TREE_CODE (kind) == NOP_EXPR) kind = TREE_OPERAND (kind, 0); + if (TREE_CODE (kind) == DEFERRED_CST_EXPR) + kind = deferred_cst_canonical_enum_value_decl (kind); + + if (kind == NULL_TREE) + goto invalid_kind_arg_error; + if (TREE_CODE (kind) == CONST_DECL) kind = DECL_INITIAL (kind); @@ -1178,8 +1283,10 @@ kind_preserve_type_info (tree *args, int nargs) return BPF_RELO_INVALID; } -/* Plugin handler used in the parser that allows to collect enum value - information that other wise would be folded and non recoverable. */ +/* Plugin handler used in the parser that allows to mark all enum types + and struct types attributed with "preserve_access_index" for constant + deferral. This preserves information that would otherwise be + folded by the frontend and non recoverable. */ void bpf_handle_plugin_finish_type (void *event_data, @@ -1187,22 +1294,12 @@ bpf_handle_plugin_finish_type (void *event_data, { tree type = (tree) event_data; - if (bpf_enum_mappings == NULL) - bpf_enum_mappings = hash_map::create_ggc (10); - if (TREE_CODE (type) == ENUMERAL_TYPE) - for (tree l = TYPE_VALUES (type); l; l = TREE_CHAIN (l)) - { - tree value = TREE_VALUE (l); - - tree initial = DECL_INITIAL (value); - initial = copy_node (initial); - DECL_INITIAL (value) = initial; - - tree *found = bpf_enum_mappings->get (initial); - if (found == NULL) - bpf_enum_mappings->put (initial, value); - } + deferred_cst_mark_type (type); + else if (TREE_CODE (type) == RECORD_TYPE + && lookup_attribute ("preserve_access_index", + TYPE_ATTRIBUTES (type))) + deferred_cst_mark_type (type); } /* Initializes support information to process CO-RE builtins. @@ -1258,6 +1355,25 @@ bpf_init_core_builtins (void) bpf_handle_plugin_finish_type, NULL); } +static tree +construct_core_reloc_from_data (location_t loc, + struct cr_builtins *reloc_data, + builtin_helpers helper) +{ + int index = search_builtin_data (helper.compare, reloc_data); + + if (index == -1) + index = allocate_builtin_data (); + + struct cr_builtins *data = get_builtin_data (index); + memcpy (data, reloc_data, sizeof (struct cr_builtins)); + + tree fndecl = bpf_builtins[BPF_BUILTIN_CORE_RELOC]; + + return build_call_expr_loc (loc, fndecl, 1, + build_int_cst (integer_type_node, index)); +} + /* This function returns the related __builtin_core_reloc call tree node to a particular CO-RE builtin definition in FNDECL when called with arguments ARGS. */ @@ -1294,23 +1410,364 @@ construct_builtin_core_reloc (location_t loc, tree fndecl, tree *args, return error_mark_node; if (local_data.reloc_decision == REPLACE_CREATE_RELOCATION) + return construct_core_reloc_from_data (loc, + &local_data.reloc_data, + helper); + } + return NULL_TREE; +} + +/* Build a relocation for the enumerator DECL at LOC. */ + +static tree +bpf_core_enum_value_reloc (location_t loc, tree decl) +{ + gcc_assert (TREE_CODE (decl) == CONST_DECL); + + tree type = TREE_TYPE (decl); + gcc_assert (TREE_CODE (type) == ENUMERAL_TYPE); + + int enum_index = get_index_for_enum_value (type, decl); + + if (enum_index < 0 || enum_index >= (1 << 16)) + { + error_at (loc, + "enum value cannot be represented in BPF CO-RE relocation"); + return error_mark_node; + } + + struct cr_builtins data; + memset (&data, 0, sizeof (data)); + + data.expr = decl; + data.type = type; + data.default_value = DECL_INITIAL (decl); + data.kind = BPF_RELO_ENUMVAL_VALUE; + data.orig_builtin_code = BPF_BUILTIN_PRESERVE_ENUM_VALUE; + data.orig_arg_expr = decl; + + builtin_helpers helper + = core_builtin_helpers[BPF_BUILTIN_PRESERVE_ENUM_VALUE]; + + return construct_core_reloc_from_data (loc, &data, helper); +} + +/* Build a relocation for the offset of FIELD at LOC. Internally + constructs a component reference for FIELD and passes it through + the existing preserve-field-info builtin machinery. */ + +static tree +bpf_core_field_offset_reloc (location_t loc, tree field) +{ + gcc_assert (TREE_CODE (field) == FIELD_DECL); + + tree record_type = DECL_FIELD_CONTEXT (field); + gcc_assert (TREE_CODE (record_type) == RECORD_TYPE); + + /* Build an artificial COMPONENT_REF solely to feed the existing + preserve-field-info packing machinery. */ + tree object = build_decl (loc, VAR_DECL, NULL_TREE, record_type); + DECL_ARTIFICIAL (object) = 1; + DECL_IGNORED_P (object) = 1; + + tree ref = build3_loc (loc, COMPONENT_REF, TREE_TYPE (field), + object, field, NULL_TREE); + + tree args[2]; + args[0] = ref; + args[1] = build_int_cst (integer_type_node, BPF_FIELD_BYTE_OFFSET); + + tree fndecl = bpf_builtins[BPF_BUILTIN_PRESERVE_FIELD_INFO]; + + return construct_builtin_core_reloc (loc, fndecl, args, 2); +} + +enum bpf_deferred_mode +{ + BPF_DEFERRED_GIMPLE, + BPF_DEFERRED_STATIC +}; + + +/* Lower the expression EXPR under a DEFERRED_CST_EXPR wrapper according + to MODE. + + Deferred enum values and field offsets selected for CO-RE via type + attributes are replaced by corresponding relocation expressions. + + Deferred values that are not selected for CO-RE are resolved to + their ordinary compile-time values. + + In BPF_DEFERRED_STATIC mode, CO-RE relocations may not be emitted. + Future instrumentation logic could automatically generate update-code + or relocations for static data that depends on CO-RE values. +*/ + +static tree +bpf_lower_deferred_inner (tree expr, enum bpf_deferred_mode mode) +{ + if (!expr) + return NULL_TREE; + + if (CONSTANT_CLASS_P (expr)) + return expr; + + if (TREE_CODE (expr) == DEFERRED_CST_EXPR) + { + error_at (EXPR_LOCATION (expr), "nested deferred constant expression"); + return error_mark_node; + } + + if (deferred_enum_value_call_p (expr)) + { + tree decl = enum_decl_from_deferred_call (expr); + + if (!decl) + { + error_at (EXPR_LOCATION (expr), + "malformed deferred enum value"); + return error_mark_node; + } + + if (!is_attr_preserve_enum_values (decl)) + return fold_convert_loc (EXPR_LOCATION (expr), + TREE_TYPE (expr), + DECL_INITIAL (decl)); + + if (mode == BPF_DEFERRED_STATIC) + { + error_at (EXPR_LOCATION (expr), + "BPF CO-RE enum values are not yet supported " + "in static initializers"); + + /* Remove the deferred node after diagnosing, so that the generic + deferred-CST barrier doesn't diagnose it again. */ + return fold_convert_loc (EXPR_LOCATION (expr), + TREE_TYPE (expr), + DECL_INITIAL (decl)); + } + + tree reloc + = bpf_core_enum_value_reloc (EXPR_LOCATION (expr), decl); + + if (reloc == error_mark_node) + return reloc; + + return fold_convert_loc (EXPR_LOCATION (expr), + TREE_TYPE (expr), reloc); + } + + if (deferred_field_offset_call_p (expr)) + { + tree field = field_decl_from_deferred_call (expr); + + if (!field) { - int index = search_builtin_data (helper.compare, - &local_data.reloc_data); - if (index == -1) - index = allocate_builtin_data (); - struct cr_builtins *data = get_builtin_data (index); - memcpy (data, &local_data.reloc_data, sizeof (struct cr_builtins)); - - tree fndecl = bpf_builtins[BPF_BUILTIN_CORE_RELOC]; - return build_call_expr_loc (loc, - fndecl, 1, - build_int_cst (integer_type_node, index)); + error_at (EXPR_LOCATION (expr), + "malformed deferred field offset"); + return error_mark_node; } + + if (!is_attr_preserve_access_field (field)) + return fold_convert_loc (EXPR_LOCATION (expr), + TREE_TYPE (expr), + byte_position (field)); + + if (mode == BPF_DEFERRED_STATIC) + { + error_at (EXPR_LOCATION (expr), + "BPF CO-RE field offsets are not yet supported " + "in static initializers"); + + return fold_convert_loc (EXPR_LOCATION (expr), + TREE_TYPE (expr), + byte_position (field)); + } + + tree reloc + = bpf_core_field_offset_reloc (EXPR_LOCATION (expr), field); + + if (reloc == error_mark_node) + return reloc; + + return fold_convert_loc (EXPR_LOCATION (expr), + TREE_TYPE (expr), reloc); } + + tree copy = copy_node (expr); + + for (int i = 0; i < TREE_OPERAND_LENGTH (expr); ++i) + { + tree op = TREE_OPERAND (expr, i); + + if (!op) + continue; + + TREE_OPERAND (copy, i) + = bpf_lower_deferred_inner (op, mode); + } + + return mode == BPF_DEFERRED_STATIC ? fold (copy) : copy; +} + +/* Lower a deferred constant expression WRAPPER according to the + transformations defined in bpf_lower_deferred_inner. */ + +static tree +bpf_lower_deferred_wrapper (tree wrapper, enum bpf_deferred_mode mode) +{ + gcc_assert (wrapper && TREE_CODE (wrapper) == DEFERRED_CST_EXPR); + + tree inner = TREE_OPERAND (wrapper, 0); + return bpf_lower_deferred_inner (inner, mode); +} + +/* Tree-walk callback for lowering deferred constants in GIMPLE statements. + + Replaces each DEFERRED_CST_EXPR with its lowered and gimplified + equivalent. Any new gimple statements are inserted immediately + before the current statement. */ + +static tree +bpf_lower_deferred_tree (tree *tp, int *walk_subtrees, void *data) +{ + tree node = *tp; + + if (!node) + return NULL_TREE; + + if (TYPE_P (node) || DECL_P (node)) + { + *walk_subtrees = 0; + return NULL_TREE; + } + + if (TREE_CODE (node) != DEFERRED_CST_EXPR) + return NULL_TREE; + + struct walk_stmt_info *wi + = static_cast (data); + + /* First transform the complete deferred expression. */ + tree replacement + = bpf_lower_deferred_wrapper (node, BPF_DEFERRED_GIMPLE); + + if (replacement == error_mark_node) + { + *tp = replacement; + *walk_subtrees = 0; + return NULL_TREE; + } + + /* Turn the resulting GENERIC expression into a GIMPLE value. Any + statements required to compute it are emitted into BEFORE. */ + gimple_seq before = NULL; + + push_gimplify_context (); + + gimplify_expr (&replacement, &before, NULL, + is_gimple_val, fb_rvalue); + + pop_gimplify_context (NULL); + + /* Insert computation of REPLACEMENT immediately before the + statement containing the original DEFERRED_CST_EXPR. */ + if (before) + gsi_insert_seq_before (&wi->gsi, before, GSI_SAME_STMT); + + /* REPLACEMENT is now a valid GIMPLE value. */ + *tp = replacement; + + /* Do not walk the newly generated expression. */ + *walk_subtrees = 0; + return NULL_TREE; } +/* Return true if the initializer expression EXPR contains deferred + constants. */ + +static bool +bpf_initializer_has_deferred (tree expr) +{ + if (!expr || DECL_P (expr) || TYPE_P (expr)) + return false; + + if (TREE_CODE (expr) == DEFERRED_CST_EXPR) + return true; + + if (TREE_CODE (expr) == CONSTRUCTOR) + { + unsigned HOST_WIDE_INT i; + tree index, value; + + FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (expr), i, index, value) + if (bpf_initializer_has_deferred (value)) + return true; + + return false; + } + + for (int i = 0; i < TREE_OPERAND_LENGTH (expr); ++i) + if (bpf_initializer_has_deferred (TREE_OPERAND (expr, i))) + return true; + + return false; +} + +/* Resolves deferred constants in the static initializer expression + EXPR. Deferred constants that do not require CO-RE relocations + (because the corresponding types are not attributed accordingly) + are replaced with their ordinary compile-time values. + + Expressions that would require CO-RE relocations are diagnosed as + errors. Support for those may be added in the future. */ + +static tree +bpf_transform_initializer (tree expr) +{ + if (!expr || DECL_P (expr) || TYPE_P (expr) || CONSTANT_CLASS_P (expr)) + return expr; + + if (TREE_CODE (expr) == DEFERRED_CST_EXPR) + return bpf_lower_deferred_wrapper (expr, BPF_DEFERRED_STATIC); + + if (TREE_CODE (expr) == CONSTRUCTOR) + { + vec *elts = NULL; + unsigned HOST_WIDE_INT i; + tree index, value; + + FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (expr), i, index, value) + { + tree replacement = bpf_transform_initializer (value); + CONSTRUCTOR_APPEND_ELT (elts, index, replacement); + } + + tree result = build_constructor (TREE_TYPE (expr), elts); + + TREE_CONSTANT (result) = TREE_CONSTANT (expr); + TREE_STATIC (result) = TREE_STATIC (expr); + + return result; + } + + if (!bpf_initializer_has_deferred (expr)) + return expr; + + tree copy = copy_node (expr); + + for (int i = 0; i < TREE_OPERAND_LENGTH (expr); ++i) + { + tree op = TREE_OPERAND (expr, i); + + if (op) + TREE_OPERAND (copy, i) = bpf_transform_initializer (op); + } + + return fold (copy); +} + /* This function constructs the CO-RE safe code around field expressions. If the expression is an array access, create an offset by multiplying the index access by the __builtin_type_info call requesting the size of the @@ -1944,11 +2401,13 @@ core_make_builtins (tree *tp, int *walk_subtrees, void *data) return NULL_TREE; } -/* This is the entry point for the pass_data_lower_bpg_core. It walks all the +/* This is the entry point for the pass_lower_bpf_core. It walks all the statements in gimple, looking for expressions that are suppose to be CO-RE preserve_access_index attributed, and should not. - It first splits CO-RE expressions from non CO-RE ones. - Then the CO-RE expressions are processed by core_make_builtins which will + It first instruments only deferred constant field offsets and enum values, + turning those relevant to CO-RE into relocations. + Then it splits all CO-RE expressions from non CO-RE ones. + Finally, the CO-RE expressions are processed by core_make_builtins which will create the required builtins that will result in the CO-RE relocations. */ static unsigned int execute_lower_bpf_core (void) @@ -1962,6 +2421,11 @@ execute_lower_bpf_core (void) struct walk_stmt_info wi; memset (&wi, 0, sizeof (wi)); + /* Deferred constants are still represented as GENERIC expression trees + embedded in GIMPLE operands. Replace their leaves with ordinary + constants or BPF CO-RE relocation calls. */ + walk_gimple_seq_mod (&body, NULL, bpf_lower_deferred_tree, &wi); + /* Early split to guarantee base of expression is a preserve_access_index structure. */ walk_gimple_seq_mod (&body, NULL, gimple_core_early_split_expr, &wi); @@ -1971,6 +2435,45 @@ execute_lower_bpf_core (void) return 0; } +/* This is the entry point for pass_bpf_deferred_static. It iterates + over all static initializers to lower deferred constants. */ + +static unsigned int +execute_bpf_deferred_static (void) +{ + if (!TARGET_BPF_CORE) + return 0; + + varpool_node *vnode; + + FOR_EACH_VARIABLE (vnode) + { + tree decl = vnode->decl; + + if (!decl + || TREE_CODE (decl) != VAR_DECL + || DECL_EXTERNAL (decl) + || !TREE_STATIC (decl)) + continue; + + tree init = DECL_INITIAL (decl); + + if (!init || !bpf_initializer_has_deferred (init)) + continue; + + tree replacement = bpf_transform_initializer (init); + + DECL_INITIAL (decl) = replacement; + + /* Even after emitting an error for an attributed leaf we replace it by + its local compile-time value. Therefore absolutely no deferred node + should survive this pass. */ + gcc_assert (!bpf_initializer_has_deferred (replacement)); + } + + return 0; +} + namespace { const pass_data pass_data_lower_bpf_core = @@ -2001,6 +2504,32 @@ public: }; /* class pass_lower_bpf_core */ +const pass_data pass_data_bpf_deferred_static = +{ + SIMPLE_IPA_PASS, /* type */ + "bpf_deferred_static", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_NONE, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_bpf_deferred_static : public simple_ipa_opt_pass +{ +public: + pass_bpf_deferred_static (gcc::context *ctxt) + : simple_ipa_opt_pass (pass_data_bpf_deferred_static, ctxt) + {} + + unsigned int execute (function *) final override + { + return execute_bpf_deferred_static (); + } +}; + } /* anon namespace */ gimple_opt_pass * @@ -2009,4 +2538,10 @@ make_pass_lower_bpf_core (gcc::context *ctxt) return new pass_lower_bpf_core (ctxt); } +simple_ipa_opt_pass * +make_pass_bpf_deferred_static (gcc::context *ctxt) +{ + return new pass_bpf_deferred_static (ctxt); +} + #include "gt-core-builtins.h" diff --git a/gcc/testsuite/gcc.target/bpf/core-auto-drain-1.c b/gcc/testsuite/gcc.target/bpf/core-auto-drain-1.c new file mode 100644 index 00000000000..660b5df9d3f --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-auto-drain-1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -dA -gbtf -mco-re -masm=normal" } */ + +enum E +{ + A = 1, + B = 2 +}; + +int +foo (void) +{ + return B; +} + +struct S +{ + int a; + long b; + int c; +}; + +unsigned long +bar (void) +{ + return __builtin_offsetof (struct S, c); +} + +/* { dg-final { scan-assembler-not "bpfcr_kind" } } */ diff --git a/gcc/testsuite/gcc.target/bpf/core-auto-enum-value-1.c b/gcc/testsuite/gcc.target/bpf/core-auto-enum-value-1.c new file mode 100644 index 00000000000..2bd21fa6146 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-auto-enum-value-1.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -dA -gbtf -mco-re -masm=normal" } */ + +enum E +{ + A = 1, + B = 1, + C = 3 +} __attribute__((preserve_enum_values)); + +int +foo (void) +{ + return A + B + C; +} + +/* Check the local values. A and B deliberately have the same value. */ +/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],1" 2 } } */ +/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],3" 1 } } */ + +/* Check the BTF access strings for the three enumerators. */ +/* { dg-final { scan-assembler-times "ascii \"0.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"1.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"2.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ + +/* Check that the relocations identify A, B and C independently. */ +/* { dg-final { scan-assembler-times "bpfcr_type \\(E\\)" 3 } } */ +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0\"\\)" 1 } } */ +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"1\"\\)" 1 } } */ +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"2\"\\)" 1 } } */ + +/* All three are BPF_CORE_ENUMVAL_VALUE relocations. */ +/* { dg-final { scan-assembler-times "0xb\[\t \]+\[^\n\]*bpfcr_kind" 3 } } */ diff --git a/gcc/testsuite/gcc.target/bpf/core-auto-field-offset-1.c b/gcc/testsuite/gcc.target/bpf/core-auto-field-offset-1.c new file mode 100644 index 00000000000..e06d42ef45c --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/core-auto-field-offset-1.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -dA -gbtf -mco-re -masm=normal" } */ + +struct S +{ + int a; + long b; + int c; +} __attribute__((preserve_access_index)); + +unsigned long +foo (void) +{ + return (__builtin_offsetof (struct S, a) + + __builtin_offsetof (struct S, b) + + __builtin_offsetof (struct S, c)); +} + +/* Check the local field offsets. */ +/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],0" 1 } } */ +/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],8" 1 } } */ +/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],16" 1 } } */ + +/* Check the BTF access strings. */ +/* { dg-final { scan-assembler-times "ascii \"0:0.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"0:1.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"0:2.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ + +/* Check that each relocation identifies the correct field. */ +/* { dg-final { scan-assembler-times "bpfcr_type \\(struct S\\)" 3 } } */ +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0:0\"\\)" 1 } } */ +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0:1\"\\)" 1 } } */ +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0:2\"\\)" 1 } } */ + +/* All three are BPF_FIELD_BYTE_OFFSET relocations. */ +/* { dg-final { scan-assembler-times "0\[\t \]+\[^\n\]*bpfcr_kind" 3 } } */ -- 2.43.0 From torbjorn.svensson@foss.st.com Sun Nov 1 08:48:38 2026 From: torbjorn.svensson@foss.st.com (Torbjorn SVENSSON) Date: Sun, 1 Nov 2026 09:48:38 +0100 Subject: [PATCH] match/fold: Fix combine_comparisons for vector(signed) boolean types [PR128123] In-Reply-To: <20261025175404.1885861-1-andrew.pinski@oss.qualcomm.com> References: <20261025175404.1885861-1-andrew.pinski@oss.qualcomm.com> Message-ID: <017b85db-7c4c-43da-a7fb-0f3323c90df5@foss.st.com> Hi, The new test is failing for MVE enabled targets on arm-none-eabi. These are the errors produced for thumb/arch=armv8.1-m.main+mve.fp+fp.dp/cpu=cortex-m55/float-abi=hard/fpu=auto: /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c: In function 'a': /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:10:14: error: incompatible types when initializing type 'v4sib' {aka '__vector(4) signed char:4'} using type '__vector(4) int' /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:11:14: error: incompatible types when initializing type 'v4sib' {aka '__vector(4) signed char:4'} using type '__vector(4) int' /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:12:3: error: cannot convert a value of type '__vector(4) signed char' to vector type '__vector(4) int' which has different size /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c: In function 'b': /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:17:14: error: incompatible types when initializing type 'v4sib' {aka '__vector(4) signed char:4'} using type '__vector(4) int' /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:18:14: error: incompatible types when initializing type 'v4sib' {aka '__vector(4) signed char:4'} using type '__vector(4) int' /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:19:3: error: cannot convert a value of type '__vector(4) signed char' to vector type '__vector(4) int' which has different size Any idea how to fix? Kind regards, Torbj?rn On 2026-10-25 18:54, Andrea Pinski wrote: > r17-4001-gbbc2517fe41 added support to combine_comparisons for LT/LE/GT/GE > but it assumed unsigned boolean types ([0,1]) which is wrong for signed > boolean types ([0,-1]). For an example, for signed boolean types, > LT is the same as GT for unsigned boolean types. So this was combining > incorrectly and getting the incorrect answer. > This fixes the problem by adding support for signed boolean. Since we > need to pass in a new argument to combine_comparisons, this updates > all of the uses of combine_comparisons which makes the patch > look bigger than it really is. > > Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > PR tree-optimization/128123 > > gcc/ChangeLog: > > * fold-const.cc (combine_comparisons): Take new argument, > inner_truth_type and look to see if it is signed boolean > and support that for LT/LE/GT/GE. > (fold_truth_andor_1): Update call to combine_comparisons. > * fold-const.h (combine_comparisons): Add new argument. > * gimple-fold.cc (and_comparisons_1): Update call to > combine_comparisons. > (or_comparisons_1): Likewise. > * tree-ssa-ifcombine.cc (ifcombine_ifandif): Likewise. > * tree-ssa-phiopt.cc (comparison_combine): Likewise. > * match.pd (`(CMP) OP (CMP)`): Update call to > combine_comparisons. > > gcc/testsuite/ChangeLog: > > * gcc.dg/tree-ssa/vect-cmp-cmp-1.c: New test. > > Signed-off-by: Andrea Pinski > --- > gcc/fold-const.cc | 54 ++++++++++++++----- > gcc/fold-const.h | 4 +- > gcc/gimple-fold.cc | 8 +-- > gcc/match.pd | 5 +- > .../gcc.dg/tree-ssa/vect-cmp-cmp-1.c | 34 ++++++++++++ > gcc/tree-ssa-ifcombine.cc | 15 ++++-- > gcc/tree-ssa-phiopt.cc | 2 +- > 7 files changed, 95 insertions(+), 27 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c > > diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc > index 1fc4941b481..047c7dcada4 100644 > --- a/gcc/fold-const.cc > +++ b/gcc/fold-const.cc > @@ -3010,13 +3010,21 @@ inverse_conditions_p (const_tree cond1, const_tree cond2) > > enum tree_code > combine_comparisons (enum tree_code code, enum tree_code lcode, > - enum tree_code rcode, tree truth_type, > - bool honor_nans, tree *res) > + enum tree_code rcode, tree truth_type, > + tree inner_truth_type, > + bool honor_nans, tree *res) > { > enum comparison_code lcompcode = comparison_to_compcode (lcode); > enum comparison_code rcompcode = comparison_to_compcode (rcode); > int compcode; > *res = NULL_TREE; > + if (TREE_CODE (inner_truth_type) == VECTOR_TYPE) > + inner_truth_type = TREE_TYPE (inner_truth_type); > + bool signed_bool = false; > + if (TYPE_SIGN (inner_truth_type) == SIGNED > + && (TREE_CODE (inner_truth_type) == BOOLEAN_TYPE > + || TYPE_PRECISION (inner_truth_type) == 1)) > + signed_bool = true; > > switch (code) > { > @@ -3039,24 +3047,40 @@ combine_comparisons (enum tree_code code, enum tree_code lcode, > compcode = ~(lcompcode ^ rcompcode); > break; > > - //`bool0 < bool1` is `!bool0 & bool1` > + //`bool0 < bool1` is `!bool0 & bool1` for unsigned > + //`bool0 < bool1` is `bool0 & !bool1` for signed > case LT_EXPR: > - compcode = ~lcompcode & rcompcode; > + if (signed_bool) > + compcode = lcompcode & ~rcompcode; > + else > + compcode = ~lcompcode & rcompcode; > break; > > - //`bool0 > bool1` is `bool0 & !bool1` > + //`bool0 > bool1` is `bool0 & !bool1` for unsigned > + //`bool0 > bool1` is `!bool0 & bool1` for signed > case GT_EXPR: > - compcode = lcompcode & ~rcompcode; > + if (signed_bool) > + compcode = ~lcompcode & rcompcode; > + else > + compcode = lcompcode & ~rcompcode; > break; > > - // `bool0 <= bool1` as !bool0 | bool1 > + // `bool0 <= bool1` as !bool0 | bool1 for unsigned > + // `bool0 <= bool1` as bool0 | !bool1 for signed > case LE_EXPR: > - compcode = ~lcompcode | rcompcode; > + if (signed_bool) > + compcode = lcompcode | ~rcompcode; > + else > + compcode = ~lcompcode | rcompcode; > break; > > - //`bool0 >= bool1` is `bool0 | !bool1` > + //`bool0 >= bool1` is `bool0 | !bool1` for unsigned > + //`bool0 >= bool1` is `bool0 | !bool1` for signed > case GE_EXPR: > - compcode = lcompcode | ~rcompcode; > + if (signed_bool) > + compcode = ~lcompcode | rcompcode; > + else > + compcode = lcompcode | ~rcompcode; > break; > > default: > @@ -3136,12 +3160,14 @@ tree > combine_comparisons (location_t loc, > enum tree_code code, enum tree_code lcode, > enum tree_code rcode, tree truth_type, > + tree inner_truth_type, > tree ll_arg, tree lr_arg) > { > bool honor_nans = HONOR_NANS (ll_arg); > tree_code rescode; > tree res; > - rescode = combine_comparisons (code, lcode, rcode, truth_type, > + rescode = combine_comparisons (code, lcode, rcode, > + truth_type, inner_truth_type, > honor_nans, &res); > if (rescode == ERROR_MARK) > return NULL_TREE; > @@ -6504,7 +6530,8 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type, > && operand_equal_p (lr_arg, rr_arg, 0)) > { > result = combine_comparisons (loc, code, lcode, rcode, > - truth_type, ll_arg, lr_arg); > + truth_type, TREE_TYPE (lhs), > + ll_arg, lr_arg); > if (result) > return result; > } > @@ -6513,7 +6540,8 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type, > { > result = combine_comparisons (loc, code, lcode, > swap_tree_comparison (rcode), > - truth_type, ll_arg, lr_arg); > + truth_type, TREE_TYPE (lhs), > + ll_arg, lr_arg); > if (result) > return result; > } > diff --git a/gcc/fold-const.h b/gcc/fold-const.h > index 437d8ece021..4e640de725f 100644 > --- a/gcc/fold-const.h > +++ b/gcc/fold-const.h > @@ -180,9 +180,9 @@ extern bool fold_cmp_float_cst_p (const wide_int &lo, const wide_int &hi, > const wide_int &i, signop isign); > > extern tree combine_comparisons (location_t, enum tree_code, enum tree_code, > - enum tree_code, tree, tree, tree); > + enum tree_code, tree, tree, tree, tree); > extern tree_code combine_comparisons (enum tree_code, enum tree_code, > - enum tree_code, tree, bool, tree*); > + enum tree_code, tree, tree, bool, tree*); > extern void debug_fold_checksum (const_tree); > extern bool may_negate_without_overflow_p (const_tree); > #define round_up(T,N) round_up_loc (UNKNOWN_LOCATION, T, N) > diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc > index e0197edece6..ed84dab7f37 100644 > --- a/gcc/gimple-fold.cc > +++ b/gcc/gimple-fold.cc > @@ -7602,7 +7602,7 @@ and_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, > /* Result will be either NULL_TREE, or a combined comparison. */ > tree t = combine_comparisons (UNKNOWN_LOCATION, > TRUTH_ANDIF_EXPR, code1, code2, > - truth_type, op1a, op1b); > + truth_type, truth_type, op1a, op1b); > if (t) > return t; > } > @@ -7615,7 +7615,7 @@ and_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, > tree t = combine_comparisons (UNKNOWN_LOCATION, > TRUTH_ANDIF_EXPR, code1, > swap_tree_comparison (code2), > - truth_type, op1a, op1b); > + truth_type, truth_type, op1a, op1b); > if (t) > return t; > } > @@ -9574,7 +9574,7 @@ or_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, > /* Result will be either NULL_TREE, or a combined comparison. */ > tree t = combine_comparisons (UNKNOWN_LOCATION, > TRUTH_ORIF_EXPR, code1, code2, > - truth_type, op1a, op1b); > + truth_type, truth_type, op1a, op1b); > if (t) > return t; > } > @@ -9587,7 +9587,7 @@ or_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, > tree t = combine_comparisons (UNKNOWN_LOCATION, > TRUTH_ORIF_EXPR, code1, > swap_tree_comparison (code2), > - truth_type, op1a, op1b); > + truth_type, truth_type, op1a, op1b); > if (t) > return t; > } > diff --git a/gcc/match.pd b/gcc/match.pd > index 696e69fd980..02941a7dacf 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -3771,14 +3771,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > (for cmp1 (tcc_comparison) > (for cmp2 (tcc_comparison) > (simplify > - (bitop (cmp1 @0 @1) (cmp2 @0 @1)) > + (bitop (cmp1@2 @0 @1) (cmp2 @0 @1)) > (with rescmpcode (tcc_comparison) > { > tree_code rescmpcode; > tree res; > bool honor_nans = HONOR_NANS (@0); > rescmpcode = combine_comparisons (bitop, cmp1, cmp2, > - type, honor_nans, &res); > + type, TREE_TYPE (@2), > + honor_nans, &res); > } > (if (rescmpcode == INTEGER_CST) > { res; } > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c b/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c > new file mode 100644 > index 00000000000..8ccf94df274 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c > @@ -0,0 +1,34 @@ > +/* { dg-do run } */ > +/* { dg-options "-O -fgimple" } */ > +/* PR tree-optimization/128123 */ > + > +typedef int v4si __attribute__((vector_size (4*sizeof(int)))); > +typedef v4si v4sib __attribute__((vector_mask)); > + > +__attribute__((noipa)) void a(v4si *x, v4si *y, v4si *res) > +{ > + v4sib m1 = *x < *y; > + v4sib m2 = *x > *y; > + *res = (v4si) (m1 < m2); > +} > + > +__attribute__((noipa)) void b(v4si *x, v4si *y, v4si *res) > +{ > + v4sib m1 = *x < *y; > + v4sib m2 = *x > *y; > + *res = (v4si) (m1 <= m2); > +} > + > +int main (void) > +{ > + v4si x = { 1, 2, 3, 4 }, y = { 2, 2, 2, 5 }; > + v4si r; > + a(&x, &y, &r); > + v4si s; > + b(&x, &y, &s); > + for (int i = 0; i < 4; i++) > + if (r[i] != -(x[i] < y[i]) || s[i] != -(x[i] <= y[i])) > + __builtin_abort(); > + return 0; > +} > + > diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc > index 28bb5bf0998..0d663f4130b 100644 > --- a/gcc/tree-ssa-ifcombine.cc > +++ b/gcc/tree-ssa-ifcombine.cc > @@ -865,14 +865,16 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, > if (!inner_inv && !outer_inv) > res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ANDIF_EXPR, > outer_cond_code, inner_cond_code, > - boolean_type_node, larg, rarg); > + boolean_type_node, boolean_type_node, > + larg, rarg); > // If both are inverse, `!a && !b`, then handle it as `!(a || b)` > // As that !a or !b are most likely not producing a comparison code. > else if (inner_inv && outer_inv) > { > res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ORIF_EXPR, > outer_cond_code, inner_cond_code, > - boolean_type_node, larg, rarg); > + boolean_type_node, boolean_type_node, > + larg, rarg); > if (res) > res = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (res), res); > } > @@ -891,7 +893,8 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, > if (inner_cond_code1 != ERROR_MARK && outer_cond_code1 != ERROR_MARK) > res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ANDIF_EXPR, > outer_cond_code1, inner_cond_code1, > - boolean_type_node, larg, rarg); > + boolean_type_node, boolean_type_node, > + larg, rarg); > // Otherwise, we need to try `!(!a || b) > else if (inner_cond_code1 == ERROR_MARK) > { > @@ -901,7 +904,8 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, > if (outer_cond_code1 != ERROR_MARK) > res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ORIF_EXPR, > outer_cond_code1, inner_cond_code, > - boolean_type_node, larg, rarg); > + boolean_type_node, boolean_type_node, > + larg, rarg); > if (res) > res = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (res), res); > } > @@ -914,7 +918,8 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, > if (inner_cond_code1 != ERROR_MARK) > res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ORIF_EXPR, > outer_cond_code, inner_cond_code1, > - boolean_type_node, larg, rarg); > + boolean_type_node, boolean_type_node, > + larg, rarg); > if (res) > res = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (res), res); > } > diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc > index 08b40897a60..51553484226 100644 > --- a/gcc/tree-ssa-phiopt.cc > +++ b/gcc/tree-ssa-phiopt.cc > @@ -1651,7 +1651,7 @@ comparison_combine (basic_block cond_bb, basic_block middle_bb, > tree result; > tree_code newcmp_code; > newcmp_code = combine_comparisons (logical, outer_code, inner_code, > - boolean_type_node, > + boolean_type_node, boolean_type_node, > HONOR_NANS (larg), &result); > if (newcmp_code == ERROR_MARK) > return false; From andrew.pinski@oss.qualcomm.com Sun Nov 1 08:52:55 2026 From: andrew.pinski@oss.qualcomm.com (Andrea Pinski) Date: Sun, 1 Nov 2026 01:52:55 -0700 Subject: [PATCH] match/fold: Fix combine_comparisons for vector(signed) boolean types [PR128123] In-Reply-To: <017b85db-7c4c-43da-a7fb-0f3323c90df5@foss.st.com> References: <20261025175404.1885861-1-andrew.pinski@oss.qualcomm.com> <017b85db-7c4c-43da-a7fb-0f3323c90df5@foss.st.com> Message-ID: On Sun, Nov 1, 2026 at 1:48?AM Torbjorn SVENSSON wrote: > > Hi, > > The new test is failing for MVE enabled targets on arm-none-eabi. > > These are the errors produced for thumb/arch=armv8.1-m.main+mve.fp+fp.dp/cpu=cortex-m55/float-abi=hard/fpu=auto: > > /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c: In function 'a': > /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:10:14: error: incompatible types when initializing type 'v4sib' {aka '__vector(4) signed char:4'} using type '__vector(4) int' > /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:11:14: error: incompatible types when initializing type 'v4sib' {aka '__vector(4) signed char:4'} using type '__vector(4) int' > /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:12:3: error: cannot convert a value of type '__vector(4) signed char' to vector type '__vector(4) int' which has different size > /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c: In function 'b': > /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:17:14: error: incompatible types when initializing type 'v4sib' {aka '__vector(4) signed char:4'} using type '__vector(4) int' > /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:18:14: error: incompatible types when initializing type 'v4sib' {aka '__vector(4) signed char:4'} using type '__vector(4) int' > /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:19:3: error: cannot convert a value of type '__vector(4) signed char' to vector type '__vector(4) int' which has different size > > Any idea how to fix? Yes, the best option is just to have it tested for x86_64/i386 and aarch64. vector_mask is not very portable. > > Kind regards, > Torbj?rn > > On 2026-10-25 18:54, Andrea Pinski wrote: > > r17-4001-gbbc2517fe41 added support to combine_comparisons for LT/LE/GT/GE > > but it assumed unsigned boolean types ([0,1]) which is wrong for signed > > boolean types ([0,-1]). For an example, for signed boolean types, > > LT is the same as GT for unsigned boolean types. So this was combining > > incorrectly and getting the incorrect answer. > > This fixes the problem by adding support for signed boolean. Since we > > need to pass in a new argument to combine_comparisons, this updates > > all of the uses of combine_comparisons which makes the patch > > look bigger than it really is. > > > > Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > > > PR tree-optimization/128123 > > > > gcc/ChangeLog: > > > > * fold-const.cc (combine_comparisons): Take new argument, > > inner_truth_type and look to see if it is signed boolean > > and support that for LT/LE/GT/GE. > > (fold_truth_andor_1): Update call to combine_comparisons. > > * fold-const.h (combine_comparisons): Add new argument. > > * gimple-fold.cc (and_comparisons_1): Update call to > > combine_comparisons. > > (or_comparisons_1): Likewise. > > * tree-ssa-ifcombine.cc (ifcombine_ifandif): Likewise. > > * tree-ssa-phiopt.cc (comparison_combine): Likewise. > > * match.pd (`(CMP) OP (CMP)`): Update call to > > combine_comparisons. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.dg/tree-ssa/vect-cmp-cmp-1.c: New test. > > > > Signed-off-by: Andrea Pinski > > --- > > gcc/fold-const.cc | 54 ++++++++++++++----- > > gcc/fold-const.h | 4 +- > > gcc/gimple-fold.cc | 8 +-- > > gcc/match.pd | 5 +- > > .../gcc.dg/tree-ssa/vect-cmp-cmp-1.c | 34 ++++++++++++ > > gcc/tree-ssa-ifcombine.cc | 15 ++++-- > > gcc/tree-ssa-phiopt.cc | 2 +- > > 7 files changed, 95 insertions(+), 27 deletions(-) > > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c > > > > diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc > > index 1fc4941b481..047c7dcada4 100644 > > --- a/gcc/fold-const.cc > > +++ b/gcc/fold-const.cc > > @@ -3010,13 +3010,21 @@ inverse_conditions_p (const_tree cond1, const_tree cond2) > > > > enum tree_code > > combine_comparisons (enum tree_code code, enum tree_code lcode, > > - enum tree_code rcode, tree truth_type, > > - bool honor_nans, tree *res) > > + enum tree_code rcode, tree truth_type, > > + tree inner_truth_type, > > + bool honor_nans, tree *res) > > { > > enum comparison_code lcompcode = comparison_to_compcode (lcode); > > enum comparison_code rcompcode = comparison_to_compcode (rcode); > > int compcode; > > *res = NULL_TREE; > > + if (TREE_CODE (inner_truth_type) == VECTOR_TYPE) > > + inner_truth_type = TREE_TYPE (inner_truth_type); > > + bool signed_bool = false; > > + if (TYPE_SIGN (inner_truth_type) == SIGNED > > + && (TREE_CODE (inner_truth_type) == BOOLEAN_TYPE > > + || TYPE_PRECISION (inner_truth_type) == 1)) > > + signed_bool = true; > > > > switch (code) > > { > > @@ -3039,24 +3047,40 @@ combine_comparisons (enum tree_code code, enum tree_code lcode, > > compcode = ~(lcompcode ^ rcompcode); > > break; > > > > - //`bool0 < bool1` is `!bool0 & bool1` > > + //`bool0 < bool1` is `!bool0 & bool1` for unsigned > > + //`bool0 < bool1` is `bool0 & !bool1` for signed > > case LT_EXPR: > > - compcode = ~lcompcode & rcompcode; > > + if (signed_bool) > > + compcode = lcompcode & ~rcompcode; > > + else > > + compcode = ~lcompcode & rcompcode; > > break; > > > > - //`bool0 > bool1` is `bool0 & !bool1` > > + //`bool0 > bool1` is `bool0 & !bool1` for unsigned > > + //`bool0 > bool1` is `!bool0 & bool1` for signed > > case GT_EXPR: > > - compcode = lcompcode & ~rcompcode; > > + if (signed_bool) > > + compcode = ~lcompcode & rcompcode; > > + else > > + compcode = lcompcode & ~rcompcode; > > break; > > > > - // `bool0 <= bool1` as !bool0 | bool1 > > + // `bool0 <= bool1` as !bool0 | bool1 for unsigned > > + // `bool0 <= bool1` as bool0 | !bool1 for signed > > case LE_EXPR: > > - compcode = ~lcompcode | rcompcode; > > + if (signed_bool) > > + compcode = lcompcode | ~rcompcode; > > + else > > + compcode = ~lcompcode | rcompcode; > > break; > > > > - //`bool0 >= bool1` is `bool0 | !bool1` > > + //`bool0 >= bool1` is `bool0 | !bool1` for unsigned > > + //`bool0 >= bool1` is `bool0 | !bool1` for signed > > case GE_EXPR: > > - compcode = lcompcode | ~rcompcode; > > + if (signed_bool) > > + compcode = ~lcompcode | rcompcode; > > + else > > + compcode = lcompcode | ~rcompcode; > > break; > > > > default: > > @@ -3136,12 +3160,14 @@ tree > > combine_comparisons (location_t loc, > > enum tree_code code, enum tree_code lcode, > > enum tree_code rcode, tree truth_type, > > + tree inner_truth_type, > > tree ll_arg, tree lr_arg) > > { > > bool honor_nans = HONOR_NANS (ll_arg); > > tree_code rescode; > > tree res; > > - rescode = combine_comparisons (code, lcode, rcode, truth_type, > > + rescode = combine_comparisons (code, lcode, rcode, > > + truth_type, inner_truth_type, > > honor_nans, &res); > > if (rescode == ERROR_MARK) > > return NULL_TREE; > > @@ -6504,7 +6530,8 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type, > > && operand_equal_p (lr_arg, rr_arg, 0)) > > { > > result = combine_comparisons (loc, code, lcode, rcode, > > - truth_type, ll_arg, lr_arg); > > + truth_type, TREE_TYPE (lhs), > > + ll_arg, lr_arg); > > if (result) > > return result; > > } > > @@ -6513,7 +6540,8 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type, > > { > > result = combine_comparisons (loc, code, lcode, > > swap_tree_comparison (rcode), > > - truth_type, ll_arg, lr_arg); > > + truth_type, TREE_TYPE (lhs), > > + ll_arg, lr_arg); > > if (result) > > return result; > > } > > diff --git a/gcc/fold-const.h b/gcc/fold-const.h > > index 437d8ece021..4e640de725f 100644 > > --- a/gcc/fold-const.h > > +++ b/gcc/fold-const.h > > @@ -180,9 +180,9 @@ extern bool fold_cmp_float_cst_p (const wide_int &lo, const wide_int &hi, > > const wide_int &i, signop isign); > > > > extern tree combine_comparisons (location_t, enum tree_code, enum tree_code, > > - enum tree_code, tree, tree, tree); > > + enum tree_code, tree, tree, tree, tree); > > extern tree_code combine_comparisons (enum tree_code, enum tree_code, > > - enum tree_code, tree, bool, tree*); > > + enum tree_code, tree, tree, bool, tree*); > > extern void debug_fold_checksum (const_tree); > > extern bool may_negate_without_overflow_p (const_tree); > > #define round_up(T,N) round_up_loc (UNKNOWN_LOCATION, T, N) > > diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc > > index e0197edece6..ed84dab7f37 100644 > > --- a/gcc/gimple-fold.cc > > +++ b/gcc/gimple-fold.cc > > @@ -7602,7 +7602,7 @@ and_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, > > /* Result will be either NULL_TREE, or a combined comparison. */ > > tree t = combine_comparisons (UNKNOWN_LOCATION, > > TRUTH_ANDIF_EXPR, code1, code2, > > - truth_type, op1a, op1b); > > + truth_type, truth_type, op1a, op1b); > > if (t) > > return t; > > } > > @@ -7615,7 +7615,7 @@ and_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, > > tree t = combine_comparisons (UNKNOWN_LOCATION, > > TRUTH_ANDIF_EXPR, code1, > > swap_tree_comparison (code2), > > - truth_type, op1a, op1b); > > + truth_type, truth_type, op1a, op1b); > > if (t) > > return t; > > } > > @@ -9574,7 +9574,7 @@ or_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, > > /* Result will be either NULL_TREE, or a combined comparison. */ > > tree t = combine_comparisons (UNKNOWN_LOCATION, > > TRUTH_ORIF_EXPR, code1, code2, > > - truth_type, op1a, op1b); > > + truth_type, truth_type, op1a, op1b); > > if (t) > > return t; > > } > > @@ -9587,7 +9587,7 @@ or_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, > > tree t = combine_comparisons (UNKNOWN_LOCATION, > > TRUTH_ORIF_EXPR, code1, > > swap_tree_comparison (code2), > > - truth_type, op1a, op1b); > > + truth_type, truth_type, op1a, op1b); > > if (t) > > return t; > > } > > diff --git a/gcc/match.pd b/gcc/match.pd > > index 696e69fd980..02941a7dacf 100644 > > --- a/gcc/match.pd > > +++ b/gcc/match.pd > > @@ -3771,14 +3771,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > > (for cmp1 (tcc_comparison) > > (for cmp2 (tcc_comparison) > > (simplify > > - (bitop (cmp1 @0 @1) (cmp2 @0 @1)) > > + (bitop (cmp1@2 @0 @1) (cmp2 @0 @1)) > > (with rescmpcode (tcc_comparison) > > { > > tree_code rescmpcode; > > tree res; > > bool honor_nans = HONOR_NANS (@0); > > rescmpcode = combine_comparisons (bitop, cmp1, cmp2, > > - type, honor_nans, &res); > > + type, TREE_TYPE (@2), > > + honor_nans, &res); > > } > > (if (rescmpcode == INTEGER_CST) > > { res; } > > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c b/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c > > new file mode 100644 > > index 00000000000..8ccf94df274 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c > > @@ -0,0 +1,34 @@ > > +/* { dg-do run } */ > > +/* { dg-options "-O -fgimple" } */ > > +/* PR tree-optimization/128123 */ > > + > > +typedef int v4si __attribute__((vector_size (4*sizeof(int)))); > > +typedef v4si v4sib __attribute__((vector_mask)); > > + > > +__attribute__((noipa)) void a(v4si *x, v4si *y, v4si *res) > > +{ > > + v4sib m1 = *x < *y; > > + v4sib m2 = *x > *y; > > + *res = (v4si) (m1 < m2); > > +} > > + > > +__attribute__((noipa)) void b(v4si *x, v4si *y, v4si *res) > > +{ > > + v4sib m1 = *x < *y; > > + v4sib m2 = *x > *y; > > + *res = (v4si) (m1 <= m2); > > +} > > + > > +int main (void) > > +{ > > + v4si x = { 1, 2, 3, 4 }, y = { 2, 2, 2, 5 }; > > + v4si r; > > + a(&x, &y, &r); > > + v4si s; > > + b(&x, &y, &s); > > + for (int i = 0; i < 4; i++) > > + if (r[i] != -(x[i] < y[i]) || s[i] != -(x[i] <= y[i])) > > + __builtin_abort(); > > + return 0; > > +} > > + > > diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc > > index 28bb5bf0998..0d663f4130b 100644 > > --- a/gcc/tree-ssa-ifcombine.cc > > +++ b/gcc/tree-ssa-ifcombine.cc > > @@ -865,14 +865,16 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, > > if (!inner_inv && !outer_inv) > > res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ANDIF_EXPR, > > outer_cond_code, inner_cond_code, > > - boolean_type_node, larg, rarg); > > + boolean_type_node, boolean_type_node, > > + larg, rarg); > > // If both are inverse, `!a && !b`, then handle it as `!(a || b)` > > // As that !a or !b are most likely not producing a comparison code. > > else if (inner_inv && outer_inv) > > { > > res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ORIF_EXPR, > > outer_cond_code, inner_cond_code, > > - boolean_type_node, larg, rarg); > > + boolean_type_node, boolean_type_node, > > + larg, rarg); > > if (res) > > res = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (res), res); > > } > > @@ -891,7 +893,8 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, > > if (inner_cond_code1 != ERROR_MARK && outer_cond_code1 != ERROR_MARK) > > res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ANDIF_EXPR, > > outer_cond_code1, inner_cond_code1, > > - boolean_type_node, larg, rarg); > > + boolean_type_node, boolean_type_node, > > + larg, rarg); > > // Otherwise, we need to try `!(!a || b) > > else if (inner_cond_code1 == ERROR_MARK) > > { > > @@ -901,7 +904,8 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, > > if (outer_cond_code1 != ERROR_MARK) > > res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ORIF_EXPR, > > outer_cond_code1, inner_cond_code, > > - boolean_type_node, larg, rarg); > > + boolean_type_node, boolean_type_node, > > + larg, rarg); > > if (res) > > res = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (res), res); > > } > > @@ -914,7 +918,8 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, > > if (inner_cond_code1 != ERROR_MARK) > > res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ORIF_EXPR, > > outer_cond_code, inner_cond_code1, > > - boolean_type_node, larg, rarg); > > + boolean_type_node, boolean_type_node, > > + larg, rarg); > > if (res) > > res = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (res), res); > > } > > diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc > > index 08b40897a60..51553484226 100644 > > --- a/gcc/tree-ssa-phiopt.cc > > +++ b/gcc/tree-ssa-phiopt.cc > > @@ -1651,7 +1651,7 @@ comparison_combine (basic_block cond_bb, basic_block middle_bb, > > tree result; > > tree_code newcmp_code; > > newcmp_code = combine_comparisons (logical, outer_code, inner_code, > > - boolean_type_node, > > + boolean_type_node, boolean_type_node, > > HONOR_NANS (larg), &result); > > if (newcmp_code == ERROR_MARK) > > return false; > From torbjorn.svensson@foss.st.com Sun Nov 1 09:06:42 2026 From: torbjorn.svensson@foss.st.com (Torbjorn SVENSSON) Date: Sun, 1 Nov 2026 10:06:42 +0100 Subject: [PATCH] match/fold: Fix combine_comparisons for vector(signed) boolean types [PR128123] In-Reply-To: References: <20261025175404.1885861-1-andrew.pinski@oss.qualcomm.com> <017b85db-7c4c-43da-a7fb-0f3323c90df5@foss.st.com> Message-ID: On 2026-11-01 09:52, Andrea Pinski wrote: > On Sun, Nov 1, 2026 at 1:48?AM Torbjorn SVENSSON > wrote: >> >> Hi, >> >> The new test is failing for MVE enabled targets on arm-none-eabi. >> >> These are the errors produced for thumb/arch=armv8.1-m.main+mve.fp+fp.dp/cpu=cortex-m55/float-abi=hard/fpu=auto: >> >> /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c: In function 'a': >> /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:10:14: error: incompatible types when initializing type 'v4sib' {aka '__vector(4) signed char:4'} using type '__vector(4) int' >> /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:11:14: error: incompatible types when initializing type 'v4sib' {aka '__vector(4) signed char:4'} using type '__vector(4) int' >> /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:12:3: error: cannot convert a value of type '__vector(4) signed char' to vector type '__vector(4) int' which has different size >> /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c: In function 'b': >> /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:17:14: error: incompatible types when initializing type 'v4sib' {aka '__vector(4) signed char:4'} using type '__vector(4) int' >> /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:18:14: error: incompatible types when initializing type 'v4sib' {aka '__vector(4) signed char:4'} using type '__vector(4) int' >> /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c:19:3: error: cannot convert a value of type '__vector(4) signed char' to vector type '__vector(4) int' which has different size >> >> Any idea how to fix? > > Yes, the best option is just to have it tested for x86_64/i386 and > aarch64. vector_mask is not very portable. Can you send a patch for that? Kind regards, Torbj?rn > >> >> Kind regards, >> Torbj?rn >> >> On 2026-10-25 18:54, Andrea Pinski wrote: >>> r17-4001-gbbc2517fe41 added support to combine_comparisons for LT/LE/GT/GE >>> but it assumed unsigned boolean types ([0,1]) which is wrong for signed >>> boolean types ([0,-1]). For an example, for signed boolean types, >>> LT is the same as GT for unsigned boolean types. So this was combining >>> incorrectly and getting the incorrect answer. >>> This fixes the problem by adding support for signed boolean. Since we >>> need to pass in a new argument to combine_comparisons, this updates >>> all of the uses of combine_comparisons which makes the patch >>> look bigger than it really is. >>> >>> Bootstrapped and tested on x86_64-linux-gnu with no regressions. >>> >>> PR tree-optimization/128123 >>> >>> gcc/ChangeLog: >>> >>> * fold-const.cc (combine_comparisons): Take new argument, >>> inner_truth_type and look to see if it is signed boolean >>> and support that for LT/LE/GT/GE. >>> (fold_truth_andor_1): Update call to combine_comparisons. >>> * fold-const.h (combine_comparisons): Add new argument. >>> * gimple-fold.cc (and_comparisons_1): Update call to >>> combine_comparisons. >>> (or_comparisons_1): Likewise. >>> * tree-ssa-ifcombine.cc (ifcombine_ifandif): Likewise. >>> * tree-ssa-phiopt.cc (comparison_combine): Likewise. >>> * match.pd (`(CMP) OP (CMP)`): Update call to >>> combine_comparisons. >>> >>> gcc/testsuite/ChangeLog: >>> >>> * gcc.dg/tree-ssa/vect-cmp-cmp-1.c: New test. >>> >>> Signed-off-by: Andrea Pinski >>> --- >>> gcc/fold-const.cc | 54 ++++++++++++++----- >>> gcc/fold-const.h | 4 +- >>> gcc/gimple-fold.cc | 8 +-- >>> gcc/match.pd | 5 +- >>> .../gcc.dg/tree-ssa/vect-cmp-cmp-1.c | 34 ++++++++++++ >>> gcc/tree-ssa-ifcombine.cc | 15 ++++-- >>> gcc/tree-ssa-phiopt.cc | 2 +- >>> 7 files changed, 95 insertions(+), 27 deletions(-) >>> create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c >>> >>> diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc >>> index 1fc4941b481..047c7dcada4 100644 >>> --- a/gcc/fold-const.cc >>> +++ b/gcc/fold-const.cc >>> @@ -3010,13 +3010,21 @@ inverse_conditions_p (const_tree cond1, const_tree cond2) >>> >>> enum tree_code >>> combine_comparisons (enum tree_code code, enum tree_code lcode, >>> - enum tree_code rcode, tree truth_type, >>> - bool honor_nans, tree *res) >>> + enum tree_code rcode, tree truth_type, >>> + tree inner_truth_type, >>> + bool honor_nans, tree *res) >>> { >>> enum comparison_code lcompcode = comparison_to_compcode (lcode); >>> enum comparison_code rcompcode = comparison_to_compcode (rcode); >>> int compcode; >>> *res = NULL_TREE; >>> + if (TREE_CODE (inner_truth_type) == VECTOR_TYPE) >>> + inner_truth_type = TREE_TYPE (inner_truth_type); >>> + bool signed_bool = false; >>> + if (TYPE_SIGN (inner_truth_type) == SIGNED >>> + && (TREE_CODE (inner_truth_type) == BOOLEAN_TYPE >>> + || TYPE_PRECISION (inner_truth_type) == 1)) >>> + signed_bool = true; >>> >>> switch (code) >>> { >>> @@ -3039,24 +3047,40 @@ combine_comparisons (enum tree_code code, enum tree_code lcode, >>> compcode = ~(lcompcode ^ rcompcode); >>> break; >>> >>> - //`bool0 < bool1` is `!bool0 & bool1` >>> + //`bool0 < bool1` is `!bool0 & bool1` for unsigned >>> + //`bool0 < bool1` is `bool0 & !bool1` for signed >>> case LT_EXPR: >>> - compcode = ~lcompcode & rcompcode; >>> + if (signed_bool) >>> + compcode = lcompcode & ~rcompcode; >>> + else >>> + compcode = ~lcompcode & rcompcode; >>> break; >>> >>> - //`bool0 > bool1` is `bool0 & !bool1` >>> + //`bool0 > bool1` is `bool0 & !bool1` for unsigned >>> + //`bool0 > bool1` is `!bool0 & bool1` for signed >>> case GT_EXPR: >>> - compcode = lcompcode & ~rcompcode; >>> + if (signed_bool) >>> + compcode = ~lcompcode & rcompcode; >>> + else >>> + compcode = lcompcode & ~rcompcode; >>> break; >>> >>> - // `bool0 <= bool1` as !bool0 | bool1 >>> + // `bool0 <= bool1` as !bool0 | bool1 for unsigned >>> + // `bool0 <= bool1` as bool0 | !bool1 for signed >>> case LE_EXPR: >>> - compcode = ~lcompcode | rcompcode; >>> + if (signed_bool) >>> + compcode = lcompcode | ~rcompcode; >>> + else >>> + compcode = ~lcompcode | rcompcode; >>> break; >>> >>> - //`bool0 >= bool1` is `bool0 | !bool1` >>> + //`bool0 >= bool1` is `bool0 | !bool1` for unsigned >>> + //`bool0 >= bool1` is `bool0 | !bool1` for signed >>> case GE_EXPR: >>> - compcode = lcompcode | ~rcompcode; >>> + if (signed_bool) >>> + compcode = ~lcompcode | rcompcode; >>> + else >>> + compcode = lcompcode | ~rcompcode; >>> break; >>> >>> default: >>> @@ -3136,12 +3160,14 @@ tree >>> combine_comparisons (location_t loc, >>> enum tree_code code, enum tree_code lcode, >>> enum tree_code rcode, tree truth_type, >>> + tree inner_truth_type, >>> tree ll_arg, tree lr_arg) >>> { >>> bool honor_nans = HONOR_NANS (ll_arg); >>> tree_code rescode; >>> tree res; >>> - rescode = combine_comparisons (code, lcode, rcode, truth_type, >>> + rescode = combine_comparisons (code, lcode, rcode, >>> + truth_type, inner_truth_type, >>> honor_nans, &res); >>> if (rescode == ERROR_MARK) >>> return NULL_TREE; >>> @@ -6504,7 +6530,8 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type, >>> && operand_equal_p (lr_arg, rr_arg, 0)) >>> { >>> result = combine_comparisons (loc, code, lcode, rcode, >>> - truth_type, ll_arg, lr_arg); >>> + truth_type, TREE_TYPE (lhs), >>> + ll_arg, lr_arg); >>> if (result) >>> return result; >>> } >>> @@ -6513,7 +6540,8 @@ fold_truth_andor_1 (location_t loc, enum tree_code code, tree truth_type, >>> { >>> result = combine_comparisons (loc, code, lcode, >>> swap_tree_comparison (rcode), >>> - truth_type, ll_arg, lr_arg); >>> + truth_type, TREE_TYPE (lhs), >>> + ll_arg, lr_arg); >>> if (result) >>> return result; >>> } >>> diff --git a/gcc/fold-const.h b/gcc/fold-const.h >>> index 437d8ece021..4e640de725f 100644 >>> --- a/gcc/fold-const.h >>> +++ b/gcc/fold-const.h >>> @@ -180,9 +180,9 @@ extern bool fold_cmp_float_cst_p (const wide_int &lo, const wide_int &hi, >>> const wide_int &i, signop isign); >>> >>> extern tree combine_comparisons (location_t, enum tree_code, enum tree_code, >>> - enum tree_code, tree, tree, tree); >>> + enum tree_code, tree, tree, tree, tree); >>> extern tree_code combine_comparisons (enum tree_code, enum tree_code, >>> - enum tree_code, tree, bool, tree*); >>> + enum tree_code, tree, tree, bool, tree*); >>> extern void debug_fold_checksum (const_tree); >>> extern bool may_negate_without_overflow_p (const_tree); >>> #define round_up(T,N) round_up_loc (UNKNOWN_LOCATION, T, N) >>> diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc >>> index e0197edece6..ed84dab7f37 100644 >>> --- a/gcc/gimple-fold.cc >>> +++ b/gcc/gimple-fold.cc >>> @@ -7602,7 +7602,7 @@ and_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, >>> /* Result will be either NULL_TREE, or a combined comparison. */ >>> tree t = combine_comparisons (UNKNOWN_LOCATION, >>> TRUTH_ANDIF_EXPR, code1, code2, >>> - truth_type, op1a, op1b); >>> + truth_type, truth_type, op1a, op1b); >>> if (t) >>> return t; >>> } >>> @@ -7615,7 +7615,7 @@ and_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, >>> tree t = combine_comparisons (UNKNOWN_LOCATION, >>> TRUTH_ANDIF_EXPR, code1, >>> swap_tree_comparison (code2), >>> - truth_type, op1a, op1b); >>> + truth_type, truth_type, op1a, op1b); >>> if (t) >>> return t; >>> } >>> @@ -9574,7 +9574,7 @@ or_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, >>> /* Result will be either NULL_TREE, or a combined comparison. */ >>> tree t = combine_comparisons (UNKNOWN_LOCATION, >>> TRUTH_ORIF_EXPR, code1, code2, >>> - truth_type, op1a, op1b); >>> + truth_type, truth_type, op1a, op1b); >>> if (t) >>> return t; >>> } >>> @@ -9587,7 +9587,7 @@ or_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, >>> tree t = combine_comparisons (UNKNOWN_LOCATION, >>> TRUTH_ORIF_EXPR, code1, >>> swap_tree_comparison (code2), >>> - truth_type, op1a, op1b); >>> + truth_type, truth_type, op1a, op1b); >>> if (t) >>> return t; >>> } >>> diff --git a/gcc/match.pd b/gcc/match.pd >>> index 696e69fd980..02941a7dacf 100644 >>> --- a/gcc/match.pd >>> +++ b/gcc/match.pd >>> @@ -3771,14 +3771,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) >>> (for cmp1 (tcc_comparison) >>> (for cmp2 (tcc_comparison) >>> (simplify >>> - (bitop (cmp1 @0 @1) (cmp2 @0 @1)) >>> + (bitop (cmp1@2 @0 @1) (cmp2 @0 @1)) >>> (with rescmpcode (tcc_comparison) >>> { >>> tree_code rescmpcode; >>> tree res; >>> bool honor_nans = HONOR_NANS (@0); >>> rescmpcode = combine_comparisons (bitop, cmp1, cmp2, >>> - type, honor_nans, &res); >>> + type, TREE_TYPE (@2), >>> + honor_nans, &res); >>> } >>> (if (rescmpcode == INTEGER_CST) >>> { res; } >>> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c b/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c >>> new file mode 100644 >>> index 00000000000..8ccf94df274 >>> --- /dev/null >>> +++ b/gcc/testsuite/gcc.dg/tree-ssa/vect-cmp-cmp-1.c >>> @@ -0,0 +1,34 @@ >>> +/* { dg-do run } */ >>> +/* { dg-options "-O -fgimple" } */ >>> +/* PR tree-optimization/128123 */ >>> + >>> +typedef int v4si __attribute__((vector_size (4*sizeof(int)))); >>> +typedef v4si v4sib __attribute__((vector_mask)); >>> + >>> +__attribute__((noipa)) void a(v4si *x, v4si *y, v4si *res) >>> +{ >>> + v4sib m1 = *x < *y; >>> + v4sib m2 = *x > *y; >>> + *res = (v4si) (m1 < m2); >>> +} >>> + >>> +__attribute__((noipa)) void b(v4si *x, v4si *y, v4si *res) >>> +{ >>> + v4sib m1 = *x < *y; >>> + v4sib m2 = *x > *y; >>> + *res = (v4si) (m1 <= m2); >>> +} >>> + >>> +int main (void) >>> +{ >>> + v4si x = { 1, 2, 3, 4 }, y = { 2, 2, 2, 5 }; >>> + v4si r; >>> + a(&x, &y, &r); >>> + v4si s; >>> + b(&x, &y, &s); >>> + for (int i = 0; i < 4; i++) >>> + if (r[i] != -(x[i] < y[i]) || s[i] != -(x[i] <= y[i])) >>> + __builtin_abort(); >>> + return 0; >>> +} >>> + >>> diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc >>> index 28bb5bf0998..0d663f4130b 100644 >>> --- a/gcc/tree-ssa-ifcombine.cc >>> +++ b/gcc/tree-ssa-ifcombine.cc >>> @@ -865,14 +865,16 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, >>> if (!inner_inv && !outer_inv) >>> res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ANDIF_EXPR, >>> outer_cond_code, inner_cond_code, >>> - boolean_type_node, larg, rarg); >>> + boolean_type_node, boolean_type_node, >>> + larg, rarg); >>> // If both are inverse, `!a && !b`, then handle it as `!(a || b)` >>> // As that !a or !b are most likely not producing a comparison code. >>> else if (inner_inv && outer_inv) >>> { >>> res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ORIF_EXPR, >>> outer_cond_code, inner_cond_code, >>> - boolean_type_node, larg, rarg); >>> + boolean_type_node, boolean_type_node, >>> + larg, rarg); >>> if (res) >>> res = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (res), res); >>> } >>> @@ -891,7 +893,8 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, >>> if (inner_cond_code1 != ERROR_MARK && outer_cond_code1 != ERROR_MARK) >>> res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ANDIF_EXPR, >>> outer_cond_code1, inner_cond_code1, >>> - boolean_type_node, larg, rarg); >>> + boolean_type_node, boolean_type_node, >>> + larg, rarg); >>> // Otherwise, we need to try `!(!a || b) >>> else if (inner_cond_code1 == ERROR_MARK) >>> { >>> @@ -901,7 +904,8 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, >>> if (outer_cond_code1 != ERROR_MARK) >>> res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ORIF_EXPR, >>> outer_cond_code1, inner_cond_code, >>> - boolean_type_node, larg, rarg); >>> + boolean_type_node, boolean_type_node, >>> + larg, rarg); >>> if (res) >>> res = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (res), res); >>> } >>> @@ -914,7 +918,8 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, >>> if (inner_cond_code1 != ERROR_MARK) >>> res = combine_comparisons (UNKNOWN_LOCATION, TRUTH_ORIF_EXPR, >>> outer_cond_code, inner_cond_code1, >>> - boolean_type_node, larg, rarg); >>> + boolean_type_node, boolean_type_node, >>> + larg, rarg); >>> if (res) >>> res = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (res), res); >>> } >>> diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc >>> index 08b40897a60..51553484226 100644 >>> --- a/gcc/tree-ssa-phiopt.cc >>> +++ b/gcc/tree-ssa-phiopt.cc >>> @@ -1651,7 +1651,7 @@ comparison_combine (basic_block cond_bb, basic_block middle_bb, >>> tree result; >>> tree_code newcmp_code; >>> newcmp_code = combine_comparisons (logical, outer_code, inner_code, >>> - boolean_type_node, >>> + boolean_type_node, boolean_type_node, >>> HONOR_NANS (larg), &result); >>> if (newcmp_code == ERROR_MARK) >>> return false; >> From torbjorn.svensson@foss.st.com Sun Nov 1 09:19:12 2026 From: torbjorn.svensson@foss.st.com (=?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?=) Date: Sun, 1 Nov 2026 10:19:12 +0100 Subject: [PATCH] testsuite: XFAIL pr125734.c on targets without CLZ support Message-ID: <20261101092433.1988785-1-torbjorn.svensson@foss.st.com> Hi, The test fails for Cortex-M0 (arm-none-eabi) for, what I belive, the same reason as the xfail on hppa*-*-hpux* in r17-4470-ge741ce45698e48. spawn -ignore SIGHUP /build/r17-5743-ge33129b871c302/bin/arm-none-eabi-gcc /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/pr125734.c -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -mfpu=auto -fdiagnostics-plain-output -O2 -fdump-tree-optimized -S -o pr125734.s ... PASS: gcc.dg/tree-ssa/pr125734.c (test for excess errors) gcc.dg/tree-ssa/pr125734.c: pattern found 0 times FAIL: gcc.dg/tree-ssa/pr125734.c scan-tree-dump-times optimized "\\.CLZ" 1 Ok for trunk? -- The test fails on targets without CLZ support. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr125734.c: XFAIl on !clz. Signed-off-by: Torbj?rn SVENSSON --- gcc/testsuite/gcc.dg/tree-ssa/pr125734.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr125734.c b/gcc/testsuite/gcc.dg/tree-ssa/pr125734.c index 0b9ec012528..c9e7c6d8c6f 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr125734.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr125734.c @@ -29,4 +29,4 @@ nlz32_negative (int b) return c; } -/* { dg-final { scan-tree-dump-times "\\.CLZ" 1 "optimized" { xfail hppa*-*-hpux* } } } */ +/* { dg-final { scan-tree-dump-times "\\.CLZ" 1 "optimized" { xfail { ! clz } } } } */ -- 2.43.0 From morin-mikael@orange.fr Sun Nov 1 10:14:54 2026 From: morin-mikael@orange.fr (Mikael Morin) Date: Sun, 1 Nov 2026 11:14:54 +0100 Subject: [PATCH 5/6] libgfortran: Update obsolete libtool macro on configure.ac [PR103459] In-Reply-To: <20261029020444.143639-6-pietro@sociotechnical.xyz> References: <20261029020444.143639-1-pietro@sociotechnical.xyz> <20261029020444.143639-6-pietro@sociotechnical.xyz> Message-ID: <6d6f4e58-7956-445a-9757-00caf4b972de@orange.fr> Le 29/10/2026 ? 03:04, Pietro Monteiro a ?crit?: > AC_LIBTOOL_DLOPEN has been deprecated. Instead pass the dlopen option > to LT_INIT. > > There are no functional changes because AC_LIBTOOL_DLOPEN was called > before LT_INIT. > > libgfortran/ChangeLog: > PR bootstrap/103459 > * configure: Regenerate. > * configure.ac: Remove AC_LIBTOOL_DLOPEN and change LT_INIT to LT_INIT([dlopen]). > > Signed-off-by: Pietro Monteiro > --- > libgfortran/configure | 9 +++------ > libgfortran/configure.ac | 3 +-- > 2 files changed, 4 insertions(+), 8 deletions(-) OK. > > diff --git a/libgfortran/configure b/libgfortran/configure > index c7d2c6666bf..d2b3b5f1bda 100755 > --- a/libgfortran/configure > +++ b/libgfortran/configure > @@ -6974,10 +6974,6 @@ fi > > # Configure libtool > #AC_MSG_NOTICE([====== Starting libtool configuration]) > -enable_dlopen=yes > - > - > - > case `pwd` in > *\ * | *\ *) > { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 > @@ -9686,6 +9682,7 @@ done > > > # Set options > +enable_dlopen=yes > > > > @@ -13245,7 +13242,7 @@ else > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > lt_status=$lt_dlunknown > cat > conftest.$ac_ext <<_LT_EOF > -#line 13248 "configure" > +#line 13245 "configure" > #include "confdefs.h" > > #if HAVE_DLFCN_H > @@ -13351,7 +13348,7 @@ else > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > lt_status=$lt_dlunknown > cat > conftest.$ac_ext <<_LT_EOF > -#line 13354 "configure" > +#line 13351 "configure" > #include "confdefs.h" > > #if HAVE_DLFCN_H > diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac > index c50112df91c..3119a883844 100644 > --- a/libgfortran/configure.ac > +++ b/libgfortran/configure.ac > @@ -258,8 +258,7 @@ AC_PROG_INSTALL > > # Configure libtool > #AC_MSG_NOTICE([====== Starting libtool configuration]) > -AC_LIBTOOL_DLOPEN > -LT_INIT > +LT_INIT([dlopen]) > LT_LIB_M > ACX_LT_HOST_FLAGS > AC_SUBST(enable_shared) From gerald@pfeifer.com Sun Nov 1 10:30:16 2026 From: gerald@pfeifer.com (Gerald Pfeifer) Date: Sun, 1 Nov 2026 11:30:16 +0100 (CET) Subject: [PATCH] wwwdocs: gcc-17: Make x86_64-unknown-freebsd primary platform In-Reply-To: References: <20260929210915.89CBA19BFAB@hamza.pair.com> Message-ID: On Mon, 12 Oct 2026, Rainer Orth wrote: >> Yes, no need to rip anything out. >> >> It's just that all FreeBSD test results in September and October so far >> have been for x86_64, not x86/i586, hence my request to adjust the primary >> platform accordingly. >> >> Any concerns with that? > not at all. While I do run weekly i?86 builds, they are 32-bit-only. > Multilib builds are almost impossible to get right due to the weird way > rtld handles execution when both LD_32_LIBRARY_PATH and LD_LIBRARY_PATH > are in the environment. Based on this thread I pushed the change below. Gerald FreeBSD end-of-lifed full 32-bit x86 support and all our test results these days are for x86-64. Accordingly switch from i586-unknown-freebsd to x86_64-unknown-freebsd as primary platform. --- htdocs/gcc-17/criteria.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/gcc-17/criteria.html b/htdocs/gcc-17/criteria.html index d2e16fcb1..f3d99f983 100644 --- a/htdocs/gcc-17/criteria.html +++ b/htdocs/gcc-17/criteria.html @@ -107,12 +107,12 @@ application testing.

  • aarch64-none-linux-gnu
  • arm-linux-gnueabi
  • -
  • i586-unknown-freebsd
  • i686-pc-linux-gnu
  • powerpc64-unknown-linux-gnu
  • powerpc64le-unknown-linux-gnu
  • sparc-sun-solaris2.11
  • x86_64-pc-linux-gnu
  • +
  • x86_64-unknown-freebsd

Secondary Platform List

-- 2.56.0 From torbjorn.svensson@foss.st.com Sun Nov 1 10:30:54 2026 From: torbjorn.svensson@foss.st.com (Torbjorn SVENSSON) Date: Sun, 1 Nov 2026 11:30:54 +0100 Subject: [PATCH] tree-optimization/128133 - wrong vectorized _BitInt load In-Reply-To: References: Message-ID: <3d2c3616-678d-455e-a6eb-70ec5d721205@foss.st.com> Hi Richard, The new test case fails for thumb/arch=armv7ve+simd/cpu=cortex-a7/float-abi=hard/fpu=auto (arm-none-eabi). Testing vect/vect-pr128133.c doing compile Executing on host: /build/r17-5743-ge33129b871c302/bin/arm-none-eabi-gcc /build/gcc_src/gcc/testsuite/gcc.dg/vect/vect-pr128133.c -mthumb -march=armv7ve+simd -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=auto -dumpbase "" -fdiagnostics-plain-output -ffast-math -ftree-vectorize -fno-tree-loop-distribute-patterns -fno-vect-cost-model -fno-common -O2 -fdump-tree-vect-details --specs=rdimon.specs -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -Wl,gcc_tg.o -lm -T qemu.ld -o ./vect-pr128133.exe (timeout = 800) spawn -ignore SIGHUP /build/r17-5743-ge33129b871c302/bin/arm-none-eabi-gcc /build/gcc_src/gcc/testsuite/gcc.dg/vect/vect-pr128133.c -mthumb -march=armv7ve+simd -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=auto -dumpbase -fdiagnostics-plain-output -ffast-math -ftree-vectorize -fno-tree-loop-distribute-patterns -fno-vect-cost-model -fno-common -O2 -fdump-tree-vect-details --specs=rdimon.specs -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -Wl,gcc_tg.o -lm -T qemu.ld -o ./vect-pr128133.exe pid is 2769237 -2769237 pid is -1 output is status 0 PASS: gcc.dg/vect/vect-pr128133.c (test for excess errors) spawning command qemu-system-arm -nographic -machine virt -cpu cortex-a7 -m 256 -semihosting -monitor /dev/null -kernel ./vect-pr128133.exe spawn qemu-system-arm -nographic -machine virt -cpu cortex-a7 -m 256 -semihosting -monitor /dev/null -kernel ./vect-pr128133.exe *** EXIT code 4242 *** EXIT code 1 pid is -1 Shell closed. Output is *** EXIT code 4242 *** EXIT code 1 FAIL: gcc.dg/vect/vect-pr128133.c execution test Running gdb shows the following after the convert() call: (gdb) print src {131071, 131071, 131071, 131071} (gdb) print dst {4294967295, 4294967295, 4294967295, 4294967295} Kind regards, Torbj?rn On 2026-10-26 13:01, Richard Biener wrote: > The following plugs the only halfway supported vectorization of > _BitInt at the load side where we currently fail to handle padding > bits correctly. > > Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. > > PR tree-optimization/128133 > * tree-vect-stmts.cc (vectorizable_load): Reject _BitInt > loads of non-mode precision. > > * gcc.dg/vect/vect-pr128133.c: New testcase. > --- > gcc/testsuite/gcc.dg/vect/vect-pr128133.c | 24 +++++++++++++++++++++++ > gcc/tree-vect-stmts.cc | 9 +++++++++ > 2 files changed, 33 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/vect/vect-pr128133.c > > diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr128133.c b/gcc/testsuite/gcc.dg/vect/vect-pr128133.c > new file mode 100644 > index 00000000000..933592384a4 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/vect/vect-pr128133.c > @@ -0,0 +1,24 @@ > +/* { dg-require-effective-target bitint } */ > + > +#include "tree-vect.h" > + > +__attribute__((noipa)) > +void convert(unsigned *dst, unsigned _BitInt(17) *src) > +{ > + for (int i = 0; i < 4; ++i) > + dst[i] = src[i]; > +} > + > +int main() > +{ > + unsigned _BitInt(17) src[4]; > + unsigned dst[4]; > + > + check_vect (); > + > + __builtin_memset(src, 0xff, sizeof src); > + convert(dst, src); > + if (dst[0] != 131071) > + __builtin_abort (); > + return 0; > +} > diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc > index 09d87739cea..85ca127244e 100644 > --- a/gcc/tree-vect-stmts.cc > +++ b/gcc/tree-vect-stmts.cc > @@ -9938,6 +9938,15 @@ vectorizable_load (vec_info *vinfo, > bool type_mode_padding_p > = TYPE_PRECISION (scalar_type) < GET_MODE_PRECISION (GET_MODE_INNER (mode)); > > + if (TREE_CODE (scalar_type) == BITINT_TYPE > + && !type_has_mode_precision_p (scalar_type)) > + { > + if (dump_enabled_p ()) > + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, > + "_BitInt loads are not fully supported.\n"); > + return false; > + } > + > if (slp_node->ldst_lanes > && memory_access_type != VMAT_LOAD_STORE_LANES) > { > > base-commit: cf43f83b4195dccbd61abeb4aeabbdd22fcbe828 > prerequisite-patch-id: e52d299db98b0892f974152cd9fa5f6859fec5b7 > prerequisite-patch-id: 39da6ec3264bae454fa504f127cd5b80a0662f04 > prerequisite-patch-id: 6d6c263a964425334ad8c2edd4dd89dcbff44bfe > prerequisite-patch-id: 9a12a1706cbdff1edf8959682cd3cf9d900cd8f1 > prerequisite-patch-id: b24057443c46d6979436cce479836178b19355de > prerequisite-patch-id: d61bf2c4249ecd3d9da5eeda002d332ed3a8b4fd > prerequisite-patch-id: 59cbeca60f782f48f945bc532c2235a50de6f0e5 > prerequisite-patch-id: 8eddd3172e2007d0fc591124a56b372dfe83e683 > prerequisite-patch-id: 862842dd3742066d039f66ffe9528bc490308c50 > prerequisite-patch-id: e413d39d9af45f25483eaf229cf883c771444fbb > prerequisite-patch-id: 2faef186ad1d816bb104d89638bc4cec6d863a46 > prerequisite-patch-id: b32cceb111f4f57798e4b1d58822281e7bbaf25e > prerequisite-patch-id: 404fd84b023dbe3994be05f26d6a86e83486d405 > prerequisite-patch-id: 08ff1c06921c5e253d911128be3a8ebb76137d3c > prerequisite-patch-id: 38ac1ab5d13f963f497b2985ef5aa0004c0e0550 From gerald@pfeifer.com Sun Nov 1 10:41:24 2026 From: gerald@pfeifer.com (Gerald Pfeifer) Date: Sun, 1 Nov 2026 11:41:24 +0100 (CET) Subject: [pushed] wwwdocs: simtest-howto: Use https to access GCC git Message-ID: <20261101104126.598FE19C026@hamza.pair.com> Pushed. Gerald git is a legacy protocol that lacks authentication and encryption. This follows commit 4e6bda6d11e to our primary git documentation. --- htdocs/simtest-howto.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/simtest-howto.html b/htdocs/simtest-howto.html index f18a78f63..3b8b0930b 100644 --- a/htdocs/simtest-howto.html +++ b/htdocs/simtest-howto.html @@ -49,7 +49,7 @@
 cd ${TOP}
-git clone git://gcc.gnu.org/git/gcc.git gcc
+git clone https://gcc.gnu.org/git/gcc.git gcc
 # This makes sure that file timestamps are in order initially.
 cd ${TOP}/gcc
 contrib/gcc_update --touch
-- 
2.56.0

From yqtian668@gmail.com  Sun Nov  1 12:09:11 2026
From: yqtian668@gmail.com (Yongqiang Tian)
Date: Sun,  1 Nov 2026 23:09:11 +1100
Subject: [PATCH] tree-cfg: Ignore debug stmts when checking coverage nops
 [PR128346]
Message-ID: <20261101120911.70954-1-yqtian668@gmail.com>

gimple_can_merge_blocks_p checks the final statement of a block for the
compiler-inserted nop that marks a coverage-suppression boundary.  A trailing
DEBUG_BEGIN_STMT hides that nop under -g, allows the blocks to be merged, and
changes the gcov CFG checksum even though the generated code is unchanged.

Use gsi_last_nondebug_bb so debug markers do not affect the merge decision.
Add a focused regression test.

The test case was found by a non-AI automated testing tool.
Assisted-by: OpenAI Codex 5.6 Sol.

Bootstrapped and regression tested on x86_64-pc-linux-gnu.  The focused
test fails before the change and passes after it.

	PR gcov-profile/128346

gcc/ChangeLog:

	* tree-cfg.cc (gimple_can_merge_blocks_p): Ignore debug statements
	when examining the end of a block.

gcc/testsuite/ChangeLog:

	* gcc.misc-tests/gcov-45.c: New test.

Signed-off-by: Yongqiang Tian 
---
 gcc/testsuite/gcc.misc-tests/gcov-45.c | 19 +++++++++++++++++++
 gcc/tree-cfg.cc                        |  2 +-
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.misc-tests/gcov-45.c

diff --git a/gcc/testsuite/gcc.misc-tests/gcov-45.c b/gcc/testsuite/gcc.misc-tests/gcov-45.c
new file mode 100644
index 000000000..c7b223048
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-45.c
@@ -0,0 +1,19 @@
+/* PR gcov-profile/128346 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -g -fno-thread-jumps -fprofile-arcs -fdump-tree-cfg-details" } */
+
+int bar (int);
+
+#pragma GCC suppress_coverage begin
+int
+foo (int a)
+{
+  a;
+#pragma GCC suppress_coverage end
+  if (a > 3)
+    a = bar (a);
+  return bar (a);
+}
+
+/* A debug marker must not hide the coverage-suppression nop.  */
+/* { dg-final { scan-tree-dump-not "Merging blocks 2 and 3" "cfg" } } */
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index ba1d4a125..93a830f0e 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -1874,7 +1874,7 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b)
 
   /* If A ends by a statement causing exceptions or something similar, we
      cannot merge the blocks.  */
-  stmt = *gsi_last_bb (a);
+  stmt = *gsi_last_nondebug_bb (a);
   if (stmt && stmt_ends_bb_p (stmt))
     return false;
 
-- 
2.34.1


From frs.dumont@gmail.com  Sun Nov  1 12:53:57 2026
From: frs.dumont@gmail.com (=?UTF-8?Q?Fran=C3=A7ois_Dumont?=)
Date: Sun, 1 Nov 2026 13:53:57 +0100
Subject: [PATCH][_GLIBCXX_DEBUG] Fix _Safe_iterator copy/move semantic PR
 127540
In-Reply-To: <7f23aa64-e31d-4132-81c9-3a8ca82607b3@gmail.com>
References: <7f23aa64-e31d-4132-81c9-3a8ca82607b3@gmail.com>
Message-ID: 

Note that I already realized that move-constructor should be rather 
implemented at _Safe_iterator_base level.

Assignment operators should be too even if it is a little bit more 
complicated because lock must be maintained while normal iterator is 
being assigned.

Fran?ois

On 10/29/26 23:05, Fran?ois Dumont wrote:
> Hi
>
> Here is what I've come up with so far.
>
> This is clearly not limited to fix of PR 127540 but it does fix it.
>
> This is a big performance improvement for the _GLIBCXX_DEBUG mode. The 
> proof is that I managed to run testsuite/23_containers/flat_* tests. 
> They were all timeout-ing on my laptop without the patch.
>
> I still need to work on the ChangeLog entry which I copied from your 
> RFC Jonathan.
>
> I've also prepared the same for _Safe_local_iterator.
>
> Happy to have some feedback.
>
> ? ? libstdc++: Fix _Safe_iterator copy/move semantic PR 127540
>
> ? ? Currently our safe iterators for debug mode fail to meet the 
> requirement
> ? ? that they have a "valid but unspecified" state after being moved 
> from.
> ? ? They have a singular and non-copyable state, which means they 
> cannot be
> ? ? copied or passed around by value. This is non-conforming.
>
> ? ? Define the moved-from state for our safe iterators to be the same as
> ? ? their value-initialized state. This means they are copyable after 
> being
> ? ? moved from.
>
> ? ? The downside of this change is that we no longer diagnose equality
> ? ? comparison with a moved-from iterator, which is undefined behaviour.
> ? ? Because value-initialized iterators can be compared, our moved-from
> ? ? iterators are now also comparable. This seems like an acceptable
> ? ? compromise in order to support copying them (which needs to work).
>
> ? ? If we care about diagnosing invalid comparisons, we would need to
> ? ? introduce a new moved-from state to the iterators. That could then be
> ? ? checked in the iterator's constructors and assignment operators so 
> that
> ? ? moved-from iterators are allowed as the source of those 
> operations. The
> ? ? new state would not be checked in comparisons so that using them 
> would
> ? ? abort, as was the case before this commit, e.g.
>
> /home/jwakely/gcc/17/include/c++/17.0.0/debug/safe_iterator.h:546:
> ? ? ? In function:
> ? ? ? ? ? constexpr bool gnu_debug::operator==(const 
> _Safe_iterator ? ? ? ? ? normal_iterator > 
> >, std::
> ? ? ? ? ? debug::vector, std::forward_iterator_tag>::_Self&, const
> ? ? ? ? ? _Safe_iterator ? ? ? ? ? std::allocator > >, std::debug::vector,
> ? ? ? ? ? std::forward_iterator_tag>::_Self&)
>
> ? ? ? Error: attempt to compare a singular iterator to a 
> dereferenceable iterator.
>
> ? ? libstdc++-v3/ChangeLog:
>
> ? ? ? ? ? ? PR libstdc++/127540
> ? ? ? ? ? ? * config/abi/pre/gnu.ver (GLIBCXX_3.4.37): Add 
> _Safe_sequence_base::_M_attach
> ? ? ? ? ? ? and _Safe_sequence_base::_M_attach_single symbols so that 
> freshly instantiated
> ? ? ? ? ? ? safe iterators can be attached without going through a 
> detach attempt.
> ? ? ? ? ? ? * include/debug/safe_base.h
> ? ? ? ? ? ? (_Safe_iterator_base): Remove implicit C++20 constexpr 
> qualification.
> ? ? ? ? ? ? (_Safe_iterator_base::operator=(const 
> _Safe_iterator_base&)): New, default.
> ? ? ? ? ? ? (_Safe_iterator_base::_M_get_sequence): New, get sequence 
> pointer if not singular.
> ? ? ? ? ? ? (_Safe_iterator_base::_M_attach_only): New.
> ? ? ? ? ? ? (_Safe_iterator_base(const _Safe_sequence_base*, bool)): 
> Use latter.
> ? ? ? ? ? ? (_Safe_iterator_base(const _Safe_iterator_base&, bool)): 
> Likewise and only copy
> ? ? ? ? ? ? input _Safe_iterator_base _M_sequence and _M_version if 
> singular.
> ? ? ? ? ? ? * include/debug/safe_iterator.h:
> ? ? ? ? ? ? (_Safe_iterator(const _Safe_iterator&)): Forward to latter 
> _Safe_iterator_base
> ? ? ? ? ? ? constructor.
> ? ? ? ? ? ? (_Safe_iterator<_MutableIte>(const _Safe_iterator<>&)): 
> Likewise.
> ? ? ? ? ? ? (_Safe_iterator): Add friend declaration to access mutable 
> iterator members
> ? ? ? ? ? ? from the immutable type.
> ? ? ? ? ? ? (_Safe_iterator::_M_move): New, make moved instance 
> value-initialized.
> ? ? ? ? ? ? (_Safe_iterator(_Safe_iterator&&, bool)): New.
> ? ? ? ? ? ? (_Safe_iterator(_Safe_iterator&&)): Forward to latter.
> (_Safe_iterator<_MutableIte>(_Safe_iterator<_MutableIte, _Seq, _Cat>&&)):
> ? ? ? ? ? ? Likewise.
> ? ? ? ? ? ? (_Safe_iterator::_M_copy_assign<_Ite>): New.
> ? ? ? ? ? ? (_Safe_iterator::operator=(const _Safe_iterator&)): Call 
> latter.
> ? ? ? ? ? ? (_Safe_iterator::operator=<_MutableIte>(const 
> _Safe_iterator<>&)): New, likewise.
> ? ? ? ? ? ? (_Safe_iterator::_M_move_assign): New.
> ? ? ? ? ? ? (_Safe_iterator::operator=(_Safe_iterator&&)): Call latter.
> (_Safe_iterator::operator=<_MutableIte>(_Safe_iterator<>&&)): New, 
> likewise.
> ? ? ? ? ? ? (_Safe_iterator::_M_attach): Remove.
> ? ? ? ? ? ? (_Safe_iterator::_M_attach_single): Remove.
> ? ? ? ? ? ? * src/c++11/debug.cc (_Safe_iterator_base::_M_attach): Do 
> not reset _M_version
> ? ? ? ? ? ? if attaching to a null sequence.
> ? ? ? ? ? ? (_Safe_iterator_base::_M_attach_single): Likewise.
> ? ? ? ? ? ? * testsuite/24_iterators/debug/safe_iterator.cc: New test.
>
> Tested under Linux x86_64 23_containers and 24_iterators tests.
>
> Fran?ois

From torbjorn.svensson@foss.st.com  Sun Nov  1 12:59:03 2026
From: torbjorn.svensson@foss.st.com (=?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?=)
Date: Sun, 1 Nov 2026 13:59:03 +0100
Subject: [PATCH] testsuite: Require checking for nested crash tests [PR124872]
Message-ID: <20261101130027.2007793-1-torbjorn.svensson@foss.st.com>

Ok for trunk?

To fix this on releases/gcc-16, a different approach is need.

Kind regards,
Torbj?rn

--

The nested crash tests fail when the compiler is built without checking.
Add a checking effective target and use it to skip these tests.

	PR testsuite/124872

gcc/ChangeLog:

	* doc/sourcebuild.texi: Document checking.

gcc/testsuite/ChangeLog:

	* lib/et-static.def (checking): New effective target.
	* gcc.dg/plugin/crash-test-nested-ice.c: Require checking.
	* gcc.dg/plugin/crash-test-nested-write-through-null.c: Likewise.

Signed-off-by: Torbj?rn SVENSSON 
---
 gcc/doc/sourcebuild.texi                                      | 3 +++
 gcc/testsuite/gcc.dg/plugin/crash-test-nested-ice.c           | 1 +
 .../gcc.dg/plugin/crash-test-nested-write-through-null.c      | 1 +
 gcc/testsuite/lib/et-static.def                               | 4 ++++
 4 files changed, 9 insertions(+)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 897be37e450..f4dca33b088 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -3064,6 +3064,9 @@ Target supports automatic stack alignment.
 @item branch_cost
 Target supports @option{-branch-cost=N}.
 
+@item checking
+Compiler has been configured with internal checking enabled.
+
 @item const_volatile_readonly_section
 Target places const volatile variables in readonly sections.
 
diff --git a/gcc/testsuite/gcc.dg/plugin/crash-test-nested-ice.c b/gcc/testsuite/gcc.dg/plugin/crash-test-nested-ice.c
index 5a98813896f..eda7c7cfdf6 100644
--- a/gcc/testsuite/gcc.dg/plugin/crash-test-nested-ice.c
+++ b/gcc/testsuite/gcc.dg/plugin/crash-test-nested-ice.c
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target checking } */
 /* { dg-skip-if "Target frontend exits early on syntax recovery errors" { hppa*-*-hpux* } } */
 /* { dg-additional-options "-fno-report-bug" } */
 /* { dg-additional-options "-fplugin-arg-crash_test_plugin-nested" } */
diff --git a/gcc/testsuite/gcc.dg/plugin/crash-test-nested-write-through-null.c b/gcc/testsuite/gcc.dg/plugin/crash-test-nested-write-through-null.c
index 3f1277bff16..fa3bdde6d8a 100644
--- a/gcc/testsuite/gcc.dg/plugin/crash-test-nested-write-through-null.c
+++ b/gcc/testsuite/gcc.dg/plugin/crash-test-nested-write-through-null.c
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target checking } */
 /* { dg-skip-if "Target frontend exits early on syntax recovery errors" { hppa*-*-hpux* } } */
 /* { dg-additional-options "-fno-report-bug" } */
 /* { dg-additional-options "-fplugin-arg-crash_test_plugin-nested" } */
diff --git a/gcc/testsuite/lib/et-static.def b/gcc/testsuite/lib/et-static.def
index b5a32335920..76c9a3e3a0f 100644
--- a/gcc/testsuite/lib/et-static.def
+++ b/gcc/testsuite/lib/et-static.def
@@ -24,6 +24,10 @@
 
 # Keep this sorted alphabetically by effective-target name.  */
 
+checking
+CHECKING_P
+the compiler was built with checking enabled
+
 code_6_gottpoff_reloc
 HAVE_AS_R_X86_64_CODE_6_GOTTPOFF
 assembler and linker support R_X86_64_CODE_6_GOTTPOFF
-- 
2.43.0


From rdsandiford@googlemail.com  Sun Nov  1 13:11:25 2026
From: rdsandiford@googlemail.com (Richard Sandiford)
Date: Sun, 1 Nov 2026 22:11:25 +0900
Subject: [PATCH 1/3] expmed: Extract subvectors via vec_perm_const.
In-Reply-To: <20261030151204.95945-2-rdapp.gcc@gmail.com>
References: <20261030151204.95945-1-rdapp.gcc@gmail.com>
 <20261030151204.95945-2-rdapp.gcc@gmail.com>
Message-ID: 

On Sat, 31 Oct 2026 at 00:12, Robin Dapp  wrote:
> This patch adds a way of extracting vectors from vectors by building a
> consecutive permute pattern for the target to handle.

I think this is ultimately what we should do for all vector-from-vector
extracts, and never use direct optabs.  Maybe that's the plan.  I realise
it would be a bit of work though.

I agree that this patch can go in on its own though.  Some comments below.

>
> gcc/ChangeLog:
>
>         * expmed.cc (vec_extract_perm_p): New function.

I think this belongs in optabs-query.cc.

>         (extract_vector_from_vector_perm): New function.
>         (extract_vector_from_vector): Allow vector extraction via
>         permute.
>         * expmed.h (vec_extract_perm_p): Declare.
> ---
>  gcc/expmed.cc | 105 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  gcc/expmed.h  |   3 ++
>  2 files changed, 107 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/expmed.cc b/gcc/expmed.cc
> index 367e8af46e5..fcf100df90d 100644
> --- a/gcc/expmed.cc
> +++ b/gcc/expmed.cc
> @@ -747,6 +747,48 @@ store_bit_field_using_insv (const extraction_insn *insv, rtx op0,
>    return false;
>  }
>
> +/* See if we can extract a vector of mode SUBVEC_MODE from a larger vector
> +   of mode VEC_MODE at EXTRACT_IDX.  EXTRACT_IDX counts in elements
> +   of VEC_MOD and SUBVEC_MODE.  If we can, return the possibly punned

VEC_MODE

> +   input mode.  */
> +
> +opt_machine_mode
> +vec_extract_perm_p (machine_mode vec_mode, machine_mode subvec_mode,
> +                   poly_uint64 extract_idx)
> +{
> +  if (!VECTOR_MODE_P (vec_mode) || !VECTOR_MODE_P (subvec_mode))
> +    return opt_machine_mode ();
> +
> +  if (maybe_ne (GET_MODE_UNIT_SIZE (vec_mode),
> +               GET_MODE_UNIT_SIZE (subvec_mode)))

This can just be !=.

> +    return opt_machine_mode ();
> +
> +  if (maybe_gt (GET_MODE_NUNITS (subvec_mode) + extract_idx,
> +               GET_MODE_NUNITS (vec_mode)))
> +    return opt_machine_mode ();
> +
> +  /* Look for a matching mode for the vector elements.
> +     Do not pun the whole vector with a mode of different element size
> +     here (e.g. V2DI and V4SI).  We expect a target to do that itself.  */
> +  if (GET_MODE_INNER (vec_mode) != GET_MODE_INNER (subvec_mode)
> +      && !related_vector_mode (vec_mode, GET_MODE_INNER (subvec_mode),
> +                              GET_MODE_NUNITS (vec_mode)).exists
> +          (&vec_mode))
> +    return opt_machine_mode ();
> +
> +  poly_uint64 out_nunits = GET_MODE_NUNITS (subvec_mode);
> +  poly_uint64 in_nunits = GET_MODE_NUNITS (vec_mode);
> +
> +  vec_perm_builder sel (out_nunits, 1, 3);
> +  for (unsigned int i = 0; i < 3; ++i)
> +    sel.quick_push (extract_idx + i);
> +
> +  vec_perm_indices indices (sel, 2, in_nunits);

Why is this 2-input rather than 1-input?

> +  if (can_vec_perm_const_p (subvec_mode, vec_mode, indices))
> +    return vec_mode;
> +  return opt_machine_mode ();
> +}
> +
>  /* A subroutine of store_bit_field, with the same arguments.  Return true
>     if the operation could be implemented.
>
> @@ -1698,9 +1740,65 @@ extract_bit_field_as_subreg (machine_mode mode, rtx op0,
>    return NULL_RTX;
>  }
>
> +/* Same as extract_vector_from_vector but try with a permutation.  */
> +
> +static rtx
> +extract_vector_from_vector_perm (rtx vec, rtx target, machine_mode mode,
> +                                machine_mode subvec_mode, poly_uint64 bitsize,
> +                                poly_uint64 bitnum, rtx *alt_rtl)
> +{
> +  machine_mode vec_mode = GET_MODE (vec);
> +  poly_uint64 extract_idx;
> +  if (!VECTOR_MODE_P (vec_mode)
> +      || MEM_P (vec)
> +      || !VECTOR_MODE_P (subvec_mode)
> +      || maybe_ne (bitsize, GET_MODE_PRECISION (subvec_mode))
> +      || known_le (GET_MODE_SIZE (GET_MODE (vec)),
> +                  GET_MODE_SIZE (subvec_mode))

known_le doesn't seem right.  Extracting a 128-bit vector from a
possibly 128-bit, possibly larger vector should be ok.

But this kind of check is redundant wrt what vec_extract_perm_p checks,
so I think we should just drop it rather than change it.

> +      || !multiple_p (bitnum, GET_MODE_UNIT_BITSIZE (subvec_mode),
> +                     &extract_idx))
> +    return NULL_RTX;
> +
> +  /* We don't want to handle single-element vector modes here.  */

Why not?  I think the comment should say, rather than leave the reader
to guess :)

> +  if (known_le (GET_MODE_NUNITS (subvec_mode), 1)
> +      || known_le (GET_MODE_NUNITS (vec_mode), 1))
> +    return NULL_RTX;
> +
> +  machine_mode punned_vec_mode;
> +  if (!vec_extract_perm_p (vec_mode, subvec_mode, extract_idx).exists
> +      (&punned_vec_mode))
> +    return NULL_RTX;
> +
> +  if (punned_vec_mode != vec_mode)
> +    vec = gen_lowpart (punned_vec_mode, vec);
> +
> +  poly_uint64 out_nunits = GET_MODE_NUNITS (subvec_mode);
> +
> +  vec_perm_builder sel (out_nunits, 1, 3);
> +  for (unsigned int i = 0; i < 3; ++i)
> +    sel.quick_push (extract_idx + i);
> +
> +  rtx tmp = subvec_mode == mode ? target : NULL_RTX;
> +  rtx res = expand_vec_perm_const (subvec_mode, vec, vec, sel, BLKmode, tmp);
> +  if (!res)
> +    return NULL_RTX;
> +
> +  if (res == target && alt_rtl)
> +    *alt_rtl = target;
> +
> +  if (subvec_mode != mode)
> +    res = gen_lowpart (mode, res);
> +
> +  return res;
> +}
> +
>  /* Try to extract a subvector of mode SUBVEC_MODE (which has BITSIZE bits)
>     from vector VEC, starting at bit BITNUM, then extract the MODE lowpart of
> -   the subvector.  Return the result on success or NULL_RTX on failure.  */
> +   the subvector.
> +   If the vec_extract-based attempt failed, build a vector permute to extract
> +   the part and hand it to the target.

I think the new sentence should either flow into the existing paragraph
or be a new paragraph.

OK with the above changes if changing to a single-input permute is correct.

Thanks,
Richard

> +
> +   Return the result on success or NULL_RTX on failure.  */
>
>  static rtx
>  extract_vector_from_vector (rtx vec, rtx target, machine_mode mode,
> @@ -1755,6 +1853,11 @@ extract_vector_from_vector (rtx vec, rtx target, machine_mode mode,
>         }
>      }
>
> +  rtx res = extract_vector_from_vector_perm (vec, target, mode, subvec_mode,
> +                                            bitsize, bitnum, alt_rtl);
> +  if (res)
> +    return res;
> +
>    return NULL_RTX;
>  }
>
> diff --git a/gcc/expmed.h b/gcc/expmed.h
> index b4b44bba1d7..2e2d9009c84 100644
> --- a/gcc/expmed.h
> +++ b/gcc/expmed.h
> @@ -730,6 +730,9 @@ extern rtx expmed_mult_highpart_optab (scalar_int_mode, rtx, rtx, rtx,
>                                        int, int);
>  extern rtx expand_rotate_as_vec_perm (machine_mode, rtx, rtx, rtx);
>
> +extern opt_machine_mode vec_extract_perm_p (machine_mode, machine_mode,
> +                                           poly_uint64);
> +
>  /* The constant divisor of the last division expanded, reset per function
>     by prepare_function_start.  */
>  extern HOST_WIDE_INT last_div_const;
> --
> 2.56.

From rdsandiford@googlemail.com  Sun Nov  1 13:18:57 2026
From: rdsandiford@googlemail.com (Richard Sandiford)
Date: Sun, 1 Nov 2026 22:18:57 +0900
Subject: [PATCH 2/3] vect: Use can_vec_extract.
In-Reply-To: <20261030151204.95945-3-rdapp.gcc@gmail.com>
References: <20261030151204.95945-1-rdapp.gcc@gmail.com>
 <20261030151204.95945-3-rdapp.gcc@gmail.com>
Message-ID: 

On Sat, 31 Oct 2026 at 00:12, Robin Dapp  wrote:
> This connects can_vec_extract and the new vec_extract_perm_p and
> replaces the vectorizer's vec_extract optab checks with it.
> That way it is mostly in sync with what we can actually expand.
> The patch passes a dummy extraction index because we don't know the
> final index yet.

But...

> A side effect of using can_vec_extract instead of a direct check is that
> we perform type punning a bit earlier now in vectorizable_store.  This
> leads to slightly different codegen in one case where we had
>
>    (set (reg:DI 123) (vec_select:DI (subreg:V2DI (reg:V4SI 121) 0) ...))
>    (set (mem:DI ...) (reg:DI 123))
>
> before but now get
>
>   (set (reg:DI 125) (vec_select:DI (subreg:V2DI (reg:V4SI 109) 0) ...))
>   (set (mem:V2SI ...) (subreg:V2SI (reg:DI 125) 0))
>
> The latter is not recognized as direct DImode store.  This is a
> scalar/vector corner case and could be fixed at the target level as well
> as by an RTL optimization.  In order not to change too much I made
> can_vec_extract's scalar punning explicit by having it return the
> extract mode.
>
> gcc/ChangeLog:
>
>         * optabs-query.cc (can_vec_extract): Query vec_extract_perm_p
>         and return extract mode.
>         * optabs-query.h (can_vec_extract): Change return type.
>         * tree-vect-loop.cc (vect_find_reusable_accumulator): Use
>         can_vec_extract.
>         (vect_create_partial_epilog): Likewise.
>         * tree-vect-stmts.cc (vectorizable_store): Likewise.
> ---
>  gcc/optabs-query.cc    | 30 +++++++++++++++++++-----------
>  gcc/optabs-query.h     |  2 +-
>  gcc/tree-vect-loop.cc  | 17 ++++++++---------
>  gcc/tree-vect-stmts.cc |  8 ++------
>  4 files changed, 30 insertions(+), 27 deletions(-)
>
> diff --git a/gcc/optabs-query.cc b/gcc/optabs-query.cc
> index da0d37cf5df..d1f513697af 100644
> --- a/gcc/optabs-query.cc
> +++ b/gcc/optabs-query.cc
> @@ -30,6 +30,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include "recog.h"
>  #include "vec-perm-indices.h"
>  #include "internal-fn.h"
> +#include "expmed.h"
>  #include "memmodel.h"
>  #include "optabs.h"
>
> @@ -793,32 +794,39 @@ supports_vec_scatter_store_p (machine_mode mode)
>  }
>
>  /* Whether we can extract part of the vector mode MODE as
> -   (scalar or vector) mode EXTR_MODE.  */
> +   (scalar or vector) mode EXTR_MODE.  Returns the extraction mode
> +   we would use or no mode.  */
>
> -bool
> +opt_machine_mode
>  can_vec_extract (machine_mode mode, machine_mode extr_mode)
>  {
>    unsigned m;
>    if (!VECTOR_MODE_P (mode)
>        || !constant_multiple_p (GET_MODE_SIZE (mode),
>                                GET_MODE_SIZE (extr_mode), &m))
> -    return false;
> +    return opt_machine_mode ();
>
>    if (convert_optab_handler (vec_extract_optab, mode, extr_mode)
>        != CODE_FOR_nothing)
> -    return true;
> +    return extr_mode;
>
>    /* Besides a direct vec_extract we can also use an element extract from
>       an integer vector mode with elements of the size of the extr_mode.  */
>    scalar_int_mode imode;
>    machine_mode vmode;
> -  if (!int_mode_for_size (GET_MODE_BITSIZE (extr_mode), 0).exists (&imode)
> -      || !related_vector_mode (mode, imode, m).exists (&vmode)
> -      || (convert_optab_handler (vec_extract_optab, vmode, imode)
> -         == CODE_FOR_nothing))
> -    return false;
> -  /* We assume we can pun mode to vmode and imode to extr_mode.  */
> -  return true;
> +  if (int_mode_for_size (GET_MODE_BITSIZE (extr_mode), 0).exists (&imode)
> +      && related_vector_mode (mode, imode, m).exists (&vmode)
> +      && (convert_optab_handler (vec_extract_optab, vmode, imode)
> +         != CODE_FOR_nothing))
> +    return imode;
> +
> +  /* We don't know yet where exactly to extract from, just use
> +     the number of units.  */
> +  if (vec_extract_perm_p (mode, extr_mode, GET_MODE_NUNITS
> +                         (extr_mode)).exists ())

...why GET_MODE_NUNITS rather than 0, given that 0 should be the most
permissive value?  GET_MODE_NUNITS could rule out some valid cases
for VLA vectors, such as extracting an AArch64 AdvSIMD vector from
an SVE vector.

(No other comment on the patch from me.)


Richard

> +    return extr_mode;
> +
> +  return opt_machine_mode ();
>  }
>
>  /* OP is either neg_optab or abs_optab and FMODE is the floating-point inner
> diff --git a/gcc/optabs-query.h b/gcc/optabs-query.h
> index faa688a0609..c230ee19aac 100644
> --- a/gcc/optabs-query.h
> +++ b/gcc/optabs-query.h
> @@ -173,7 +173,7 @@ bool supports_vec_gather_load_p (machine_mode = E_VOIDmode,
>  bool supports_vec_scatter_store_p (machine_mode = E_VOIDmode);
>  opt_machine_mode get_absneg_bit_mode (optab, machine_mode,
>                                       scalar_float_mode, int *);
> -bool can_vec_extract (machine_mode, machine_mode);
> +opt_machine_mode can_vec_extract (machine_mode, machine_mode);
>  bool can_open_code_p (optab, machine_mode);
>  bool can_implement_p (optab, machine_mode);
>
> diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
> index e8cff98997c..89a3671ab08 100644
> --- a/gcc/tree-vect-loop.cc
> +++ b/gcc/tree-vect-loop.cc
> @@ -5226,7 +5226,10 @@ vect_find_reusable_accumulator (loop_vec_info loop_vinfo,
>           || !directly_supported_p (VECT_REDUC_INFO_CODE (reduc_info),
>                                     intermediate_vectype)
>           || !can_vec_extract (TYPE_MODE (prev_vectype),
> -                              TYPE_MODE (intermediate_vectype)))
> +                              TYPE_MODE (intermediate_vectype)).exists ()
> +         /* We could actually extract VLA vectors but bit_field_ref and
> +            friends aren't yet prepared for it.  */
> +         || !TYPE_VECTOR_SUBPARTS (intermediate_vectype).is_constant ())
>         return false;
>        prev_vectype = intermediate_vectype;
>      }
> @@ -5286,10 +5289,8 @@ vect_create_partial_epilog (tree vec_def, tree vectype, code_helper code,
>          an integer mode punning.  */
>        tree dst1, dst2;
>        gimple *epilog_stmt;
> -      if (convert_optab_handler (vec_extract_optab,
> -                                TYPE_MODE (TREE_TYPE (new_temp)),
> -                                TYPE_MODE (vectype1))
> -         != CODE_FOR_nothing)
> +      if (can_vec_extract (TYPE_MODE (TREE_TYPE (new_temp)),
> +                          TYPE_MODE (vectype1)).exists ())
>         {
>           /* Extract sub-vectors directly once vec_extract becomes
>              a conversion optab.  */
> @@ -5314,10 +5315,8 @@ vect_create_partial_epilog (tree vec_def, tree vectype, code_helper code,
>              vector.  */
>           tree eltype = build_nonstandard_integer_type (bitsize, 1);
>           tree etype = build_vector_type (eltype, 2);
> -         gcc_assert (convert_optab_handler (vec_extract_optab,
> -                                            TYPE_MODE (etype),
> -                                            TYPE_MODE (eltype))
> -                     != CODE_FOR_nothing);
> +         gcc_assert (can_vec_extract (TYPE_MODE (etype),
> +                                      TYPE_MODE (eltype)).exists ());
>           tree tem = make_ssa_name (etype);
>           epilog_stmt = gimple_build_assign (tem, VIEW_CONVERT_EXPR,
>                                              build1 (VIEW_CONVERT_EXPR,
> diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
> index b33d3f6b782..7a72a872e67 100644
> --- a/gcc/tree-vect-stmts.cc
> +++ b/gcc/tree-vect-stmts.cc
> @@ -8552,9 +8552,7 @@ vectorizable_store (vec_info *vinfo,
>           if (!VECTOR_MODE_P (TYPE_MODE (vectype))
>               || !related_vector_mode (TYPE_MODE (vectype), elmode,
>                                        n).exists (&vmode)
> -             || (convert_optab_handler (vec_extract_optab,
> -                                        TYPE_MODE (vectype), vmode)
> -                 == CODE_FOR_nothing)
> +             || can_vec_extract (TYPE_MODE (vectype), vmode) != vmode
>               || !(dr_align == dr_aligned
>                    || dr_align == dr_unaligned_supported))
>             {
> @@ -8572,9 +8570,7 @@ vectorizable_store (vec_info *vinfo,
>                   && VECTOR_MODE_P (TYPE_MODE (vectype))
>                   && related_vector_mode (TYPE_MODE (vectype), elmode,
>                                           lnunits).exists (&vmode)
> -                 && (convert_optab_handler (vec_extract_optab,
> -                                            vmode, elmode)
> -                     != CODE_FOR_nothing))
> +                 && can_vec_extract (vmode, elmode).exists ())
>                 {
>                   nstores = lnunits;
>                   lnel = n;
> --
> 2.56.0

From iains.gcc@gmail.com  Sun Nov  1 13:39:40 2026
From: iains.gcc@gmail.com (Iain Sandoe)
Date: Sun,  1 Nov 2026 13:39:40 +0000
Subject: [PATCH 0/2] Fix JIT for Darwin and emulated TLS
Message-ID: <20261101133942.28618-1-iain@sandoe.co.uk>

Currently all Jit TLS access tests fail for several reasons;
1. the builtins needed are not created during startup
2. Darwin needs the "word" type to be available
3. Emulated TLS variables are not exported by name - instead the name of the
   control object is exported, so we have to look up via that.

Tested on x86_64-linux, darwin and aarch64-linux, OK for trunk?
thanks,
Iain

Iain Sandoe (2):
  jit: Create additional builtins that Darwin uses.
  jit: Lookup TLS globals for targets with emulated TLS.

 gcc/jit/jit-builtins.cc |  9 +++++-
 gcc/jit/jit-result.cc   | 70 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+), 1 deletion(-)

-- 
2.50.1 (Apple Git-155)


From iains.gcc@gmail.com  Sun Nov  1 13:39:41 2026
From: iains.gcc@gmail.com (Iain Sandoe)
Date: Sun,  1 Nov 2026 13:39:41 +0000
Subject: [PATCH 1/2] jit: Create additional builtins that Darwin uses.
In-Reply-To: <20261101133942.28618-1-iain@sandoe.co.uk>
References: <20261101133942.28618-1-iain@sandoe.co.uk>
Message-ID: <20261101133942.28618-2-iain@sandoe.co.uk>

For Darwin (and any other emulated TLS targets) we must initialise the
relevant builtins for the two functions that are used by this.

Darwin also needs the "WORD" type to be registered.

gcc/jit/ChangeLog:

	* jit-builtins.cc (builtins_manager::make_primitive_type): Register
	word type.
	(builtins_manager::ensure_optimization_builtins_exist): For targets
	without native TLS, register the builtins for the two functions used
	by emulated TLS.

Signed-off-by: Iain Sandoe 
---
 gcc/jit/jit-builtins.cc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/jit/jit-builtins.cc b/gcc/jit/jit-builtins.cc
index 539ee132393..4d5cbb4aa41 100644
--- a/gcc/jit/jit-builtins.cc
+++ b/gcc/jit/jit-builtins.cc
@@ -483,7 +483,8 @@ builtins_manager::make_primitive_type (enum jit_builtin_type type_id)
     case BT_UINT32: return m_ctxt->get_int_type (4, false);
     case BT_UINT64: return m_ctxt->get_int_type (8, false);
     case BT_UINT128: return m_ctxt->get_int_type (16, false);
-    // case BT_WORD:
+    case BT_WORD:
+      return m_ctxt->get_int_type (GET_MODE_SIZE (word_mode), false);
     // case BT_UNWINDWORD:
     case BT_FLOAT: return m_ctxt->get_type (GCC_JIT_TYPE_FLOAT);
     case BT_DOUBLE: return m_ctxt->get_type (GCC_JIT_TYPE_DOUBLE);
@@ -620,6 +621,12 @@ builtins_manager::ensure_optimization_builtins_exist ()
   (void)get_builtin_function_by_id (BUILT_IN_CTZL);
   (void)get_builtin_function_by_id (BUILT_IN_CLZLL);
   (void)get_builtin_function_by_id (BUILT_IN_CTZLL);
+  if (!targetm.have_tls)
+    {
+      /* Targets without native TLS may use the emulated model.  */
+      (void)get_builtin_function_by_id (BUILT_IN_EMUTLS_GET_ADDRESS);
+      (void)get_builtin_function_by_id (BUILT_IN_EMUTLS_REGISTER_COMMON);
+    }
 }
 
 /* Playback support.  */
-- 
2.50.1 (Apple Git-155)


From iains.gcc@gmail.com  Sun Nov  1 13:39:42 2026
From: iains.gcc@gmail.com (Iain Sandoe)
Date: Sun,  1 Nov 2026 13:39:42 +0000
Subject: [PATCH 2/2] jit: Lookup TLS globals for targets with emulated TLS.
In-Reply-To: <20261101133942.28618-2-iain@sandoe.co.uk>
References: <20261101133942.28618-1-iain@sandoe.co.uk>
 <20261101133942.28618-2-iain@sandoe.co.uk>
Message-ID: <20261101133942.28618-3-iain@sandoe.co.uk>

For glibc targets with native TLS, the C library automatically indirects
the symbol lookup through the TLS machinery.

For emulated TLS we have to do a similar process, but we have no way to
tell that the symbol is TLS.  So the strategy is to try to look it up as
a regular global and, if that fails, try to look up the name of the
corresponding control object, if that succeeds we have a TLS var of that
name and we can collect its address in the usual manner.

gcc/jit/ChangeLog:

	* jit-result.cc (EMUTLS_SEPARATOR): New.
	(get_emulated_tls_global): New.
	(get_global): If an initial attempt to find a global fails and the
	target is using emulated TLS, try looking the corresponding control
	object and resolving the object address from that.

Signed-off-by: Iain Sandoe 
---
 gcc/jit/jit-result.cc | 70 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/gcc/jit/jit-result.cc b/gcc/jit/jit-result.cc
index f48f2eddc74..78284830cb8 100644
--- a/gcc/jit/jit-result.cc
+++ b/gcc/jit/jit-result.cc
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #define INCLUDE_DLFCN_H
 #include "system.h"
 #include "coretypes.h"
+#include "target.h"
 
 #include "jit-common.h"
 #include "jit-logging.h"
@@ -104,6 +105,61 @@ get_code (const char *funcname)
   return code;
 }
 
+#ifndef _WIN32
+/* Emulated TLS has no exported symbol for the variable itself.  What is
+   exported is the control object, so we need to first look to see if there
+   is a control object for the named var; if there is we can then translate
+   the address.  Control object name composition copied from tree-emutls.cc.  */
+
+#if !defined (NO_DOT_IN_LABEL)
+# define EMUTLS_SEPARATOR	"."
+#elif !defined (NO_DOLLAR_IN_LABEL)
+# define EMUTLS_SEPARATOR	"$"
+#else
+# define EMUTLS_SEPARATOR	"_"
+#endif
+
+static void *
+get_emulated_tls_global (void *dso_handle, const char *name)
+{
+  const char *prefix = (targetm.emutls.var_prefix
+			? targetm.emutls.var_prefix
+			: "__emutls_v" EMUTLS_SEPARATOR);
+  char *control_name = concat (prefix, name, NULL);
+  /* Look this up and exit early if it is not available.  */
+  void *control = dlsym (dso_handle, control_name);
+  free (control_name);
+  if (!control)
+    return NULL;
+
+  /* We have to call get_address function to translate the emulated TLS
+     control object address to a pointer the actual var.  */
+  const char *fn_name;
+  if (targetm.emutls.get_address)
+    {
+      fn_name = targetm.emutls.get_address;
+      if (strncmp (fn_name, "__builtin_", 10) == 0)
+	fn_name += 10;
+    }
+  else
+    fn_name = "__emutls_get_address";
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconditionally-supported"
+  /* We need the function pointer here, but we need to look up the version
+     that the dynamic linker resolved - which is most likely not in the same
+     DSO as the variable we are looking up.  */
+  using fn_t = void * (*) (void*);
+  auto get_address_fn
+    = reinterpret_cast (dlsym (RTLD_DEFAULT, fn_name));
+#pragma GCC diagnostic pop
+  if (!get_address_fn)
+    return NULL;
+
+  return get_address_fn (control);
+}
+#endif /* !_WIN32 */
+
 /* Attempt to locate the given global by name within the
    playback::result, using dlsym.
 
@@ -133,6 +189,20 @@ get_global (const char *name)
 
   global = dlsym (m_dso_handle, name);
 
+  if (!global && !targetm.have_tls)
+    {
+      /* Under emulated TLS there is no symbol for the variable itself, so the
+	 global lookup above fails. The only way to tell if there is a TLS var
+	 with this name is by trying to look it up via its control object.  */
+      void *tls_global = get_emulated_tls_global (m_dso_handle, name);
+      if (tls_global)
+	{
+	  /* Discard the "symbol not found" error from the failed lookup.  */
+	  dlerror ();
+	  return tls_global;
+	}
+    }
+
   if ((error = dlerror()) != NULL)  {
     fprintf(stderr, "%s\n", error);
   }
-- 
2.50.1 (Apple Git-155)


From iains.gcc@gmail.com  Sun Nov  1 13:41:47 2026
From: iains.gcc@gmail.com (Iain Sandoe)
Date: Sun,  1 Nov 2026 13:41:47 +0000
Subject: [PATCH] jit, testsuite: Fix bfloat16 tests.
Message-ID: <20261101134155.28797-1-iain@sandoe.co.uk>

Tested on x86_64,aarch64-linux (one progression on aarch64) and on
x86_64-darwin, OK for trunk?
thanks,
Iain

--- 8< ---

These were failing on build on any non-x86 platform because of the
unconditional inclusion .  Additionaly the bfloat16
cases were behind HAVE_BFmode which is not a define available to the
testsuite.  Use a compiler pre-define for this.

gcc/testsuite/ChangeLog:

	* jit.dg/test-types.c: Remove unneeded header, gate bfloat16
	tests on an compiler pre-define that is present when it is
	supported.

Signed-off-by: Iain Sandoe 
---
 gcc/testsuite/jit.dg/test-types.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/jit.dg/test-types.c b/gcc/testsuite/jit.dg/test-types.c
index e5c2b77112c..bd59c11deb9 100644
--- a/gcc/testsuite/jit.dg/test-types.c
+++ b/gcc/testsuite/jit.dg/test-types.c
@@ -1,4 +1,3 @@
-#include 
 #include 
 #include 
 #include 
@@ -521,8 +520,8 @@ verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
 
   CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_FLOAT)), sizeof (float));
   CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_DOUBLE)), sizeof (double));
-#ifdef HAVE_BFmode
-  CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_BFLOAT16)), sizeof (__bfloat16));
+#ifdef __BFLT16_MANT_DIG__
+  CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_BFLOAT16)), sizeof (__bf16));
 #endif
 
   gcc_jit_type *int_type = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
-- 
2.50.1 (Apple Git-155)


From Dipesh.Sharma@amd.com  Sun Nov  1 13:47:52 2026
From: Dipesh.Sharma@amd.com (Dipesh Sharma)
Date: Sun, 1 Nov 2026 19:17:52 +0530
Subject: [PATCH v3 0/4][X86] Add support for AVX10V1AUX.
Message-ID: <20261101134756.351245-1-Dipesh.Sharma@amd.com>

This patch series adds support for AVX10V1AUX.


This revision addresses the comments on the
previous(V2) revision: https://gcc.gnu.org/pipermail/gcc-patches/2026-October/736257.html


Dipesh Sharma (4):
  [X86]: Initial support for AVX10V1AUX
  [X86]: Move shared AVX10.2 convert intrinsics to AVX10V1AUX.
  [X86]: Move shared AVX10.2 and VNNI byte and word intrinsics to
    AVX10V1AUX.
  [X86]: Add AVX10V1AUX tests for VNNIINT8/16.

 gcc/common/config/i386/cpuinfo.h              |   15 +-
 gcc/common/config/i386/i386-common.cc         |   27 +-
 gcc/common/config/i386/i386-cpuinfo.h         |    1 +
 gcc/common/config/i386/i386-isas.h            |    2 +
 gcc/config.gcc                                |    2 +-
 gcc/config/i386/avx10_2convertintrin.h        | 1376 ---------
 gcc/config/i386/avx10_2mediaintrin.h          | 1032 -------
 gcc/config/i386/avx10v1auxintrin.h            | 2459 +++++++++++++++++
 gcc/config/i386/cpuid.h                       |    1 +
 gcc/config/i386/i386-builtin.def              |  308 +--
 gcc/config/i386/i386-c.cc                     |    2 +
 gcc/config/i386/i386-expand.cc                |    8 +-
 gcc/config/i386/i386-isa.def                  |    1 +
 gcc/config/i386/i386-options.cc               |    4 +-
 gcc/config/i386/i386.cc                       |    4 +-
 gcc/config/i386/i386.h                        |    5 +-
 gcc/config/i386/i386.md                       |    4 +-
 gcc/config/i386/i386.opt                      |    5 +
 gcc/config/i386/i386.opt.urls                 |    3 +
 gcc/config/i386/immintrin.h                   |    2 +
 gcc/config/i386/sse.md                        |  162 +-
 gcc/doc/extend.texi                           |    5 +
 gcc/doc/invoke.texi                           |    8 +-
 gcc/doc/sourcebuild.texi                      |    3 +
 gcc/testsuite/gcc.target/i386/avx-1.c         |    2 +-
 .../gcc.target/i386/avx10_2-builtin-1.c       |    2 +-
 .../gcc.target/i386/avx10_2-builtin-2.c       |    2 +-
 gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c |  375 +++
 gcc/testsuite/gcc.target/i386/avx10v1aux-1b.c |  267 ++
 gcc/testsuite/gcc.target/i386/funcspec-56.inc |    2 +
 gcc/testsuite/gcc.target/i386/sse-13.c        |    2 +-
 gcc/testsuite/gcc.target/i386/sse-14.c        |    2 +-
 gcc/testsuite/gcc.target/i386/sse-22.c        |    2 +-
 gcc/testsuite/gcc.target/i386/sse-23.c        |    2 +-
 gcc/testsuite/lib/target-supports.exp         |   13 +
 35 files changed, 3441 insertions(+), 2669 deletions(-)
 create mode 100644 gcc/config/i386/avx10v1auxintrin.h
 create mode 100644 gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/avx10v1aux-1b.c

--
2.34.1


From Dipesh.Sharma@amd.com  Sun Nov  1 13:47:53 2026
From: Dipesh.Sharma@amd.com (Dipesh Sharma)
Date: Sun, 1 Nov 2026 19:17:53 +0530
Subject: [PATCH v3 1/4] [X86]: Initial support for AVX10V1AUX
In-Reply-To: <20261101134756.351245-1-Dipesh.Sharma@amd.com>
References: <20261101134756.351245-1-Dipesh.Sharma@amd.com>
Message-ID: <20261101134756.351245-2-Dipesh.Sharma@amd.com>

AVX10.2 now implies AVX10V1AUX.

gcc/ChangeLog:

	* common/config/i386/cpuinfo.h (get_available_features): Add AVX10V1AUX.
	* common/config/i386/i386-common.cc (OPTION_MASK_ISA2_AVX10V1AUX_SET): New.
	(OPTION_MASK_ISA2_AVX10_1_UNSET): Disable AVX10V1AUX.
	(OPTION_MASK_ISA2_AVX10V2AUX_UNSET): Disable ACEV1.
	(OPTION_MASK_ISA2_AVX10V1AUX_UNSET): Disable ACEV1.
	(ix86_handle_option): Handle AVX10V1AUX.
	* common/config/i386/i386-cpuinfo.h (enum processor_features): Add FEATURE_AVX10V1AUX.
	* common/config/i386/i386-isas.h: Handle avx10v1aux.
	* config/i386/cpuid.h (bit_AVX10V1AUX): New.
	* config/i386/i386-c.cc (ix86_target_macros_internal): Handle avx10v1aux.
	* config/i386/i386-isa.def (AVX10V1AUX): New.
	* config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p): Handle Ditto..
	* config/i386/i386.h: Add PTA_AVX10V1AUX to targets using
	  PTA_AVX10_2.
	* config/i386/i386.opt: Add avx10v1aux.
	* config/i386/i386.opt.urls: Regenerated.
	* doc/extend.texi: Add avx10v1aux documentation.
	* doc/invoke.texi: Ditto.
	* doc/sourcebuild.texi: Ditto.

Co-authored-by: Venkataramanan Kumar 
---
 gcc/common/config/i386/cpuinfo.h      | 15 +++++++++++----
 gcc/common/config/i386/i386-common.cc | 27 ++++++++++++++++++++++++---
 gcc/common/config/i386/i386-cpuinfo.h |  1 +
 gcc/common/config/i386/i386-isas.h    |  2 ++
 gcc/config/i386/cpuid.h               |  1 +
 gcc/config/i386/i386-c.cc             |  2 ++
 gcc/config/i386/i386-isa.def          |  1 +
 gcc/config/i386/i386-options.cc       |  4 +++-
 gcc/config/i386/i386.h                |  5 +++--
 gcc/config/i386/i386.opt              |  5 +++++
 gcc/config/i386/i386.opt.urls         |  3 +++
 gcc/doc/extend.texi                   |  5 +++++
 gcc/doc/invoke.texi                   |  8 +++++++-
 gcc/doc/sourcebuild.texi              |  3 +++
 14 files changed, 71 insertions(+), 11 deletions(-)

diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h
index f433810457b9..bc660a803af1 100644
--- a/gcc/common/config/i386/cpuinfo.h
+++ b/gcc/common/config/i386/cpuinfo.h
@@ -837,7 +837,7 @@ get_available_features (struct __processor_model *cpu_model,
   int has_kl = 0;
   /* Record AVX10 version.  */
   int avx10_set = 0;
-  int ace_set = 0, avx10v2aux_set = 0;
+  int ace_set = 0, avx10v2aux_set = 0, avx10v1aux_set = 0;
   int version = 0;
   if ((ecx & bit_OSXSAVE))
     {
@@ -1169,13 +1169,20 @@ get_available_features (struct __processor_model *cpu_model,
 	      set_feature (FEATURE_AVX10V2AUX);
 	      avx10v2aux_set = 1;
 	    }
+	  if (ecx & bit_AVX10V1AUX)
+	    {
+	      set_feature (FEATURE_AVX10V1AUX);
+	      avx10v1aux_set = 1;
+	    }
 	}
     }

   /* Get Advanced Features at level 0x1d (eax = 0x1d).
-     ACE check must be put after AVX10 check to get AVX10 features.
-     TODO: Change the condition after AVX10V1AUX is added.  */
-  if (version >= 2 && avx10v2aux_set && ace_set && max_cpuid_level >= 0x1d)
+     ACE check must be put after AVX10 check to get AVX10 features.  */
+  if (((avx10v1aux_set && version >= 1) || version >= 2)
+	&& avx10v2aux_set
+	&& ace_set
+	&& max_cpuid_level >= 0x1d)
     {
       __cpuid_count (0x1d, 0, eax, ebx, ecx, edx);
       if (eax == 2)
diff --git a/gcc/common/config/i386/i386-common.cc b/gcc/common/config/i386/i386-common.cc
index ed126f4c70dc..2ca4f9a911e8 100644
--- a/gcc/common/config/i386/i386-common.cc
+++ b/gcc/common/config/i386/i386-common.cc
@@ -129,7 +129,8 @@ along with GCC; see the file COPYING3.  If not see
   (OPTION_MASK_ISA2_AVX512FP16_SET | OPTION_MASK_ISA2_AVX512BF16_SET \
    | OPTION_MASK_ISA2_AVX10_1)
 #define OPTION_MASK_ISA2_AVX10_2_SET \
-  (OPTION_MASK_ISA2_AVX10_1_SET | OPTION_MASK_ISA2_AVX10_2)
+  (OPTION_MASK_ISA2_AVX10_1_SET | OPTION_MASK_ISA2_AVX10V1AUX_SET \
+   | OPTION_MASK_ISA2_AVX10_2)
 #define OPTION_MASK_ISA2_AMX_AVX512_SET \
   (OPTION_MASK_ISA2_AMX_TILE_SET | OPTION_MASK_ISA2_AMX_AVX512)
 #define OPTION_MASK_ISA2_AMX_FP8_SET \
@@ -142,6 +143,8 @@ along with GCC; see the file COPYING3.  If not see
   (OPTION_MASK_ISA2_AVX10_1_SET | OPTION_MASK_ISA2_AVX10V2AUX)
 #define OPTION_MASK_ISA2_ACEV1_SET \
   (OPTION_MASK_ISA2_AVX10V2AUX_SET | OPTION_MASK_ISA2_ACEV1)
+#define OPTION_MASK_ISA2_AVX10V1AUX_SET \
+  (OPTION_MASK_ISA2_AVX10_1_SET | OPTION_MASK_ISA2_AVX10V1AUX)

 /* SSE4 includes both SSE4.1 and SSE4.2. -msse4 should be the same
    as -msse4.2.  */
@@ -328,7 +331,7 @@ along with GCC; see the file COPYING3.  If not see
 #define OPTION_MASK_ISA2_USER_MSR_UNSET OPTION_MASK_ISA2_USER_MSR
 #define OPTION_MASK_ISA2_AVX10_1_UNSET \
   (OPTION_MASK_ISA2_AVX10_1 | OPTION_MASK_ISA2_AVX10_2_UNSET \
-   | OPTION_MASK_ISA2_AVX10V2AUX_UNSET)
+   | OPTION_MASK_ISA2_AVX10V2AUX_UNSET | OPTION_MASK_ISA2_AVX10V1AUX_UNSET)
 #define OPTION_MASK_ISA2_AVX10_2_UNSET OPTION_MASK_ISA2_AVX10_2
 #define OPTION_MASK_ISA2_AMX_AVX512_UNSET OPTION_MASK_ISA2_AMX_AVX512
 #define OPTION_MASK_ISA2_AMX_FP8_UNSET OPTION_MASK_ISA2_AMX_FP8
@@ -338,6 +341,9 @@ along with GCC; see the file COPYING3.  If not see
 #define OPTION_MASK_ISA2_AVX10V2AUX_UNSET \
   (OPTION_MASK_ISA2_AVX10V2AUX | OPTION_MASK_ISA2_ACEV1_UNSET)
 #define OPTION_MASK_ISA2_ACEV1_UNSET OPTION_MASK_ISA2_ACEV1
+#define OPTION_MASK_ISA2_AVX10V1AUX_UNSET \
+  (OPTION_MASK_ISA2_AVX10V1AUX | OPTION_MASK_ISA2_AVX10_2_UNSET \
+   | OPTION_MASK_ISA2_ACEV1_UNSET)

 /* SSE4 includes both SSE4.1 and SSE4.2.  -mno-sse4 should the same
    as -mno-sse4.1. */
@@ -1422,7 +1428,7 @@ ix86_handle_option (struct gcc_options *opts,
 	}
       return true;

-	case OPT_mavx10v2aux:
+    case OPT_mavx10v2aux:
       if (value)
 	{
 	  opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_AVX10V2AUX_SET;
@@ -1437,6 +1443,21 @@ ix86_handle_option (struct gcc_options *opts,
 	}
       return true;

+    case OPT_mavx10v1aux:
+      if (value)
+	{
+	  opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_AVX10V1AUX_SET;
+	  opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX10V1AUX_SET;
+	  opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX10_1_SET;
+	  opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX10_1_SET;
+	}
+      else
+	{
+	  opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX10V1AUX_UNSET;
+	  opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX10V1AUX_UNSET;
+	}
+      return true;
+
     case OPT_mamx_avx512:
       if (value)
 	{
diff --git a/gcc/common/config/i386/i386-cpuinfo.h b/gcc/common/config/i386/i386-cpuinfo.h
index ed989667e020..e75b18bda227 100644
--- a/gcc/common/config/i386/i386-cpuinfo.h
+++ b/gcc/common/config/i386/i386-cpuinfo.h
@@ -285,6 +285,7 @@ enum processor_features
   FEATURE_AVX512BMM,
   FEATURE_AVX10V2AUX,
   FEATURE_ACEV1,
+  FEATURE_AVX10V1AUX,
   CPU_FEATURE_MAX
 };

diff --git a/gcc/common/config/i386/i386-isas.h b/gcc/common/config/i386/i386-isas.h
index 171226ab07b7..f4a9fbad6bfc 100644
--- a/gcc/common/config/i386/i386-isas.h
+++ b/gcc/common/config/i386/i386-isas.h
@@ -194,4 +194,6 @@ ISA_NAMES_TABLE_START
   ISA_NAMES_TABLE_ENTRY("avx10v2aux", FEATURE_AVX10V2AUX, P_NONE,
 			"-mavx10v2aux")
   ISA_NAMES_TABLE_ENTRY("acev1", FEATURE_ACEV1, P_NONE, "-macev1")
+  ISA_NAMES_TABLE_ENTRY("avx10v1aux", FEATURE_AVX10V1AUX, P_NONE,
+			"-mavx10v1aux")
 ISA_NAMES_TABLE_END
diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h
index c40970df872d..6f33927b50a9 100644
--- a/gcc/config/i386/cpuid.h
+++ b/gcc/config/i386/cpuid.h
@@ -173,6 +173,7 @@

 /* AVX10 sub leaf (%eax == 0x24, %ecx == 1) */
 /* %ecx */
+#define bit_AVX10V1AUX	(1 << 2)
 #define bit_AVX10V2AUX	(1 << 3)

 /* AMX sub leaf (%eax == 0x1e, %ecx == 1) */
diff --git a/gcc/config/i386/i386-c.cc b/gcc/config/i386/i386-c.cc
index f6a4093c2776..6750332ee9cf 100644
--- a/gcc/config/i386/i386-c.cc
+++ b/gcc/config/i386/i386-c.cc
@@ -794,6 +794,8 @@ ix86_target_macros_internal (HOST_WIDE_INT isa_flag,
     def_or_undef (parse_in, "__AVX10V2AUX__");
   if (isa_flag2 & OPTION_MASK_ISA2_ACEV1)
     def_or_undef (parse_in, "__ACEV1__");
+  if (isa_flag2 & OPTION_MASK_ISA2_AVX10V1AUX)
+    def_or_undef (parse_in, "__AVX10V1AUX__");
   if (TARGET_IAMCU)
     {
       def_or_undef (parse_in, "__iamcu");
diff --git a/gcc/config/i386/i386-isa.def b/gcc/config/i386/i386-isa.def
index 28835b1d542e..9803ad6b6f11 100644
--- a/gcc/config/i386/i386-isa.def
+++ b/gcc/config/i386/i386-isa.def
@@ -127,3 +127,4 @@ DEF_PTA(AMX_MOVRS)
 DEF_PTA(AVX512BMM)
 DEF_PTA(AVX10V2AUX)
 DEF_PTA(ACEV1)
+DEF_PTA(AVX10V1AUX)
diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
index ebd86f71f93a..27c3db38ad7a 100644
--- a/gcc/config/i386/i386-options.cc
+++ b/gcc/config/i386/i386-options.cc
@@ -276,7 +276,8 @@ static struct ix86_target_opts isa2_opts[] =
   { "-mamx-movrs",	OPTION_MASK_ISA2_AMX_MOVRS },
   { "-mavx512bmm",	OPTION_MASK_ISA2_AVX512BMM },
   { "-mavx10v2aux",	OPTION_MASK_ISA2_AVX10V2AUX },
-  { "-macev1",		OPTION_MASK_ISA2_ACEV1 }
+  { "-macev1",		OPTION_MASK_ISA2_ACEV1 },
+  { "-mavx10v1aux",	OPTION_MASK_ISA2_AVX10V1AUX }
 };
 static struct ix86_target_opts isa_opts[] =
 {
@@ -1143,6 +1144,7 @@ ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[],
     IX86_ATTR_ISA ("avx512bmm", OPT_mavx512bmm),
     IX86_ATTR_ISA ("avx10v2aux", OPT_mavx10v2aux),
     IX86_ATTR_ISA ("acev1", OPT_macev1),
+    IX86_ATTR_ISA ("avx10v1aux", OPT_mavx10v1aux),

     /* enum options */
     IX86_ATTR_ENUM ("fpmath=",	OPT_mfpmath_),
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 47725c560906..aeaa057d3bd5 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -2510,12 +2510,13 @@ constexpr wide_int_bitmask PTA_PANTHERLAKE =
 constexpr wide_int_bitmask PTA_DIAMONDRAPIDS = PTA_GRANITERAPIDS_D
   | PTA_AVXIFMA | PTA_AVXNECONVERT | PTA_AVXVNNIINT16 | PTA_AVXVNNIINT8
   | PTA_CMPCCXADD | PTA_SHA512 | PTA_SM3 | PTA_SM4 | PTA_AVX10_2
-  | PTA_APX_F | PTA_AMX_AVX512 | PTA_AMX_FP8 | PTA_MOVRS | PTA_AMX_MOVRS;
+  | PTA_APX_F | PTA_AMX_AVX512 | PTA_AMX_FP8 | PTA_MOVRS | PTA_AMX_MOVRS
+  | PTA_AVX10V1AUX;
 constexpr wide_int_bitmask PTA_NOVALAKE = PTA_PANTHERLAKE | PTA_PREFETCHI
   | PTA_AVX512F | PTA_AVX512CD | PTA_AVX512VL | PTA_AVX512BW | PTA_AVX512DQ
   | PTA_AVX512VBMI | PTA_AVX512IFMA | PTA_AVX512VNNI | PTA_AVX512VBMI2
   | PTA_AVX512BITALG | PTA_AVX512VPOPCNTDQ | PTA_AVX512FP16 | PTA_AVX512BF16
-  | PTA_AVX10_1 | PTA_AVX10_2 | PTA_APX_F | PTA_MOVRS;
+  | PTA_AVX10_1 | PTA_AVX10_2 | PTA_APX_F | PTA_MOVRS | PTA_AVX10V1AUX;

 constexpr wide_int_bitmask PTA_BDVER1 = PTA_64BIT | PTA_MMX | PTA_SSE
   | PTA_SSE2 | PTA_SSE3 | PTA_SSE4A | PTA_CX16 | PTA_POPCNT | PTA_LZCNT
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index f9aeeac08faf..740a08f80752 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -1399,3 +1399,8 @@ macev1
 Target Mask(ISA2_ACEV1) Var(ix86_isa_flags2) Save
 Support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2,
 AVX10.1 and ACEV1 built-in functions and code generation.
+
+mavx10v1aux
+Target Mask(ISA2_AVX10V1AUX) Var(ix86_isa_flags2) Save
+Support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2,
+AVX10.1 and AVX10V1AUX built-in functions and code generation.
diff --git a/gcc/config/i386/i386.opt.urls b/gcc/config/i386/i386.opt.urls
index 5cfa30c07e3b..304cd67c5aab 100644
--- a/gcc/config/i386/i386.opt.urls
+++ b/gcc/config/i386/i386.opt.urls
@@ -641,3 +641,6 @@ UrlSuffix(gcc/x86-Options.html#index-mavx10v2aux)
 macev1
 UrlSuffix(gcc/x86-Options.html#index-macev1)

+mavx10v1aux
+UrlSuffix(gcc/x86-Options.html#index-mavx10v1aux)
+
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 9b6161334680..09261ea611d1 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -9575,6 +9575,11 @@ Enable/disable the generation of the AVX10V2AUX instructions.
 @itemx no-acev1
 Enable/disable the generation of the ACEV1 instructions.

+@atindex @code{target("avx10v1aux")}, x86
+@item avx10v1aux
+@itemx no-avx10v1aux
+Enable/disable the generation of the AVX10V1AUX instructions.
+
 @atindex @code{target("cld")}, x86
 @item cld
 @itemx no-cld
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index f89b984fd25f..4ee15dee1df2 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -1553,7 +1553,7 @@ See RS/6000 and PowerPC Options.
 -mavxneconvert  -mcmpccxadd  -mamx-fp16  -mprefetchi  -mraoint
 -mamx-complex  -mavxvnniint16  -msm3  -msha512  -msm4  -mapxf
 -musermsr  -mavx10.1  -mavx10.2  -mamx-avx512  -mmovrs  -mamx-movrs
--mavx512bmm  -mavx10v2aux  -macev1
+-mavx512bmm  -mavx10v2aux  -macev1  -mavx10v1aux
 -mcldemote  -mms-bitfields  -mno-align-stringops  -minline-all-stringops
 -minline-stringops-dynamically  -mstringop-strategy=@var{alg}
 -mkl  -mwidekl
@@ -36382,6 +36382,12 @@ AVX10.1 and AVX10V2AUX built-in functions and code generation.
 @item -macev1
 Support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2,
 AVX10.1 and ACEV1 built-in functions and code generation.
+
+@opindex mavx10v1aux
+@opindex mno-avx10v1aux
+@item -mavx10v1aux
+Support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2,
+AVX10.1 and AVX10V1AUX built-in functions and code generation.
 @end table

 These additional options are available for the x86 processor family.
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 3aa9fcbb5778..755494751e18 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2718,6 +2718,9 @@ Target supports the execution of @code{avx} instructions.
 @item avx10v2aux
 Target supports the execution of @code{avx10v2aux} instructions.

+@item avx10v1aux
+Target supports the execution of @code{avx10v1aux} instructions.
+
 @item avx10.1
 Target supports the execution of @code{avx10.1} instructions.

--
2.34.1


From Dipesh.Sharma@amd.com  Sun Nov  1 13:47:56 2026
From: Dipesh.Sharma@amd.com (Dipesh Sharma)
Date: Sun, 1 Nov 2026 19:17:56 +0530
Subject: [PATCH v3 4/4] [X86]: Add AVX10V1AUX tests for VNNIINT8/16.
In-Reply-To: <20261101134756.351245-1-Dipesh.Sharma@amd.com>
References: <20261101134756.351245-1-Dipesh.Sharma@amd.com>
Message-ID: <20261101134756.351245-5-Dipesh.Sharma@amd.com>

Since avx10.2 implies avx10v1aux, I feel passing avx10v1aux on
top of avx10.2 in several testfiles{ e.g. sse-*.c} is redundant.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/avx-1.c: Rename header avx10v1aux builtins.
	* gcc.target/i386/avx10_2-builtin-1.c: Check builtins under avx10v1aux.
	* gcc.target/i386/avx10_2-builtin-2.c: Likewise.
	* gcc.target/i386/sse-13.c: Rename header avx10v1aux builtins.
	* gcc.target/i386/sse-14.c: Likewise.
	* gcc.target/i386/sse-22.c: Likewise.
	* gcc.target/i386/sse-23.c: Likewise.
	* lib/target-supports.exp: Add more check for avx10v1aux.
	* gcc.target/i386/avx10v1aux-1b.c: New test.

Co-authored-by: Venkataramanan Kumar 
---
 gcc/testsuite/gcc.target/i386/avx-1.c         |   2 +-
 .../gcc.target/i386/avx10_2-builtin-1.c       |   2 +-
 .../gcc.target/i386/avx10_2-builtin-2.c       |   2 +-
 gcc/testsuite/gcc.target/i386/avx10v1aux-1b.c | 267 ++++++++++++++++++
 gcc/testsuite/gcc.target/i386/sse-13.c        |   2 +-
 gcc/testsuite/gcc.target/i386/sse-14.c        |   2 +-
 gcc/testsuite/gcc.target/i386/sse-22.c        |   2 +-
 gcc/testsuite/gcc.target/i386/sse-23.c        |   2 +-
 gcc/testsuite/lib/target-supports.exp         |   4 +-
 9 files changed, 277 insertions(+), 8 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/avx10v1aux-1b.c

diff --git a/gcc/testsuite/gcc.target/i386/avx-1.c b/gcc/testsuite/gcc.target/i386/avx-1.c
index 7a8e5cc2301f..ec21ef4f43c9 100644
--- a/gcc/testsuite/gcc.target/i386/avx-1.c
+++ b/gcc/testsuite/gcc.target/i386/avx-1.c
@@ -848,7 +848,7 @@
 #define __builtin_ia32_mpsadbw256_mask(A, B, C, D, E) __builtin_ia32_mpsadbw256_mask (A, B, 1, D, E)
 #define __builtin_ia32_mpsadbw128_mask(A, B, C, D, E) __builtin_ia32_mpsadbw128_mask (A, B, 1, D, E)

-/* avx10_2convertintrin.h */
+/* avx10v1auxintrin.h */
 #define __builtin_ia32_vcvt2ps2phx512_mask_round(A, B, C, D, E) __builtin_ia32_vcvt2ps2phx512_mask_round(A, B, C, D, 8)

 /* avx10_2bf16intrin.h */
diff --git a/gcc/testsuite/gcc.target/i386/avx10_2-builtin-1.c b/gcc/testsuite/gcc.target/i386/avx10_2-builtin-1.c
index 2c793cfa0a98..867a439364b1 100644
--- a/gcc/testsuite/gcc.target/i386/avx10_2-builtin-1.c
+++ b/gcc/testsuite/gcc.target/i386/avx10_2-builtin-1.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O0 -march=x86-64-v3 -mavx10.2 -mno-avxvnniint8" } */
+/* { dg-options "-O0 -march=x86-64-v3 -mavx10v1aux -mno-avx10.2 -mno-avxvnniint8" } */
 typedef int v8si __attribute__ ((vector_size (32)));
 v8si
 foo (v8si a, v8si b, v8si c)
diff --git a/gcc/testsuite/gcc.target/i386/avx10_2-builtin-2.c b/gcc/testsuite/gcc.target/i386/avx10_2-builtin-2.c
index 6eeb20e034f0..73e32fe4f9fa 100644
--- a/gcc/testsuite/gcc.target/i386/avx10_2-builtin-2.c
+++ b/gcc/testsuite/gcc.target/i386/avx10_2-builtin-2.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O0 -march=x86-64-v3 -mavx10.2 -mno-avxvnniint16" } */
+/* { dg-options "-O0 -march=x86-64-v3 -mavx10v1aux -mno-avx10.2 -mno-avxvnniint16" } */
 typedef int v8si __attribute__ ((vector_size (32)));
 v8si
 foo (v8si a, v8si b, v8si c)
diff --git a/gcc/testsuite/gcc.target/i386/avx10v1aux-1b.c b/gcc/testsuite/gcc.target/i386/avx10v1aux-1b.c
new file mode 100644
index 000000000000..3df9ce9c120c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx10v1aux-1b.c
@@ -0,0 +1,267 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx10v1aux -O2 " } */
+/* { dg-final { scan-assembler-times "vpdpbssd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssd\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssd\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssd\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbssds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsud\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsud\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsud\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsud\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsud\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsud\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsud\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsud\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsud\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsuds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsuds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsuds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsuds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsuds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsuds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsuds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsuds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbsuds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuud\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuud\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuud\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuud\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuud\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuud\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuud\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuud\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuud\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuuds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuuds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuuds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuuds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuuds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuuds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuuds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuuds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpbuuds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsud\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsud\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsud\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsud\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsud\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsud\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsud\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsud\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsud\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsuds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsuds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsuds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsuds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsuds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsuds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsuds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsuds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwsuds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusd\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusd\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusd\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwusds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuud\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuud\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuud\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuud\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuud\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuud\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuud\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuud\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuud\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuuds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuuds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuuds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuuds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuuds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuuds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuuds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuuds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vpdpwuuds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+
+#include 
+
+volatile __m512i x1,y2,z1;
+volatile __m256i x,y,z;
+volatile __m128i x_,y_,z_;
+volatile __mmask16 m16;
+volatile __mmask8 m;
+
+void extern
+avx10v1aux_test (void)
+{
+  x1 = _mm512_dpbssd_epi32 (x1, y2, z1);
+  x1 = _mm512_mask_dpbssd_epi32 (x1, m16, y2, z1);
+  x1 = _mm512_maskz_dpbssd_epi32 (m16, x1, y2, z1);
+
+  x = _mm256_dpbssd_epi32 (x, y, z);
+  x = _mm256_mask_dpbssd_epi32 (x, m, y, z);
+  x = _mm256_maskz_dpbssd_epi32 (m, x, y, z);
+
+  x_ = _mm_dpbssd_epi32 (x_, y_, z_);
+  x_ = _mm_mask_dpbssd_epi32 (x_, m, y_, z_);
+  x_ = _mm_maskz_dpbssd_epi32 (m, x_, y_, z_);
+
+  x1 = _mm512_dpbssds_epi32 (x1, y2, z1);
+  x1 = _mm512_mask_dpbssds_epi32 (x1, m16, y2, z1);
+  x1 = _mm512_maskz_dpbssds_epi32 (m16, x1, y2, z1);
+
+  x = _mm256_dpbssds_epi32 (x, y, z);
+  x = _mm256_mask_dpbssds_epi32 (x, m, y, z);
+  x = _mm256_maskz_dpbssds_epi32 (m, x, y, z);
+
+  x_ = _mm_dpbssds_epi32 (x_, y_, z_);
+  x_ = _mm_mask_dpbssds_epi32 (x_, m, y_, z_);
+  x_ = _mm_maskz_dpbssds_epi32 (m, x_, y_, z_);
+
+  x1 = _mm512_dpbsud_epi32 (x1, y2, z1);
+  x1 = _mm512_mask_dpbsud_epi32 (x1, m16, y2, z1);
+  x1 = _mm512_maskz_dpbsud_epi32 (m16, x1, y2, z1);
+
+  x = _mm256_dpbsud_epi32 (x, y, z);
+  x = _mm256_mask_dpbsud_epi32 (x, m, y, z);
+  x = _mm256_maskz_dpbsud_epi32 (m, x, y, z);
+
+  x_ = _mm_dpbsud_epi32 (x_, y_, z_);
+  x_ = _mm_mask_dpbsud_epi32 (x_, m, y_, z_);
+  x_ = _mm_maskz_dpbsud_epi32 (m, x_, y_, z_);
+
+  x1 = _mm512_dpbsuds_epi32 (x1, y2, z1);
+  x1 = _mm512_mask_dpbsuds_epi32 (x1, m16, y2, z1);
+  x1 = _mm512_maskz_dpbsuds_epi32 (m16, x1, y2, z1);
+
+  x = _mm256_dpbsuds_epi32 (x, y, z);
+  x = _mm256_mask_dpbsuds_epi32 (x, m, y, z);
+  x = _mm256_maskz_dpbsuds_epi32 (m, x, y, z);
+
+  x_ = _mm_dpbsuds_epi32 (x_, y_, z_);
+  x_ = _mm_mask_dpbsuds_epi32 (x_, m, y_, z_);
+  x_ = _mm_maskz_dpbsuds_epi32 (m, x_, y_, z_);
+
+  x1 = _mm512_dpbuud_epi32 (x1, y2, z1);
+  x1 = _mm512_mask_dpbuud_epi32 (x1, m16, y2, z1);
+  x1 = _mm512_maskz_dpbuud_epi32 (m16, x1, y2, z1);
+
+  x = _mm256_dpbuud_epi32 (x, y, z);
+  x = _mm256_mask_dpbuud_epi32 (x, m, y, z);
+  x = _mm256_maskz_dpbuud_epi32 (m, x, y, z);
+
+  x_ = _mm_dpbuud_epi32 (x_, y_, z_);
+  x_ = _mm_mask_dpbuud_epi32 (x_, m, y_, z_);
+  x_ = _mm_maskz_dpbuud_epi32 (m, x_, y_, z_);
+
+  x1 = _mm512_dpbuuds_epi32 (x1, y2, z1);
+  x1 = _mm512_mask_dpbuuds_epi32 (x1, m16, y2, z1);
+  x1 = _mm512_maskz_dpbuuds_epi32 (m16, x1, y2, z1);
+
+  x = _mm256_dpbuuds_epi32 (x, y, z);
+  x = _mm256_mask_dpbuuds_epi32 (x, m, y, z);
+  x = _mm256_maskz_dpbuuds_epi32 (m, x, y, z);
+
+  x_ = _mm_dpbuuds_epi32 (x_, y_, z_);
+  x_ = _mm_mask_dpbuuds_epi32 (x_, m, y_, z_);
+  x_ = _mm_maskz_dpbuuds_epi32 (m, x_, y_, z_);
+
+  x1 = _mm512_dpwsud_epi32 (x1, y2, z1);
+  x1 = _mm512_mask_dpwsud_epi32 (x1, m16, y2, z1);
+  x1 = _mm512_maskz_dpwsud_epi32 (m16, x1, y2, z1);
+
+  x = _mm256_dpwsud_epi32 (x, y, z);
+  x = _mm256_mask_dpwsud_epi32 (x, m, y, z);
+  x = _mm256_maskz_dpwsud_epi32 (m, x, y, z);
+
+  x_ = _mm_dpwsud_epi32 (x_, y_, z_);
+  x_ = _mm_mask_dpwsud_epi32 (x_, m, y_, z_);
+  x_ = _mm_maskz_dpwsud_epi32 (m, x_, y_, z_);
+
+  x1 = _mm512_dpwsuds_epi32 (x1, y2, z1);
+  x1 = _mm512_mask_dpwsuds_epi32 (x1, m16, y2, z1);
+  x1 = _mm512_maskz_dpwsuds_epi32 (m16, x1, y2, z1);
+
+  x = _mm256_dpwsuds_epi32 (x, y, z);
+  x = _mm256_mask_dpwsuds_epi32 (x, m, y, z);
+  x = _mm256_maskz_dpwsuds_epi32 (m, x, y, z);
+
+  x_ = _mm_dpwsuds_epi32 (x_, y_, z_);
+  x_ = _mm_mask_dpwsuds_epi32 (x_, m, y_, z_);
+  x_ = _mm_maskz_dpwsuds_epi32 (m, x_, y_, z_);
+
+  x1 = _mm512_dpwusd_epi32 (x1, y2, z1);
+  x1 = _mm512_mask_dpwusd_epi32 (x1, m16, y2, z1);
+  x1 = _mm512_maskz_dpwusd_epi32 (m16, x1, y2, z1);
+
+  x = _mm256_dpwusd_epi32 (x, y, z);
+  x = _mm256_mask_dpwusd_epi32 (x, m, y, z);
+  x = _mm256_maskz_dpwusd_epi32 (m, x, y, z);
+
+  x_ = _mm_dpwusd_epi32 (x_, y_, z_);
+  x_ = _mm_mask_dpwusd_epi32 (x_, m, y_, z_);
+  x_ = _mm_maskz_dpwusd_epi32 (m, x_, y_, z_);
+
+  x1 = _mm512_dpwusds_epi32 (x1, y2, z1);
+  x1 = _mm512_mask_dpwusds_epi32 (x1, m16, y2, z1);
+  x1 = _mm512_maskz_dpwusds_epi32 (m16, x1, y2, z1);
+
+  x = _mm256_dpwusds_epi32 (x, y, z);
+  x = _mm256_mask_dpwusds_epi32 (x, m, y, z);
+  x = _mm256_maskz_dpwusds_epi32 (m, x, y, z);
+
+  x_ = _mm_dpwusds_epi32 (x_, y_, z_);
+  x_ = _mm_mask_dpwusds_epi32 (x_, m, y_, z_);
+  x_ = _mm_maskz_dpwusds_epi32 (m, x_, y_, z_);
+
+  x1 = _mm512_dpwuud_epi32 (x1, y2, z1);
+  x1 = _mm512_mask_dpwuud_epi32 (x1, m16, y2, z1);
+  x1 = _mm512_maskz_dpwuud_epi32 (m16, x1, y2, z1);
+
+  x = _mm256_dpwuud_epi32 (x, y, z);
+  x = _mm256_mask_dpwuud_epi32 (x, m, y, z);
+  x = _mm256_maskz_dpwuud_epi32 (m, x, y, z);
+
+  x_ = _mm_dpwuud_epi32 (x_, y_, z_);
+  x_ = _mm_mask_dpwuud_epi32 (x_, m, y_, z_);
+  x_ = _mm_maskz_dpwuud_epi32 (m, x_, y_, z_);
+
+  x1 = _mm512_dpwuuds_epi32 (x1, y2, z1);
+  x1 = _mm512_mask_dpwuuds_epi32 (x1, m16, y2, z1);
+  x1 = _mm512_maskz_dpwuuds_epi32 (m16, x1, y2, z1);
+
+  x = _mm256_dpwuuds_epi32 (x, y, z);
+  x = _mm256_mask_dpwuuds_epi32 (x, m, y, z);
+  x = _mm256_maskz_dpwuuds_epi32 (m, x, y, z);
+
+  x_ = _mm_dpwuuds_epi32 (x_, y_, z_);
+  x_ = _mm_mask_dpwuuds_epi32 (x_, m, y_, z_);
+  x_ = _mm_maskz_dpwuuds_epi32 (m, x_, y_, z_);
+
+}
diff --git a/gcc/testsuite/gcc.target/i386/sse-13.c b/gcc/testsuite/gcc.target/i386/sse-13.c
index 3284fcd4bd43..f43fa8cebf1b 100644
--- a/gcc/testsuite/gcc.target/i386/sse-13.c
+++ b/gcc/testsuite/gcc.target/i386/sse-13.c
@@ -855,7 +855,7 @@
 #define __builtin_ia32_mpsadbw256_mask(A, B, C, D, E) __builtin_ia32_mpsadbw256_mask (A, B, 1, D, E)
 #define __builtin_ia32_mpsadbw128_mask(A, B, C, D, E) __builtin_ia32_mpsadbw128_mask (A, B, 1, D, E)

-/* avx10_2convertintrin.h */
+/* avx10v1auxintrin.h */
 #define __builtin_ia32_vcvt2ps2phx512_mask_round(A, B, C, D, E) __builtin_ia32_vcvt2ps2phx512_mask_round(A, B, C, D, 8)

 /* avx10_2bf16intrin.h */
diff --git a/gcc/testsuite/gcc.target/i386/sse-14.c b/gcc/testsuite/gcc.target/i386/sse-14.c
index 1e9ad6bdcf95..600fe9f3ecea 100644
--- a/gcc/testsuite/gcc.target/i386/sse-14.c
+++ b/gcc/testsuite/gcc.target/i386/sse-14.c
@@ -1045,7 +1045,7 @@ test_4 (_mm512_mask_mpsadbw_epu8, __m512i, __m512i, __mmask32, __m512i, __m512i,
 test_4 (_mm256_mask_mpsadbw_epu8, __m256i, __m256i, __mmask16, __m256i, __m256i, 1)
 test_4 (_mm_mask_mpsadbw_epu8, __m128i, __m128i, __mmask8, __m128i, __m128i, 1)

-/* avx10_2convertintrin.h */
+/* avx10v1auxintrin.h */
 test_2 (_mm512_cvtx_round2ps_ph, __m512h, __m512, __m512, 4)

 /* avx10_2bf16intrin.h */
diff --git a/gcc/testsuite/gcc.target/i386/sse-22.c b/gcc/testsuite/gcc.target/i386/sse-22.c
index 9e50994946c5..a4f2613131bd 100644
--- a/gcc/testsuite/gcc.target/i386/sse-22.c
+++ b/gcc/testsuite/gcc.target/i386/sse-22.c
@@ -1086,7 +1086,7 @@ test_4 (_mm512_mask_mpsadbw_epu8, __m512i, __m512i, __mmask32, __m512i, __m512i,
 test_4 (_mm256_mask_mpsadbw_epu8, __m256i, __m256i, __mmask16, __m256i, __m256i, 1)
 test_4 (_mm_mask_mpsadbw_epu8, __m128i, __m128i, __mmask8, __m128i, __m128i, 1)

-/* avx10_2convertintrin.h */
+/* avx10v1auxintrin.h */
 test_2 (_mm512_cvtx_round2ps_ph, __m512h, __m512, __m512, 4)

 /* avx10_2bf16intrin.h */
diff --git a/gcc/testsuite/gcc.target/i386/sse-23.c b/gcc/testsuite/gcc.target/i386/sse-23.c
index c6cf53b5ed08..509cceb21eaa 100644
--- a/gcc/testsuite/gcc.target/i386/sse-23.c
+++ b/gcc/testsuite/gcc.target/i386/sse-23.c
@@ -830,7 +830,7 @@
 #define __builtin_ia32_mpsadbw256_mask(A, B, C, D, E) __builtin_ia32_mpsadbw256_mask (A, B, 1, D, E)
 #define __builtin_ia32_mpsadbw128_mask(A, B, C, D, E) __builtin_ia32_mpsadbw128_mask (A, B, 1, D, E)

-/* avx10_2convertintrin.h */
+/* avx10v1auxintrin.h */
 #define __builtin_ia32_vcvt2ps2phx512_mask_round(A, B, C, D, E) __builtin_ia32_vcvt2ps2phx512_mask_round(A, B, C, D, 8)

 /* avx10_2bf16intrin.h */
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 1485d1bef81b..d6794c0e8c59 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -11773,7 +11773,9 @@ proc check_effective_target_avx10v1aux { } {
 	void
 	foo ()
 	{
-	  __asm__ volatile ("vcvt2ph2bf8\t{%%zmm2, %%zmm1, %%zmm1|%%zmm1, %%zmm1, %%zmm2}");
+	  __asm__ volatile ("vpdpbssds\t{%%zmm2, %%zmm1, %%zmm0|%%zmm0, %%zmm1, %%zmm2}");
+	  __asm__ volatile ("vpdpwsud\t{%%zmm2, %%zmm1, %%zmm0|%%zmm0, %%zmm1, %%zmm2}");
+	  __asm__ volatile ("vcvt2ph2bf8\t{%%zmm2, %%zmm1, %%zmm0|%%zmm0, %%zmm1, %%zmm2}");
 	}
     } "-mavx10v1aux" ]
 }
--
2.34.1


From Dipesh.Sharma@amd.com  Sun Nov  1 13:47:54 2026
From: Dipesh.Sharma@amd.com (Dipesh Sharma)
Date: Sun, 1 Nov 2026 19:17:54 +0530
Subject: [PATCH v3 2/4] [X86]: Move shared AVX10.2 convert intrinsics to
 AVX10V1AUX.
In-Reply-To: <20261101134756.351245-1-Dipesh.Sharma@amd.com>
References: <20261101134756.351245-1-Dipesh.Sharma@amd.com>
Message-ID: <20261101134756.351245-3-Dipesh.Sharma@amd.com>

gcc/ChangeLog:

	* config.gcc: Add avx10v1auxintrin.h.
	* config/i386/avx10_2convertintrin.h: Moved convert intrins to avx10v1auxintrin.h.
	* config/i386/i386-builtin.def (BDESC): Updated option mask for convert builtins.
	* config/i386/immintrin.h: Include avx10v1auxintrin.h.
	* config/i386/sse.md: Retarget avx10.2 subset convert patterns to AVX10V1AUX.
	* config/i386/avx10v1auxintrin.h: New file.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/funcspec-56.inc: Check for avx10v1aux.
	* lib/target-supports.exp: Ditto.
	* gcc.target/i386/avx10v1aux-1a.c: New test.

Co-authored-by: Venkataramanan Kumar 
---
 gcc/config.gcc                                |    2 +-
 gcc/config/i386/avx10_2convertintrin.h        | 1376 ----------------
 gcc/config/i386/avx10v1auxintrin.h            | 1427 +++++++++++++++++
 gcc/config/i386/i386-builtin.def              |   92 +-
 gcc/config/i386/immintrin.h                   |    2 +
 gcc/config/i386/sse.md                        |   37 +-
 gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c |  375 +++++
 gcc/testsuite/gcc.target/i386/funcspec-56.inc |    2 +
 gcc/testsuite/lib/target-supports.exp         |   11 +
 9 files changed, 1881 insertions(+), 1443 deletions(-)
 create mode 100644 gcc/config/i386/avx10v1auxintrin.h
 create mode 100644 gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c

diff --git a/gcc/config.gcc b/gcc/config.gcc
index d651c3aae37e..4369ebd3f6d9 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -489,7 +489,7 @@ i[34567]86-*-* | x86_64-*-*)
 		       avx10_2minmaxintrin.h avx10_2copyintrin.h
 		       amxavx512intrin.h amxfp8intrin.h movrsintrin.h
 		       amxmovrsintrin.h avx512bmmintrin.h avx512bmmvlintrin.h
-		       avx10v2auxintrin.h acev1intrin.h"
+		       avx10v2auxintrin.h avx10v1auxintrin.h acev1intrin.h"
 	;;
 ia64-*-*)
 	extra_headers=ia64intrin.h
diff --git a/gcc/config/i386/avx10_2convertintrin.h b/gcc/config/i386/avx10_2convertintrin.h
index fad82e75ca39..aebb5cd8d7c2 100644
--- a/gcc/config/i386/avx10_2convertintrin.h
+++ b/gcc/config/i386/avx10_2convertintrin.h
@@ -34,1382 +34,6 @@
 #define __DISABLE_AVX10_2__
 #endif /* __AVX10_2__ */

-extern __inline __m128h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvtx2ps_ph (__m128 __A, __m128 __B)
-{
-  return (__m128h) __builtin_ia32_vcvt2ps2phx128_mask ((__v4sf) __A,
-						       (__v4sf) __B,
-						       (__v8hf)
-						       _mm_setzero_ph (),
-						       (__mmask8) -1);
-}
-
-extern __inline __m128h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvtx2ps_ph (__m128h __W, __mmask8 __U, __m128 __A, __m128 __B)
-{
-  return (__m128h) __builtin_ia32_vcvt2ps2phx128_mask ((__v4sf) __A,
-						       (__v4sf) __B,
-						       (__v8hf) __W,
-						       (__mmask8) __U);
-}
-
-extern __inline __m128h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvtx2ps_ph (__mmask8 __U, __m128 __A, __m128 __B)
-{
-  return (__m128h) __builtin_ia32_vcvt2ps2phx128_mask ((__v4sf) __A,
-						       (__v4sf) __B,
-						       (__v8hf)
-						       _mm_setzero_ph (),
-						       (__mmask8) __U);
-}
-
-extern __inline __m256h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvtx2ps_ph (__m256 __A, __m256 __B)
-{
-  return (__m256h) __builtin_ia32_vcvt2ps2phx256_mask ((__v8sf) __A,
-						       (__v8sf) __B,
-						       (__v16hf)
-						       _mm256_setzero_ph (),
-						       (__mmask16) -1);
-}
-
-extern __inline __m256h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvtx2ps_ph (__m256h __W, __mmask16 __U, __m256 __A, __m256 __B)
-{
-  return (__m256h) __builtin_ia32_vcvt2ps2phx256_mask ((__v8sf) __A,
-						       (__v8sf) __B,
-						       (__v16hf) __W,
-						       (__mmask16) __U);
-}
-
-extern __inline __m256h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvtx2ps_ph ( __mmask16 __U, __m256 __A, __m256 __B)
-{
-  return (__m256h) __builtin_ia32_vcvt2ps2phx256_mask ((__v8sf) __A,
-						       (__v8sf) __B,
-						       (__v16hf)
-						       _mm256_setzero_ph (),
-						       (__mmask16) __U);
-}
-
-extern __inline __m512h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvtx2ps_ph (__m512 __A, __m512 __B)
-{
-  return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) __A,
-							     (__v16sf) __B,
-							     (__v32hf)
-							     _mm512_setzero_ph (),
-							     (__mmask32) -1,
-							     _MM_FROUND_CUR_DIRECTION);
-}
-
-extern __inline __m512h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvtx2ps_ph (__m512h __W, __mmask32 __U, __m512 __A,
-			__m512 __B)
-{
-  return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) __A,
-							     (__v16sf) __B,
-							     (__v32hf) __W,
-							     (__mmask32) __U,
-							     _MM_FROUND_CUR_DIRECTION);
-}
-
-extern __inline __m512h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvtx2ps_ph (__mmask32 __U, __m512 __A, __m512 __B)
-{
-  return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) __A,
-							     (__v16sf) __B,
-							     (__v32hf)
-							     _mm512_setzero_ph (),
-							     (__mmask32) __U,
-							     _MM_FROUND_CUR_DIRECTION);
-}
-
-#ifdef __OPTIMIZE__
-extern __inline __m512h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvtx_round2ps_ph (__m512 __A, __m512 __B, const int __R)
-{
-  return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) __A,
-							    (__v16sf) __B,
-							    (__v32hf)
-							    _mm512_setzero_ph (),
-							    (__mmask32) -1,
-							    __R);
-}
-
-extern __inline __m512h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvtx_round2ps_ph (__m512h __W, __mmask32 __U, __m512 __A,
-			      __m512 __B, const int __R)
-{
-  return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) __A,
-							    (__v16sf) __B,
-							    (__v32hf) __W,
-							    (__mmask32) __U,
-							    __R);
-}
-
-extern __inline __m512h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvtx_round2ps_ph (__mmask32 __U, __m512 __A,
-			      __m512 __B, const int __R)
-{
-  return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) __A,
-							    (__v16sf) __B,
-							    (__v32hf)
-							    _mm512_setzero_ph (),
-							    (__mmask32) __U,
-							    __R);
-}
-
-#else
-#define _mm512_cvtx_round2ps_ph(A, B, R) \
-  ((__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) (A), \
-						       (__v16sf) (B), \
-						       (__v32hf) \
-						       (_mm512_setzero_ph ()), \
-						       (__mmask32) (-1), \
-						       (R)))
-#define _mm512_mask_cvtx_round2ps_ph(W, U, A, B, R) \
-  ((__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) (A), \
-						       (__v16sf) (B), \
-						       (__v32hf) (W), \
-						       (__mmask32) (U), \
-						       (R)))
-#define _mm512_maskz_cvtx_round2ps_ph(U, A, B, R) \
-  ((__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) (A), \
-						       (__v16sf) (B), \
-						       (__v32hf) \
-						       (_mm512_setzero_ph ()), \
-						       (__mmask32) (U), \
-						       (R)))
-#endif  /* __OPTIMIZE__  */
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvtbiasph_bf8 (__m128i __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2bf8128 ((__v16qi) __A,
-						     (__v8hf) __B);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvtbiasph_bf8 (__m128i __W, __mmask8 __U, __m128i __A,
-			__m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2bf8128_mask ((__v16qi) __A,
-							  (__v8hf) __B,
-							  (__v16qi)(__m128i) __W,
-							  (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvtbiasph_bf8 (__mmask8 __U, __m128i __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2bf8128_mask ((__v16qi) __A,
-							  (__v8hf) __B,
-							  (__v16qi)(__m128i)
-							   _mm_setzero_si128 (),
-							  (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvtbiasph_bf8 (__m256i __A, __m256h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2bf8256_mask ((__v32qi) __A,
-							  (__v16hf) __B,
-							  (__v16qi)(__m128i)
-							  _mm_undefined_si128 (),
-							  (__mmask16) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvtbiasph_bf8 (__m128i __W, __mmask16 __U, __m256i __A,
-			   __m256h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2bf8256_mask ((__v32qi) __A,
-							  (__v16hf) __B,
-							  (__v16qi)(__m128i) __W,
-							  (__mmask16) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvtbiasph_bf8 (__mmask16 __U, __m256i __A, __m256h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2bf8256_mask ((__v32qi) __A,
-							  (__v16hf) __B,
-							  (__v16qi)(__m128i)
-							   _mm_setzero_si128 (),
-							  (__mmask16) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvtbiasph_bf8 (__m512i __A, __m512h __B)
-{
-  return (__m256i) __builtin_ia32_vcvtbiasph2bf8512_mask ((__v64qi) __A,
-							  (__v32hf) __B,
-							  (__v32qi)(__m256i)
-							  _mm256_undefined_si256 (),
-							  (__mmask32) -1);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvtbiasph_bf8 (__m256i __W, __mmask32 __U,
-			   __m512i __A, __m512h __B)
-{
-  return (__m256i) __builtin_ia32_vcvtbiasph2bf8512_mask ((__v64qi) __A,
-							  (__v32hf) __B,
-							  (__v32qi)(__m256i) __W,
-							  (__mmask32) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvtbiasph_bf8 (__mmask32 __U, __m512i __A, __m512h __B)
-{
-  return (__m256i) __builtin_ia32_vcvtbiasph2bf8512_mask ((__v64qi) __A,
-							  (__v32hf) __B,
-							  (__v32qi)(__m256i)
-							  _mm256_setzero_si256 (),
-							  (__mmask32) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvts_biasph_bf8 (__m128i __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2bf8s128 ((__v16qi) __A,
-						      (__v8hf) __B);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvts_biasph_bf8 (__m128i __W, __mmask8 __U,
-			  __m128i __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2bf8s128_mask ((__v16qi) __A,
-							   (__v8hf) __B,
-							   (__v16qi)(__m128i) __W,
-							   (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvts_biasph_bf8 (__mmask8 __U, __m128i __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2bf8s128_mask ((__v16qi) __A,
-							   (__v8hf) __B,
-							   (__v16qi)(__m128i)
-							   _mm_setzero_si128 (),
-							   (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvts_biasph_bf8 (__m256i __A, __m256h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2bf8s256_mask ((__v32qi) __A,
-							   (__v16hf) __B,
-							   (__v16qi)(__m128i)
-							   _mm_undefined_si128 (),
-							   (__mmask16) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvts_biasph_bf8 (__m128i __W, __mmask16 __U,
-			     __m256i __A, __m256h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2bf8s256_mask ((__v32qi) __A,
-							   (__v16hf) __B,
-							   (__v16qi)(__m128i) __W,
-							   (__mmask16) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvts_biasph_bf8 (__mmask16 __U, __m256i __A, __m256h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2bf8s256_mask ((__v32qi) __A,
-							   (__v16hf) __B,
-							   (__v16qi)(__m128i)
-							   _mm_setzero_si128 (),
-							   (__mmask16) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvts_biasph_bf8 (__m512i __A, __m512h __B)
-{
-  return (__m256i) __builtin_ia32_vcvtbiasph2bf8s512_mask ((__v64qi) __A,
-							   (__v32hf) __B,
-							   (__v32qi)(__m256i)
-							   _mm256_undefined_si256 (),
-							   (__mmask32) -1);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvts_biasph_bf8 (__m256i __W, __mmask32 __U,
-			     __m512i __A, __m512h __B)
-{
-  return (__m256i) __builtin_ia32_vcvtbiasph2bf8s512_mask ((__v64qi) __A,
-							   (__v32hf) __B,
-							   (__v32qi)(__m256i) __W,
-							   (__mmask32) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvts_biasph_bf8 (__mmask32 __U, __m512i __A, __m512h __B)
-{
-  return (__m256i) __builtin_ia32_vcvtbiasph2bf8s512_mask ((__v64qi) __A,
-							   (__v32hf) __B,
-							   (__v32qi)(__m256i)
-							   _mm256_setzero_si256 (),
-							   (__mmask32) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvtbiasph_hf8 (__m128i __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2hf8128 ((__v16qi) __A,
-						     (__v8hf) __B);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvtbiasph_hf8 (__m128i __W, __mmask8 __U, __m128i __A,
-			__m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2hf8128_mask ((__v16qi) __A,
-							  (__v8hf) __B,
-							  (__v16qi)(__m128i) __W,
-							  (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvtbiasph_hf8 (__mmask8 __U, __m128i __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2hf8128_mask ((__v16qi) __A,
-							  (__v8hf) __B,
-							  (__v16qi)(__m128i)
-							  _mm_setzero_si128 (),
-							  (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvtbiasph_hf8 (__m256i __A, __m256h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2hf8256_mask ((__v32qi) __A,
-							  (__v16hf) __B,
-							  (__v16qi)(__m128i)
-							  _mm_undefined_si128 (),
-							  (__mmask16) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvtbiasph_hf8 (__m128i __W, __mmask16 __U,
-			   __m256i __A, __m256h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2hf8256_mask ((__v32qi) __A,
-							  (__v16hf) __B,
-							  (__v16qi)(__m128i) __W,
-							  (__mmask16) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvtbiasph_hf8 (__mmask16 __U, __m256i __A, __m256h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2hf8256_mask ((__v32qi) __A,
-							  (__v16hf) __B,
-							  (__v16qi)(__m128i)
-							  _mm_setzero_si128 (),
-							  (__mmask16) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvtbiasph_hf8 (__m512i __A, __m512h __B)
-{
-  return (__m256i) __builtin_ia32_vcvtbiasph2hf8512_mask ((__v64qi) __A,
-							  (__v32hf) __B,
-							  (__v32qi)(__m256i)
-					 		  _mm256_undefined_si256 (),
-							  (__mmask32) -1);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvtbiasph_hf8 (__m256i __W, __mmask32 __U, __m512i __A,
-			   __m512h __B)
-{
-  return (__m256i) __builtin_ia32_vcvtbiasph2hf8512_mask ((__v64qi) __A,
-							  (__v32hf) __B,
-							  (__v32qi)(__m256i) __W,
-							  (__mmask32) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvtbiasph_hf8 (__mmask32 __U, __m512i __A, __m512h __B)
-{
-  return (__m256i) __builtin_ia32_vcvtbiasph2hf8512_mask ((__v64qi) __A,
-							  (__v32hf) __B,
-							  (__v32qi)(__m256i)
-							  _mm256_setzero_si256 (),
-							  (__mmask32) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvts_biasph_hf8 (__m128i __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2hf8s128 ((__v16qi) __A,
-						      (__v8hf) __B);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvts_biasph_hf8 (__m128i __W, __mmask8 __U,
-			  __m128i __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2hf8s128_mask ((__v16qi) __A,
-							   (__v8hf) __B,
-							   (__v16qi)(__m128i) __W,
-							   (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvts_biasph_hf8 (__mmask8 __U, __m128i __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2hf8s128_mask ((__v16qi) __A,
-							   (__v8hf) __B,
-							   (__v16qi)(__m128i)
-							   _mm_setzero_si128 (),
-							   (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvts_biasph_hf8 (__m256i __A, __m256h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2hf8s256_mask ((__v32qi) __A,
-							   (__v16hf) __B,
-							   (__v16qi)(__m128i)
-							   _mm_undefined_si128 (),
-							   (__mmask16) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvts_biasph_hf8 (__m128i __W, __mmask16 __U,
-			     __m256i __A, __m256h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2hf8s256_mask ((__v32qi) __A,
-							   (__v16hf) __B,
-							   (__v16qi)(__m128i) __W,
-							   (__mmask16) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvts_biasph_hf8 (__mmask16 __U, __m256i __A, __m256h __B)
-{
-  return (__m128i) __builtin_ia32_vcvtbiasph2hf8s256_mask ((__v32qi) __A,
-							   (__v16hf) __B,
-							   (__v16qi)(__m128i)
-							   _mm_setzero_si128 (),
-							   (__mmask16) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvts_biasph_hf8 (__m512i __A, __m512h __B)
-{
-  return (__m256i) __builtin_ia32_vcvtbiasph2hf8s512_mask ((__v64qi) __A,
-							   (__v32hf) __B,
-							   (__v32qi)(__m256i)
-							   _mm256_undefined_si256 (),
-							   (__mmask32) -1);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvts_biasph_hf8 (__m256i __W, __mmask32 __U,
-			     __m512i __A, __m512h __B)
-{
-  return (__m256i) __builtin_ia32_vcvtbiasph2hf8s512_mask ((__v64qi) __A,
-							   (__v32hf) __B,
-							   (__v32qi)(__m256i) __W,
-							   (__mmask32) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvts_biasph_hf8 (__mmask32 __U, __m512i __A, __m512h __B)
-{
-  return (__m256i) __builtin_ia32_vcvtbiasph2hf8s512_mask ((__v64qi) __A,
-							   (__v32hf) __B,
-							   (__v32qi)(__m256i)
-							   _mm256_setzero_si256 (),
-							   (__mmask32) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvt2ph_bf8 (__m128h __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvt2ph2bf8128_mask ((__v8hf) __A,
-						       (__v8hf) __B,
-						       (__v16qi)
-						       _mm_setzero_si128 (),
-						       (__mmask16) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvt2ph_bf8 (__m128i __W, __mmask16 __U,
-		     __m128h __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvt2ph2bf8128_mask ((__v8hf) __A,
-						       (__v8hf) __B,
-						       (__v16qi) __W,
-						       (__mmask16) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvt2ph_bf8 (__mmask16 __U, __m128h __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvt2ph2bf8128_mask ((__v8hf) __A,
-						       (__v8hf) __B,
-						       (__v16qi)
-						       _mm_setzero_si128 (),
-						       (__mmask16) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvt2ph_bf8 (__m256h __A, __m256h __B)
-{
-  return (__m256i) __builtin_ia32_vcvt2ph2bf8256_mask ((__v16hf) __A,
-						       (__v16hf) __B,
-						       (__v32qi)
-						       _mm256_setzero_si256 (),
-						       (__mmask32) -1);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvt2ph_bf8 (__m256i __W, __mmask32 __U,
-			__m256h __A, __m256h __B)
-{
-  return (__m256i) __builtin_ia32_vcvt2ph2bf8256_mask ((__v16hf) __A,
-						       (__v16hf) __B,
-						       (__v32qi) __W,
-						       (__mmask32) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvt2ph_bf8 (__mmask32 __U, __m256h __A, __m256h __B)
-{
-  return (__m256i) __builtin_ia32_vcvt2ph2bf8256_mask ((__v16hf) __A,
-						       (__v16hf) __B,
-						       (__v32qi)
-						       _mm256_setzero_si256 (),
-						       (__mmask32) __U);
-}
-
-extern __inline__ __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvt2ph_bf8 (__m512h __A, __m512h __B)
-{
-  return (__m512i) __builtin_ia32_vcvt2ph2bf8512_mask ((__v32hf) __A,
-						       (__v32hf) __B,
-						       (__v64qi)
-						       _mm512_setzero_si512 (),
-						       (__mmask64) -1);
-}
-
-extern __inline__ __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvt2ph_bf8 (__m512i __W, __mmask64 __U,
-			__m512h __A, __m512h __B)
-{
-  return (__m512i) __builtin_ia32_vcvt2ph2bf8512_mask ((__v32hf) __A,
-						       (__v32hf) __B,
-						       (__v64qi) __W,
-						       (__mmask64) __U);
-}
-
-extern __inline__ __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvt2ph_bf8 (__mmask64 __U,  __m512h __A, __m512h __B)
-{
-  return (__m512i) __builtin_ia32_vcvt2ph2bf8512_mask ((__v32hf) __A,
-						       (__v32hf) __B,
-						       (__v64qi)
-						       _mm512_setzero_si512 (),
-						       (__mmask64) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvts_2ph_bf8 (__m128h __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvt2ph2bf8s128_mask ((__v8hf) __A,
-							(__v8hf) __B,
-							(__v16qi)
-							_mm_setzero_si128 (),
-							(__mmask16) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvts_2ph_bf8 (__m128i __W, __mmask16 __U,
-		       __m128h __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvt2ph2bf8s128_mask ((__v8hf) __A,
-							(__v8hf) __B,
-							(__v16qi) __W,
-							(__mmask16) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvts_2ph_bf8 (__mmask16 __U, __m128h __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvt2ph2bf8s128_mask ((__v8hf) __A,
-							(__v8hf) __B,
-							(__v16qi)
-							_mm_setzero_si128 (),
-							(__mmask16) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvts_2ph_bf8 (__m256h __A, __m256h __B)
-{
-  return (__m256i) __builtin_ia32_vcvt2ph2bf8s256_mask ((__v16hf) __A,
-							(__v16hf) __B,
-							(__v32qi)
-							_mm256_setzero_si256 (),
-							(__mmask32) -1);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvts_2ph_bf8 (__m256i __W, __mmask32 __U,
-			  __m256h __A, __m256h __B)
-{
-  return (__m256i) __builtin_ia32_vcvt2ph2bf8s256_mask ((__v16hf) __A,
-							(__v16hf) __B,
-							(__v32qi) __W,
-							(__mmask32) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvts_2ph_bf8 (__mmask32 __U, __m256h __A, __m256h __B)
-{
-  return (__m256i) __builtin_ia32_vcvt2ph2bf8s256_mask ((__v16hf) __A,
-							(__v16hf) __B,
-							(__v32qi)
-							_mm256_setzero_si256 (),
-							(__mmask32) __U);
-}
-
-extern __inline__ __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvts_2ph_bf8 (__m512h __A, __m512h __B)
-{
-  return (__m512i) __builtin_ia32_vcvt2ph2bf8s512_mask ((__v32hf) __A,
-							(__v32hf) __B,
-							(__v64qi)
-							_mm512_setzero_si512 (),
-							(__mmask64) -1);
-}
-
-extern __inline__ __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvts_2ph_bf8 (__m512i __W, __mmask64 __U,
-			  __m512h __A, __m512h __B)
-{
-  return (__m512i) __builtin_ia32_vcvt2ph2bf8s512_mask ((__v32hf) __A,
-							(__v32hf) __B,
-							(__v64qi) __W,
-							(__mmask64) __U);
-}
-
-extern __inline__ __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvts_2ph_bf8 (__mmask64 __U, __m512h __A, __m512h __B)
-{
-  return (__m512i) __builtin_ia32_vcvt2ph2bf8s512_mask ((__v32hf) __A,
-							(__v32hf) __B,
-							(__v64qi)
-							_mm512_setzero_si512 (),
-							(__mmask64) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvt2ph_hf8 (__m128h __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvt2ph2hf8128_mask ((__v8hf) __A,
-						       (__v8hf) __B,
-						       (__v16qi)
-						       _mm_setzero_si128 (),
-						       (__mmask16) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvt2ph_hf8 (__m128i __W, __mmask16 __U,
-		     __m128h __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvt2ph2hf8128_mask ((__v8hf) __A,
-						       (__v8hf) __B,
-						       (__v16qi) __W,
-						       (__mmask16) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvt2ph_hf8 (__mmask16 __U, __m128h __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvt2ph2hf8128_mask ((__v8hf) __A,
-						       (__v8hf) __B,
-						       (__v16qi)
-						       _mm_setzero_si128 (),
-						       (__mmask16) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvt2ph_hf8 (__m256h __A, __m256h __B)
-{
-  return (__m256i) __builtin_ia32_vcvt2ph2hf8256_mask ((__v16hf) __A,
-						       (__v16hf) __B,
-						       (__v32qi)
-						       _mm256_setzero_si256 (),
-						       (__mmask32) -1);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvt2ph_hf8 (__m256i __W, __mmask32 __U,
-			__m256h __A, __m256h __B)
-{
-  return (__m256i) __builtin_ia32_vcvt2ph2hf8256_mask ((__v16hf) __A,
-						       (__v16hf) __B,
-						       (__v32qi) __W,
-						       (__mmask32) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvt2ph_hf8 (__mmask32 __U, __m256h __A, __m256h __B)
-{
-  return (__m256i) __builtin_ia32_vcvt2ph2hf8256_mask ((__v16hf) __A,
-						       (__v16hf) __B,
-						       (__v32qi)
-						       _mm256_setzero_si256 (),
-						       (__mmask32) __U);
-}
-
-extern __inline__ __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvt2ph_hf8 (__m512h __A, __m512h __B)
-{
-  return (__m512i) __builtin_ia32_vcvt2ph2hf8512_mask ((__v32hf) __A,
-						       (__v32hf) __B,
-						       (__v64qi)
-						       _mm512_setzero_si512 (),
-						       (__mmask64) -1);
-}
-
-extern __inline__ __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvt2ph_hf8 (__m512i __W, __mmask64 __U,
-			__m512h __A, __m512h __B)
-{
-  return (__m512i) __builtin_ia32_vcvt2ph2hf8512_mask ((__v32hf) __A,
-						       (__v32hf) __B,
-						       (__v64qi) __W,
-						       (__mmask64) __U);
-}
-
-extern __inline__ __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvt2ph_hf8 (__mmask64 __U, __m512h __A, __m512h __B)
-{
-  return (__m512i) __builtin_ia32_vcvt2ph2hf8512_mask ((__v32hf) __A,
-						       (__v32hf) __B,
-						       (__v64qi)
-						       _mm512_setzero_si512 (),
-						       (__mmask64) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvts_2ph_hf8 (__m128h __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvt2ph2hf8s128_mask ((__v8hf) __A,
-							(__v8hf) __B,
-							(__v16qi)
-							_mm_setzero_si128 (),
-							(__mmask16) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvts_2ph_hf8 (__m128i __W, __mmask16 __U,
-		       __m128h __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvt2ph2hf8s128_mask ((__v8hf) __A,
-							(__v8hf) __B,
-							(__v16qi) __W,
-							(__mmask16) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvts_2ph_hf8 (__mmask16 __U, __m128h __A, __m128h __B)
-{
-  return (__m128i) __builtin_ia32_vcvt2ph2hf8s128_mask ((__v8hf) __A,
-							(__v8hf) __B,
-							(__v16qi)
-							_mm_setzero_si128 (),
-							(__mmask16) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvts_2ph_hf8 (__m256h __A, __m256h __B)
-{
-  return (__m256i) __builtin_ia32_vcvt2ph2hf8s256_mask ((__v16hf) __A,
-							(__v16hf) __B,
-							(__v32qi)
-							_mm256_setzero_si256 (),
-							(__mmask32) -1);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvts_2ph_hf8 (__m256i __W, __mmask32 __U,
-			  __m256h __A, __m256h __B)
-{
-  return (__m256i) __builtin_ia32_vcvt2ph2hf8s256_mask ((__v16hf) __A,
-							(__v16hf) __B,
-							(__v32qi) __W,
-							(__mmask32) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvts_2ph_hf8 (__mmask32 __U, __m256h __A, __m256h __B)
-{
-  return (__m256i) __builtin_ia32_vcvt2ph2hf8s256_mask ((__v16hf) __A,
-							(__v16hf) __B,
-							(__v32qi)
-							_mm256_setzero_si256 (),
-							(__mmask32) __U);
-}
-
-extern __inline__ __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvts_2ph_hf8 (__m512h __A, __m512h __B)
-{
-  return (__m512i) __builtin_ia32_vcvt2ph2hf8s512_mask ((__v32hf) __A,
-							(__v32hf) __B,
-							(__v64qi)
-							_mm512_setzero_si512 (),
-							(__mmask64) -1);
-}
-
-extern __inline__ __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvts_2ph_hf8 (__m512i __W, __mmask64 __U,
-			  __m512h __A, __m512h __B)
-{
-  return (__m512i) __builtin_ia32_vcvt2ph2hf8s512_mask ((__v32hf) __A,
-							(__v32hf) __B,
-							(__v64qi) __W,
-							(__mmask64) __U);
-}
-
-extern __inline__ __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvts_2ph_hf8 (__mmask64 __U, __m512h __A, __m512h __B)
-{
-  return (__m512i) __builtin_ia32_vcvt2ph2hf8s512_mask ((__v32hf) __A,
-							(__v32hf) __B,
-							(__v64qi)
-							_mm512_setzero_si512 (),
-							(__mmask64) __U);
-}
-
-extern __inline__ __m128h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvthf8_ph (__m128i __A)
-{
-  return (__m128h) __builtin_ia32_vcvthf82ph128_mask ((__v16qi) __A,
-						      (__v8hf)(__m128h)
-						      _mm_undefined_ph (),
-						      (__mmask8) -1);
-}
-
-extern __inline__ __m128h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvthf8_ph (__m128h __W, __mmask8 __U, __m128i __A)
-{
-  return (__m128h) __builtin_ia32_vcvthf82ph128_mask ((__v16qi) __A,
-						      (__v8hf)(__m128h) __W,
-						      (__mmask8) __U);
-}
-
-extern __inline__ __m128h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvthf8_ph (__mmask8 __U, __m128i __A)
-{
-  return (__m128h) __builtin_ia32_vcvthf82ph128_mask ((__v16qi) __A,
-						      (__v8hf)(__m128h)
-						      _mm_setzero_ph (),
-						      (__mmask8) __U);
-}
-
-extern __inline__ __m256h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvthf8_ph (__m128i __A)
-{
-  return (__m256h) __builtin_ia32_vcvthf82ph256_mask ((__v16qi) __A,
-						      (__v16hf)(__m256h)
-						      _mm256_undefined_ph (),
-						      (__mmask16) -1);
-}
-
-extern __inline__ __m256h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvthf8_ph (__m256h __W, __mmask16 __U, __m128i __A)
-{
-  return (__m256h) __builtin_ia32_vcvthf82ph256_mask ((__v16qi) __A,
-						      (__v16hf)(__m256h) __W,
-						      (__mmask16) __U);
-}
-
-extern __inline__ __m256h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvthf8_ph (__mmask16 __U, __m128i __A)
-{
-  return (__m256h) __builtin_ia32_vcvthf82ph256_mask ((__v16qi) __A,
-						      (__v16hf)(__m256h)
-						      _mm256_setzero_ph (),
-						      (__mmask16) __U);
-}
-
-extern __inline__ __m512h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvthf8_ph (__m256i __A)
-{
-  return (__m512h) __builtin_ia32_vcvthf82ph512_mask ((__v32qi) __A,
-						      (__v32hf) (__m512h)
-						      _mm512_undefined_ph (),
-						      (__mmask32) -1);
-}
-
-extern __inline__ __m512h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvthf8_ph (__m512h __W, __mmask32 __U, __m256i __A)
-{
-  return (__m512h) __builtin_ia32_vcvthf82ph512_mask ((__v32qi) __A,
-						      (__v32hf) (__m512h) __W,
-						      (__mmask32) __U);
-}
-
-extern __inline__ __m512h
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvthf8_ph (__mmask32 __U, __m256i __A)
-{
-  return (__m512h) __builtin_ia32_vcvthf82ph512_mask ((__v32qi) __A,
-						      (__v32hf) (__m512h)
-						      _mm512_setzero_ph (),
-						      (__mmask32) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvtph_bf8 (__m128h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2bf8128_mask ((__v8hf) __A,
-						      (__v16qi)(__m128i)
-						      _mm_undefined_si128 (),
-						      (__mmask8) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvtph_bf8 (__m128i __W, __mmask8 __U, __m128h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2bf8128_mask ((__v8hf) __A,
-						      (__v16qi)(__m128i) __W,
-						      (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvtph_bf8 (__mmask8 __U, __m128h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2bf8128_mask ((__v8hf) __A,
-						      (__v16qi)(__m128i)
-						      _mm_setzero_si128 (),
-						      (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvtph_bf8 (__m256h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2bf8256_mask ((__v16hf) __A,
-						      (__v16qi)(__m128i)
-						      _mm_undefined_si128 (),
-						      (__mmask16) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvtph_bf8 (__m128i __W, __mmask16 __U, __m256h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2bf8256_mask ((__v16hf) __A,
-						      (__v16qi)(__m128i) __W,
-						      (__mmask16) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvtph_bf8 (__mmask16 __U, __m256h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2bf8256_mask ((__v16hf) __A,
-						      (__v16qi)(__m128i)
-						      _mm_setzero_si128 (),
-						      (__mmask16) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvtph_bf8 (__m512h __A)
-{
-  return (__m256i) __builtin_ia32_vcvtph2bf8512_mask ((__v32hf) __A,
-						      (__v32qi) (__m256i)
-						      _mm256_undefined_si256 (),
-						      (__mmask32) -1);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvtph_bf8 (__m256i __W, __mmask32 __U, __m512h __A)
-{
-  return (__m256i) __builtin_ia32_vcvtph2bf8512_mask ((__v32hf) __A,
-						      (__v32qi) (__m256i) __W,
-						      (__mmask32) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvtph_bf8 (__mmask32 __U, __m512h __A)
-{
-  return (__m256i) __builtin_ia32_vcvtph2bf8512_mask ((__v32hf) __A,
-						      (__v32qi) (__m256i)
-						      _mm256_setzero_si256 (),
-						      (__mmask32) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvts_ph_bf8 (__m128h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2bf8s128_mask ((__v8hf) __A,
-						       (__v16qi)(__m128i)
-						       _mm_undefined_si128 (),
-						       (__mmask8) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvts_ph_bf8 (__m128i __W, __mmask8 __U, __m128h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2bf8s128_mask ((__v8hf) __A,
-						       (__v16qi)(__m128i) __W,
-						       (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvts_ph_bf8 (__mmask8 __U, __m128h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2bf8s128_mask ((__v8hf) __A,
-						       (__v16qi)(__m128i)
-						       _mm_setzero_si128 (),
-						       (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvts_ph_bf8 (__m256h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2bf8s256_mask ((__v16hf) __A,
-						       (__v16qi)(__m128i)
-						       _mm_undefined_si128 (),
-						       (__mmask16) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvts_ph_bf8 (__m128i __W, __mmask16 __U, __m256h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2bf8s256_mask ((__v16hf) __A,
-						       (__v16qi)(__m128i) __W,
-						       (__mmask16) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvts_ph_bf8 (__mmask16 __U, __m256h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2bf8s256_mask ((__v16hf) __A,
-						       (__v16qi)(__m128i)
-						       _mm_setzero_si128 (),
-						       (__mmask16) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvts_ph_bf8 (__m512h __A)
-{
-  return (__m256i) __builtin_ia32_vcvtph2bf8s512_mask ((__v32hf) __A,
-						       (__v32qi) (__m256i)
-						       _mm256_undefined_si256 (),
-						       (__mmask32) -1);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvts_ph_bf8 (__m256i __W, __mmask32 __U, __m512h __A)
-{
-  return (__m256i) __builtin_ia32_vcvtph2bf8s512_mask ((__v32hf) __A,
-						       (__v32qi) (__m256i) __W,
-						       (__mmask32) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvts_ph_bf8 (__mmask32 __U, __m512h __A)
-{
-  return (__m256i) __builtin_ia32_vcvtph2bf8s512_mask ((__v32hf) __A,
-						       (__v32qi) (__m256i)
-						       _mm256_setzero_si256 (),
-						       (__mmask32) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvtph_hf8 (__m128h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2hf8128_mask ((__v8hf) __A,
-						      (__v16qi)(__m128i)
-						      _mm_undefined_si128 (),
-						      (__mmask8) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvtph_hf8 (__m128i __W, __mmask8 __U, __m128h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2hf8128_mask ((__v8hf) __A,
-						      (__v16qi)(__m128i) __W,
-						      (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvtph_hf8 (__mmask8 __U, __m128h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2hf8128_mask ((__v8hf) __A,
-						      (__v16qi)(__m128i)
-						      _mm_setzero_si128 (),
-						      (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvtph_hf8 (__m256h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2hf8256_mask ((__v16hf) __A,
-						      (__v16qi)(__m128i)
-						      _mm_undefined_si128 (),
-						      (__mmask16) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvtph_hf8 (__m128i __W, __mmask16 __U, __m256h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2hf8256_mask ((__v16hf) __A,
-						      (__v16qi)(__m128i) __W,
-						      (__mmask16) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvtph_hf8 (__mmask16 __U, __m256h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2hf8256_mask ((__v16hf) __A,
-						      (__v16qi)(__m128i)
-						      _mm_setzero_si128 (),
-						      (__mmask16) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvtph_hf8 (__m512h __A)
-{
-  return (__m256i) __builtin_ia32_vcvtph2hf8512_mask ((__v32hf) __A,
-						      (__v32qi) (__m256i)
-						      _mm256_undefined_si256 (),
-						      (__mmask32) -1);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvtph_hf8 (__m256i __W, __mmask32 __U, __m512h __A)
-{
-  return (__m256i) __builtin_ia32_vcvtph2hf8512_mask ((__v32hf) __A,
-						      (__v32qi)(__m256i) __W,
-						      (__mmask32) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvtph_hf8 (__mmask32 __U, __m512h __A)
-{
-  return (__m256i) __builtin_ia32_vcvtph2hf8512_mask ((__v32hf) __A,
-						      (__v32qi) (__m256i)
-						      _mm256_setzero_si256 (),
-						      (__mmask32) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_cvts_ph_hf8 (__m128h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2hf8s128_mask ((__v8hf) __A,
-						       (__v16qi)(__m128i)
-						       _mm_undefined_si128 (),
-						       (__mmask8) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_cvts_ph_hf8 (__m128i __W, __mmask8 __U, __m128h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2hf8s128_mask ((__v8hf) __A,
-						       (__v16qi)(__m128i) __W,
-						       (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_cvts_ph_hf8 (__mmask8 __U, __m128h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2hf8s128_mask ((__v8hf) __A,
-						       (__v16qi)(__m128i)
-						       _mm_setzero_si128 (),
-						       (__mmask8) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_cvts_ph_hf8 (__m256h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2hf8s256_mask ((__v16hf) __A,
-						       (__v16qi)(__m128i)
-						       _mm_undefined_si128 (),
-						       (__mmask16) -1);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_cvts_ph_hf8 (__m128i __W, __mmask16 __U, __m256h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2hf8s256_mask ((__v16hf) __A,
-						       (__v16qi)(__m128i) __W,
-						       (__mmask16) __U);
-}
-
-extern __inline__ __m128i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_cvts_ph_hf8 (__mmask16 __U, __m256h __A)
-{
-  return (__m128i) __builtin_ia32_vcvtph2hf8s256_mask ((__v16hf) __A,
-						       (__v16qi)(__m128i)
-						       _mm_setzero_si128 (),
-						       (__mmask16) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_cvts_ph_hf8 (__m512h __A)
-{
-  return (__m256i) __builtin_ia32_vcvtph2hf8s512_mask ((__v32hf) __A,
-						       (__v32qi) (__m256i)
-						       _mm256_undefined_si256 (),
-						       (__mmask32) -1);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_cvts_ph_hf8 (__m256i __W, __mmask32 __U, __m512h __A)
-{
-  return (__m256i) __builtin_ia32_vcvtph2hf8s512_mask ((__v32hf) __A,
-						       (__v32qi) (__m256i) __W,
-						       (__mmask32) __U);
-}
-
-extern __inline__ __m256i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_cvts_ph_hf8 (__mmask32 __U, __m512h __A)
-{
-  return (__m256i) __builtin_ia32_vcvtph2hf8s512_mask ((__v32hf) __A,
-						       (__v32qi) (__m256i)
-						       _mm256_setzero_si256 (),
-						       (__mmask32) __U);
-}
-
 extern __inline __m128h
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm_cvtbf8_ph (__m128i __A)
diff --git a/gcc/config/i386/avx10v1auxintrin.h b/gcc/config/i386/avx10v1auxintrin.h
new file mode 100644
index 000000000000..9929e926ba07
--- /dev/null
+++ b/gcc/config/i386/avx10v1auxintrin.h
@@ -0,0 +1,1427 @@
+/* Copyright (C) 2026 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   .  */
+
+#if !defined _IMMINTRIN_H_INCLUDED
+#error "Never use  directly; include  instead."
+#endif
+
+#ifndef _AVX10V1AUXINTRIN_H_INCLUDED
+#define _AVX10V1AUXINTRIN_H_INCLUDED
+
+#if !defined(__AVX10V1AUX__)
+#pragma GCC push_options
+#pragma GCC target("avx10v1aux")
+#define __DISABLE_AVX10V1AUX__
+#endif /* __AVX10V1AUX__ */
+
+/* FP16 to FP8 converts(Single-source). */
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtph_bf8 (__m128h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2bf8128_mask ((__v8hf) __A,
+						      (__v16qi)(__m128i)
+						      _mm_undefined_si128 (),
+						      (__mmask8) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvtph_bf8 (__m128i __W, __mmask8 __U, __m128h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2bf8128_mask ((__v8hf) __A,
+						      (__v16qi)(__m128i) __W,
+						      (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvtph_bf8 (__mmask8 __U, __m128h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2bf8128_mask ((__v8hf) __A,
+						      (__v16qi)(__m128i)
+						      _mm_setzero_si128 (),
+						      (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvtph_bf8 (__m256h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2bf8256_mask ((__v16hf) __A,
+						      (__v16qi)(__m128i)
+						      _mm_undefined_si128 (),
+						      (__mmask16) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvtph_bf8 (__m128i __W, __mmask16 __U, __m256h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2bf8256_mask ((__v16hf) __A,
+						      (__v16qi)(__m128i) __W,
+						      (__mmask16) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvtph_bf8 (__mmask16 __U, __m256h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2bf8256_mask ((__v16hf) __A,
+						      (__v16qi)(__m128i)
+						      _mm_setzero_si128 (),
+						      (__mmask16) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvtph_bf8 (__m512h __A)
+{
+  return (__m256i) __builtin_ia32_vcvtph2bf8512_mask ((__v32hf) __A,
+						      (__v32qi) (__m256i)
+						      _mm256_undefined_si256 (),
+						      (__mmask32) -1);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvtph_bf8 (__m256i __W, __mmask32 __U, __m512h __A)
+{
+  return (__m256i) __builtin_ia32_vcvtph2bf8512_mask ((__v32hf) __A,
+						      (__v32qi) (__m256i) __W,
+						      (__mmask32) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvtph_bf8 (__mmask32 __U, __m512h __A)
+{
+  return (__m256i) __builtin_ia32_vcvtph2bf8512_mask ((__v32hf) __A,
+						      (__v32qi) (__m256i)
+						      _mm256_setzero_si256 (),
+						      (__mmask32) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvts_ph_bf8 (__m128h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2bf8s128_mask ((__v8hf) __A,
+						       (__v16qi)(__m128i)
+						       _mm_undefined_si128 (),
+						       (__mmask8) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvts_ph_bf8 (__m128i __W, __mmask8 __U, __m128h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2bf8s128_mask ((__v8hf) __A,
+						       (__v16qi)(__m128i) __W,
+						       (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvts_ph_bf8 (__mmask8 __U, __m128h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2bf8s128_mask ((__v8hf) __A,
+						       (__v16qi)(__m128i)
+						       _mm_setzero_si128 (),
+						       (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvts_ph_bf8 (__m256h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2bf8s256_mask ((__v16hf) __A,
+						       (__v16qi)(__m128i)
+						       _mm_undefined_si128 (),
+						       (__mmask16) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvts_ph_bf8 (__m128i __W, __mmask16 __U, __m256h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2bf8s256_mask ((__v16hf) __A,
+						       (__v16qi)(__m128i) __W,
+						       (__mmask16) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvts_ph_bf8 (__mmask16 __U, __m256h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2bf8s256_mask ((__v16hf) __A,
+						       (__v16qi)(__m128i)
+						       _mm_setzero_si128 (),
+						       (__mmask16) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvts_ph_bf8 (__m512h __A)
+{
+  return (__m256i) __builtin_ia32_vcvtph2bf8s512_mask ((__v32hf) __A,
+						       (__v32qi) (__m256i)
+						       _mm256_undefined_si256 (),
+						       (__mmask32) -1);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvts_ph_bf8 (__m256i __W, __mmask32 __U, __m512h __A)
+{
+  return (__m256i) __builtin_ia32_vcvtph2bf8s512_mask ((__v32hf) __A,
+						       (__v32qi) (__m256i) __W,
+						       (__mmask32) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvts_ph_bf8 (__mmask32 __U, __m512h __A)
+{
+  return (__m256i) __builtin_ia32_vcvtph2bf8s512_mask ((__v32hf) __A,
+						       (__v32qi) (__m256i)
+						       _mm256_setzero_si256 (),
+						       (__mmask32) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtph_hf8 (__m128h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2hf8128_mask ((__v8hf) __A,
+						      (__v16qi)(__m128i)
+						      _mm_undefined_si128 (),
+						      (__mmask8) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvtph_hf8 (__m128i __W, __mmask8 __U, __m128h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2hf8128_mask ((__v8hf) __A,
+						      (__v16qi)(__m128i) __W,
+						      (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvtph_hf8 (__mmask8 __U, __m128h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2hf8128_mask ((__v8hf) __A,
+						      (__v16qi)(__m128i)
+						      _mm_setzero_si128 (),
+						      (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvtph_hf8 (__m256h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2hf8256_mask ((__v16hf) __A,
+						      (__v16qi)(__m128i)
+						      _mm_undefined_si128 (),
+						      (__mmask16) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvtph_hf8 (__m128i __W, __mmask16 __U, __m256h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2hf8256_mask ((__v16hf) __A,
+						      (__v16qi)(__m128i) __W,
+						      (__mmask16) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvtph_hf8 (__mmask16 __U, __m256h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2hf8256_mask ((__v16hf) __A,
+						      (__v16qi)(__m128i)
+						      _mm_setzero_si128 (),
+						      (__mmask16) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvtph_hf8 (__m512h __A)
+{
+  return (__m256i) __builtin_ia32_vcvtph2hf8512_mask ((__v32hf) __A,
+						      (__v32qi) (__m256i)
+						      _mm256_undefined_si256 (),
+						      (__mmask32) -1);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvtph_hf8 (__m256i __W, __mmask32 __U, __m512h __A)
+{
+  return (__m256i) __builtin_ia32_vcvtph2hf8512_mask ((__v32hf) __A,
+						      (__v32qi)(__m256i) __W,
+						      (__mmask32) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvtph_hf8 (__mmask32 __U, __m512h __A)
+{
+  return (__m256i) __builtin_ia32_vcvtph2hf8512_mask ((__v32hf) __A,
+						      (__v32qi) (__m256i)
+						      _mm256_setzero_si256 (),
+						      (__mmask32) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvts_ph_hf8 (__m128h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2hf8s128_mask ((__v8hf) __A,
+						       (__v16qi)(__m128i)
+						       _mm_undefined_si128 (),
+						       (__mmask8) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvts_ph_hf8 (__m128i __W, __mmask8 __U, __m128h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2hf8s128_mask ((__v8hf) __A,
+						       (__v16qi)(__m128i) __W,
+						       (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvts_ph_hf8 (__mmask8 __U, __m128h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2hf8s128_mask ((__v8hf) __A,
+						       (__v16qi)(__m128i)
+						       _mm_setzero_si128 (),
+						       (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvts_ph_hf8 (__m256h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2hf8s256_mask ((__v16hf) __A,
+						       (__v16qi)(__m128i)
+						       _mm_undefined_si128 (),
+						       (__mmask16) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvts_ph_hf8 (__m128i __W, __mmask16 __U, __m256h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2hf8s256_mask ((__v16hf) __A,
+						       (__v16qi)(__m128i) __W,
+						       (__mmask16) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvts_ph_hf8 (__mmask16 __U, __m256h __A)
+{
+  return (__m128i) __builtin_ia32_vcvtph2hf8s256_mask ((__v16hf) __A,
+						       (__v16qi)(__m128i)
+						       _mm_setzero_si128 (),
+						       (__mmask16) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvts_ph_hf8 (__m512h __A)
+{
+  return (__m256i) __builtin_ia32_vcvtph2hf8s512_mask ((__v32hf) __A,
+						       (__v32qi) (__m256i)
+						       _mm256_undefined_si256 (),
+						       (__mmask32) -1);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvts_ph_hf8 (__m256i __W, __mmask32 __U, __m512h __A)
+{
+  return (__m256i) __builtin_ia32_vcvtph2hf8s512_mask ((__v32hf) __A,
+						       (__v32qi) (__m256i) __W,
+						       (__mmask32) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvts_ph_hf8 (__mmask32 __U, __m512h __A)
+{
+  return (__m256i) __builtin_ia32_vcvtph2hf8s512_mask ((__v32hf) __A,
+						       (__v32qi) (__m256i)
+						       _mm256_setzero_si256 (),
+						       (__mmask32) __U);
+}
+
+/* FP16 to FP8 converts(Two-source). */
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvt2ph_bf8 (__m128h __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvt2ph2bf8128_mask ((__v8hf) __A,
+						       (__v8hf) __B,
+						       (__v16qi)
+						       _mm_setzero_si128 (),
+						       (__mmask16) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvt2ph_bf8 (__m128i __W, __mmask16 __U,
+		     __m128h __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvt2ph2bf8128_mask ((__v8hf) __A,
+						       (__v8hf) __B,
+						       (__v16qi) __W,
+						       (__mmask16) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvt2ph_bf8 (__mmask16 __U, __m128h __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvt2ph2bf8128_mask ((__v8hf) __A,
+						       (__v8hf) __B,
+						       (__v16qi)
+						       _mm_setzero_si128 (),
+						       (__mmask16) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvt2ph_bf8 (__m256h __A, __m256h __B)
+{
+  return (__m256i) __builtin_ia32_vcvt2ph2bf8256_mask ((__v16hf) __A,
+						       (__v16hf) __B,
+						       (__v32qi)
+						       _mm256_setzero_si256 (),
+						       (__mmask32) -1);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvt2ph_bf8 (__m256i __W, __mmask32 __U,
+			__m256h __A, __m256h __B)
+{
+  return (__m256i) __builtin_ia32_vcvt2ph2bf8256_mask ((__v16hf) __A,
+						       (__v16hf) __B,
+						       (__v32qi) __W,
+						       (__mmask32) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvt2ph_bf8 (__mmask32 __U, __m256h __A, __m256h __B)
+{
+  return (__m256i) __builtin_ia32_vcvt2ph2bf8256_mask ((__v16hf) __A,
+						       (__v16hf) __B,
+						       (__v32qi)
+						       _mm256_setzero_si256 (),
+						       (__mmask32) __U);
+}
+
+extern __inline__ __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvt2ph_bf8 (__m512h __A, __m512h __B)
+{
+  return (__m512i) __builtin_ia32_vcvt2ph2bf8512_mask ((__v32hf) __A,
+						       (__v32hf) __B,
+						       (__v64qi)
+						       _mm512_setzero_si512 (),
+						       (__mmask64) -1);
+}
+
+extern __inline__ __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvt2ph_bf8 (__m512i __W, __mmask64 __U,
+			__m512h __A, __m512h __B)
+{
+  return (__m512i) __builtin_ia32_vcvt2ph2bf8512_mask ((__v32hf) __A,
+						       (__v32hf) __B,
+						       (__v64qi) __W,
+						       (__mmask64) __U);
+}
+
+extern __inline__ __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvt2ph_bf8 (__mmask64 __U,  __m512h __A, __m512h __B)
+{
+  return (__m512i) __builtin_ia32_vcvt2ph2bf8512_mask ((__v32hf) __A,
+						       (__v32hf) __B,
+						       (__v64qi)
+						       _mm512_setzero_si512 (),
+						       (__mmask64) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvts_2ph_bf8 (__m128h __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvt2ph2bf8s128_mask ((__v8hf) __A,
+							(__v8hf) __B,
+							(__v16qi)
+							_mm_setzero_si128 (),
+							(__mmask16) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvts_2ph_bf8 (__m128i __W, __mmask16 __U,
+		       __m128h __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvt2ph2bf8s128_mask ((__v8hf) __A,
+							(__v8hf) __B,
+							(__v16qi) __W,
+							(__mmask16) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvts_2ph_bf8 (__mmask16 __U, __m128h __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvt2ph2bf8s128_mask ((__v8hf) __A,
+							(__v8hf) __B,
+							(__v16qi)
+							_mm_setzero_si128 (),
+							(__mmask16) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvts_2ph_bf8 (__m256h __A, __m256h __B)
+{
+  return (__m256i) __builtin_ia32_vcvt2ph2bf8s256_mask ((__v16hf) __A,
+							(__v16hf) __B,
+							(__v32qi)
+							_mm256_setzero_si256 (),
+							(__mmask32) -1);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvts_2ph_bf8 (__m256i __W, __mmask32 __U,
+			  __m256h __A, __m256h __B)
+{
+  return (__m256i) __builtin_ia32_vcvt2ph2bf8s256_mask ((__v16hf) __A,
+							(__v16hf) __B,
+							(__v32qi) __W,
+							(__mmask32) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvts_2ph_bf8 (__mmask32 __U, __m256h __A, __m256h __B)
+{
+  return (__m256i) __builtin_ia32_vcvt2ph2bf8s256_mask ((__v16hf) __A,
+							(__v16hf) __B,
+							(__v32qi)
+							_mm256_setzero_si256 (),
+							(__mmask32) __U);
+}
+
+extern __inline__ __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvts_2ph_bf8 (__m512h __A, __m512h __B)
+{
+  return (__m512i) __builtin_ia32_vcvt2ph2bf8s512_mask ((__v32hf) __A,
+							(__v32hf) __B,
+							(__v64qi)
+							_mm512_setzero_si512 (),
+							(__mmask64) -1);
+}
+
+extern __inline__ __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvts_2ph_bf8 (__m512i __W, __mmask64 __U,
+			  __m512h __A, __m512h __B)
+{
+  return (__m512i) __builtin_ia32_vcvt2ph2bf8s512_mask ((__v32hf) __A,
+							(__v32hf) __B,
+							(__v64qi) __W,
+							(__mmask64) __U);
+}
+
+extern __inline__ __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvts_2ph_bf8 (__mmask64 __U, __m512h __A, __m512h __B)
+{
+  return (__m512i) __builtin_ia32_vcvt2ph2bf8s512_mask ((__v32hf) __A,
+							(__v32hf) __B,
+							(__v64qi)
+							_mm512_setzero_si512 (),
+							(__mmask64) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvt2ph_hf8 (__m128h __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvt2ph2hf8128_mask ((__v8hf) __A,
+						       (__v8hf) __B,
+						       (__v16qi)
+						       _mm_setzero_si128 (),
+						       (__mmask16) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvt2ph_hf8 (__m128i __W, __mmask16 __U,
+		     __m128h __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvt2ph2hf8128_mask ((__v8hf) __A,
+						       (__v8hf) __B,
+						       (__v16qi) __W,
+						       (__mmask16) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvt2ph_hf8 (__mmask16 __U, __m128h __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvt2ph2hf8128_mask ((__v8hf) __A,
+						       (__v8hf) __B,
+						       (__v16qi)
+						       _mm_setzero_si128 (),
+						       (__mmask16) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvt2ph_hf8 (__m256h __A, __m256h __B)
+{
+  return (__m256i) __builtin_ia32_vcvt2ph2hf8256_mask ((__v16hf) __A,
+						       (__v16hf) __B,
+						       (__v32qi)
+						       _mm256_setzero_si256 (),
+						       (__mmask32) -1);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvt2ph_hf8 (__m256i __W, __mmask32 __U,
+			__m256h __A, __m256h __B)
+{
+  return (__m256i) __builtin_ia32_vcvt2ph2hf8256_mask ((__v16hf) __A,
+						       (__v16hf) __B,
+						       (__v32qi) __W,
+						       (__mmask32) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvt2ph_hf8 (__mmask32 __U, __m256h __A, __m256h __B)
+{
+  return (__m256i) __builtin_ia32_vcvt2ph2hf8256_mask ((__v16hf) __A,
+						       (__v16hf) __B,
+						       (__v32qi)
+						       _mm256_setzero_si256 (),
+						       (__mmask32) __U);
+}
+
+extern __inline__ __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvt2ph_hf8 (__m512h __A, __m512h __B)
+{
+  return (__m512i) __builtin_ia32_vcvt2ph2hf8512_mask ((__v32hf) __A,
+						       (__v32hf) __B,
+						       (__v64qi)
+						       _mm512_setzero_si512 (),
+						       (__mmask64) -1);
+}
+
+extern __inline__ __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvt2ph_hf8 (__m512i __W, __mmask64 __U,
+			__m512h __A, __m512h __B)
+{
+  return (__m512i) __builtin_ia32_vcvt2ph2hf8512_mask ((__v32hf) __A,
+						       (__v32hf) __B,
+						       (__v64qi) __W,
+						       (__mmask64) __U);
+}
+
+extern __inline__ __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvt2ph_hf8 (__mmask64 __U, __m512h __A, __m512h __B)
+{
+  return (__m512i) __builtin_ia32_vcvt2ph2hf8512_mask ((__v32hf) __A,
+						       (__v32hf) __B,
+						       (__v64qi)
+						       _mm512_setzero_si512 (),
+						       (__mmask64) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvts_2ph_hf8 (__m128h __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvt2ph2hf8s128_mask ((__v8hf) __A,
+							(__v8hf) __B,
+							(__v16qi)
+							_mm_setzero_si128 (),
+							(__mmask16) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvts_2ph_hf8 (__m128i __W, __mmask16 __U,
+		       __m128h __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvt2ph2hf8s128_mask ((__v8hf) __A,
+							(__v8hf) __B,
+							(__v16qi) __W,
+							(__mmask16) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvts_2ph_hf8 (__mmask16 __U, __m128h __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvt2ph2hf8s128_mask ((__v8hf) __A,
+							(__v8hf) __B,
+							(__v16qi)
+							_mm_setzero_si128 (),
+							(__mmask16) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvts_2ph_hf8 (__m256h __A, __m256h __B)
+{
+  return (__m256i) __builtin_ia32_vcvt2ph2hf8s256_mask ((__v16hf) __A,
+							(__v16hf) __B,
+							(__v32qi)
+							_mm256_setzero_si256 (),
+							(__mmask32) -1);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvts_2ph_hf8 (__m256i __W, __mmask32 __U,
+			  __m256h __A, __m256h __B)
+{
+  return (__m256i) __builtin_ia32_vcvt2ph2hf8s256_mask ((__v16hf) __A,
+							(__v16hf) __B,
+							(__v32qi) __W,
+							(__mmask32) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvts_2ph_hf8 (__mmask32 __U, __m256h __A, __m256h __B)
+{
+  return (__m256i) __builtin_ia32_vcvt2ph2hf8s256_mask ((__v16hf) __A,
+							(__v16hf) __B,
+							(__v32qi)
+							_mm256_setzero_si256 (),
+							(__mmask32) __U);
+}
+
+extern __inline__ __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvts_2ph_hf8 (__m512h __A, __m512h __B)
+{
+  return (__m512i) __builtin_ia32_vcvt2ph2hf8s512_mask ((__v32hf) __A,
+							(__v32hf) __B,
+							(__v64qi)
+							_mm512_setzero_si512 (),
+							(__mmask64) -1);
+}
+
+extern __inline__ __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvts_2ph_hf8 (__m512i __W, __mmask64 __U,
+			  __m512h __A, __m512h __B)
+{
+  return (__m512i) __builtin_ia32_vcvt2ph2hf8s512_mask ((__v32hf) __A,
+							(__v32hf) __B,
+							(__v64qi) __W,
+							(__mmask64) __U);
+}
+
+extern __inline__ __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvts_2ph_hf8 (__mmask64 __U, __m512h __A, __m512h __B)
+{
+  return (__m512i) __builtin_ia32_vcvt2ph2hf8s512_mask ((__v32hf) __A,
+							(__v32hf) __B,
+							(__v64qi)
+							_mm512_setzero_si512 (),
+							(__mmask64) __U);
+}
+
+/* FP16 to FP8 Converts (Biased) */
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtbiasph_bf8 (__m128i __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2bf8128 ((__v16qi) __A,
+						     (__v8hf) __B);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvtbiasph_bf8 (__m128i __W, __mmask8 __U, __m128i __A,
+			__m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2bf8128_mask ((__v16qi) __A,
+							  (__v8hf) __B,
+							  (__v16qi)(__m128i) __W,
+							  (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvtbiasph_bf8 (__mmask8 __U, __m128i __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2bf8128_mask ((__v16qi) __A,
+							  (__v8hf) __B,
+							  (__v16qi)(__m128i)
+							   _mm_setzero_si128 (),
+							  (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvtbiasph_bf8 (__m256i __A, __m256h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2bf8256_mask ((__v32qi) __A,
+							  (__v16hf) __B,
+							  (__v16qi)(__m128i)
+							  _mm_undefined_si128 (),
+							  (__mmask16) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvtbiasph_bf8 (__m128i __W, __mmask16 __U, __m256i __A,
+			   __m256h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2bf8256_mask ((__v32qi) __A,
+							  (__v16hf) __B,
+							  (__v16qi)(__m128i) __W,
+							  (__mmask16) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvtbiasph_bf8 (__mmask16 __U, __m256i __A, __m256h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2bf8256_mask ((__v32qi) __A,
+							  (__v16hf) __B,
+							  (__v16qi)(__m128i)
+							   _mm_setzero_si128 (),
+							  (__mmask16) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvtbiasph_bf8 (__m512i __A, __m512h __B)
+{
+  return (__m256i) __builtin_ia32_vcvtbiasph2bf8512_mask ((__v64qi) __A,
+							  (__v32hf) __B,
+							  (__v32qi)(__m256i)
+							  _mm256_undefined_si256 (),
+							  (__mmask32) -1);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvtbiasph_bf8 (__m256i __W, __mmask32 __U,
+			   __m512i __A, __m512h __B)
+{
+  return (__m256i) __builtin_ia32_vcvtbiasph2bf8512_mask ((__v64qi) __A,
+							  (__v32hf) __B,
+							  (__v32qi)(__m256i) __W,
+							  (__mmask32) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvtbiasph_bf8 (__mmask32 __U, __m512i __A, __m512h __B)
+{
+  return (__m256i) __builtin_ia32_vcvtbiasph2bf8512_mask ((__v64qi) __A,
+							  (__v32hf) __B,
+							  (__v32qi)(__m256i)
+							  _mm256_setzero_si256 (),
+							  (__mmask32) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvts_biasph_bf8 (__m128i __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2bf8s128 ((__v16qi) __A,
+						      (__v8hf) __B);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvts_biasph_bf8 (__m128i __W, __mmask8 __U,
+			  __m128i __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2bf8s128_mask ((__v16qi) __A,
+							   (__v8hf) __B,
+							   (__v16qi)(__m128i) __W,
+							   (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvts_biasph_bf8 (__mmask8 __U, __m128i __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2bf8s128_mask ((__v16qi) __A,
+							   (__v8hf) __B,
+							   (__v16qi)(__m128i)
+							   _mm_setzero_si128 (),
+							   (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvts_biasph_bf8 (__m256i __A, __m256h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2bf8s256_mask ((__v32qi) __A,
+							   (__v16hf) __B,
+							   (__v16qi)(__m128i)
+							   _mm_undefined_si128 (),
+							   (__mmask16) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvts_biasph_bf8 (__m128i __W, __mmask16 __U,
+			     __m256i __A, __m256h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2bf8s256_mask ((__v32qi) __A,
+							   (__v16hf) __B,
+							   (__v16qi)(__m128i) __W,
+							   (__mmask16) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvts_biasph_bf8 (__mmask16 __U, __m256i __A, __m256h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2bf8s256_mask ((__v32qi) __A,
+							   (__v16hf) __B,
+							   (__v16qi)(__m128i)
+							   _mm_setzero_si128 (),
+							   (__mmask16) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvts_biasph_bf8 (__m512i __A, __m512h __B)
+{
+  return (__m256i) __builtin_ia32_vcvtbiasph2bf8s512_mask ((__v64qi) __A,
+							   (__v32hf) __B,
+							   (__v32qi)(__m256i)
+							   _mm256_undefined_si256 (),
+							   (__mmask32) -1);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvts_biasph_bf8 (__m256i __W, __mmask32 __U,
+			     __m512i __A, __m512h __B)
+{
+  return (__m256i) __builtin_ia32_vcvtbiasph2bf8s512_mask ((__v64qi) __A,
+							   (__v32hf) __B,
+							   (__v32qi)(__m256i) __W,
+							   (__mmask32) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvts_biasph_bf8 (__mmask32 __U, __m512i __A, __m512h __B)
+{
+  return (__m256i) __builtin_ia32_vcvtbiasph2bf8s512_mask ((__v64qi) __A,
+							   (__v32hf) __B,
+							   (__v32qi)(__m256i)
+							   _mm256_setzero_si256 (),
+							   (__mmask32) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtbiasph_hf8 (__m128i __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2hf8128 ((__v16qi) __A,
+						     (__v8hf) __B);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvtbiasph_hf8 (__m128i __W, __mmask8 __U, __m128i __A,
+			__m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2hf8128_mask ((__v16qi) __A,
+							  (__v8hf) __B,
+							  (__v16qi)(__m128i) __W,
+							  (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvtbiasph_hf8 (__mmask8 __U, __m128i __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2hf8128_mask ((__v16qi) __A,
+							  (__v8hf) __B,
+							  (__v16qi)(__m128i)
+							  _mm_setzero_si128 (),
+							  (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvtbiasph_hf8 (__m256i __A, __m256h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2hf8256_mask ((__v32qi) __A,
+							  (__v16hf) __B,
+							  (__v16qi)(__m128i)
+							  _mm_undefined_si128 (),
+							  (__mmask16) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvtbiasph_hf8 (__m128i __W, __mmask16 __U,
+			   __m256i __A, __m256h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2hf8256_mask ((__v32qi) __A,
+							  (__v16hf) __B,
+							  (__v16qi)(__m128i) __W,
+							  (__mmask16) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvtbiasph_hf8 (__mmask16 __U, __m256i __A, __m256h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2hf8256_mask ((__v32qi) __A,
+							  (__v16hf) __B,
+							  (__v16qi)(__m128i)
+							  _mm_setzero_si128 (),
+							  (__mmask16) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvtbiasph_hf8 (__m512i __A, __m512h __B)
+{
+  return (__m256i) __builtin_ia32_vcvtbiasph2hf8512_mask ((__v64qi) __A,
+							  (__v32hf) __B,
+							  (__v32qi)(__m256i)
+					 		  _mm256_undefined_si256 (),
+							  (__mmask32) -1);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvtbiasph_hf8 (__m256i __W, __mmask32 __U, __m512i __A,
+			   __m512h __B)
+{
+  return (__m256i) __builtin_ia32_vcvtbiasph2hf8512_mask ((__v64qi) __A,
+							  (__v32hf) __B,
+							  (__v32qi)(__m256i) __W,
+							  (__mmask32) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvtbiasph_hf8 (__mmask32 __U, __m512i __A, __m512h __B)
+{
+  return (__m256i) __builtin_ia32_vcvtbiasph2hf8512_mask ((__v64qi) __A,
+							  (__v32hf) __B,
+							  (__v32qi)(__m256i)
+							  _mm256_setzero_si256 (),
+							  (__mmask32) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvts_biasph_hf8 (__m128i __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2hf8s128 ((__v16qi) __A,
+						      (__v8hf) __B);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvts_biasph_hf8 (__m128i __W, __mmask8 __U,
+			  __m128i __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2hf8s128_mask ((__v16qi) __A,
+							   (__v8hf) __B,
+							   (__v16qi)(__m128i) __W,
+							   (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvts_biasph_hf8 (__mmask8 __U, __m128i __A, __m128h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2hf8s128_mask ((__v16qi) __A,
+							   (__v8hf) __B,
+							   (__v16qi)(__m128i)
+							   _mm_setzero_si128 (),
+							   (__mmask8) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvts_biasph_hf8 (__m256i __A, __m256h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2hf8s256_mask ((__v32qi) __A,
+							   (__v16hf) __B,
+							   (__v16qi)(__m128i)
+							   _mm_undefined_si128 (),
+							   (__mmask16) -1);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvts_biasph_hf8 (__m128i __W, __mmask16 __U,
+			     __m256i __A, __m256h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2hf8s256_mask ((__v32qi) __A,
+							   (__v16hf) __B,
+							   (__v16qi)(__m128i) __W,
+							   (__mmask16) __U);
+}
+
+extern __inline__ __m128i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvts_biasph_hf8 (__mmask16 __U, __m256i __A, __m256h __B)
+{
+  return (__m128i) __builtin_ia32_vcvtbiasph2hf8s256_mask ((__v32qi) __A,
+							   (__v16hf) __B,
+							   (__v16qi)(__m128i)
+							   _mm_setzero_si128 (),
+							   (__mmask16) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvts_biasph_hf8 (__m512i __A, __m512h __B)
+{
+  return (__m256i) __builtin_ia32_vcvtbiasph2hf8s512_mask ((__v64qi) __A,
+							   (__v32hf) __B,
+							   (__v32qi)(__m256i)
+							   _mm256_undefined_si256 (),
+							   (__mmask32) -1);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvts_biasph_hf8 (__m256i __W, __mmask32 __U,
+			     __m512i __A, __m512h __B)
+{
+  return (__m256i) __builtin_ia32_vcvtbiasph2hf8s512_mask ((__v64qi) __A,
+							   (__v32hf) __B,
+							   (__v32qi)(__m256i) __W,
+							   (__mmask32) __U);
+}
+
+extern __inline__ __m256i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvts_biasph_hf8 (__mmask32 __U, __m512i __A, __m512h __B)
+{
+  return (__m256i) __builtin_ia32_vcvtbiasph2hf8s512_mask ((__v64qi) __A,
+							   (__v32hf) __B,
+							   (__v32qi)(__m256i)
+							   _mm256_setzero_si256 (),
+							   (__mmask32) __U);
+}
+
+/* FP8 to FP16 Converts */
+
+extern __inline__ __m128h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvthf8_ph (__m128i __A)
+{
+  return (__m128h) __builtin_ia32_vcvthf82ph128_mask ((__v16qi) __A,
+						      (__v8hf)(__m128h)
+						      _mm_undefined_ph (),
+						      (__mmask8) -1);
+}
+
+extern __inline__ __m128h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvthf8_ph (__m128h __W, __mmask8 __U, __m128i __A)
+{
+  return (__m128h) __builtin_ia32_vcvthf82ph128_mask ((__v16qi) __A,
+						      (__v8hf)(__m128h) __W,
+						      (__mmask8) __U);
+}
+
+extern __inline__ __m128h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvthf8_ph (__mmask8 __U, __m128i __A)
+{
+  return (__m128h) __builtin_ia32_vcvthf82ph128_mask ((__v16qi) __A,
+						      (__v8hf)(__m128h)
+						      _mm_setzero_ph (),
+						      (__mmask8) __U);
+}
+
+extern __inline__ __m256h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvthf8_ph (__m128i __A)
+{
+  return (__m256h) __builtin_ia32_vcvthf82ph256_mask ((__v16qi) __A,
+						      (__v16hf)(__m256h)
+						      _mm256_undefined_ph (),
+						      (__mmask16) -1);
+}
+
+extern __inline__ __m256h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvthf8_ph (__m256h __W, __mmask16 __U, __m128i __A)
+{
+  return (__m256h) __builtin_ia32_vcvthf82ph256_mask ((__v16qi) __A,
+						      (__v16hf)(__m256h) __W,
+						      (__mmask16) __U);
+}
+
+extern __inline__ __m256h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvthf8_ph (__mmask16 __U, __m128i __A)
+{
+  return (__m256h) __builtin_ia32_vcvthf82ph256_mask ((__v16qi) __A,
+						      (__v16hf)(__m256h)
+						      _mm256_setzero_ph (),
+						      (__mmask16) __U);
+}
+
+extern __inline__ __m512h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvthf8_ph (__m256i __A)
+{
+  return (__m512h) __builtin_ia32_vcvthf82ph512_mask ((__v32qi) __A,
+						      (__v32hf) (__m512h)
+						      _mm512_undefined_ph (),
+						      (__mmask32) -1);
+}
+
+extern __inline__ __m512h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvthf8_ph (__m512h __W, __mmask32 __U, __m256i __A)
+{
+  return (__m512h) __builtin_ia32_vcvthf82ph512_mask ((__v32qi) __A,
+						      (__v32hf) (__m512h) __W,
+						      (__mmask32) __U);
+}
+
+extern __inline__ __m512h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvthf8_ph (__mmask32 __U, __m256i __A)
+{
+  return (__m512h) __builtin_ia32_vcvthf82ph512_mask ((__v32qi) __A,
+						      (__v32hf) (__m512h)
+						      _mm512_setzero_ph (),
+						      (__mmask32) __U);
+}
+
+/* FP32-Pair to FP16 Converts */
+extern __inline __m128h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtx2ps_ph (__m128 __A, __m128 __B)
+{
+  return (__m128h) __builtin_ia32_vcvt2ps2phx128_mask ((__v4sf) __A,
+						       (__v4sf) __B,
+						       (__v8hf)
+						       _mm_setzero_ph (),
+						       (__mmask8) -1);
+}
+
+extern __inline __m128h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_cvtx2ps_ph (__m128h __W, __mmask8 __U, __m128 __A, __m128 __B)
+{
+  return (__m128h) __builtin_ia32_vcvt2ps2phx128_mask ((__v4sf) __A,
+						       (__v4sf) __B,
+						       (__v8hf) __W,
+						       (__mmask8) __U);
+}
+
+extern __inline __m128h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_cvtx2ps_ph (__mmask8 __U, __m128 __A, __m128 __B)
+{
+  return (__m128h) __builtin_ia32_vcvt2ps2phx128_mask ((__v4sf) __A,
+						       (__v4sf) __B,
+						       (__v8hf)
+						       _mm_setzero_ph (),
+						       (__mmask8) __U);
+}
+
+extern __inline __m256h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cvtx2ps_ph (__m256 __A, __m256 __B)
+{
+  return (__m256h) __builtin_ia32_vcvt2ps2phx256_mask ((__v8sf) __A,
+						       (__v8sf) __B,
+						       (__v16hf)
+						       _mm256_setzero_ph (),
+						       (__mmask16) -1);
+}
+
+extern __inline __m256h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cvtx2ps_ph (__m256h __W, __mmask16 __U, __m256 __A, __m256 __B)
+{
+  return (__m256h) __builtin_ia32_vcvt2ps2phx256_mask ((__v8sf) __A,
+						       (__v8sf) __B,
+						       (__v16hf) __W,
+						       (__mmask16) __U);
+}
+
+extern __inline __m256h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_cvtx2ps_ph ( __mmask16 __U, __m256 __A, __m256 __B)
+{
+  return (__m256h) __builtin_ia32_vcvt2ps2phx256_mask ((__v8sf) __A,
+						       (__v8sf) __B,
+						       (__v16hf)
+						       _mm256_setzero_ph (),
+						       (__mmask16) __U);
+}
+
+extern __inline __m512h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvtx2ps_ph (__m512 __A, __m512 __B)
+{
+  return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) __A,
+							     (__v16sf) __B,
+							     (__v32hf)
+							     _mm512_setzero_ph (),
+							     (__mmask32) -1,
+							     _MM_FROUND_CUR_DIRECTION);
+}
+
+extern __inline __m512h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvtx2ps_ph (__m512h __W, __mmask32 __U, __m512 __A,
+			__m512 __B)
+{
+  return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) __A,
+							     (__v16sf) __B,
+							     (__v32hf) __W,
+							     (__mmask32) __U,
+							     _MM_FROUND_CUR_DIRECTION);
+}
+
+extern __inline __m512h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvtx2ps_ph (__mmask32 __U, __m512 __A, __m512 __B)
+{
+  return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) __A,
+							     (__v16sf) __B,
+							     (__v32hf)
+							     _mm512_setzero_ph (),
+							     (__mmask32) __U,
+							     _MM_FROUND_CUR_DIRECTION);
+}
+
+#ifdef __OPTIMIZE__
+extern __inline __m512h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_cvtx_round2ps_ph (__m512 __A, __m512 __B, const int __R)
+{
+  return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) __A,
+							    (__v16sf) __B,
+							    (__v32hf)
+							    _mm512_setzero_ph (),
+							    (__mmask32) -1,
+							    __R);
+}
+
+extern __inline __m512h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_cvtx_round2ps_ph (__m512h __W, __mmask32 __U, __m512 __A,
+			      __m512 __B, const int __R)
+{
+  return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) __A,
+							    (__v16sf) __B,
+							    (__v32hf) __W,
+							    (__mmask32) __U,
+							    __R);
+}
+
+extern __inline __m512h
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_cvtx_round2ps_ph (__mmask32 __U, __m512 __A,
+			      __m512 __B, const int __R)
+{
+  return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) __A,
+							    (__v16sf) __B,
+							    (__v32hf)
+							    _mm512_setzero_ph (),
+							    (__mmask32) __U,
+							    __R);
+}
+
+#else
+#define _mm512_cvtx_round2ps_ph(A, B, R) \
+  ((__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) (A), \
+						       (__v16sf) (B), \
+						       (__v32hf) \
+						       (_mm512_setzero_ph ()), \
+						       (__mmask32) (-1), \
+						       (R)))
+#define _mm512_mask_cvtx_round2ps_ph(W, U, A, B, R) \
+  ((__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) (A), \
+						       (__v16sf) (B), \
+						       (__v32hf) (W), \
+						       (__mmask32) (U), \
+						       (R)))
+#define _mm512_maskz_cvtx_round2ps_ph(U, A, B, R) \
+  ((__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) (A), \
+						       (__v16sf) (B), \
+						       (__v32hf) \
+						       (_mm512_setzero_ph ()), \
+						       (__mmask32) (U), \
+						       (R)))
+#endif  /* __OPTIMIZE__  */
+
+#ifdef __DISABLE_AVX10V1AUX__
+#undef __DISABLE_AVX10V1AUX__
+#pragma GCC pop_options
+#endif /* __DISABLE_AVX10V1AUX__ */
+
+#endif /* __AVX10V1AUXINTRIN_H_INCLUDED */
diff --git a/gcc/config/i386/i386-builtin.def b/gcc/config/i386/i386-builtin.def
index e2b7714d4c3e..fc8475b3e6a7 100644
--- a/gcc/config/i386/i386-builtin.def
+++ b/gcc/config/i386/i386-builtin.def
@@ -3148,51 +3148,51 @@ BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_avx10_2_mpsadbw, "__builtin_ia32_mp
 BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_avx10_2_mpsadbw_mask, "__builtin_ia32_mpsadbw512_mask", IX86_BUILTIN_VMPSADBW_V32HI_MASK, UNKNOWN, (int) V32HI_FTYPE_V64QI_V64QI_INT_V32HI_USI)
 BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_avx2_mpsadbw_mask, "__builtin_ia32_mpsadbw256_mask", IX86_BUILTIN_VMPSADBW_V16HI_MASK, UNKNOWN, (int) V16HI_FTYPE_V32QI_V32QI_INT_V16HI_UHI)
 BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_sse4_1_mpsadbw_mask, "__builtin_ia32_mpsadbw128_mask", IX86_BUILTIN_VMPSADBW_V8HI_MASK, UNKNOWN, (int) V8HI_FTYPE_V16QI_V16QI_INT_V8HI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_avx10_2_cvt2ps2phx_v16hf_mask, "__builtin_ia32_vcvt2ps2phx256_mask", IX86_BUILTIN_VCVT2PS2PHX_V16HF_MASK, UNKNOWN, (int) V16HF_FTYPE_V8SF_V8SF_V16HF_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_avx10_2_cvt2ps2phx_v8hf_mask, "__builtin_ia32_vcvt2ps2phx128_mask", IX86_BUILTIN_VCVT2PS2PHX_V8HF_MASK, UNKNOWN, (int) V8HF_FTYPE_V4SF_V4SF_V8HF_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2bf8v8hf, "__builtin_ia32_vcvtbiasph2bf8128", IX86_BUILTIN_VCVTBIASPH2BF8128, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2bf8v8hf_mask, "__builtin_ia32_vcvtbiasph2bf8128_mask", IX86_BUILTIN_VCVTBIASPH2BF8128_MASK, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2bf8v16hf_mask, "__builtin_ia32_vcvtbiasph2bf8256_mask", IX86_BUILTIN_VCVTBIASPH2BF8256_MASK, UNKNOWN, (int) V16QI_FTYPE_V32QI_V16HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2bf8v32hf_mask, "__builtin_ia32_vcvtbiasph2bf8512_mask", IX86_BUILTIN_VCVTBIASPH2BF8512_MASK, UNKNOWN, (int) V32QI_FTYPE_V64QI_V32HF_V32QI_USI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2bf8sv8hf, "__builtin_ia32_vcvtbiasph2bf8s128", IX86_BUILTIN_VCVTBIASPH2BF8S128, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2bf8sv8hf_mask, "__builtin_ia32_vcvtbiasph2bf8s128_mask", IX86_BUILTIN_VCVTBIASPH2BF8S128_MASK, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2bf8sv16hf_mask, "__builtin_ia32_vcvtbiasph2bf8s256_mask", IX86_BUILTIN_VCVTBIASPH2BF8S256_MASK, UNKNOWN, (int) V16QI_FTYPE_V32QI_V16HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2bf8sv32hf_mask, "__builtin_ia32_vcvtbiasph2bf8s512_mask", IX86_BUILTIN_VCVTBIASPH2BF8S512_MASK, UNKNOWN, (int) V32QI_FTYPE_V64QI_V32HF_V32QI_USI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2hf8v8hf, "__builtin_ia32_vcvtbiasph2hf8128", IX86_BUILTIN_VCVTBIASPH2HF8128, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2hf8v8hf_mask, "__builtin_ia32_vcvtbiasph2hf8128_mask", IX86_BUILTIN_VCVTBIASPH2HF8128_MASK, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2hf8v16hf_mask, "__builtin_ia32_vcvtbiasph2hf8256_mask", IX86_BUILTIN_VCVTBIASPH2HF8256_MASK, UNKNOWN, (int) V16QI_FTYPE_V32QI_V16HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2hf8v32hf_mask, "__builtin_ia32_vcvtbiasph2hf8512_mask", IX86_BUILTIN_VCVTBIASPH2HF8512_MASK, UNKNOWN, (int) V32QI_FTYPE_V64QI_V32HF_V32QI_USI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2hf8sv8hf, "__builtin_ia32_vcvtbiasph2hf8s128", IX86_BUILTIN_VCVTBIASPH2HF8S128, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2hf8sv8hf_mask, "__builtin_ia32_vcvtbiasph2hf8s128_mask", IX86_BUILTIN_VCVTBIASPH2HF8S128_MASK, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2hf8sv16hf_mask, "__builtin_ia32_vcvtbiasph2hf8s256_mask", IX86_BUILTIN_VCVTBIASPH2HF8S256_MASK, UNKNOWN, (int) V16QI_FTYPE_V32QI_V16HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2hf8sv32hf_mask, "__builtin_ia32_vcvtbiasph2hf8s512_mask", IX86_BUILTIN_VCVTBIASPH2HF8S512_MASK, UNKNOWN, (int) V32QI_FTYPE_V64QI_V32HF_V32QI_USI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvt2ph2bf8v8hf_mask, "__builtin_ia32_vcvt2ph2bf8128_mask", IX86_BUILTIN_VCVT2PH2BF8128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V8HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvt2ph2bf8v16hf_mask, "__builtin_ia32_vcvt2ph2bf8256_mask", IX86_BUILTIN_VCVT2PH2BF8256_MASK, UNKNOWN, (int) V32QI_FTYPE_V16HF_V16HF_V32QI_USI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvt2ph2bf8v32hf_mask, "__builtin_ia32_vcvt2ph2bf8512_mask", IX86_BUILTIN_VCVT2PH2BF8512_MASK, UNKNOWN, (int) V64QI_FTYPE_V32HF_V32HF_V64QI_UDI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvt2ph2bf8sv8hf_mask, "__builtin_ia32_vcvt2ph2bf8s128_mask", IX86_BUILTIN_VCVT2PH2BF8S128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V8HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvt2ph2bf8sv16hf_mask, "__builtin_ia32_vcvt2ph2bf8s256_mask", IX86_BUILTIN_VCVT2PH2BF8S256_MASK, UNKNOWN, (int) V32QI_FTYPE_V16HF_V16HF_V32QI_USI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvt2ph2bf8sv32hf_mask, "__builtin_ia32_vcvt2ph2bf8s512_mask", IX86_BUILTIN_VCVT2PH2BF8S512_MASK, UNKNOWN, (int) V64QI_FTYPE_V32HF_V32HF_V64QI_UDI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvt2ph2hf8v8hf_mask, "__builtin_ia32_vcvt2ph2hf8128_mask", IX86_BUILTIN_VCVT2PH2HF8128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V8HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvt2ph2hf8v16hf_mask, "__builtin_ia32_vcvt2ph2hf8256_mask", IX86_BUILTIN_VCVT2PH2HF8256_MASK, UNKNOWN, (int) V32QI_FTYPE_V16HF_V16HF_V32QI_USI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvt2ph2hf8v32hf_mask, "__builtin_ia32_vcvt2ph2hf8512_mask", IX86_BUILTIN_VCVT2PH2HF8512_MASK, UNKNOWN, (int) V64QI_FTYPE_V32HF_V32HF_V64QI_UDI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvt2ph2hf8sv8hf_mask, "__builtin_ia32_vcvt2ph2hf8s128_mask", IX86_BUILTIN_VCVT2PH2HF8S128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V8HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvt2ph2hf8sv16hf_mask, "__builtin_ia32_vcvt2ph2hf8s256_mask", IX86_BUILTIN_VCVT2PH2HF8S256_MASK, UNKNOWN, (int) V32QI_FTYPE_V16HF_V16HF_V32QI_USI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvt2ph2hf8sv32hf_mask, "__builtin_ia32_vcvt2ph2hf8s512_mask", IX86_BUILTIN_VCVT2PH2HF8S512_MASK, UNKNOWN, (int) V64QI_FTYPE_V32HF_V32HF_V64QI_UDI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtph2bf8v8hf_mask, "__builtin_ia32_vcvtph2bf8128_mask", IX86_BUILTIN_VCVTPH2BF8128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V16QI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtph2bf8v16hf_mask, "__builtin_ia32_vcvtph2bf8256_mask", IX86_BUILTIN_VCVTPH2BF8256_MASK, UNKNOWN, (int) V16QI_FTYPE_V16HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtph2bf8v32hf_mask, "__builtin_ia32_vcvtph2bf8512_mask", IX86_BUILTIN_VCVTPH2BF8512_MASK, UNKNOWN, (int) V32QI_FTYPE_V32HF_V32QI_USI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtph2bf8sv8hf_mask, "__builtin_ia32_vcvtph2bf8s128_mask", IX86_BUILTIN_VCVTPH2BF8S128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V16QI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtph2bf8sv16hf_mask, "__builtin_ia32_vcvtph2bf8s256_mask", IX86_BUILTIN_VCVTPH2BF8S256_MASK, UNKNOWN, (int) V16QI_FTYPE_V16HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtph2bf8sv32hf_mask, "__builtin_ia32_vcvtph2bf8s512_mask", IX86_BUILTIN_VCVTPH2BF8S512_MASK, UNKNOWN, (int) V32QI_FTYPE_V32HF_V32QI_USI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtph2hf8v8hf_mask, "__builtin_ia32_vcvtph2hf8128_mask", IX86_BUILTIN_VCVTPH2HF8128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V16QI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtph2hf8v16hf_mask, "__builtin_ia32_vcvtph2hf8256_mask", IX86_BUILTIN_VCVTPH2HF8256_MASK, UNKNOWN, (int) V16QI_FTYPE_V16HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtph2hf8v32hf_mask, "__builtin_ia32_vcvtph2hf8512_mask", IX86_BUILTIN_VCVTPH2HF8512_MASK, UNKNOWN, (int) V32QI_FTYPE_V32HF_V32QI_USI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtph2hf8sv8hf_mask, "__builtin_ia32_vcvtph2hf8s128_mask", IX86_BUILTIN_VCVTPH2HF8S128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V16QI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtph2hf8sv16hf_mask, "__builtin_ia32_vcvtph2hf8s256_mask", IX86_BUILTIN_VCVTPH2HF8S256_MASK, UNKNOWN, (int) V16QI_FTYPE_V16HF_V16QI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtph2hf8sv32hf_mask, "__builtin_ia32_vcvtph2hf8s512_mask", IX86_BUILTIN_VCVTPH2HF8S512_MASK, UNKNOWN, (int) V32QI_FTYPE_V32HF_V32QI_USI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvthf82phv8hf_mask, "__builtin_ia32_vcvthf82ph128_mask", IX86_BUILTIN_VCVTHF82PH128_MASK, UNKNOWN, (int) V8HF_FTYPE_V16QI_V8HF_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvthf82phv16hf_mask, "__builtin_ia32_vcvthf82ph256_mask", IX86_BUILTIN_VCVTHF82PH256_MASK, UNKNOWN, (int) V16HF_FTYPE_V16QI_V16HF_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvthf82phv32hf_mask, "__builtin_ia32_vcvthf82ph512_mask", IX86_BUILTIN_VCVTHF82PH512_MASK, UNKNOWN, (int) V32HF_FTYPE_V32QI_V32HF_USI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_avx10v1aux_cvt2ps2phx_v16hf_mask, "__builtin_ia32_vcvt2ps2phx256_mask", IX86_BUILTIN_VCVT2PS2PHX_V16HF_MASK, UNKNOWN, (int) V16HF_FTYPE_V8SF_V8SF_V16HF_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_avx10v1aux_cvt2ps2phx_v8hf_mask, "__builtin_ia32_vcvt2ps2phx128_mask", IX86_BUILTIN_VCVT2PS2PHX_V8HF_MASK, UNKNOWN, (int) V8HF_FTYPE_V4SF_V4SF_V8HF_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2bf8v8hf, "__builtin_ia32_vcvtbiasph2bf8128", IX86_BUILTIN_VCVTBIASPH2BF8128, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2bf8v8hf_mask, "__builtin_ia32_vcvtbiasph2bf8128_mask", IX86_BUILTIN_VCVTBIASPH2BF8128_MASK, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2bf8v16hf_mask, "__builtin_ia32_vcvtbiasph2bf8256_mask", IX86_BUILTIN_VCVTBIASPH2BF8256_MASK, UNKNOWN, (int) V16QI_FTYPE_V32QI_V16HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2bf8v32hf_mask, "__builtin_ia32_vcvtbiasph2bf8512_mask", IX86_BUILTIN_VCVTBIASPH2BF8512_MASK, UNKNOWN, (int) V32QI_FTYPE_V64QI_V32HF_V32QI_USI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2bf8sv8hf, "__builtin_ia32_vcvtbiasph2bf8s128", IX86_BUILTIN_VCVTBIASPH2BF8S128, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2bf8sv8hf_mask, "__builtin_ia32_vcvtbiasph2bf8s128_mask", IX86_BUILTIN_VCVTBIASPH2BF8S128_MASK, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2bf8sv16hf_mask, "__builtin_ia32_vcvtbiasph2bf8s256_mask", IX86_BUILTIN_VCVTBIASPH2BF8S256_MASK, UNKNOWN, (int) V16QI_FTYPE_V32QI_V16HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2bf8sv32hf_mask, "__builtin_ia32_vcvtbiasph2bf8s512_mask", IX86_BUILTIN_VCVTBIASPH2BF8S512_MASK, UNKNOWN, (int) V32QI_FTYPE_V64QI_V32HF_V32QI_USI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2hf8v8hf, "__builtin_ia32_vcvtbiasph2hf8128", IX86_BUILTIN_VCVTBIASPH2HF8128, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2hf8v8hf_mask, "__builtin_ia32_vcvtbiasph2hf8128_mask", IX86_BUILTIN_VCVTBIASPH2HF8128_MASK, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2hf8v16hf_mask, "__builtin_ia32_vcvtbiasph2hf8256_mask", IX86_BUILTIN_VCVTBIASPH2HF8256_MASK, UNKNOWN, (int) V16QI_FTYPE_V32QI_V16HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2hf8v32hf_mask, "__builtin_ia32_vcvtbiasph2hf8512_mask", IX86_BUILTIN_VCVTBIASPH2HF8512_MASK, UNKNOWN, (int) V32QI_FTYPE_V64QI_V32HF_V32QI_USI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2hf8sv8hf, "__builtin_ia32_vcvtbiasph2hf8s128", IX86_BUILTIN_VCVTBIASPH2HF8S128, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2hf8sv8hf_mask, "__builtin_ia32_vcvtbiasph2hf8s128_mask", IX86_BUILTIN_VCVTBIASPH2HF8S128_MASK, UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2hf8sv16hf_mask, "__builtin_ia32_vcvtbiasph2hf8s256_mask", IX86_BUILTIN_VCVTBIASPH2HF8S256_MASK, UNKNOWN, (int) V16QI_FTYPE_V32QI_V16HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtbiasph2hf8sv32hf_mask, "__builtin_ia32_vcvtbiasph2hf8s512_mask", IX86_BUILTIN_VCVTBIASPH2HF8S512_MASK, UNKNOWN, (int) V32QI_FTYPE_V64QI_V32HF_V32QI_USI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvt2ph2bf8v8hf_mask, "__builtin_ia32_vcvt2ph2bf8128_mask", IX86_BUILTIN_VCVT2PH2BF8128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V8HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvt2ph2bf8v16hf_mask, "__builtin_ia32_vcvt2ph2bf8256_mask", IX86_BUILTIN_VCVT2PH2BF8256_MASK, UNKNOWN, (int) V32QI_FTYPE_V16HF_V16HF_V32QI_USI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvt2ph2bf8v32hf_mask, "__builtin_ia32_vcvt2ph2bf8512_mask", IX86_BUILTIN_VCVT2PH2BF8512_MASK, UNKNOWN, (int) V64QI_FTYPE_V32HF_V32HF_V64QI_UDI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvt2ph2bf8sv8hf_mask, "__builtin_ia32_vcvt2ph2bf8s128_mask", IX86_BUILTIN_VCVT2PH2BF8S128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V8HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvt2ph2bf8sv16hf_mask, "__builtin_ia32_vcvt2ph2bf8s256_mask", IX86_BUILTIN_VCVT2PH2BF8S256_MASK, UNKNOWN, (int) V32QI_FTYPE_V16HF_V16HF_V32QI_USI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvt2ph2bf8sv32hf_mask, "__builtin_ia32_vcvt2ph2bf8s512_mask", IX86_BUILTIN_VCVT2PH2BF8S512_MASK, UNKNOWN, (int) V64QI_FTYPE_V32HF_V32HF_V64QI_UDI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvt2ph2hf8v8hf_mask, "__builtin_ia32_vcvt2ph2hf8128_mask", IX86_BUILTIN_VCVT2PH2HF8128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V8HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvt2ph2hf8v16hf_mask, "__builtin_ia32_vcvt2ph2hf8256_mask", IX86_BUILTIN_VCVT2PH2HF8256_MASK, UNKNOWN, (int) V32QI_FTYPE_V16HF_V16HF_V32QI_USI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvt2ph2hf8v32hf_mask, "__builtin_ia32_vcvt2ph2hf8512_mask", IX86_BUILTIN_VCVT2PH2HF8512_MASK, UNKNOWN, (int) V64QI_FTYPE_V32HF_V32HF_V64QI_UDI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvt2ph2hf8sv8hf_mask, "__builtin_ia32_vcvt2ph2hf8s128_mask", IX86_BUILTIN_VCVT2PH2HF8S128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V8HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvt2ph2hf8sv16hf_mask, "__builtin_ia32_vcvt2ph2hf8s256_mask", IX86_BUILTIN_VCVT2PH2HF8S256_MASK, UNKNOWN, (int) V32QI_FTYPE_V16HF_V16HF_V32QI_USI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvt2ph2hf8sv32hf_mask, "__builtin_ia32_vcvt2ph2hf8s512_mask", IX86_BUILTIN_VCVT2PH2HF8S512_MASK, UNKNOWN, (int) V64QI_FTYPE_V32HF_V32HF_V64QI_UDI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtph2bf8v8hf_mask, "__builtin_ia32_vcvtph2bf8128_mask", IX86_BUILTIN_VCVTPH2BF8128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V16QI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtph2bf8v16hf_mask, "__builtin_ia32_vcvtph2bf8256_mask", IX86_BUILTIN_VCVTPH2BF8256_MASK, UNKNOWN, (int) V16QI_FTYPE_V16HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtph2bf8v32hf_mask, "__builtin_ia32_vcvtph2bf8512_mask", IX86_BUILTIN_VCVTPH2BF8512_MASK, UNKNOWN, (int) V32QI_FTYPE_V32HF_V32QI_USI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtph2bf8sv8hf_mask, "__builtin_ia32_vcvtph2bf8s128_mask", IX86_BUILTIN_VCVTPH2BF8S128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V16QI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtph2bf8sv16hf_mask, "__builtin_ia32_vcvtph2bf8s256_mask", IX86_BUILTIN_VCVTPH2BF8S256_MASK, UNKNOWN, (int) V16QI_FTYPE_V16HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtph2bf8sv32hf_mask, "__builtin_ia32_vcvtph2bf8s512_mask", IX86_BUILTIN_VCVTPH2BF8S512_MASK, UNKNOWN, (int) V32QI_FTYPE_V32HF_V32QI_USI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtph2hf8v8hf_mask, "__builtin_ia32_vcvtph2hf8128_mask", IX86_BUILTIN_VCVTPH2HF8128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V16QI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtph2hf8v16hf_mask, "__builtin_ia32_vcvtph2hf8256_mask", IX86_BUILTIN_VCVTPH2HF8256_MASK, UNKNOWN, (int) V16QI_FTYPE_V16HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtph2hf8v32hf_mask, "__builtin_ia32_vcvtph2hf8512_mask", IX86_BUILTIN_VCVTPH2HF8512_MASK, UNKNOWN, (int) V32QI_FTYPE_V32HF_V32QI_USI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtph2hf8sv8hf_mask, "__builtin_ia32_vcvtph2hf8s128_mask", IX86_BUILTIN_VCVTPH2HF8S128_MASK, UNKNOWN, (int) V16QI_FTYPE_V8HF_V16QI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtph2hf8sv16hf_mask, "__builtin_ia32_vcvtph2hf8s256_mask", IX86_BUILTIN_VCVTPH2HF8S256_MASK, UNKNOWN, (int) V16QI_FTYPE_V16HF_V16QI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvtph2hf8sv32hf_mask, "__builtin_ia32_vcvtph2hf8s512_mask", IX86_BUILTIN_VCVTPH2HF8S512_MASK, UNKNOWN, (int) V32QI_FTYPE_V32HF_V32QI_USI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvthf82phv8hf_mask, "__builtin_ia32_vcvthf82ph128_mask", IX86_BUILTIN_VCVTHF82PH128_MASK, UNKNOWN, (int) V8HF_FTYPE_V16QI_V8HF_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvthf82phv16hf_mask, "__builtin_ia32_vcvthf82ph256_mask", IX86_BUILTIN_VCVTHF82PH256_MASK, UNKNOWN, (int) V16HF_FTYPE_V16QI_V16HF_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vcvthf82phv32hf_mask, "__builtin_ia32_vcvthf82ph512_mask", IX86_BUILTIN_VCVTHF82PH512_MASK, UNKNOWN, (int) V32HF_FTYPE_V32QI_V32HF_USI)
 BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_avx10_2_addbf16_v32bf, "__builtin_ia32_addbf16512", IX86_BUILTIN_ADDBF16512, UNKNOWN, (int) V32BF_FTYPE_V32BF_V32BF)
 BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_avx10_2_addbf16_v32bf_mask, "__builtin_ia32_addbf16512_mask", IX86_BUILTIN_ADDBF16512_MASK, UNKNOWN, (int) V32BF_FTYPE_V32BF_V32BF_V32BF_USI)
 BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_avx10_2_addbf16_v16bf, "__builtin_ia32_addbf16256", IX86_BUILTIN_ADDBF16256, UNKNOWN, (int) V16BF_FTYPE_V16BF_V16BF)
@@ -3738,7 +3738,7 @@ BDESC (0, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fmulcsh_v8hf_round, "
 BDESC (0, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fmulcsh_v8hf_mask_round, "__builtin_ia32_vfmulcsh_mask_round", IX86_BUILTIN_VFMULCSH_MASK_ROUND, UNKNOWN, (int) V8HF_FTYPE_V8HF_V8HF_V8HF_UQI_INT)

 /* AVX10.2.  */
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_avx10_2_cvt2ps2phx_v32hf_mask_round, "__builtin_ia32_vcvt2ps2phx512_mask_round", IX86_BUILTIN_VCVT2PS2PHX_V32HF_MASK_ROUND, UNKNOWN, (int) V32HF_FTYPE_V16SF_V16SF_V32HF_USI_INT)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_avx10v1aux_cvt2ps2phx_v32hf_mask_round, "__builtin_ia32_vcvt2ps2phx512_mask_round", IX86_BUILTIN_VCVT2PS2PHX_V32HF_MASK_ROUND, UNKNOWN, (int) V32HF_FTYPE_V16SF_V16SF_V32HF_USI_INT)
 BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_avx10_2_cvtph2ibsv32hf_mask_round, "__builtin_ia32_cvtph2ibs512_mask_round", IX86_BUILTIN_CVTPH2IBS512_MASK_ROUND, UNKNOWN, (int) V32HI_FTYPE_V32HF_V32HI_USI_INT)
 BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_avx10_2_cvtph2iubsv32hf_mask_round, "__builtin_ia32_cvtph2iubs512_mask_round", IX86_BUILTIN_CVTPH2IUBS512_MASK_ROUND, UNKNOWN, (int) V32HI_FTYPE_V32HF_V32HI_USI_INT)
 BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_avx10_2_cvtps2ibsv16sf_mask_round, "__builtin_ia32_cvtps2ibs512_mask_round", IX86_BUILTIN_CVTPS2IBS512_MASK_ROUND, UNKNOWN, (int) V16SI_FTYPE_V16SF_V16SI_UHI_INT)
diff --git a/gcc/config/i386/immintrin.h b/gcc/config/i386/immintrin.h
index 63db4fddca65..74063ee40532 100644
--- a/gcc/config/i386/immintrin.h
+++ b/gcc/config/i386/immintrin.h
@@ -148,6 +148,8 @@

 #include 

+#include 
+
 #include 

 #include 
diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index c1e8b2562958..a223acc606d7 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -33436,14 +33436,14 @@
    (set_attr "addr" "gpr16")
    (set_attr "mode" "")])

-(define_insn "avx10_2_cvt2ps2phx_"
+(define_insn "avx10v1aux_cvt2ps2phx_"
   [(set (match_operand:VHF_AVX512VL 0 "register_operand" "=v")
 	(vec_concat:VHF_AVX512VL
 	  (float_truncate:
 	    (match_operand: 2 "" ""))
 	  (float_truncate:
 	    (match_operand: 1 "register_operand" "v"))))]
-  "TARGET_AVX10_2 && "
+  "TARGET_AVX10V1AUX && "
   "vcvt2ps2phx\t{%2, %1, %0|%0, %1, %2}")

 (define_mode_attr ssebvecmode
@@ -33465,7 +33465,7 @@
 	  [(match_operand:VHF_AVX512VL 1 "register_operand" "v")
 	   (match_operand:VHF_AVX512VL 2 "nonimmediate_operand" "vm")]
 	  UNSPEC_CONVERTFP8_PACK))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vcvt\t{%2, %1, %0|%0, %1, %2}"
   [(set_attr "prefix" "evex")])

@@ -33494,7 +33494,7 @@
 	     (match_operand:V8HF 2 "nonimmediate_operand")]
 	      UNSPEC_VCVTBIASPH2FP8_PACK)
 	  (match_dup 3)))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "operands[3] = CONST0_RTX (V8QImode);")

 (define_insn "*vcvtv8hf"
@@ -33505,7 +33505,7 @@
 	     (match_operand:V8HF 2 "nonimmediate_operand" "vm")]
 	      UNSPEC_VCVTBIASPH2FP8_PACK)
 	  (match_operand:V8QI 3 "const0_operand")))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vcvt\t{%2, %1, %0|%0, %1, %2}"
   [(set_attr "prefix" "evex")
    (set_attr "mode" "HF")])
@@ -33526,7 +33526,7 @@
 			 (const_int 6) (const_int 7)]))
 	    (match_operand:QI 4 "register_operand" "C"))
 	  (match_dup 5)))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "operands[5] = CONST0_RTX (V8QImode);")

 (define_insn "*vcvtv8hf_mask"
@@ -33545,26 +33545,23 @@
 			 (const_int 6) (const_int 7)]))
 	    (match_operand:QI 4 "register_operand" "Yk"))
 	  (match_operand:V8QI 5 "const0_operand")))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vcvt\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, %2}"
   [(set_attr "prefix" "evex")])

-(define_mode_iterator VHF_AVX10_2_2
-  [V32HF V16HF])
+(define_mode_iterator VHF_256_512
+  [V16HF (V32HF "TARGET_AVX10V1AUX")])

 (define_insn "vcvt"
   [(set (match_operand: 0 "register_operand" "=v")
 	(unspec:
 	  [(match_operand: 1 "register_operand" "v")
-	   (match_operand:VHF_AVX10_2_2 2 "nonimmediate_operand" "vm")]
+	   (match_operand:VHF_256_512 2 "nonimmediate_operand" "vm")]
 	  UNSPEC_VCVTBIASPH2FP8_PACK))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vcvt\t{%2, %1, %0|%0, %1, %2}"
   [(set_attr "prefix" "evex")])

-(define_mode_iterator VHF_256_512
-  [V16HF (V32HF "TARGET_AVX10_2")])
-
 (define_mode_attr ph2fp8suff
   [(V32HF "") (V16HF "{y}") (V8HF "{x}")])

@@ -33585,7 +33582,7 @@
 	    [(match_operand:V8HF 1 "nonimmediate_operand")]
 	      UNSPEC_CONVERTPH2FP8)
 	  (match_dup 2)))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "operands[2] = CONST0_RTX (V8QImode);")

 (define_insn "*vcvtv8hf"
@@ -33595,7 +33592,7 @@
 	    [(match_operand:V8HF 1 "nonimmediate_operand" "vm")]
 	      UNSPEC_CONVERTPH2FP8)
 	  (match_operand:V8QI 2 "const0_operand")))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vcvt{x}\t{%1, %0|%0, %1}"
   [(set_attr "prefix" "evex")
    (set_attr "mode" "HF")])
@@ -33615,7 +33612,7 @@
 			 (const_int 6) (const_int 7)]))
 	    (match_operand:QI 3 "register_operand"))
 	  (match_dup 4)))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "operands[4] = CONST0_RTX (V8QImode);")

 (define_insn "*vcvtv8hf_mask"
@@ -33633,7 +33630,7 @@
 			 (const_int 6) (const_int 7)]))
 	    (match_operand:QI 3 "register_operand" "Yk"))
 	  (match_operand:V8QI 4 "const0_operand")))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vcvt{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"
   [(set_attr "prefix" "evex")])

@@ -33642,7 +33639,7 @@
 	(unspec:
 	  [(match_operand:VHF_256_512 1 "nonimmediate_operand" "vm")]
 	  UNSPEC_CONVERTPH2FP8))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vcvt\t{%1, %0|%0, %1}"
   [(set_attr "prefix" "evex")])

@@ -33651,7 +33648,7 @@
 	(unspec:VHF_AVX512VL
 	  [(match_operand: 1 "nonimmediate_operand" "vm")]
 	  UNSPEC_VCVTHF82PH))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vcvthf82ph\t{%1, %0|%0, %1}"
   [(set_attr "prefix" "evex")])

diff --git a/gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c b/gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c
new file mode 100644
index 000000000000..369ec969dde5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c
@@ -0,0 +1,375 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx10v1aux -O2 -fno-fuse-ops-with-volatile-access" } */
+/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\{%k\[0-9\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\{%k\[0-9\]\}\{z\}\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\{%k\[0-9\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\{%k\[0-9\]\}\{z\}\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\{%k\[0-9\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\{%k\[0-9\]\}\{z\}\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\{rn-sae\}\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\{rn-sae\}\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\{%k\[0-9\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\{rn-sae\}\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\{%k\[0-9\]\}\{z\}\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)"  1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8x\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8x\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8x\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8y\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8y\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8y\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8\[ \\t\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8\[ \\t\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8\[ \\t\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8sx\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8sx\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8sx\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8sy\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8sy\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8sy\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8s\[ \\t\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8s\[ \\t\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2bf8s\[ \\t\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8x\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8x\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8x\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8y\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8y\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8y\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8\[ \\t\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8\[ \\t\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8\[ \\t\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8sx\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8sx\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8sx\[ \\t\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8sy\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8sy\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8sy\[ \\t\]*%ymm\[0-9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8s\[ \\t\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8s\[ \\t\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "vcvtph2hf8s\[ \\t\]*%zmm\[0-9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */
+
+#include 
+
+volatile __m128 a1,b1;
+volatile __m256 a2,b2;
+volatile __m512 a3,b3;
+volatile __m128h y,x128h,z;
+volatile __m256h y2,x256h,z2;
+volatile __m512h y3,x512h,z4;
+volatile __m128i x128i,z3;
+volatile __m256i x256i,z1;
+volatile __m512i x512i;
+volatile __mmask8 m8;
+volatile __mmask16 m16;
+volatile __mmask32 m32;
+volatile __mmask64 m64;
+
+void extern
+avx10v1aux_test (void)
+{
+  y = _mm_cvtx2ps_ph (a1, b1);
+  y = _mm_mask_cvtx2ps_ph (y, m8, a1, b1);
+  y = _mm_maskz_cvtx2ps_ph (m8, a1, b1);
+
+  y2 = _mm256_cvtx2ps_ph (a2, b2);
+  y2 = _mm256_mask_cvtx2ps_ph (y2, m16, a2, b2);
+  y2 = _mm256_maskz_cvtx2ps_ph (m16, a2, b2);
+
+  y3 = _mm512_cvtx2ps_ph (a3, b3);
+  y3 = _mm512_mask_cvtx2ps_ph (y3, m32, a3, b3);
+  y3 = _mm512_maskz_cvtx2ps_ph (m32, a3, b3);
+
+  y3 = _mm512_cvtx_round2ps_ph (a3, b3, 8);
+  y3 = _mm512_mask_cvtx_round2ps_ph (y3, m32, a3, b3, 8);
+  y3 = _mm512_maskz_cvtx_round2ps_ph (m32, a3, b3, 8);
+}
+
+void extern
+avx10v1aux_vcvtbiasph2bf8_test (void)
+{
+  x128i = _mm_cvtbiasph_bf8 (x128i, x128h);
+  x128i = _mm_mask_cvtbiasph_bf8 (x128i, m8, x128i, x128h);
+  x128i = _mm_maskz_cvtbiasph_bf8 (m8, x128i, x128h);
+
+  x128i = _mm256_cvtbiasph_bf8 (x256i, x256h);
+  x128i = _mm256_mask_cvtbiasph_bf8 (x128i, m16, x256i, x256h);
+  x128i = _mm256_maskz_cvtbiasph_bf8 (m16, x256i, x256h);
+
+  x256i = _mm512_cvtbiasph_bf8 (x512i, x512h);
+  x256i = _mm512_mask_cvtbiasph_bf8 (x256i, m32, x512i, x512h);
+  x256i = _mm512_maskz_cvtbiasph_bf8 (m32, x512i, x512h);
+}
+
+void extern
+avx10v1aux_vcvtbiasph2bf8s_test (void)
+{
+  x128i = _mm_cvts_biasph_bf8 (x128i, x128h);
+  x128i = _mm_mask_cvts_biasph_bf8 (x128i, m8, x128i, x128h);
+  x128i = _mm_maskz_cvts_biasph_bf8 (m8, x128i, x128h);
+
+  x128i = _mm256_cvts_biasph_bf8 (x256i, x256h);
+  x128i = _mm256_mask_cvts_biasph_bf8 (x128i, m16, x256i, x256h);
+  x128i = _mm256_maskz_cvts_biasph_bf8 (m16, x256i, x256h);
+
+  x256i = _mm512_cvts_biasph_bf8 (x512i, x512h);
+  x256i = _mm512_mask_cvts_biasph_bf8 (x256i, m32, x512i, x512h);
+  x256i = _mm512_maskz_cvts_biasph_bf8 (m32, x512i, x512h);
+}
+
+void extern
+avx10v1aux_vcvtbiasph2hf8_test (void)
+{
+  x128i = _mm_cvtbiasph_hf8 (x128i, x128h);
+  x128i = _mm_mask_cvtbiasph_hf8 (x128i, m8, x128i, x128h);
+  x128i = _mm_maskz_cvtbiasph_hf8 (m8, x128i, x128h);
+
+  x128i = _mm256_cvtbiasph_hf8 (x256i, x256h);
+  x128i = _mm256_mask_cvtbiasph_hf8 (x128i, m16, x256i, x256h);
+  x128i = _mm256_maskz_cvtbiasph_hf8 (m16, x256i, x256h);
+
+  x256i = _mm512_cvtbiasph_hf8 (x512i, x512h);
+  x256i = _mm512_mask_cvtbiasph_hf8 (x256i, m32, x512i, x512h);
+  x256i = _mm512_maskz_cvtbiasph_hf8 (m32, x512i, x512h);
+}
+
+void extern
+avx10v1aux_vcvtbiasph2hf8s_test (void)
+{
+  x128i = _mm_cvts_biasph_hf8 (x128i, x128h);
+  x128i = _mm_mask_cvts_biasph_hf8 (x128i, m8, x128i, x128h);
+  x128i = _mm_maskz_cvts_biasph_hf8 (m8, x128i, x128h);
+
+  x128i = _mm256_cvts_biasph_hf8 (x256i, x256h);
+  x128i = _mm256_mask_cvts_biasph_hf8 (x128i, m16, x256i, x256h);
+  x128i = _mm256_maskz_cvts_biasph_hf8 (m16, x256i, x256h);
+
+  x256i = _mm512_cvts_biasph_hf8 (x512i, x512h);
+  x256i = _mm512_mask_cvts_biasph_hf8 (x256i, m32, x512i, x512h);
+  x256i = _mm512_maskz_cvts_biasph_hf8 (m32, x512i, x512h);
+}
+
+void extern
+avx10v1aux_vcvt2ph2bf8_test (void)
+{
+  x128i = _mm_cvt2ph_bf8 (x128h, x128h);
+  x128i = _mm_mask_cvt2ph_bf8 (x128i, m16, x128h, x128h);
+  x128i = _mm_maskz_cvt2ph_bf8 (m16, x128h, x128h);
+
+  x256i = _mm256_cvt2ph_bf8 (x256h, x256h);
+  x256i = _mm256_mask_cvt2ph_bf8 (x256i, m32, x256h, x256h);
+  x256i = _mm256_maskz_cvt2ph_bf8 (m32, x256h, x256h);
+
+  x512i = _mm512_cvt2ph_bf8 (x512h, x512h);
+  x512i = _mm512_mask_cvt2ph_bf8 (x512i, m64, x512h, x512h);
+  x512i = _mm512_maskz_cvt2ph_bf8 (m64, x512h, x512h);
+}
+
+void extern
+avx10v1aux_vcvt2ph2bf8s_test (void)
+{
+  x128i = _mm_cvts_2ph_bf8 (x128h, x128h);
+  x128i = _mm_mask_cvts_2ph_bf8 (x128i, m16, x128h, x128h);
+  x128i = _mm_maskz_cvts_2ph_bf8 (m16, x128h, x128h);
+
+  x256i = _mm256_cvts_2ph_bf8 (x256h, x256h);
+  x256i = _mm256_mask_cvts_2ph_bf8 (x256i, m32, x256h, x256h);
+  x256i = _mm256_maskz_cvts_2ph_bf8 (m32, x256h, x256h);
+
+  x512i = _mm512_cvts_2ph_bf8 (x512h, x512h);
+  x512i = _mm512_mask_cvts_2ph_bf8 (x512i, m64, x512h, x512h);
+  x512i = _mm512_maskz_cvts_2ph_bf8 (m64, x512h, x512h);
+}
+
+void extern
+avx10v1aux_vcvt2ph2hf8_test (void)
+{
+  x128i = _mm_cvt2ph_hf8 (x128h, x128h);
+  x128i = _mm_mask_cvt2ph_hf8 (x128i, m16, x128h, x128h);
+  x128i = _mm_maskz_cvt2ph_hf8 (m16, x128h, x128h);
+
+  x256i = _mm256_cvt2ph_hf8 (x256h, x256h);
+  x256i = _mm256_mask_cvt2ph_hf8 (x256i, m32, x256h, x256h);
+  x256i = _mm256_maskz_cvt2ph_hf8 (m32, x256h, x256h);
+
+  x512i = _mm512_cvt2ph_hf8 (x512h, x512h);
+  x512i = _mm512_mask_cvt2ph_hf8 (x512i, m64, x512h, x512h);
+  x512i = _mm512_maskz_cvt2ph_hf8 (m64, x512h, x512h);
+}
+
+void extern
+avx10v1aux_vcvt2ph2hf8s_test (void)
+{
+  x128i = _mm_cvts_2ph_hf8 (x128h, x128h);
+  x128i = _mm_mask_cvts_2ph_hf8 (x128i, m16, x128h, x128h);
+  x128i = _mm_maskz_cvts_2ph_hf8 (m16, x128h, x128h);
+
+  x256i = _mm256_cvts_2ph_hf8 (x256h, x256h);
+  x256i = _mm256_mask_cvts_2ph_hf8 (x256i, m32, x256h, x256h);
+  x256i = _mm256_maskz_cvts_2ph_hf8 (m32, x256h, x256h);
+
+  x512i = _mm512_cvts_2ph_hf8 (x512h, x512h);
+  x512i = _mm512_mask_cvts_2ph_hf8 (x512i, m64, x512h, x512h);
+  x512i = _mm512_maskz_cvts_2ph_hf8 (m64, x512h, x512h);
+}
+
+void extern
+avx10v1aux_vcvthf82ph_test (void)
+{
+  x128h = _mm_cvthf8_ph (x128i);
+  x128h = _mm_mask_cvthf8_ph (x128h, m8, x128i);
+  x128h = _mm_maskz_cvthf8_ph (m8, x128i);
+
+  x256h = _mm256_cvthf8_ph (x128i);
+  x256h = _mm256_mask_cvthf8_ph (x256h, m16, x128i);
+  x256h = _mm256_maskz_cvthf8_ph (m16, x128i);
+
+  x512h = _mm512_cvthf8_ph (x256i);
+  x512h = _mm512_mask_cvthf8_ph (x512h, m32, x256i);
+  x512h = _mm512_maskz_cvthf8_ph (m32, x256i);
+}
+
+void extern
+avx10v1aux_vcvtph2bf8_test (void)
+{
+  x128i = _mm_cvtph_bf8 (x128h);
+  x128i = _mm_mask_cvtph_bf8 (x128i, m8, x128h);
+  x128i = _mm_maskz_cvtph_bf8 (m8, x128h);
+
+  x128i = _mm256_cvtph_bf8 (x256h);
+  x128i = _mm256_mask_cvtph_bf8 (x128i, m16, x256h);
+  x128i = _mm256_maskz_cvtph_bf8 (m16, x256h);
+
+  x256i = _mm512_cvtph_bf8 (x512h);
+  x256i = _mm512_mask_cvtph_bf8 (x256i, m32, x512h);
+  x256i = _mm512_maskz_cvtph_bf8 (m32, x512h);
+}
+
+void extern
+avx10v1aux_vcvtph2bf8s_test (void)
+{
+  x128i = _mm_cvts_ph_bf8 (x128h);
+  x128i = _mm_mask_cvts_ph_bf8 (x128i, m8, x128h);
+  x128i = _mm_maskz_cvts_ph_bf8 (m8, x128h);
+
+  x128i = _mm256_cvts_ph_bf8 (x256h);
+  x128i = _mm256_mask_cvts_ph_bf8 (x128i, m16, x256h);
+  x128i = _mm256_maskz_cvts_ph_bf8 (m16, x256h);
+
+  x256i = _mm512_cvts_ph_bf8 (x512h);
+  x256i = _mm512_mask_cvts_ph_bf8 (x256i, m32, x512h);
+  x256i = _mm512_maskz_cvts_ph_bf8 (m32, x512h);
+}
+
+void extern
+avx10v1aux_vcvtph2hf8_test (void)
+{
+  x128i = _mm_cvtph_hf8 (x128h);
+  x128i = _mm_mask_cvtph_hf8 (x128i, m8, x128h);
+  x128i = _mm_maskz_cvtph_hf8 (m8, x128h);
+
+  x128i = _mm256_cvtph_hf8 (x256h);
+  x128i = _mm256_mask_cvtph_hf8 (x128i, m16, x256h);
+  x128i = _mm256_maskz_cvtph_hf8 (m16, x256h);
+
+  x256i = _mm512_cvtph_hf8 (x512h);
+  x256i = _mm512_mask_cvtph_hf8 (x256i, m32, x512h);
+  x256i = _mm512_maskz_cvtph_hf8 (m32, x512h);
+}
+
+void extern
+avx10v1aux_vcvtph2hf8s_test (void)
+{
+  x128i = _mm_cvts_ph_hf8 (x128h);
+  x128i = _mm_mask_cvts_ph_hf8 (x128i, m8, x128h);
+  x128i = _mm_maskz_cvts_ph_hf8 (m8, x128h);
+
+  x128i = _mm256_cvts_ph_hf8 (x256h);
+  x128i = _mm256_mask_cvts_ph_hf8 (x128i, m16, x256h);
+  x128i = _mm256_maskz_cvts_ph_hf8 (m16, x256h);
+
+  x256i = _mm512_cvts_ph_hf8 (x512h);
+  x256i = _mm512_mask_cvts_ph_hf8 (x256i, m32, x512h);
+  x256i = _mm512_maskz_cvts_ph_hf8 (m32, x512h);
+}
diff --git a/gcc/testsuite/gcc.target/i386/funcspec-56.inc b/gcc/testsuite/gcc.target/i386/funcspec-56.inc
index f18778025753..0a364ff43d3a 100644
--- a/gcc/testsuite/gcc.target/i386/funcspec-56.inc
+++ b/gcc/testsuite/gcc.target/i386/funcspec-56.inc
@@ -94,6 +94,7 @@ extern void test_movrs (void)			__attribute__((__target__("movrs")));
 extern void test_amx_movrs (void)		__attribute__((__target__("amx-movrs")));
 extern void test_avx10v2aux (void)		__attribute__((__target__("avx10v2aux")));
 extern void test_acev1 (void)			__attribute__((__target__("acev1")));
+extern void test_avx10v1aux (void)		__attribute__((__target__("avx10v1aux")));

 extern void test_no_sgx (void)			__attribute__((__target__("no-sgx")));
 extern void test_no_avx512vpopcntdq(void)	__attribute__((__target__("no-avx512vpopcntdq")));
@@ -189,6 +190,7 @@ extern void test_no_movrs (void)		__attribute__((__target__("no-movrs")));
 extern void test_no_amx_movrs (void)		__attribute__((__target__("no-amx-movrs")));
 extern void test_no_avx10v2aux (void)		__attribute__((__target__("no-avx10v2aux")));
 extern void test_no_acev1 (void)		__attribute__((__target__("no-acev1")));
+extern void test_no_avx10v1aux (void)		__attribute__((__target__("no-avx10v1aux")));

 extern void test_arch_nocona (void)		__attribute__((__target__("arch=nocona")));
 extern void test_arch_core2 (void)		__attribute__((__target__("arch=core2")));
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index ae04b6a8daa1..1485d1bef81b 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -11767,6 +11767,17 @@ proc check_effective_target_avx10v2aux { } {
     } "-mavx10v2aux" ]
 }

+# Return 1 if avx10v1aux instructions can be compiled.
+proc check_effective_target_avx10v1aux { } {
+    return [check_no_compiler_messages avx10v1aux object {
+	void
+	foo ()
+	{
+	  __asm__ volatile ("vcvt2ph2bf8\t{%%zmm2, %%zmm1, %%zmm1|%%zmm1, %%zmm1, %%zmm2}");
+	}
+    } "-mavx10v1aux" ]
+}
+
 # Return 1 if amx-avx512 instructions can be compiled.
 proc check_effective_target_amx_avx512 { } {
     return [check_no_compiler_messages amx_avx512 object {
--
2.34.1


From Dipesh.Sharma@amd.com  Sun Nov  1 13:47:55 2026
From: Dipesh.Sharma@amd.com (Dipesh Sharma)
Date: Sun, 1 Nov 2026 19:17:55 +0530
Subject: [PATCH v3 3/4] [X86]: Move shared AVX10.2 and VNNI byte and word
 intrinsics to AVX10V1AUX.
In-Reply-To: <20261101134756.351245-1-Dipesh.Sharma@amd.com>
References: <20261101134756.351245-1-Dipesh.Sharma@amd.com>
Message-ID: <20261101134756.351245-4-Dipesh.Sharma@amd.com>

gcc/ChangeLog:

	* config/i386/avx10_2mediaintrin.h: Moved VNNI byte and word
  intrinsics to avx10v1auxintrin.h.
	* config/i386/avx10v1auxintrin.h: Added VNNI byte and word intrinsics.
	* config/i386/i386-builtin.def (BDESC): Updated option mask for
  VNNIINT{8,16} and 10.2 builtins.
	* config/i386/i386.md: Add target avx10v1aux.
	* config/i386/i386-expand.cc (ix86_check_builtin_isa_match): Share builtins between
  VNNIINT{8,16} and AVX10V1AUX.
	* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost): Update target guard
  from AVX10_2 to AVX10V1AUX.
	* config/i386/sse.md: Retarget avx10.2 subset VNNI
  byte and word patterns to AVX10V1AUX.

Co-authored-by: Venkataramanan Kumar 
---
 gcc/config/i386/avx10_2mediaintrin.h | 1032 --------------------------
 gcc/config/i386/avx10v1auxintrin.h   | 1032 ++++++++++++++++++++++++++
 gcc/config/i386/i386-builtin.def     |  216 +++---
 gcc/config/i386/i386-expand.cc       |    8 +-
 gcc/config/i386/i386.cc              |    4 +-
 gcc/config/i386/i386.md              |    4 +-
 gcc/config/i386/sse.md               |  125 ++--
 7 files changed, 1213 insertions(+), 1208 deletions(-)

diff --git a/gcc/config/i386/avx10_2mediaintrin.h b/gcc/config/i386/avx10_2mediaintrin.h
index 24af37954166..ffc1cbf66a56 100644
--- a/gcc/config/i386/avx10_2mediaintrin.h
+++ b/gcc/config/i386/avx10_2mediaintrin.h
@@ -34,1038 +34,6 @@
 #define __DISABLE_AVX10_2__
 #endif /* __AVX10_2__ */

-#define _mm_dpbssd_epi32(W, A, B) \
-  (__m128i) __builtin_ia32_vpdpbssd128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
-
-#define _mm_dpbssds_epi32(W, A, B) \
-  (__m128i) __builtin_ia32_vpdpbssds128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
-
-#define _mm_dpbsud_epi32(W, A, B) \
-  (__m128i) __builtin_ia32_vpdpbsud128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
-
-#define _mm_dpbsuds_epi32(W, A, B) \
-  (__m128i) __builtin_ia32_vpdpbsuds128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
-
-#define _mm_dpbuud_epi32(W, A, B) \
-  (__m128i) __builtin_ia32_vpdpbuud128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
-
-#define _mm_dpbuuds_epi32(W, A, B) \
-  (__m128i) __builtin_ia32_vpdpbuuds128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
-
-#define _mm256_dpbssd_epi32(W, A, B) \
-  (__m256i) __builtin_ia32_vpdpbssd256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
-
-#define _mm256_dpbssds_epi32(W, A, B) \
-  (__m256i) __builtin_ia32_vpdpbssds256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
-
-#define _mm256_dpbsud_epi32(W, A, B) \
-  (__m256i) __builtin_ia32_vpdpbsud256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
-
-#define _mm256_dpbsuds_epi32(W, A, B) \
-  (__m256i) __builtin_ia32_vpdpbsuds256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
-
-#define _mm256_dpbuud_epi32(W, A, B) \
-  (__m256i) __builtin_ia32_vpdpbuud256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
-
-#define _mm256_dpbuuds_epi32(W, A, B) \
-  (__m256i) __builtin_ia32_vpdpbuuds256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
-
-#define _mm_dpwsud_epi32(W, A, B) \
-  (__m128i) __builtin_ia32_vpdpwsud128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
-
-#define _mm_dpwsuds_epi32(W, A, B) \
-  (__m128i) __builtin_ia32_vpdpwsuds128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
-
-#define _mm_dpwusd_epi32(W, A, B) \
-  (__m128i) __builtin_ia32_vpdpwusd128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
-
-#define _mm_dpwusds_epi32(W, A, B) \
-  (__m128i) __builtin_ia32_vpdpwusds128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
-
-#define _mm_dpwuud_epi32(W, A, B) \
-  (__m128i) __builtin_ia32_vpdpwuud128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
-
-#define _mm_dpwuuds_epi32(W, A, B) \
-  (__m128i) __builtin_ia32_vpdpwuuds128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
-
-#define _mm256_dpwsud_epi32(W, A, B) \
-  (__m256i) __builtin_ia32_vpdpwsud256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
-
-#define _mm256_dpwsuds_epi32(W, A, B) \
-  (__m256i) __builtin_ia32_vpdpwsuds256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
-
-#define _mm256_dpwusd_epi32(W, A, B) \
-  (__m256i) __builtin_ia32_vpdpwusd256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
-
-#define _mm256_dpwusds_epi32(W, A, B) \
-  (__m256i) __builtin_ia32_vpdpwusds256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
-
-#define _mm256_dpwuud_epi32(W, A, B) \
-  (__m256i) __builtin_ia32_vpdpwuud256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
-
-#define _mm256_dpwuuds_epi32(W, A, B) \
-  (__m256i) __builtin_ia32_vpdpwuuds256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_dpbssd_epi32 (__m128i __W, __mmask8 __U,
-		       __m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpbssd_v4si_mask ((__v4si) __W,
-				       (__v4si) __A,
-				       (__v4si) __B,
-				       (__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_dpbssd_epi32 (__mmask8 __U, __m128i __W,
-			__m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpbssd_v4si_maskz ((__v4si) __W,
-					(__v4si) __A,
-					(__v4si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_dpbssds_epi32 (__m128i __W, __mmask8 __U,
-			__m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpbssds_v4si_mask ((__v4si) __W,
-					(__v4si) __A,
-					(__v4si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_dpbssds_epi32 (__mmask8 __U, __m128i __W,
-			 __m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpbssds_v4si_maskz ((__v4si) __W,
-					 (__v4si) __A,
-					 (__v4si) __B,
-					 (__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_dpbsud_epi32 (__m128i __W, __mmask8 __U,
-		       __m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpbsud_v4si_mask ((__v4si) __W,
-				       (__v4si) __A,
-				       (__v4si) __B,
-				       (__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_dpbsud_epi32 (__mmask8 __U, __m128i __W,
-			__m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpbsud_v4si_maskz ((__v4si) __W,
-					(__v4si) __A,
-					(__v4si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_dpbsuds_epi32 (__m128i __W, __mmask8 __U,
-			__m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpbsuds_v4si_mask ((__v4si) __W,
-					(__v4si) __A,
-					(__v4si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_dpbsuds_epi32 (__mmask8 __U, __m128i __W,
-			 __m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpbsuds_v4si_maskz ((__v4si) __W,
-					 (__v4si) __A,
-					 (__v4si) __B,
-					 (__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_dpbuud_epi32 (__m128i __W, __mmask8 __U,
-		       __m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpbuud_v4si_mask ((__v4si) __W,
-				       (__v4si) __A,
-				       (__v4si) __B,
-				       (__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_dpbuud_epi32 (__mmask8 __U, __m128i __W,
-			__m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpbuud_v4si_maskz ((__v4si) __W,
-					(__v4si) __A,
-					(__v4si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_dpbuuds_epi32 (__m128i __W, __mmask8 __U,
-			__m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpbuuds_v4si_mask ((__v4si) __W,
-					(__v4si) __A,
-					(__v4si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_dpbuuds_epi32 (__mmask8 __U, __m128i __W,
-			 __m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpbuuds_v4si_maskz ((__v4si) __W,
-					 (__v4si) __A,
-					 (__v4si) __B,
-					 (__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_dpbssd_epi32 (__m256i __W, __mmask8 __U,
-			  __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpbssd_v8si_mask ((__v8si) __W,
-				       (__v8si) __A,
-				       (__v8si) __B,
-				       (__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_dpbssd_epi32 (__mmask8 __U, __m256i __W,
-			   __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpbssd_v8si_maskz ((__v8si) __W,
-					(__v8si) __A,
-					(__v8si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_dpbssds_epi32 (__m256i __W, __mmask8 __U,
-			   __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpbssds_v8si_mask ((__v8si) __W,
-					(__v8si) __A,
-					(__v8si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_dpbssds_epi32 (__mmask8 __U, __m256i __W,
-			    __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpbssds_v8si_maskz ((__v8si) __W,
-					 (__v8si) __A,
-					 (__v8si) __B,
-					 (__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_dpbsud_epi32 (__m256i __W, __mmask8 __U,
-			  __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpbsud_v8si_mask ((__v8si) __W,
-				       (__v8si) __A,
-				       (__v8si) __B,
-				       (__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_dpbsud_epi32 (__mmask8 __U, __m256i __W,
-			   __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpbsud_v8si_maskz ((__v8si) __W,
-					(__v8si) __A,
-					(__v8si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_dpbsuds_epi32 (__m256i __W, __mmask8 __U,
-			   __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpbsuds_v8si_mask ((__v8si) __W,
-					(__v8si) __A,
-					(__v8si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_dpbsuds_epi32 (__mmask8 __U, __m256i __W,
-			    __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpbsuds_v8si_maskz ((__v8si) __W,
-					 (__v8si) __A,
-					 (__v8si) __B,
-					 (__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_dpbuud_epi32 (__m256i __W, __mmask8 __U,
-			  __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpbuud_v8si_mask ((__v8si) __W,
-				       (__v8si) __A,
-				       (__v8si) __B,
-				       (__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_dpbuud_epi32 (__mmask8 __U, __m256i __W,
-			   __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpbuud_v8si_maskz ((__v8si) __W,
-					(__v8si) __A,
-					(__v8si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_dpbuuds_epi32 (__m256i __W, __mmask8 __U,
-			   __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpbuuds_v8si_mask ((__v8si) __W,
-					(__v8si) __A,
-					(__v8si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_dpbuuds_epi32 (__mmask8 __U, __m256i __W,
-			    __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpbuuds_v8si_maskz ((__v8si) __W,
-					 (__v8si) __A,
-					 (__v8si) __B,
-					 (__mmask8) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_dpbssd_epi32 (__m512i __W, __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbssd512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_dpbssd_epi32 (__m512i __W, __mmask16 __U,
-			  __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbssd_v16si_mask ((__v16si) __W,
-					(__v16si) __A,
-					(__v16si) __B,
-					(__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_dpbssd_epi32 (__mmask16 __U, __m512i __W,
-			   __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbssd_v16si_maskz ((__v16si) __W,
-					 (__v16si) __A,
-					 (__v16si) __B,
-					 (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_dpbssds_epi32 (__m512i __W, __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbssds512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_dpbssds_epi32 (__m512i __W, __mmask16 __U,
-			   __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbssds_v16si_mask ((__v16si) __W,
-					 (__v16si) __A,
-					 (__v16si) __B,
-					 (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_dpbssds_epi32 (__mmask16 __U, __m512i __W,
-			    __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbssds_v16si_maskz ((__v16si) __W,
-					  (__v16si) __A,
-					  (__v16si) __B,
-					  (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_dpbsud_epi32 (__m512i __W, __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbsud512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_dpbsud_epi32 (__m512i __W, __mmask16 __U,
-			  __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbsud_v16si_mask ((__v16si) __W,
-					(__v16si) __A,
-					(__v16si) __B,
-					(__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_dpbsud_epi32 (__mmask16 __U, __m512i __W,
-			   __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbsud_v16si_maskz ((__v16si) __W,
-					 (__v16si) __A,
-					 (__v16si) __B,
-					 (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_dpbsuds_epi32 (__m512i __W, __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbsuds512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_dpbsuds_epi32 (__m512i __W, __mmask16 __U,
-			   __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbsuds_v16si_mask ((__v16si) __W,
-					 (__v16si) __A,
-					 (__v16si) __B,
-					 (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_dpbsuds_epi32 (__mmask16 __U, __m512i __W,
-			    __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbsuds_v16si_maskz ((__v16si) __W,
-					  (__v16si) __A,
-					  (__v16si) __B,
-					  (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_dpbuud_epi32 (__m512i __W, __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbuud512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_dpbuud_epi32 (__m512i __W, __mmask16 __U,
-			  __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbuud_v16si_mask ((__v16si) __W,
-					(__v16si) __A,
-					(__v16si) __B,
-					(__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_dpbuud_epi32 (__mmask16 __U, __m512i __W,
-			   __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbuud_v16si_maskz ((__v16si) __W,
-					 (__v16si) __A,
-					 (__v16si) __B,
-					 (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_dpbuuds_epi32 (__m512i __W, __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbuuds512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_dpbuuds_epi32 (__m512i __W, __mmask16 __U,
-			   __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbuuds_v16si_mask ((__v16si) __W,
-					 (__v16si) __A,
-					 (__v16si) __B,
-					 (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_dpbuuds_epi32 (__mmask16 __U, __m512i __W,
-			    __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpbuuds_v16si_maskz ((__v16si) __W,
-					  (__v16si) __A,
-					  (__v16si) __B,
-					  (__mmask16) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_dpwsud_epi32 (__m128i __W, __mmask8 __U,
-		       __m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpwsud_v4si_mask ((__v4si) __W,
-				       (__v4si) __A,
-				       (__v4si) __B,
-				       (__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_dpwsud_epi32 (__mmask8 __U, __m128i __W,
-			__m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpwsud_v4si_maskz ((__v4si) __W,
-					(__v4si) __A,
-					(__v4si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_dpwsuds_epi32 (__m128i __W, __mmask8 __U,
-			__m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpwsuds_v4si_mask ((__v4si) __W,
-					(__v4si) __A,
-					(__v4si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_dpwsuds_epi32 (__mmask8 __U, __m128i __W,
-			 __m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpwsuds_v4si_maskz ((__v4si) __W,
-					 (__v4si) __A,
-					 (__v4si) __B,
-					 (__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_dpwusd_epi32 (__m128i __W, __mmask8 __U,
-		       __m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpwusd_v4si_mask ((__v4si) __W,
-				       (__v4si) __A,
-				       (__v4si) __B,
-				       (__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_dpwusd_epi32 (__mmask8 __U, __m128i __W,
-			__m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpwusd_v4si_maskz ((__v4si) __W,
-					(__v4si) __A,
-					(__v4si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_dpwusds_epi32 (__m128i __W, __mmask8 __U,
-			__m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpwusds_v4si_mask ((__v4si) __W,
-					(__v4si) __A,
-					(__v4si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_dpwusds_epi32 (__mmask8 __U, __m128i __W,
-			 __m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpwusds_v4si_maskz ((__v4si) __W,
-					 (__v4si) __A,
-					 (__v4si) __B,
-					 (__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_dpwuud_epi32 (__m128i __W, __mmask8 __U,
-		       __m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpwuud_v4si_mask ((__v4si) __W,
-				       (__v4si) __A,
-				       (__v4si) __B,
-				       (__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_dpwuud_epi32 (__mmask8 __U, __m128i __W,
-			__m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpwuud_v4si_maskz ((__v4si) __W,
-					(__v4si) __A,
-					(__v4si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_dpwuuds_epi32 (__m128i __W, __mmask8 __U,
-			__m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpwuuds_v4si_mask ((__v4si) __W,
-					(__v4si) __A,
-					(__v4si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m128i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_dpwuuds_epi32 (__mmask8 __U, __m128i __W,
-			 __m128i __A, __m128i __B)
-{
-  return (__m128i)
-    __builtin_ia32_vpdpwuuds_v4si_maskz ((__v4si) __W,
-					 (__v4si) __A,
-					 (__v4si) __B,
-					 (__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_dpwsud_epi32 (__m256i __W, __mmask8 __U,
-			  __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpwsud_v8si_mask ((__v8si) __W,
-				       (__v8si) __A,
-				       (__v8si) __B,
-				       (__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_dpwsud_epi32 (__mmask8 __U, __m256i __W,
-			   __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpwsud_v8si_maskz ((__v8si) __W,
-					(__v8si) __A,
-					(__v8si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_dpwsuds_epi32 (__m256i __W, __mmask8 __U,
-			   __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpwsuds_v8si_mask ((__v8si) __W,
-					(__v8si) __A,
-					(__v8si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_dpwsuds_epi32 (__mmask8 __U, __m256i __W,
-			    __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpwsuds_v8si_maskz ((__v8si) __W,
-					 (__v8si) __A,
-					 (__v8si) __B,
-					 (__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_dpwusd_epi32 (__m256i __W, __mmask8 __U,
-			  __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpwusd_v8si_mask ((__v8si) __W,
-				       (__v8si) __A,
-				       (__v8si) __B,
-				       (__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_dpwusd_epi32 (__mmask8 __U, __m256i __W,
-			   __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpwusd_v8si_maskz ((__v8si) __W,
-					(__v8si) __A,
-					(__v8si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_dpwusds_epi32 (__m256i __W, __mmask8 __U,
-			   __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpwusds_v8si_mask ((__v8si) __W,
-					(__v8si) __A,
-					(__v8si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_dpwusds_epi32 (__mmask8 __U, __m256i __W,
-			    __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpwusds_v8si_maskz ((__v8si) __W,
-					 (__v8si) __A,
-					 (__v8si) __B,
-					 (__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_dpwuud_epi32 (__m256i __W, __mmask8 __U,
-			  __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpwuud_v8si_mask ((__v8si) __W,
-				       (__v8si) __A,
-				       (__v8si) __B,
-				       (__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_dpwuud_epi32 (__mmask8 __U, __m256i __W,
-			   __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpwuud_v8si_maskz ((__v8si) __W,
-					(__v8si) __A,
-					(__v8si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_mask_dpwuuds_epi32 (__m256i __W, __mmask8 __U,
-			   __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpwuuds_v8si_mask ((__v8si) __W,
-					(__v8si) __A,
-					(__v8si) __B,
-					(__mmask8) __U);
-}
-
-extern __inline __m256i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_dpwuuds_epi32 (__mmask8 __U, __m256i __W,
-			    __m256i __A, __m256i __B)
-{
-  return (__m256i)
-    __builtin_ia32_vpdpwuuds_v8si_maskz ((__v8si) __W,
-					 (__v8si) __A,
-					 (__v8si) __B,
-					 (__mmask8) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_dpwsud_epi32 (__m512i __W, __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwsud512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_dpwsud_epi32 (__m512i __W, __mmask16 __U,
-			  __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwsud_v16si_mask ((__v16si) __W,
-					(__v16si) __A,
-					(__v16si) __B,
-					(__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_dpwsud_epi32 (__mmask16 __U, __m512i __W,
-			   __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwsud_v16si_maskz ((__v16si) __W,
-					 (__v16si) __A,
-					 (__v16si) __B,
-					 (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_dpwsuds_epi32 (__m512i __W, __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwsuds512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_dpwsuds_epi32 (__m512i __W, __mmask16 __U,
-			   __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwsuds_v16si_mask ((__v16si) __W,
-					 (__v16si) __A,
-					 (__v16si) __B,
-					 (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_dpwsuds_epi32 (__mmask16 __U, __m512i __W,
-			    __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwsuds_v16si_maskz ((__v16si) __W,
-					  (__v16si) __A,
-					  (__v16si) __B,
-					  (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_dpwusd_epi32 (__m512i __W, __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwusd512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_dpwusd_epi32 (__m512i __W, __mmask16 __U,
-			  __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwusd_v16si_mask ((__v16si) __W,
-					(__v16si) __A,
-					(__v16si) __B,
-					(__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_dpwusd_epi32 (__mmask16 __U, __m512i __W,
-			   __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwusd_v16si_maskz ((__v16si) __W,
-					 (__v16si) __A,
-					 (__v16si) __B,
-					 (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_dpwusds_epi32 (__m512i __W, __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwusds512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_dpwusds_epi32 (__m512i __W, __mmask16 __U,
-			   __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwusds_v16si_mask ((__v16si) __W,
-					 (__v16si) __A,
-					 (__v16si) __B,
-					 (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_dpwusds_epi32 (__mmask16 __U, __m512i __W,
-			    __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwusds_v16si_maskz ((__v16si) __W,
-					  (__v16si) __A,
-					  (__v16si) __B,
-					  (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_dpwuud_epi32 (__m512i __W, __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwuud512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_dpwuud_epi32 (__m512i __W, __mmask16 __U,
-			  __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwuud_v16si_mask ((__v16si) __W,
-					(__v16si) __A,
-					(__v16si) __B,
-					(__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_dpwuud_epi32 (__mmask16 __U, __m512i __W,
-			   __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwuud_v16si_maskz ((__v16si) __W,
-					 (__v16si) __A,
-					 (__v16si) __B,
-					 (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_dpwuuds_epi32 (__m512i __W, __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwuuds512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_mask_dpwuuds_epi32 (__m512i __W, __mmask16 __U,
-			   __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwuuds_v16si_mask ((__v16si) __W,
-					 (__v16si) __A,
-					 (__v16si) __B,
-					 (__mmask16) __U);
-}
-
-extern __inline __m512i
-__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_dpwuuds_epi32 (__mmask16 __U, __m512i __W,
-			    __m512i __A, __m512i __B)
-{
-  return (__m512i)
-    __builtin_ia32_vpdpwuuds_v16si_maskz ((__v16si) __W,
-					  (__v16si) __A,
-					  (__v16si) __B,
-					  (__mmask16) __U);
-}
-
 extern __inline __m512
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
 _mm512_dpph_ps (__m512 __W, __m512h __A, __m512h __B)
diff --git a/gcc/config/i386/avx10v1auxintrin.h b/gcc/config/i386/avx10v1auxintrin.h
index 9929e926ba07..61bf6c02e60e 100644
--- a/gcc/config/i386/avx10v1auxintrin.h
+++ b/gcc/config/i386/avx10v1auxintrin.h
@@ -1419,6 +1419,1038 @@ _mm512_maskz_cvtx_round2ps_ph (__mmask32 __U, __m512 __A,
 						       (R)))
 #endif  /* __OPTIMIZE__  */

+#define _mm_dpbssd_epi32(W, A, B) \
+  (__m128i) __builtin_ia32_vpdpbssd128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
+
+#define _mm_dpbssds_epi32(W, A, B) \
+  (__m128i) __builtin_ia32_vpdpbssds128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
+
+#define _mm_dpbsud_epi32(W, A, B) \
+  (__m128i) __builtin_ia32_vpdpbsud128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
+
+#define _mm_dpbsuds_epi32(W, A, B) \
+  (__m128i) __builtin_ia32_vpdpbsuds128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
+
+#define _mm_dpbuud_epi32(W, A, B) \
+  (__m128i) __builtin_ia32_vpdpbuud128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
+
+#define _mm_dpbuuds_epi32(W, A, B) \
+  (__m128i) __builtin_ia32_vpdpbuuds128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
+
+#define _mm256_dpbssd_epi32(W, A, B) \
+  (__m256i) __builtin_ia32_vpdpbssd256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
+
+#define _mm256_dpbssds_epi32(W, A, B) \
+  (__m256i) __builtin_ia32_vpdpbssds256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
+
+#define _mm256_dpbsud_epi32(W, A, B) \
+  (__m256i) __builtin_ia32_vpdpbsud256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
+
+#define _mm256_dpbsuds_epi32(W, A, B) \
+  (__m256i) __builtin_ia32_vpdpbsuds256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
+
+#define _mm256_dpbuud_epi32(W, A, B) \
+  (__m256i) __builtin_ia32_vpdpbuud256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
+
+#define _mm256_dpbuuds_epi32(W, A, B) \
+  (__m256i) __builtin_ia32_vpdpbuuds256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
+
+#define _mm_dpwsud_epi32(W, A, B) \
+  (__m128i) __builtin_ia32_vpdpwsud128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
+
+#define _mm_dpwsuds_epi32(W, A, B) \
+  (__m128i) __builtin_ia32_vpdpwsuds128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
+
+#define _mm_dpwusd_epi32(W, A, B) \
+  (__m128i) __builtin_ia32_vpdpwusd128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
+
+#define _mm_dpwusds_epi32(W, A, B) \
+  (__m128i) __builtin_ia32_vpdpwusds128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
+
+#define _mm_dpwuud_epi32(W, A, B) \
+  (__m128i) __builtin_ia32_vpdpwuud128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
+
+#define _mm_dpwuuds_epi32(W, A, B) \
+  (__m128i) __builtin_ia32_vpdpwuuds128 ((__v4si) (W), (__v4si) (A), (__v4si) (B))
+
+#define _mm256_dpwsud_epi32(W, A, B) \
+  (__m256i) __builtin_ia32_vpdpwsud256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
+
+#define _mm256_dpwsuds_epi32(W, A, B) \
+  (__m256i) __builtin_ia32_vpdpwsuds256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
+
+#define _mm256_dpwusd_epi32(W, A, B) \
+  (__m256i) __builtin_ia32_vpdpwusd256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
+
+#define _mm256_dpwusds_epi32(W, A, B) \
+  (__m256i) __builtin_ia32_vpdpwusds256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
+
+#define _mm256_dpwuud_epi32(W, A, B) \
+  (__m256i) __builtin_ia32_vpdpwuud256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
+
+#define _mm256_dpwuuds_epi32(W, A, B) \
+  (__m256i) __builtin_ia32_vpdpwuuds256 ((__v8si) (W), (__v8si) (A), (__v8si) (B))
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_dpbssd_epi32 (__m128i __W, __mmask8 __U,
+		       __m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpbssd_v4si_mask ((__v4si) __W,
+				       (__v4si) __A,
+				       (__v4si) __B,
+				       (__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_dpbssd_epi32 (__mmask8 __U, __m128i __W,
+			__m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpbssd_v4si_maskz ((__v4si) __W,
+					(__v4si) __A,
+					(__v4si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_dpbssds_epi32 (__m128i __W, __mmask8 __U,
+			__m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpbssds_v4si_mask ((__v4si) __W,
+					(__v4si) __A,
+					(__v4si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_dpbssds_epi32 (__mmask8 __U, __m128i __W,
+			 __m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpbssds_v4si_maskz ((__v4si) __W,
+					 (__v4si) __A,
+					 (__v4si) __B,
+					 (__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_dpbsud_epi32 (__m128i __W, __mmask8 __U,
+		       __m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpbsud_v4si_mask ((__v4si) __W,
+				       (__v4si) __A,
+				       (__v4si) __B,
+				       (__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_dpbsud_epi32 (__mmask8 __U, __m128i __W,
+			__m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpbsud_v4si_maskz ((__v4si) __W,
+					(__v4si) __A,
+					(__v4si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_dpbsuds_epi32 (__m128i __W, __mmask8 __U,
+			__m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpbsuds_v4si_mask ((__v4si) __W,
+					(__v4si) __A,
+					(__v4si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_dpbsuds_epi32 (__mmask8 __U, __m128i __W,
+			 __m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpbsuds_v4si_maskz ((__v4si) __W,
+					 (__v4si) __A,
+					 (__v4si) __B,
+					 (__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_dpbuud_epi32 (__m128i __W, __mmask8 __U,
+		       __m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpbuud_v4si_mask ((__v4si) __W,
+				       (__v4si) __A,
+				       (__v4si) __B,
+				       (__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_dpbuud_epi32 (__mmask8 __U, __m128i __W,
+			__m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpbuud_v4si_maskz ((__v4si) __W,
+					(__v4si) __A,
+					(__v4si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_dpbuuds_epi32 (__m128i __W, __mmask8 __U,
+			__m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpbuuds_v4si_mask ((__v4si) __W,
+					(__v4si) __A,
+					(__v4si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_dpbuuds_epi32 (__mmask8 __U, __m128i __W,
+			 __m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpbuuds_v4si_maskz ((__v4si) __W,
+					 (__v4si) __A,
+					 (__v4si) __B,
+					 (__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_dpbssd_epi32 (__m256i __W, __mmask8 __U,
+			  __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpbssd_v8si_mask ((__v8si) __W,
+				       (__v8si) __A,
+				       (__v8si) __B,
+				       (__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_dpbssd_epi32 (__mmask8 __U, __m256i __W,
+			   __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpbssd_v8si_maskz ((__v8si) __W,
+					(__v8si) __A,
+					(__v8si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_dpbssds_epi32 (__m256i __W, __mmask8 __U,
+			   __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpbssds_v8si_mask ((__v8si) __W,
+					(__v8si) __A,
+					(__v8si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_dpbssds_epi32 (__mmask8 __U, __m256i __W,
+			    __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpbssds_v8si_maskz ((__v8si) __W,
+					 (__v8si) __A,
+					 (__v8si) __B,
+					 (__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_dpbsud_epi32 (__m256i __W, __mmask8 __U,
+			  __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpbsud_v8si_mask ((__v8si) __W,
+				       (__v8si) __A,
+				       (__v8si) __B,
+				       (__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_dpbsud_epi32 (__mmask8 __U, __m256i __W,
+			   __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpbsud_v8si_maskz ((__v8si) __W,
+					(__v8si) __A,
+					(__v8si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_dpbsuds_epi32 (__m256i __W, __mmask8 __U,
+			   __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpbsuds_v8si_mask ((__v8si) __W,
+					(__v8si) __A,
+					(__v8si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_dpbsuds_epi32 (__mmask8 __U, __m256i __W,
+			    __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpbsuds_v8si_maskz ((__v8si) __W,
+					 (__v8si) __A,
+					 (__v8si) __B,
+					 (__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_dpbuud_epi32 (__m256i __W, __mmask8 __U,
+			  __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpbuud_v8si_mask ((__v8si) __W,
+				       (__v8si) __A,
+				       (__v8si) __B,
+				       (__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_dpbuud_epi32 (__mmask8 __U, __m256i __W,
+			   __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpbuud_v8si_maskz ((__v8si) __W,
+					(__v8si) __A,
+					(__v8si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_dpbuuds_epi32 (__m256i __W, __mmask8 __U,
+			   __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpbuuds_v8si_mask ((__v8si) __W,
+					(__v8si) __A,
+					(__v8si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_dpbuuds_epi32 (__mmask8 __U, __m256i __W,
+			    __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpbuuds_v8si_maskz ((__v8si) __W,
+					 (__v8si) __A,
+					 (__v8si) __B,
+					 (__mmask8) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_dpbssd_epi32 (__m512i __W, __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbssd512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_dpbssd_epi32 (__m512i __W, __mmask16 __U,
+			  __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbssd_v16si_mask ((__v16si) __W,
+					(__v16si) __A,
+					(__v16si) __B,
+					(__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_dpbssd_epi32 (__mmask16 __U, __m512i __W,
+			   __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbssd_v16si_maskz ((__v16si) __W,
+					 (__v16si) __A,
+					 (__v16si) __B,
+					 (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_dpbssds_epi32 (__m512i __W, __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbssds512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_dpbssds_epi32 (__m512i __W, __mmask16 __U,
+			   __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbssds_v16si_mask ((__v16si) __W,
+					 (__v16si) __A,
+					 (__v16si) __B,
+					 (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_dpbssds_epi32 (__mmask16 __U, __m512i __W,
+			    __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbssds_v16si_maskz ((__v16si) __W,
+					  (__v16si) __A,
+					  (__v16si) __B,
+					  (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_dpbsud_epi32 (__m512i __W, __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbsud512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_dpbsud_epi32 (__m512i __W, __mmask16 __U,
+			  __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbsud_v16si_mask ((__v16si) __W,
+					(__v16si) __A,
+					(__v16si) __B,
+					(__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_dpbsud_epi32 (__mmask16 __U, __m512i __W,
+			   __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbsud_v16si_maskz ((__v16si) __W,
+					 (__v16si) __A,
+					 (__v16si) __B,
+					 (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_dpbsuds_epi32 (__m512i __W, __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbsuds512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_dpbsuds_epi32 (__m512i __W, __mmask16 __U,
+			   __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbsuds_v16si_mask ((__v16si) __W,
+					 (__v16si) __A,
+					 (__v16si) __B,
+					 (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_dpbsuds_epi32 (__mmask16 __U, __m512i __W,
+			    __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbsuds_v16si_maskz ((__v16si) __W,
+					  (__v16si) __A,
+					  (__v16si) __B,
+					  (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_dpbuud_epi32 (__m512i __W, __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbuud512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_dpbuud_epi32 (__m512i __W, __mmask16 __U,
+			  __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbuud_v16si_mask ((__v16si) __W,
+					(__v16si) __A,
+					(__v16si) __B,
+					(__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_dpbuud_epi32 (__mmask16 __U, __m512i __W,
+			   __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbuud_v16si_maskz ((__v16si) __W,
+					 (__v16si) __A,
+					 (__v16si) __B,
+					 (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_dpbuuds_epi32 (__m512i __W, __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbuuds512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_dpbuuds_epi32 (__m512i __W, __mmask16 __U,
+			   __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbuuds_v16si_mask ((__v16si) __W,
+					 (__v16si) __A,
+					 (__v16si) __B,
+					 (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_dpbuuds_epi32 (__mmask16 __U, __m512i __W,
+			    __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpbuuds_v16si_maskz ((__v16si) __W,
+					  (__v16si) __A,
+					  (__v16si) __B,
+					  (__mmask16) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_dpwsud_epi32 (__m128i __W, __mmask8 __U,
+		       __m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpwsud_v4si_mask ((__v4si) __W,
+				       (__v4si) __A,
+				       (__v4si) __B,
+				       (__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_dpwsud_epi32 (__mmask8 __U, __m128i __W,
+			__m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpwsud_v4si_maskz ((__v4si) __W,
+					(__v4si) __A,
+					(__v4si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_dpwsuds_epi32 (__m128i __W, __mmask8 __U,
+			__m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpwsuds_v4si_mask ((__v4si) __W,
+					(__v4si) __A,
+					(__v4si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_dpwsuds_epi32 (__mmask8 __U, __m128i __W,
+			 __m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpwsuds_v4si_maskz ((__v4si) __W,
+					 (__v4si) __A,
+					 (__v4si) __B,
+					 (__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_dpwusd_epi32 (__m128i __W, __mmask8 __U,
+		       __m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpwusd_v4si_mask ((__v4si) __W,
+				       (__v4si) __A,
+				       (__v4si) __B,
+				       (__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_dpwusd_epi32 (__mmask8 __U, __m128i __W,
+			__m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpwusd_v4si_maskz ((__v4si) __W,
+					(__v4si) __A,
+					(__v4si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_dpwusds_epi32 (__m128i __W, __mmask8 __U,
+			__m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpwusds_v4si_mask ((__v4si) __W,
+					(__v4si) __A,
+					(__v4si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_dpwusds_epi32 (__mmask8 __U, __m128i __W,
+			 __m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpwusds_v4si_maskz ((__v4si) __W,
+					 (__v4si) __A,
+					 (__v4si) __B,
+					 (__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_dpwuud_epi32 (__m128i __W, __mmask8 __U,
+		       __m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpwuud_v4si_mask ((__v4si) __W,
+				       (__v4si) __A,
+				       (__v4si) __B,
+				       (__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_dpwuud_epi32 (__mmask8 __U, __m128i __W,
+			__m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpwuud_v4si_maskz ((__v4si) __W,
+					(__v4si) __A,
+					(__v4si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_mask_dpwuuds_epi32 (__m128i __W, __mmask8 __U,
+			__m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpwuuds_v4si_mask ((__v4si) __W,
+					(__v4si) __A,
+					(__v4si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m128i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_maskz_dpwuuds_epi32 (__mmask8 __U, __m128i __W,
+			 __m128i __A, __m128i __B)
+{
+  return (__m128i)
+    __builtin_ia32_vpdpwuuds_v4si_maskz ((__v4si) __W,
+					 (__v4si) __A,
+					 (__v4si) __B,
+					 (__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_dpwsud_epi32 (__m256i __W, __mmask8 __U,
+			  __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpwsud_v8si_mask ((__v8si) __W,
+				       (__v8si) __A,
+				       (__v8si) __B,
+				       (__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_dpwsud_epi32 (__mmask8 __U, __m256i __W,
+			   __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpwsud_v8si_maskz ((__v8si) __W,
+					(__v8si) __A,
+					(__v8si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_dpwsuds_epi32 (__m256i __W, __mmask8 __U,
+			   __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpwsuds_v8si_mask ((__v8si) __W,
+					(__v8si) __A,
+					(__v8si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_dpwsuds_epi32 (__mmask8 __U, __m256i __W,
+			    __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpwsuds_v8si_maskz ((__v8si) __W,
+					 (__v8si) __A,
+					 (__v8si) __B,
+					 (__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_dpwusd_epi32 (__m256i __W, __mmask8 __U,
+			  __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpwusd_v8si_mask ((__v8si) __W,
+				       (__v8si) __A,
+				       (__v8si) __B,
+				       (__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_dpwusd_epi32 (__mmask8 __U, __m256i __W,
+			   __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpwusd_v8si_maskz ((__v8si) __W,
+					(__v8si) __A,
+					(__v8si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_dpwusds_epi32 (__m256i __W, __mmask8 __U,
+			   __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpwusds_v8si_mask ((__v8si) __W,
+					(__v8si) __A,
+					(__v8si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_dpwusds_epi32 (__mmask8 __U, __m256i __W,
+			    __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpwusds_v8si_maskz ((__v8si) __W,
+					 (__v8si) __A,
+					 (__v8si) __B,
+					 (__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_dpwuud_epi32 (__m256i __W, __mmask8 __U,
+			  __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpwuud_v8si_mask ((__v8si) __W,
+				       (__v8si) __A,
+				       (__v8si) __B,
+				       (__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_dpwuud_epi32 (__mmask8 __U, __m256i __W,
+			   __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpwuud_v8si_maskz ((__v8si) __W,
+					(__v8si) __A,
+					(__v8si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_dpwuuds_epi32 (__m256i __W, __mmask8 __U,
+			   __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpwuuds_v8si_mask ((__v8si) __W,
+					(__v8si) __A,
+					(__v8si) __B,
+					(__mmask8) __U);
+}
+
+extern __inline __m256i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_maskz_dpwuuds_epi32 (__mmask8 __U, __m256i __W,
+			    __m256i __A, __m256i __B)
+{
+  return (__m256i)
+    __builtin_ia32_vpdpwuuds_v8si_maskz ((__v8si) __W,
+					 (__v8si) __A,
+					 (__v8si) __B,
+					 (__mmask8) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_dpwsud_epi32 (__m512i __W, __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwsud512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_dpwsud_epi32 (__m512i __W, __mmask16 __U,
+			  __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwsud_v16si_mask ((__v16si) __W,
+					(__v16si) __A,
+					(__v16si) __B,
+					(__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_dpwsud_epi32 (__mmask16 __U, __m512i __W,
+			   __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwsud_v16si_maskz ((__v16si) __W,
+					 (__v16si) __A,
+					 (__v16si) __B,
+					 (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_dpwsuds_epi32 (__m512i __W, __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwsuds512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_dpwsuds_epi32 (__m512i __W, __mmask16 __U,
+			   __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwsuds_v16si_mask ((__v16si) __W,
+					 (__v16si) __A,
+					 (__v16si) __B,
+					 (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_dpwsuds_epi32 (__mmask16 __U, __m512i __W,
+			    __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwsuds_v16si_maskz ((__v16si) __W,
+					  (__v16si) __A,
+					  (__v16si) __B,
+					  (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_dpwusd_epi32 (__m512i __W, __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwusd512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_dpwusd_epi32 (__m512i __W, __mmask16 __U,
+			  __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwusd_v16si_mask ((__v16si) __W,
+					(__v16si) __A,
+					(__v16si) __B,
+					(__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_dpwusd_epi32 (__mmask16 __U, __m512i __W,
+			   __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwusd_v16si_maskz ((__v16si) __W,
+					 (__v16si) __A,
+					 (__v16si) __B,
+					 (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_dpwusds_epi32 (__m512i __W, __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwusds512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_dpwusds_epi32 (__m512i __W, __mmask16 __U,
+			   __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwusds_v16si_mask ((__v16si) __W,
+					 (__v16si) __A,
+					 (__v16si) __B,
+					 (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_dpwusds_epi32 (__mmask16 __U, __m512i __W,
+			    __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwusds_v16si_maskz ((__v16si) __W,
+					  (__v16si) __A,
+					  (__v16si) __B,
+					  (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_dpwuud_epi32 (__m512i __W, __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwuud512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_dpwuud_epi32 (__m512i __W, __mmask16 __U,
+			  __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwuud_v16si_mask ((__v16si) __W,
+					(__v16si) __A,
+					(__v16si) __B,
+					(__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_dpwuud_epi32 (__mmask16 __U, __m512i __W,
+			   __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwuud_v16si_maskz ((__v16si) __W,
+					 (__v16si) __A,
+					 (__v16si) __B,
+					 (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_dpwuuds_epi32 (__m512i __W, __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwuuds512 ((__v16si) __W, (__v16si) __A, (__v16si) __B);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_dpwuuds_epi32 (__m512i __W, __mmask16 __U,
+			   __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwuuds_v16si_mask ((__v16si) __W,
+					 (__v16si) __A,
+					 (__v16si) __B,
+					 (__mmask16) __U);
+}
+
+extern __inline __m512i
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_dpwuuds_epi32 (__mmask16 __U, __m512i __W,
+			    __m512i __A, __m512i __B)
+{
+  return (__m512i)
+    __builtin_ia32_vpdpwuuds_v16si_maskz ((__v16si) __W,
+					  (__v16si) __A,
+					  (__v16si) __B,
+					  (__mmask16) __U);
+}
+
 #ifdef __DISABLE_AVX10V1AUX__
 #undef __DISABLE_AVX10V1AUX__
 #pragma GCC pop_options
diff --git a/gcc/config/i386/i386-builtin.def b/gcc/config/i386/i386-builtin.def
index fc8475b3e6a7..6afae026040e 100644
--- a/gcc/config/i386/i386-builtin.def
+++ b/gcc/config/i386/i386-builtin.def
@@ -2773,32 +2773,32 @@ BDESC (OPTION_MASK_ISA_AVX512VNNI | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_vpdpws
 BDESC (OPTION_MASK_ISA_AVX512VNNI | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_vpdpwssds_v4si_maskz, "__builtin_ia32_vpdpwssds_v4si_maskz", IX86_BUILTIN_VPDPWSSDSV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)

 /* AVXVNNIINT8 */
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssd_v8si, "__builtin_ia32_vpdpbssd256", IX86_BUILTIN_VPDPBSSDV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssds_v8si, "__builtin_ia32_vpdpbssds256", IX86_BUILTIN_VPDPBSSDSV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsud_v8si, "__builtin_ia32_vpdpbsud256", IX86_BUILTIN_VPDPBSUDV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsuds_v8si, "__builtin_ia32_vpdpbsuds256", IX86_BUILTIN_VPDPBSUDSV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuud_v8si, "__builtin_ia32_vpdpbuud256", IX86_BUILTIN_VPDPBUUDV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuuds_v8si, "__builtin_ia32_vpdpbuuds256", IX86_BUILTIN_VPDPBUUDSV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssd_v4si, "__builtin_ia32_vpdpbssd128", IX86_BUILTIN_VPDPBSSDV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssds_v4si, "__builtin_ia32_vpdpbssds128", IX86_BUILTIN_VPDPBSSDSV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsud_v4si, "__builtin_ia32_vpdpbsud128", IX86_BUILTIN_VPDPBSUDV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsuds_v4si, "__builtin_ia32_vpdpbsuds128", IX86_BUILTIN_VPDPBSUDSV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuud_v4si, "__builtin_ia32_vpdpbuud128", IX86_BUILTIN_VPDPBUUDV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuuds_v4si, "__builtin_ia32_vpdpbuuds128", IX86_BUILTIN_VPDPBUUDSV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssd_v8si, "__builtin_ia32_vpdpbssd256", IX86_BUILTIN_VPDPBSSDV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssds_v8si, "__builtin_ia32_vpdpbssds256", IX86_BUILTIN_VPDPBSSDSV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsud_v8si, "__builtin_ia32_vpdpbsud256", IX86_BUILTIN_VPDPBSUDV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsuds_v8si, "__builtin_ia32_vpdpbsuds256", IX86_BUILTIN_VPDPBSUDSV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuud_v8si, "__builtin_ia32_vpdpbuud256", IX86_BUILTIN_VPDPBUUDV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuuds_v8si, "__builtin_ia32_vpdpbuuds256", IX86_BUILTIN_VPDPBUUDSV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssd_v4si, "__builtin_ia32_vpdpbssd128", IX86_BUILTIN_VPDPBSSDV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssds_v4si, "__builtin_ia32_vpdpbssds128", IX86_BUILTIN_VPDPBSSDSV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsud_v4si, "__builtin_ia32_vpdpbsud128", IX86_BUILTIN_VPDPBSUDV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsuds_v4si, "__builtin_ia32_vpdpbsuds128", IX86_BUILTIN_VPDPBSUDSV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuud_v4si, "__builtin_ia32_vpdpbuud128", IX86_BUILTIN_VPDPBUUDV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuuds_v4si, "__builtin_ia32_vpdpbuuds128", IX86_BUILTIN_VPDPBUUDSV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)

 /* AVXVNNIINT16 */
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusd_v8si, "__builtin_ia32_vpdpwusd256", IX86_BUILTIN_VPDPWUSDV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusds_v8si, "__builtin_ia32_vpdpwusds256", IX86_BUILTIN_VPDPWUSDSV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsud_v8si, "__builtin_ia32_vpdpwsud256", IX86_BUILTIN_VPDPWSUDV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsuds_v8si, "__builtin_ia32_vpdpwsuds256", IX86_BUILTIN_VPDPWSUDSV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuud_v8si, "__builtin_ia32_vpdpwuud256", IX86_BUILTIN_VPDPWUUDV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuuds_v8si, "__builtin_ia32_vpdpwuuds256", IX86_BUILTIN_VPDPWUUDSV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusd_v4si, "__builtin_ia32_vpdpwusd128", IX86_BUILTIN_VPDPWUSDV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusds_v4si, "__builtin_ia32_vpdpwusds128", IX86_BUILTIN_VPDPWUSDSV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsud_v4si, "__builtin_ia32_vpdpwsud128", IX86_BUILTIN_VPDPWSUDV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsuds_v4si, "__builtin_ia32_vpdpwsuds128", IX86_BUILTIN_VPDPWSUDSV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuud_v4si, "__builtin_ia32_vpdpwuud128", IX86_BUILTIN_VPDPWUUDV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
-BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuuds_v4si, "__builtin_ia32_vpdpwuuds128", IX86_BUILTIN_VPDPWUUDSV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusd_v8si, "__builtin_ia32_vpdpwusd256", IX86_BUILTIN_VPDPWUSDV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusds_v8si, "__builtin_ia32_vpdpwusds256", IX86_BUILTIN_VPDPWUSDSV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsud_v8si, "__builtin_ia32_vpdpwsud256", IX86_BUILTIN_VPDPWSUDV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsuds_v8si, "__builtin_ia32_vpdpwsuds256", IX86_BUILTIN_VPDPWSUDSV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuud_v8si, "__builtin_ia32_vpdpwuud256", IX86_BUILTIN_VPDPWUUDV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuuds_v8si, "__builtin_ia32_vpdpwuuds256", IX86_BUILTIN_VPDPWUUDSV8SI, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusd_v4si, "__builtin_ia32_vpdpwusd128", IX86_BUILTIN_VPDPWUSDV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusds_v4si, "__builtin_ia32_vpdpwusds128", IX86_BUILTIN_VPDPWUSDSV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsud_v4si, "__builtin_ia32_vpdpwsud128", IX86_BUILTIN_VPDPWSUDV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsuds_v4si, "__builtin_ia32_vpdpwsuds128", IX86_BUILTIN_VPDPWSUDSV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuud_v4si, "__builtin_ia32_vpdpwuud128", IX86_BUILTIN_VPDPWUUDV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)
+BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuuds_v4si, "__builtin_ia32_vpdpwuuds128", IX86_BUILTIN_VPDPWUUDSV4SI, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI)

 /* VPCLMULQDQ */
 BDESC (OPTION_MASK_ISA_VPCLMULQDQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_vpclmulqdq_v2di, "__builtin_ia32_vpclmulqdq_v2di", IX86_BUILTIN_VPCLMULQDQ2, UNKNOWN, (int) V2DI_FTYPE_V2DI_V2DI_INT)
@@ -3054,90 +3054,90 @@ BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512vl_
 BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512vl_fmulc_v16hf_mask, "__builtin_ia32_vfmulcph256_mask", IX86_BUILTIN_VFMULCPH256_MASK, UNKNOWN, (int) V16HF_FTYPE_V16HF_V16HF_V16HF_UQI)

 /* AVX10.2.  */
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssd_v16si, "__builtin_ia32_vpdpbssd512", IX86_BUILTIN_VPDPBSSDV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssds_v16si, "__builtin_ia32_vpdpbssds512", IX86_BUILTIN_VPDPBSSDSV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsud_v16si, "__builtin_ia32_vpdpbsud512", IX86_BUILTIN_VPDPBSUDV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsuds_v16si, "__builtin_ia32_vpdpbsuds512", IX86_BUILTIN_VPDPBSUDSV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuud_v16si, "__builtin_ia32_vpdpbuud512", IX86_BUILTIN_VPDPBUUDV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuuds_v16si, "__builtin_ia32_vpdpbuuds512", IX86_BUILTIN_VPDPBUUDSV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssd_v16si_mask, "__builtin_ia32_vpdpbssd_v16si_mask", IX86_BUILTIN_VPDPBSSDV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssd_v16si_maskz, "__builtin_ia32_vpdpbssd_v16si_maskz", IX86_BUILTIN_VPDPBSSDV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssds_v16si_mask, "__builtin_ia32_vpdpbssds_v16si_mask", IX86_BUILTIN_VPDPBSSDSV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssds_v16si_maskz, "__builtin_ia32_vpdpbssds_v16si_maskz", IX86_BUILTIN_VPDPBSSDSV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsud_v16si_mask, "__builtin_ia32_vpdpbsud_v16si_mask", IX86_BUILTIN_VPDPBSUDV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsud_v16si_maskz, "__builtin_ia32_vpdpbsud_v16si_maskz", IX86_BUILTIN_VPDPBSUDV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsuds_v16si_mask, "__builtin_ia32_vpdpbsuds_v16si_mask", IX86_BUILTIN_VPDPBSUDSV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsuds_v16si_maskz, "__builtin_ia32_vpdpbsuds_v16si_maskz", IX86_BUILTIN_VPDPBSUDSV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuud_v16si_mask, "__builtin_ia32_vpdpbuud_v16si_mask", IX86_BUILTIN_VPDPBUUDV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuud_v16si_maskz, "__builtin_ia32_vpdpbuud_v16si_maskz", IX86_BUILTIN_VPDPBUUDV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuuds_v16si_mask, "__builtin_ia32_vpdpbuuds_v16si_mask", IX86_BUILTIN_VPDPBUUDSV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuuds_v16si_maskz, "__builtin_ia32_vpdpbuuds_v16si_maskz", IX86_BUILTIN_VPDPBUUDSV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssd_v8si_mask, "__builtin_ia32_vpdpbssd_v8si_mask", IX86_BUILTIN_VPDPBSSDV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssd_v8si_maskz, "__builtin_ia32_vpdpbssd_v8si_maskz", IX86_BUILTIN_VPDPBSSDV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssds_v8si_mask, "__builtin_ia32_vpdpbssds_v8si_mask", IX86_BUILTIN_VPDPBSSDSV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssds_v8si_maskz, "__builtin_ia32_vpdpbssds_v8si_maskz", IX86_BUILTIN_VPDPBSSDSV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsud_v8si_mask, "__builtin_ia32_vpdpbsud_v8si_mask", IX86_BUILTIN_VPDPBSUDV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsud_v8si_maskz, "__builtin_ia32_vpdpbsud_v8si_maskz", IX86_BUILTIN_VPDPBSUDV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsuds_v8si_mask, "__builtin_ia32_vpdpbsuds_v8si_mask", IX86_BUILTIN_VPDPBSUDSV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsuds_v8si_maskz, "__builtin_ia32_vpdpbsuds_v8si_maskz", IX86_BUILTIN_VPDPBSUDSV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuud_v8si_mask, "__builtin_ia32_vpdpbuud_v8si_mask", IX86_BUILTIN_VPDPBUUDV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuud_v8si_maskz, "__builtin_ia32_vpdpbuud_v8si_maskz", IX86_BUILTIN_VPDPBUUDV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuuds_v8si_mask, "__builtin_ia32_vpdpbuuds_v8si_mask", IX86_BUILTIN_VPDPBUUDSV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuuds_v8si_maskz, "__builtin_ia32_vpdpbuuds_v8si_maskz", IX86_BUILTIN_VPDPBUUDSV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssd_v4si_mask, "__builtin_ia32_vpdpbssd_v4si_mask", IX86_BUILTIN_VPDPBSSDV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssd_v4si_maskz, "__builtin_ia32_vpdpbssd_v4si_maskz", IX86_BUILTIN_VPDPBSSDV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssds_v4si_mask, "__builtin_ia32_vpdpbssds_v4si_mask", IX86_BUILTIN_VPDPBSSDSV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssds_v4si_maskz, "__builtin_ia32_vpdpbssds_v4si_maskz", IX86_BUILTIN_VPDPBSSDSV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsud_v4si_mask, "__builtin_ia32_vpdpbsud_v4si_mask", IX86_BUILTIN_VPDPBSUDV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsud_v4si_maskz, "__builtin_ia32_vpdpbsud_v4si_maskz", IX86_BUILTIN_VPDPBSUDV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsuds_v4si_mask, "__builtin_ia32_vpdpbsuds_v4si_mask", IX86_BUILTIN_VPDPBSUDSV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsuds_v4si_maskz, "__builtin_ia32_vpdpbsuds_v4si_maskz", IX86_BUILTIN_VPDPBSUDSV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuud_v4si_mask, "__builtin_ia32_vpdpbuud_v4si_mask", IX86_BUILTIN_VPDPBUUDV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuud_v4si_maskz, "__builtin_ia32_vpdpbuud_v4si_maskz", IX86_BUILTIN_VPDPBUUDV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuuds_v4si_mask, "__builtin_ia32_vpdpbuuds_v4si_mask", IX86_BUILTIN_VPDPBUUDSV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuuds_v4si_maskz, "__builtin_ia32_vpdpbuuds_v4si_maskz", IX86_BUILTIN_VPDPBUUDSV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsud_v16si, "__builtin_ia32_vpdpwsud512", IX86_BUILTIN_VPDPWSUDV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsuds_v16si, "__builtin_ia32_vpdpwsuds512", IX86_BUILTIN_VPDPWSUDSV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusd_v16si, "__builtin_ia32_vpdpwusd512", IX86_BUILTIN_VPDPWUSDV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusds_v16si, "__builtin_ia32_vpdpwusds512", IX86_BUILTIN_VPDPWUSDSV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuud_v16si, "__builtin_ia32_vpdpwuud512", IX86_BUILTIN_VPDPWUUDV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuuds_v16si, "__builtin_ia32_vpdpwuuds512", IX86_BUILTIN_VPDPWUUDSV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsud_v16si_mask, "__builtin_ia32_vpdpwsud_v16si_mask", IX86_BUILTIN_VPDPWSUDV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsud_v16si_maskz, "__builtin_ia32_vpdpwsud_v16si_maskz", IX86_BUILTIN_VPDPWSUDV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsuds_v16si_mask, "__builtin_ia32_vpdpwsuds_v16si_mask", IX86_BUILTIN_VPDPWSUDSV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsuds_v16si_maskz, "__builtin_ia32_vpdpwsuds_v16si_maskz", IX86_BUILTIN_VPDPWSUDSV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusd_v16si_mask, "__builtin_ia32_vpdpwusd_v16si_mask", IX86_BUILTIN_VPDPWUSDV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusd_v16si_maskz, "__builtin_ia32_vpdpwusd_v16si_maskz", IX86_BUILTIN_VPDPWUSDV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusds_v16si_mask, "__builtin_ia32_vpdpwusds_v16si_mask", IX86_BUILTIN_VPDPWUSDSV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusds_v16si_maskz, "__builtin_ia32_vpdpwusds_v16si_maskz", IX86_BUILTIN_VPDPWUSDSV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuud_v16si_mask, "__builtin_ia32_vpdpwuud_v16si_mask", IX86_BUILTIN_VPDPWUUDV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuud_v16si_maskz, "__builtin_ia32_vpdpwuud_v16si_maskz", IX86_BUILTIN_VPDPWUUDV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuuds_v16si_mask, "__builtin_ia32_vpdpwuuds_v16si_mask", IX86_BUILTIN_VPDPWUUDSV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuuds_v16si_maskz, "__builtin_ia32_vpdpwuuds_v16si_maskz", IX86_BUILTIN_VPDPWUUDSV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsud_v8si_mask, "__builtin_ia32_vpdpwsud_v8si_mask", IX86_BUILTIN_VPDPWSUDV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsud_v8si_maskz, "__builtin_ia32_vpdpwsud_v8si_maskz", IX86_BUILTIN_VPDPWSUDV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsuds_v8si_mask, "__builtin_ia32_vpdpwsuds_v8si_mask", IX86_BUILTIN_VPDPWSUDSV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsuds_v8si_maskz, "__builtin_ia32_vpdpwsuds_v8si_maskz", IX86_BUILTIN_VPDPWSUDSV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusd_v8si_mask, "__builtin_ia32_vpdpwusd_v8si_mask", IX86_BUILTIN_VPDPWUSDV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusd_v8si_maskz, "__builtin_ia32_vpdpwusd_v8si_maskz", IX86_BUILTIN_VPDPWUSDV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusds_v8si_mask, "__builtin_ia32_vpdpwusds_v8si_mask", IX86_BUILTIN_VPDPWUSDSV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusds_v8si_maskz, "__builtin_ia32_vpdpwusds_v8si_maskz", IX86_BUILTIN_VPDPWUSDSV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuud_v8si_mask, "__builtin_ia32_vpdpwuud_v8si_mask", IX86_BUILTIN_VPDPWUUDV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuud_v8si_maskz, "__builtin_ia32_vpdpwuud_v8si_maskz", IX86_BUILTIN_VPDPWUUDV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuuds_v8si_mask, "__builtin_ia32_vpdpwuuds_v8si_mask", IX86_BUILTIN_VPDPWUUDSV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuuds_v8si_maskz, "__builtin_ia32_vpdpwuuds_v8si_maskz", IX86_BUILTIN_VPDPWUUDSV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsud_v4si_mask, "__builtin_ia32_vpdpwsud_v4si_mask", IX86_BUILTIN_VPDPWSUDV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsud_v4si_maskz, "__builtin_ia32_vpdpwsud_v4si_maskz", IX86_BUILTIN_VPDPWSUDV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsuds_v4si_mask, "__builtin_ia32_vpdpwsuds_v4si_mask", IX86_BUILTIN_VPDPWSUDSV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsuds_v4si_maskz, "__builtin_ia32_vpdpwsuds_v4si_maskz", IX86_BUILTIN_VPDPWSUDSV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusd_v4si_mask, "__builtin_ia32_vpdpwusd_v4si_mask", IX86_BUILTIN_VPDPWUSDV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusd_v4si_maskz, "__builtin_ia32_vpdpwusd_v4si_maskz", IX86_BUILTIN_VPDPWUSDV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusds_v4si_mask, "__builtin_ia32_vpdpwusds_v4si_mask", IX86_BUILTIN_VPDPWUSDSV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusds_v4si_maskz, "__builtin_ia32_vpdpwusds_v4si_maskz", IX86_BUILTIN_VPDPWUSDSV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuud_v4si_mask, "__builtin_ia32_vpdpwuud_v4si_mask", IX86_BUILTIN_VPDPWUUDV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuud_v4si_maskz, "__builtin_ia32_vpdpwuud_v4si_maskz", IX86_BUILTIN_VPDPWUUDV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuuds_v4si_mask, "__builtin_ia32_vpdpwuuds_v4si_mask", IX86_BUILTIN_VPDPWUUDSV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuuds_v4si_maskz, "__builtin_ia32_vpdpwuuds_v4si_maskz", IX86_BUILTIN_VPDPWUUDSV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssd_v16si, "__builtin_ia32_vpdpbssd512", IX86_BUILTIN_VPDPBSSDV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssds_v16si, "__builtin_ia32_vpdpbssds512", IX86_BUILTIN_VPDPBSSDSV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsud_v16si, "__builtin_ia32_vpdpbsud512", IX86_BUILTIN_VPDPBSUDV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsuds_v16si, "__builtin_ia32_vpdpbsuds512", IX86_BUILTIN_VPDPBSUDSV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuud_v16si, "__builtin_ia32_vpdpbuud512", IX86_BUILTIN_VPDPBUUDV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuuds_v16si, "__builtin_ia32_vpdpbuuds512", IX86_BUILTIN_VPDPBUUDSV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssd_v16si_mask, "__builtin_ia32_vpdpbssd_v16si_mask", IX86_BUILTIN_VPDPBSSDV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssd_v16si_maskz, "__builtin_ia32_vpdpbssd_v16si_maskz", IX86_BUILTIN_VPDPBSSDV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssds_v16si_mask, "__builtin_ia32_vpdpbssds_v16si_mask", IX86_BUILTIN_VPDPBSSDSV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssds_v16si_maskz, "__builtin_ia32_vpdpbssds_v16si_maskz", IX86_BUILTIN_VPDPBSSDSV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsud_v16si_mask, "__builtin_ia32_vpdpbsud_v16si_mask", IX86_BUILTIN_VPDPBSUDV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsud_v16si_maskz, "__builtin_ia32_vpdpbsud_v16si_maskz", IX86_BUILTIN_VPDPBSUDV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsuds_v16si_mask, "__builtin_ia32_vpdpbsuds_v16si_mask", IX86_BUILTIN_VPDPBSUDSV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsuds_v16si_maskz, "__builtin_ia32_vpdpbsuds_v16si_maskz", IX86_BUILTIN_VPDPBSUDSV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuud_v16si_mask, "__builtin_ia32_vpdpbuud_v16si_mask", IX86_BUILTIN_VPDPBUUDV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuud_v16si_maskz, "__builtin_ia32_vpdpbuud_v16si_maskz", IX86_BUILTIN_VPDPBUUDV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuuds_v16si_mask, "__builtin_ia32_vpdpbuuds_v16si_mask", IX86_BUILTIN_VPDPBUUDSV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuuds_v16si_maskz, "__builtin_ia32_vpdpbuuds_v16si_maskz", IX86_BUILTIN_VPDPBUUDSV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssd_v8si_mask, "__builtin_ia32_vpdpbssd_v8si_mask", IX86_BUILTIN_VPDPBSSDV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssd_v8si_maskz, "__builtin_ia32_vpdpbssd_v8si_maskz", IX86_BUILTIN_VPDPBSSDV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssds_v8si_mask, "__builtin_ia32_vpdpbssds_v8si_mask", IX86_BUILTIN_VPDPBSSDSV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssds_v8si_maskz, "__builtin_ia32_vpdpbssds_v8si_maskz", IX86_BUILTIN_VPDPBSSDSV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsud_v8si_mask, "__builtin_ia32_vpdpbsud_v8si_mask", IX86_BUILTIN_VPDPBSUDV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsud_v8si_maskz, "__builtin_ia32_vpdpbsud_v8si_maskz", IX86_BUILTIN_VPDPBSUDV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsuds_v8si_mask, "__builtin_ia32_vpdpbsuds_v8si_mask", IX86_BUILTIN_VPDPBSUDSV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsuds_v8si_maskz, "__builtin_ia32_vpdpbsuds_v8si_maskz", IX86_BUILTIN_VPDPBSUDSV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuud_v8si_mask, "__builtin_ia32_vpdpbuud_v8si_mask", IX86_BUILTIN_VPDPBUUDV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuud_v8si_maskz, "__builtin_ia32_vpdpbuud_v8si_maskz", IX86_BUILTIN_VPDPBUUDV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuuds_v8si_mask, "__builtin_ia32_vpdpbuuds_v8si_mask", IX86_BUILTIN_VPDPBUUDSV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuuds_v8si_maskz, "__builtin_ia32_vpdpbuuds_v8si_maskz", IX86_BUILTIN_VPDPBUUDSV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssd_v4si_mask, "__builtin_ia32_vpdpbssd_v4si_mask", IX86_BUILTIN_VPDPBSSDV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssd_v4si_maskz, "__builtin_ia32_vpdpbssd_v4si_maskz", IX86_BUILTIN_VPDPBSSDV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssds_v4si_mask, "__builtin_ia32_vpdpbssds_v4si_mask", IX86_BUILTIN_VPDPBSSDSV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssds_v4si_maskz, "__builtin_ia32_vpdpbssds_v4si_maskz", IX86_BUILTIN_VPDPBSSDSV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsud_v4si_mask, "__builtin_ia32_vpdpbsud_v4si_mask", IX86_BUILTIN_VPDPBSUDV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsud_v4si_maskz, "__builtin_ia32_vpdpbsud_v4si_maskz", IX86_BUILTIN_VPDPBSUDV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsuds_v4si_mask, "__builtin_ia32_vpdpbsuds_v4si_mask", IX86_BUILTIN_VPDPBSUDSV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsuds_v4si_maskz, "__builtin_ia32_vpdpbsuds_v4si_maskz", IX86_BUILTIN_VPDPBSUDSV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuud_v4si_mask, "__builtin_ia32_vpdpbuud_v4si_mask", IX86_BUILTIN_VPDPBUUDV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuud_v4si_maskz, "__builtin_ia32_vpdpbuud_v4si_maskz", IX86_BUILTIN_VPDPBUUDV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuuds_v4si_mask, "__builtin_ia32_vpdpbuuds_v4si_mask", IX86_BUILTIN_VPDPBUUDSV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuuds_v4si_maskz, "__builtin_ia32_vpdpbuuds_v4si_maskz", IX86_BUILTIN_VPDPBUUDSV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsud_v16si, "__builtin_ia32_vpdpwsud512", IX86_BUILTIN_VPDPWSUDV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsuds_v16si, "__builtin_ia32_vpdpwsuds512", IX86_BUILTIN_VPDPWSUDSV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusd_v16si, "__builtin_ia32_vpdpwusd512", IX86_BUILTIN_VPDPWUSDV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusds_v16si, "__builtin_ia32_vpdpwusds512", IX86_BUILTIN_VPDPWUSDSV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuud_v16si, "__builtin_ia32_vpdpwuud512", IX86_BUILTIN_VPDPWUUDV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuuds_v16si, "__builtin_ia32_vpdpwuuds512", IX86_BUILTIN_VPDPWUUDSV16SI, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsud_v16si_mask, "__builtin_ia32_vpdpwsud_v16si_mask", IX86_BUILTIN_VPDPWSUDV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsud_v16si_maskz, "__builtin_ia32_vpdpwsud_v16si_maskz", IX86_BUILTIN_VPDPWSUDV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsuds_v16si_mask, "__builtin_ia32_vpdpwsuds_v16si_mask", IX86_BUILTIN_VPDPWSUDSV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsuds_v16si_maskz, "__builtin_ia32_vpdpwsuds_v16si_maskz", IX86_BUILTIN_VPDPWSUDSV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusd_v16si_mask, "__builtin_ia32_vpdpwusd_v16si_mask", IX86_BUILTIN_VPDPWUSDV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusd_v16si_maskz, "__builtin_ia32_vpdpwusd_v16si_maskz", IX86_BUILTIN_VPDPWUSDV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusds_v16si_mask, "__builtin_ia32_vpdpwusds_v16si_mask", IX86_BUILTIN_VPDPWUSDSV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusds_v16si_maskz, "__builtin_ia32_vpdpwusds_v16si_maskz", IX86_BUILTIN_VPDPWUSDSV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuud_v16si_mask, "__builtin_ia32_vpdpwuud_v16si_mask", IX86_BUILTIN_VPDPWUUDV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuud_v16si_maskz, "__builtin_ia32_vpdpwuud_v16si_maskz", IX86_BUILTIN_VPDPWUUDV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuuds_v16si_mask, "__builtin_ia32_vpdpwuuds_v16si_mask", IX86_BUILTIN_VPDPWUUDSV16SI_MASK, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuuds_v16si_maskz, "__builtin_ia32_vpdpwuuds_v16si_maskz", IX86_BUILTIN_VPDPWUUDSV16SI_MASKZ, UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI_UHI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsud_v8si_mask, "__builtin_ia32_vpdpwsud_v8si_mask", IX86_BUILTIN_VPDPWSUDV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsud_v8si_maskz, "__builtin_ia32_vpdpwsud_v8si_maskz", IX86_BUILTIN_VPDPWSUDV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsuds_v8si_mask, "__builtin_ia32_vpdpwsuds_v8si_mask", IX86_BUILTIN_VPDPWSUDSV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsuds_v8si_maskz, "__builtin_ia32_vpdpwsuds_v8si_maskz", IX86_BUILTIN_VPDPWSUDSV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusd_v8si_mask, "__builtin_ia32_vpdpwusd_v8si_mask", IX86_BUILTIN_VPDPWUSDV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusd_v8si_maskz, "__builtin_ia32_vpdpwusd_v8si_maskz", IX86_BUILTIN_VPDPWUSDV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusds_v8si_mask, "__builtin_ia32_vpdpwusds_v8si_mask", IX86_BUILTIN_VPDPWUSDSV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusds_v8si_maskz, "__builtin_ia32_vpdpwusds_v8si_maskz", IX86_BUILTIN_VPDPWUSDSV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuud_v8si_mask, "__builtin_ia32_vpdpwuud_v8si_mask", IX86_BUILTIN_VPDPWUUDV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuud_v8si_maskz, "__builtin_ia32_vpdpwuud_v8si_maskz", IX86_BUILTIN_VPDPWUUDV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuuds_v8si_mask, "__builtin_ia32_vpdpwuuds_v8si_mask", IX86_BUILTIN_VPDPWUUDSV8SI_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuuds_v8si_maskz, "__builtin_ia32_vpdpwuuds_v8si_maskz", IX86_BUILTIN_VPDPWUUDSV8SI_MASKZ, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsud_v4si_mask, "__builtin_ia32_vpdpwsud_v4si_mask", IX86_BUILTIN_VPDPWSUDV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsud_v4si_maskz, "__builtin_ia32_vpdpwsud_v4si_maskz", IX86_BUILTIN_VPDPWSUDV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsuds_v4si_mask, "__builtin_ia32_vpdpwsuds_v4si_mask", IX86_BUILTIN_VPDPWSUDSV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsuds_v4si_maskz, "__builtin_ia32_vpdpwsuds_v4si_maskz", IX86_BUILTIN_VPDPWSUDSV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusd_v4si_mask, "__builtin_ia32_vpdpwusd_v4si_mask", IX86_BUILTIN_VPDPWUSDV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusd_v4si_maskz, "__builtin_ia32_vpdpwusd_v4si_maskz", IX86_BUILTIN_VPDPWUSDV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusds_v4si_mask, "__builtin_ia32_vpdpwusds_v4si_mask", IX86_BUILTIN_VPDPWUSDSV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusds_v4si_maskz, "__builtin_ia32_vpdpwusds_v4si_maskz", IX86_BUILTIN_VPDPWUSDSV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuud_v4si_mask, "__builtin_ia32_vpdpwuud_v4si_mask", IX86_BUILTIN_VPDPWUUDV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuud_v4si_maskz, "__builtin_ia32_vpdpwuud_v4si_maskz", IX86_BUILTIN_VPDPWUUDV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuuds_v4si_mask, "__builtin_ia32_vpdpwuuds_v4si_mask", IX86_BUILTIN_VPDPWUUDSV4SI_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
+BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuuds_v4si_maskz, "__builtin_ia32_vpdpwuuds_v4si_maskz", IX86_BUILTIN_VPDPWUUDSV4SI_MASKZ, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI_UQI)
 BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vdpphps_v16sf_mask, "__builtin_ia32_vdpphps512_mask", IX86_BUILTIN_VDPPHPS512_MASK, UNKNOWN, (int) V16SF_FTYPE_V16SF_V16SF_V16SF_UHI)
 BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vdpphps_v16sf_maskz, "__builtin_ia32_vdpphps512_maskz", IX86_BUILTIN_VDPPHPS512_MASKZ, UNKNOWN, (int) V16SF_FTYPE_V16SF_V16SF_V16SF_UHI)
 BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vdpphps_v8sf_mask, "__builtin_ia32_vdpphps256_mask", IX86_BUILTIN_VDPPHPS256_MASK, UNKNOWN, (int) V8SF_FTYPE_V8SF_V8SF_V8SF_UQI)
diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index a81993c29c52..285227a3f943 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -14995,8 +14995,8 @@ ix86_check_builtin_isa_match (unsigned int fcode,
      (OPTION_MASK_ISA_AVX512VL | OPTION_MASK_ISA2_AVX512BF16) or
        OPTION_MASK_ISA2_AVXNECONVERT
      OPTION_MASK_ISA_AES or (OPTION_MASK_ISA_AVX512VL | OPTION_MASK_ISA2_VAES)
-     OPTION_MASK_ISA2_AVX10_2 or OPTION_MASK_ISA2_AVXVNNIINT8
-     OPTION_MASK_ISA2_AVX10_2 or OPTION_MASK_ISA2_AVXVNNIINT16
+     OPTION_MASK_ISA2_AVX10V1AUX or OPTION_MASK_ISA2_AVXVNNIINT8
+     OPTION_MASK_ISA2_AVX10V1AUX or OPTION_MASK_ISA2_AVXVNNIINT16
      OPTION_MASK_ISA2_AMX_TILE or OPTION_MASK_ISA2_ACEV1
      where for each such pair it is sufficient if either of the ISAs is
      enabled, plus if it is ored with other options also those others.
@@ -15024,9 +15024,9 @@ ix86_check_builtin_isa_match (unsigned int fcode,
   SHARE_BUILTIN (OPTION_MASK_ISA_AES, 0, OPTION_MASK_ISA_AVX512VL,
 		 OPTION_MASK_ISA2_VAES);
   SHARE_BUILTIN (0, OPTION_MASK_ISA2_AVXVNNIINT8, 0,
-		 OPTION_MASK_ISA2_AVX10_2);
+		 OPTION_MASK_ISA2_AVX10V1AUX);
   SHARE_BUILTIN (0, OPTION_MASK_ISA2_AVXVNNIINT16, 0,
-		 OPTION_MASK_ISA2_AVX10_2);
+		 OPTION_MASK_ISA2_AVX10V1AUX);
   SHARE_BUILTIN (0, OPTION_MASK_ISA2_AMX_TILE, 0, OPTION_MASK_ISA2_ACEV1);
   isa = tmp_isa;
   isa2 = tmp_isa2;
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 2aad91ecf46e..21ef8d5b4b13 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -27092,8 +27092,8 @@ ix86_vector_costs::add_stmt_cost (int count, vect_cost_for_stmt kind,
 			/* vpdpbssd.  */
 			native_vnni_p
 			  = (GET_MODE_SIZE (mode) == 64
-			     ? TARGET_AVX10_2
-			     : (TARGET_AVXVNNIINT8 || TARGET_AVX10_2));
+			     ? TARGET_AVX10V1AUX
+			     : (TARGET_AVXVNNIINT8 || TARGET_AVX10V1AUX));
 		    }
 		  m_num_reduc[X86_REDUC_DOT_PROD] += count * scale;

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index d5b90291fc9c..1fff2f0a277c 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -613,7 +613,8 @@
 		    avx512bw,noavx512bw,avx512dq,noavx512dq,fma_or_avx512vl,
 		    avx512vl,noavx512vl,avxvnni,avxvnniint8,avx512vnnivl,avx512fp16,avxifma,
 		    avx512ifmavl,avxneconvert,avx512bf16vl,vpclmulqdqvl,
-		    avx_noavx512f,avx_noavx512vl,vaes_avx512vl,noapx_nf,avx10_2"
+		    avx_noavx512f,avx_noavx512vl,vaes_avx512vl,noapx_nf,avx10_2,
+		    avx10v1aux"
   (const_string "base"))

 ;; The (bounding maximum) length of an instruction immediate.
@@ -1015,6 +1016,7 @@
 	 (eq_attr "isa" "vaes_avx512vl")
 	   (symbol_ref "TARGET_VAES && TARGET_AVX512VL")
 	 (eq_attr "isa" "avx10_2") (symbol_ref "TARGET_AVX10_2")
+	 (eq_attr "isa" "avx10v1aux") (symbol_ref "TARGET_AVX10V1AUX")

 	 (eq_attr "mmx_isa" "native")
 	   (symbol_ref "!TARGET_MMX_WITH_SSE")
diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index a223acc606d7..b4a41d7abd53 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -695,8 +695,8 @@
 (define_mode_iterator VI2_AVX512F
   [(V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX2") V8HI])

-(define_mode_iterator VI2_AVX10_2
-  [(V32HI "TARGET_AVX10_2") (V16HI "TARGET_AVX2") V8HI])
+(define_mode_iterator VI2_AVX10V1AUX
+  [(V32HI "TARGET_AVX10V1AUX") (V16HI "TARGET_AVX2") V8HI])

 (define_mode_iterator VI2_AVX512VNNIBW
   [(V32HI "TARGET_AVX512BW || TARGET_AVX512VNNI")
@@ -717,6 +717,9 @@
 (define_mode_iterator VI4_AVX10_2
   [(V16SI "TARGET_AVX10_2") V8SI V4SI])

+(define_mode_iterator VI4_AVX10V1AUX
+  [(V16SI "TARGET_AVX10V1AUX") V8SI V4SI])
+
 (define_mode_iterator VI48_AVX512F_AVX512VL
   [V4SI V8SI (V16SI "TARGET_AVX512F")
    (V2DI "TARGET_AVX512VL") (V4DI "TARGET_AVX512VL")
@@ -33200,8 +33203,8 @@
    (match_operand: 3 "register_operand")]
   "TARGET_SSE2"
 {
-  if (( == 64 && TARGET_AVX10_2)
-      || ( < 64 && (TARGET_AVXVNNIINT8 || TARGET_AVX10_2)))
+  if (( == 64 && TARGET_AVX10V1AUX)
+      || ( < 64 && (TARGET_AVXVNNIINT8 || TARGET_AVX10V1AUX)))
     {
       operands[1] = lowpart_subreg (mode,
 				    force_reg (mode, operands[1]),
@@ -33248,8 +33251,8 @@
    (match_operand: 3 "register_operand")]
   "TARGET_SSE2"
 {
-  if (( == 64 && TARGET_AVX10_2)
-      || ( < 64 && (TARGET_AVXVNNIINT8 || TARGET_AVX10_2)))
+  if (( == 64 && TARGET_AVX10V1AUX)
+      || ( < 64 && (TARGET_AVXVNNIINT8 || TARGET_AVX10V1AUX)))
     {
       operands[1] = lowpart_subreg (mode,
 				    force_reg (mode, operands[1]),
@@ -33296,11 +33299,11 @@
 	   (match_operand:VI4_AVX 2 "register_operand" "x,v")
 	   (match_operand:VI4_AVX 3 "nonimmediate_operand" "xjm,vm")]
 	  VPDOTPROD))]
-  "TARGET_AVXVNNIINT8 || TARGET_AVX10_2"
+  "TARGET_AVXVNNIINT8 || TARGET_AVX10V1AUX"
   "vpdp\t{%3, %2, %0|%0, %2, %3}"
    [(set_attr "prefix" "maybe_evex")
     (set_attr "addr" "gpr16,*")
-    (set_attr "isa" "avxvnniint8,avx10_2")])
+    (set_attr "isa" "avxvnniint8,avx10v1aux")])

 (define_insn "vpdp_v16si"
   [(set (match_operand:V16SI 0 "register_operand" "=v")
@@ -33309,48 +33312,48 @@
            (match_operand:V16SI 2 "register_operand" "v")
            (match_operand:V16SI 3 "nonimmediate_operand" "vm")]
           VPDOTPROD))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vpdp\t{%3, %2, %0|%0, %2, %3}"
    [(set_attr "prefix" "evex")])

 (define_insn "vpdp__mask"
-  [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=v")
-	(vec_merge:VI4_AVX10_2
-	  (unspec:VI4_AVX10_2
-	    [(match_operand:VI4_AVX10_2 1 "register_operand" "0")
-	     (match_operand:VI4_AVX10_2 2 "register_operand" "v")
-	     (match_operand:VI4_AVX10_2 3 "nonimmediate_operand" "vm")]
+  [(set (match_operand:VI4_AVX10V1AUX 0 "register_operand" "=v")
+	(vec_merge:VI4_AVX10V1AUX
+	  (unspec:VI4_AVX10V1AUX
+	    [(match_operand:VI4_AVX10V1AUX 1 "register_operand" "0")
+	     (match_operand:VI4_AVX10V1AUX 2 "register_operand" "v")
+	     (match_operand:VI4_AVX10V1AUX 3 "nonimmediate_operand" "vm")]
 	    VPDOTPROD)
 	  (match_dup 1)
 	  (match_operand: 4 "register_operand" "Yk")))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vpdp\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
    [(set_attr "prefix" "evex")])

 (define_expand "vpdp__maskz"
-  [(set (match_operand:VI4_AVX10_2 0 "register_operand")
-	(vec_merge:VI4_AVX10_2
-	  (unspec:VI4_AVX10_2
-	    [(match_operand:VI4_AVX10_2 1 "register_operand")
-	     (match_operand:VI4_AVX10_2 2 "register_operand")
-	     (match_operand:VI4_AVX10_2 3 "nonimmediate_operand")]
+  [(set (match_operand:VI4_AVX10V1AUX 0 "register_operand")
+	(vec_merge:VI4_AVX10V1AUX
+	  (unspec:VI4_AVX10V1AUX
+	    [(match_operand:VI4_AVX10V1AUX 1 "register_operand")
+	     (match_operand:VI4_AVX10V1AUX 2 "register_operand")
+	     (match_operand:VI4_AVX10V1AUX 3 "nonimmediate_operand")]
 	    VPDOTPROD)
 	  (match_dup 5)
 	  (match_operand: 4 "register_operand")))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "operands[5] = CONST0_RTX (mode);")

 (define_insn "*vpdp__maskz"
-  [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=v")
-	(vec_merge:VI4_AVX10_2
-	  (unspec:VI4_AVX10_2
-	    [(match_operand:VI4_AVX10_2 1 "register_operand" "0")
-	     (match_operand:VI4_AVX10_2 2 "register_operand" "v")
-	     (match_operand:VI4_AVX10_2 3 "nonimmediate_operand" "vm")]
+  [(set (match_operand:VI4_AVX10V1AUX 0 "register_operand" "=v")
+	(vec_merge:VI4_AVX10V1AUX
+	  (unspec:VI4_AVX10V1AUX
+	    [(match_operand:VI4_AVX10V1AUX 1 "register_operand" "0")
+	     (match_operand:VI4_AVX10V1AUX 2 "register_operand" "v")
+	     (match_operand:VI4_AVX10V1AUX 3 "nonimmediate_operand" "vm")]
 	    VPDOTPROD)
-	  (match_operand:VI4_AVX10_2 5 "const0_operand" "C")
+	  (match_operand:VI4_AVX10V1AUX 5 "const0_operand" "C")
 	  (match_operand: 4 "register_operand" "Yk")))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vpdp\t{%3, %2, %0%{%4%}%N5|%0%{%4%}%N5, %2, %3}"
    [(set_attr "prefix" "evex")])

@@ -33667,10 +33670,10 @@

 (define_expand "usdot_prod"
   [(match_operand: 0 "register_operand")
-   (match_operand:VI2_AVX10_2 1 "register_operand")
-   (match_operand:VI2_AVX10_2 2 "register_operand")
+   (match_operand:VI2_AVX10V1AUX 1 "register_operand")
+   (match_operand:VI2_AVX10V1AUX 2 "register_operand")
    (match_operand: 3 "register_operand")]
-  "TARGET_AVXVNNIINT16 || TARGET_AVX10_2"
+  "TARGET_AVXVNNIINT16 || TARGET_AVX10V1AUX"
 {
   operands[1] = lowpart_subreg (mode,
                                 force_reg (mode, operands[1]),
@@ -33685,10 +33688,10 @@

 (define_expand "udot_prod"
   [(match_operand: 0 "register_operand")
-   (match_operand:VI2_AVX10_2 1 "register_operand")
-   (match_operand:VI2_AVX10_2 2 "register_operand")
+   (match_operand:VI2_AVX10V1AUX 1 "register_operand")
+   (match_operand:VI2_AVX10V1AUX 2 "register_operand")
    (match_operand: 3 "register_operand")]
-  "TARGET_AVXVNNIINT16 || TARGET_AVX10_2"
+  "TARGET_AVXVNNIINT16 || TARGET_AVX10V1AUX"
 {
   operands[1] = lowpart_subreg (mode,
                                 force_reg (mode, operands[1]),
@@ -33708,7 +33711,7 @@
 	   (match_operand:VI4_AVX 2 "register_operand" "v")
 	   (match_operand:VI4_AVX 3 "nonimmediate_operand" "vm")]
 	  VPDPWPROD))]
-  "TARGET_AVXVNNIINT16 || TARGET_AVX10_2"
+  "TARGET_AVXVNNIINT16 || TARGET_AVX10V1AUX"
   "vpdp\t{%3, %2, %0|%0, %2, %3}"
    [(set_attr "prefix" "maybe_evex")])

@@ -33719,48 +33722,48 @@
            (match_operand:V16SI 2 "register_operand" "v")
            (match_operand:V16SI 3 "nonimmediate_operand" "vm")]
           VPDPWPROD))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vpdp\t{%3, %2, %0|%0, %2, %3}"
   [(set_attr "prefix" "evex")])

 (define_insn "vpdp__mask"
-  [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=v")
-	(vec_merge:VI4_AVX10_2
-	  (unspec:VI4_AVX10_2
-	    [(match_operand:VI4_AVX10_2 1 "register_operand" "0")
-	     (match_operand:VI4_AVX10_2 2 "register_operand" "v")
-	     (match_operand:VI4_AVX10_2 3 "nonimmediate_operand" "vm")]
+  [(set (match_operand:VI4_AVX10V1AUX 0 "register_operand" "=v")
+	(vec_merge:VI4_AVX10V1AUX
+	  (unspec:VI4_AVX10V1AUX
+	    [(match_operand:VI4_AVX10V1AUX 1 "register_operand" "0")
+	     (match_operand:VI4_AVX10V1AUX 2 "register_operand" "v")
+	     (match_operand:VI4_AVX10V1AUX 3 "nonimmediate_operand" "vm")]
 	    VPDPWPROD)
 	  (match_dup 1)
 	  (match_operand: 4 "register_operand" "Yk")))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vpdp\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}"
    [(set_attr "prefix" "evex")])

 (define_expand "vpdp__maskz"
-  [(set (match_operand:VI4_AVX10_2 0 "register_operand")
-	(vec_merge:VI4_AVX10_2
-	  (unspec:VI4_AVX10_2
-	    [(match_operand:VI4_AVX10_2 1 "register_operand")
-	     (match_operand:VI4_AVX10_2 2 "register_operand")
-	     (match_operand:VI4_AVX10_2 3 "nonimmediate_operand")]
+  [(set (match_operand:VI4_AVX10V1AUX 0 "register_operand")
+	(vec_merge:VI4_AVX10V1AUX
+	  (unspec:VI4_AVX10V1AUX
+	    [(match_operand:VI4_AVX10V1AUX 1 "register_operand")
+	     (match_operand:VI4_AVX10V1AUX 2 "register_operand")
+	     (match_operand:VI4_AVX10V1AUX 3 "nonimmediate_operand")]
 	    VPDPWPROD)
 	  (match_dup 5)
 	  (match_operand: 4 "register_operand")))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "operands[5] = CONST0_RTX (mode);")

 (define_insn "*vpdp__maskz"
-  [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=v")
-	(vec_merge:VI4_AVX10_2
-	  (unspec:VI4_AVX10_2
-	    [(match_operand:VI4_AVX10_2 1 "register_operand" "0")
-	     (match_operand:VI4_AVX10_2 2 "register_operand" "v")
-	     (match_operand:VI4_AVX10_2 3 "nonimmediate_operand" "vm")]
+  [(set (match_operand:VI4_AVX10V1AUX 0 "register_operand" "=v")
+	(vec_merge:VI4_AVX10V1AUX
+	  (unspec:VI4_AVX10V1AUX
+	    [(match_operand:VI4_AVX10V1AUX 1 "register_operand" "0")
+	     (match_operand:VI4_AVX10V1AUX 2 "register_operand" "v")
+	     (match_operand:VI4_AVX10V1AUX 3 "nonimmediate_operand" "vm")]
 	    VPDPWPROD)
-	  (match_operand:VI4_AVX10_2 5 "const0_operand" "C")
+	  (match_operand:VI4_AVX10V1AUX 5 "const0_operand" "C")
 	  (match_operand: 4 "register_operand" "Yk")))]
-  "TARGET_AVX10_2"
+  "TARGET_AVX10V1AUX"
   "vpdp\t{%3, %2, %0%{%4%}%N5|%0%{%4%}%N5, %2, %3}"
    [(set_attr "prefix" "evex")])

--
2.34.1


From jeffrey.law@oss.qualcomm.com  Sun Nov  1 14:01:42 2026
From: jeffrey.law@oss.qualcomm.com (Jeff Law)
Date: Sun, 1 Nov 2026 07:01:42 -0700
Subject: [PATCH] testsuite: XFAIL pr125734.c on targets without CLZ support
In-Reply-To: <20261101092433.1988785-1-torbjorn.svensson@foss.st.com>
References: <20261101092433.1988785-1-torbjorn.svensson@foss.st.com>
Message-ID: <7d6e00ea-c16f-4abf-a5e3-41f4603b83f9@oss.qualcomm.com>



On 11/1/26 2:19 AM, Torbj?rn SVENSSON wrote:
> Hi,
>
> The test fails for Cortex-M0 (arm-none-eabi) for, what I belive, the same reason as
> the xfail on hppa*-*-hpux* in r17-4470-ge741ce45698e48.
>
> spawn -ignore SIGHUP /build/r17-5743-ge33129b871c302/bin/arm-none-eabi-gcc /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/pr125734.c -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -mfpu=auto -fdiagnostics-plain-output -O2 -fdump-tree-optimized -S -o pr125734.s
> ...
> PASS: gcc.dg/tree-ssa/pr125734.c (test for excess errors)
> gcc.dg/tree-ssa/pr125734.c: pattern found 0 times
> FAIL: gcc.dg/tree-ssa/pr125734.c scan-tree-dump-times optimized "\\.CLZ" 1
>
> Ok for trunk?
>
> --
>
> The test fails on targets without CLZ support.
>
> gcc/testsuite/ChangeLog:
>
> 	* gcc.dg/tree-ssa/pr125734.c: XFAIl on !clz.
OK
jeff

From torbjorn.svensson@foss.st.com  Sun Nov  1 14:15:05 2026
From: torbjorn.svensson@foss.st.com (=?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?=)
Date: Sun, 1 Nov 2026 15:15:05 +0100
Subject: [PATCH] testsuite: Use gcc-nm for symbol scans
Message-ID: <20261101141813.2019428-1-torbjorn.svensson@foss.st.com>

Hi,

This fixes the following error for arm-none-eabi (probably other targets too):

ERROR: gcc.dg/builtin-pi-linkage.c: error executing dg-final: arm-none-eabi-nm: builtin-pi-linkage.o: plugin needed to handle lto object

Ok for trunk?

Kind regards,
Torbj?rn

--

Find gcc-nm alongside the compiler under test instead of searching
the build tree for nm. This ensures that liblto_plugin.so is found
automatically when available, fixing the "plugin needed to handle
lto object" error for LTO tests like gcc.dg/builtin-pi-linkage.c.
Allow GCC_NM_UNDER_TEST to override the tool.

This follows the approach used for gcc-ar in r16-7327-gc9addbc79ac0f9.

gcc/testsuite/ChangeLog:

	* lib/gcc-dg.exp (scan-symbol-common): Use gcc-nm and honor
	GCC_NM_UNDER_TEST.

Signed-off-by: Torbj?rn SVENSSON 
---
 gcc/testsuite/lib/gcc-dg.exp | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 9f183259257..bdd74d132c1 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1394,8 +1394,8 @@ proc gdb-exists { args } {
 # Argument 0 is the regexp to match.
 # Argument 1 handles expected failures and the like
 proc scan-symbol-common { scan_directive args } {
-    global nm
-    global base_dir
+    global GCC_UNDER_TEST
+    global GCC_NM_UNDER_TEST
 
     # Access variable from gcc-dg-test-1 or lto-execute.
     upvar 3 output_file output_file
@@ -1409,15 +1409,20 @@ proc scan-symbol-common { scan_directive args } {
 	}
     }
 
-    # Find nm like we find g++ in g++.exp.
-    if ![info exists nm]  {
-	set nm [findfile $base_dir/../../../binutils/nm \
-		$base_dir/../../../binutils/nm \
-	        [findfile $base_dir/../../nm $base_dir/../../nm \
-		      [findfile $base_dir/nm $base_dir/nm \
-		       [transform nm]]]]
-	verbose -log "nm is $nm"
+    # For now find gcc-nm in the same directory as $GCC_UNDER_TEST, unless
+    # GCC_NM_UNDER_TEST is defined.
+
+    if ![info exists GCC_NM_UNDER_TEST] {
+	if { ![is_remote host] && [string match "*/*" [lindex $GCC_UNDER_TEST 0]] } {
+	    set nm_cmd [file dirname [lindex $GCC_UNDER_TEST 0]]/[gcc-transform-out-of-tree gcc-nm]
+	} else {
+	    set nm_cmd [gcc-transform-out-of-tree gcc-nm]
+	}
+	set nm_cmd "$nm_cmd [lrange $GCC_UNDER_TEST 1 end]"
+    } else {
+	set nm_cmd $GCC_NM_UNDER_TEST
     }
+    verbose -log "nm is $nm_cmd"
 
     set output_file "[glob -nocomplain $output_file]"
     if { $output_file == "" } {
@@ -1425,7 +1430,7 @@ proc scan-symbol-common { scan_directive args } {
 	return
     }
 
-    set fd [open "| $nm $output_file" r]
+    set fd [open "| $nm_cmd $output_file" r]
     set text [read $fd]
     close $fd
 
-- 
2.43.0


From gerald@pfeifer.com  Sun Nov  1 14:32:27 2026
From: gerald@pfeifer.com (Gerald Pfeifer)
Date: Sun, 1 Nov 2026 15:32:27 +0100 (CET)
Subject: [pushed] wwwdocs: readings: Drop ISO Modula-2 standards at TU
 Delft
Message-ID: <20261101143229.9EB0719BFCA@hamza.pair.com>

Pushed.

Gaius, if you have an alternate link, absolutely feel free to add that (or 
let me know). I did not find a good alternative, just the official ISO 
standards site which asks for 200+ CHF.

Gerald


The subdomain sc22wg13.twi.tudelft.nl no longer resolves.
---
 htdocs/readings.html | 2 --
 1 file changed, 2 deletions(-)

diff --git a/htdocs/readings.html b/htdocs/readings.html
index 31c75d050..1902c391a 100644
--- a/htdocs/readings.html
+++ b/htdocs/readings.html
@@ -558,8 +558,6 @@ names.
   in Modula-2 (Edition 2)
   
  • Programming in Modula-2 (Edition 4)
  • -
  • ISO Modula-2 standards - (base language, OO and generic language extensions)
  • -- 2.56.0 From iains.gcc@gmail.com Sun Nov 1 14:55:15 2026 From: iains.gcc@gmail.com (Iain Sandoe) Date: Sun, 1 Nov 2026 14:55:15 +0000 Subject: [PATCH] c++, middle-end: Avoid an undefined C4 [125359] Message-ID: <20261101145544.39238-1-iain@sandoe.co.uk> Tested on x86_64-darwin, Windows (by the OP) and x86_64/aarch64-linux, OK for trunk / 16? thanks Iain --- 8< --- At -Os, -fdeclone-ctor-dtor is enabled, which splits a cdtor into a unified body (C4) plus C1/C2 thunks. A TU that inlines a thunk therefore materialises a call to a C4 whose own offline body is DECL_EXTERNAL (but emitted by nobody), and the link fails with an undefined reference. This fires on targets without support for COMDAT or where ONE_ONLY decls are not marked as DECL_WEAK. The solution is to decline the inline of such thunks if they would leave a reference to an un-emitted C4. Some testcase input from an LLM. Assisted-by: Claude Opus 5.5 PR c++/125359 gcc/ChangeLog: * cgraph.h: Add flag for no external decl. * ipa-inline.cc (can_inline_edge_p): Refuse to inline thunks that point to an absent target. * lto-cgraph.cc (lto_output_node): Handle no_external_definition. (lto_output_varpool_node): Likewise. (input_overwrite_node): Likewise. (input_varpool_node): Likewise. gcc/cp/ChangeLog: * optimize.cc (maybe_thunk_body): Mark cases where a thunkee will have no availabile def, and therefore the thunk should not be inlined. gcc/testsuite/ChangeLog: * g++.dg/opt/declone6-aux.cc: New test. * g++.dg/opt/declone6.C: New test. * g++.dg/opt/declone6.h: New test. Signed-off-by: Iain Sandoe --- gcc/cgraph.h | 6 +- gcc/cp/optimize.cc | 12 ++++ gcc/ipa-inline.cc | 14 ++++ gcc/lto-cgraph.cc | 4 ++ gcc/testsuite/g++.dg/opt/declone-cdtor-lto.C | 69 ++++++++++++++++++++ gcc/testsuite/g++.dg/opt/declone6-aux.cc | 8 +++ gcc/testsuite/g++.dg/opt/declone6.C | 61 +++++++++++++++++ gcc/testsuite/g++.dg/opt/declone6.h | 26 ++++++++ 8 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/opt/declone-cdtor-lto.C create mode 100644 gcc/testsuite/g++.dg/opt/declone6-aux.cc create mode 100644 gcc/testsuite/g++.dg/opt/declone6.C create mode 100644 gcc/testsuite/g++.dg/opt/declone6.h diff --git a/gcc/cgraph.h b/gcc/cgraph.h index cad7fb3c127..2bed061b3ff 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -149,7 +149,8 @@ public: must_remain_in_tu_name (false), must_remain_in_tu_body (false), unique_name (false), implicit_section (false), body_removed (false), semantic_interposition (flag_semantic_interposition), - used_from_other_partition (false), in_other_partition (false), + used_from_other_partition (false), no_external_definition (false), + in_other_partition (false), address_taken (false), in_init_priority_hash (false), need_lto_streaming (false), offloadable (false), ifunc_resolver (false), next_sharing_asm_name (NULL), @@ -622,6 +623,9 @@ public: /* Set when variable is used from other LTRANS partition. */ unsigned used_from_other_partition : 1; + /* Set when no definition of this symbol is guaranteed to exist in any + translation unit. */ + unsigned no_external_definition : 1; /* Set when function is available in the other LTRANS partition. During WPA output it is used to mark nodes that are present in multiple partitions. */ diff --git a/gcc/cp/optimize.cc b/gcc/cp/optimize.cc index 0afeefd5704..83a3d7ba804 100644 --- a/gcc/cp/optimize.cc +++ b/gcc/cp/optimize.cc @@ -295,6 +295,8 @@ maybe_thunk_body (tree fn, bool force) DECL_ABSTRACT_P (fn) = false; if (!DECL_WEAK (fn)) { + if (DECL_ONE_ONLY (fn)) + symtab_node::get_create (fn)->no_external_definition = true; TREE_PUBLIC (fn) = false; DECL_EXTERNAL (fn) = false; DECL_INTERFACE_KNOWN (fn) = true; @@ -327,6 +329,16 @@ maybe_thunk_body (tree fn, bool force) DECL_WEAK (fn) = false; DECL_COMDAT (fn) = false; } + else + { + /* Neither case above could claim the unified body for this TU, so keep + vague linkage and may end up DECL_EXTERNAL. However, no other TU + will necessarily emit it. */ + symtab_node::get_create (fn)->no_external_definition = true; + /* It is an implementation detail of this TU. */ + DECL_VISIBILITY (fn) = VISIBILITY_HIDDEN; + DECL_VISIBILITY_SPECIFIED (fn) = 1; + } /* Find the vtt_parm, if present. */ for (vtt_parmno = -1, parmno = 0, fn_parm = DECL_ARGUMENTS (fn); diff --git a/gcc/ipa-inline.cc b/gcc/ipa-inline.cc index ba8bf11b66e..012c5f4301a 100644 --- a/gcc/ipa-inline.cc +++ b/gcc/ipa-inline.cc @@ -463,6 +463,20 @@ can_inline_edge_p (struct cgraph_edge *e, bool report, e->inline_failed = CIF_MUST_REMAIN_IN_TU; inlinable = false; } + /* Do not inline a body that still calls a target with no guaranteed + definition: the call would be duplicated into the caller, while the + callee's own body is DECL_EXTERNAL and so emitted by nobody. + However, allow always-inline. */ + if (inlinable && !DECL_DISREGARD_INLINE_LIMITS (callee->decl)) + for (cgraph_edge *e2 = callee->callees; e2; e2 = e2->next_callee) + if (e2->callee->no_external_definition + && DECL_EXTERNAL (e2->callee->decl)) + { + e->inline_failed = CIF_BODY_NOT_AVAILABLE; + inlinable = false; + break; + } + if (!inlinable && report) report_inline_failed_reason (e); return inlinable; diff --git a/gcc/lto-cgraph.cc b/gcc/lto-cgraph.cc index b3644e47bec..f3b0d9ecd65 100644 --- a/gcc/lto-cgraph.cc +++ b/gcc/lto-cgraph.cc @@ -542,6 +542,7 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, bp_pack_value (&bp, node->must_remain_in_tu_body, 1); bp_pack_value (&bp, node->unique_name, 1); bp_pack_value (&bp, node->body_removed, 1); + bp_pack_value (&bp, node->no_external_definition, 1); bp_pack_value (&bp, node->semantic_interposition, 1); bp_pack_value (&bp, node->implicit_section, 1); bp_pack_value (&bp, node->address_taken, 1); @@ -636,6 +637,7 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, varpool_node *node, node->body_removed || (!encode_initializer_p && !node->alias && node->definition), 1); + bp_pack_value (&bp, node->no_external_definition, 1); bp_pack_value (&bp, node->semantic_interposition, 1); bp_pack_value (&bp, node->implicit_section, 1); bp_pack_value (&bp, node->writeonly, 1); @@ -1269,6 +1271,7 @@ input_overwrite_node (struct lto_file_decl_data *file_data, node->must_remain_in_tu_body = bp_unpack_value (bp, 1); node->unique_name = bp_unpack_value (bp, 1); node->body_removed = bp_unpack_value (bp, 1); + node->no_external_definition = bp_unpack_value (bp, 1); node->semantic_interposition = bp_unpack_value (bp, 1); node->implicit_section = bp_unpack_value (bp, 1); node->address_taken = bp_unpack_value (bp, 1); @@ -1479,6 +1482,7 @@ input_varpool_node (struct lto_file_decl_data *file_data, node->must_remain_in_tu_body = bp_unpack_value (&bp, 1); node->unique_name = bp_unpack_value (&bp, 1); node->body_removed = bp_unpack_value (&bp, 1); + node->no_external_definition = bp_unpack_value (&bp, 1); node->semantic_interposition = bp_unpack_value (&bp, 1); node->implicit_section = bp_unpack_value (&bp, 1); node->writeonly = bp_unpack_value (&bp, 1); diff --git a/gcc/testsuite/g++.dg/opt/declone-cdtor-lto.C b/gcc/testsuite/g++.dg/opt/declone-cdtor-lto.C new file mode 100644 index 00000000000..59ad5e698f6 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/declone-cdtor-lto.C @@ -0,0 +1,69 @@ +// PR c++/125359 + +// Check that we do not leave a call to a unified cdtor in an LTO build. +// { dg-do run { target c++14 } } +// { dg-require-effective-target lto } +// { dg-options "-Os -flto -fstrict-aliasing" } +// { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } } + +#include +#include +#include + +class Base +{ +public: + Base* previous = nullptr; + Base* next = nullptr; + Base* target = nullptr; +}; + +class Target : public Base +{ +public: + __attribute__((always_inline)) ~Target() + { + while (this->next) + { + Base* n = this->next; + + if (n->previous) + n->previous->next = n->next; + if (n->next) + n->next->previous = n->previous; + n->previous = nullptr; + n->next = nullptr; + n->target = nullptr; + } + } +}; + +template +class TargetWithData final : public Target +{ +public: + TargetWithData(T data) + : data(data) + {} + T data; +}; + +void test() +{ + Base ptr; + { + auto data = std::make_unique>(std::string("asdf")); + ptr.target = &*data; + ptr.previous = &*data; + data->next = &ptr; + + assert(ptr.target != nullptr); + } + assert(ptr.target == nullptr); +} + +int main(int, char**) +{ + test(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/opt/declone6-aux.cc b/gcc/testsuite/g++.dg/opt/declone6-aux.cc new file mode 100644 index 00000000000..3cbe4de1234 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/declone6-aux.cc @@ -0,0 +1,8 @@ +// Emitter for declone6.C. It includes the same header, so it sees +// the `extern template' declaration, and then overrides it with an explicit +// instantiation def -- which [temp.explicit] permits provided the +// definition follows the declaration, as it does here. + +#include "declone6.h" + +template struct B; // the override: emit them HERE diff --git a/gcc/testsuite/g++.dg/opt/declone6.C b/gcc/testsuite/g++.dg/opt/declone6.C new file mode 100644 index 00000000000..a81188f911b --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/declone6.C @@ -0,0 +1,61 @@ +// PR c++/125359 + +// declone6.h holds inline definitions plus `extern template struct B;', so the +// bodies are VISIBLE in both TUs while neither is told to emit them. +// declone6-aux.cc overrides that with an explicit instantiation DEFINITION, which +// [temp.explicit] permits after the declaration, making it the one designated +// emitter. The program is therefore exactly what the standard asks for. +// +// At -Os the clones become forwarding thunks to a unified C4 body; if a thunk is +// inlined here, the call to that C4 must not be left behind, because nothing in the +// source can name a C4 and so no TU can be asked to export one. +// +// { dg-do run { target c++20 } } +// { dg-options "-Os" } +// { dg-additional-sources "declone6-aux.cc" } + +#include "declone6.h" + +struct D : B // derived: uses B::C2 (base-object ctor) +{ + D (int x) : B (x) {} +}; + +struct Sink +{ + __attribute__((always_inline)) ~Sink () { total += v; } + static int total; + int v; +}; +int Sink::total; + +template +struct Holder : Sink +{ + T held; + Holder (const T &x) : held (x) { v = held.n; } +}; + +B *p; +D *q; + +__attribute__((noinline)) static int +use (int x) +{ + p = new B (x); // uses B::C1 (complete-object ctor) + q = new D (x); + { + B t (x); + Holder > h (t); // needs B's copy cdtor HERE, by value + (void) h; + } + return p->n + q->n; +} + +int +main () +{ + int a = use (2); + int b = use (2); + return !(a == b && Sink::total != 0); +} diff --git a/gcc/testsuite/g++.dg/opt/declone6.h b/gcc/testsuite/g++.dg/opt/declone6.h new file mode 100644 index 00000000000..d2e210005af --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/declone6.h @@ -0,0 +1,26 @@ +// Shared "header" for declone6.C and declone6-aux.cc. The definitions must be +// inline to live here, which is the point: the explicit instantiation decl +// below tells every includer not to emit them, and exactly one TU overrides it with +// an explicit instantiation def to become the designated emitter, +// declone6-aux.cc +// +// Shaped after std::basic_string, which triggered this case. + +template +struct B +{ + T n; + + constexpr B (T x) : n (x) + { + for (int i = 0; i < 16; i++) + n += (x ^ i) + (n >> 1); + } + + constexpr B (const B &o) : n (o.n) { n += 1; } + + constexpr ~B () { n = 0; } +}; + +// The declaration: "do not instantiate the definitions here." +extern template struct B; -- 2.50.1 (Apple Git-155) From iains.gcc@gmail.com Sun Nov 1 15:28:01 2026 From: iains.gcc@gmail.com (Iain Sandoe) Date: Sun, 1 Nov 2026 15:28:01 +0000 Subject: [PATCH] dwarf2out: Allow for an empty cie_cfi_vec. Message-ID: <20261101152819.43397-1-iain@sandoe.co.uk> This shows up on aarch64-darwin but can be repeated with -fno-cfi-asm on Linux, tested on x86_64, aarch64-linux, aarch64-darwin, OK for trunk? thanks Iain --- 8< --- The RTL front end can start at a pass later than the initialisation of the cie/cfi vector and so we must cater for it being unset. This fires for RTL testcases on platform which do not use cfi instructions. gcc/ChangeLog: * dwarf2out.cc (output_call_frame_info): Check for unset cie/cfi vector before iteration. Signed-off-by: Iain Sandoe --- gcc/dwarf2out.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index e8a6019f72e..4e8a2ddfc75 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -943,8 +943,12 @@ output_call_frame_info (int for_eh) eh_data_format_name (fde_encoding)); } - FOR_EACH_VEC_ELT (*cie_cfi_vec, i, cfi) - output_cfi (cfi, NULL, for_eh); + /* cie_cfi_vec is created lazily by the dwarf2 frame pass. + The RTL front end allows for starting from a pass after that so that + this can be absent. */ + if (cie_cfi_vec) + FOR_EACH_VEC_ELT (*cie_cfi_vec, i, cfi) + output_cfi (cfi, NULL, for_eh); /* Pad the CIE out to an address sized boundary. */ ASM_OUTPUT_ALIGN (asm_out_file, -- 2.50.1 (Apple Git-155) From jeffrey.law@oss.qualcomm.com Sun Nov 1 16:06:05 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 09:06:05 -0700 Subject: [PATCH] tree-cfg: Ignore debug stmts when checking coverage nops [PR128346] In-Reply-To: <20261101120911.70954-1-yqtian668@gmail.com> References: <20261101120911.70954-1-yqtian668@gmail.com> Message-ID: <75fc93f1-c4d9-4eb9-9797-e790fc62ccd4@oss.qualcomm.com> On 11/1/26 5:09 AM, Yongqiang Tian wrote: > gimple_can_merge_blocks_p checks the final statement of a block for the > compiler-inserted nop that marks a coverage-suppression boundary. A trailing > DEBUG_BEGIN_STMT hides that nop under -g, allows the blocks to be merged, and > changes the gcov CFG checksum even though the generated code is unchanged. > > Use gsi_last_nondebug_bb so debug markers do not affect the merge decision. > Add a focused regression test. > > The test case was found by a non-AI automated testing tool. > Assisted-by: OpenAI Codex 5.6 Sol. > > Bootstrapped and regression tested on x86_64-pc-linux-gnu. The focused > test fails before the change and passes after it. > > PR gcov-profile/128346 > > gcc/ChangeLog: > > * tree-cfg.cc (gimple_can_merge_blocks_p): Ignore debug statements > when examining the end of a block. > > gcc/testsuite/ChangeLog: > > * gcc.misc-tests/gcov-45.c: New test. > > Signed-off-by: Yongqiang Tian Thanks.? Looks good to me.? No issues in Sashiko.? Pushed to the trunk. Thanks again for all the fixes in this space! jeff From jeffrey.law@oss.qualcomm.com Sun Nov 1 16:07:43 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 09:07:43 -0700 Subject: [PATCH v1 0/2] Add non overlap test for rest rvv widen tenary insn In-Reply-To: <20261031125415.2311363-1-pan2.li@intel.com> References: <20261031125415.2311363-1-pan2.li@intel.com> Message-ID: <126b1330-6608-404f-a9bb-cc187aab1369@oss.qualcomm.com> On 10/31/26 6:50 AM, pan2.li@intel.com wrote: > From: Pan Li > > To make sure there is no overlap for all rvv widen tenary insns. > > The below test suites are passed for this patch: > 1. The rv64gcv fully regression tests. > > Pan Li (2): > RISC-V: Add tests for no reg overlap of int widen ternary [PR target/128162] > RISC-V: Add tests for no reg overlap of fp widen ternary [PR target/128162] OK.? Thanks again! jeff From jeffrey.law@oss.qualcomm.com Sun Nov 1 16:18:38 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 09:18:38 -0700 Subject: [PATCH v2] match.pd: (X ^ Y) & (X | Y) -> X ^ Y patterns [PR115547] In-Reply-To: <20261030120514.650823-1-daniel.barboza@oss.qualcomm.com> References: <20261030120514.650823-1-daniel.barboza@oss.qualcomm.com> Message-ID: On 10/30/26 6:05 AM, Daniel Barboza wrote: > Add a couple of match.pd patterns that simplifies a bit_and using a > bit_xor and a bit_ior with the same operands: > > (X ^ Y) & (X | Y) -> X ^ Y > > For boolean values there is also a NE variant: > > (X NE Y) & (X | Y) -> X NE Y > > Also, for boolean values, we're also handling chained bit_iors: > > (X ^ Y) & (Z | X | Y) -> (X ^ Y) > (X NE Y) & (Z | X | Y) -> (X NE Y) > > The takeaway is that if we know that X != Y then X != Y & (X | Y | ...) > is always going to be the same as X != Y. > > The remaining PR115547 patterns that uses "&&" generate chained ifconds > that can't be handled via match.pd. We'll try our luck handling those > inside one of the passes at a later date. > > Bootstrapped and regression tested in x86_64. > > PR tree-optimization/115547 > > gcc/ChangeLog: > > * match.pd(`(X ^ Y) & (X | Y)`): New pattern. > (`(X NE Y) & (X | Y)`): New pattern. > (`(X NE Y) & (Z | X | Y)`): New pattern. > (`(X ^ Y) & (Z | X | Y)`): New pattern. > > gcc/testsuite/ChangeLog: > > * gcc.dg/tree-ssa/pr115547.c: New test. > --- > > Changes from v1: > - re-use bit_xor patterns; > - remove redudant inner ":c" qualifiers > - v1 link:https://gcc.gnu.org/pipermail/gcc-patches/2026-October/736840.html Sashiko called out the lack of :c, but that's clearly an implementation decision based on feedback from Andrea. It does seem to think restricting to 0/1 values it not necessary for the |(X^Y) & (Z|X|Y) ? X^Y| ?case, which seems right to me.? Seems like a trivial follow-up to me. OK for the trunk. jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffrey.law@oss.qualcomm.com Sun Nov 1 16:23:18 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 09:23:18 -0700 Subject: [PATCH v3] match.pd: (A << N) >> N -> A for signed type A [PR126644] In-Reply-To: <20261028083827.836-1-daniel.barboza@oss.qualcomm.com> References: <20261028083827.836-1-daniel.barboza@oss.qualcomm.com> Message-ID: <7ed87df6-1a92-4545-ae9e-f989475de9ea@oss.qualcomm.com> On 10/28/26 2:38 AM, Daniel Barboza wrote: > This is done during RTL. Do it earlier in Gimple to potentially allow > more optimizations opportunities. > > For signed types we need to consider that the rshift will preserve the > original sign of its operand, thus if there's a sign change in A during > the lshift we can no longer do the simplification since the end result is > no longer equal to A. E.g: > > - for signed type A = 0x001.. and N = 2: > (0x001.. << 2) >> 2 --> 0x1.. >> 2 --> 0x111.., which is not A; > > - Likewise, for signed type A = 0x110.. and N = 2: > (0x110.. << 2) >> 2 --> 0x0.. >> 2 --> 0x000.., also not A. > > We're ignoring unsigned types because there are match.pd optimizations > like "(x << c) >> c -> x & ((unsigned)-1 >> c)" that already optimizes > them. > > Bootstrapped and regression tested in x86_64. > > PR tree-optimization/126644 > > gcc/ChangeLog: > > * match.pd(`((A << N) >> N) -> N`): New pattern. > > gcc/testsuite/ChangeLog: > > * gcc.dg/tree-ssa/pr126644.c: New test. > --- > > Changes from v2: > - removed the TYPE_UNSIGNED pattern since match.pd already had patterns > handling it; > - use get_nonzero_bits() and get_known_nonzero_bits() to detect if the > lshift might change the sign bit. > - v2 link: https://gcc.gnu.org/pipermail/gcc-patches/2026-October/734172.html LGTM and Sashiko clean.? OK for the trunk. jeff From jeffrey.law@oss.qualcomm.com Sun Nov 1 16:47:32 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 09:47:32 -0700 Subject: [PATCH v2 1/2] simplify-rtx: Name the bits of the comparison masks In-Reply-To: References: Message-ID: <9127a0a7-9507-41cd-a11b-cf194de98a5c@oss.qualcomm.com> On 10/27/26 12:05 PM, Igor Shevlyakov wrote: > Use named bits instead of numbers for the comparison masks of > simplify_logical_relational_operation. No functional change. > > Assisted-by: Claude Opus 5.5 > > gcc/ChangeLog: > > * simplify-rtx.cc (enum comparison_mask): New. > (unsigned_inequality_p): New function. > (unsigned_comparison_to_mask, mask_to_unsigned_comparison) > (comparison_to_mask, mask_to_comparison) > (simplify_context::simplify_logical_relational_operation): Use them. > > Signed-off-by: Igor Shevlyakov For reasons unknown, this didn't get a Sashiko review.? But it's also quite trivial, so no real loss. OK for the trunk. jeff From iains.gcc@gmail.com Sun Nov 1 17:26:47 2026 From: iains.gcc@gmail.com (Iain Sandoe) Date: Sun, 1 Nov 2026 17:26:47 +0000 Subject: [PATCH] D: Correct vector compares for targets with mask types different from data size. Message-ID: <20261101172719.59602-1-iain@sandoe.co.uk> This shows, for example, on cascadelake. Tested on x86_64-linux (cfarm151) and darwin both with cascadelake CPUs. OK for trunk? thanks Iain --- 8< --- build_boolop types the VEC_COND_EXPR result with the comparison's mask type instead of a same-width integral vector. Where the target has AVX512 mask registers (avx512vl) that type is 32x narrower than the operands, and D's same-size rule then rejects the reinterpretation. The solution is to copy the approach used in the C/C++ frontends, where a separate return type is computed, the patch here essentially duplicates those actions. gcc/d/ChangeLog: * d-codegen.cc (build_vec_cmp): New. (build_boolop): Where required compute a separate return type for vector boolean ops. gcc/testsuite/ChangeLog: * gdc.dg/pr108945.d: Actully test for the absence of the floating point constant, instead of using VEC_COND_EXPR; the latter is now validly emitted. Signed-off-by: Iain Sandoe --- gcc/d/d-codegen.cc | 46 +++++++++++++++++++++++---------- gcc/testsuite/gdc.dg/pr108945.d | 2 +- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc index 0f51fd70eb6..ff4b006fb26 100644 --- a/gcc/d/d-codegen.cc +++ b/gcc/d/d-codegen.cc @@ -1514,41 +1514,61 @@ warn_for_null_address (tree arg) TREE_OPERAND (arg, 0)); } +static tree +build_vec_cmp (location_t loc, tree_code code, tree type, + tree arg0, tree arg1) +{ + tree zero_vec = build_zero_cst (type); + tree minus_one_vec = build_minus_one_cst (type); + tree cmp_type = truth_type_for (TREE_TYPE (arg0)); + tree cmp = fold_build2_loc (loc, code, cmp_type, arg0, arg1); + return fold_build3_loc (loc, VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec); +} + /* Build a boolean ARG0 op ARG1 expression. */ tree build_boolop (tree_code code, tree arg0, tree arg1) { + tree type0 = TREE_TYPE (arg0); + tree type1 = TREE_TYPE (arg1); /* Aggregate comparisons may get lowered to a call to builtin memcmp, so need to remove all side effects in case its address is taken. */ - if (AGGREGATE_TYPE_P (TREE_TYPE (arg0))) + if (AGGREGATE_TYPE_P (type0)) arg0 = d_save_expr (arg0); - if (AGGREGATE_TYPE_P (TREE_TYPE (arg1))) + if (AGGREGATE_TYPE_P (type1)) arg1 = d_save_expr (arg1); - if (VECTOR_TYPE_P (TREE_TYPE (arg0)) && VECTOR_TYPE_P (TREE_TYPE (arg1))) + tree res_type = type0; + if (VECTOR_TYPE_P (type0) && VECTOR_TYPE_P (type1)) { - /* Build a vector comparison. - VEC_COND_EXPR ; */ - tree cmptype = truth_type_for (TREE_TYPE (arg0)); - tree cmp = fold_build2_loc (input_location, code, cmptype, arg0, arg1); - - return fold_build3_loc (input_location, VEC_COND_EXPR, cmptype, cmp, - build_minus_one_cst (cmptype), - build_zero_cst (cmptype)); + if (!VECTOR_BOOLEAN_TYPE_P (type0) || !VECTOR_BOOLEAN_TYPE_P (type1)) + { + tree intt = lang_hooks.types.type_for_size + (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (type0))), 0); + if (intt == NULL_TREE) + { + error_at (input_location, "could not find an integer type " + "of the same size as %qT", TREE_TYPE (type0)); + return error_mark_node; + } + res_type + = build_opaque_vector_type (intt, TYPE_VECTOR_SUBPARTS (type0)); + } + return build_vec_cmp (input_location, code, res_type, arg0, arg1); } if (code == EQ_EXPR || code == NE_EXPR) { /* Check if comparing the address of a variable to null. */ - if (POINTER_TYPE_P (TREE_TYPE (arg0)) && integer_zerop (arg1)) + if (POINTER_TYPE_P (type0) && integer_zerop (arg1)) warn_for_null_address (arg0); if (POINTER_TYPE_P (TREE_TYPE (arg1)) && integer_zerop (arg0)) warn_for_null_address (arg1); } return fold_build2_loc (input_location, code, d_bool_type, - arg0, d_convert (TREE_TYPE (arg0), arg1)); + arg0, d_convert (type0, arg1)); } /* Return a COND_EXPR. ARG0, ARG1, and ARG2 are the three diff --git a/gcc/testsuite/gdc.dg/pr108945.d b/gcc/testsuite/gdc.dg/pr108945.d index 03b9de8e758..837cc3f34c3 100644 --- a/gcc/testsuite/gdc.dg/pr108945.d +++ b/gcc/testsuite/gdc.dg/pr108945.d @@ -9,4 +9,4 @@ auto pr108945(f4 a, f4 b) return a < b; } -// { dg-final { scan-tree-dump-not "VEC_COND_EXPR" "gimple" } } +// { dg-final { scan-tree-dump-not "1\.0e\+0" "gimple" } } -- 2.50.1 (Apple Git-155) From jeffrey.law@oss.qualcomm.com Sun Nov 1 17:55:07 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 10:55:07 -0700 Subject: [committed][RISC-V][PR target/127908] Properly recognize additional UNSPECs that may trap for RISC-v Message-ID: As noted in the BZ the RISC-V port has several UNSPECs with integer modes, but which can trigger FE_INVALID or other similar exceptions. Because the UNSPECs have an integer mode, the standard may-trap hooks return false and that allows the scheduler to move things around too aggressively speculate a trapping insn up past its controlling condition. This patch introduces a suitable target override which will detect the potentially trapping UNSPECs with integer modes which in turn avoids the invalid speculation. Tested on riscv32-elf and riscv64-elf.? Bootstrap on the K3 and c920 is in flight.? K1 is queued.? Pushing to the trunk. -------------- next part -------------- commit 02018d606e8ae483cdf2f5ea3f222fc582ce3090 Author: Jeff Law Date: Sun Nov 1 10:01:00 2026 -0700 [RISC-V][PR target/127908] Properly recognize additional UNSPECs that may trap for RISC-v As noted in the BZ the RISC-V port has several UNSPECs with integer modes, but which can trigger FE_INVALID or other similar exceptions. Because the UNSPECs have an integer mode, the standard may-trap hooks return false and that allows the scheduler to move things around too aggressively speculate a trapping insn up past its controlling condition. This patch introduces a suitable target override which will detect the potentially trapping UNSPECs with integer modes which in turn avoids the invalid speculation. Tested on riscv32-elf and riscv64-elf. Bootstrap on the K3 and c920 is in flight. K1 is queued. Pushing to the trunk. PR target/127908 gcc/ * config/riscv/riscv.cc (riscv_unspec_may_trap_p): New function. (TARGET_UNSPEC_MAY_TRAP_P): Define. gcc/testsuite * gcc.target/riscv/pr127908.c: New test. diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index bed695ccae4..ab9354162fa 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -16984,6 +16984,38 @@ riscv_can_tag_addresses () return TARGET_64BIT && target_has_pointer_masking_p; } +/* Implement TARGET_UNSPEC_MAY_TRAP_P. */ + +static int +riscv_unspec_may_trap_p (const_rtx x, unsigned flags) +{ + /* The default implementation catches things with an FP mode on the UNSPEC. + Thus we don't need to list all those. We can focus on cases where the + UNSPEC has no mode or an integer/vector mode. */ + switch (XINT (x, 1)) + { + case UNSPEC_LRINT: + case UNSPEC_ROUND: + case UNSPEC_FLOOR: + case UNSPEC_CEIL: + case UNSPEC_BTRUNC: + case UNSPEC_ROUNDEVEN: + case UNSPEC_NEARBYINT: + case UNSPEC_FLT_QUIET: + case UNSPEC_FLE_QUIET: + case UNSPEC_VFCVT: + case UNSPEC_UNSIGNED_VFCVT: + /* If FLAG_TRAPPING_MATH is active, then these potentially trap, otherwise + fall into the default case. */ + if (flag_trapping_math) + return 1; + default: + break; + } + + return default_unspec_may_trap_p (x, flags); +} + /* libsanitizer expects 8 tag bits. */ @@ -17437,6 +17469,9 @@ riscv_memtag_tag_bitsize () #undef TARGET_MEMTAG_TAG_BITSIZE #define TARGET_MEMTAG_TAG_BITSIZE riscv_memtag_tag_bitsize +#undef TARGET_UNSPEC_MAY_TRAP_P +#define TARGET_UNSPEC_MAY_TRAP_P riscv_unspec_may_trap_p + #undef TARGET_DOCUMENTATION_NAME #define TARGET_DOCUMENTATION_NAME "RISC-V" diff --git a/gcc/testsuite/gcc.target/riscv/pr127908.c b/gcc/testsuite/gcc.target/riscv/pr127908.c new file mode 100644 index 00000000000..a67d276d7cb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr127908.c @@ -0,0 +1,48 @@ +/* { dg-do run } */ +/* { dg-additional-options "-std=c11" } */ + +#include +#include + +#define DEF(NAME, FN, T) \ + __attribute__((noipa)) void \ + NAME (const T *s, T *d, long n) \ + { \ + for (; n > 0; --n, ++s, ++d) \ + *d = FN (*s); \ + } + +DEF (ceil_d, ceil, double) +DEF (floor_d, floor, double) +DEF (trunc_d, trunc, double) +DEF (ceil_f, ceilf, float) +DEF (floor_f, floorf, float) +DEF (trunc_f, truncf, float) + +#define CHECK(NAME, T, IN) \ + do \ + for (int i = 0; i < 4; i++) \ + { \ + T out; \ + feclearexcept (FE_ALL_EXCEPT); \ + NAME (&(IN)[i], &out, 1); \ + if (fetestexcept (FE_INVALID)) \ + __builtin_abort (); \ + } \ + while (0) + +int +main (void) +{ + const double in_d[] = { INFINITY, -INFINITY, 1e300, 2.5 }; + const float in_f[] = { INFINITY, -INFINITY, 1e30f, 2.5f }; + + CHECK (ceil_d, double, in_d); + CHECK (floor_d, double, in_d); + CHECK (trunc_d, double, in_d); + CHECK (ceil_f, float, in_f); + CHECK (floor_f, float, in_f); + CHECK (trunc_f, float, in_f); + + __builtin_exit (0); +} From jeffrey.law@oss.qualcomm.com Sun Nov 1 17:56:24 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 10:56:24 -0700 Subject: [PATCH] testsuite: Add -fno-signed-zeros to more FMA tests [PR124820] In-Reply-To: <20261030113102.2084217-1-merlin.warner-huish@embecosm.com> References: <20261030113102.2084217-1-merlin.warner-huish@embecosm.com> Message-ID: On 10/30/26 5:31 AM, Merlin Warner-Huish wrote: > r17-5664 restricted the negated FMA folds in match.pd to > !HONOR_SIGNED_ZEROS. These tests expect those folds to apply with the > default options, so they started failing on aarch64. Add > -fno-signed-zeros to them, as that commit did for the i386 FMA tests. > > PR middle-end/124820 > > gcc/testsuite/ChangeLog: > > * gcc.dg/fma-5.c: Add -fno-signed-zeros. > * gcc.dg/fma-6.c: Likewise. > * gcc.dg/fma-7.c: Likewise. > * gcc.target/aarch64/sve/unpacked_cond_fnmla_1.c: Likewise. > * gcc.target/aarch64/sve/unpacked_cond_fnmla_2.c: Likewise. > * gcc.target/aarch64/sve/unpacked_cond_fnmls_1.c: Likewise. > * gcc.target/aarch64/sve/unpacked_cond_fnmls_2.c: Likewise. > * gcc.target/aarch64/sve/unpacked_fnmla_1.c: Likewise. > * gcc.target/aarch64/sve/unpacked_fnmla_2.c: Likewise. > * gcc.target/aarch64/sve/unpacked_fnmls_1.c: Likewise. > * gcc.target/aarch64/sve/unpacked_fnmls_2.c: Likewise. > * gcc.target/aarch64/sve/vcond_13.c: Likewise. > * gcc.target/aarch64/sve/vcond_14.c: Likewise. > * gcc.target/aarch64/sve/vcond_15.c: Likewise. > * gcc.target/aarch64/sve/vcond_16.c: Likewise. > --- > These are the 65 aarch64 failures reported by the Linaro CI after > r17-5664. Tested with an aarch64-linux-gnu cross compiler (they are > all compile-only tests): all of them fail before this patch and pass > after it. Also checked gcc.dg/fma-[567].c on x86_64-pc-linux-gnu. > > The unpacked_cond_* and vcond_* tests cover the IFN_COND_* folds the > original patch changed, so those changes are tested after all. > > My write access request is still pending, so I'd be grateful if > someone could commit this once approved. OK.? I also ack'd your account request over the weekend, so hopefully you'll be set up Monday US time.? I'll push this patch since it's a regression and it's good to see the state go from reg back to green in my tester :-) jeff From mikestump@comcast.net Sun Nov 1 18:02:02 2026 From: mikestump@comcast.net (Mike Stump) Date: Sun, 1 Nov 2026 10:02:02 -0800 Subject: [PATCH] testsuite: Use gcc-nm for symbol scans In-Reply-To: <20261101141813.2019428-1-torbjorn.svensson@foss.st.com> References: <20261101141813.2019428-1-torbjorn.svensson@foss.st.com> Message-ID: On Nov 1, 2026, at 6:15?AM, Torbj?rn SVENSSON wrote: > This fixes the following error for arm-none-eabi (probably other targets too): > > ERROR: gcc.dg/builtin-pi-linkage.c: error executing dg-final: arm-none-eabi-nm: builtin-pi-linkage.o: plugin needed to handle lto object > > Ok for trunk? Ok. From andrew.pinski@oss.qualcomm.com Sun Nov 1 18:28:30 2026 From: andrew.pinski@oss.qualcomm.com (Andrea Pinski) Date: Sun, 1 Nov 2026 10:28:30 -0800 Subject: [PATCH] tree-ssa-forwprop.cc: reorder_ior_chain [PR115547] In-Reply-To: <20261031001936.837141-1-daniel.barboza@oss.qualcomm.com> References: <20261031001936.837141-1-daniel.barboza@oss.qualcomm.com> Message-ID: On Fri, Oct 30, 2026 at 5:19?PM Daniel Barboza wrote: > > Given a boolean only IOR chain that follows a gcond: > > if (a_4 != b_5) > goto ; > else > goto ; > > ;; basic block 3 > ;; prev block 2 > ;; pred: 2 (TRUE_VALUE,EXECUTABLE) > _1 = b_5 | c_6; > _2 = _1 | a_4; > > This would be equivalent to (a != b) && (b | c | a). This can be > simplified to (a != b) because the IOR chain, if a != b, simplifies to > 1. But we're not able to see that due to operand order: we're seeing > res = b | c and then res | a, and we can't derive nothing from these. > If we reorder the operands we're able to leverage the relation that is > derived from the gcond. > > A reordering work like this usually goes in reassoc but we want > visibility of the gcond as well, and the phi access wasn't trivial for > me to fit in there. Forwprop was the next in mind. So thinking about this. This seems to belong in reassociation. Ranger can provide that a_4 == b_5 is true when seeing if ssa names are the same. Maybe if there is a relationship that is known and reassociation should group them together. Note your patch does not handle: ``` int fn2 (int a, int b, int c) { if (a == c) { return c | b | a; } return 0; } ``` Or: ``` int fn2 (int a, int b, int c) { if (a == c) { return c |b | a; } return a | b; } ``` > > Bootstrapped and regression tested in x86_64. > > PR tree-optimization/115547 > > gcc/ChangeLog: > > * tree-ssa-forwprop.cc (reorder_ior_chain): Reorder IOR chains > operands if there's optimization opportunities with a previous > PHI. > (pass_forwprop::execute): Call reorder_ior_chain. > > gcc/testsuite/ChangeLog: > > * gcc.dg/tree-ssa/pr115547-2.c: New test. > * gcc.dg/tree-ssa/pr115547-3.c: New test. > --- > gcc/testsuite/gcc.dg/tree-ssa/pr115547-2.c | 22 +++ > gcc/testsuite/gcc.dg/tree-ssa/pr115547-3.c | 22 +++ > gcc/tree-ssa-forwprop.cc | 167 +++++++++++++++++++++ > 3 files changed, 211 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr115547-2.c > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr115547-3.c > > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr115547-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr115547-2.c > new file mode 100644 > index 00000000000..242a1772ec6 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr115547-2.c > @@ -0,0 +1,22 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O1 -fdump-tree-optimized" } */ > + > +_Bool fn1 (_Bool a, _Bool b, _Bool c) { > + return a != c && (b || (c || a)); > +} > + > +_Bool fn2 (_Bool a, _Bool b, _Bool c) { > + return a != c && (b || c || a); > +} > + > +_Bool fn3 (_Bool a, _Bool b, _Bool c) { > + return a != c && (a || b || c); > +} > + > +_Bool fn4 (_Bool a, _Bool b, _Bool c) { > + return a != c && (a || c || b); > +} > + > +/* { dg-final { scan-tree-dump-times " != " 4 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times " \\\| " 0 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times " & " 0 "optimized" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr115547-3.c b/gcc/testsuite/gcc.dg/tree-ssa/pr115547-3.c > new file mode 100644 > index 00000000000..66577fa3400 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr115547-3.c > @@ -0,0 +1,22 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O1 -fdump-tree-optimized" } */ > + > +_Bool fn1 (_Bool a, _Bool b, _Bool c) { > + return a == c && (b || (c || a)); > +} > + > +_Bool fn2 (_Bool a, _Bool b, _Bool c) { > + return a == c && (b || c || a); > +} > + > +_Bool fn3 (_Bool a, _Bool b, _Bool c) { > + return a == c && (a || b || c); > +} > + > +_Bool fn4 (_Bool a, _Bool b, _Bool c) { > + return a == c && (a || c || b); > +} > + > +/* { dg-final { scan-tree-dump-times " == " 4 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times " \\\| " 4 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times " & " 4 "optimized" } } */ > diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc > index 88f69e12ed1..d9749250e4b 100644 > --- a/gcc/tree-ssa-forwprop.cc > +++ b/gcc/tree-ssa-forwprop.cc > @@ -4937,6 +4937,168 @@ simplify_phi_result_movdiv (gimple *stmt, tree_code code) > return true; > } > > +/* PR115547: given the following IOR sequence where all > + trees involved are bools/zero_one_valued: > + > + ;; basic block 2 > + ;; prev block 0 > + if (a_4 != b_5) > + goto ; > + else > + goto ; > + > + ;; basic block 3 > + ;; prev block 2 > + ;; pred: 2 (TRUE_VALUE,EXECUTABLE) > + _1 = b_5 | c_6; > + _2 = _1 | a_4; > + > + I.e. (a_4 != b_5) && b_5 | c_6 | a_4; > + > + We want to make it easier to deduce the relationship > + a_4 != b_5 in the IOR chain by re-ordering the IORs > + operands, putting a_4 and b_5 in the first IOR: > + > + _1 = b_5 | a_4; > + _2 = _1 | c_6; > + > + Our expectation is that the IOR chain collapses into "1". Note > + that even with a EQ code there's still benefit from reordering > + the IOR chain - we can have one less IOR in the sequence. */ > +static bool > +reorder_ior_chain (gimple *first_ior) > +{ > + tree first_ior_rhs1 = gimple_assign_rhs1 (first_ior); > + tree first_ior_rhs2 = gimple_assign_rhs2 (first_ior); > + > + if (TREE_CODE (first_ior_rhs1) != SSA_NAME > + || !tree_zero_one_valued_p (first_ior_rhs1) > + || TREE_CODE (first_ior_rhs2) != SSA_NAME > + || !tree_zero_one_valued_p (first_ior_rhs2)) > + return false; > + > + basic_block middle_bb = gimple_bb (first_ior); > + gimple_stmt_iterator gsi = gsi_start_nondebug_after_labels_bb (middle_bb); > + > + /* first_ior must be the first insn of the bb. The > + next insn must also be an IOR. */ > + if (gsi_end_p (gsi) > + || gsi_stmt (gsi) != first_ior) > + return false; > + > + gsi_next (&gsi); > + gimple *second_ior = gsi_stmt (gsi); > + > + if (!second_ior > + || gimple_code (second_ior) != GIMPLE_ASSIGN > + || gimple_assign_rhs_code (second_ior) != BIT_IOR_EXPR) > + return false; > + > + tree second_ior_rhs1 = gimple_assign_rhs1 (second_ior); > + tree second_ior_rhs2 = gimple_assign_rhs2 (second_ior); > + > + if (TREE_CODE (second_ior_rhs1) != SSA_NAME > + || !tree_zero_one_valued_p (second_ior_rhs1) > + || TREE_CODE (second_ior_rhs2) != SSA_NAME > + || !tree_zero_one_valued_p (second_ior_rhs2)) > + return false; > + > + /* One of second_ior operands must be LHS (first_ior) and the > + other operand is going to be swapped later. */ > + tree first_lhs = gimple_assign_lhs (first_ior); > + bool swap_second_ior_rhs2; > + if (gimple_assign_rhs1 (second_ior) == first_lhs) > + swap_second_ior_rhs2 = true; > + else if (gimple_assign_rhs2 (second_ior) == first_lhs) > + swap_second_ior_rhs2 = false; > + else > + return false; > + > + /* The current bb must be a single_pred bb and its predecessor > + must have a gcond. */ > + if (!single_pred_p (middle_bb)) > + return false; > + > + edge e = single_pred_edge (middle_bb); > + if (!(e->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE))) > + return false; > + > + basic_block cond_bb = e->src; > + gsi = gsi_last_bb (cond_bb); > + gcond *cond = dyn_cast (gsi_stmt (gsi)); > + > + if (!cond > + || TREE_CODE (gimple_cond_rhs (cond)) != SSA_NAME) > + return false; > + > + tree A = gimple_cond_lhs (cond); > + tree B = gimple_cond_rhs (cond); > + > + if (A != first_ior_rhs1 > + && A != first_ior_rhs2 > + && A != second_ior_rhs1 > + && A != second_ior_rhs2) > + return false; > + > + if (B != first_ior_rhs1 > + && B != first_ior_rhs2 > + && B != second_ior_rhs1 > + && B != second_ior_rhs2) > + return false; > + > + /* A and B are already in first_ior, i.e. nothing to do. */ > + if ((A == first_ior_rhs1 && B == first_ior_rhs2) > + || (A == first_ior_rhs2 && B == first_ior_rhs1)) > + return false; > + > + /* At this point we know that we have A, B and the first_ior > + LHS in the middle of the 2 IOR stmts, and A and B are not > + together in first_ior. Now we need to do is see which RHS > + from first_ior needs to be swapped with the non_LHS element > + from second_ior. */ > + bool swap_first_ior_rhs2 = first_ior_rhs1 == A || first_ior_rhs1 == B; > + if (swap_second_ior_rhs2) > + { > + /* Swap second_ior_rhs2. */ > + if (swap_first_ior_rhs2) > + { > + /* Swap first_ior_rhs2 with second_ior_2. */ > + gimple_assign_set_rhs2 (first_ior, second_ior_rhs2); > + gimple_assign_set_rhs2 (second_ior, first_ior_rhs2); > + } > + else > + { > + /* Swap first_ior_rhs1 with second_ior_2. */ > + gimple_assign_set_rhs1 (first_ior, second_ior_rhs2); > + gimple_assign_set_rhs2 (second_ior, first_ior_rhs1); > + } > + } > + else > + { > + /* Swap second_ior_rhs1. */ > + if (swap_first_ior_rhs2) > + { > + /* Swap first_ior_rhs2 with second_ior_rhs1. */ > + gimple_assign_set_rhs2 (first_ior, second_ior_rhs1); > + gimple_assign_set_rhs1 (second_ior, first_ior_rhs2); > + } > + else > + { > + /* Swap first_ior_rhs1 with second_ior_rhs1. */ > + gimple_assign_set_rhs1 (first_ior, second_ior_rhs1); > + gimple_assign_set_rhs1 (second_ior, first_ior_rhs1); > + } > + } > + > + update_stmt (first_ior); > + update_stmt (second_ior); > + > + if (dump_file && (dump_flags & TDF_DETAILS)) > + fprintf (dump_file, "Changed order of IOR chain operands.\n"); > + > + return true; > +} > + > /* Determine whether applying the 2 permutations (mask1 then mask2) > gives back one of the input. */ > > @@ -7219,6 +7381,11 @@ pass_forwprop::execute (function *fun) > bool folded = match_long_mul (as_a (stmt)); > if (!folded) > folded = simplify_rotate (&gsi); > + > + if (!folded > + && code == BIT_IOR_EXPR) > + folded = reorder_ior_chain (stmt); > + > changed |= folded; > } > else if (code == BIT_XOR_EXPR) > -- > 2.43.0 > From navi@vlhl.dev Sun Nov 1 20:14:38 2026 From: navi@vlhl.dev (navi) Date: Sun, 1 Nov 2026 21:14:38 +0100 Subject: [PATCH v10 0/4] implement defer statements as per ts 25755 Message-ID: <20261101201530.2684116-1-navi@vlhl.dev> fixed a rebase mistake, updated the document url on 4/4, and fixed up typos on docs. Arsen Arsenovi? (1): gcc/testsuite: support specifying a language for additional sources navi (3): c: handle expression nodes in push_cleanup c: introduce jump barriers for statement expressions c: implement defer gcc/Makefile.in | 1 + gcc/c-family/c-common.cc | 1 + gcc/c-family/c-common.h | 1 + gcc/c-family/c-cppbuiltin.cc | 3 + gcc/c/c-decl.cc | 145 ++++++++++++----- gcc/c/c-parser.cc | 39 +++++ gcc/c/c-tree.h | 8 +- gcc/c/c-typeck.cc | 60 ++++++-- gcc/doc/extend.texi | 15 ++ gcc/doc/sourcebuild.texi | 7 +- gcc/ginclude/stddefer.h | 38 +++++ gcc/testsuite/g++.dg/defer-aux.c | 12 ++ gcc/testsuite/g++.dg/defer.C | 29 ++++ gcc/testsuite/gcc.dg/defer-1.c | 256 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/defer-2.c | 78 ++++++++++ gcc/testsuite/gcc.dg/defer-3.c | 17 ++ gcc/testsuite/gcc.dg/defer-4.c | 8 + gcc/testsuite/lib/gcc-defs.exp | 140 +++++++++++++---- gcc/testsuite/lib/gcc-dg.exp | 4 +- 19 files changed, 781 insertions(+), 81 deletions(-) create mode 100644 gcc/ginclude/stddefer.h create mode 100644 gcc/testsuite/g++.dg/defer-aux.c create mode 100644 gcc/testsuite/g++.dg/defer.C create mode 100644 gcc/testsuite/gcc.dg/defer-1.c create mode 100644 gcc/testsuite/gcc.dg/defer-2.c create mode 100644 gcc/testsuite/gcc.dg/defer-3.c create mode 100644 gcc/testsuite/gcc.dg/defer-4.c Range-diff against v9: -: ----------- > 1: ac508d6b7a7 c: handle expression nodes in push_cleanup 1: bdec86a2ad3 ! 2: d0164ec7cf1 c: introduce jump barriers for statement expressions @@ gcc/c/c-decl.cc: finish_underspecified_init (tree name, unsigned int prev_state) in_underspecified_init = (prev_state & (1u << 1)) >> 1; } --/* Adjust the bindings for the start of a statement expression. */ + +/* Push or pop the jump barrier count of a statement expression. */ + +static void +c_binding_adjust_jump_barrier (struct c_spot_bindings *binding, bool start) +{ -+ struct c_jump_barrier *barrier = defer -+ ? &binding->defer_blocks -+ : &binding->stmt_exprs; -+ + if (start) -+ barrier->count++; ++ binding->stmt_exprs.count++; + else -+ barrier->count--; ++ binding->stmt_exprs.count--; + -+ if (barrier->count < 0) ++ if (binding->stmt_exprs.count < 0) + { -+ barrier->count = 0; -+ barrier->left = true; ++ binding->stmt_exprs.count = 0; ++ binding->stmt_exprs.left = true; + } +} + -+/* Adjust the bindings for the start of a statement expression or defer block. */ + /* Adjust the bindings for the start of a statement expression. */ void - c_bindings_start_stmt_expr (struct c_spot_bindings* switch_bindings) @@ gcc/c/c-decl.cc: c_bindings_start_stmt_expr (struct c_spot_bindings* switch_bindings) if (TREE_CODE (b->decl) != LABEL_DECL) continue; @@ gcc/c/c-decl.cc: c_bindings_start_stmt_expr (struct c_spot_bindings* switch_bind + c_binding_adjust_jump_barrier (switch_bindings, true); } --/* Adjust the bindings for the end of a statement expression. */ -+/* Adjust the bindings for the end of a statement expression or defer block. */ - - void - c_bindings_end_stmt_expr (struct c_spot_bindings *switch_bindings) + /* Adjust the bindings for the end of a statement expression. */ @@ gcc/c/c-decl.cc: c_bindings_end_stmt_expr (struct c_spot_bindings *switch_bindings) if (TREE_CODE (b->decl) != LABEL_DECL) continue; @@ gcc/c/c-decl.cc: c_bindings_end_stmt_expr (struct c_spot_bindings *switch_bindin { - --switch_bindings->stmt_exprs; - gcc_assert (switch_bindings->stmt_exprs >= 0); -+ c_binding_adjust_jump_barrier (switch_bindings, defer, false); ++ c_binding_adjust_jump_barrier (switch_bindings, false); + gcc_assert (switch_bindings->stmt_exprs.count >= 0); } } 2: f326f70ee14 = 3: bc24bd62af1 gcc/testsuite: support specifying a language for additional sources 3: ac9492f6281 ! 4: ce5253004bf c: implement defer @@ Commit message local jump shall jump over a defer statement, nor shall return, break, and continue, jump out of one - 1: https://open-std.org/JTC1/SC22/WG14/www/docs/n3734.pdf + 1: https://open-std.org/JTC1/SC22/WG14/www/docs/n3928.pdf gcc/ChangeLog: @@ gcc/c/c-decl.cc: finish_underspecified_init (tree name, unsigned int prev_state) static void -c_binding_adjust_jump_barrier (struct c_spot_bindings *binding, bool start) -+c_binding_adjust_jump_barrier (struct c_spot_bindings *binding, -+ bool defer, bool start) ++c_binding_adjust_jump_barrier (struct c_spot_bindings *binding, bool defer, bool start) { - struct c_jump_barrier *barrier = defer - ? &binding->defer_blocks -@@ gcc/c/c-decl.cc: c_binding_adjust_jump_barrier (struct c_spot_bindings *binding, bool start) - /* Adjust the bindings for the start of a statement expression or defer block. */ +- if (start) +- binding->stmt_exprs.count++; +- else +- binding->stmt_exprs.count--; ++ struct c_jump_barrier *barrier = defer ++ ? &binding->defer_blocks ++ : &binding->stmt_exprs; + +- if (binding->stmt_exprs.count < 0) ++ if (start) ++ barrier->count++; ++ else ++ barrier->count--; ++ ++ if (barrier->count < 0) + { +- binding->stmt_exprs.count = 0; +- binding->stmt_exprs.left = true; ++ barrier->count = 0; ++ barrier->left = true; + } + } + +-/* Adjust the bindings for the start of a statement expression. */ ++/* Adjust the bindings for the start of a statement expression or defer block. */ void -c_bindings_start_stmt_expr (struct c_spot_bindings* switch_bindings) @@ gcc/c/c-decl.cc: c_bindings_start_stmt_expr (struct c_spot_bindings* switch_bind + } } - /* Adjust the bindings for the end of a statement expression or defer block. */ + /* Adjust the bindings for the end of a statement expression. */ void -c_bindings_end_stmt_expr (struct c_spot_bindings *switch_bindings) @@ gcc/c/c-decl.cc: c_bindings_end_stmt_expr (struct c_spot_bindings *switch_bindin } } -@@ gcc/c/c-decl.cc: c_bindings_end_stmt_expr (struct c_spot_bindings *switch_bindings) + if (switch_bindings != NULL) { - c_binding_adjust_jump_barrier (switch_bindings, defer, false); +- c_binding_adjust_jump_barrier (switch_bindings, false); ++ c_binding_adjust_jump_barrier (switch_bindings, defer, false); gcc_assert (switch_bindings->stmt_exprs.count >= 0); + gcc_assert (switch_bindings->defer_blocks.count >= 0); } @@ gcc/doc/extend.texi: These identifiers are variables, not preprocessor macros, a +language keyword for deferred execution of statements on scope exit. As an +extension, GNU C recognizes @code{_Defer} in all C versions. + -+If @option{-fexceptions} is enabled, then all defeered statements ++If @option{-fexceptions} is enabled, then all deferred statements +are run during the stack unwinding that happens during the processing +of the exception. Note that the @code{_Defer} does not allow the +exception to be caught, only to perform an action. -- 2.55.0 From navi@vlhl.dev Sun Nov 1 20:14:39 2026 From: navi@vlhl.dev (navi) Date: Sun, 1 Nov 2026 21:14:39 +0100 Subject: [PATCH v10 1/4] c: handle expression nodes in push_cleanup In-Reply-To: <20261101201530.2684116-1-navi@vlhl.dev> References: <20261101201530.2684116-1-navi@vlhl.dev> Message-ID: <20261101201530.2684116-2-navi@vlhl.dev> for future use with defer statements, as they do not have a declaration associated, and are bound to the scope with a BIND_EXPR gcc/c/ChangeLog: * c-typeck.cc (push_cleanup): Handle EXPR_P nodes. Signed-off-by: navi --- gcc/c/c-typeck.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 2d020085833..df4b1686975 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -14147,14 +14147,20 @@ c_end_compound_stmt (location_t loc, tree stmt, bool do_scope) meant to apply to normal control flow transfer. */ void -push_cleanup (tree decl, tree cleanup, bool eh_only) +push_cleanup (tree node, tree cleanup, bool eh_only) { + location_t loc = UNKNOWN_LOCATION; enum tree_code code; tree stmt, list; bool stmt_expr; + if (DECL_P (node)) + loc = DECL_SOURCE_LOCATION (node); + else if (EXPR_P (node)) + loc = EXPR_LOCATION (node); + code = eh_only ? TRY_CATCH_EXPR : TRY_FINALLY_EXPR; - stmt = build_stmt (DECL_SOURCE_LOCATION (decl), code, NULL, cleanup); + stmt = build_stmt (loc, code, NULL, cleanup); add_stmt (stmt); stmt_expr = STATEMENT_LIST_STMT_EXPR (cur_stmt_list); list = push_stmt_list (); -- 2.55.0 From navi@vlhl.dev Sun Nov 1 20:14:40 2026 From: navi@vlhl.dev (navi) Date: Sun, 1 Nov 2026 21:14:40 +0100 Subject: [PATCH v10 2/4] c: introduce jump barriers for statement expressions In-Reply-To: <20261101201530.2684116-1-navi@vlhl.dev> References: <20261101201530.2684116-1-navi@vlhl.dev> Message-ID: <20261101201530.2684116-3-navi@vlhl.dev> represent the start and end of scope which a local jump is not allowed to cross as a jump barrier, moving this logic out into a function allows for defer statements to use the same codepath gcc/c/ChangeLog: * c-decl.cc (struct c_jump_barrier): New structure. (struct c_spot_bindings): Extract out members to struct c_jump_barrier. (set_spot_bindings): Adjust member access for c_jump_barrier. (c_binding_adjust_jump_barrier): New function. (c_bindings_start_stmt_expr): Call c_binding_adjust_jump_barrier. (c_bindings_end_stmt_expr): Likewise. (lookup_label_for_goto): Adjust member access for c_jump_barrier. (check_earlier_gotos): Likewise. (c_release_switch_bindings): Likewise. (c_check_switch_jump_warnings): Likewise. Signed-off-by: navi --- gcc/c/c-decl.cc | 78 +++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index ada5a5043af..700b0409643 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -383,6 +383,16 @@ c_tree_size (enum tree_code code) scopes are popped, we update these structures and gather the decls that matter at that time. */ +struct GTY(()) c_jump_barrier { + /* The number of barriers that have started since this label or goto + statement was defined. This is zero if we are at the same barrier. + It is positive if we are in a barrier that started since this spot. + If it goes negative, it is reset to zero and .left is set to true. */ + int count; + /* Whether we started in a barrier but are no longer in it. */ + bool left; +}; + struct GTY(()) c_spot_bindings { /* The currently open scope which holds bindings defined when the label was defined or the goto statement was found. */ @@ -391,16 +401,7 @@ struct GTY(()) c_spot_bindings { of the label or goto. This lets us look at older or newer bindings in the scope, as appropriate. */ struct c_binding *bindings_in_scope; - /* The number of statement expressions that have started since this - label or goto statement was defined. This is zero if we are at - the same statement expression level. It is positive if we are in - a statement expression started since this spot. It is negative - if this spot was in a statement expression and we have left - it. */ - int stmt_exprs; - /* Whether we started in a statement expression but are no longer in - it. This is set to true if stmt_exprs ever goes negative. */ - bool left_stmt_expr; + struct c_jump_barrier stmt_exprs; }; /* This structure is used to keep track of bindings seen when a goto @@ -989,8 +990,8 @@ set_spot_bindings (struct c_spot_bindings *p, bool defining) p->scope = NULL; p->bindings_in_scope = NULL; } - p->stmt_exprs = 0; - p->left_stmt_expr = false; + p->stmt_exprs.count = 0; + p->stmt_exprs.left = false; } /* Update spot bindings P as we pop out of SCOPE. Return true if we @@ -1616,6 +1617,24 @@ finish_underspecified_init (tree name, unsigned int prev_state) in_underspecified_init = (prev_state & (1u << 1)) >> 1; } + +/* Push or pop the jump barrier count of a statement expression. */ + +static void +c_binding_adjust_jump_barrier (struct c_spot_bindings *binding, bool start) +{ + if (start) + binding->stmt_exprs.count++; + else + binding->stmt_exprs.count--; + + if (binding->stmt_exprs.count < 0) + { + binding->stmt_exprs.count = 0; + binding->stmt_exprs.left = true; + } +} + /* Adjust the bindings for the start of a statement expression. */ void @@ -1639,14 +1658,15 @@ c_bindings_start_stmt_expr (struct c_spot_bindings* switch_bindings) if (TREE_CODE (b->decl) != LABEL_DECL) continue; label_vars = b->u.label; - ++label_vars->label_bindings.stmt_exprs; + + c_binding_adjust_jump_barrier (&label_vars->label_bindings, true); FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g) - ++g->goto_bindings.stmt_exprs; + c_binding_adjust_jump_barrier (&g->goto_bindings, true); } } if (switch_bindings != NULL) - ++switch_bindings->stmt_exprs; + c_binding_adjust_jump_barrier (switch_bindings, true); } /* Adjust the bindings for the end of a statement expression. */ @@ -1672,28 +1692,16 @@ c_bindings_end_stmt_expr (struct c_spot_bindings *switch_bindings) if (TREE_CODE (b->decl) != LABEL_DECL) continue; label_vars = b->u.label; - --label_vars->label_bindings.stmt_exprs; - if (label_vars->label_bindings.stmt_exprs < 0) - { - label_vars->label_bindings.left_stmt_expr = true; - label_vars->label_bindings.stmt_exprs = 0; - } + c_binding_adjust_jump_barrier (&label_vars->label_bindings, false); FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g) - { - --g->goto_bindings.stmt_exprs; - if (g->goto_bindings.stmt_exprs < 0) - { - g->goto_bindings.left_stmt_expr = true; - g->goto_bindings.stmt_exprs = 0; - } - } + c_binding_adjust_jump_barrier (&g->goto_bindings, false); } } if (switch_bindings != NULL) { - --switch_bindings->stmt_exprs; - gcc_assert (switch_bindings->stmt_exprs >= 0); + c_binding_adjust_jump_barrier (switch_bindings, false); + gcc_assert (switch_bindings->stmt_exprs.count >= 0); } } @@ -4278,7 +4286,7 @@ lookup_label_for_goto (location_t loc, tree name) FOR_EACH_VEC_SAFE_ELT (label_vars->decls_in_scope, ix, decl) warn_about_goto (loc, label, decl); - if (label_vars->label_bindings.left_stmt_expr) + if (label_vars->label_bindings.stmt_exprs.left) { auto_diagnostic_group d; error_at (loc, "jump into statement expression"); @@ -4369,7 +4377,7 @@ check_earlier_gotos (tree label, struct c_label_vars* label_vars) } } - if (g->goto_bindings.stmt_exprs > 0) + if (g->goto_bindings.stmt_exprs.count > 0) { auto_diagnostic_group d; error_at (g->loc, "jump into statement expression"); @@ -4460,7 +4468,7 @@ c_get_switch_bindings (void) void c_release_switch_bindings (struct c_spot_bindings *bindings) { - gcc_assert (bindings->stmt_exprs == 0 && !bindings->left_stmt_expr); + gcc_assert (bindings->stmt_exprs.count == 0 && !bindings->stmt_exprs.left); XDELETE (bindings); } @@ -4524,7 +4532,7 @@ c_check_switch_jump_warnings (struct c_spot_bindings *switch_bindings, } } - if (switch_bindings->stmt_exprs > 0) + if (switch_bindings->stmt_exprs.count > 0) { saw_error = true; auto_diagnostic_group d; -- 2.55.0 From navi@vlhl.dev Sun Nov 1 20:14:41 2026 From: navi@vlhl.dev (navi) Date: Sun, 1 Nov 2026 21:14:41 +0100 Subject: [PATCH v10 3/4] gcc/testsuite: support specifying a language for additional sources In-Reply-To: <20261101201530.2684116-1-navi@vlhl.dev> References: <20261101201530.2684116-1-navi@vlhl.dev> Message-ID: <20261101201530.2684116-4-navi@vlhl.dev> From: Arsen Arsenovi? This patch permits the dg-additional-sources construct to accept a 'lang' clause. This 'lang' clause tells the testsuite to pass '-x' flags around the additional sources list, which is useful for multi-language tests that can be built with one driver invocation. Tested-by: navi gcc/testsuite/ChangeLog: * lib/gcc-defs.exp (additional_sources_omit_on_compile): Drop. (additional_sources): Instead of a list, make it a list of "additional sources" entries, which are triplets holding the language and linkonly status for a given dg-additional-sources invocation in addition to FILELIST. (dg-additional-sources): Process 'lang' clause. Produce entries like described above. Rewrite clause parsing to be less strange. (dg-additional-files-options): Update to match changes above. Pass -x LANG -Wno-complain-wrong-lang ... -x none if LANG is nonempty in list above. * lib/gcc-dg.exp (schedule-cleanups): Fix interpretation of $additional_sources now that it's a list. gcc/ChangeLog: * doc/sourcebuild.texi (Specify additional files for a test): Document dg-additional-sources { lang ... } clause. --- gcc/doc/sourcebuild.texi | 7 +- gcc/testsuite/lib/gcc-defs.exp | 140 ++++++++++++++++++++++++++------- gcc/testsuite/lib/gcc-dg.exp | 4 +- 3 files changed, 119 insertions(+), 32 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index db725087566..bd07e760247 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -1347,7 +1347,7 @@ to @var{var_value} before execution of the program created by the test. Specify additional files, other than source files, that must be copied to the system where the compiler runs. -@item @{ dg-additional-sources "@var{filelist}" [@{ \[linkonly\] \[target @var{selector}\] @}] @} +@item @{ dg-additional-sources "@var{filelist}" [@{ \[linkonly\] \[target @var{selector}\] @}] @{ lang @var{lang} @} @} Specify additional source files to appear in the compile line following the main test file. If the directive includes the optional @samp{@{ @var{selector} @}} @@ -1357,6 +1357,11 @@ If @samp{linkonly} is specified, additional sources are used only in @samp{link} and @samp{run} tests; they are reported as unsupported and discarded in other kinds of tests that direct the compiler to output to a single file. + +If the directive includes the optional @samp{@{ lang @var{lang} @}} +clause, then the additional sources are given to the driver surrounded +with @code{-x @var{lang}} and @code{-x none} flag. The driver is also +given the @option{-Wno-complain-wrong-lang} flag. @end table @subsubsection Add checks at the end of a test diff --git a/gcc/testsuite/lib/gcc-defs.exp b/gcc/testsuite/lib/gcc-defs.exp index 191e2b83fe1..0b58f45d587 100644 --- a/gcc/testsuite/lib/gcc-defs.exp +++ b/gcc/testsuite/lib/gcc-defs.exp @@ -305,34 +305,86 @@ proc dg-additional-options { args } { # Record additional sources files that must be compiled along with the # main source file. +# List of additional sources. Each additional sources entry is a list of form: +# +# { FILELIST LANG LINKONLY } +# +# FILELIST is a list of additional files, LANG is the language they should be +# parsed as, if any. If present, FILELIST will be passed to the compiler as: +# +# -x LANG FILELIST -x none +# +# ... and otherwise just as FILELIST, without any '-x'. LINKONLY is true iff +# FILELIST should be omitted on compile, otherwise false. set additional_sources "" -set additional_sources_omit_on_compile "" set additional_sources_used "" proc dg-additional-sources { args } { global additional_sources - global additional_sources_omit_on_compile - if { [llength $args] > 3 } { - error "[lindex $args 0]: too many arguments" + # Must see at least { dg-additional-sources SOURCE } + if { [llength $args] < 2 } { + error "[lindex $args 0]: too few arguments" return } - set target [lindex $args 2] - if { [llength $args] >= 3 && [lindex $target 0] == "linkonly" } { - append additional_sources_omit_on_compile " [lindex $args 1]" - set target [lreplace $target 0 1] + set filearg [lindex $args 1] + set target {} + set lang {} + set linkonly false + + # Iterate given clauses. + foreach arg [lreplace $args 0 1] { + # First, check if the current one is { linkonly ... } or "linkonly". + # This is because we currently permit both '{ linkonly target ... }' + # and mere 'linkonly'. + if { [lindex $arg 0] == "linkonly" } { + set linkonly true + set arg [lreplace $arg 0 0] + + # If we processed the whole clause, skip the rest of the work. + if { [llength $arg] == 0 } { + continue + } + } + + # Then, try for the target clause. + if { [lindex $arg 0] == "target" } { + if { $target != {} } { + error "[lindex $args 0]: duplicate `target' clause" + } + set target $arg + continue + } + + # Then, try the 'lang' clause. This one adds '-x LANG ... -x none' to + # additional_flags instead of just the filename. + if { [lindex $arg 0] == "lang" } { + if { $lang != {} } { + error "[lindex $args 0]: duplicate `lang' clause" + } + if { [llength $arg] != 2 } { + error "[lindex $args 0]: `lang' clause must be of form { lang LANG }" + } + set lang [lindex $arg 1] + continue + } + + error "[lindex $args 0]: could not parse clause $arg" } - if { [llength $args] >= 3 && $target != ""} { + # Construct the additional sources element + set entry [list $filearg $lang $linkonly] + + if { $target != "" } { switch [dg-process-target $target] { - "S" { append additional_sources " [lindex $args 1]" } + "S" { lappend additional_sources $entry } "N" { } "F" { error "[lindex $args 0]: `xfail' not allowed here" } "P" { error "[lindex $args 0]: `xfail' not allowed here" } } } else { - append additional_sources " [lindex $args 1]" + lappend additional_sources $entry } } @@ -418,39 +470,67 @@ proc dg-additional-files-options { options source dest type } { gcc_adjust_linker_flags global additional_sources - global additional_sources_omit_on_compile global additional_sources_used global additional_files set to_download [list] - if { $additional_sources_omit_on_compile != "" \ + + # Find if we have any linkonly sources. + set has_linkonly false + foreach s $additional_sources { + if [lindex $s 2] { + set has_linkonly true + break + } + } + + if { $has_linkonly && $additional_sources != "" \ && $type != "executable" && $dest != "" } then { - set linkonly "" + # Extract only linkonly sources, emit unsupported for rest. + set linkonly {} foreach s $additional_sources { - foreach s2 $additional_sources_omit_on_compile { - if { $s == $s2 } { - unsupported "$s: additional-source will not be used to build $dest" - set s "" - break - } + if [lindex $s 2] { + lappend linkonly $s + continue } - if { $s != "" } { - append linkonly " $s" + + # This source set is not linkonly, emit 'unsupported'. + foreach s2 [lindex $s 0] { + unsupported "$s2: additional-source will not be used to build $dest" } } set additional_sources "$linkonly" } if { $additional_sources == "" } then { } else { - if [is_remote host] { - lappend options "additional_flags=$additional_sources" + set additional_sources_used {} + foreach s $additional_sources { + set files [lindex $s 0] + set lang [lindex $s 1] + + # Add -x LANG + if { $lang != "" } { + lappend options "additional_flags=-x $lang" + lappend options "additional_flags=-Wno-complain-wrong-lang" + } + + # Add the actual sources + if [is_remote host] { + lappend options "additional_flags=$files" + } + regsub -all {^ *| *} $files " [file dirname $source]/" files + if ![is_remote host] { + lappend options "additional_flags=$files" + } + append to_download $files + append additional_sources_used $files + + # Undo -x LANG + if { $lang != "" } { + lappend options "additional_flags=-x none" + } } - regsub -all {^ *| *} $additional_sources " [file dirname $source]/" additional_sources - if ![is_remote host] { - lappend options "additional_flags=$additional_sources" - } - set to_download [concat $to_download $additional_sources] - set additional_sources_used "$additional_sources" + set additional_sources "" # This option restores naming of aux and dump output files # after input files when multiple input files are named, diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 9f183259257..ac1412d8195 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -139,7 +139,9 @@ proc schedule-cleanups { opts } { lappend testcases [lindex [testname-for-summary] 0] verbose "Cleanup testcases: $testcases" 4 if { [info exists additional_sources] && $additional_sources != "" } { - lappend testcases $additional_sources + foreach s $additional_sources { + append testcases " [lindex $s 0]" + } verbose "Cleanup testcases, additional: $additional_sources" 4 } verbose "Cleanup all options: $opts" 4 -- 2.55.0 From navi@vlhl.dev Sun Nov 1 20:14:42 2026 From: navi@vlhl.dev (navi) Date: Sun, 1 Nov 2026 21:14:42 +0100 Subject: [PATCH v10 4/4] c: implement defer In-Reply-To: <20261101201530.2684116-1-navi@vlhl.dev> References: <20261101201530.2684116-1-navi@vlhl.dev> Message-ID: <20261101201530.2684116-5-navi@vlhl.dev> based on the technical specification 25755[1] as an extension _Defer is provided as a keyword if gnu extensions are enabled, and stddefer.h provided a macro for the 'defer' spelling deferred statements execute at the end of the scope they're added on, similar to the cleanup attribute, and they have much of the same constraints as statement expressions, with added limitation that no local jump shall jump over a defer statement, nor shall return, break, and continue, jump out of one 1: https://open-std.org/JTC1/SC22/WG14/www/docs/n3928.pdf gcc/ChangeLog: * Makefile.in: * ginclude/stddefer.h: New file. gcc/c-family/ChangeLog: * c-common.cc: Add _Defer keywords. * c-common.h (enum rid): Add RID_DEFER. * c-cppbuiltin.cc (c_cpp_builtins): Set __STDC_DEFER_TS25755__. gcc/c/ChangeLog: * c-decl.cc (struct c_spot_bindings): Add defer_blocks. (struct c_scope): Add has_defer_block flag. (set_spot_bindings): Clear defer_blocks. (c_binding_adjust_jump_barrier): Handle deferred blocks. (c_bindings_start_stmt_expr): Rename to c_bindings_start_jump_barrier. (c_bindings_start_jump_barrier): Handle deferred statements. (c_bindings_end_stmt_expr): Rename to c_bindings_end_jump_barrier. (c_bindings_end_jump_barrier): Handle deferred statements. (lookup_label_for_goto): Check defer contraints. (check_earlier_gotos): Likewise. (c_release_switch_bindings): Likewise. (c_check_switch_jump_warnings): Likewise. * c-parser.cc (c_parser_defer_statement): New function. (c_parser_statement_after_labels): Check defer contraints and parse defer. * c-tree.h (IN_DEFER_STMT): Add variant. (c_bindings_start_stmt_expr): Rename to c_bindings_start_jump_barrier. (c_bindings_end_stmt_expr): Rename to c_bindings_end_jump_barrier. (c_bindings_start_jump_barrier): New function. (c_bindings_end_jump_barrier): New function. (c_begin_defer_block): New function. (c_end_defer_block): New function. * c-typeck.cc (c_finish_return): (c_finish_bc_stmt): Check for IN_DEFER_STMT. (c_begin_stmt_expr): Likewise. (c_finish_stmt_expr): Likewise. (c_begin_defer_block): New function. (c_end_defer_block): New function. gcc/testsuite/ChangeLog: * gcc.dg/defer-1.c: New test. * gcc.dg/defer-2.c: New test. * gcc.dg/defer-3.c: New test. * gcc.dg/defer-4.c: New test. gcc/ChangeLog: * doc/extend.texi: Add _Defer documentation. Signed-off-by: navi --- gcc/Makefile.in | 1 + gcc/c-family/c-common.cc | 1 + gcc/c-family/c-common.h | 1 + gcc/c-family/c-cppbuiltin.cc | 3 + gcc/c/c-decl.cc | 99 +++++++++--- gcc/c/c-parser.cc | 39 +++++ gcc/c/c-tree.h | 8 +- gcc/c/c-typeck.cc | 50 +++++- gcc/doc/extend.texi | 15 ++ gcc/ginclude/stddefer.h | 38 +++++ gcc/testsuite/g++.dg/defer-aux.c | 12 ++ gcc/testsuite/g++.dg/defer.C | 29 ++++ gcc/testsuite/gcc.dg/defer-1.c | 256 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/defer-2.c | 78 ++++++++++ gcc/testsuite/gcc.dg/defer-3.c | 17 ++ gcc/testsuite/gcc.dg/defer-4.c | 8 + 16 files changed, 627 insertions(+), 28 deletions(-) create mode 100644 gcc/ginclude/stddefer.h create mode 100644 gcc/testsuite/g++.dg/defer-aux.c create mode 100644 gcc/testsuite/g++.dg/defer.C create mode 100644 gcc/testsuite/gcc.dg/defer-1.c create mode 100644 gcc/testsuite/gcc.dg/defer-2.c create mode 100644 gcc/testsuite/gcc.dg/defer-3.c create mode 100644 gcc/testsuite/gcc.dg/defer-4.c diff --git a/gcc/Makefile.in b/gcc/Makefile.in index f2a015d729d..8a1999fcd99 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -487,6 +487,7 @@ USER_H = $(srcdir)/ginclude/float.h \ $(srcdir)/ginclude/stdatomic.h \ $(srcdir)/ginclude/stdckdint.h \ $(srcdir)/ginclude/stdcountof.h \ + $(srcdir)/ginclude/stddefer.h \ $(EXTRA_HEADERS) USER_H_INC_NEXT_PRE = @user_headers_inc_next_pre@ diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index 6380bec4515..3f0bcd65ee1 100644 --- a/gcc/c-family/c-common.cc +++ b/gcc/c-family/c-common.cc @@ -415,6 +415,7 @@ const struct c_common_resword c_common_reswords[] = { "_Decimal64", RID_DFLOAT64, D_CONLY }, { "_Decimal128", RID_DFLOAT128, D_CONLY }, { "_Decimal64x", RID_DFLOAT64X, D_CONLY }, + { "_Defer", RID_DEFER, D_CONLY | D_EXT }, { "_Fract", RID_FRACT, D_CONLY | D_EXT }, { "_Accum", RID_ACCUM, D_CONLY | D_EXT }, { "_Sat", RID_SAT, D_CONLY | D_EXT }, diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 197db508c16..fe4bf92762f 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -114,6 +114,7 @@ enum rid RID_BUILTIN_COUNTED_BY_REF, RID_BUILTIN_BSWAPG, RID_BUILTIN_BITREVERSEG, RID_DFLOAT32, RID_DFLOAT64, RID_DFLOAT128, RID_DFLOAT64X, + RID_DEFER, /* TS 18661-3 keywords, in the same sequence as the TI_* values. */ RID_FLOAT16, diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc index 2c68681a368..8e4ec7550db 100644 --- a/gcc/c-family/c-cppbuiltin.cc +++ b/gcc/c-family/c-cppbuiltin.cc @@ -1669,6 +1669,9 @@ c_cpp_builtins (cpp_reader *pfile) if (flag_iso) cpp_define (pfile, "__STRICT_ANSI__"); + if (!flag_no_gnu_keywords) + builtin_define_with_int_value ("__STDC_DEFER_TS25755__", 1); + if (!flag_signed_char) cpp_define (pfile, "__CHAR_UNSIGNED__"); diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 700b0409643..ce67d8f5320 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -401,7 +401,7 @@ struct GTY(()) c_spot_bindings { of the label or goto. This lets us look at older or newer bindings in the scope, as appropriate. */ struct c_binding *bindings_in_scope; - struct c_jump_barrier stmt_exprs; + struct c_jump_barrier stmt_exprs, defer_blocks; }; /* This structure is used to keep track of bindings seen when a goto @@ -535,6 +535,10 @@ struct GTY((chain_next ("%h.outer"))) c_scope { decl_jump_unsafe would return true for any of the bindings. This is used to avoid looping over all the bindings unnecessarily. */ bool has_jump_unsafe_decl : 1; + + /* True if this scope has any deferred statement. This is used to + * check invalid goto jumps. */ + bool has_defer_block : 1; }; /* The scope currently in effect. */ @@ -992,6 +996,8 @@ set_spot_bindings (struct c_spot_bindings *p, bool defining) } p->stmt_exprs.count = 0; p->stmt_exprs.left = false; + p->defer_blocks.count = 0; + p->defer_blocks.left = false; } /* Update spot bindings P as we pop out of SCOPE. Return true if we @@ -1618,30 +1624,37 @@ finish_underspecified_init (tree name, unsigned int prev_state) } -/* Push or pop the jump barrier count of a statement expression. */ +/* Push or pop the jump barrier count of a statement expression or defer block. */ static void -c_binding_adjust_jump_barrier (struct c_spot_bindings *binding, bool start) +c_binding_adjust_jump_barrier (struct c_spot_bindings *binding, bool defer, bool start) { - if (start) - binding->stmt_exprs.count++; - else - binding->stmt_exprs.count--; + struct c_jump_barrier *barrier = defer + ? &binding->defer_blocks + : &binding->stmt_exprs; - if (binding->stmt_exprs.count < 0) + if (start) + barrier->count++; + else + barrier->count--; + + if (barrier->count < 0) { - binding->stmt_exprs.count = 0; - binding->stmt_exprs.left = true; + barrier->count = 0; + barrier->left = true; } } -/* Adjust the bindings for the start of a statement expression. */ +/* Adjust the bindings for the start of a statement expression or defer block. */ void -c_bindings_start_stmt_expr (struct c_spot_bindings* switch_bindings) +c_bindings_start_jump_barrier (bool defer, struct c_spot_bindings* switch_bindings) { struct c_scope *scope; + if (defer) + current_scope->has_defer_block = true; + for (scope = current_scope; scope != NULL; scope = scope->outer) { struct c_binding *b; @@ -1659,20 +1672,24 @@ c_bindings_start_stmt_expr (struct c_spot_bindings* switch_bindings) continue; label_vars = b->u.label; - c_binding_adjust_jump_barrier (&label_vars->label_bindings, true); + c_binding_adjust_jump_barrier (&label_vars->label_bindings, defer, true); FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g) - c_binding_adjust_jump_barrier (&g->goto_bindings, true); + c_binding_adjust_jump_barrier (&g->goto_bindings, defer, true); } } if (switch_bindings != NULL) - c_binding_adjust_jump_barrier (switch_bindings, true); + { + if (defer) + switch_bindings->scope->has_defer_block = true; + c_binding_adjust_jump_barrier (switch_bindings, defer, true); + } } /* Adjust the bindings for the end of a statement expression. */ void -c_bindings_end_stmt_expr (struct c_spot_bindings *switch_bindings) +c_bindings_end_jump_barrier (bool defer, struct c_spot_bindings *switch_bindings) { struct c_scope *scope; @@ -1692,16 +1709,17 @@ c_bindings_end_stmt_expr (struct c_spot_bindings *switch_bindings) if (TREE_CODE (b->decl) != LABEL_DECL) continue; label_vars = b->u.label; - c_binding_adjust_jump_barrier (&label_vars->label_bindings, false); + c_binding_adjust_jump_barrier (&label_vars->label_bindings, defer, false); FOR_EACH_VEC_SAFE_ELT (label_vars->gotos, ix, g) - c_binding_adjust_jump_barrier (&g->goto_bindings, false); + c_binding_adjust_jump_barrier (&g->goto_bindings, defer, false); } } if (switch_bindings != NULL) { - c_binding_adjust_jump_barrier (switch_bindings, false); + c_binding_adjust_jump_barrier (switch_bindings, defer, false); gcc_assert (switch_bindings->stmt_exprs.count >= 0); + gcc_assert (switch_bindings->defer_blocks.count >= 0); } } @@ -4293,6 +4311,12 @@ lookup_label_for_goto (location_t loc, tree name) inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label); } + if (label_vars->label_bindings.defer_blocks.left) + { + error_at (loc, "jump into defer block"); + inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label); + } + return label; } @@ -4384,6 +4408,23 @@ check_earlier_gotos (tree label, struct c_label_vars* label_vars) inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label); } + + if (g->goto_bindings.defer_blocks.count > 0) + { + error_at (g->loc, "jump into defer block"); + inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label); + } + else if (g->goto_bindings.defer_blocks.left) + { + error_at (g->loc, "jump out of defer block"); + inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label); + } + else if (label_vars->label_bindings.scope->has_defer_block + || g->goto_bindings.scope->has_defer_block) + { + error_at (g->loc, "jump over defer block"); + inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label); + } } /* Now that the label is defined, we will issue warnings about @@ -4469,6 +4510,7 @@ void c_release_switch_bindings (struct c_spot_bindings *bindings) { gcc_assert (bindings->stmt_exprs.count == 0 && !bindings->stmt_exprs.left); + gcc_assert (bindings->defer_blocks.count == 0 && !bindings->defer_blocks.left); XDELETE (bindings); } @@ -4540,6 +4582,25 @@ c_check_switch_jump_warnings (struct c_spot_bindings *switch_bindings, inform (switch_loc, "switch starts here"); } + if (switch_bindings->defer_blocks.count > 0) + { + saw_error = true; + error_at (case_loc, "switch jumps into defer block"); + inform (switch_loc, "switch starts here"); + } + else if (switch_bindings->defer_blocks.left) + { + saw_error = true; + error_at (case_loc, "switch jumps out of defer block"); + inform (switch_loc, "switch starts here"); + } + else if (switch_bindings->scope->has_defer_block) + { + saw_error = true; + error_at (case_loc, "switch jumps over defer block"); + inform (switch_loc, "switch starts here"); + } + return saw_error; } diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 519959e7290..29fa5c4885e 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -1849,6 +1849,7 @@ static void c_parser_statement_after_labels (c_parser *, bool *, tree, static tree c_parser_c99_block_statement (c_parser *, bool *, location_t * = NULL); static void c_parser_if_statement (c_parser *, bool *, vec *); +static void c_parser_defer_statement (c_parser *parser, bool *if_p, tree before_labels); static void c_parser_switch_statement (c_parser *, bool *, tree); static void c_parser_while_statement (c_parser *, bool, unsigned short, bool, bool *, tree); @@ -8402,6 +8403,9 @@ c_parser_statement_after_labels (c_parser *parser, bool *if_p, case RID_FOR: c_parser_for_statement (parser, false, 0, false, if_p, before_labels); break; + case RID_DEFER: + c_parser_defer_statement (parser, if_p, before_labels); + break; case RID_GOTO: c_parser_consume_token (parser); if (c_parser_next_token_is (parser, CPP_NAME)) @@ -8928,6 +8932,41 @@ c_parser_if_statement (c_parser *parser, bool *if_p, vec *chain) c_parser_maybe_reclassify_token (parser); } +/* Parse a defer statement (ISO/DIS TS 25755 6.4). + + defer-statement: + defer deferred-block */ + +static void +c_parser_defer_statement (c_parser *parser, bool *if_p, tree before_labels) +{ + location_t loc = c_parser_peek_token (parser)->location; + unsigned char save_in_statement = in_statement; + tree deferred; + + gcc_assert (c_parser_next_token_is_keyword (parser, RID_DEFER)); + c_parser_consume_token (parser); + + if (c_parser_next_token_is (parser, CPP_SEMICOLON)) + { + c_end_defer_block (loc, c_begin_defer_block ()); + add_stmt (build_empty_stmt (loc)); + c_parser_consume_token (parser); + warning_at (loc, OPT_Wempty_body, + "suggest braces around empty body in % statement"); + return; + } + + deferred = c_begin_defer_block (); + + in_statement = IN_DEFER_STMT; + c_parser_statement_after_labels (parser, if_p, before_labels); + in_statement = save_in_statement; + + deferred = c_end_defer_block (loc, deferred); + push_cleanup(deferred, deferred, false); +} + /* Parse a switch statement (C90 6.6.4, C99 6.8.4, C11 6.8.4). switch-statement: diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 0800230873b..db63f6af300 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -667,6 +667,7 @@ extern struct obstack parser_obstack; #define IN_OMP_FOR 8 #define IN_OBJC_FOREACH 16 #define IN_NAMED_STMT 32 +#define IN_DEFER_STMT 64 extern unsigned char in_statement; extern bool switch_statement_break_seen_p; @@ -678,8 +679,8 @@ extern void finish_underspecified_init (tree, unsigned int); extern void push_scope (void); extern tree pop_scope (void); extern void c_mark_decl_jump_unsafe_in_current_scope (); -extern void c_bindings_start_stmt_expr (struct c_spot_bindings *); -extern void c_bindings_end_stmt_expr (struct c_spot_bindings *); +extern void c_bindings_start_jump_barrier (bool, struct c_spot_bindings *); +extern void c_bindings_end_jump_barrier (bool, struct c_spot_bindings *); extern void record_inline_static (location_t, tree, tree, enum c_inline_static_type); @@ -925,6 +926,9 @@ extern tree c_end_compound_stmt (location_t, tree, bool); extern void c_finish_if_stmt (location_t, tree, tree, tree); extern void c_finish_loop (location_t, location_t, tree, location_t, tree, tree, tree, tree, bool); + +extern tree c_begin_defer_block (void); +extern tree c_end_defer_block (location_t loc, tree body); extern tree c_begin_stmt_expr (void); extern tree c_finish_stmt_expr (location_t, tree); extern tree c_process_expr_stmt (location_t, tree); diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index df4b1686975..459caa26438 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -13426,6 +13426,12 @@ c_finish_return (location_t loc, tree retval, tree origtype, bool musttail_p) warning_at (xloc, 0, "function declared % has a % statement"); + if (in_statement & IN_DEFER_STMT) + { + error_at (loc, "return from defer block"); + return NULL_TREE; + } + set_musttail_on_return (retval, xloc, musttail_p); if (retval) @@ -13813,6 +13819,9 @@ c_finish_bc_stmt (location_t loc, tree label, bool is_break, tree name) case IN_OMP_FOR: error_at (loc, "break statement used with OpenMP for loop"); return NULL_TREE; + case IN_DEFER_STMT: + error_at (loc, "break statement jumps out of defer block"); + return NULL_TREE; case IN_ITERATION_STMT: case IN_OBJC_FOREACH: break; @@ -13830,6 +13839,9 @@ c_finish_bc_stmt (location_t loc, tree label, bool is_break, tree name) case IN_OMP_BLOCK: error_at (loc, "invalid exit from OpenMP structured block"); return NULL_TREE; + case IN_DEFER_STMT: + error_at (loc, "continue statement jumps out of defer block"); + return NULL_TREE; case IN_ITERATION_STMT: case IN_OMP_FOR: case IN_OBJC_FOREACH: @@ -13975,9 +13987,9 @@ c_begin_stmt_expr (void) keep_next_level (); ret = c_begin_compound_stmt (true); - c_bindings_start_stmt_expr (c_switch_stack == NULL - ? NULL - : c_switch_stack->bindings); + c_bindings_start_jump_barrier (false, c_switch_stack == NULL + ? NULL + : c_switch_stack->bindings); /* Mark the current statement list as belonging to a statement list. */ STATEMENT_LIST_STMT_EXPR (ret) = 1; @@ -13996,9 +14008,9 @@ c_finish_stmt_expr (location_t loc, tree body) body = c_end_compound_stmt (loc, body, true); - c_bindings_end_stmt_expr (c_switch_stack == NULL - ? NULL - : c_switch_stack->bindings); + c_bindings_end_jump_barrier (false, c_switch_stack == NULL + ? NULL + : c_switch_stack->bindings); /* Locate the last statement in BODY. See c_end_compound_stmt about always returning a BIND_EXPR. */ @@ -14093,7 +14105,31 @@ c_finish_stmt_expr (location_t loc, tree body) return t; } } - + +/* Starts a new deferred block to be executed on scope exit. */ + +tree +c_begin_defer_block (void) +{ + c_bindings_start_jump_barrier (true, c_switch_stack == NULL + ? NULL + : c_switch_stack->bindings); + + return c_begin_compound_stmt (true); +} + +/* Ends a deferred block. */ + +tree +c_end_defer_block (location_t loc, tree body) +{ + c_bindings_end_jump_barrier (true, c_switch_stack == NULL + ? NULL + : c_switch_stack->bindings); + + return c_end_compound_stmt (loc, body, true); +} + /* Begin and end compound statements. This is as simple as pushing and popping new statement lists from the tree. */ diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 684af9cdbb3..b43d63d8f1d 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -13725,6 +13725,7 @@ C and/or C++ standards, while others remain specific to GNU C. * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files. * Function Names:: Printable strings which are the name of the current function. +* Defer:: Support for the @code{_Defer} keyword @end menu @node Statement Exprs @@ -14934,6 +14935,20 @@ These identifiers are variables, not preprocessor macros, and may not be used to initialize @code{char} arrays or be concatenated with string literals. +@node Defer +@subsection Support for the @code{_Defer} keyword +@cindex defer +@cindex @code{_Defer} keyword + +The technical specification ISO/DIS TS 25755 added @code{_Defer} as a C +language keyword for deferred execution of statements on scope exit. As an +extension, GNU C recognizes @code{_Defer} in all C versions. + +If @option{-fexceptions} is enabled, then all deferred statements +are run during the stack unwinding that happens during the processing +of the exception. Note that the @code{_Defer} does not allow the +exception to be caught, only to perform an action. + @node Semantic Extensions @section Extensions to C Semantics diff --git a/gcc/ginclude/stddefer.h b/gcc/ginclude/stddefer.h new file mode 100644 index 00000000000..b142eebe490 --- /dev/null +++ b/gcc/ginclude/stddefer.h @@ -0,0 +1,38 @@ +/* Copyright (C) 1998-2025 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +/* + * ISO C Standard: 7.16 Boolean type and values + */ + +#ifndef _STDDEFER_H_ +#define _STDDEFER_H_ + +#ifndef __cplusplus + +#define __STDC_VERSION_STDDEFER_H__ 202602L +#define defer _Defer + +#endif /* __cplusplus */ + +#endif /* stddefer.h */ diff --git a/gcc/testsuite/g++.dg/defer-aux.c b/gcc/testsuite/g++.dg/defer-aux.c new file mode 100644 index 00000000000..ec7e0bce199 --- /dev/null +++ b/gcc/testsuite/g++.dg/defer-aux.c @@ -0,0 +1,12 @@ +/* { dg-options "-fexceptions" } */ + +extern void a (); +extern int c; + +void b () +{ + c += 1; + _Defer c += 1; + a (); + c += 1; +} diff --git a/gcc/testsuite/g++.dg/defer.C b/gcc/testsuite/g++.dg/defer.C new file mode 100644 index 00000000000..03794cef524 --- /dev/null +++ b/gcc/testsuite/g++.dg/defer.C @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fexceptions" } */ +/* { dg-additional-sources defer-aux.c { lang c } } */ + +extern "C" { + extern void b (); + + int c = 0; + + void a () + { + throw 1; + } +} + +int main () +{ + try + { + b (); + } + catch (int e) + { + if (c != 2) + __builtin_abort (); + return 0; + } + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/defer-1.c b/gcc/testsuite/gcc.dg/defer-1.c new file mode 100644 index 00000000000..8432a04a2e8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/defer-1.c @@ -0,0 +1,256 @@ +/* { dg-do run } */ +/* { dg-options "" } */ + +#include +#include + +#define assert(x) if (!(x)) __builtin_abort () + +#if __STDC_DEFER_TS25755__ != 2 +# error "missing defer flag" +#endif + +int a () +{ + int r = 5; + return r; + + defer r *= 2; +} + +int b () +{ + int r = 0; + goto b; + { + defer r += 2; + } +b: + r += 5; + return r; +} + +int c () +{ + int r = 0; + { + defer r += 2; + goto b; + } +b: + r += 5; + return r; +} + +int d () +{ + int r = 0; + goto b; + { +b: + defer r += 2; + } + r += 5; + return r; +} + +int e () +{ + int r = 0; + { + goto b; + defer r += 2; + } +b:; + r += 5; + return r; +} + +int f () +{ + int r = 4; + int *p = &r; + defer *p = 5; + return *p; +} + +int g () +{ + int r = 1; + { + defer r += 2; + if (true) + defer r *= 2; + r += 10; + } + return r; +} + +int h () +{ + int r = 1; + { + defer r += 2; + for (int i = 0; i < 5; i++) + defer r *= 2; + } + return r; +} + +int i () +{ + int r = 0; + { + defer { + defer r *= 4; + r *= 2; + defer { + r += 3; + } + } + defer r += 1; + } + + return r; +} + +int j () +{ + int r = 0; + { + defer if (0) r = 5; + } + return r; +} + +int global = 0; + +int k () +{ + global = 5; + defer global = 10; + return global; +} + +int l () +{ + int r = 5; + int j = 2; + + { + defer { + int j = 10; + r *= j; + } + } + + return r; +} + +int m () +{ + int r = 0; + + void clear(int *value) { + *value = 10; + } + + { + [[gnu::cleanup(clear)]] int j = 1; + defer r = j * 2; + } + return r; +} + +int n () +{ + jmp_buf env; + int r = 0; + + if (setjmp(env) != 0) + return r; + + defer r = 1; + + { + defer r = 2; + r++; + longjmp(env, 1); + } +} + +int o () +{ + int r = 0; + + int foo() { + r = 2; + defer r *= 2; + return r; + } + + return foo() + r; +} + +int p (int *arg) +{ + *arg = 2; + defer *arg *= 2; + return *arg; +} + +int q () +{ + int r = 1; + { +b: + defer r *= 2; + if (r < 10) + goto b; + } + + return r; +} + +int r () +{ + int r = 1; + { + defer r *= 2; +b: + if (r < 10) + { + r++; + goto b; + } + } + + return r; +} + +int +main () +{ + int arg; + + assert (a () == 5); + assert (b () == 5); + assert (c () == 7); + assert (d () == 7); + assert (e () == 5); + assert (f () == 4); + assert (g () == 14); + assert (h () == 34); + assert (i () == 20); + assert (j () == 0); + assert (k () == 5 && global == 10); + assert (l () == 50); + assert (m () == 2); + assert (n () == 1); + assert (o () == 6); + assert (p (&arg) == 2 && arg == 4); + assert (q () == 32); + assert (r () == 20); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/defer-2.c b/gcc/testsuite/gcc.dg/defer-2.c new file mode 100644 index 00000000000..3e07a1b7840 --- /dev/null +++ b/gcc/testsuite/gcc.dg/defer-2.c @@ -0,0 +1,78 @@ +/* { dg-do compile } */ +/* { dg-options "-fdefer-kw" } */ + +#include + +void a () +{ + goto b; /* { dg-error "jump over defer block" } */ + defer; +b: +} + +void b () { + defer { + goto b; /* { dg-error "jump out of defer block" } */ + } +b: +} + +int c () { + defer { + return 5; /* { dg-error "return from defer block" } */ + } + return 1; +} + +void d () { + defer { +b: + } + goto b; /* { dg-error "jump into defer block" } */ +} + +void e () { + goto b; /* { dg-error "jump over defer block" } */ + { + defer; +b: + } +} + +void f () +{ + goto b; /* { dg-error "jump into defer block" } */ + defer { +b: + }; +} + +void g () { + switch (1) { + defer; + default: /* { dg-error "switch jumps over defer block" } */ + defer; + break; + } +} + +void h () { + switch (1) { + default: + defer { + break; /* { dg-error "break statement jumps out of defer block" } */ + } + } + + for (;;) { + defer { + break; /* { dg-error "break statement jumps out of defer block" } */ + } + } + + for (;;) { + defer { + continue; /* { dg-error "continue statement jumps out of defer block" } */ + } + } +} diff --git a/gcc/testsuite/gcc.dg/defer-3.c b/gcc/testsuite/gcc.dg/defer-3.c new file mode 100644 index 00000000000..ea2fff6b761 --- /dev/null +++ b/gcc/testsuite/gcc.dg/defer-3.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "" } */ + +#include + +extern void exit(int); +extern void abort(void); + +int main(void) { + { + defer { + exit(0); + } + } + abort(); + return 1; +} diff --git a/gcc/testsuite/gcc.dg/defer-4.c b/gcc/testsuite/gcc.dg/defer-4.c new file mode 100644 index 00000000000..67dd5d29365 --- /dev/null +++ b/gcc/testsuite/gcc.dg/defer-4.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int main(void) +{ + _Defer; + defer; /* { dg-error "'defer' undeclared" "undeclared identifier" } */ +} -- 2.55.0 From purgeinflame321@gmail.com Sun Nov 1 20:58:42 2026 From: purgeinflame321@gmail.com (Vincent Li) Date: Sun, 1 Nov 2026 15:58:42 -0500 Subject: [PATCH] jit: Add support for computed gotos and block addresses In-Reply-To: <0a0b4e486be69a733a4b8e8ab021d036bd0e38b7.camel@redhat.com> References: <0a0b4e486be69a733a4b8e8ab021d036bd0e38b7.camel@redhat.com> Message-ID: Thanks for the response! I believe I've got everything lined back up according to your suggestions. Vincent Li is my legal name used for the DCO sign-off, and Marcus Valette was just an old display handle on my Gmail account?fixed the sender header for v2. Sorry for any confusion that may have caused. --------- >8 ------------------ >From 0eff1430218fb1eb3768500f82a8998c31db7e75 Mon Sep 17 00:00:00 2001 From: Vincent Li Date: Fri, 23 Oct 2026 13:23:48 -0400 Subject: [PATCH v2] jit: Add support for computed gotos and block addresses This patch adds `gcc_jit_block_get_address` and `gcc_jit_block_end_with_indirect_jump` under ABI version LIBGCCJIT_ABI_39. This exposes GNU C labels-as-values (`&&label`) and indirect jumps (`goto *expr;`) in libgccjit, enabling JIT-compiled interpreter dispatch loops and state machines to implement direct-threaded code tables. Tested on x86_64-pc-linux-gnu. All 30 iterations of jit.dg/test-indirect-jump.c passed across -O0 to -O3. check_GNU_style.py reports 0 errors. gcc/jit/ChangeLog: * docs/topics/expressions.rst (gcc_jit_block_get_address): Document. * docs/topics/functions.rst (gcc_jit_block_end_with_indirect_jump): Document. * jit-playback.cc (playback::block::get_address): New method. (playback::block::add_indirect_jump): New method. * jit-playback.h (playback::block::get_address): New method. (playback::block::add_indirect_jump): New method. * jit-recording.cc (recording::block::get_address): New method. (recording::block::end_with_indirect_jump): New method. (recording::get_block_address::replay_into): New method. (recording::get_block_address::make_debug_string): New method. (recording::get_block_address::write_reproducer): New method. (recording::indirect_jump::replay_into): New method. (recording::indirect_jump::get_successor_blocks): New method. (recording::indirect_jump::make_debug_string): New method. (recording::indirect_jump::write_reproducer): New method. * jit-recording.h (class get_block_address): New class. (class indirect_jump): New class. (recording::block::get_address): New method. (recording::block::end_with_indirect_jump): New method. * libgccjit.cc (gcc_jit_block_get_address): New entrypoint. (gcc_jit_block_end_with_indirect_jump): New entrypoint. * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_block_get_address): New macro. (LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump): New macro. (gcc_jit_block_get_address): New declaration. (gcc_jit_block_end_with_indirect_jump): New declaration. * libgccjit.map (LIBGCCJIT_ABI_39): Add gcc_jit_block_get_address and gcc_jit_block_end_with_indirect_jump. gcc/testsuite/ChangeLog: * jit.dg/all-non-failing-tests.h: Include test-indirect-jump.c. * jit.dg/test-indirect-jump.c: New test. Signed-off-by: Vincent Li --- gcc/jit/docs/topics/compatibility.rst | 8 + gcc/jit/docs/topics/functions.rst | 40 +++++ gcc/jit/jit-playback.cc | 43 +++++ gcc/jit/jit-playback.h | 7 + gcc/jit/jit-recording.cc | 157 ++++++++++++++++++ gcc/jit/jit-recording.h | 59 ++++++- gcc/jit/libgccjit.cc | 68 ++++++++ gcc/jit/libgccjit.h | 45 ++++- gcc/jit/libgccjit.map | 6 + gcc/testsuite/jit.dg/all-non-failing-tests.h | 10 ++ .../jit.dg/test-error-indirect-jump.c | 112 +++++++++++++ gcc/testsuite/jit.dg/test-indirect-jump.c | 109 ++++++++++++ 12 files changed, 661 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/jit.dg/test-error-indirect-jump.c create mode 100644 gcc/testsuite/jit.dg/test-indirect-jump.c diff --git a/gcc/jit/docs/topics/compatibility.rst b/gcc/jit/docs/topics/compatibility.rst index e4a231e79..ca1a428f3 100644 --- a/gcc/jit/docs/topics/compatibility.rst +++ b/gcc/jit/docs/topics/compatibility.rst @@ -489,3 +489,11 @@ information: ``LIBGCCJIT_ABI_38`` covers the addition of * :func:`gcc_jit_type_is_floating_point` + + .. _LIBGCCJIT_ABI_39: + +``LIBGCCJIT_ABI_39`` +----------------------- +``LIBGCCJIT_ABI_39`` covers the addition of API entrypoints + * :func:`gcc_jit_block_get_address` + * :func:`gcc_jit_block_end_with_indirect_jump` diff --git a/gcc/jit/docs/topics/functions.rst b/gcc/jit/docs/topics/functions.rst index 66d4b6b2f..67818881d 100644 --- a/gcc/jit/docs/topics/functions.rst +++ b/gcc/jit/docs/topics/functions.rst @@ -466,6 +466,46 @@ Statements goto target; +.. function:: gcc_jit_rvalue *\ + gcc_jit_block_get_address (gcc_jit_block *block,\ + gcc_jit_location *loc) + + Get the address of a block as a ``void *`` rvalue, equivalent to GNU C's + ``&&label`` extension. + + ``block`` must be non-NULL. + + This API entrypoint was added in :ref:`LIBGCCJIT_ABI_39`; you can test + for its presence using + + .. code-block:: c + + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_get_address + +.. function:: void\ + gcc_jit_block_end_with_indirect_jump (\ + gcc_jit_block *block,\ + gcc_jit_location *loc,\ + gcc_jit_rvalue *target_address,\ + int num_destinations,\ + gcc_jit_block **destinations) + + Terminate a basic block by adding an indirect jump to ``target_address``, + analogous to GNU C's ``goto *target_address;``. + + Here, ``target_address`` must be a pointer rvalue, and ``destinations`` + must be an array of ``num_destinations`` candidate target blocks within + the same function. Listing the candidate destination blocks is required + so that ``libgccjit`` can validate block reachability when checking the + function. + + This API entrypoint was added in ``LIBGCCJIT_ABI_39``; you can test for its + presence using: + + .. code-block:: c + + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump + .. function:: void\ gcc_jit_block_end_with_return (gcc_jit_block *block,\ gcc_jit_location *loc,\ diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc index 56c9413f8..c4c1ec8fd 100644 --- a/gcc/jit/jit-playback.cc +++ b/gcc/jit/jit-playback.cc @@ -2547,6 +2547,49 @@ c_finish_goto_label (location_t loc, tree label) } +/* Take the address of a block as a void * rvalue (&&block). */ + +playback::rvalue * +playback::block:: +get_address (location *loc) +{ + tree label = as_label_decl (); + TREE_USED (label) = 1; + /* Also set during gimplification by gimplify_addr_expr, but marked + explicitly here when constructing the ADDR_EXPR. */ + FORCED_LABEL (label) = 1; + + tree addr = build1 (ADDR_EXPR, ptr_type_node, label); + if (loc) + set_tree_location (addr, loc); + + return new rvalue (m_func->m_ctxt, addr); +} + +/* Add an indirect jump statement (goto *target_address;). */ + +void +playback::block::add_indirect_jump (location *loc, + rvalue *target_address, + auto_vec *destinations) +{ + unsigned i; + block *dest; + FOR_EACH_VEC_ELT (*destinations, i, dest) + { + tree label = dest->as_label_decl (); + TREE_USED (label) = 1; + FORCED_LABEL (label) = 1; + } + + tree target = target_address->as_tree (); + target = fold_convert (ptr_type_node, target); + tree stmt = build1 (GOTO_EXPR, void_type_node, target); + if (loc) + set_tree_location (stmt, loc); + add_stmt (stmt); +} + /* Add a return statement to the function's statement list. */ void diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h index ad3e41f3d..d32ed4d49 100644 --- a/gcc/jit/jit-playback.h +++ b/gcc/jit/jit-playback.h @@ -692,6 +692,13 @@ public: add_jump (location *loc, block *target); + rvalue *get_address (location *loc); + + void + add_indirect_jump (location *loc, + rvalue *target_address, + auto_vec *destinations); + void add_return (location *loc, rvalue *rvalue); diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc index e28e5f67c..337f14925 100644 --- a/gcc/jit/jit-recording.cc +++ b/gcc/jit/jit-recording.cc @@ -5072,6 +5072,26 @@ recording::block::end_with_jump (recording::location *loc, return result; } +/* Create a recording::end_with_indirect_jump instance and add + it to the block's context's list of mementos, and to the + block's list of statements. + + Implements the heart of gcc_jit_block_end_with_indirect_jump. */ + +recording::statement * +recording::block::end_with_indirect_jump (location *loc, + rvalue *target_address, + int num_destinations, + block **destinations) +{ + statement *result = new indirect_jump (this, loc, target_address, + num_destinations, destinations); + m_ctxt->record (result); + m_statements.safe_push (result); + m_has_been_terminated = true; + return result; +} + /* Create a recording::end_with_return instance and add it to the block's context's list of mementos, and to the block's list of statements. @@ -5197,6 +5217,20 @@ recording::block::get_loc () const return NULL; } +/* Create a recording::get_address instance and add it to + the block's context's list of mementos, and to the block's + list of statements. + + Implements the heart of gcc_jit_block_get_address. */ + +recording::rvalue * +recording::block::get_address (location *loc) +{ + recording::rvalue *result = new get_block_address (m_ctxt, loc, this); + m_ctxt->record (result); + return result; +} + /* Get the first statement within a block, if any. */ recording::statement * @@ -7332,6 +7366,45 @@ recording::get_address_of_lvalue::write_reproducer (reproducer &r) r.get_identifier (m_loc)); } +/* The implementation of class gcc::jit::recording::get_block_address. */ + +/* Implementation of pure virtual hook recording::memento::replay_into + for recording::get_block_address. */ + +void +recording::get_block_address::replay_into (replayer *r) +{ + set_playback_obj ( + m_block->playback_block ()-> + get_address (playback_location (r, m_loc))); +} + +/* Implementation of recording::memento::make_debug_string for + getting the address of a block. */ + +recording::string * +recording::get_block_address::make_debug_string () +{ + return string::from_printf (m_ctxt, + "&&%s", + m_block->get_debug_string ()); +} + +/* Implementation of recording::memento::write_reproducer for + get_block_address. */ + +void +recording::get_block_address::write_reproducer (reproducer &r) +{ + const char *id = r.make_identifier (this, "address_of"); + r.write (" gcc_jit_rvalue *%s =\n" + " gcc_jit_block_get_address (%s,\n" + " %s);\n", + id, + r.get_identifier (m_block), + r.get_identifier (m_loc)); +} + /* The implementation of class gcc::jit::recording::function_pointer. */ /* Implementation of pure virtual hook recording::memento::replay_into @@ -7765,6 +7838,90 @@ recording::jump::write_reproducer (reproducer &r) r.get_identifier (m_target)); } +/* The implementation of class gcc::jit::recording::indirect_jump. */ + +/* gcc::jit::recording::indirect_jump's constructor. */ + +recording::indirect_jump::indirect_jump (block *b, + location *loc, + rvalue *target_address, + int num_destinations, + block **destinations) +: statement (b, loc), + m_target_address (target_address) +{ + m_destinations.reserve_exact (num_destinations); + for (int i = 0; i < num_destinations; i++) + m_destinations.quick_push (destinations[i]); +} + +/* Implementation of pure virtual hook recording::memento::replay_into + for recording::indirect_jump. */ + +void +recording::indirect_jump::replay_into (replayer *r) +{ + auto_vec pb_dests; + pb_dests.reserve_exact (m_destinations.length ()); + for (unsigned i = 0; i < m_destinations.length (); i++) + pb_dests.quick_push (m_destinations[i]->playback_block ()); + + playback_block (get_block ()) + ->add_indirect_jump (playback_location (r), + m_target_address->playback_rvalue (), + &pb_dests); +} + +/* Override the poisoned default implementation of + gcc::jit::recording::statement::get_successor_blocks. */ + +vec +recording::indirect_jump::get_successor_blocks () const +{ + vec result; + result.create (m_destinations.length ()); + for (unsigned i = 0; i < m_destinations.length (); i++) + result.quick_push (m_destinations[i]); + return result; +} + +/* Implementation of recording::memento::make_debug_string for + an indirect jump statement. */ + +recording::string * +recording::indirect_jump::make_debug_string () +{ + return string::from_printf (m_ctxt, + "goto *%s;", + m_target_address->get_debug_string_parens (PRECEDENCE_UNARY)); +} + +/* Implementation of recording::memento::write_reproducer for + indirect_jump statements. */ + +void +recording::indirect_jump::write_reproducer (reproducer &r) +{ + r.make_identifier (this, "indirect_jump"); + const char *dests_id = r.make_tmp_identifier ("destinations_for", this); + r.write (" gcc_jit_block *%s[%i] = {\n", + dests_id, + m_destinations.length ()); + for (unsigned i = 0; i < m_destinations.length (); i++) + r.write (" %s,\n", r.get_identifier (m_destinations[i])); + r.write (" };\n"); + r.write (" gcc_jit_block_end_with_indirect_jump (%s,\n" + " %s,\n" + " %s,\n" + " %i,\n" + " %s);\n", + r.get_identifier (get_block ()), + r.get_identifier (get_loc ()), + r.get_identifier_as_rvalue (m_target_address), + m_destinations.length (), + dests_id); +} + /* The implementation of class gcc::jit::recording::return_. */ /* Implementation of pure virtual hook recording::memento::replay_into diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index 2a5f23a05..952761dca 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -966,7 +966,7 @@ public: type *unqualified () final override { return m_other_type; } void replay_into (replayer *) final override; - memento_of_get_aligned *dyn_cast_aligned_type () final override + memento_of_get_aligned *dyn_cast_aligned_type () final override { return this; } @@ -1682,6 +1682,13 @@ public: end_with_jump (location *loc, block *target); + rvalue * get_address (location *loc); + + statement * end_with_indirect_jump (location *loc, + rvalue *target_address, + int num_destinations, + block **destinations); + statement * end_with_return (location *loc, rvalue *rvalue); @@ -2427,6 +2434,34 @@ private: lvalue *m_lvalue; }; +class get_block_address : public rvalue +{ +public: + get_block_address (context *ctxt, + location *loc, + block *b) + : rvalue (ctxt, loc, ctxt->get_type (GCC_JIT_TYPE_VOID_PTR)), + m_block (b) + { + set_scope (b->get_function ()); + } + + void replay_into (replayer *r) final override; + + void visit_children (rvalue_visitor *) final override {} + +private: + string * make_debug_string () final override; + void write_reproducer (reproducer &r) final override; + enum precedence get_precedence () const final override + { + return PRECEDENCE_UNARY; + } + +private: + block *m_block; +}; + class function_pointer : public rvalue { public: @@ -2650,6 +2685,28 @@ private: block *m_target; }; +class indirect_jump : public statement +{ +public: + indirect_jump (block *b, + location *loc, + rvalue *target_address, + int num_destinations, + block **destinations); + + void replay_into (replayer *r) final override; + + vec get_successor_blocks () const final override; + +private: + string * make_debug_string () final override; + void write_reproducer (reproducer &r) final override; + +private: + rvalue *m_target_address; + auto_vec m_destinations; +}; + class return_ : public statement { public: diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc index 5a874fc48..42c6fe828 100644 --- a/gcc/jit/libgccjit.cc +++ b/gcc/jit/libgccjit.cc @@ -2874,6 +2874,23 @@ gcc_jit_lvalue_get_address (gcc_jit_lvalue *lvalue, return (gcc_jit_rvalue *)lvalue->get_address (loc); } +/* Public entrypoint. See description in libgccjit.h. + + After error-checking, the real work is done by the + gcc::jit::recording::block::get_address method in + jit-recording.cc. */ + +gcc_jit_rvalue * +gcc_jit_block_get_address (gcc_jit_block *block, + gcc_jit_location *loc) +{ + RETURN_NULL_IF_FAIL (block, NULL, loc, "NULL block"); + JIT_LOG_FUNC (block->get_context ()->get_logger ()); + /* LOC can be NULL. */ + + return (gcc_jit_rvalue *)block->get_address (loc); +} + /* Public entrypoint. See description in libgccjit.h. After error-checking, the real work is done by the @@ -3258,6 +3275,57 @@ gcc_jit_block_end_with_jump (gcc_jit_block *block, block->end_with_jump (loc, target); } +/* Public entrypoint. See description in libgccjit.h. + + After error-checking, the real work is done by the + gcc::jit::recording::block::end_with_indirect_jump method in + jit-recording.cc. */ + +void +gcc_jit_block_end_with_indirect_jump (gcc_jit_block *block, + gcc_jit_location *loc, + gcc_jit_rvalue *target_address, + int num_destinations, + gcc_jit_block **destinations) +{ + RETURN_IF_NOT_VALID_BLOCK (block, loc); + gcc::jit::recording::context *ctxt = block->get_context (); + JIT_LOG_FUNC (ctxt->get_logger ()); + /* LOC can be NULL. */ + RETURN_IF_FAIL (target_address, ctxt, loc, "NULL target_address"); + RETURN_IF_FAIL_PRINTF1 ( + target_address->get_type ()->is_pointer (), + ctxt, loc, + "target_address: %s is not of a pointer type", + target_address->get_debug_string ()); + RETURN_IF_FAIL (num_destinations >= 0, ctxt, loc, "num_destinations < 0"); + if (num_destinations > 0) + RETURN_IF_FAIL (destinations, ctxt, loc, "NULL destinations"); + + for (int i = 0; i < num_destinations; i++) + { + RETURN_IF_FAIL_PRINTF1 (destinations[i], ctxt, loc, + "NULL destination block at index %d", i); + RETURN_IF_FAIL_PRINTF4 ( + block->get_function () == destinations[i]->get_function (), + ctxt, loc, + "destination block %d (%s) is not in the same function" + " (function %s) as source block %s", + i, + destinations[i]->get_debug_string (), + destinations[i]->get_function ()->get_debug_string (), + block->get_debug_string ()); + } + + gcc::jit::recording::statement *stmt = + block->end_with_indirect_jump (loc, target_address, + num_destinations, + (gcc::jit::recording::block **)destinations); + + /* target_address must be valid to use within STMT. */ + target_address->verify_valid_within_stmt (__func__, stmt); +} + /* Public entrypoint. See description in libgccjit.h. After error-checking, the real work is done by the diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h index 2247c99de..272085986 100644 --- a/gcc/jit/libgccjit.h +++ b/gcc/jit/libgccjit.h @@ -1455,16 +1455,31 @@ extern gcc_jit_rvalue * gcc_jit_lvalue_get_address (gcc_jit_lvalue *lvalue, gcc_jit_location *loc); +#define LIBGCCJIT_HAVE_gcc_jit_block_get_address + +/* Taking the address of a block; analogous to: + &&block + in C. + + This API entrypoint was added in LIBGCCJIT_ABI_39; you can test for its + presence using + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_get_address +*/ +extern gcc_jit_rvalue * +gcc_jit_block_get_address (gcc_jit_block *block, + gcc_jit_location *loc); + #define LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model /* Set the thread-local storage model of a global variable This API entrypoint was added in LIBGCCJIT_ABI_17; you can test for its presence using - #ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model */ + #ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model +*/ extern void gcc_jit_lvalue_set_tls_model (gcc_jit_lvalue *lvalue, - enum gcc_jit_tls_model model); + enum gcc_jit_tls_model model); #define LIBGCCJIT_HAVE_gcc_jit_lvalue_set_link_section @@ -1592,6 +1607,32 @@ gcc_jit_block_end_with_jump (gcc_jit_block *block, gcc_jit_location *loc, gcc_jit_block *target); +#define LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump + +/* Terminate a block by adding an indirect jump to target_address. + + All possible indirect jump targets must be constrained to a fixed array. + + The candidate destination blocks must be listed in DESTINATIONS + + (of length NUM_DESTINATIONS) so that libgccjit can validate block + + reachability within the function. + + This is roughly equivalent to this C code: + + goto *target_address; + + This API entrypoint was added in LIBGCCJIT_ABI_39; you can test for its + presence using + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump. */ +extern void +gcc_jit_block_end_with_indirect_jump (gcc_jit_block *block, + gcc_jit_location *loc, + gcc_jit_rvalue *target_address, + int num_destinations, + gcc_jit_block **destinations); + /* Terminate a block by adding evaluation of an rvalue, returning the value. This is roughly equivalent to this C code: diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map index 78b6be9ff..9412700a2 100644 --- a/gcc/jit/libgccjit.map +++ b/gcc/jit/libgccjit.map @@ -349,3 +349,9 @@ LIBGCCJIT_ABI_38 { global: gcc_jit_type_is_floating_point; } LIBGCCJIT_ABI_37; + +LIBGCCJIT_ABI_39 { + global: + gcc_jit_block_get_address; + gcc_jit_block_end_with_indirect_jump; +} LIBGCCJIT_ABI_38; diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h b/gcc/testsuite/jit.dg/all-non-failing-tests.h index e8f8463e8..f8202635e 100644 --- a/gcc/testsuite/jit.dg/all-non-failing-tests.h +++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h @@ -269,6 +269,13 @@ #undef create_code #undef verify_code +/* test-indirect-jump.c */ +#define create_code create_code_indirect_jump +#define verify_code verify_code_indirect_jump +#include "test-indirect-jump.c" +#undef create_code +#undef verify_code + /* test-link-section-assembler.c: This can't be in the testcases array as it doesn't have a verify_code implementation. */ @@ -688,6 +695,9 @@ const struct testcase testcases[] = { {"vector_perm", create_code_vector_perm, verify_code_vector_perm}, + {"indirect_jump", + create_code_indirect_jump, + verify_code_indirect_jump}, }; const int num_testcases = (sizeof (testcases) / sizeof (testcases[0])); diff --git a/gcc/testsuite/jit.dg/test-error-indirect-jump.c b/gcc/testsuite/jit.dg/test-error-indirect-jump.c new file mode 100644 index 000000000..8f40a3738 --- /dev/null +++ b/gcc/testsuite/jit.dg/test-error-indirect-jump.c @@ -0,0 +1,112 @@ +#include +#include + +#include "libgccjit.h" +#include "harness.h" + +void +create_code (gcc_jit_context *ctxt, void *user_data) +{ + /* Let's try to trigger every validation error on + gcc_jit_block_get_address and gcc_jit_block_end_with_indirect_jump. */ + gcc_jit_type *void_type = + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID); + gcc_jit_type *int_type = + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); + + gcc_jit_function *fn1 = + gcc_jit_context_new_function (ctxt, NULL, + GCC_JIT_FUNCTION_EXPORTED, + void_type, + "fn1", + 0, NULL, + 0); + gcc_jit_block *b_fn1 = + gcc_jit_function_new_block (fn1, "b_fn1"); + + gcc_jit_function *fn2 = + gcc_jit_context_new_function (ctxt, NULL, + GCC_JIT_FUNCTION_EXPORTED, + void_type, + "fn2", + 0, NULL, + 0); + gcc_jit_block *b_fn2 = + gcc_jit_function_new_block (fn2, "b_fn2"); + + /* 1. Non-pointer target_address. */ + gcc_jit_rvalue * non_ptr = + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 42); + gcc_jit_block_end_with_indirect_jump (b_fn1, NULL, non_ptr, 0, NULL); + CHECK_STRING_VALUE ( + gcc_jit_context_get_last_error (ctxt), + "gcc_jit_block_end_with_indirect_jump:" + " target_address: (int)42 is not of a pointer type"); + + /* 2. Negative num_destinations. */ + gcc_jit_rvalue *addr_fn1 = gcc_jit_block_get_address (b_fn1, NULL); + gcc_jit_block_end_with_indirect_jump (b_fn1, NULL, addr_fn1, -1, NULL); + CHECK_STRING_VALUE ( + gcc_jit_context_get_last_error (ctxt), + "gcc_jit_block_end_with_indirect_jump: num_destinations < 0"); + + /* 3. NULL destinations array when num_destinations > 0. */ + gcc_jit_block_end_with_indirect_jump (b_fn1, NULL, addr_fn1, 1, NULL); + CHECK_STRING_VALUE ( + gcc_jit_context_get_last_error (ctxt), + "gcc_jit_block_end_with_indirect_jump: NULL destinations"); + + /* 4. NULL element in destinations array. */ + gcc_jit_block *null_dests[1] = { NULL }; + gcc_jit_block_end_with_indirect_jump (b_fn1, NULL, addr_fn1, 1, null_dests); + CHECK_STRING_VALUE ( + gcc_jit_context_get_last_error (ctxt), + "gcc_jit_block_end_with_indirect_jump:" + " NULL destination block at index 0"); + + /* 5. Destination block in wrong function. */ + gcc_jit_block *wrong_fn_dests[1] = { b_fn2 }; + gcc_jit_block_end_with_indirect_jump (b_fn1, NULL, addr_fn1, 1, + wrong_fn_dests); + CHECK_STRING_VALUE ( + gcc_jit_context_get_last_error (ctxt), + "gcc_jit_block_end_with_indirect_jump:" + " destination block 0 (b_fn2) is not in the same function" + " (function fn2) as source block b_fn1"); + + /* Terminate b_fn1 cleanly so function validation doesn't overwrite + last_error with an "unterminated block" error during compile. */ + gcc_jit_block_end_with_void_return (b_fn1, NULL); + + /* 6. Cross-function block address (addr_fn1 used inside fn2). */ + gcc_jit_block *fn2_dests[1] = { b_fn2 }; + gcc_jit_block_end_with_indirect_jump (b_fn2, NULL, addr_fn1, 1, + fn2_dests); + + CHECK_STRING_VALUE ( + gcc_jit_context_get_last_error (ctxt), + "gcc_jit_block_end_with_indirect_jump:" + " rvalue &&b_fn1 (type: void *) has scope limited to function fn1" + " but was used within function fn2" + " (in statement: goto *&&b_fn1;)"); +} + +void +verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) +{ + CHECK_VALUE (result, NULL); + + CHECK_STRING_VALUE ( + gcc_jit_context_get_first_error (ctxt), + "gcc_jit_block_end_with_indirect_jump:" + " target_address: (int)42 is not of a pointer type"); + + /* Verify that using a block address from fn1 inside fn2 was caught + by verify_valid_within_stmt. */ + CHECK_STRING_VALUE ( + gcc_jit_context_get_last_error (ctxt), + "gcc_jit_block_end_with_indirect_jump:" + " rvalue &&b_fn1 (type: void *) has scope limited to function fn1" + " but was used within function fn2" + " (in statement: goto *&&b_fn1;)"); +} diff --git a/gcc/testsuite/jit.dg/test-indirect-jump.c b/gcc/testsuite/jit.dg/test-indirect-jump.c new file mode 100644 index 000000000..f464a6edb --- /dev/null +++ b/gcc/testsuite/jit.dg/test-indirect-jump.c @@ -0,0 +1,109 @@ +#include +#include + +#include "libgccjit.h" +#include "harness.h" + +void +create_code (gcc_jit_context *ctxt, void *user_data) +{ + /* Let's try to inject the equivalent of: + int + test_indirect_jump (int idx) + { + void *targets[3]; + targets[0] = &&b_zero; + targets[1] = &&b_one; + targets[2] = &&b_two; + goto *targets[idx]; + + b_zero: + return 10; + b_one: + return 20; + b_two: + return 30; + } + */ + gcc_jit_type *int_type = + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); + gcc_jit_type *void_ptr_type = + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID_PTR); + gcc_jit_type *array_type = + gcc_jit_context_new_array_type (ctxt, NULL, void_ptr_type, 3); + + gcc_jit_param *param_idx = + gcc_jit_context_new_param (ctxt, NULL, int_type, "idx"); + gcc_jit_function *func = + gcc_jit_context_new_function (ctxt, NULL, + GCC_JIT_FUNCTION_EXPORTED, + int_type, + "test_indirect_jump", + 1, ¶m_idx, + 0); + + gcc_jit_block *b_entry = gcc_jit_function_new_block (func, "entry"); + gcc_jit_block *b_zero = gcc_jit_function_new_block (func, "b_zero"); + gcc_jit_block *b_one = gcc_jit_function_new_block (func, "b_one"); + gcc_jit_block *b_two = gcc_jit_function_new_block (func, "b_two"); + + gcc_jit_lvalue *targets = + gcc_jit_function_new_local (func, NULL, array_type, "targets"); + + gcc_jit_block *blocks[3] = { b_zero, b_one, b_two }; + for (int i = 0; i < 3; i++) + { + gcc_jit_rvalue *idx_val = + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, i); + gcc_jit_lvalue *elem = + gcc_jit_context_new_array_access (ctxt, NULL, + gcc_jit_lvalue_as_rvalue (targets), + idx_val); + gcc_jit_rvalue *blk_addr = + gcc_jit_block_get_address (blocks[i], NULL); + gcc_jit_block_add_assignment (b_entry, NULL, elem, blk_addr); + } + + /* void *target_addr = targets[idx]; */ + gcc_jit_lvalue *selected_elem = + gcc_jit_context_new_array_access (ctxt, NULL, + gcc_jit_lvalue_as_rvalue (targets), + gcc_jit_param_as_rvalue (param_idx)); + + /* goto *targets[idx]; */ + gcc_jit_block_end_with_indirect_jump ( + b_entry, NULL, + gcc_jit_lvalue_as_rvalue (selected_elem), + 3, blocks); + + /* b_zero: return 10; */ + gcc_jit_block_end_with_return ( + b_zero, NULL, + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 10)); + + /* b_one: return 20; */ + gcc_jit_block_end_with_return ( + b_one, NULL, + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 20)); + + /* b_two: return 30; */ + gcc_jit_block_end_with_return ( + b_two, NULL, + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 30)); +} + +void +verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) + +{ + typedef int (*fn_type) (int); + CHECK_NON_NULL (result); + + fn_type test_indirect_jump = + (fn_type)gcc_jit_result_get_code (result, "test_indirect_jump"); + CHECK_NON_NULL (test_indirect_jump); + + CHECK_VALUE (test_indirect_jump (0), 10); + CHECK_VALUE (test_indirect_jump (1), 20); + CHECK_VALUE (test_indirect_jump (2), 30); +} -- 2.56.0 On Sun, Oct 25, 2026 at 7:58?PM David Malcolm wrote: > > On Fri, 2026-10-23 at 13:34 -0400, Marcus Valette wrote: > > From b55719183abf5ff37373115b5929ebd6ca914258 Mon Sep 17 00:00:00 > > 2001 > > From: Vincent Li > > Date: Fri, 23 Oct 2026 13:23:48 -0400 > > Subject: [PATCH] jit: Add support for computed gotos and block > > addresses > > > > This patch adds `gcc_jit_block_get_address` and > > `gcc_jit_block_end_with_indirect_jump` > > under ABI version LIBGCCJIT_ABI_39. This exposes GNU C > > labels-as-values (`&&label`) > > and indirect jumps (`goto *expr;`) in libgccjit, enabling JIT- > > compiled > > interpreter > > dispatch loops and state machines to implement direct-threaded code > > tables. > > > > Tested on x86_64-pc-linux-gnu. All 30 iterations of jit.dg/test- > > indirect-jump.c > > passed across -O0 to -O3. check_GNU_style.py reports 0 errors. > > > > gcc/jit/ChangeLog: > > > > * docs/topics/expressions.rst (gcc_jit_block_get_address): > > Document. > > * docs/topics/functions.rst > > (gcc_jit_block_end_with_indirect_jump): Document. > > * jit-playback.cc (playback::block::get_address): New method. > > (playback::block::add_indirect_jump): New method. > > * jit-playback.h (playback::block::get_address): New method. > > (playback::block::add_indirect_jump): New method. > > * jit-recording.cc (recording::block::get_address): New method. > > (recording::block::end_with_indirect_jump): New method. > > (recording::get_block_address::replay_into): New method. > > (recording::get_block_address::make_debug_string): New method. > > (recording::get_block_address::write_reproducer): New method. > > (recording::indirect_jump::replay_into): New method. > > (recording::indirect_jump::get_successor_blocks): New method. > > (recording::indirect_jump::make_debug_string): New method. > > (recording::indirect_jump::write_reproducer): New method. > > * jit-recording.h (class get_block_address): New class. > > (class indirect_jump): New class. > > (recording::block::get_address): New method. > > (recording::block::end_with_indirect_jump): New method. > > * libgccjit.cc (gcc_jit_block_get_address): New entrypoint. > > (gcc_jit_block_end_with_indirect_jump): New entrypoint. > > * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_block_get_address): New > > macro. > > (LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump): New macro. > > (gcc_jit_block_get_address): New declaration. > > (gcc_jit_block_end_with_indirect_jump): New declaration. > > * libgccjit.map (LIBGCCJIT_ABI_39): Add gcc_jit_block_get_address > > and > > gcc_jit_block_end_with_indirect_jump. > > > > gcc/testsuite/ChangeLog: > > > > * jit.dg/all-non-failing-tests.h: Include test-indirect-jump.c. > > * jit.dg/test-indirect-jump.c: New test. > > > > Signed-off-by: Vincent Li > > > Thanks for the patch. Overall it looks promising, but there are some > minor issues. > > The From: header reads "Marcus Valette" while the patch author and > Signed-off-by: both read "Vincent Li", albeit at the same gmail > address. Who wrote this patch? (the DCO sign-off is standing in for > copyright assignment here). > > I looked on https://gcc.sashiko.dev/ and for some reason I'm not seeing > this patch there (perhaps because it was To: jit@gcc.gnu.org and only > CC: gcc-patches@gcc.gnu.org ?) Given that, I had Claude code take a > look at it; please forgive me for taking the liberty of pasting what it > said verbatim, since its feedback seems correct to me: > > (begin quote): > > Verdict: good direction, needs a v2. The design follows the existing > end_with_extended_asm_goto precedent closely, it applies cleanly to > master, builds warning-free, and the new test passes including the > reproducer round-trip. But there are two real defects ? one of which is > an ICE ? plus a documentation claim that is factually wrong. > > Verification performed > > Applied to master @ 9f6f255b68b, built libgccjit.so, ran jit.exp=test- > indirect-jump.c: 35 passes, 0 failures. The jit harness auto-generates > and recompiles a reproducer per test, so write_reproducer is covered. > ABI 39 is the correct next number ? LIBGCCJIT_ABI_38 is the current tip > in both libgccjit.map and compatibility.rst. > > I did not run test-combination.c / test-threads.c, which pick up the > new test via all-non-failing-tests.h. Those should be run before > commit. > > Blockers > > 1. ICE instead of a clean error: missing verify_valid_within_stmt > > gcc_jit_block_end_with_indirect_jump never calls target_address- > >verify_valid_within_stmt (__func__, stmt). Every other statement > entrypoint does ? libgccjit.cc:3038, 3082-3083, 3139-3140, 3208, 3297. > > Passing a target_address scoped to a different function gives: > > internal compiler error: in expand_expr_real_1, at expr.cc:11811 > > The identical misuse via gcc_jit_block_end_with_return is diagnosed > properly: > > gcc_jit_block_end_with_return: rvalue g1loc (type: int) has scope > limited to function g1 but was used within function g2 (in statement: > return g1loc;) > > Fix: capture the statement returned by end_with_indirect_jump and call > verify_valid_within_stmt on it, as the neighbouring entrypoints do. > > 2. Cross-function block addresses silently accepted > > recording::get_block_address never calls set_scope (b->get_function > ()), so m_scope stays NULL and the rvalue is treated as a global. > Taking &&a_lbl in func_a and jumping to it from func_b produces no > diagnostic at all. Confirmed via DUMP_INITIAL_GIMPLE: > > int func_b () > { > b_entry: > tmp = &a_lbl; /* a_lbl lives in func_a */ > goto tmp; > ... > } > > GNU C explicitly forbids jumping to a label in a different function. > Calling set_scope in the constructor ? the same mechanism locals and > params use ? turns this into a clean API error. > > 3. The documented rationale for destinations is wrong > > Both libgccjit.h and functions.rst say the array is needed "to allow > GCC's middle-end to construct valid CFG edges." It isn't. Edges come > from FORCED_LABEL, which gimplify.cc:20972 sets when the address is > taken and tree-cfg.cc:1046 wires into abnormal edges for every computed > goto. > > I tested a deliberately incomplete destinations list (two labels in the > jump table, only one listed) at -O3: both targets still dispatch > correctly, no diagnostic, correct results. > > The parameter is load-bearing ? recording::function::validate walks > get_successor_blocks for its reachability check, and without it > legitimate targets get flagged "unreachable block". That is the honest > justification and what the docs should say. As written, users are told > the array is a safety requirement when under-listing is silently > harmless and over-listing just force-marks extra labels. > > Should-fix > > - compatibility.rst has no LIBGCCJIT_ABI_39 section. Required for > every ABI bump; also needed so the docs can use > :ref:LIBGCCJIT_ABI_39instead of the plain ```LIBGCCJIT_ABI_39`` ``` > literal the patch uses. The surrounding entries in expressions.rst use > the :ref: form. > - gcc_jit_block_get_address is documented in the wrong section. It > lands at expressions.rst:806, inside Lvalues (which starts at > line 778), between gcc_jit_lvalue_get_address and > gcc_jit_lvalue_set_tls_model. It is neither an lvalue operation nor an > lvalue method ? it belongs with the block APIs in functions.rst, next > to the new end_with_indirect_jump. > - No error-path tests. The new entrypoints add five validation checks > and none are covered. jit.dg/test-error-*.c is the convention. > - Three unrelated hunks. Trailing-whitespace removal at jit- > recording.h:966, and a comment-terminator plus re-indent of > gcc_jit_lvalue_set_tls_model in libgccjit.h. Drop them or split into a > separate cleanup patch ? neither is in the ChangeLog. > - all-non-failing-tests.h ordering. Both the #include block and the > testcases[] entry are alphabetically sorted; the patch puts the include > after test-switch.c and the array entry at the very end, rather than > among the i entries. > > Minor > > - write_reproducer embeds literal tabs in the strings it emits, so > generated reproducer files get tab-indented continuation lines. > extended_asm_goto::write_reproducer uses spaces ? match it. > - indirect_jump::make_debug_string uses get_debug_string () rather > than get_debug_string_parens (PRECEDENCE_UNARY), so goto *a + b; will > render ambiguously. > - playback::block::add_indirect_jump omits the convert > (ptr_type_node, expr) that c_finish_goto_ptr performs. Not a > correctness bug today ? verify_gimple_goto accepts any POINTER_TYPE_P ? > but normalizing is cheaper than reasoning about named address spaces > later. > - The FORCED_LABEL assignment in get_address is redundant with > gimplify.cc:20972. Harmless; worth a comment if kept. > - RETURN_IF_FAIL (num_destinations > 0, ...) with message > "num_destinations <= 0". end_with_extended_asm_goto permits >= 0; and > the message should describe the problem, not restate the predicate. > > (end quote from AI) > > Hope this is constructive; thanks again for the patch > Dave > > > > > > > > --- > > gcc/jit/docs/topics/expressions.rst | 14 ++ > > gcc/jit/docs/topics/functions.rst | 21 +++ > > gcc/jit/jit-playback.cc | 39 +++++ > > gcc/jit/jit-playback.h | 7 + > > gcc/jit/jit-recording.cc | 157 > > +++++++++++++++++++ > > gcc/jit/jit-recording.h | 57 ++++++- > > gcc/jit/libgccjit.cc | 63 ++++++++ > > gcc/jit/libgccjit.h | 39 ++++- > > gcc/jit/libgccjit.map | 6 + > > gcc/testsuite/jit.dg/all-non-failing-tests.h | 10 ++ > > gcc/testsuite/jit.dg/test-indirect-jump.c | 108 +++++++++++++ > > 11 files changed, 518 insertions(+), 3 deletions(-) > > create mode 100644 gcc/testsuite/jit.dg/test-indirect-jump.c > > > > diff --git a/gcc/jit/docs/topics/expressions.rst > > b/gcc/jit/docs/topics/expressions.rst > > index 680ea1d86..0f9f705fe 100644 > > --- a/gcc/jit/docs/topics/expressions.rst > > +++ b/gcc/jit/docs/topics/expressions.rst > > @@ -806,6 +806,20 @@ where the rvalue is computed by reading from the > > storage area. > > > > in C. > > > > +.. function:: gcc_jit_rvalue * \ > > + gcc_jit_block_get_address (gcc_jit_block *block, \ > > + gcc_jit_location *loc) > > + > > + Get the address of a basic block as an rvalue of type ``void *``, > > + analogous to GNU C's ``&&label``. > > + > > + This API entrypoint was added in ``LIBGCCJIT_ABI_39``; you can > > test for its > > + presence using: > > + > > + .. code-block:: c > > + > > + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_get_address > > + > > .. function:: void\ > > gcc_jit_lvalue_set_tls_model (gcc_jit_lvalue *lvalue,\ > > enum gcc_jit_tls_model > > model) > > diff --git a/gcc/jit/docs/topics/functions.rst > > b/gcc/jit/docs/topics/functions.rst > > index 66d4b6b2f..1f2eefb1c 100644 > > --- a/gcc/jit/docs/topics/functions.rst > > +++ b/gcc/jit/docs/topics/functions.rst > > @@ -466,6 +466,27 @@ Statements > > > > goto target; > > > > +.. function:: void\ > > + gcc_jit_block_end_with_indirect_jump (\ > > + gcc_jit_block *block,\ > > + gcc_jit_location *loc,\ > > + gcc_jit_rvalue *target_address,\ > > + int num_destinations,\ > > + gcc_jit_block **destinations) > > + > > + Terminate a basic block by adding an indirect jump to > > ``target_address``, > > + analogous to GNU C's ``goto *target_address;``. > > + > > + All possible destination blocks must be listed in the > > ``destinations`` > > + array to allow GCC's middle-end to construct valid CFG edges. > > + > > + This API entrypoint was added in ``LIBGCCJIT_ABI_39``; you can > > test for its > > + presence using: > > + > > + .. code-block:: c > > + > > + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump > > + > > .. function:: void\ > > gcc_jit_block_end_with_return (gcc_jit_block *block,\ > > gcc_jit_location *loc,\ > > diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc > > index 56c9413f8..66a1e8fef 100644 > > --- a/gcc/jit/jit-playback.cc > > +++ b/gcc/jit/jit-playback.cc > > @@ -2547,6 +2547,45 @@ c_finish_goto_label (location_t loc, tree > > label) > > > > } > > > > +/* Take the address of a block as a void * rvalue (&&block). */ > > + > > +playback::rvalue * > > +playback::block:: > > +get_address (location *loc) > > +{ > > + tree label = as_label_decl (); > > + TREE_USED (label) = 1; > > + FORCED_LABEL (label) = 1; > > + > > + tree addr = build1 (ADDR_EXPR, ptr_type_node, label); > > + if (loc) > > + set_tree_location (addr, loc); > > + > > + return new rvalue (m_func->m_ctxt, addr); > > +} > > + > > +/* Add an indirect jump statement (goto *target_address;). */ > > + > > +void > > +playback::block::add_indirect_jump (location *loc, > > + rvalue *target_address, > > + auto_vec *destinations) > > +{ > > + unsigned i; > > + block *dest; > > + FOR_EACH_VEC_ELT (*destinations, i, dest) > > + { > > + tree label = dest->as_label_decl (); > > + TREE_USED (label) = 1; > > + FORCED_LABEL (label) = 1; > > + } > > + > > + tree stmt = build1 (GOTO_EXPR, void_type_node, target_address- > > >as_tree ()); > > + if (loc) > > + set_tree_location (stmt, loc); > > + add_stmt (stmt); > > +} > > + > > /* Add a return statement to the function's statement list. */ > > > > void > > diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h > > index ad3e41f3d..d32ed4d49 100644 > > --- a/gcc/jit/jit-playback.h > > +++ b/gcc/jit/jit-playback.h > > @@ -692,6 +692,13 @@ public: > > add_jump (location *loc, > > block *target); > > > > + rvalue *get_address (location *loc); > > + > > + void > > + add_indirect_jump (location *loc, > > + rvalue *target_address, > > + auto_vec *destinations); > > + > > void > > add_return (location *loc, > > rvalue *rvalue); > > diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc > > index e28e5f67c..47983e06c 100644 > > --- a/gcc/jit/jit-recording.cc > > +++ b/gcc/jit/jit-recording.cc > > @@ -5072,6 +5072,26 @@ recording::block::end_with_jump > > (recording::location *loc, > > return result; > > } > > > > +/* Create a recording::end_with_indirect_jump instance and add > > + it to the block's context's list of mementos, and to the > > + block's list of statements. > > + > > + Implements the heart of gcc_jit_block_end_with_indirect_jump. */ > > + > > +recording::statement * > > +recording::block::end_with_indirect_jump (location *loc, > > + rvalue *target_address, > > + int num_destinations, > > + block **destinations) > > +{ > > + statement *result = new indirect_jump (this, loc, target_address, > > + num_destinations, destinations); > > + m_ctxt->record (result); > > + m_statements.safe_push (result); > > + m_has_been_terminated = true; > > + return result; > > +} > > + > > /* Create a recording::end_with_return instance and add it to > > the block's context's list of mementos, and to the block's > > list of statements. > > @@ -5197,6 +5217,20 @@ recording::block::get_loc () const > > return NULL; > > } > > > > +/* Create a recording::get_address instance and add it to > > + the block's context's list of mementos, and to the block's > > + list of statements. > > + > > + Implements the heart of gcc_jit_block_get_address. */ > > + > > +recording::rvalue * > > +recording::block::get_address (location *loc) > > +{ > > + recording::rvalue *result = new get_block_address (m_ctxt, loc, > > this); > > + m_ctxt->record (result); > > + return result; > > +} > > + > > /* Get the first statement within a block, if any. */ > > > > recording::statement * > > @@ -7332,6 +7366,45 @@ > > recording::get_address_of_lvalue::write_reproducer (reproducer &r) > > r.get_identifier (m_loc)); > > } > > > > +/* The implementation of class > > gcc::jit::recording::get_block_address. */ > > + > > +/* Implementation of pure virtual hook > > recording::memento::replay_into > > + for recording::get_block_address. */ > > + > > +void > > +recording::get_block_address::replay_into (replayer *r) > > +{ > > + set_playback_obj ( > > + m_block->playback_block ()-> > > + get_address (playback_location (r, m_loc))); > > +} > > + > > +/* Implementation of recording::memento::make_debug_string for > > + getting the address of a block. */ > > + > > +recording::string * > > +recording::get_block_address::make_debug_string () > > +{ > > + return string::from_printf (m_ctxt, > > + "&&%s", > > + m_block->get_debug_string ()); > > +} > > + > > +/* Implementation of recording::memento::write_reproducer for > > + get_block_address. */ > > + > > +void > > +recording::get_block_address::write_reproducer (reproducer &r) > > +{ > > + const char *id = r.make_identifier (this, "address_of"); > > + r.write (" gcc_jit_rvalue *%s =\n" > > + " gcc_jit_block_get_address (%s,\n" > > + " %s);\n", > > + id, > > + r.get_identifier (m_block), > > + r.get_identifier (m_loc)); > > +} > > + > > /* The implementation of class > > gcc::jit::recording::function_pointer. */ > > > > /* Implementation of pure virtual hook > > recording::memento::replay_into > > @@ -7765,6 +7838,90 @@ recording::jump::write_reproducer (reproducer > > &r) > > r.get_identifier (m_target)); > > } > > > > +/* The implementation of class gcc::jit::recording::indirect_jump. > > */ > > + > > +/* gcc::jit::recording::indirect_jump's constructor. */ > > + > > +recording::indirect_jump::indirect_jump (block *b, > > + location *loc, > > + rvalue *target_address, > > + int num_destinations, > > + block **destinations) > > +: statement (b, loc), > > + m_target_address (target_address) > > +{ > > + m_destinations.reserve_exact (num_destinations); > > + for (int i = 0; i < num_destinations; i++) > > + m_destinations.quick_push (destinations[i]); > > +} > > + > > +/* Implementation of pure virtual hook > > recording::memento::replay_into > > + for recording::indirect_jump. */ > > + > > +void > > +recording::indirect_jump::replay_into (replayer *r) > > +{ > > + auto_vec pb_dests; > > + pb_dests.reserve_exact (m_destinations.length ()); > > + for (unsigned i = 0; i < m_destinations.length (); i++) > > + pb_dests.quick_push (m_destinations[i]->playback_block ()); > > + > > + playback_block (get_block ()) > > + ->add_indirect_jump (playback_location (r), > > + m_target_address->playback_rvalue (), > > + &pb_dests); > > +} > > + > > +/* Override the poisoned default implementation of > > + gcc::jit::recording::statement::get_successor_blocks. */ > > + > > +vec > > +recording::indirect_jump::get_successor_blocks () const > > +{ > > + vec result; > > + result.create (m_destinations.length ()); > > + for (unsigned i = 0; i < m_destinations.length (); i++) > > + result.quick_push (m_destinations[i]); > > + return result; > > +} > > + > > +/* Implementation of recording::memento::make_debug_string for > > + an indirect jump statement. */ > > + > > +recording::string * > > +recording::indirect_jump::make_debug_string () > > +{ > > + return string::from_printf (m_ctxt, > > + "goto *%s;", > > + m_target_address->get_debug_string ()); > > +} > > + > > +/* Implementation of recording::memento::write_reproducer for > > + indirect_jump statements. */ > > + > > +void > > +recording::indirect_jump::write_reproducer (reproducer &r) > > +{ > > + r.make_identifier (this, "indirect_jump"); > > + const char *dests_id = r.make_tmp_identifier ("destinations_for", > > this); > > + r.write (" gcc_jit_block *%s[%i] = {\n", > > + dests_id, > > + m_destinations.length ()); > > + for (unsigned i = 0; i < m_destinations.length (); i++) > > + r.write (" %s,\n", r.get_identifier (m_destinations[i])); > > + r.write (" };\n"); > > + r.write (" gcc_jit_block_end_with_indirect_jump (%s,\n" > > + " %s,\n" > > + " %s,\n" > > + " %i,\n" > > + " %s);\n", > > + r.get_identifier (get_block ()), > > + r.get_identifier (get_loc ()), > > + r.get_identifier_as_rvalue (m_target_address), > > + m_destinations.length (), > > + dests_id); > > +} > > + > > /* The implementation of class gcc::jit::recording::return_. */ > > > > /* Implementation of pure virtual hook > > recording::memento::replay_into > > diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h > > index 2a5f23a05..c500ea659 100644 > > --- a/gcc/jit/jit-recording.h > > +++ b/gcc/jit/jit-recording.h > > @@ -966,7 +966,7 @@ public: > > type *unqualified () final override { return m_other_type; } > > > > void replay_into (replayer *) final override; > > - memento_of_get_aligned *dyn_cast_aligned_type () final override > > + memento_of_get_aligned *dyn_cast_aligned_type () final override > > { > > return this; > > } > > @@ -1682,6 +1682,13 @@ public: > > end_with_jump (location *loc, > > block *target); > > > > + rvalue * get_address (location *loc); > > + > > + statement * end_with_indirect_jump (location *loc, > > + rvalue *target_address, > > + int num_destinations, > > + block **destinations); > > + > > statement * > > end_with_return (location *loc, > > rvalue *rvalue); > > @@ -2427,6 +2434,32 @@ private: > > lvalue *m_lvalue; > > }; > > > > +class get_block_address : public rvalue > > +{ > > +public: > > + get_block_address (context *ctxt, > > + location *loc, > > + block *b) > > + : rvalue (ctxt, loc, ctxt->get_type (GCC_JIT_TYPE_VOID_PTR)), > > + m_block (b) > > + {} > > + > > + void replay_into (replayer *r) final override; > > + > > + void visit_children (rvalue_visitor *) final override {} > > + > > +private: > > + string * make_debug_string () final override; > > + void write_reproducer (reproducer &r) final override; > > + enum precedence get_precedence () const final override > > + { > > + return PRECEDENCE_UNARY; > > + } > > + > > +private: > > + block *m_block; > > +}; > > + > > class function_pointer : public rvalue > > { > > public: > > @@ -2650,6 +2683,28 @@ private: > > block *m_target; > > }; > > > > +class indirect_jump : public statement > > +{ > > +public: > > + indirect_jump (block *b, > > + location *loc, > > + rvalue *target_address, > > + int num_destinations, > > + block **destinations); > > + > > + void replay_into (replayer *r) final override; > > + > > + vec get_successor_blocks () const final override; > > + > > +private: > > + string * make_debug_string () final override; > > + void write_reproducer (reproducer &r) final override; > > + > > +private: > > + rvalue *m_target_address; > > + auto_vec m_destinations; > > +}; > > + > > class return_ : public statement > > { > > public: > > diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc > > index 5a874fc48..4fac8c56b 100644 > > --- a/gcc/jit/libgccjit.cc > > +++ b/gcc/jit/libgccjit.cc > > @@ -2874,6 +2874,23 @@ gcc_jit_lvalue_get_address (gcc_jit_lvalue > > *lvalue, > > return (gcc_jit_rvalue *)lvalue->get_address (loc); > > } > > > > +/* Public entrypoint. See description in libgccjit.h. > > + > > + After error-checking, the real work is done by the > > + gcc::jit::recording::block::get_address method in > > + jit-recording.cc. */ > > + > > +gcc_jit_rvalue * > > +gcc_jit_block_get_address (gcc_jit_block *block, > > + gcc_jit_location *loc) > > +{ > > + RETURN_NULL_IF_FAIL (block, NULL, loc, "NULL block"); > > + JIT_LOG_FUNC (block->get_context ()->get_logger ()); > > + /* LOC can be NULL. */ > > + > > + return (gcc_jit_rvalue *)block->get_address (loc); > > +} > > + > > /* Public entrypoint. See description in libgccjit.h. > > > > After error-checking, the real work is done by the > > @@ -3258,6 +3275,52 @@ gcc_jit_block_end_with_jump (gcc_jit_block > > *block, > > block->end_with_jump (loc, target); > > } > > > > +/* Public entrypoint. See description in libgccjit.h. > > + > > + After error-checking, the real work is done by the > > + gcc::jit::recording::block::end_with_indirect_jump method in > > + jit-recording.cc. */ > > + > > +void > > +gcc_jit_block_end_with_indirect_jump (gcc_jit_block *block, > > + gcc_jit_location *loc, > > + gcc_jit_rvalue *target_address, > > + int num_destinations, > > + gcc_jit_block **destinations) > > +{ > > + RETURN_IF_NOT_VALID_BLOCK (block, loc); > > + gcc::jit::recording::context *ctxt = block->get_context (); > > + JIT_LOG_FUNC (ctxt->get_logger ()); > > + /* LOC can be NULL. */ > > + RETURN_IF_FAIL (target_address, ctxt, loc, "NULL target_address"); > > + RETURN_IF_FAIL_PRINTF1 ( > > + target_address->get_type ()->is_pointer (), > > + ctxt, loc, > > + "target_address: %s is not of a pointer type", > > + target_address->get_debug_string ()); > > + RETURN_IF_FAIL (num_destinations > 0, ctxt, loc, "num_destinations > > <= 0"); > > + RETURN_IF_FAIL (destinations, ctxt, loc, "NULL destinations"); > > + > > + for (int i = 0; i < num_destinations; i++) > > + { > > + RETURN_IF_FAIL_PRINTF1 (destinations[i], ctxt, loc, > > + "NULL destination block at index %d", i); > > + RETURN_IF_FAIL_PRINTF4 ( > > + block->get_function () == destinations[i]->get_function (), > > + ctxt, loc, > > + "destination block %d (%s) is not in the same function" > > + " (function %s) as source block %s", > > + i, > > + destinations[i]->get_debug_string (), > > + destinations[i]->get_function ()->get_debug_string (), > > + block->get_debug_string ()); > > + } > > + > > + block->end_with_indirect_jump (loc, target_address, > > + num_destinations, > > + (gcc::jit::recording::block **)destinations); > > +} > > + > > /* Public entrypoint. See description in libgccjit.h. > > > > After error-checking, the real work is done by the > > diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h > > index 2247c99de..9d00ba33a 100644 > > --- a/gcc/jit/libgccjit.h > > +++ b/gcc/jit/libgccjit.h > > @@ -1455,16 +1455,31 @@ extern gcc_jit_rvalue * > > gcc_jit_lvalue_get_address (gcc_jit_lvalue *lvalue, > > gcc_jit_location *loc); > > > > +#define LIBGCCJIT_HAVE_gcc_jit_block_get_address > > + > > +/* Taking the address of a block; analogous to: > > + &&block > > + in C. > > + > > + This API entrypoint was added in LIBGCCJIT_ABI_39; you can test > > for its > > + presence using > > + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_get_address > > +*/ > > +extern gcc_jit_rvalue * > > +gcc_jit_block_get_address (gcc_jit_block *block, > > + gcc_jit_location *loc); > > + > > #define LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model > > > > /* Set the thread-local storage model of a global variable > > > > This API entrypoint was added in LIBGCCJIT_ABI_17; you can test > > for its > > presence using > > - #ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model */ > > + #ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model > > +*/ > > extern void > > gcc_jit_lvalue_set_tls_model (gcc_jit_lvalue *lvalue, > > - enum gcc_jit_tls_model model); > > + enum gcc_jit_tls_model model); > > > > #define LIBGCCJIT_HAVE_gcc_jit_lvalue_set_link_section > > > > @@ -1592,6 +1607,26 @@ gcc_jit_block_end_with_jump (gcc_jit_block > > *block, > > gcc_jit_location *loc, > > gcc_jit_block *target); > > > > +#define LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump > > + > > +/* Terminate a block by adding an indirect jump to target_address. > > + > > + All possible indirect jump targets must be constrained to a fixed > > array. > > + > > + This is roughly equivalent to this C code: > > + > > + goto *target_address; > > + > > + This API entrypoint was added in LIBGCCJIT_ABI_39; you can test > > for its > > + presence using > > + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump. > > */ > > +extern void > > +gcc_jit_block_end_with_indirect_jump (gcc_jit_block *block, > > + gcc_jit_location *loc, > > + gcc_jit_rvalue *target_address, > > + int num_destinations, > > + gcc_jit_block **destinations); > > + > > /* Terminate a block by adding evaluation of an rvalue, returning > > the value. > > > > This is roughly equivalent to this C code: > > diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map > > index 78b6be9ff..9412700a2 100644 > > --- a/gcc/jit/libgccjit.map > > +++ b/gcc/jit/libgccjit.map > > @@ -349,3 +349,9 @@ LIBGCCJIT_ABI_38 { > > global: > > gcc_jit_type_is_floating_point; > > } LIBGCCJIT_ABI_37; > > + > > +LIBGCCJIT_ABI_39 { > > + global: > > + gcc_jit_block_get_address; > > + gcc_jit_block_end_with_indirect_jump; > > +} LIBGCCJIT_ABI_38; > > diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h > > b/gcc/testsuite/jit.dg/all-non-failing-tests.h > > index e8f8463e8..5bf18a874 100644 > > --- a/gcc/testsuite/jit.dg/all-non-failing-tests.h > > +++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h > > @@ -448,6 +448,13 @@ > > #undef create_code > > #undef verify_code > > > > +/* test-indirect-jump.c */ > > +#define create_code create_code_indirect_jump > > +#define verify_code verify_code_indirect_jump > > +#include "test-indirect-jump.c" > > +#undef create_code > > +#undef verify_code > > + > > /* test-target-info.c: This can't be in the testcases array as it > > is target-specific. */ > > > > @@ -688,6 +695,9 @@ const struct testcase testcases[] = { > > {"vector_perm", > > create_code_vector_perm, > > verify_code_vector_perm}, > > + {"indirect_jump", > > + create_code_indirect_jump, > > + verify_code_indirect_jump}, > > }; > > > > const int num_testcases = (sizeof (testcases) / sizeof > > (testcases[0])); > > diff --git a/gcc/testsuite/jit.dg/test-indirect-jump.c > > b/gcc/testsuite/jit.dg/test-indirect-jump.c > > new file mode 100644 > > index 000000000..3d407f7ea > > --- /dev/null > > +++ b/gcc/testsuite/jit.dg/test-indirect-jump.c > > @@ -0,0 +1,108 @@ > > +#include > > +#include > > + > > +#include "libgccjit.h" > > +#include "harness.h" > > + > > +void > > +create_code (gcc_jit_context *ctxt, void *user_data) > > +{ > > + /* Let's try to inject the equivalent of: > > + int > > + test_indirect_jump (int idx) > > + { > > + void *targets[3]; > > + targets[0] = &&b_zero; > > + targets[1] = &&b_one; > > + targets[2] = &&b_two; > > + goto *targets[idx]; > > + > > + b_zero: > > + return 10; > > + b_one: > > + return 20; > > + b_two: > > + return 30; > > + } > > + */ > > + gcc_jit_type *int_type = > > + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); > > + gcc_jit_type *void_ptr_type = > > + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID_PTR); > > + gcc_jit_type *array_type = > > + gcc_jit_context_new_array_type (ctxt, NULL, void_ptr_type, 3); > > + > > + gcc_jit_param *param_idx = > > + gcc_jit_context_new_param (ctxt, NULL, int_type, "idx"); > > + gcc_jit_function *func = > > + gcc_jit_context_new_function (ctxt, NULL, > > + GCC_JIT_FUNCTION_EXPORTED, > > + int_type, > > + "test_indirect_jump", > > + 1, ¶m_idx, > > + 0); > > + > > + gcc_jit_block *b_entry = gcc_jit_function_new_block (func, > > "entry"); > > + gcc_jit_block *b_zero = gcc_jit_function_new_block (func, > > "b_zero"); > > + gcc_jit_block *b_one = gcc_jit_function_new_block (func, "b_one"); > > + gcc_jit_block *b_two = gcc_jit_function_new_block (func, "b_two"); > > + > > + gcc_jit_lvalue *targets = > > + gcc_jit_function_new_local (func, NULL, array_type, "targets"); > > + > > + gcc_jit_block *blocks[3] = { b_zero, b_one, b_two }; > > + for (int i = 0; i < 3; i++) > > + { > > + gcc_jit_rvalue *idx_val = > > + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, i); > > + gcc_jit_lvalue *elem = > > + gcc_jit_context_new_array_access (ctxt, NULL, > > + gcc_jit_lvalue_as_rvalue (targets), > > + idx_val); > > + gcc_jit_rvalue *blk_addr = > > + gcc_jit_block_get_address (blocks[i], NULL); > > + gcc_jit_block_add_assignment (b_entry, NULL, elem, blk_addr); > > + } > > + > > + /* void *target_addr = targets[idx]; */ > > + gcc_jit_lvalue *selected_elem = > > + gcc_jit_context_new_array_access (ctxt, NULL, > > + gcc_jit_lvalue_as_rvalue (targets), > > + gcc_jit_param_as_rvalue (param_idx)); > > + > > + /* goto *targets[idx]; */ > > + gcc_jit_block_end_with_indirect_jump ( > > + b_entry, NULL, > > + gcc_jit_lvalue_as_rvalue (selected_elem), > > + 3, blocks); > > + > > + /* b_zero: return 10; */ > > + gcc_jit_block_end_with_return ( > > + b_zero, NULL, > > + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 10)); > > + > > + /* b_one: return 20; */ > > + gcc_jit_block_end_with_return ( > > + b_one, NULL, > > + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 20)); > > + > > + /* b_two: return 30; */ > > + gcc_jit_block_end_with_return ( > > + b_two, NULL, > > + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 30)); > > +} > > + > > +void > > +verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) > > +{ > > + typedef int (*fn_type) (int); > > + CHECK_NON_NULL (result); > > + > > + fn_type test_indirect_jump = > > + (fn_type)gcc_jit_result_get_code (result, "test_indirect_jump"); > > + CHECK_NON_NULL (test_indirect_jump); > > + > > + CHECK_VALUE (test_indirect_jump (0), 10); > > + CHECK_VALUE (test_indirect_jump (1), 20); > > + CHECK_VALUE (test_indirect_jump (2), 30); > > +} > -------------- next part -------------- A non-text attachment was scrubbed... Name: v2-0001-PATCH-jit-Add-support-for-computed-gotos-and-bloc.patch Type: text/x-patch Size: 29981 bytes Desc: not available URL: From morin-mikael@orange.fr Sun Nov 1 21:15:07 2026 From: morin-mikael@orange.fr (Mikael Morin) Date: Sun, 1 Nov 2026 22:15:07 +0100 Subject: [PATCH 1/2] libgfortran: [PR127751] caf_shmem: catch overflowing coarray sizes In-Reply-To: <07769c2d-e878-48b9-89e0-a7959174ae9a@gmail.com> References: <07769c2d-e878-48b9-89e0-a7959174ae9a@gmail.com> Message-ID: Le 30/10/2026 ? 13:56, Jerry DeLisle a ?crit?: > See attached patch. This is 1 of 2 to fix some loose ends in this effort. > > Fairly self explanatory. > > Regression tested on x86_64 > > OK for mainline? This is mostly good; two cosmetic points below. > > Regards, > > Jerry > diff --git a/libgfortran/caf/shmem.c b/libgfortran/caf/shmem.c > index 964c7449e02..88b800e5247 100644 > --- a/libgfortran/caf/shmem.c > +++ b/libgfortran/caf/shmem.c > @@ -266,7 +274,8 @@ _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token, > if (type != CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY) > *token = malloc (sizeof (struct caf_shmem_token)); > > - size = alignto (size, sizeof (ptrdiff_t)); > + size = size > SIZE_MAX - sizeof (ptrdiff_t) > + ? SIZE_MAX : alignto (size, sizeof (ptrdiff_t)); Can you put a comment somewhere telling that saturating to SIZE_MAX will end up being caught by the allocation code, resulting in a failed allocation? You mention it in the commit message, but it remains somehow implicit in the code itself. > switch (type) > { > case CAF_REGTYPE_LOCK_STATIC: > @@ -309,7 +319,8 @@ _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token, > > allocator_lock (&local->ai.alloc); > mem = alloc_get_memory_by_id_created ( > - &local->ai, size * local->total_num_images, next_memid, &created); > + &local->ai, mul_size_sat (size, local->total_num_images), next_memid, > + &created); Please use a variable for the multiplication result, here... > if (created) > memset (mem, 0, size * local->total_num_images); ... and here, so that it remains apparent that we are clearing the same amount as allocated. > allocator_unlock (&local->ai.alloc); OK with these changes. From purgeinflame321@gmail.com Sun Nov 1 21:23:29 2026 From: purgeinflame321@gmail.com (Vincent Li) Date: Sun, 1 Nov 2026 16:23:29 -0500 Subject: [PATCH] jit: Add support for computed gotos and block addresses In-Reply-To: References: <0a0b4e486be69a733a4b8e8ab021d036bd0e38b7.camel@redhat.com> Message-ID: Reattaching file due to previous patch merge issues. Please alert me if anything happens again. On Sun, Nov 1, 2026 at 3:58?PM Vincent Li wrote: > > Thanks for the response! I believe I've got everything lined back up > according to your suggestions. > > Vincent Li is my legal name used for the DCO sign-off, and Marcus > Valette was just an old display handle on my Gmail account?fixed the > sender header for v2. Sorry for any confusion that may have caused. > > --------- >8 ------------------ > > From 0eff1430218fb1eb3768500f82a8998c31db7e75 Mon Sep 17 00:00:00 2001 > From: Vincent Li > Date: Fri, 23 Oct 2026 13:23:48 -0400 > Subject: [PATCH v2] jit: Add support for computed gotos and block addresses > > This patch adds `gcc_jit_block_get_address` and > `gcc_jit_block_end_with_indirect_jump` > under ABI version LIBGCCJIT_ABI_39. This exposes GNU C > labels-as-values (`&&label`) > and indirect jumps (`goto *expr;`) in libgccjit, enabling JIT-compiled > interpreter > dispatch loops and state machines to implement direct-threaded code tables. > > Tested on x86_64-pc-linux-gnu. All 30 iterations of jit.dg/test-indirect-jump.c > passed across -O0 to -O3. check_GNU_style.py reports 0 errors. > > gcc/jit/ChangeLog: > > * docs/topics/expressions.rst (gcc_jit_block_get_address): Document. > * docs/topics/functions.rst > (gcc_jit_block_end_with_indirect_jump): Document. > * jit-playback.cc (playback::block::get_address): New method. > (playback::block::add_indirect_jump): New method. > * jit-playback.h (playback::block::get_address): New method. > (playback::block::add_indirect_jump): New method. > * jit-recording.cc (recording::block::get_address): New method. > (recording::block::end_with_indirect_jump): New method. > (recording::get_block_address::replay_into): New method. > (recording::get_block_address::make_debug_string): New method. > (recording::get_block_address::write_reproducer): New method. > (recording::indirect_jump::replay_into): New method. > (recording::indirect_jump::get_successor_blocks): New method. > (recording::indirect_jump::make_debug_string): New method. > (recording::indirect_jump::write_reproducer): New method. > * jit-recording.h (class get_block_address): New class. > (class indirect_jump): New class. > (recording::block::get_address): New method. > (recording::block::end_with_indirect_jump): New method. > * libgccjit.cc (gcc_jit_block_get_address): New entrypoint. > (gcc_jit_block_end_with_indirect_jump): New entrypoint. > * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_block_get_address): New macro. > (LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump): New macro. > (gcc_jit_block_get_address): New declaration. > (gcc_jit_block_end_with_indirect_jump): New declaration. > * libgccjit.map (LIBGCCJIT_ABI_39): Add gcc_jit_block_get_address and > gcc_jit_block_end_with_indirect_jump. > > gcc/testsuite/ChangeLog: > > * jit.dg/all-non-failing-tests.h: Include test-indirect-jump.c. > * jit.dg/test-indirect-jump.c: New test. > > Signed-off-by: Vincent Li > --- > gcc/jit/docs/topics/compatibility.rst | 8 + > gcc/jit/docs/topics/functions.rst | 40 +++++ > gcc/jit/jit-playback.cc | 43 +++++ > gcc/jit/jit-playback.h | 7 + > gcc/jit/jit-recording.cc | 157 ++++++++++++++++++ > gcc/jit/jit-recording.h | 59 ++++++- > gcc/jit/libgccjit.cc | 68 ++++++++ > gcc/jit/libgccjit.h | 45 ++++- > gcc/jit/libgccjit.map | 6 + > gcc/testsuite/jit.dg/all-non-failing-tests.h | 10 ++ > .../jit.dg/test-error-indirect-jump.c | 112 +++++++++++++ > gcc/testsuite/jit.dg/test-indirect-jump.c | 109 ++++++++++++ > 12 files changed, 661 insertions(+), 3 deletions(-) > create mode 100644 gcc/testsuite/jit.dg/test-error-indirect-jump.c > create mode 100644 gcc/testsuite/jit.dg/test-indirect-jump.c > > diff --git a/gcc/jit/docs/topics/compatibility.rst > b/gcc/jit/docs/topics/compatibility.rst > index e4a231e79..ca1a428f3 100644 > --- a/gcc/jit/docs/topics/compatibility.rst > +++ b/gcc/jit/docs/topics/compatibility.rst > @@ -489,3 +489,11 @@ information: > ``LIBGCCJIT_ABI_38`` covers the addition of > > * :func:`gcc_jit_type_is_floating_point` > + > + .. _LIBGCCJIT_ABI_39: > + > +``LIBGCCJIT_ABI_39`` > +----------------------- > +``LIBGCCJIT_ABI_39`` covers the addition of API entrypoints > + * :func:`gcc_jit_block_get_address` > + * :func:`gcc_jit_block_end_with_indirect_jump` > diff --git a/gcc/jit/docs/topics/functions.rst > b/gcc/jit/docs/topics/functions.rst > index 66d4b6b2f..67818881d 100644 > --- a/gcc/jit/docs/topics/functions.rst > +++ b/gcc/jit/docs/topics/functions.rst > @@ -466,6 +466,46 @@ Statements > > goto target; > > +.. function:: gcc_jit_rvalue *\ > + gcc_jit_block_get_address (gcc_jit_block *block,\ > + gcc_jit_location *loc) > + > + Get the address of a block as a ``void *`` rvalue, equivalent to GNU C's > + ``&&label`` extension. > + > + ``block`` must be non-NULL. > + > + This API entrypoint was added in :ref:`LIBGCCJIT_ABI_39`; you can test > + for its presence using > + > + .. code-block:: c > + > + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_get_address > + > +.. function:: void\ > + gcc_jit_block_end_with_indirect_jump (\ > + gcc_jit_block *block,\ > + gcc_jit_location *loc,\ > + gcc_jit_rvalue *target_address,\ > + int num_destinations,\ > + gcc_jit_block **destinations) > + > + Terminate a basic block by adding an indirect jump to ``target_address``, > + analogous to GNU C's ``goto *target_address;``. > + > + Here, ``target_address`` must be a pointer rvalue, and ``destinations`` > + must be an array of ``num_destinations`` candidate target blocks within > + the same function. Listing the candidate destination blocks is required > + so that ``libgccjit`` can validate block reachability when checking the > + function. > + > + This API entrypoint was added in ``LIBGCCJIT_ABI_39``; you can test for its > + presence using: > + > + .. code-block:: c > + > + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump > + > .. function:: void\ > gcc_jit_block_end_with_return (gcc_jit_block *block,\ > gcc_jit_location *loc,\ > diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc > index 56c9413f8..c4c1ec8fd 100644 > --- a/gcc/jit/jit-playback.cc > +++ b/gcc/jit/jit-playback.cc > @@ -2547,6 +2547,49 @@ c_finish_goto_label (location_t loc, tree label) > > } > > +/* Take the address of a block as a void * rvalue (&&block). */ > + > +playback::rvalue * > +playback::block:: > +get_address (location *loc) > +{ > + tree label = as_label_decl (); > + TREE_USED (label) = 1; > + /* Also set during gimplification by gimplify_addr_expr, but marked > + explicitly here when constructing the ADDR_EXPR. */ > + FORCED_LABEL (label) = 1; > + > + tree addr = build1 (ADDR_EXPR, ptr_type_node, label); > + if (loc) > + set_tree_location (addr, loc); > + > + return new rvalue (m_func->m_ctxt, addr); > +} > + > +/* Add an indirect jump statement (goto *target_address;). */ > + > +void > +playback::block::add_indirect_jump (location *loc, > + rvalue *target_address, > + auto_vec *destinations) > +{ > + unsigned i; > + block *dest; > + FOR_EACH_VEC_ELT (*destinations, i, dest) > + { > + tree label = dest->as_label_decl (); > + TREE_USED (label) = 1; > + FORCED_LABEL (label) = 1; > + } > + > + tree target = target_address->as_tree (); > + target = fold_convert (ptr_type_node, target); > + tree stmt = build1 (GOTO_EXPR, void_type_node, target); > + if (loc) > + set_tree_location (stmt, loc); > + add_stmt (stmt); > +} > + > /* Add a return statement to the function's statement list. */ > > void > diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h > index ad3e41f3d..d32ed4d49 100644 > --- a/gcc/jit/jit-playback.h > +++ b/gcc/jit/jit-playback.h > @@ -692,6 +692,13 @@ public: > add_jump (location *loc, > block *target); > > + rvalue *get_address (location *loc); > + > + void > + add_indirect_jump (location *loc, > + rvalue *target_address, > + auto_vec *destinations); > + > void > add_return (location *loc, > rvalue *rvalue); > diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc > index e28e5f67c..337f14925 100644 > --- a/gcc/jit/jit-recording.cc > +++ b/gcc/jit/jit-recording.cc > @@ -5072,6 +5072,26 @@ recording::block::end_with_jump > (recording::location *loc, > return result; > } > > +/* Create a recording::end_with_indirect_jump instance and add > + it to the block's context's list of mementos, and to the > + block's list of statements. > + > + Implements the heart of gcc_jit_block_end_with_indirect_jump. */ > + > +recording::statement * > +recording::block::end_with_indirect_jump (location *loc, > + rvalue *target_address, > + int num_destinations, > + block **destinations) > +{ > + statement *result = new indirect_jump (this, loc, target_address, > + num_destinations, destinations); > + m_ctxt->record (result); > + m_statements.safe_push (result); > + m_has_been_terminated = true; > + return result; > +} > + > /* Create a recording::end_with_return instance and add it to > the block's context's list of mementos, and to the block's > list of statements. > @@ -5197,6 +5217,20 @@ recording::block::get_loc () const > return NULL; > } > > +/* Create a recording::get_address instance and add it to > + the block's context's list of mementos, and to the block's > + list of statements. > + > + Implements the heart of gcc_jit_block_get_address. */ > + > +recording::rvalue * > +recording::block::get_address (location *loc) > +{ > + recording::rvalue *result = new get_block_address (m_ctxt, loc, this); > + m_ctxt->record (result); > + return result; > +} > + > /* Get the first statement within a block, if any. */ > > recording::statement * > @@ -7332,6 +7366,45 @@ > recording::get_address_of_lvalue::write_reproducer (reproducer &r) > r.get_identifier (m_loc)); > } > > +/* The implementation of class gcc::jit::recording::get_block_address. */ > + > +/* Implementation of pure virtual hook recording::memento::replay_into > + for recording::get_block_address. */ > + > +void > +recording::get_block_address::replay_into (replayer *r) > +{ > + set_playback_obj ( > + m_block->playback_block ()-> > + get_address (playback_location (r, m_loc))); > +} > + > +/* Implementation of recording::memento::make_debug_string for > + getting the address of a block. */ > + > +recording::string * > +recording::get_block_address::make_debug_string () > +{ > + return string::from_printf (m_ctxt, > + "&&%s", > + m_block->get_debug_string ()); > +} > + > +/* Implementation of recording::memento::write_reproducer for > + get_block_address. */ > + > +void > +recording::get_block_address::write_reproducer (reproducer &r) > +{ > + const char *id = r.make_identifier (this, "address_of"); > + r.write (" gcc_jit_rvalue *%s =\n" > + " gcc_jit_block_get_address (%s,\n" > + " %s);\n", > + id, > + r.get_identifier (m_block), > + r.get_identifier (m_loc)); > +} > + > /* The implementation of class gcc::jit::recording::function_pointer. */ > > /* Implementation of pure virtual hook recording::memento::replay_into > @@ -7765,6 +7838,90 @@ recording::jump::write_reproducer (reproducer &r) > r.get_identifier (m_target)); > } > > +/* The implementation of class gcc::jit::recording::indirect_jump. */ > + > +/* gcc::jit::recording::indirect_jump's constructor. */ > + > +recording::indirect_jump::indirect_jump (block *b, > + location *loc, > + rvalue *target_address, > + int num_destinations, > + block **destinations) > +: statement (b, loc), > + m_target_address (target_address) > +{ > + m_destinations.reserve_exact (num_destinations); > + for (int i = 0; i < num_destinations; i++) > + m_destinations.quick_push (destinations[i]); > +} > + > +/* Implementation of pure virtual hook recording::memento::replay_into > + for recording::indirect_jump. */ > + > +void > +recording::indirect_jump::replay_into (replayer *r) > +{ > + auto_vec pb_dests; > + pb_dests.reserve_exact (m_destinations.length ()); > + for (unsigned i = 0; i < m_destinations.length (); i++) > + pb_dests.quick_push (m_destinations[i]->playback_block ()); > + > + playback_block (get_block ()) > + ->add_indirect_jump (playback_location (r), > + m_target_address->playback_rvalue (), > + &pb_dests); > +} > + > +/* Override the poisoned default implementation of > + gcc::jit::recording::statement::get_successor_blocks. */ > + > +vec > +recording::indirect_jump::get_successor_blocks () const > +{ > + vec result; > + result.create (m_destinations.length ()); > + for (unsigned i = 0; i < m_destinations.length (); i++) > + result.quick_push (m_destinations[i]); > + return result; > +} > + > +/* Implementation of recording::memento::make_debug_string for > + an indirect jump statement. */ > + > +recording::string * > +recording::indirect_jump::make_debug_string () > +{ > + return string::from_printf (m_ctxt, > + "goto *%s;", > + m_target_address->get_debug_string_parens > (PRECEDENCE_UNARY)); > +} > + > +/* Implementation of recording::memento::write_reproducer for > + indirect_jump statements. */ > + > +void > +recording::indirect_jump::write_reproducer (reproducer &r) > +{ > + r.make_identifier (this, "indirect_jump"); > + const char *dests_id = r.make_tmp_identifier ("destinations_for", this); > + r.write (" gcc_jit_block *%s[%i] = {\n", > + dests_id, > + m_destinations.length ()); > + for (unsigned i = 0; i < m_destinations.length (); i++) > + r.write (" %s,\n", r.get_identifier (m_destinations[i])); > + r.write (" };\n"); > + r.write (" gcc_jit_block_end_with_indirect_jump (%s,\n" > + " %s,\n" > + " %s,\n" > + " %i,\n" > + " %s);\n", > + r.get_identifier (get_block ()), > + r.get_identifier (get_loc ()), > + r.get_identifier_as_rvalue (m_target_address), > + m_destinations.length (), > + dests_id); > +} > + > /* The implementation of class gcc::jit::recording::return_. */ > > /* Implementation of pure virtual hook recording::memento::replay_into > diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h > index 2a5f23a05..952761dca 100644 > --- a/gcc/jit/jit-recording.h > +++ b/gcc/jit/jit-recording.h > @@ -966,7 +966,7 @@ public: > type *unqualified () final override { return m_other_type; } > > void replay_into (replayer *) final override; > - memento_of_get_aligned *dyn_cast_aligned_type () final override > + memento_of_get_aligned *dyn_cast_aligned_type () final override > { > return this; > } > @@ -1682,6 +1682,13 @@ public: > end_with_jump (location *loc, > block *target); > > + rvalue * get_address (location *loc); > + > + statement * end_with_indirect_jump (location *loc, > + rvalue *target_address, > + int num_destinations, > + block **destinations); > + > statement * > end_with_return (location *loc, > rvalue *rvalue); > @@ -2427,6 +2434,34 @@ private: > lvalue *m_lvalue; > }; > > +class get_block_address : public rvalue > +{ > +public: > + get_block_address (context *ctxt, > + location *loc, > + block *b) > + : rvalue (ctxt, loc, ctxt->get_type (GCC_JIT_TYPE_VOID_PTR)), > + m_block (b) > + { > + set_scope (b->get_function ()); > + } > + > + void replay_into (replayer *r) final override; > + > + void visit_children (rvalue_visitor *) final override {} > + > +private: > + string * make_debug_string () final override; > + void write_reproducer (reproducer &r) final override; > + enum precedence get_precedence () const final override > + { > + return PRECEDENCE_UNARY; > + } > + > +private: > + block *m_block; > +}; > + > class function_pointer : public rvalue > { > public: > @@ -2650,6 +2685,28 @@ private: > block *m_target; > }; > > +class indirect_jump : public statement > +{ > +public: > + indirect_jump (block *b, > + location *loc, > + rvalue *target_address, > + int num_destinations, > + block **destinations); > + > + void replay_into (replayer *r) final override; > + > + vec get_successor_blocks () const final override; > + > +private: > + string * make_debug_string () final override; > + void write_reproducer (reproducer &r) final override; > + > +private: > + rvalue *m_target_address; > + auto_vec m_destinations; > +}; > + > class return_ : public statement > { > public: > diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc > index 5a874fc48..42c6fe828 100644 > --- a/gcc/jit/libgccjit.cc > +++ b/gcc/jit/libgccjit.cc > @@ -2874,6 +2874,23 @@ gcc_jit_lvalue_get_address (gcc_jit_lvalue *lvalue, > return (gcc_jit_rvalue *)lvalue->get_address (loc); > } > > +/* Public entrypoint. See description in libgccjit.h. > + > + After error-checking, the real work is done by the > + gcc::jit::recording::block::get_address method in > + jit-recording.cc. */ > + > +gcc_jit_rvalue * > +gcc_jit_block_get_address (gcc_jit_block *block, > + gcc_jit_location *loc) > +{ > + RETURN_NULL_IF_FAIL (block, NULL, loc, "NULL block"); > + JIT_LOG_FUNC (block->get_context ()->get_logger ()); > + /* LOC can be NULL. */ > + > + return (gcc_jit_rvalue *)block->get_address (loc); > +} > + > /* Public entrypoint. See description in libgccjit.h. > > After error-checking, the real work is done by the > @@ -3258,6 +3275,57 @@ gcc_jit_block_end_with_jump (gcc_jit_block *block, > block->end_with_jump (loc, target); > } > > +/* Public entrypoint. See description in libgccjit.h. > + > + After error-checking, the real work is done by the > + gcc::jit::recording::block::end_with_indirect_jump method in > + jit-recording.cc. */ > + > +void > +gcc_jit_block_end_with_indirect_jump (gcc_jit_block *block, > + gcc_jit_location *loc, > + gcc_jit_rvalue *target_address, > + int num_destinations, > + gcc_jit_block **destinations) > +{ > + RETURN_IF_NOT_VALID_BLOCK (block, loc); > + gcc::jit::recording::context *ctxt = block->get_context (); > + JIT_LOG_FUNC (ctxt->get_logger ()); > + /* LOC can be NULL. */ > + RETURN_IF_FAIL (target_address, ctxt, loc, "NULL target_address"); > + RETURN_IF_FAIL_PRINTF1 ( > + target_address->get_type ()->is_pointer (), > + ctxt, loc, > + "target_address: %s is not of a pointer type", > + target_address->get_debug_string ()); > + RETURN_IF_FAIL (num_destinations >= 0, ctxt, loc, "num_destinations < 0"); > + if (num_destinations > 0) > + RETURN_IF_FAIL (destinations, ctxt, loc, "NULL destinations"); > + > + for (int i = 0; i < num_destinations; i++) > + { > + RETURN_IF_FAIL_PRINTF1 (destinations[i], ctxt, loc, > + "NULL destination block at index %d", i); > + RETURN_IF_FAIL_PRINTF4 ( > + block->get_function () == destinations[i]->get_function (), > + ctxt, loc, > + "destination block %d (%s) is not in the same function" > + " (function %s) as source block %s", > + i, > + destinations[i]->get_debug_string (), > + destinations[i]->get_function ()->get_debug_string (), > + block->get_debug_string ()); > + } > + > + gcc::jit::recording::statement *stmt = > + block->end_with_indirect_jump (loc, target_address, > + num_destinations, > + (gcc::jit::recording::block **)destinations); > + > + /* target_address must be valid to use within STMT. */ > + target_address->verify_valid_within_stmt (__func__, stmt); > +} > + > /* Public entrypoint. See description in libgccjit.h. > > After error-checking, the real work is done by the > diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h > index 2247c99de..272085986 100644 > --- a/gcc/jit/libgccjit.h > +++ b/gcc/jit/libgccjit.h > @@ -1455,16 +1455,31 @@ extern gcc_jit_rvalue * > gcc_jit_lvalue_get_address (gcc_jit_lvalue *lvalue, > gcc_jit_location *loc); > > +#define LIBGCCJIT_HAVE_gcc_jit_block_get_address > + > +/* Taking the address of a block; analogous to: > + &&block > + in C. > + > + This API entrypoint was added in LIBGCCJIT_ABI_39; you can test for its > + presence using > + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_get_address > +*/ > +extern gcc_jit_rvalue * > +gcc_jit_block_get_address (gcc_jit_block *block, > + gcc_jit_location *loc); > + > #define LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model > > /* Set the thread-local storage model of a global variable > > This API entrypoint was added in LIBGCCJIT_ABI_17; you can test for its > presence using > - #ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model */ > + #ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model > +*/ > extern void > gcc_jit_lvalue_set_tls_model (gcc_jit_lvalue *lvalue, > - enum gcc_jit_tls_model model); > + enum gcc_jit_tls_model model); > > #define LIBGCCJIT_HAVE_gcc_jit_lvalue_set_link_section > > @@ -1592,6 +1607,32 @@ gcc_jit_block_end_with_jump (gcc_jit_block *block, > gcc_jit_location *loc, > gcc_jit_block *target); > > +#define LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump > + > +/* Terminate a block by adding an indirect jump to target_address. > + > + All possible indirect jump targets must be constrained to a fixed array. > + > + The candidate destination blocks must be listed in DESTINATIONS > + > + (of length NUM_DESTINATIONS) so that libgccjit can validate block > + > + reachability within the function. > + > + This is roughly equivalent to this C code: > + > + goto *target_address; > + > + This API entrypoint was added in LIBGCCJIT_ABI_39; you can test for its > + presence using > + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump. */ > +extern void > +gcc_jit_block_end_with_indirect_jump (gcc_jit_block *block, > + gcc_jit_location *loc, > + gcc_jit_rvalue *target_address, > + int num_destinations, > + gcc_jit_block **destinations); > + > /* Terminate a block by adding evaluation of an rvalue, returning the value. > > This is roughly equivalent to this C code: > diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map > index 78b6be9ff..9412700a2 100644 > --- a/gcc/jit/libgccjit.map > +++ b/gcc/jit/libgccjit.map > @@ -349,3 +349,9 @@ LIBGCCJIT_ABI_38 { > global: > gcc_jit_type_is_floating_point; > } LIBGCCJIT_ABI_37; > + > +LIBGCCJIT_ABI_39 { > + global: > + gcc_jit_block_get_address; > + gcc_jit_block_end_with_indirect_jump; > +} LIBGCCJIT_ABI_38; > diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h > b/gcc/testsuite/jit.dg/all-non-failing-tests.h > index e8f8463e8..f8202635e 100644 > --- a/gcc/testsuite/jit.dg/all-non-failing-tests.h > +++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h > @@ -269,6 +269,13 @@ > #undef create_code > #undef verify_code > > +/* test-indirect-jump.c */ > +#define create_code create_code_indirect_jump > +#define verify_code verify_code_indirect_jump > +#include "test-indirect-jump.c" > +#undef create_code > +#undef verify_code > + > /* test-link-section-assembler.c: This can't be in the testcases array as it > doesn't have a verify_code implementation. */ > > @@ -688,6 +695,9 @@ const struct testcase testcases[] = { > {"vector_perm", > create_code_vector_perm, > verify_code_vector_perm}, > + {"indirect_jump", > + create_code_indirect_jump, > + verify_code_indirect_jump}, > }; > > const int num_testcases = (sizeof (testcases) / sizeof (testcases[0])); > diff --git a/gcc/testsuite/jit.dg/test-error-indirect-jump.c > b/gcc/testsuite/jit.dg/test-error-indirect-jump.c > new file mode 100644 > index 000000000..8f40a3738 > --- /dev/null > +++ b/gcc/testsuite/jit.dg/test-error-indirect-jump.c > @@ -0,0 +1,112 @@ > +#include > +#include > + > +#include "libgccjit.h" > +#include "harness.h" > + > +void > +create_code (gcc_jit_context *ctxt, void *user_data) > +{ > + /* Let's try to trigger every validation error on > + gcc_jit_block_get_address and gcc_jit_block_end_with_indirect_jump. */ > + gcc_jit_type *void_type = > + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID); > + gcc_jit_type *int_type = > + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); > + > + gcc_jit_function *fn1 = > + gcc_jit_context_new_function (ctxt, NULL, > + GCC_JIT_FUNCTION_EXPORTED, > + void_type, > + "fn1", > + 0, NULL, > + 0); > + gcc_jit_block *b_fn1 = > + gcc_jit_function_new_block (fn1, "b_fn1"); > + > + gcc_jit_function *fn2 = > + gcc_jit_context_new_function (ctxt, NULL, > + GCC_JIT_FUNCTION_EXPORTED, > + void_type, > + "fn2", > + 0, NULL, > + 0); > + gcc_jit_block *b_fn2 = > + gcc_jit_function_new_block (fn2, "b_fn2"); > + > + /* 1. Non-pointer target_address. */ > + gcc_jit_rvalue * non_ptr = > + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 42); > + gcc_jit_block_end_with_indirect_jump (b_fn1, NULL, non_ptr, 0, NULL); > + CHECK_STRING_VALUE ( > + gcc_jit_context_get_last_error (ctxt), > + "gcc_jit_block_end_with_indirect_jump:" > + " target_address: (int)42 is not of a pointer type"); > + > + /* 2. Negative num_destinations. */ > + gcc_jit_rvalue *addr_fn1 = gcc_jit_block_get_address (b_fn1, NULL); > + gcc_jit_block_end_with_indirect_jump (b_fn1, NULL, addr_fn1, -1, NULL); > + CHECK_STRING_VALUE ( > + gcc_jit_context_get_last_error (ctxt), > + "gcc_jit_block_end_with_indirect_jump: num_destinations < 0"); > + > + /* 3. NULL destinations array when num_destinations > 0. */ > + gcc_jit_block_end_with_indirect_jump (b_fn1, NULL, addr_fn1, 1, NULL); > + CHECK_STRING_VALUE ( > + gcc_jit_context_get_last_error (ctxt), > + "gcc_jit_block_end_with_indirect_jump: NULL destinations"); > + > + /* 4. NULL element in destinations array. */ > + gcc_jit_block *null_dests[1] = { NULL }; > + gcc_jit_block_end_with_indirect_jump (b_fn1, NULL, addr_fn1, 1, null_dests); > + CHECK_STRING_VALUE ( > + gcc_jit_context_get_last_error (ctxt), > + "gcc_jit_block_end_with_indirect_jump:" > + " NULL destination block at index 0"); > + > + /* 5. Destination block in wrong function. */ > + gcc_jit_block *wrong_fn_dests[1] = { b_fn2 }; > + gcc_jit_block_end_with_indirect_jump (b_fn1, NULL, addr_fn1, 1, > + wrong_fn_dests); > + CHECK_STRING_VALUE ( > + gcc_jit_context_get_last_error (ctxt), > + "gcc_jit_block_end_with_indirect_jump:" > + " destination block 0 (b_fn2) is not in the same function" > + " (function fn2) as source block b_fn1"); > + > + /* Terminate b_fn1 cleanly so function validation doesn't overwrite > + last_error with an "unterminated block" error during compile. */ > + gcc_jit_block_end_with_void_return (b_fn1, NULL); > + > + /* 6. Cross-function block address (addr_fn1 used inside fn2). */ > + gcc_jit_block *fn2_dests[1] = { b_fn2 }; > + gcc_jit_block_end_with_indirect_jump (b_fn2, NULL, addr_fn1, 1, > + fn2_dests); > + > + CHECK_STRING_VALUE ( > + gcc_jit_context_get_last_error (ctxt), > + "gcc_jit_block_end_with_indirect_jump:" > + " rvalue &&b_fn1 (type: void *) has scope limited to function fn1" > + " but was used within function fn2" > + " (in statement: goto *&&b_fn1;)"); > +} > + > +void > +verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) > +{ > + CHECK_VALUE (result, NULL); > + > + CHECK_STRING_VALUE ( > + gcc_jit_context_get_first_error (ctxt), > + "gcc_jit_block_end_with_indirect_jump:" > + " target_address: (int)42 is not of a pointer type"); > + > + /* Verify that using a block address from fn1 inside fn2 was caught > + by verify_valid_within_stmt. */ > + CHECK_STRING_VALUE ( > + gcc_jit_context_get_last_error (ctxt), > + "gcc_jit_block_end_with_indirect_jump:" > + " rvalue &&b_fn1 (type: void *) has scope limited to function fn1" > + " but was used within function fn2" > + " (in statement: goto *&&b_fn1;)"); > +} > diff --git a/gcc/testsuite/jit.dg/test-indirect-jump.c > b/gcc/testsuite/jit.dg/test-indirect-jump.c > new file mode 100644 > index 000000000..f464a6edb > --- /dev/null > +++ b/gcc/testsuite/jit.dg/test-indirect-jump.c > @@ -0,0 +1,109 @@ > +#include > +#include > + > +#include "libgccjit.h" > +#include "harness.h" > + > +void > +create_code (gcc_jit_context *ctxt, void *user_data) > +{ > + /* Let's try to inject the equivalent of: > + int > + test_indirect_jump (int idx) > + { > + void *targets[3]; > + targets[0] = &&b_zero; > + targets[1] = &&b_one; > + targets[2] = &&b_two; > + goto *targets[idx]; > + > + b_zero: > + return 10; > + b_one: > + return 20; > + b_two: > + return 30; > + } > + */ > + gcc_jit_type *int_type = > + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); > + gcc_jit_type *void_ptr_type = > + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID_PTR); > + gcc_jit_type *array_type = > + gcc_jit_context_new_array_type (ctxt, NULL, void_ptr_type, 3); > + > + gcc_jit_param *param_idx = > + gcc_jit_context_new_param (ctxt, NULL, int_type, "idx"); > + gcc_jit_function *func = > + gcc_jit_context_new_function (ctxt, NULL, > + GCC_JIT_FUNCTION_EXPORTED, > + int_type, > + "test_indirect_jump", > + 1, ¶m_idx, > + 0); > + > + gcc_jit_block *b_entry = gcc_jit_function_new_block (func, "entry"); > + gcc_jit_block *b_zero = gcc_jit_function_new_block (func, "b_zero"); > + gcc_jit_block *b_one = gcc_jit_function_new_block (func, "b_one"); > + gcc_jit_block *b_two = gcc_jit_function_new_block (func, "b_two"); > + > + gcc_jit_lvalue *targets = > + gcc_jit_function_new_local (func, NULL, array_type, "targets"); > + > + gcc_jit_block *blocks[3] = { b_zero, b_one, b_two }; > + for (int i = 0; i < 3; i++) > + { > + gcc_jit_rvalue *idx_val = > + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, i); > + gcc_jit_lvalue *elem = > + gcc_jit_context_new_array_access (ctxt, NULL, > + gcc_jit_lvalue_as_rvalue (targets), > + idx_val); > + gcc_jit_rvalue *blk_addr = > + gcc_jit_block_get_address (blocks[i], NULL); > + gcc_jit_block_add_assignment (b_entry, NULL, elem, blk_addr); > + } > + > + /* void *target_addr = targets[idx]; */ > + gcc_jit_lvalue *selected_elem = > + gcc_jit_context_new_array_access (ctxt, NULL, > + gcc_jit_lvalue_as_rvalue (targets), > + gcc_jit_param_as_rvalue (param_idx)); > + > + /* goto *targets[idx]; */ > + gcc_jit_block_end_with_indirect_jump ( > + b_entry, NULL, > + gcc_jit_lvalue_as_rvalue (selected_elem), > + 3, blocks); > + > + /* b_zero: return 10; */ > + gcc_jit_block_end_with_return ( > + b_zero, NULL, > + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 10)); > + > + /* b_one: return 20; */ > + gcc_jit_block_end_with_return ( > + b_one, NULL, > + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 20)); > + > + /* b_two: return 30; */ > + gcc_jit_block_end_with_return ( > + b_two, NULL, > + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 30)); > +} > + > +void > +verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) > + > +{ > + typedef int (*fn_type) (int); > + CHECK_NON_NULL (result); > + > + fn_type test_indirect_jump = > + (fn_type)gcc_jit_result_get_code (result, "test_indirect_jump"); > + CHECK_NON_NULL (test_indirect_jump); > + > + CHECK_VALUE (test_indirect_jump (0), 10); > + CHECK_VALUE (test_indirect_jump (1), 20); > + CHECK_VALUE (test_indirect_jump (2), 30); > +} > -- > 2.56.0 > > On Sun, Oct 25, 2026 at 7:58?PM David Malcolm wrote: > > > > On Fri, 2026-10-23 at 13:34 -0400, Marcus Valette wrote: > > > From b55719183abf5ff37373115b5929ebd6ca914258 Mon Sep 17 00:00:00 > > > 2001 > > > From: Vincent Li > > > Date: Fri, 23 Oct 2026 13:23:48 -0400 > > > Subject: [PATCH] jit: Add support for computed gotos and block > > > addresses > > > > > > This patch adds `gcc_jit_block_get_address` and > > > `gcc_jit_block_end_with_indirect_jump` > > > under ABI version LIBGCCJIT_ABI_39. This exposes GNU C > > > labels-as-values (`&&label`) > > > and indirect jumps (`goto *expr;`) in libgccjit, enabling JIT- > > > compiled > > > interpreter > > > dispatch loops and state machines to implement direct-threaded code > > > tables. > > > > > > Tested on x86_64-pc-linux-gnu. All 30 iterations of jit.dg/test- > > > indirect-jump.c > > > passed across -O0 to -O3. check_GNU_style.py reports 0 errors. > > > > > > gcc/jit/ChangeLog: > > > > > > * docs/topics/expressions.rst (gcc_jit_block_get_address): > > > Document. > > > * docs/topics/functions.rst > > > (gcc_jit_block_end_with_indirect_jump): Document. > > > * jit-playback.cc (playback::block::get_address): New method. > > > (playback::block::add_indirect_jump): New method. > > > * jit-playback.h (playback::block::get_address): New method. > > > (playback::block::add_indirect_jump): New method. > > > * jit-recording.cc (recording::block::get_address): New method. > > > (recording::block::end_with_indirect_jump): New method. > > > (recording::get_block_address::replay_into): New method. > > > (recording::get_block_address::make_debug_string): New method. > > > (recording::get_block_address::write_reproducer): New method. > > > (recording::indirect_jump::replay_into): New method. > > > (recording::indirect_jump::get_successor_blocks): New method. > > > (recording::indirect_jump::make_debug_string): New method. > > > (recording::indirect_jump::write_reproducer): New method. > > > * jit-recording.h (class get_block_address): New class. > > > (class indirect_jump): New class. > > > (recording::block::get_address): New method. > > > (recording::block::end_with_indirect_jump): New method. > > > * libgccjit.cc (gcc_jit_block_get_address): New entrypoint. > > > (gcc_jit_block_end_with_indirect_jump): New entrypoint. > > > * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_block_get_address): New > > > macro. > > > (LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump): New macro. > > > (gcc_jit_block_get_address): New declaration. > > > (gcc_jit_block_end_with_indirect_jump): New declaration. > > > * libgccjit.map (LIBGCCJIT_ABI_39): Add gcc_jit_block_get_address > > > and > > > gcc_jit_block_end_with_indirect_jump. > > > > > > gcc/testsuite/ChangeLog: > > > > > > * jit.dg/all-non-failing-tests.h: Include test-indirect-jump.c. > > > * jit.dg/test-indirect-jump.c: New test. > > > > > > Signed-off-by: Vincent Li > > > > > > Thanks for the patch. Overall it looks promising, but there are some > > minor issues. > > > > The From: header reads "Marcus Valette" while the patch author and > > Signed-off-by: both read "Vincent Li", albeit at the same gmail > > address. Who wrote this patch? (the DCO sign-off is standing in for > > copyright assignment here). > > > > I looked on https://gcc.sashiko.dev/ and for some reason I'm not seeing > > this patch there (perhaps because it was To: jit@gcc.gnu.org and only > > CC: gcc-patches@gcc.gnu.org ?) Given that, I had Claude code take a > > look at it; please forgive me for taking the liberty of pasting what it > > said verbatim, since its feedback seems correct to me: > > > > (begin quote): > > > > Verdict: good direction, needs a v2. The design follows the existing > > end_with_extended_asm_goto precedent closely, it applies cleanly to > > master, builds warning-free, and the new test passes including the > > reproducer round-trip. But there are two real defects ? one of which is > > an ICE ? plus a documentation claim that is factually wrong. > > > > Verification performed > > > > Applied to master @ 9f6f255b68b, built libgccjit.so, ran jit.exp=test- > > indirect-jump.c: 35 passes, 0 failures. The jit harness auto-generates > > and recompiles a reproducer per test, so write_reproducer is covered. > > ABI 39 is the correct next number ? LIBGCCJIT_ABI_38 is the current tip > > in both libgccjit.map and compatibility.rst. > > > > I did not run test-combination.c / test-threads.c, which pick up the > > new test via all-non-failing-tests.h. Those should be run before > > commit. > > > > Blockers > > > > 1. ICE instead of a clean error: missing verify_valid_within_stmt > > > > gcc_jit_block_end_with_indirect_jump never calls target_address- > > >verify_valid_within_stmt (__func__, stmt). Every other statement > > entrypoint does ? libgccjit.cc:3038, 3082-3083, 3139-3140, 3208, 3297. > > > > Passing a target_address scoped to a different function gives: > > > > internal compiler error: in expand_expr_real_1, at expr.cc:11811 > > > > The identical misuse via gcc_jit_block_end_with_return is diagnosed > > properly: > > > > gcc_jit_block_end_with_return: rvalue g1loc (type: int) has scope > > limited to function g1 but was used within function g2 (in statement: > > return g1loc;) > > > > Fix: capture the statement returned by end_with_indirect_jump and call > > verify_valid_within_stmt on it, as the neighbouring entrypoints do. > > > > 2. Cross-function block addresses silently accepted > > > > recording::get_block_address never calls set_scope (b->get_function > > ()), so m_scope stays NULL and the rvalue is treated as a global. > > Taking &&a_lbl in func_a and jumping to it from func_b produces no > > diagnostic at all. Confirmed via DUMP_INITIAL_GIMPLE: > > > > int func_b () > > { > > b_entry: > > tmp = &a_lbl; /* a_lbl lives in func_a */ > > goto tmp; > > ... > > } > > > > GNU C explicitly forbids jumping to a label in a different function. > > Calling set_scope in the constructor ? the same mechanism locals and > > params use ? turns this into a clean API error. > > > > 3. The documented rationale for destinations is wrong > > > > Both libgccjit.h and functions.rst say the array is needed "to allow > > GCC's middle-end to construct valid CFG edges." It isn't. Edges come > > from FORCED_LABEL, which gimplify.cc:20972 sets when the address is > > taken and tree-cfg.cc:1046 wires into abnormal edges for every computed > > goto. > > > > I tested a deliberately incomplete destinations list (two labels in the > > jump table, only one listed) at -O3: both targets still dispatch > > correctly, no diagnostic, correct results. > > > > The parameter is load-bearing ? recording::function::validate walks > > get_successor_blocks for its reachability check, and without it > > legitimate targets get flagged "unreachable block". That is the honest > > justification and what the docs should say. As written, users are told > > the array is a safety requirement when under-listing is silently > > harmless and over-listing just force-marks extra labels. > > > > Should-fix > > > > - compatibility.rst has no LIBGCCJIT_ABI_39 section. Required for > > every ABI bump; also needed so the docs can use > > :ref:LIBGCCJIT_ABI_39instead of the plain ```LIBGCCJIT_ABI_39`` ``` > > literal the patch uses. The surrounding entries in expressions.rst use > > the :ref: form. > > - gcc_jit_block_get_address is documented in the wrong section. It > > lands at expressions.rst:806, inside Lvalues (which starts at > > line 778), between gcc_jit_lvalue_get_address and > > gcc_jit_lvalue_set_tls_model. It is neither an lvalue operation nor an > > lvalue method ? it belongs with the block APIs in functions.rst, next > > to the new end_with_indirect_jump. > > - No error-path tests. The new entrypoints add five validation checks > > and none are covered. jit.dg/test-error-*.c is the convention. > > - Three unrelated hunks. Trailing-whitespace removal at jit- > > recording.h:966, and a comment-terminator plus re-indent of > > gcc_jit_lvalue_set_tls_model in libgccjit.h. Drop them or split into a > > separate cleanup patch ? neither is in the ChangeLog. > > - all-non-failing-tests.h ordering. Both the #include block and the > > testcases[] entry are alphabetically sorted; the patch puts the include > > after test-switch.c and the array entry at the very end, rather than > > among the i entries. > > > > Minor > > > > - write_reproducer embeds literal tabs in the strings it emits, so > > generated reproducer files get tab-indented continuation lines. > > extended_asm_goto::write_reproducer uses spaces ? match it. > > - indirect_jump::make_debug_string uses get_debug_string () rather > > than get_debug_string_parens (PRECEDENCE_UNARY), so goto *a + b; will > > render ambiguously. > > - playback::block::add_indirect_jump omits the convert > > (ptr_type_node, expr) that c_finish_goto_ptr performs. Not a > > correctness bug today ? verify_gimple_goto accepts any POINTER_TYPE_P ? > > but normalizing is cheaper than reasoning about named address spaces > > later. > > - The FORCED_LABEL assignment in get_address is redundant with > > gimplify.cc:20972. Harmless; worth a comment if kept. > > - RETURN_IF_FAIL (num_destinations > 0, ...) with message > > "num_destinations <= 0". end_with_extended_asm_goto permits >= 0; and > > the message should describe the problem, not restate the predicate. > > > > (end quote from AI) > > > > Hope this is constructive; thanks again for the patch > > Dave > > > > > > > > > > > > > > > --- > > > gcc/jit/docs/topics/expressions.rst | 14 ++ > > > gcc/jit/docs/topics/functions.rst | 21 +++ > > > gcc/jit/jit-playback.cc | 39 +++++ > > > gcc/jit/jit-playback.h | 7 + > > > gcc/jit/jit-recording.cc | 157 > > > +++++++++++++++++++ > > > gcc/jit/jit-recording.h | 57 ++++++- > > > gcc/jit/libgccjit.cc | 63 ++++++++ > > > gcc/jit/libgccjit.h | 39 ++++- > > > gcc/jit/libgccjit.map | 6 + > > > gcc/testsuite/jit.dg/all-non-failing-tests.h | 10 ++ > > > gcc/testsuite/jit.dg/test-indirect-jump.c | 108 +++++++++++++ > > > 11 files changed, 518 insertions(+), 3 deletions(-) > > > create mode 100644 gcc/testsuite/jit.dg/test-indirect-jump.c > > > > > > diff --git a/gcc/jit/docs/topics/expressions.rst > > > b/gcc/jit/docs/topics/expressions.rst > > > index 680ea1d86..0f9f705fe 100644 > > > --- a/gcc/jit/docs/topics/expressions.rst > > > +++ b/gcc/jit/docs/topics/expressions.rst > > > @@ -806,6 +806,20 @@ where the rvalue is computed by reading from the > > > storage area. > > > > > > in C. > > > > > > +.. function:: gcc_jit_rvalue * \ > > > + gcc_jit_block_get_address (gcc_jit_block *block, \ > > > + gcc_jit_location *loc) > > > + > > > + Get the address of a basic block as an rvalue of type ``void *``, > > > + analogous to GNU C's ``&&label``. > > > + > > > + This API entrypoint was added in ``LIBGCCJIT_ABI_39``; you can > > > test for its > > > + presence using: > > > + > > > + .. code-block:: c > > > + > > > + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_get_address > > > + > > > .. function:: void\ > > > gcc_jit_lvalue_set_tls_model (gcc_jit_lvalue *lvalue,\ > > > enum gcc_jit_tls_model > > > model) > > > diff --git a/gcc/jit/docs/topics/functions.rst > > > b/gcc/jit/docs/topics/functions.rst > > > index 66d4b6b2f..1f2eefb1c 100644 > > > --- a/gcc/jit/docs/topics/functions.rst > > > +++ b/gcc/jit/docs/topics/functions.rst > > > @@ -466,6 +466,27 @@ Statements > > > > > > goto target; > > > > > > +.. function:: void\ > > > + gcc_jit_block_end_with_indirect_jump (\ > > > + gcc_jit_block *block,\ > > > + gcc_jit_location *loc,\ > > > + gcc_jit_rvalue *target_address,\ > > > + int num_destinations,\ > > > + gcc_jit_block **destinations) > > > + > > > + Terminate a basic block by adding an indirect jump to > > > ``target_address``, > > > + analogous to GNU C's ``goto *target_address;``. > > > + > > > + All possible destination blocks must be listed in the > > > ``destinations`` > > > + array to allow GCC's middle-end to construct valid CFG edges. > > > + > > > + This API entrypoint was added in ``LIBGCCJIT_ABI_39``; you can > > > test for its > > > + presence using: > > > + > > > + .. code-block:: c > > > + > > > + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump > > > + > > > .. function:: void\ > > > gcc_jit_block_end_with_return (gcc_jit_block *block,\ > > > gcc_jit_location *loc,\ > > > diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc > > > index 56c9413f8..66a1e8fef 100644 > > > --- a/gcc/jit/jit-playback.cc > > > +++ b/gcc/jit/jit-playback.cc > > > @@ -2547,6 +2547,45 @@ c_finish_goto_label (location_t loc, tree > > > label) > > > > > > } > > > > > > +/* Take the address of a block as a void * rvalue (&&block). */ > > > + > > > +playback::rvalue * > > > +playback::block:: > > > +get_address (location *loc) > > > +{ > > > + tree label = as_label_decl (); > > > + TREE_USED (label) = 1; > > > + FORCED_LABEL (label) = 1; > > > + > > > + tree addr = build1 (ADDR_EXPR, ptr_type_node, label); > > > + if (loc) > > > + set_tree_location (addr, loc); > > > + > > > + return new rvalue (m_func->m_ctxt, addr); > > > +} > > > + > > > +/* Add an indirect jump statement (goto *target_address;). */ > > > + > > > +void > > > +playback::block::add_indirect_jump (location *loc, > > > + rvalue *target_address, > > > + auto_vec *destinations) > > > +{ > > > + unsigned i; > > > + block *dest; > > > + FOR_EACH_VEC_ELT (*destinations, i, dest) > > > + { > > > + tree label = dest->as_label_decl (); > > > + TREE_USED (label) = 1; > > > + FORCED_LABEL (label) = 1; > > > + } > > > + > > > + tree stmt = build1 (GOTO_EXPR, void_type_node, target_address- > > > >as_tree ()); > > > + if (loc) > > > + set_tree_location (stmt, loc); > > > + add_stmt (stmt); > > > +} > > > + > > > /* Add a return statement to the function's statement list. */ > > > > > > void > > > diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h > > > index ad3e41f3d..d32ed4d49 100644 > > > --- a/gcc/jit/jit-playback.h > > > +++ b/gcc/jit/jit-playback.h > > > @@ -692,6 +692,13 @@ public: > > > add_jump (location *loc, > > > block *target); > > > > > > + rvalue *get_address (location *loc); > > > + > > > + void > > > + add_indirect_jump (location *loc, > > > + rvalue *target_address, > > > + auto_vec *destinations); > > > + > > > void > > > add_return (location *loc, > > > rvalue *rvalue); > > > diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc > > > index e28e5f67c..47983e06c 100644 > > > --- a/gcc/jit/jit-recording.cc > > > +++ b/gcc/jit/jit-recording.cc > > > @@ -5072,6 +5072,26 @@ recording::block::end_with_jump > > > (recording::location *loc, > > > return result; > > > } > > > > > > +/* Create a recording::end_with_indirect_jump instance and add > > > + it to the block's context's list of mementos, and to the > > > + block's list of statements. > > > + > > > + Implements the heart of gcc_jit_block_end_with_indirect_jump. */ > > > + > > > +recording::statement * > > > +recording::block::end_with_indirect_jump (location *loc, > > > + rvalue *target_address, > > > + int num_destinations, > > > + block **destinations) > > > +{ > > > + statement *result = new indirect_jump (this, loc, target_address, > > > + num_destinations, destinations); > > > + m_ctxt->record (result); > > > + m_statements.safe_push (result); > > > + m_has_been_terminated = true; > > > + return result; > > > +} > > > + > > > /* Create a recording::end_with_return instance and add it to > > > the block's context's list of mementos, and to the block's > > > list of statements. > > > @@ -5197,6 +5217,20 @@ recording::block::get_loc () const > > > return NULL; > > > } > > > > > > +/* Create a recording::get_address instance and add it to > > > + the block's context's list of mementos, and to the block's > > > + list of statements. > > > + > > > + Implements the heart of gcc_jit_block_get_address. */ > > > + > > > +recording::rvalue * > > > +recording::block::get_address (location *loc) > > > +{ > > > + recording::rvalue *result = new get_block_address (m_ctxt, loc, > > > this); > > > + m_ctxt->record (result); > > > + return result; > > > +} > > > + > > > /* Get the first statement within a block, if any. */ > > > > > > recording::statement * > > > @@ -7332,6 +7366,45 @@ > > > recording::get_address_of_lvalue::write_reproducer (reproducer &r) > > > r.get_identifier (m_loc)); > > > } > > > > > > +/* The implementation of class > > > gcc::jit::recording::get_block_address. */ > > > + > > > +/* Implementation of pure virtual hook > > > recording::memento::replay_into > > > + for recording::get_block_address. */ > > > + > > > +void > > > +recording::get_block_address::replay_into (replayer *r) > > > +{ > > > + set_playback_obj ( > > > + m_block->playback_block ()-> > > > + get_address (playback_location (r, m_loc))); > > > +} > > > + > > > +/* Implementation of recording::memento::make_debug_string for > > > + getting the address of a block. */ > > > + > > > +recording::string * > > > +recording::get_block_address::make_debug_string () > > > +{ > > > + return string::from_printf (m_ctxt, > > > + "&&%s", > > > + m_block->get_debug_string ()); > > > +} > > > + > > > +/* Implementation of recording::memento::write_reproducer for > > > + get_block_address. */ > > > + > > > +void > > > +recording::get_block_address::write_reproducer (reproducer &r) > > > +{ > > > + const char *id = r.make_identifier (this, "address_of"); > > > + r.write (" gcc_jit_rvalue *%s =\n" > > > + " gcc_jit_block_get_address (%s,\n" > > > + " %s);\n", > > > + id, > > > + r.get_identifier (m_block), > > > + r.get_identifier (m_loc)); > > > +} > > > + > > > /* The implementation of class > > > gcc::jit::recording::function_pointer. */ > > > > > > /* Implementation of pure virtual hook > > > recording::memento::replay_into > > > @@ -7765,6 +7838,90 @@ recording::jump::write_reproducer (reproducer > > > &r) > > > r.get_identifier (m_target)); > > > } > > > > > > +/* The implementation of class gcc::jit::recording::indirect_jump. > > > */ > > > + > > > +/* gcc::jit::recording::indirect_jump's constructor. */ > > > + > > > +recording::indirect_jump::indirect_jump (block *b, > > > + location *loc, > > > + rvalue *target_address, > > > + int num_destinations, > > > + block **destinations) > > > +: statement (b, loc), > > > + m_target_address (target_address) > > > +{ > > > + m_destinations.reserve_exact (num_destinations); > > > + for (int i = 0; i < num_destinations; i++) > > > + m_destinations.quick_push (destinations[i]); > > > +} > > > + > > > +/* Implementation of pure virtual hook > > > recording::memento::replay_into > > > + for recording::indirect_jump. */ > > > + > > > +void > > > +recording::indirect_jump::replay_into (replayer *r) > > > +{ > > > + auto_vec pb_dests; > > > + pb_dests.reserve_exact (m_destinations.length ()); > > > + for (unsigned i = 0; i < m_destinations.length (); i++) > > > + pb_dests.quick_push (m_destinations[i]->playback_block ()); > > > + > > > + playback_block (get_block ()) > > > + ->add_indirect_jump (playback_location (r), > > > + m_target_address->playback_rvalue (), > > > + &pb_dests); > > > +} > > > + > > > +/* Override the poisoned default implementation of > > > + gcc::jit::recording::statement::get_successor_blocks. */ > > > + > > > +vec > > > +recording::indirect_jump::get_successor_blocks () const > > > +{ > > > + vec result; > > > + result.create (m_destinations.length ()); > > > + for (unsigned i = 0; i < m_destinations.length (); i++) > > > + result.quick_push (m_destinations[i]); > > > + return result; > > > +} > > > + > > > +/* Implementation of recording::memento::make_debug_string for > > > + an indirect jump statement. */ > > > + > > > +recording::string * > > > +recording::indirect_jump::make_debug_string () > > > +{ > > > + return string::from_printf (m_ctxt, > > > + "goto *%s;", > > > + m_target_address->get_debug_string ()); > > > +} > > > + > > > +/* Implementation of recording::memento::write_reproducer for > > > + indirect_jump statements. */ > > > + > > > +void > > > +recording::indirect_jump::write_reproducer (reproducer &r) > > > +{ > > > + r.make_identifier (this, "indirect_jump"); > > > + const char *dests_id = r.make_tmp_identifier ("destinations_for", > > > this); > > > + r.write (" gcc_jit_block *%s[%i] = {\n", > > > + dests_id, > > > + m_destinations.length ()); > > > + for (unsigned i = 0; i < m_destinations.length (); i++) > > > + r.write (" %s,\n", r.get_identifier (m_destinations[i])); > > > + r.write (" };\n"); > > > + r.write (" gcc_jit_block_end_with_indirect_jump (%s,\n" > > > + " %s,\n" > > > + " %s,\n" > > > + " %i,\n" > > > + " %s);\n", > > > + r.get_identifier (get_block ()), > > > + r.get_identifier (get_loc ()), > > > + r.get_identifier_as_rvalue (m_target_address), > > > + m_destinations.length (), > > > + dests_id); > > > +} > > > + > > > /* The implementation of class gcc::jit::recording::return_. */ > > > > > > /* Implementation of pure virtual hook > > > recording::memento::replay_into > > > diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h > > > index 2a5f23a05..c500ea659 100644 > > > --- a/gcc/jit/jit-recording.h > > > +++ b/gcc/jit/jit-recording.h > > > @@ -966,7 +966,7 @@ public: > > > type *unqualified () final override { return m_other_type; } > > > > > > void replay_into (replayer *) final override; > > > - memento_of_get_aligned *dyn_cast_aligned_type () final override > > > + memento_of_get_aligned *dyn_cast_aligned_type () final override > > > { > > > return this; > > > } > > > @@ -1682,6 +1682,13 @@ public: > > > end_with_jump (location *loc, > > > block *target); > > > > > > + rvalue * get_address (location *loc); > > > + > > > + statement * end_with_indirect_jump (location *loc, > > > + rvalue *target_address, > > > + int num_destinations, > > > + block **destinations); > > > + > > > statement * > > > end_with_return (location *loc, > > > rvalue *rvalue); > > > @@ -2427,6 +2434,32 @@ private: > > > lvalue *m_lvalue; > > > }; > > > > > > +class get_block_address : public rvalue > > > +{ > > > +public: > > > + get_block_address (context *ctxt, > > > + location *loc, > > > + block *b) > > > + : rvalue (ctxt, loc, ctxt->get_type (GCC_JIT_TYPE_VOID_PTR)), > > > + m_block (b) > > > + {} > > > + > > > + void replay_into (replayer *r) final override; > > > + > > > + void visit_children (rvalue_visitor *) final override {} > > > + > > > +private: > > > + string * make_debug_string () final override; > > > + void write_reproducer (reproducer &r) final override; > > > + enum precedence get_precedence () const final override > > > + { > > > + return PRECEDENCE_UNARY; > > > + } > > > + > > > +private: > > > + block *m_block; > > > +}; > > > + > > > class function_pointer : public rvalue > > > { > > > public: > > > @@ -2650,6 +2683,28 @@ private: > > > block *m_target; > > > }; > > > > > > +class indirect_jump : public statement > > > +{ > > > +public: > > > + indirect_jump (block *b, > > > + location *loc, > > > + rvalue *target_address, > > > + int num_destinations, > > > + block **destinations); > > > + > > > + void replay_into (replayer *r) final override; > > > + > > > + vec get_successor_blocks () const final override; > > > + > > > +private: > > > + string * make_debug_string () final override; > > > + void write_reproducer (reproducer &r) final override; > > > + > > > +private: > > > + rvalue *m_target_address; > > > + auto_vec m_destinations; > > > +}; > > > + > > > class return_ : public statement > > > { > > > public: > > > diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc > > > index 5a874fc48..4fac8c56b 100644 > > > --- a/gcc/jit/libgccjit.cc > > > +++ b/gcc/jit/libgccjit.cc > > > @@ -2874,6 +2874,23 @@ gcc_jit_lvalue_get_address (gcc_jit_lvalue > > > *lvalue, > > > return (gcc_jit_rvalue *)lvalue->get_address (loc); > > > } > > > > > > +/* Public entrypoint. See description in libgccjit.h. > > > + > > > + After error-checking, the real work is done by the > > > + gcc::jit::recording::block::get_address method in > > > + jit-recording.cc. */ > > > + > > > +gcc_jit_rvalue * > > > +gcc_jit_block_get_address (gcc_jit_block *block, > > > + gcc_jit_location *loc) > > > +{ > > > + RETURN_NULL_IF_FAIL (block, NULL, loc, "NULL block"); > > > + JIT_LOG_FUNC (block->get_context ()->get_logger ()); > > > + /* LOC can be NULL. */ > > > + > > > + return (gcc_jit_rvalue *)block->get_address (loc); > > > +} > > > + > > > /* Public entrypoint. See description in libgccjit.h. > > > > > > After error-checking, the real work is done by the > > > @@ -3258,6 +3275,52 @@ gcc_jit_block_end_with_jump (gcc_jit_block > > > *block, > > > block->end_with_jump (loc, target); > > > } > > > > > > +/* Public entrypoint. See description in libgccjit.h. > > > + > > > + After error-checking, the real work is done by the > > > + gcc::jit::recording::block::end_with_indirect_jump method in > > > + jit-recording.cc. */ > > > + > > > +void > > > +gcc_jit_block_end_with_indirect_jump (gcc_jit_block *block, > > > + gcc_jit_location *loc, > > > + gcc_jit_rvalue *target_address, > > > + int num_destinations, > > > + gcc_jit_block **destinations) > > > +{ > > > + RETURN_IF_NOT_VALID_BLOCK (block, loc); > > > + gcc::jit::recording::context *ctxt = block->get_context (); > > > + JIT_LOG_FUNC (ctxt->get_logger ()); > > > + /* LOC can be NULL. */ > > > + RETURN_IF_FAIL (target_address, ctxt, loc, "NULL target_address"); > > > + RETURN_IF_FAIL_PRINTF1 ( > > > + target_address->get_type ()->is_pointer (), > > > + ctxt, loc, > > > + "target_address: %s is not of a pointer type", > > > + target_address->get_debug_string ()); > > > + RETURN_IF_FAIL (num_destinations > 0, ctxt, loc, "num_destinations > > > <= 0"); > > > + RETURN_IF_FAIL (destinations, ctxt, loc, "NULL destinations"); > > > + > > > + for (int i = 0; i < num_destinations; i++) > > > + { > > > + RETURN_IF_FAIL_PRINTF1 (destinations[i], ctxt, loc, > > > + "NULL destination block at index %d", i); > > > + RETURN_IF_FAIL_PRINTF4 ( > > > + block->get_function () == destinations[i]->get_function (), > > > + ctxt, loc, > > > + "destination block %d (%s) is not in the same function" > > > + " (function %s) as source block %s", > > > + i, > > > + destinations[i]->get_debug_string (), > > > + destinations[i]->get_function ()->get_debug_string (), > > > + block->get_debug_string ()); > > > + } > > > + > > > + block->end_with_indirect_jump (loc, target_address, > > > + num_destinations, > > > + (gcc::jit::recording::block **)destinations); > > > +} > > > + > > > /* Public entrypoint. See description in libgccjit.h. > > > > > > After error-checking, the real work is done by the > > > diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h > > > index 2247c99de..9d00ba33a 100644 > > > --- a/gcc/jit/libgccjit.h > > > +++ b/gcc/jit/libgccjit.h > > > @@ -1455,16 +1455,31 @@ extern gcc_jit_rvalue * > > > gcc_jit_lvalue_get_address (gcc_jit_lvalue *lvalue, > > > gcc_jit_location *loc); > > > > > > +#define LIBGCCJIT_HAVE_gcc_jit_block_get_address > > > + > > > +/* Taking the address of a block; analogous to: > > > + &&block > > > + in C. > > > + > > > + This API entrypoint was added in LIBGCCJIT_ABI_39; you can test > > > for its > > > + presence using > > > + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_get_address > > > +*/ > > > +extern gcc_jit_rvalue * > > > +gcc_jit_block_get_address (gcc_jit_block *block, > > > + gcc_jit_location *loc); > > > + > > > #define LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model > > > > > > /* Set the thread-local storage model of a global variable > > > > > > This API entrypoint was added in LIBGCCJIT_ABI_17; you can test > > > for its > > > presence using > > > - #ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model */ > > > + #ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model > > > +*/ > > > extern void > > > gcc_jit_lvalue_set_tls_model (gcc_jit_lvalue *lvalue, > > > - enum gcc_jit_tls_model model); > > > + enum gcc_jit_tls_model model); > > > > > > #define LIBGCCJIT_HAVE_gcc_jit_lvalue_set_link_section > > > > > > @@ -1592,6 +1607,26 @@ gcc_jit_block_end_with_jump (gcc_jit_block > > > *block, > > > gcc_jit_location *loc, > > > gcc_jit_block *target); > > > > > > +#define LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump > > > + > > > +/* Terminate a block by adding an indirect jump to target_address. > > > + > > > + All possible indirect jump targets must be constrained to a fixed > > > array. > > > + > > > + This is roughly equivalent to this C code: > > > + > > > + goto *target_address; > > > + > > > + This API entrypoint was added in LIBGCCJIT_ABI_39; you can test > > > for its > > > + presence using > > > + #ifdef LIBGCCJIT_HAVE_gcc_jit_block_end_with_indirect_jump. > > > */ > > > +extern void > > > +gcc_jit_block_end_with_indirect_jump (gcc_jit_block *block, > > > + gcc_jit_location *loc, > > > + gcc_jit_rvalue *target_address, > > > + int num_destinations, > > > + gcc_jit_block **destinations); > > > + > > > /* Terminate a block by adding evaluation of an rvalue, returning > > > the value. > > > > > > This is roughly equivalent to this C code: > > > diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map > > > index 78b6be9ff..9412700a2 100644 > > > --- a/gcc/jit/libgccjit.map > > > +++ b/gcc/jit/libgccjit.map > > > @@ -349,3 +349,9 @@ LIBGCCJIT_ABI_38 { > > > global: > > > gcc_jit_type_is_floating_point; > > > } LIBGCCJIT_ABI_37; > > > + > > > +LIBGCCJIT_ABI_39 { > > > + global: > > > + gcc_jit_block_get_address; > > > + gcc_jit_block_end_with_indirect_jump; > > > +} LIBGCCJIT_ABI_38; > > > diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h > > > b/gcc/testsuite/jit.dg/all-non-failing-tests.h > > > index e8f8463e8..5bf18a874 100644 > > > --- a/gcc/testsuite/jit.dg/all-non-failing-tests.h > > > +++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h > > > @@ -448,6 +448,13 @@ > > > #undef create_code > > > #undef verify_code > > > > > > +/* test-indirect-jump.c */ > > > +#define create_code create_code_indirect_jump > > > +#define verify_code verify_code_indirect_jump > > > +#include "test-indirect-jump.c" > > > +#undef create_code > > > +#undef verify_code > > > + > > > /* test-target-info.c: This can't be in the testcases array as it > > > is target-specific. */ > > > > > > @@ -688,6 +695,9 @@ const struct testcase testcases[] = { > > > {"vector_perm", > > > create_code_vector_perm, > > > verify_code_vector_perm}, > > > + {"indirect_jump", > > > + create_code_indirect_jump, > > > + verify_code_indirect_jump}, > > > }; > > > > > > const int num_testcases = (sizeof (testcases) / sizeof > > > (testcases[0])); > > > diff --git a/gcc/testsuite/jit.dg/test-indirect-jump.c > > > b/gcc/testsuite/jit.dg/test-indirect-jump.c > > > new file mode 100644 > > > index 000000000..3d407f7ea > > > --- /dev/null > > > +++ b/gcc/testsuite/jit.dg/test-indirect-jump.c > > > @@ -0,0 +1,108 @@ > > > +#include > > > +#include > > > + > > > +#include "libgccjit.h" > > > +#include "harness.h" > > > + > > > +void > > > +create_code (gcc_jit_context *ctxt, void *user_data) > > > +{ > > > + /* Let's try to inject the equivalent of: > > > + int > > > + test_indirect_jump (int idx) > > > + { > > > + void *targets[3]; > > > + targets[0] = &&b_zero; > > > + targets[1] = &&b_one; > > > + targets[2] = &&b_two; > > > + goto *targets[idx]; > > > + > > > + b_zero: > > > + return 10; > > > + b_one: > > > + return 20; > > > + b_two: > > > + return 30; > > > + } > > > + */ > > > + gcc_jit_type *int_type = > > > + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); > > > + gcc_jit_type *void_ptr_type = > > > + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID_PTR); > > > + gcc_jit_type *array_type = > > > + gcc_jit_context_new_array_type (ctxt, NULL, void_ptr_type, 3); > > > + > > > + gcc_jit_param *param_idx = > > > + gcc_jit_context_new_param (ctxt, NULL, int_type, "idx"); > > > + gcc_jit_function *func = > > > + gcc_jit_context_new_function (ctxt, NULL, > > > + GCC_JIT_FUNCTION_EXPORTED, > > > + int_type, > > > + "test_indirect_jump", > > > + 1, ¶m_idx, > > > + 0); > > > + > > > + gcc_jit_block *b_entry = gcc_jit_function_new_block (func, > > > "entry"); > > > + gcc_jit_block *b_zero = gcc_jit_function_new_block (func, > > > "b_zero"); > > > + gcc_jit_block *b_one = gcc_jit_function_new_block (func, "b_one"); > > > + gcc_jit_block *b_two = gcc_jit_function_new_block (func, "b_two"); > > > + > > > + gcc_jit_lvalue *targets = > > > + gcc_jit_function_new_local (func, NULL, array_type, "targets"); > > > + > > > + gcc_jit_block *blocks[3] = { b_zero, b_one, b_two }; > > > + for (int i = 0; i < 3; i++) > > > + { > > > + gcc_jit_rvalue *idx_val = > > > + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, i); > > > + gcc_jit_lvalue *elem = > > > + gcc_jit_context_new_array_access (ctxt, NULL, > > > + gcc_jit_lvalue_as_rvalue (targets), > > > + idx_val); > > > + gcc_jit_rvalue *blk_addr = > > > + gcc_jit_block_get_address (blocks[i], NULL); > > > + gcc_jit_block_add_assignment (b_entry, NULL, elem, blk_addr); > > > + } > > > + > > > + /* void *target_addr = targets[idx]; */ > > > + gcc_jit_lvalue *selected_elem = > > > + gcc_jit_context_new_array_access (ctxt, NULL, > > > + gcc_jit_lvalue_as_rvalue (targets), > > > + gcc_jit_param_as_rvalue (param_idx)); > > > + > > > + /* goto *targets[idx]; */ > > > + gcc_jit_block_end_with_indirect_jump ( > > > + b_entry, NULL, > > > + gcc_jit_lvalue_as_rvalue (selected_elem), > > > + 3, blocks); > > > + > > > + /* b_zero: return 10; */ > > > + gcc_jit_block_end_with_return ( > > > + b_zero, NULL, > > > + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 10)); > > > + > > > + /* b_one: return 20; */ > > > + gcc_jit_block_end_with_return ( > > > + b_one, NULL, > > > + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 20)); > > > + > > > + /* b_two: return 30; */ > > > + gcc_jit_block_end_with_return ( > > > + b_two, NULL, > > > + gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 30)); > > > +} > > > + > > > +void > > > +verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) > > > +{ > > > + typedef int (*fn_type) (int); > > > + CHECK_NON_NULL (result); > > > + > > > + fn_type test_indirect_jump = > > > + (fn_type)gcc_jit_result_get_code (result, "test_indirect_jump"); > > > + CHECK_NON_NULL (test_indirect_jump); > > > + > > > + CHECK_VALUE (test_indirect_jump (0), 10); > > > + CHECK_VALUE (test_indirect_jump (1), 20); > > > + CHECK_VALUE (test_indirect_jump (2), 30); > > > +} > > -------------- next part -------------- A non-text attachment was scrubbed... Name: v2-0001-PATCH-jit-Add-support-for-computed-gotos-and-bloc.patch Type: text/x-patch Size: 29981 bytes Desc: not available URL: From morin-mikael@orange.fr Sun Nov 1 21:30:26 2026 From: morin-mikael@orange.fr (Mikael Morin) Date: Sun, 1 Nov 2026 22:30:26 +0100 Subject: [PATCH 2/2] libgfortran: [PR127751] caf_shmem: report a full table of coarray ids In-Reply-To: References: Message-ID: <3df6db1c-598e-47d4-953a-46cbb6cfdace@orange.fr> Le 30/10/2026 ? 14:00, Jerry DeLisle a ?crit?: > See the attached patch. This is the second of the two patches making > things a bit mor reliable. > > Regression tested on x86_64. > > OK for mainline? OK. > > Regards, > > Jerry > > --- > > libgfortran: [PR127751] caf_shmem: report a full table of coarray ids > > When ALLOCATE of a coarray needed a larger table of coarray ids and the > shared memory pool could not hold it, the image error terminated while > holding the allocator lock, so the other images hung.? The table is now > left unchanged and the failure is reported through STAT= and ERRMSG=. > Old tables were also freed with their number of entries instead of their > size in bytes. > > A failed ALLOCATE of a component of a coarray freed the token of the > component, so retrying the ALLOCATE freed it twice.? The token is now kept. > > Assisted-by: Claude Opus 5.5 > > ????PR libfortran/127751 > > libgfortran/ChangeLog: > > ????* caf/shmem.c (_gfortran_caf_register): Keep the token of a > ????component when its allocation fails. > ????* caf/shmem/alloc.c (get_memory_by_id_internal): Free the memory and > ????return NULL when the id cannot be entered into the hashmap. > ????* caf/shmem/hashmap.c (enlarge_hashmap_mem): Return false, leaving > ????the hashmap unchanged, when the shared memory is exhausted.? Free the > ????old table with its size in bytes. > ????(resize_hm): Return false and restore the old table on failure. > ????Free the old table with its size in bytes. > ????(hashmap_set): Return false when the hashmap cannot be enlarged. > ????* caf/shmem/hashmap.h (hashmap_set): Return bool. > > gcc/testsuite/ChangeLog: > > ????* gfortran.dg/coarray/alloc_pool_exhausted_3.f90: New test. > --- From pietro@sociotechnical.xyz Sun Nov 1 21:48:09 2026 From: pietro@sociotechnical.xyz (Pietro Monteiro) Date: Sun, 1 Nov 2026 16:48:09 -0500 Subject: [PATCH] libiberty: Update Makefile dependencies Message-ID: <20261101214808.388949-2-pietro@sociotechnical.xyz> Autoconf macros from config/hwcaps.m4, config/clang-plugin.m4, and config/mmap.m4 were added to configure.ac, in commits r14-5993-gf2c52c0dfde581, r16-4178-g6051a849aa1e8e, and r17-5270-gd58a2bf47606f0, respectively. But they weren't added to Makefile.in aclocal_deps. Add them so the files are tracked when maintainer mode is enabled. I also ran a build with maintainer mode enabled and the liibterty make targets maint-missing, maint-undoc, and maint-deps, which updated some Makefile targets dependencies and regenerated the documentation. libiberty/ChangeLog: * Makefile.in (aclocal_deps): Depend on ../config/clang-plugin.m4, ../config/hwcaps.m4, and ../config/mmap.m4. (./filedescriptor.$(objext)): Update dependencies. (./filename_cmp.$(objext)): Likewise. (./memrchr.$(objext)): Likewise. ( ./pex-unix.$(objext)): Likewise. (./setenv.$(objext)): Likewise. ( ./xmalloc.$(objext)): Likewise. * acinclude.m4: Stop including ../config/mmap.m4. * aclocal.m4: Regenerate. * functions.texi: Likewise. Signed-off-by: Pietro Monteiro --- libiberty/Makefile.in | 37 ++++++++++++--------- libiberty/acinclude.m4 | 2 -- libiberty/aclocal.m4 | 1 + libiberty/functions.texi | 70 +++++++++++++++++++++++++++------------- 4 files changed, 69 insertions(+), 41 deletions(-) diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in index 00af4acca66..38d770d89d6 100644 --- a/libiberty/Makefile.in +++ b/libiberty/Makefile.in @@ -508,8 +508,11 @@ ACLOCAL_AMFLAGS = -I ../config -I .. aclocal_deps = \ $(srcdir)/../config/acx.m4 \ $(srcdir)/../config/cet.m4 \ + $(srcdir)/../config/clang-plugin.m4 \ $(srcdir)/../config/enable.m4 \ $(srcdir)/../config/gcc-plugin.m4 \ + $(srcdir)/../config/hwcaps.m4 \ + $(srcdir)/../config/mmap.m4 \ $(srcdir)/../config/no-executables.m4 \ $(srcdir)/../config/override.m4 \ $(srcdir)/../config/picflag.m4 \ @@ -799,8 +802,8 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir else true; fi $(COMPILE.c) $(srcdir)/fibheap.c $(OUTPUT_OPTION) -./filedescriptor.$(objext): $(srcdir)/filedescriptor.c config.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/libiberty.h +./filedescriptor.$(objext): $(srcdir)/filedescriptor.c config.h \ + $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/filedescriptor.c -o pic/$@; \ else true; fi @@ -809,9 +812,8 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir else true; fi $(COMPILE.c) $(srcdir)/filedescriptor.c $(OUTPUT_OPTION) - ./filename_cmp.$(objext): $(srcdir)/filename_cmp.c config.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ + $(INCDIR)/filenames.h $(INCDIR)/hashtab.h $(INCDIR)/libiberty.h \ $(INCDIR)/safe-ctype.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/filename_cmp.c -o pic/$@; \ @@ -1026,15 +1028,6 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir else true; fi $(COMPILE.c) $(srcdir)/memchr.c $(OUTPUT_OPTION) -./memrchr.$(objext): $(srcdir)/memrchr.c $(INCDIR)/ansidecl.h - if [ x"$(PICFLAG)" != x ]; then \ - $(COMPILE.c) $(PICFLAG) $(srcdir)/memrchr.c -o pic/$@; \ - else true; fi - if [ x"$(NOASANFLAG)" != x ]; then \ - $(COMPILE.c) $(PICFLAG) $(NOASANFLAG) $(srcdir)/memrchr.c -o noasan/$@; \ - else true; fi - $(COMPILE.c) $(srcdir)/memrchr.c $(OUTPUT_OPTION) - ./memcmp.$(objext): $(srcdir)/memcmp.c $(INCDIR)/ansidecl.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/memcmp.c -o pic/$@; \ @@ -1080,6 +1073,15 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir else true; fi $(COMPILE.c) $(srcdir)/mempcpy.c $(OUTPUT_OPTION) +./memrchr.$(objext): $(srcdir)/memrchr.c $(INCDIR)/ansidecl.h + if [ x"$(PICFLAG)" != x ]; then \ + $(COMPILE.c) $(PICFLAG) $(srcdir)/memrchr.c -o pic/$@; \ + else true; fi + if [ x"$(NOASANFLAG)" != x ]; then \ + $(COMPILE.c) $(PICFLAG) $(NOASANFLAG) $(srcdir)/memrchr.c -o noasan/$@; \ + else true; fi + $(COMPILE.c) $(srcdir)/memrchr.c $(OUTPUT_OPTION) + ./memset.$(objext): $(srcdir)/memset.c $(INCDIR)/ansidecl.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/memset.c -o pic/$@; \ @@ -1178,7 +1180,8 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir $(COMPILE.c) $(srcdir)/pex-one.c $(OUTPUT_OPTION) ./pex-unix.$(objext): $(srcdir)/pex-unix.c config.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/libiberty.h $(srcdir)/pex-common.h + $(INCDIR)/environ.h $(INCDIR)/libiberty.h \ + $(srcdir)/pex-common.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/pex-unix.c -o pic/$@; \ else true; fi @@ -1284,7 +1287,8 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir else true; fi $(COMPILE.c) $(srcdir)/safe-ctype.c $(OUTPUT_OPTION) -./setenv.$(objext): $(srcdir)/setenv.c config.h $(INCDIR)/ansidecl.h +./setenv.$(objext): $(srcdir)/setenv.c config.h $(INCDIR)/ansidecl.h \ + $(INCDIR)/environ.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/setenv.c -o pic/$@; \ else true; fi @@ -1735,7 +1739,7 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir $(COMPILE.c) $(srcdir)/xexit.c $(OUTPUT_OPTION) ./xmalloc.$(objext): $(srcdir)/xmalloc.c config.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/libiberty.h + $(INCDIR)/environ.h $(INCDIR)/libiberty.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/xmalloc.c -o pic/$@; \ else true; fi @@ -1793,3 +1797,4 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir $(COMPILE.c) $(PICFLAG) $(NOASANFLAG) $(srcdir)/xvasprintf.c -o noasan/$@; \ else true; fi $(COMPILE.c) $(srcdir)/xvasprintf.c $(OUTPUT_OPTION) + diff --git a/libiberty/acinclude.m4 b/libiberty/acinclude.m4 index b2dd0f1ba98..41285c5bf08 100644 --- a/libiberty/acinclude.m4 +++ b/libiberty/acinclude.m4 @@ -192,5 +192,3 @@ AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction, STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown]) ]) - -m4_include([../config/mmap.m4]) diff --git a/libiberty/aclocal.m4 b/libiberty/aclocal.m4 index 5151f5fee18..46cefc36edc 100644 --- a/libiberty/aclocal.m4 +++ b/libiberty/aclocal.m4 @@ -18,6 +18,7 @@ m4_include([../config/clang-plugin.m4]) m4_include([../config/enable.m4]) m4_include([../config/gcc-plugin.m4]) m4_include([../config/hwcaps.m4]) +m4_include([../config/mmap.m4]) m4_include([../config/no-executables.m4]) m4_include([../config/override.m4]) m4_include([../config/picflag.m4]) diff --git a/libiberty/functions.texi b/libiberty/functions.texi index 7c7da1ba296..16a9d3ae4ac 100644 --- a/libiberty/functions.texi +++ b/libiberty/functions.texi @@ -101,7 +101,7 @@ is respectively less than, matching, or greater than the array member. @end deftypefn -@c argv.c:138 +@c argv.c:129 @deftypefn Extension char** buildargv (char *@var{sp}) Given a pointer to a string, parse the string extracting fields @@ -165,7 +165,7 @@ not recommended. @end deftypefn -@c make-temp-file.c:95 +@c make-temp-file.c:108 @deftypefn Replacement const char* choose_tmpdir () Returns a pointer to a directory path suitable for creating temporary @@ -192,7 +192,7 @@ Concatenate zero or more of strings and return the result in freshly @end deftypefn -@c argv.c:495 +@c argv.c:474 @deftypefn Extension int countargv (char * const *@var{argv}) Return the number of elements in @var{argv}. @@ -257,7 +257,18 @@ symbolic name or message. @end deftypefn -@c argv.c:352 +@c argv.c:497 +@deftypefn Extension {char *} expandargstr @ + (const char *@var{progname}, const char *@var{val}) + +Expand @var{val} as a response file via @code{expandargv} if it begins +with @samp{@@}, using @var{progname} as @code{argv[0]}, and return the +expanded option list as a shell-quoted string. Returns a newly +allocated string. + +@end deftypefn + +@c argv.c:337 @deftypefn Extension void expandargv (int *@var{argcp}, char ***@var{argvp}) The @var{argcp} and @code{argvp} arguments are pointers to the usual @@ -690,6 +701,19 @@ and a path ending in @code{/} returns the empty string after it. @end deftypefn +@c ldirname.c:23 +@deftypefn Replacement {char*} ldirname (const char *@var{name}) + +Given a pointer to a string containing a typical pathname +(@samp{/usr/src/cmd/ls/ls.c} for example), returns a string containing the +passed string up to, but not including, the final directory separator. + +If the given pathname doesn't contain a directory separator then this function +returns the empty string; this includes an empty given pathname. @code{NULL} +is returned on memory allocation error. + +@end deftypefn + @c lrealpath.c:25 @deftypefn Replacement {const char*} lrealpath (const char *@var{name}) @@ -726,7 +750,7 @@ relative prefix can be found, return @code{NULL}. @end deftypefn -@c make-temp-file.c:173 +@c make-temp-file.c:185 @deftypefn Replacement char* make_temp_file (const char *@var{suffix}) Return a temporary file name (as a string) or @code{NULL} if unable to @@ -749,20 +773,6 @@ returned. @end deftypefn -@c memrchr.c:3 -@deftypefn Supplemental void* memrchr (const void *@var{s}, int @var{c}, @ - size_t @var{n}) - -This function searches memory for the character @var{c} in reverse order, -starting at @code{*@var{s}+@var{n}-1} . The search only ends with -the first occurrence of @var{c}, or when the start us reached; in particular, -a null character does not terminate the search. If the character @var{c} is -found within @var{length} characters of @code{*@var{s}}, a pointer -to the character is returned. If @var{c} is not found, then @code{NULL} is -returned. - -@end deftypefn - @c memcmp.c:6 @deftypefn Supplemental int memcmp (const void *@var{x}, const void *@var{y}, @ size_t @var{count}) @@ -812,6 +822,20 @@ Copies @var{length} bytes from memory region @var{in} to region @end deftypefn +@c memrchr.c:3 +@deftypefn Supplemental void* memrchr (const void *@var{s}, int @var{c}, @ + size_t @var{n}) + +This function searches memory for the character @var{c} in reverse order, +starting at @code{*@var{s}+@var{n}-1} . The search only ends with +the first occurrence of @var{c}, or when the start us reached; in particular, +a null character does not terminate the search. If the character @var{c} is +found within @var{length} characters of @code{*@var{s}}, a pointer +to the character is returned. If @var{c} is not found, then @code{NULL} is +returned. + +@end deftypefn + @c memset.c:6 @deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, @ size_t @var{count}) @@ -1761,7 +1785,7 @@ that the converted value is unsigned. @c strtoll.c:33 @deftypefn Supplemental {long long int} strtoll (const char *@var{string}, @ char **@var{endptr}, int @var{base}) -@deftypefnx Supplemental {unsigned long long int} strtoull (@ +@deftypefnx Supplemental {unsigned long long int} strtoul (@ const char *@var{string}, char **@var{endptr}, int @var{base}) The @code{strtoll} function converts the string in @var{string} to a @@ -1948,12 +1972,12 @@ does the return value. The third argument is unused in @libib{}. @end deftypefn -@c argv.c:289 +@c argv.c:287 @deftypefn Extension int writeargv (char * const *@var{argv}, FILE *@var{file}) Write each member of ARGV, handling all necessary quoting, to the file -named by FILE, separated by whitespace. Return 0 on success, non-zero -if an error occurred while writing to FILE. +associated with FILE, separated by whitespace. Return 0 on success, +non-zero if an error occurred while writing to FILE. @end deftypefn -- 2.56.0 From pietro@sociotechnical.xyz Sun Nov 1 22:26:21 2026 From: pietro@sociotechnical.xyz (Pietro Monteiro) Date: Sun, 1 Nov 2026 17:26:21 -0500 Subject: [PATCH] libobjc: Update Makefile aclocal_deps Message-ID: <20261101222620.450840-2-pietro@sociotechnical.xyz> Autoconf macros from the following files were added to libojc configury on the commits: File Commit config/acx.m4 r0-57614-g9c01f3959321c1 config/bitfields.m4 r6-429-g539280a8e89d4e config/clang-plugin.m4 r16-4232-gac273977adbe76 config/enable.m4 r0-102901-gfd3125375f17ba config/gcc-plugin.m4 r16-4232-gac273977adbe76 config/lthostflags.m4 r0-105126-g7de6ba7a0bf338 config/mmap.m4 r17-5270-gd58a2bf47606f0 config/no-executables.m4 r0-57617-g8838605016a588 config/tls.m4 r0-102901-gfd3125375f17ba libtool.m4 r0-29632-g8cab40f72e6434 And config/proginstall.m4 was removed from libobjc configury on commit r0-95340-g5213506e247206. But they weren't added, or removed, to Makefile.in aclocal_deps. Add, or remove, them so the files are tracked when maintainer mode is enabled. libobjc/ChangeLog: * Makefile.in (aclocal_deps): Depend on ../config/acx.m4, ../config/bitfields.m4, ../config/clang-plugin.m4, ../config/enable.m4, ../config/gcc-plugin.m4, ../config/lthostflags.m4, ../config/mmap.m4, ../config/no-executables.m4, ../config/tls.m4, and ../libtool.m4. Stop depending on ../config/proginstall.m4. Signed-off-by: Pietro Monteiro --- libobjc/Makefile.in | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libobjc/Makefile.in b/libobjc/Makefile.in index 8129ed07a00..87e4ba6724c 100644 --- a/libobjc/Makefile.in +++ b/libobjc/Makefile.in @@ -290,15 +290,24 @@ AUTOCONF = autoconf ACLOCAL = aclocal ACLOCAL_AMFLAGS = -I ../config -I .. aclocal_deps = \ + $(srcdir)/../config/acx.m4 \ + $(srcdir)/../config/bitfields.m4 \ + $(srcdir)/../config/cet.m4 \ + $(srcdir)/../config/clang-plugin.m4 \ + $(srcdir)/../config/enable.m4 \ + $(srcdir)/../config/gcc-plugin.m4 \ + $(srcdir)/../config/lthostflags.m4 \ + $(srcdir)/../config/mmap.m4 \ $(srcdir)/../config/multi.m4 \ + $(srcdir)/../config/no-executables.m4 \ $(srcdir)/../config/override.m4 \ - $(srcdir)/../config/proginstall.m4 \ + $(srcdir)/../config/tls.m4 \ $(srcdir)/../config/toolexeclibdir.m4 \ + $(srcdir)/../libtool.m4 \ $(srcdir)/../ltoptions.m4 \ $(srcdir)/../ltsugar.m4 \ $(srcdir)/../ltversion.m4 \ $(srcdir)/../lt~obsolete.m4 \ - $(srcdir)/../config/cet.m4 \ $(srcdir)/acinclude.m4 $(srcdir)/configure: @MAINT@ configure.ac $(srcdir)/aclocal.m4 -- 2.56.0 From jeffrey.law@oss.qualcomm.com Sun Nov 1 22:24:14 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 15:24:14 -0700 Subject: [PATCH] RISC-V: Keep whole-word tails in block-move group In-Reply-To: <20261028091224.3248490-1-panciyan@eswincomputing.com> References: <20261028091224.3248490-1-panciyan@eswincomputing.com> Message-ID: <07ca17db-b6de-4897-a6d5-ed58664f724c@oss.qualcomm.com> On 10/28/26 3:12 AM, e0001533 wrote: > From: panciyan > > When a constant-size block copy has a size that is an exact multiple > of the word size and a copied word is immediately overwritten by a > later store, the pre-patch expansion defers the trailing whole word > to move_by_pieces, emitting its accesses after the group's stores. > RTL DSE then cannot prove that the trailing load does not read the > overwritten word, so it retains the dead copy pair, costing one dead > load and one dead store per overwritten word. > > Keeping the trailing whole word in the group keeps all loads ahead of > all stores, which lets DSE remove the dead pair. The new > cpymem-dse-1.c test (a copy whose Int_Comp word is immediately > overwritten; 48 bytes on rv32, 64 on rv64) flips from FAIL to PASS. > > Signed-off-by: Ciyan Pan > gcc/ChangeLog: > > * config/riscv/riscv-string.cc (riscv_block_move_straight): > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/cpymem-dse-1.c: New test. You didn't indicate if you'd run the full testsuite or not, so I went ahead and threw it into my tester to ensure the basic tests were run.? In the future you need to verify there are no regressions using "make check" before and after your patch and comparing the summary files.? You also didn't include a ChangeLog entry for the riscv-string change.? I fixed that for you. Other than the testing & ChangeLog goof's I didn't see anything concerning.? Sashiko raised no concerns either.? I've pushed this to the trunk. jeff From kaelfandrew@gmail.com Sun Nov 1 22:33:16 2026 From: kaelfandrew@gmail.com (Kael Andrew Franco) Date: Sun, 1 Nov 2026 17:33:16 -0500 Subject: [PATCH] gcc: Remove HAVE_SWAP_IN_UTILITY in gcc/configure.ac. [PR112422] Message-ID: <20261101223316.4181254-1-kaelfandrew@gmail.com> GCC itself needs C++14 and std::swap was move to in C++11. Bootstrapped on x86_64-pc-linux-gnu. PR bootstrap/112422 gcc/ChangeLog: * configure.ac (HAVE_SWAP_IN_UTILITY): Remove. * configure: Regenerate. * config.in: Regenerate. * system.h: Remove HAVE_SWAP_IN_UTILITY. --- gcc/config.in | 6 ------ gcc/configure | 38 ++------------------------------------ gcc/configure.ac | 9 --------- gcc/system.h | 2 +- 4 files changed, 3 insertions(+), 52 deletions(-) diff --git a/gcc/config.in b/gcc/config.in index 1027a45a207..241c299682d 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1964,12 +1964,6 @@ #endif -/* Define if defines std::swap. */ -#ifndef USED_FOR_TARGET -#undef HAVE_SWAP_IN_UTILITY -#endif - - /* Define to 1 if you have the `sysconf' function. */ #ifndef USED_FOR_TARGET #undef HAVE_SYSCONF diff --git a/gcc/configure b/gcc/configure index 14c9b39d9ce..a60ae0ffbcc 100755 --- a/gcc/configure +++ b/gcc/configure @@ -7065,40 +7065,6 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for std::swap in " >&5 -$as_echo_n "checking for std::swap in ... " >&6; } -if ${ac_cv_std_swap_in_utility+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include - -int -main () -{ -int a, b; std::swap(a,b); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_std_swap_in_utility=yes -else - ac_cv_std_swap_in_utility=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_std_swap_in_utility" >&5 -$as_echo "$ac_cv_std_swap_in_utility" >&6; } -if test $ac_cv_std_swap_in_utility = yes; then - -$as_echo "#define HAVE_SWAP_IN_UTILITY 1" >>confdefs.h - -fi - # --------------------- # Warnings and checking # --------------------- @@ -22088,7 +22054,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 22091 "configure" +#line 22057 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -22194,7 +22160,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 22197 "configure" +#line 22163 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index 06b23d6de41..cc0d00e911b 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -552,15 +552,6 @@ struct X { typedef long long t; }; ]], [[X::t x;]])],[],[AC_MSG_ERROR([error verifying int64_t uses long long])]) fi -AC_CACHE_CHECK(for std::swap in , ac_cv_std_swap_in_utility, [ -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -]], [[int a, b; std::swap(a,b);]])],[ac_cv_std_swap_in_utility=yes],[ac_cv_std_swap_in_utility=no])]) -if test $ac_cv_std_swap_in_utility = yes; then - AC_DEFINE(HAVE_SWAP_IN_UTILITY, 1, - [Define if defines std::swap.]) -fi - # --------------------- # Warnings and checking # --------------------- diff --git a/gcc/system.h b/gcc/system.h index b967c5677fa..6a05e6dc88f 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -203,7 +203,7 @@ extern int fprintf_unlocked (FILE *, const char *, ...); poisoning the ctype macros through safe-ctype.h */ #ifdef __cplusplus -#if defined (INCLUDE_ALGORITHM) || !defined (HAVE_SWAP_IN_UTILITY) +#ifdef INCLUDE_ALGORITHM # include #endif #ifdef INCLUDE_DEQUE -- 2.56.0 From jeffrey.law@oss.qualcomm.com Sun Nov 1 22:31:05 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 15:31:05 -0700 Subject: [committed][RISC-V][PR target/128139] Don't create pseudos when !can_create_pseudos_p on RISC-V Message-ID: <999f8e4d-84d2-49ea-bd11-3331de7cae25@oss.qualcomm.com> Dumb mistake on my part.? When I added a new path to call synthesize_add I didn't account for the possibility it could be called after the point where no new pseudos are allowed. The good news is that new path can handle synthesize_add returning false (no synthesis available) so we just need to return false from synthesize_add if the synthesis requires creating a new pseudo register (we could probably improve that further by re-using the output if it doesn't overlap the register input, but these paths should be very uncommon, so likely not worth the effort). Regression tested on riscv32-elf and riscv64-elf.? K3, K1 and C920 are all queued.? Pushing to the trunk. Jeff -------------- next part -------------- commit c95c6184ac83496704538b0572cbca577acbdcb0 Author: Jeff Law Date: Sun Nov 1 15:30:29 2026 -0700 Drop upstreamed patch diff --git a/gcc/0006-pr128139.patch b/gcc/0006-pr128139.patch deleted file mode 100644 index d641368..0000000 --- a/gcc/0006-pr128139.patch +++ /dev/null @@ -1,79 +0,0 @@ -diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc -index ab9354162fab..517e4f995775 100644 ---- a/gcc/config/riscv/riscv.cc -+++ b/gcc/config/riscv/riscv.cc -@@ -16763,7 +16763,7 @@ synthesize_add (rtx operands[3]) - shcount = 3; - } - -- if (shcount != 0) -+ if (shcount != 0 && can_create_pseudo_p ()) - { - rtx x = force_reg (word_mode, GEN_INT (sext_hwi (ival >> shcount, 32))); - x = gen_rtx_ASHIFT (word_mode, x, GEN_INT (shcount)); -@@ -16787,7 +16787,8 @@ synthesize_add (rtx operands[3]) - || ((ival % 4) == 0 && budget1 - > riscv_integer_cost (ival >> 2, true)) - || ((ival % 8) == 0 && budget1 -- > riscv_integer_cost (ival >> 3, true)))) -+ > riscv_integer_cost (ival >> 3, true))) -+ && can_create_pseudo_p ()) - { - // Load the shifted constant into a temporary - int shct = ctz_hwi (ival); -@@ -16813,7 +16814,8 @@ synthesize_add (rtx operands[3]) - then synthesize C' and use add.uw. */ - if ((TARGET_64BIT && TARGET_ZBA) - && (ival & HOST_WIDE_INT_UC (0xffffffff00000000)) == 0 -- && riscv_integer_cost (sext_hwi (ival, 32), true) < budget1) -+ && riscv_integer_cost (sext_hwi (ival, 32), true) < budget1 -+ && can_create_pseudo_p ()) - { - /* Load the sign extended constant into a temporary. */ - rtx tempreg = force_reg (word_mode, GEN_INT (sext_hwi (ival, 32))); -@@ -16828,7 +16830,7 @@ synthesize_add (rtx operands[3]) - - /* If the negated constant is cheaper than the original, then negate - the constant and use sub. */ -- if (budget2 < budget1) -+ if (budget2 < budget1 && can_create_pseudo_p ()) - { - // load -INTVAL (operands[2]) into a temporary - rtx tmp = force_reg (word_mode, GEN_INT (-INTVAL (operands[2]))); -@@ -16841,10 +16843,14 @@ synthesize_add (rtx operands[3]) - - /* No add synthesis was found. Synthesize the constant into - a temporary and use that. */ -- rtx x = force_reg (word_mode, operands[2]); -- x = gen_rtx_PLUS (word_mode, operands[1], x); -- emit_insn (gen_rtx_SET (operands[0], x)); -- return true; -+ if (can_create_pseudo_p ()) -+ { -+ rtx x = force_reg (word_mode, operands[2]); -+ x = gen_rtx_PLUS (word_mode, operands[1], x); -+ emit_insn (gen_rtx_SET (operands[0], x)); -+ return true; -+ } -+ return false; - } - - /* Synthesize OPERANDS[0] = OPERANDS[1] + OPERANDS[2]. -diff --git a/gcc/testsuite/gcc.target/riscv/pr128139.c b/gcc/testsuite/gcc.target/riscv/pr128139.c -new file mode 100644 -index 000000000000..bd72baca3621 ---- /dev/null -+++ b/gcc/testsuite/gcc.target/riscv/pr128139.c -@@ -0,0 +1,12 @@ -+/* { dg-do compile } */ -+ -+void b(char *); -+ -+void a(long off, void *h) -+{ -+ char buf[8192]; -+ b(buf); -+ __builtin_eh_return (off, h); -+} -+ -+ From andrew.pinski@oss.qualcomm.com Sun Nov 1 22:36:12 2026 From: andrew.pinski@oss.qualcomm.com (Andrea Pinski) Date: Sun, 1 Nov 2026 14:36:12 -0800 Subject: [PATCH] gcc: Remove HAVE_SWAP_IN_UTILITY in gcc/configure.ac. [PR112422] In-Reply-To: <20261101223316.4181254-1-kaelfandrew@gmail.com> References: <20261101223316.4181254-1-kaelfandrew@gmail.com> Message-ID: On Sun, Nov 1, 2026 at 2:34?PM Kael Andrew Franco wrote: > > GCC itself needs C++14 and std::swap was move to > in C++11. > > Bootstrapped on x86_64-pc-linux-gnu. > > PR bootstrap/112422 > > gcc/ChangeLog: > > * configure.ac (HAVE_SWAP_IN_UTILITY): Remove. > * configure: Regenerate. > * config.in: Regenerate. > * system.h: Remove HAVE_SWAP_IN_UTILITY. Ok. > --- > gcc/config.in | 6 ------ > gcc/configure | 38 ++------------------------------------ > gcc/configure.ac | 9 --------- > gcc/system.h | 2 +- > 4 files changed, 3 insertions(+), 52 deletions(-) > > diff --git a/gcc/config.in b/gcc/config.in > index 1027a45a207..241c299682d 100644 > --- a/gcc/config.in > +++ b/gcc/config.in > @@ -1964,12 +1964,6 @@ > #endif > > > -/* Define if defines std::swap. */ > -#ifndef USED_FOR_TARGET > -#undef HAVE_SWAP_IN_UTILITY > -#endif > - > - > /* Define to 1 if you have the `sysconf' function. */ > #ifndef USED_FOR_TARGET > #undef HAVE_SYSCONF > diff --git a/gcc/configure b/gcc/configure > index 14c9b39d9ce..a60ae0ffbcc 100755 > --- a/gcc/configure > +++ b/gcc/configure > @@ -7065,40 +7065,6 @@ fi > rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > fi > > -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for std::swap in " >&5 > -$as_echo_n "checking for std::swap in ... " >&6; } > -if ${ac_cv_std_swap_in_utility+:} false; then : > - $as_echo_n "(cached) " >&6 > -else > - > -cat confdefs.h - <<_ACEOF >conftest.$ac_ext > -/* end confdefs.h. */ > - > -#include > - > -int > -main () > -{ > -int a, b; std::swap(a,b); > - ; > - return 0; > -} > -_ACEOF > -if ac_fn_cxx_try_compile "$LINENO"; then : > - ac_cv_std_swap_in_utility=yes > -else > - ac_cv_std_swap_in_utility=no > -fi > -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > -fi > -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_std_swap_in_utility" >&5 > -$as_echo "$ac_cv_std_swap_in_utility" >&6; } > -if test $ac_cv_std_swap_in_utility = yes; then > - > -$as_echo "#define HAVE_SWAP_IN_UTILITY 1" >>confdefs.h > - > -fi > - > # --------------------- > # Warnings and checking > # --------------------- > @@ -22088,7 +22054,7 @@ else > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > lt_status=$lt_dlunknown > cat > conftest.$ac_ext <<_LT_EOF > -#line 22091 "configure" > +#line 22057 "configure" > #include "confdefs.h" > > #if HAVE_DLFCN_H > @@ -22194,7 +22160,7 @@ else > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > lt_status=$lt_dlunknown > cat > conftest.$ac_ext <<_LT_EOF > -#line 22197 "configure" > +#line 22163 "configure" > #include "confdefs.h" > > #if HAVE_DLFCN_H > diff --git a/gcc/configure.ac b/gcc/configure.ac > index 06b23d6de41..cc0d00e911b 100644 > --- a/gcc/configure.ac > +++ b/gcc/configure.ac > @@ -552,15 +552,6 @@ struct X { typedef long long t; }; > ]], [[X::t x;]])],[],[AC_MSG_ERROR([error verifying int64_t uses long long])]) > fi > > -AC_CACHE_CHECK(for std::swap in , ac_cv_std_swap_in_utility, [ > -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ > -#include > -]], [[int a, b; std::swap(a,b);]])],[ac_cv_std_swap_in_utility=yes],[ac_cv_std_swap_in_utility=no])]) > -if test $ac_cv_std_swap_in_utility = yes; then > - AC_DEFINE(HAVE_SWAP_IN_UTILITY, 1, > - [Define if defines std::swap.]) > -fi > - > # --------------------- > # Warnings and checking > # --------------------- > diff --git a/gcc/system.h b/gcc/system.h > index b967c5677fa..6a05e6dc88f 100644 > --- a/gcc/system.h > +++ b/gcc/system.h > @@ -203,7 +203,7 @@ extern int fprintf_unlocked (FILE *, const char *, ...); > poisoning the ctype macros through safe-ctype.h */ > > #ifdef __cplusplus > -#if defined (INCLUDE_ALGORITHM) || !defined (HAVE_SWAP_IN_UTILITY) > +#ifdef INCLUDE_ALGORITHM > # include > #endif > #ifdef INCLUDE_DEQUE > -- > 2.56.0 > From andrew.pinski@oss.qualcomm.com Sun Nov 1 22:36:49 2026 From: andrew.pinski@oss.qualcomm.com (Andrea Pinski) Date: Sun, 1 Nov 2026 14:36:49 -0800 Subject: [PATCH] libobjc: Update Makefile aclocal_deps In-Reply-To: <20261101222620.450840-2-pietro@sociotechnical.xyz> References: <20261101222620.450840-2-pietro@sociotechnical.xyz> Message-ID: On Sun, Nov 1, 2026 at 2:27?PM Pietro Monteiro wrote: > > Autoconf macros from the following files were added to libojc > configury on the commits: > > File Commit > config/acx.m4 r0-57614-g9c01f3959321c1 > config/bitfields.m4 r6-429-g539280a8e89d4e > config/clang-plugin.m4 r16-4232-gac273977adbe76 > config/enable.m4 r0-102901-gfd3125375f17ba > config/gcc-plugin.m4 r16-4232-gac273977adbe76 > config/lthostflags.m4 r0-105126-g7de6ba7a0bf338 > config/mmap.m4 r17-5270-gd58a2bf47606f0 > config/no-executables.m4 r0-57617-g8838605016a588 > config/tls.m4 r0-102901-gfd3125375f17ba > libtool.m4 r0-29632-g8cab40f72e6434 > > And config/proginstall.m4 was removed from libobjc configury on commit > r0-95340-g5213506e247206. > > But they weren't added, or removed, to Makefile.in aclocal_deps. Add, > or remove, them so the files are tracked when maintainer mode is > enabled. > > libobjc/ChangeLog: > > * Makefile.in (aclocal_deps): Depend on ../config/acx.m4, > ../config/bitfields.m4, ../config/clang-plugin.m4, > ../config/enable.m4, ../config/gcc-plugin.m4, > ../config/lthostflags.m4, ../config/mmap.m4, > ../config/no-executables.m4, ../config/tls.m4, and ../libtool.m4. > Stop depending on ../config/proginstall.m4. Ok. > > Signed-off-by: Pietro Monteiro > --- > libobjc/Makefile.in | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/libobjc/Makefile.in b/libobjc/Makefile.in > index 8129ed07a00..87e4ba6724c 100644 > --- a/libobjc/Makefile.in > +++ b/libobjc/Makefile.in > @@ -290,15 +290,24 @@ AUTOCONF = autoconf > ACLOCAL = aclocal > ACLOCAL_AMFLAGS = -I ../config -I .. > aclocal_deps = \ > + $(srcdir)/../config/acx.m4 \ > + $(srcdir)/../config/bitfields.m4 \ > + $(srcdir)/../config/cet.m4 \ > + $(srcdir)/../config/clang-plugin.m4 \ > + $(srcdir)/../config/enable.m4 \ > + $(srcdir)/../config/gcc-plugin.m4 \ > + $(srcdir)/../config/lthostflags.m4 \ > + $(srcdir)/../config/mmap.m4 \ > $(srcdir)/../config/multi.m4 \ > + $(srcdir)/../config/no-executables.m4 \ > $(srcdir)/../config/override.m4 \ > - $(srcdir)/../config/proginstall.m4 \ > + $(srcdir)/../config/tls.m4 \ > $(srcdir)/../config/toolexeclibdir.m4 \ > + $(srcdir)/../libtool.m4 \ > $(srcdir)/../ltoptions.m4 \ > $(srcdir)/../ltsugar.m4 \ > $(srcdir)/../ltversion.m4 \ > $(srcdir)/../lt~obsolete.m4 \ > - $(srcdir)/../config/cet.m4 \ > $(srcdir)/acinclude.m4 > > $(srcdir)/configure: @MAINT@ configure.ac $(srcdir)/aclocal.m4 > -- > 2.56.0 > From alx@kernel.org Sun Nov 1 22:47:32 2026 From: alx@kernel.org (Alejandro Colomar) Date: Sun, 1 Nov 2026 23:47:32 +0100 Subject: [PATCH 0/2] c: Add support for array parameters in _Countof In-Reply-To: References: Message-ID: Hi, Changes in v7 compared to v5 (v6 never existed): - Add tests to make sure that _Countof() works reasonably well with forward declarations of array parameters. - Rebase on top of master. See the range-diff at the bottom. Joseph, as we agreed recently, I want to make _Countof() support array parameters where the length is declared only in the forward declaration. However, that seems non-trivial, so it might be interesting to do a first release that doesn't yet compile for that. I've added tests to make sure that it never produces UB, but rather just compiler errors or reasonable behavior (one of the specified lengths). I think it would be interesting to release this feature already, because it works decently well for most reasonable code. If we have this feature already in GCC 17, then programs could start using this feature in some (~5 for many projects) years from now, while delaying it until we have better support for forward declarations could delay it by one or two years, which would be bad for bounds safety in general. Do you think we could release this, with the acknowledgement that we want to eventually fix the test which has a 'FIXME'? I plan to work on that, but can't promise when I'll have it done. The current patch set is robust to be released, IMO. Have a lovely night! Alex Alejandro Colomar (2): c: Refactor implementation of _Countof c: Add support for array parameters in _Countof gcc/c/c-typeck.cc | 45 +++++++- gcc/doc/extend.texi | 11 ++ gcc/testsuite/gcc.dg/countof-compile.c | 8 +- gcc/testsuite/gcc.dg/countof-param-compile.c | 104 ++++++++++++++++++ gcc/testsuite/gcc.dg/countof-param-pedantic.c | 11 ++ gcc/testsuite/gcc.dg/countof-param.c | 25 +++++ 6 files changed, 191 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/countof-param-compile.c create mode 100644 gcc/testsuite/gcc.dg/countof-param-pedantic.c create mode 100644 gcc/testsuite/gcc.dg/countof-param.c Range-diff: 1: 31191ae061c2 ! 1: 53c196b9667d c: Refactor implementation of _Countof() @@ Metadata Author: Alejandro Colomar ## Commit message ## - c: Refactor implementation of _Countof() + c: Refactor implementation of _Countof No changes intended. This refactor prepares the code so that a future - patch extending the semantic of _Countof() will be smaller. + patch extending the semantics of _Countof() will be smaller. gcc/c/ChangeLog: @@ gcc/c/c-typeck.cc: c_expr_countof_expr (location_t loc, struct c_expr expr) - tree folded_expr = c_fully_fold (expr.value, require_constant_value, - &expr_const_operands); - ret.value = c_countof_type (loc, TREE_TYPE (folded_expr)); -- c_last_sizeof_arg = expr.value; -- c_last_sizeof_loc = loc; + c_last_sizeof_arg = expr.value; + c_last_sizeof_loc = loc; ret.original_code = COUNTOF_EXPR; ret.original_type = NULL; ret.m_decimal = 0; -- if (is_top_array_vla (TREE_TYPE (folded_expr))) +- if (top_array_vla_p (TREE_TYPE (folded_expr))) + + tree folded_expr = c_fully_fold (expr.value, require_constant_value, + &expr_const_operands); -+ + tree type = TREE_TYPE (folded_expr); + ret.value = c_countof_type (loc, type); -+ c_last_sizeof_arg = expr.value; -+ c_last_sizeof_loc = loc; + -+ if (is_top_array_vla (type)) ++ if (top_array_vla_p (type)) { /* countof is evaluated when given a vla. */ ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value), @@ gcc/c/c-typeck.cc: c_expr_countof_expr (location_t loc, struct c_expr expr) C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands; SET_EXPR_LOCATION (ret.value, loc); } -- pop_maybe_used (is_top_array_vla (TREE_TYPE (folded_expr))); -+ pop_maybe_used (is_top_array_vla (type)); +- pop_maybe_used (top_array_vla_p (TREE_TYPE (folded_expr))); ++ pop_maybe_used (top_array_vla_p (type)); } return ret; } 2: b1ca7e6c7135 ! 2: 026b76ce72ec c: Add support for array parameters in _Countof @@ Commit message This extension will allow using _Countof() in more places, reducing the chances of specifying an incorrect size accidentally. - We should eventually add -farray-parameters-are-const to make array - parameters be implicitly const-qualified (similar to -Wwrite-strings). + If an array parameter has a forward declaration, it is unspecified which + of the lengths is taken. It is generally unwise to specify the length + in the forward declarations, and it is even more unwise to specify it + more than once. Currently, the implementation takes the length from + the actual declaration, and if it doesn't specify the length, it won't + compile. In the future, we want to improve this so that the length + from a forward declaration is taken if the actual declaration lacks one. + But that's more complex, so let's keep it as is for now. Link: @@ Commit message Signed-off-by: Alejandro Colomar ## gcc/c/c-typeck.cc ## -@@ gcc/c/c-typeck.cc: is_top_array_vla (tree type) - return var; +@@ gcc/c/c-typeck.cc: top_array_vla_p (const_tree type) + || TREE_CODE (TYPE_MIN_VALUE (d)) != INTEGER_CST; } + @@ gcc/c/c-typeck.cc: is_top_array_vla (tree type) struct c_expr @@ gcc/c/c-typeck.cc: c_expr_countof_expr (location_t loc, struct c_expr expr) + tree folded_expr = c_fully_fold (expr.value, require_constant_value, &expr_const_operands); - tree type = TREE_TYPE (folded_expr); + if (POINTER_TYPE_P (type)) + { -+ if (tree rv = c_array_parm_orig_type (expr.value)) ++ if (tree t = c_array_parm_orig_type (expr.value)) + { + pedwarn (input_location, OPT_Wpedantic, + "ISO C does not support array parameters in %qs", + "_Countof"); -+ type = rv; ++ type = t; + } + } + ret.value = c_countof_type (loc, type); - c_last_sizeof_arg = expr.value; - c_last_sizeof_loc = loc; + + if (top_array_vla_p (type)) ## gcc/doc/extend.texi ## @@ gcc/doc/extend.texi: _Countof (int [7][n++]); // integer constant expression @@ gcc/testsuite/gcc.dg/countof-param-compile.c (new) +{ + a++; + _Countof (a); ++} ++ ++void ++fwd_a_first (char a[6]; char a[]) ++{ ++ _Countof (a); /* { dg-error "incomplete" } */ ++ // FIXME: This should pass: ++ //_Static_assert (_Countof (a) == 6); ++} ++ ++void ++fwd_ap_first (char (*a)[6]; char (*a)[]) ++{ ++ _Static_assert (_Countof (*a) == 6); ++} ++ ++void ++fwd_a_second (char a[]; char a[7]) ++{ ++ _Static_assert (_Countof (a) == 7); ++} ++ ++void ++fwd_ap_second (char (*a)[]; char (*a)[7]) ++{ ++ _Static_assert (_Countof (*a) == 7); ++} ++ ++void ++fwd_a_both (char a[6]; char a[7]) ++{ ++ _Static_assert (_Countof (a) == 6 || _Countof (a) == 7); ++} ++ ++void ++fwd_ap_both (char (*a)[6]; char (*a)[6]) ++{ ++ _Static_assert (_Countof (*a) == 6); +} ## gcc/testsuite/gcc.dg/countof-param-pedantic.c (new) ## base-commit: a440b382e43203857de9195eb526c4a16f21ceb1 -- 2.55.0 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From alx@kernel.org Sun Nov 1 22:47:36 2026 From: alx@kernel.org (Alejandro Colomar) Date: Sun, 1 Nov 2026 23:47:36 +0100 Subject: [PATCH 1/2] c: Refactor implementation of _Countof In-Reply-To: References: Message-ID: <53c196b9667daffb06e5fb7f42dcee3e8da83606.1793572618.git.alx@kernel.org> No changes intended. This refactor prepares the code so that a future patch extending the semantics of _Countof() will be smaller. gcc/c/ChangeLog: * c-typeck.cc (c_expr_countof_expr): Refactor. Co-authored-by: Martin Uecker Signed-off-by: Alejandro Colomar --- gcc/c/c-typeck.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 2d0200858331..61abace966da 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -4159,16 +4159,18 @@ c_expr_countof_expr (location_t loc, struct c_expr expr) else { bool expr_const_operands = true; - - tree folded_expr = c_fully_fold (expr.value, require_constant_value, - &expr_const_operands); - ret.value = c_countof_type (loc, TREE_TYPE (folded_expr)); c_last_sizeof_arg = expr.value; c_last_sizeof_loc = loc; ret.original_code = COUNTOF_EXPR; ret.original_type = NULL; ret.m_decimal = 0; - if (top_array_vla_p (TREE_TYPE (folded_expr))) + + tree folded_expr = c_fully_fold (expr.value, require_constant_value, + &expr_const_operands); + tree type = TREE_TYPE (folded_expr); + ret.value = c_countof_type (loc, type); + + if (top_array_vla_p (type)) { /* countof is evaluated when given a vla. */ ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value), @@ -4176,7 +4178,7 @@ c_expr_countof_expr (location_t loc, struct c_expr expr) C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands; SET_EXPR_LOCATION (ret.value, loc); } - pop_maybe_used (top_array_vla_p (TREE_TYPE (folded_expr))); + pop_maybe_used (top_array_vla_p (type)); } return ret; } -- 2.55.0 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From alx@kernel.org Sun Nov 1 22:47:40 2026 From: alx@kernel.org (Alejandro Colomar) Date: Sun, 1 Nov 2026 23:47:40 +0100 Subject: [PATCH 2/2] c: Add support for array parameters in _Countof In-Reply-To: References: Message-ID: <026b76ce72ec6c96c51d42039560480ecbd6ca40.1793572618.git.alx@kernel.org> As a GNU extension. I'll propose it for standardization, but first we'd need to make array parameters meaningful in the standard. This extension will allow using _Countof() in more places, reducing the chances of specifying an incorrect size accidentally. If an array parameter has a forward declaration, it is unspecified which of the lengths is taken. It is generally unwise to specify the length in the forward declarations, and it is even more unwise to specify it more than once. Currently, the implementation takes the length from the actual declaration, and if it doesn't specify the length, it won't compile. In the future, we want to improve this so that the length from a forward declaration is taken if the actual declaration lacks one. But that's more complex, so let's keep it as is for now. Link: gcc/ChangeLog: * doc/extend.texi (_Countof): Document this extension. gcc/c/ChangeLog: * c-typeck.cc (c_array_parm_orig_type): New function. (c_expr_countof_expr): Add support for array parameters. gcc/testsuite/ChangeLog: * gcc.dg/countof-compile.c (incomplete): Remove test. (param): Adapt test. * gcc.dg/countof-param-compile.c: New test. * gcc.dg/countof-param-pedantic.c: New test. * gcc.dg/countof-param.c: New test. Co-authored-by: Martin Uecker Signed-off-by: Alejandro Colomar --- gcc/c/c-typeck.cc | 31 ++++++ gcc/doc/extend.texi | 11 ++ gcc/testsuite/gcc.dg/countof-compile.c | 8 +- gcc/testsuite/gcc.dg/countof-param-compile.c | 104 ++++++++++++++++++ gcc/testsuite/gcc.dg/countof-param-pedantic.c | 11 ++ gcc/testsuite/gcc.dg/countof-param.c | 25 +++++ 6 files changed, 183 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/countof-param-compile.c create mode 100644 gcc/testsuite/gcc.dg/countof-param-pedantic.c create mode 100644 gcc/testsuite/gcc.dg/countof-param.c diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 61abace966da..b624b804ffd1 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -4142,6 +4142,26 @@ top_array_vla_p (const_tree type) || TREE_CODE (TYPE_MIN_VALUE (d)) != INTEGER_CST; } + +tree +c_array_parm_orig_type (tree expr) +{ + gcc_assert (POINTER_TYPE_P (TREE_TYPE (expr))); + + if (TREE_CODE (expr) == PARM_DECL + && C_ARRAY_PARAMETER (expr)) + { + if (tree attr = lookup_attribute ("arg spec", DECL_ATTRIBUTES (expr))) + { + tree arg = TREE_CHAIN (TREE_VALUE (attr)); + if (arg) + return TREE_VALUE (arg); + } + } + + return NULL_TREE; +} + /* Return the result of countof applied to EXPR. */ struct c_expr @@ -4168,6 +4188,17 @@ c_expr_countof_expr (location_t loc, struct c_expr expr) tree folded_expr = c_fully_fold (expr.value, require_constant_value, &expr_const_operands); tree type = TREE_TYPE (folded_expr); + if (POINTER_TYPE_P (type)) + { + if (tree t = c_array_parm_orig_type (expr.value)) + { + pedwarn (input_location, OPT_Wpedantic, + "ISO C does not support array parameters in %qs", + "_Countof"); + type = t; + } + } + ret.value = c_countof_type (loc, type); if (top_array_vla_p (type)) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 961fa27ba0eb..1016b474565a 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -14377,6 +14377,17 @@ _Countof (int [7][n++]); // integer constant expression _Countof (int [n++][7]); // run-time value; n++ is evaluated @end smallexample +It also works with array parameters. +For example: + +@smallexample +void +f (int n, int a[n]) +@{ + assert(n == _Countof(a)); +@} +@end smallexample + @node _Maxof and _Minof @subsection The maximum and minimum representable values of a type @findex _Maxof diff --git a/gcc/testsuite/gcc.dg/countof-compile.c b/gcc/testsuite/gcc.dg/countof-compile.c index ebbac16ed38d..d992dd8de0ee 100644 --- a/gcc/testsuite/gcc.dg/countof-compile.c +++ b/gcc/testsuite/gcc.dg/countof-compile.c @@ -21,10 +21,6 @@ void incomplete (int p[]) { _Countof (x); /* { dg-error "incomplete" } */ - - /* We want to support array parameters in the future, - which should change this from "invalid" to "incomplete". */ - _Countof (p); /* { dg-error "invalid" } */ } void @@ -41,9 +37,7 @@ fam (void) void param (int n, int p[n]) { - /* We want to support array parameters in the future, - which would make this work. */ - _Countof (p); /* { dg-error "invalid" } */ + _Countof (p); /* { dg-error "ISO C does not support array parameters" } */ } void fix_fix (int i, char (*a)[3][5], int (*x)[_Countof (*a)], diff --git a/gcc/testsuite/gcc.dg/countof-param-compile.c b/gcc/testsuite/gcc.dg/countof-param-compile.c new file mode 100644 index 000000000000..802168a04114 --- /dev/null +++ b/gcc/testsuite/gcc.dg/countof-param-compile.c @@ -0,0 +1,104 @@ +/* { dg-do compile } */ +/* { dg-options "-Wvla-parameter -Warray-parameter=2" } */ + +#define NULL ((void *) 0) + +int f1 (int , int a[2]) { return _Countof (a); } +int f2 (int n, int a[n]) { return _Countof (a); } +int f3 (int , int a[*]) { return _Countof (a); } /* { dg-error "not allowed in other than function prototype scope" } */ +int f4 (int , int a[ ]) { return _Countof (a); } /* { dg-error "incomplete" } */ +int f5 (int , int *a) { return _Countof (a); } /* { dg-error "invalid" } */ + +int g1 (int , int a[2], int b[_Countof (a)]); +int g2 (int n, int a[n], int b[_Countof (a)]); +int g3 (int , int a[*], int b[_Countof (a)]); + +int g1 (int , int a[2], int b[_Countof (a)]) { return _Countof (b); } +int g2 (int n, int a[n], int b[_Countof (a)]) { return _Countof (b); } +int g3 (int , int a[*], int b[_Countof (a)]) { return _Countof (b); } /* { dg-error "not allowed in other than function prototype scope" } */ + +int h1 (int , int a[2], int b[(_Static_assert (_Countof (a) == 2), 7)]); +int h2 (int n, int a[n], int b[(_Static_assert (_Countof (a) == 2), 7)]); /* { dg-error "expression in static assertion is not constant" } */ +int h3 (int , int a[*], int b[(_Static_assert (_Countof (a) == 2), 7)]); /* { dg-error "expression in static assertion is not constant" } */ + +void +decay_obvious (int a[2]) +{ + _Countof (typeof (a)); /* { dg-error "invalid" } */ + _Countof (a + 1); /* { dg-error "invalid" } */ + _Countof (42 ? NULL : a); /* { dg-error "invalid" } */ + _Countof (a + 0); /* { dg-error "invalid" } */ + _Countof (&*a); /* { dg-error "invalid" } */ + _Countof (42, a); /* { dg-error "invalid" } */ + _Countof (42 ? a : a); /* { dg-error "invalid" } */ + _Countof (42 ? a : NULL); /* { dg-error "invalid" } */ + + int *p = a; + + _Countof (p); /* { dg-error "invalid" } */ + + typeof(a) a2; + + _Countof (a2); /* { dg-error "invalid" } */ +} + +void +no_decay_obvious (int a[2]) +{ + _Static_assert (2 == _Countof (a)); + _Static_assert (2 == _Countof (*&a)); + _Static_assert (2 == _Countof (*(&a + 0))); +} + +/* It would not decay if it were an array, but being a parameter, it decays. */ +void +decay_surprising (int a[2]) +{ + _Countof (*(&a + 1)); /* { dg-error "invalid" } */ +} + +/* We should warn: . */ +void +non_const (int a[2]) +{ + a++; + _Countof (a); +} + +void +fwd_a_first (char a[6]; char a[]) +{ + _Countof (a); /* { dg-error "incomplete" } */ + // FIXME: This should pass: + //_Static_assert (_Countof (a) == 6); +} + +void +fwd_ap_first (char (*a)[6]; char (*a)[]) +{ + _Static_assert (_Countof (*a) == 6); +} + +void +fwd_a_second (char a[]; char a[7]) +{ + _Static_assert (_Countof (a) == 7); +} + +void +fwd_ap_second (char (*a)[]; char (*a)[7]) +{ + _Static_assert (_Countof (*a) == 7); +} + +void +fwd_a_both (char a[6]; char a[7]) +{ + _Static_assert (_Countof (a) == 6 || _Countof (a) == 7); +} + +void +fwd_ap_both (char (*a)[6]; char (*a)[6]) +{ + _Static_assert (_Countof (*a) == 6); +} diff --git a/gcc/testsuite/gcc.dg/countof-param-pedantic.c b/gcc/testsuite/gcc.dg/countof-param-pedantic.c new file mode 100644 index 000000000000..7d52f27a72bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/countof-param-pedantic.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c2y -pedantic" } */ + +#include + +int +f (int a[1]) +{ + countof(a); /* { dg-warning "ISO C does not support array parameters" } */ + _Countof(a); /* { dg-warning "ISO C does not support array parameters" } */ +} diff --git a/gcc/testsuite/gcc.dg/countof-param.c b/gcc/testsuite/gcc.dg/countof-param.c new file mode 100644 index 000000000000..e03f8b9389db --- /dev/null +++ b/gcc/testsuite/gcc.dg/countof-param.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-Wvla-parameter -Warray-parameter=2" } */ + +#define assert(e) ((e) ? (void) 0 : __builtin_abort ()) + +int f1 (int , int a[3]) { return _Countof(a); } +int f2 (int , int a[2]) { return _Countof(a); } + +int f1 (int , int a[2]); /* { dg-warning "with mismatched bound" } */ +int f2 (int n, int a[n]); /* { dg-warning "declared as a variable length array" } */ + +int g1 (int , int a[3]); +int g2 (int , int a[2]); + +int g1 (int , int a[2]) { return _Countof(a); } // { dg-warning "with mismatched bound" } */ +int g2 (int n, int a[n]) { return _Countof(a); } // { dg-warning "declared as a variable length array" } */ + +int +main (void) +{ + assert (3 == f1 (42, (int [42]){})); + assert (2 == f2 (42, (int [42]){})); + assert (2 == g1 (42, (int [42]){})); + assert (42 == g2 (42, (int [42]){})); +} -- 2.55.0 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From alx@kernel.org Sun Nov 1 22:54:02 2026 From: alx@kernel.org (Alejandro Colomar) Date: Sun, 1 Nov 2026 23:54:02 +0100 Subject: [PATCH 0/2] c: Add support for array parameters in _Countof In-Reply-To: References: Message-ID: > To: gcc-patches@gcc.gnu.org, gcc-patches@gcc-gnu.org Oops, I miswrote the address; thankfully, the git configuration picked the good one too. Please drop the bad address when replying. Cheers, Alex > Date: 2026-11-01 23:47:32+0100 > From: Alejandro Colomar > > Hi, > > Changes in v7 compared to v5 (v6 never existed): > > - Add tests to make sure that _Countof() works reasonably well with > forward declarations of array parameters. > - Rebase on top of master. > > See the range-diff at the bottom. > > Joseph, as we agreed recently, I want to make _Countof() support array > parameters where the length is declared only in the forward declaration. > However, that seems non-trivial, so it might be interesting to do a > first release that doesn't yet compile for that. I've added tests to > make sure that it never produces UB, but rather just compiler errors or > reasonable behavior (one of the specified lengths). > > I think it would be interesting to release this feature already, because > it works decently well for most reasonable code. If we have this > feature already in GCC 17, then programs could start using this feature > in some (~5 for many projects) years from now, while delaying it until > we have better support for forward declarations could delay it by one or > two years, which would be bad for bounds safety in general. > > Do you think we could release this, with the acknowledgement that we > want to eventually fix the test which has a 'FIXME'? I plan to work on > that, but can't promise when I'll have it done. > > The current patch set is robust to be released, IMO. > > > Have a lovely night! > Alex > > > Alejandro Colomar (2): > c: Refactor implementation of _Countof > c: Add support for array parameters in _Countof > > gcc/c/c-typeck.cc | 45 +++++++- > gcc/doc/extend.texi | 11 ++ > gcc/testsuite/gcc.dg/countof-compile.c | 8 +- > gcc/testsuite/gcc.dg/countof-param-compile.c | 104 ++++++++++++++++++ > gcc/testsuite/gcc.dg/countof-param-pedantic.c | 11 ++ > gcc/testsuite/gcc.dg/countof-param.c | 25 +++++ > 6 files changed, 191 insertions(+), 13 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/countof-param-compile.c > create mode 100644 gcc/testsuite/gcc.dg/countof-param-pedantic.c > create mode 100644 gcc/testsuite/gcc.dg/countof-param.c > > Range-diff: > 1: 31191ae061c2 ! 1: 53c196b9667d c: Refactor implementation of _Countof() > @@ Metadata > Author: Alejandro Colomar > > ## Commit message ## > - c: Refactor implementation of _Countof() > + c: Refactor implementation of _Countof > > No changes intended. This refactor prepares the code so that a future > - patch extending the semantic of _Countof() will be smaller. > + patch extending the semantics of _Countof() will be smaller. > > gcc/c/ChangeLog: > > @@ gcc/c/c-typeck.cc: c_expr_countof_expr (location_t loc, struct c_expr expr) > - tree folded_expr = c_fully_fold (expr.value, require_constant_value, > - &expr_const_operands); > - ret.value = c_countof_type (loc, TREE_TYPE (folded_expr)); > -- c_last_sizeof_arg = expr.value; > -- c_last_sizeof_loc = loc; > + c_last_sizeof_arg = expr.value; > + c_last_sizeof_loc = loc; > ret.original_code = COUNTOF_EXPR; > ret.original_type = NULL; > ret.m_decimal = 0; > -- if (is_top_array_vla (TREE_TYPE (folded_expr))) > +- if (top_array_vla_p (TREE_TYPE (folded_expr))) > + > + tree folded_expr = c_fully_fold (expr.value, require_constant_value, > + &expr_const_operands); > -+ > + tree type = TREE_TYPE (folded_expr); > + ret.value = c_countof_type (loc, type); > -+ c_last_sizeof_arg = expr.value; > -+ c_last_sizeof_loc = loc; > + > -+ if (is_top_array_vla (type)) > ++ if (top_array_vla_p (type)) > { > /* countof is evaluated when given a vla. */ > ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value), > @@ gcc/c/c-typeck.cc: c_expr_countof_expr (location_t loc, struct c_expr expr) > C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands; > SET_EXPR_LOCATION (ret.value, loc); > } > -- pop_maybe_used (is_top_array_vla (TREE_TYPE (folded_expr))); > -+ pop_maybe_used (is_top_array_vla (type)); > +- pop_maybe_used (top_array_vla_p (TREE_TYPE (folded_expr))); > ++ pop_maybe_used (top_array_vla_p (type)); > } > return ret; > } > 2: b1ca7e6c7135 ! 2: 026b76ce72ec c: Add support for array parameters in _Countof > @@ Commit message > This extension will allow using _Countof() in more places, reducing the > chances of specifying an incorrect size accidentally. > > - We should eventually add -farray-parameters-are-const to make array > - parameters be implicitly const-qualified (similar to -Wwrite-strings). > + If an array parameter has a forward declaration, it is unspecified which > + of the lengths is taken. It is generally unwise to specify the length > + in the forward declarations, and it is even more unwise to specify it > + more than once. Currently, the implementation takes the length from > + the actual declaration, and if it doesn't specify the length, it won't > + compile. In the future, we want to improve this so that the length > + from a forward declaration is taken if the actual declaration lacks one. > + But that's more complex, so let's keep it as is for now. > > Link: > > @@ Commit message > Signed-off-by: Alejandro Colomar > > ## gcc/c/c-typeck.cc ## > -@@ gcc/c/c-typeck.cc: is_top_array_vla (tree type) > - return var; > +@@ gcc/c/c-typeck.cc: top_array_vla_p (const_tree type) > + || TREE_CODE (TYPE_MIN_VALUE (d)) != INTEGER_CST; > } > > + > @@ gcc/c/c-typeck.cc: is_top_array_vla (tree type) > > struct c_expr > @@ gcc/c/c-typeck.cc: c_expr_countof_expr (location_t loc, struct c_expr expr) > + tree folded_expr = c_fully_fold (expr.value, require_constant_value, > &expr_const_operands); > - > tree type = TREE_TYPE (folded_expr); > + if (POINTER_TYPE_P (type)) > + { > -+ if (tree rv = c_array_parm_orig_type (expr.value)) > ++ if (tree t = c_array_parm_orig_type (expr.value)) > + { > + pedwarn (input_location, OPT_Wpedantic, > + "ISO C does not support array parameters in %qs", > + "_Countof"); > -+ type = rv; > ++ type = t; > + } > + } > + > ret.value = c_countof_type (loc, type); > - c_last_sizeof_arg = expr.value; > - c_last_sizeof_loc = loc; > + > + if (top_array_vla_p (type)) > > ## gcc/doc/extend.texi ## > @@ gcc/doc/extend.texi: _Countof (int [7][n++]); // integer constant expression > @@ gcc/testsuite/gcc.dg/countof-param-compile.c (new) > +{ > + a++; > + _Countof (a); > ++} > ++ > ++void > ++fwd_a_first (char a[6]; char a[]) > ++{ > ++ _Countof (a); /* { dg-error "incomplete" } */ > ++ // FIXME: This should pass: > ++ //_Static_assert (_Countof (a) == 6); > ++} > ++ > ++void > ++fwd_ap_first (char (*a)[6]; char (*a)[]) > ++{ > ++ _Static_assert (_Countof (*a) == 6); > ++} > ++ > ++void > ++fwd_a_second (char a[]; char a[7]) > ++{ > ++ _Static_assert (_Countof (a) == 7); > ++} > ++ > ++void > ++fwd_ap_second (char (*a)[]; char (*a)[7]) > ++{ > ++ _Static_assert (_Countof (*a) == 7); > ++} > ++ > ++void > ++fwd_a_both (char a[6]; char a[7]) > ++{ > ++ _Static_assert (_Countof (a) == 6 || _Countof (a) == 7); > ++} > ++ > ++void > ++fwd_ap_both (char (*a)[6]; char (*a)[6]) > ++{ > ++ _Static_assert (_Countof (*a) == 6); > +} > > ## gcc/testsuite/gcc.dg/countof-param-pedantic.c (new) ## > > base-commit: a440b382e43203857de9195eb526c4a16f21ceb1 > -- > 2.55.0 > -- -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From pietro@sociotechnical.xyz Sun Nov 1 22:54:56 2026 From: pietro@sociotechnical.xyz (Pietro Monteiro) Date: Sun, 1 Nov 2026 17:54:56 -0500 Subject: [PATCH] libgcc: Update Makefile configure_deps Message-ID: <20261101225455.520999-2-pietro@sociotechnical.xyz> In r17-5270-gd58a2bf47606f0 config/mmap.m4 was added to libgcc/configure.ac. But Makefile configure_deps wasn't updated to track it. Add it so the file is tracked when maintainer mode is enabled. libgcc/ChangeLog: * Makefile.in (configure_deps): Depend on ../config/mmap.m4. Signed-off-by: Pietro Monteiro --- libgcc/Makefile.in | 1 + 1 file changed, 1 insertion(+) diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index 59df657e282..9d39d1a133c 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -168,6 +168,7 @@ configure_deps = \ $(srcdir)/../config/tls.m4 \ $(srcdir)/../config/toolexeclibdir.m4 \ $(srcdir)/../config/acx.m4 \ + $(srcdir)/../config/mmap.m4 \ $(srcdir)/../config/no-executables.m4 \ $(srcdir)/../config/lib-ld.m4 \ $(srcdir)/../config/override.m4 \ -- 2.56.0 From alx@kernel.org Sun Nov 1 22:57:15 2026 From: alx@kernel.org (Alejandro Colomar) Date: Sun, 1 Nov 2026 23:57:15 +0100 Subject: [PATCH v7 0/2] c: Add support for array parameters in _Countof In-Reply-To: References: Message-ID: [Resend, with correct address, and with 'v7' in the Subject line.] Hi, Changes in v7 compared to v5 (v6 never existed): - Add tests to make sure that _Countof() works reasonably well with forward declarations of array parameters. - Rebase on top of master. See the range-diff at the bottom. Joseph, as we agreed recently, I want to make _Countof() support array parameters where the length is declared only in the forward declaration. However, that seems non-trivial, so it might be interesting to do a first release that doesn't yet compile for that. I've added tests to make sure that it never produces UB, but rather just compiler errors or reasonable behavior (one of the specified lengths). I think it would be interesting to release this feature already, because it works decently well for most reasonable code. If we have this feature already in GCC 17, then programs could start using this feature in some (~5 for many projects) years from now, while delaying it until we have better support for forward declarations could delay it by one or two years, which would be bad for bounds safety in general. Do you think we could release this, with the acknowledgement that we want to eventually fix the test which has a 'FIXME'? I plan to work on that, but can't promise when I'll have it done. The current patch set is robust to be released, IMO. Have a lovely night! Alex Alejandro Colomar (2): c: Refactor implementation of _Countof c: Add support for array parameters in _Countof gcc/c/c-typeck.cc | 45 +++++++- gcc/doc/extend.texi | 11 ++ gcc/testsuite/gcc.dg/countof-compile.c | 8 +- gcc/testsuite/gcc.dg/countof-param-compile.c | 104 ++++++++++++++++++ gcc/testsuite/gcc.dg/countof-param-pedantic.c | 11 ++ gcc/testsuite/gcc.dg/countof-param.c | 25 +++++ 6 files changed, 191 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/countof-param-compile.c create mode 100644 gcc/testsuite/gcc.dg/countof-param-pedantic.c create mode 100644 gcc/testsuite/gcc.dg/countof-param.c Range-diff: 1: 31191ae061c2 ! 1: 53c196b9667d c: Refactor implementation of _Countof() @@ Metadata Author: Alejandro Colomar ## Commit message ## - c: Refactor implementation of _Countof() + c: Refactor implementation of _Countof No changes intended. This refactor prepares the code so that a future - patch extending the semantic of _Countof() will be smaller. + patch extending the semantics of _Countof() will be smaller. gcc/c/ChangeLog: @@ gcc/c/c-typeck.cc: c_expr_countof_expr (location_t loc, struct c_expr expr) - tree folded_expr = c_fully_fold (expr.value, require_constant_value, - &expr_const_operands); - ret.value = c_countof_type (loc, TREE_TYPE (folded_expr)); -- c_last_sizeof_arg = expr.value; -- c_last_sizeof_loc = loc; + c_last_sizeof_arg = expr.value; + c_last_sizeof_loc = loc; ret.original_code = COUNTOF_EXPR; ret.original_type = NULL; ret.m_decimal = 0; -- if (is_top_array_vla (TREE_TYPE (folded_expr))) +- if (top_array_vla_p (TREE_TYPE (folded_expr))) + + tree folded_expr = c_fully_fold (expr.value, require_constant_value, + &expr_const_operands); -+ + tree type = TREE_TYPE (folded_expr); + ret.value = c_countof_type (loc, type); -+ c_last_sizeof_arg = expr.value; -+ c_last_sizeof_loc = loc; + -+ if (is_top_array_vla (type)) ++ if (top_array_vla_p (type)) { /* countof is evaluated when given a vla. */ ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value), @@ gcc/c/c-typeck.cc: c_expr_countof_expr (location_t loc, struct c_expr expr) C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands; SET_EXPR_LOCATION (ret.value, loc); } -- pop_maybe_used (is_top_array_vla (TREE_TYPE (folded_expr))); -+ pop_maybe_used (is_top_array_vla (type)); +- pop_maybe_used (top_array_vla_p (TREE_TYPE (folded_expr))); ++ pop_maybe_used (top_array_vla_p (type)); } return ret; } 2: b1ca7e6c7135 ! 2: 026b76ce72ec c: Add support for array parameters in _Countof @@ Commit message This extension will allow using _Countof() in more places, reducing the chances of specifying an incorrect size accidentally. - We should eventually add -farray-parameters-are-const to make array - parameters be implicitly const-qualified (similar to -Wwrite-strings). + If an array parameter has a forward declaration, it is unspecified which + of the lengths is taken. It is generally unwise to specify the length + in the forward declarations, and it is even more unwise to specify it + more than once. Currently, the implementation takes the length from + the actual declaration, and if it doesn't specify the length, it won't + compile. In the future, we want to improve this so that the length + from a forward declaration is taken if the actual declaration lacks one. + But that's more complex, so let's keep it as is for now. Link: @@ Commit message Signed-off-by: Alejandro Colomar ## gcc/c/c-typeck.cc ## -@@ gcc/c/c-typeck.cc: is_top_array_vla (tree type) - return var; +@@ gcc/c/c-typeck.cc: top_array_vla_p (const_tree type) + || TREE_CODE (TYPE_MIN_VALUE (d)) != INTEGER_CST; } + @@ gcc/c/c-typeck.cc: is_top_array_vla (tree type) struct c_expr @@ gcc/c/c-typeck.cc: c_expr_countof_expr (location_t loc, struct c_expr expr) + tree folded_expr = c_fully_fold (expr.value, require_constant_value, &expr_const_operands); - tree type = TREE_TYPE (folded_expr); + if (POINTER_TYPE_P (type)) + { -+ if (tree rv = c_array_parm_orig_type (expr.value)) ++ if (tree t = c_array_parm_orig_type (expr.value)) + { + pedwarn (input_location, OPT_Wpedantic, + "ISO C does not support array parameters in %qs", + "_Countof"); -+ type = rv; ++ type = t; + } + } + ret.value = c_countof_type (loc, type); - c_last_sizeof_arg = expr.value; - c_last_sizeof_loc = loc; + + if (top_array_vla_p (type)) ## gcc/doc/extend.texi ## @@ gcc/doc/extend.texi: _Countof (int [7][n++]); // integer constant expression @@ gcc/testsuite/gcc.dg/countof-param-compile.c (new) +{ + a++; + _Countof (a); ++} ++ ++void ++fwd_a_first (char a[6]; char a[]) ++{ ++ _Countof (a); /* { dg-error "incomplete" } */ ++ // FIXME: This should pass: ++ //_Static_assert (_Countof (a) == 6); ++} ++ ++void ++fwd_ap_first (char (*a)[6]; char (*a)[]) ++{ ++ _Static_assert (_Countof (*a) == 6); ++} ++ ++void ++fwd_a_second (char a[]; char a[7]) ++{ ++ _Static_assert (_Countof (a) == 7); ++} ++ ++void ++fwd_ap_second (char (*a)[]; char (*a)[7]) ++{ ++ _Static_assert (_Countof (*a) == 7); ++} ++ ++void ++fwd_a_both (char a[6]; char a[7]) ++{ ++ _Static_assert (_Countof (a) == 6 || _Countof (a) == 7); ++} ++ ++void ++fwd_ap_both (char (*a)[6]; char (*a)[6]) ++{ ++ _Static_assert (_Countof (*a) == 6); +} ## gcc/testsuite/gcc.dg/countof-param-pedantic.c (new) ## base-commit: a440b382e43203857de9195eb526c4a16f21ceb1 -- 2.55.0 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From alx@kernel.org Sun Nov 1 22:57:18 2026 From: alx@kernel.org (Alejandro Colomar) Date: Sun, 1 Nov 2026 23:57:18 +0100 Subject: [PATCH v7 1/2] c: Refactor implementation of _Countof In-Reply-To: References: Message-ID: <53c196b9667daffb06e5fb7f42dcee3e8da83606.1793572618.git.alx@kernel.org> No changes intended. This refactor prepares the code so that a future patch extending the semantics of _Countof() will be smaller. gcc/c/ChangeLog: * c-typeck.cc (c_expr_countof_expr): Refactor. Co-authored-by: Martin Uecker Signed-off-by: Alejandro Colomar --- gcc/c/c-typeck.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 2d0200858331..61abace966da 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -4159,16 +4159,18 @@ c_expr_countof_expr (location_t loc, struct c_expr expr) else { bool expr_const_operands = true; - - tree folded_expr = c_fully_fold (expr.value, require_constant_value, - &expr_const_operands); - ret.value = c_countof_type (loc, TREE_TYPE (folded_expr)); c_last_sizeof_arg = expr.value; c_last_sizeof_loc = loc; ret.original_code = COUNTOF_EXPR; ret.original_type = NULL; ret.m_decimal = 0; - if (top_array_vla_p (TREE_TYPE (folded_expr))) + + tree folded_expr = c_fully_fold (expr.value, require_constant_value, + &expr_const_operands); + tree type = TREE_TYPE (folded_expr); + ret.value = c_countof_type (loc, type); + + if (top_array_vla_p (type)) { /* countof is evaluated when given a vla. */ ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value), @@ -4176,7 +4178,7 @@ c_expr_countof_expr (location_t loc, struct c_expr expr) C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands; SET_EXPR_LOCATION (ret.value, loc); } - pop_maybe_used (top_array_vla_p (TREE_TYPE (folded_expr))); + pop_maybe_used (top_array_vla_p (type)); } return ret; } -- 2.55.0 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From alx@kernel.org Sun Nov 1 22:57:22 2026 From: alx@kernel.org (Alejandro Colomar) Date: Sun, 1 Nov 2026 23:57:22 +0100 Subject: [PATCH v7 2/2] c: Add support for array parameters in _Countof In-Reply-To: References: Message-ID: <026b76ce72ec6c96c51d42039560480ecbd6ca40.1793572618.git.alx@kernel.org> As a GNU extension. I'll propose it for standardization, but first we'd need to make array parameters meaningful in the standard. This extension will allow using _Countof() in more places, reducing the chances of specifying an incorrect size accidentally. If an array parameter has a forward declaration, it is unspecified which of the lengths is taken. It is generally unwise to specify the length in the forward declarations, and it is even more unwise to specify it more than once. Currently, the implementation takes the length from the actual declaration, and if it doesn't specify the length, it won't compile. In the future, we want to improve this so that the length from a forward declaration is taken if the actual declaration lacks one. But that's more complex, so let's keep it as is for now. Link: gcc/ChangeLog: * doc/extend.texi (_Countof): Document this extension. gcc/c/ChangeLog: * c-typeck.cc (c_array_parm_orig_type): New function. (c_expr_countof_expr): Add support for array parameters. gcc/testsuite/ChangeLog: * gcc.dg/countof-compile.c (incomplete): Remove test. (param): Adapt test. * gcc.dg/countof-param-compile.c: New test. * gcc.dg/countof-param-pedantic.c: New test. * gcc.dg/countof-param.c: New test. Co-authored-by: Martin Uecker Signed-off-by: Alejandro Colomar --- gcc/c/c-typeck.cc | 31 ++++++ gcc/doc/extend.texi | 11 ++ gcc/testsuite/gcc.dg/countof-compile.c | 8 +- gcc/testsuite/gcc.dg/countof-param-compile.c | 104 ++++++++++++++++++ gcc/testsuite/gcc.dg/countof-param-pedantic.c | 11 ++ gcc/testsuite/gcc.dg/countof-param.c | 25 +++++ 6 files changed, 183 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/countof-param-compile.c create mode 100644 gcc/testsuite/gcc.dg/countof-param-pedantic.c create mode 100644 gcc/testsuite/gcc.dg/countof-param.c diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 61abace966da..b624b804ffd1 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -4142,6 +4142,26 @@ top_array_vla_p (const_tree type) || TREE_CODE (TYPE_MIN_VALUE (d)) != INTEGER_CST; } + +tree +c_array_parm_orig_type (tree expr) +{ + gcc_assert (POINTER_TYPE_P (TREE_TYPE (expr))); + + if (TREE_CODE (expr) == PARM_DECL + && C_ARRAY_PARAMETER (expr)) + { + if (tree attr = lookup_attribute ("arg spec", DECL_ATTRIBUTES (expr))) + { + tree arg = TREE_CHAIN (TREE_VALUE (attr)); + if (arg) + return TREE_VALUE (arg); + } + } + + return NULL_TREE; +} + /* Return the result of countof applied to EXPR. */ struct c_expr @@ -4168,6 +4188,17 @@ c_expr_countof_expr (location_t loc, struct c_expr expr) tree folded_expr = c_fully_fold (expr.value, require_constant_value, &expr_const_operands); tree type = TREE_TYPE (folded_expr); + if (POINTER_TYPE_P (type)) + { + if (tree t = c_array_parm_orig_type (expr.value)) + { + pedwarn (input_location, OPT_Wpedantic, + "ISO C does not support array parameters in %qs", + "_Countof"); + type = t; + } + } + ret.value = c_countof_type (loc, type); if (top_array_vla_p (type)) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 961fa27ba0eb..1016b474565a 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -14377,6 +14377,17 @@ _Countof (int [7][n++]); // integer constant expression _Countof (int [n++][7]); // run-time value; n++ is evaluated @end smallexample +It also works with array parameters. +For example: + +@smallexample +void +f (int n, int a[n]) +@{ + assert(n == _Countof(a)); +@} +@end smallexample + @node _Maxof and _Minof @subsection The maximum and minimum representable values of a type @findex _Maxof diff --git a/gcc/testsuite/gcc.dg/countof-compile.c b/gcc/testsuite/gcc.dg/countof-compile.c index ebbac16ed38d..d992dd8de0ee 100644 --- a/gcc/testsuite/gcc.dg/countof-compile.c +++ b/gcc/testsuite/gcc.dg/countof-compile.c @@ -21,10 +21,6 @@ void incomplete (int p[]) { _Countof (x); /* { dg-error "incomplete" } */ - - /* We want to support array parameters in the future, - which should change this from "invalid" to "incomplete". */ - _Countof (p); /* { dg-error "invalid" } */ } void @@ -41,9 +37,7 @@ fam (void) void param (int n, int p[n]) { - /* We want to support array parameters in the future, - which would make this work. */ - _Countof (p); /* { dg-error "invalid" } */ + _Countof (p); /* { dg-error "ISO C does not support array parameters" } */ } void fix_fix (int i, char (*a)[3][5], int (*x)[_Countof (*a)], diff --git a/gcc/testsuite/gcc.dg/countof-param-compile.c b/gcc/testsuite/gcc.dg/countof-param-compile.c new file mode 100644 index 000000000000..802168a04114 --- /dev/null +++ b/gcc/testsuite/gcc.dg/countof-param-compile.c @@ -0,0 +1,104 @@ +/* { dg-do compile } */ +/* { dg-options "-Wvla-parameter -Warray-parameter=2" } */ + +#define NULL ((void *) 0) + +int f1 (int , int a[2]) { return _Countof (a); } +int f2 (int n, int a[n]) { return _Countof (a); } +int f3 (int , int a[*]) { return _Countof (a); } /* { dg-error "not allowed in other than function prototype scope" } */ +int f4 (int , int a[ ]) { return _Countof (a); } /* { dg-error "incomplete" } */ +int f5 (int , int *a) { return _Countof (a); } /* { dg-error "invalid" } */ + +int g1 (int , int a[2], int b[_Countof (a)]); +int g2 (int n, int a[n], int b[_Countof (a)]); +int g3 (int , int a[*], int b[_Countof (a)]); + +int g1 (int , int a[2], int b[_Countof (a)]) { return _Countof (b); } +int g2 (int n, int a[n], int b[_Countof (a)]) { return _Countof (b); } +int g3 (int , int a[*], int b[_Countof (a)]) { return _Countof (b); } /* { dg-error "not allowed in other than function prototype scope" } */ + +int h1 (int , int a[2], int b[(_Static_assert (_Countof (a) == 2), 7)]); +int h2 (int n, int a[n], int b[(_Static_assert (_Countof (a) == 2), 7)]); /* { dg-error "expression in static assertion is not constant" } */ +int h3 (int , int a[*], int b[(_Static_assert (_Countof (a) == 2), 7)]); /* { dg-error "expression in static assertion is not constant" } */ + +void +decay_obvious (int a[2]) +{ + _Countof (typeof (a)); /* { dg-error "invalid" } */ + _Countof (a + 1); /* { dg-error "invalid" } */ + _Countof (42 ? NULL : a); /* { dg-error "invalid" } */ + _Countof (a + 0); /* { dg-error "invalid" } */ + _Countof (&*a); /* { dg-error "invalid" } */ + _Countof (42, a); /* { dg-error "invalid" } */ + _Countof (42 ? a : a); /* { dg-error "invalid" } */ + _Countof (42 ? a : NULL); /* { dg-error "invalid" } */ + + int *p = a; + + _Countof (p); /* { dg-error "invalid" } */ + + typeof(a) a2; + + _Countof (a2); /* { dg-error "invalid" } */ +} + +void +no_decay_obvious (int a[2]) +{ + _Static_assert (2 == _Countof (a)); + _Static_assert (2 == _Countof (*&a)); + _Static_assert (2 == _Countof (*(&a + 0))); +} + +/* It would not decay if it were an array, but being a parameter, it decays. */ +void +decay_surprising (int a[2]) +{ + _Countof (*(&a + 1)); /* { dg-error "invalid" } */ +} + +/* We should warn: . */ +void +non_const (int a[2]) +{ + a++; + _Countof (a); +} + +void +fwd_a_first (char a[6]; char a[]) +{ + _Countof (a); /* { dg-error "incomplete" } */ + // FIXME: This should pass: + //_Static_assert (_Countof (a) == 6); +} + +void +fwd_ap_first (char (*a)[6]; char (*a)[]) +{ + _Static_assert (_Countof (*a) == 6); +} + +void +fwd_a_second (char a[]; char a[7]) +{ + _Static_assert (_Countof (a) == 7); +} + +void +fwd_ap_second (char (*a)[]; char (*a)[7]) +{ + _Static_assert (_Countof (*a) == 7); +} + +void +fwd_a_both (char a[6]; char a[7]) +{ + _Static_assert (_Countof (a) == 6 || _Countof (a) == 7); +} + +void +fwd_ap_both (char (*a)[6]; char (*a)[6]) +{ + _Static_assert (_Countof (*a) == 6); +} diff --git a/gcc/testsuite/gcc.dg/countof-param-pedantic.c b/gcc/testsuite/gcc.dg/countof-param-pedantic.c new file mode 100644 index 000000000000..7d52f27a72bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/countof-param-pedantic.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c2y -pedantic" } */ + +#include + +int +f (int a[1]) +{ + countof(a); /* { dg-warning "ISO C does not support array parameters" } */ + _Countof(a); /* { dg-warning "ISO C does not support array parameters" } */ +} diff --git a/gcc/testsuite/gcc.dg/countof-param.c b/gcc/testsuite/gcc.dg/countof-param.c new file mode 100644 index 000000000000..e03f8b9389db --- /dev/null +++ b/gcc/testsuite/gcc.dg/countof-param.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-Wvla-parameter -Warray-parameter=2" } */ + +#define assert(e) ((e) ? (void) 0 : __builtin_abort ()) + +int f1 (int , int a[3]) { return _Countof(a); } +int f2 (int , int a[2]) { return _Countof(a); } + +int f1 (int , int a[2]); /* { dg-warning "with mismatched bound" } */ +int f2 (int n, int a[n]); /* { dg-warning "declared as a variable length array" } */ + +int g1 (int , int a[3]); +int g2 (int , int a[2]); + +int g1 (int , int a[2]) { return _Countof(a); } // { dg-warning "with mismatched bound" } */ +int g2 (int n, int a[n]) { return _Countof(a); } // { dg-warning "declared as a variable length array" } */ + +int +main (void) +{ + assert (3 == f1 (42, (int [42]){})); + assert (2 == f2 (42, (int [42]){})); + assert (2 == g1 (42, (int [42]){})); + assert (42 == g2 (42, (int [42]){})); +} -- 2.55.0 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From alx@kernel.org Sun Nov 1 23:00:39 2026 From: alx@kernel.org (Alejandro Colomar) Date: Mon, 2 Nov 2026 00:00:39 +0100 Subject: [PATCH v7 0/2] c: Add support for array parameters in _Countof In-Reply-To: References: Message-ID: > Date: 2026-11-01 23:57:15+0100 > From: Alejandro Colomar > > [Resend, with correct address, and with 'v7' in the Subject line.] > > Hi, > > Changes in v7 compared to v5 (v6 never existed): > > - Add tests to make sure that _Countof() works reasonably well with > forward declarations of array parameters. > - Rebase on top of master. > > See the range-diff at the bottom. > > Joseph, as we agreed recently, I want to make _Countof() support array > parameters where the length is declared only in the forward declaration. > However, that seems non-trivial, so it might be interesting to do a > first release that doesn't yet compile for that. I've added tests to > make sure that it never produces UB, but rather just compiler errors or > reasonable behavior (one of the specified lengths). > > I think it would be interesting to release this feature already, because > it works decently well for most reasonable code. If we have this > feature already in GCC 17, then programs could start using this feature > in some (~5 for many projects) years from now, while delaying it until > we have better support for forward declarations could delay it by one or > two years, which would be bad for bounds safety in general. > > Do you think we could release this, with the acknowledgement that we > want to eventually fix the test which has a 'FIXME'? I plan to work on > that, but can't promise when I'll have it done. > > The current patch set is robust to be released, IMO. Tests pass: alx@devuan:~/src/gnu/gcc/countof_ap$ git log --oneline master^..cap7 026b76ce72ec (HEAD -> countof_ap, tag: cap7) c: Add support for array parameters in _Countof 53c196b9667d c: Refactor implementation of _Countof 1892effc2f4b (gnu/trunk, gnu/master, gnu/HEAD, master) fortran: Use span indexing for polymorphic target dummies [PR127827] alx@devuan:~/src/gnu/gcc/countof_ap$ git reset master --h HEAD is now at 1892effc2f4b fortran: Use span indexing for polymorphic target dummies [PR127827] alx@devuan:~/src/gnu/gcc/countof_ap$ mkdir ../cap7 alx@devuan:~/src/gnu/gcc/countof_ap$ cd ../cap7/ alx@devuan:~/src/gnu/gcc/cap7$ set -o pipefail alx@devuan:~/src/gnu/gcc/cap7$ ../countof_ap/configure --disable-multilib --prefix=/opt/local/gnu/gcc/cap7 |& ts -s | tail -n1; echo $?; make -j24 bootstrap |& ts -s | tail -n1; echo $?; make -j24 check |& ts -s | tail -n1; echo $?; 00:00:01 config.status: creating Makefile 0 00:22:03 make[1]: Leaving directory '/srv/alx/src/gnu/gcc/cap7' 0 00:43:40 make[1]: Leaving directory '/srv/alx/src/gnu/gcc/cap7' 0 alx@devuan:~/src/gnu/gcc/cap7$ cd ../countof_ap/ alx@devuan:~/src/gnu/gcc/countof_ap$ git merge --ff-only cap7 Updating 1892effc2f4b..026b76ce72ec Fast-forward gcc/c/c-typeck.cc | 45 +++++++- gcc/doc/extend.texi | 11 ++ gcc/testsuite/gcc.dg/countof-compile.c | 8 +- gcc/testsuite/gcc.dg/countof-param-compile.c | 104 ++++++++++++++++++ gcc/testsuite/gcc.dg/countof-param-pedantic.c | 11 ++ gcc/testsuite/gcc.dg/countof-param.c | 25 +++++ 6 files changed, 191 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/countof-param-compile.c create mode 100644 gcc/testsuite/gcc.dg/countof-param-pedantic.c create mode 100644 gcc/testsuite/gcc.dg/countof-param.c alx@devuan:~/src/gnu/gcc/countof_ap$ cd ../ alx@devuan:~/src/gnu/gcc$ mv cap7/ cap7_b4 alx@devuan:~/src/gnu/gcc$ mkdir cap7 alx@devuan:~/src/gnu/gcc$ cd cap7 alx@devuan:~/src/gnu/gcc/cap7$ ../countof_ap/configure --disable-multilib --prefix=/opt/local/gnu/gcc/cap7 |& ts -s | tail -n1; echo $?; make -j24 bootstrap |& ts -s | tail -n1; echo $?; make -j24 check |& ts -s | tail -n1; echo $?; 00:00:02 config.status: creating Makefile 0 00:21:55 make[1]: Leaving directory '/srv/alx/src/gnu/gcc/cap7' 0 00:43:59 make[1]: Leaving directory '/srv/alx/src/gnu/gcc/cap7' 0 alx@devuan:~/src/gnu/gcc/cap7$ find -type f | grep '\.sum$' | while read f; do diff -u "../cap7_b4/$f" "$f"; done; --- ../cap7_b4/./x86_64-pc-linux-gnu/libitm/testsuite/libitm.sum 2026-11-01 21:05:38.712249381 +0100 +++ ./x86_64-pc-linux-gnu/libitm/testsuite/libitm.sum 2026-11-01 22:36:53.892865284 +0100 @@ -1,4 +1,4 @@ -Test run by alx on Sun Nov 1 21:05:35 2026 +Test run by alx on Sun Nov 1 22:36:50 2026 Native configuration is x86_64-pc-linux-gnu === libitm tests === --- ../cap7_b4/./x86_64-pc-linux-gnu/libatomic/testsuite/libatomic.sum 2026-11-01 21:05:37.423006904 +0100 +++ ./x86_64-pc-linux-gnu/libatomic/testsuite/libatomic.sum 2026-11-01 22:36:52.290750836 +0100 @@ -1,4 +1,4 @@ -Test run by alx on Sun Nov 1 21:05:35 2026 +Test run by alx on Sun Nov 1 22:36:50 2026 Native configuration is x86_64-pc-linux-gnu === libatomic tests === --- ../cap7_b4/./x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.sum 2026-11-01 21:07:57.973840085 +0100 +++ ./x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.sum 2026-11-01 22:39:22.971716165 +0100 @@ -1,4 +1,4 @@ -Test run by alx on Sun Nov 1 21:05:35 2026 +Test run by alx on Sun Nov 1 22:36:50 2026 Native configuration is x86_64-pc-linux-gnu === libgomp tests === --- ../cap7_b4/./x86_64-pc-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum 2026-11-01 21:49:15.263253088 +0100 +++ ./x86_64-pc-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum 2026-11-01 23:20:49.595924539 +0100 @@ -1,4 +1,4 @@ -Test run by alx on Sun Nov 1 21:05:37 2026 +Test run by alx on Sun Nov 1 22:36:52 2026 Native configuration is x86_64-pc-linux-gnu === libstdc++ tests === --- ../cap7_b4/./gcc/testsuite/objc/objc.sum 2026-11-01 21:06:57.013057336 +0100 +++ ./gcc/testsuite/objc/objc.sum 2026-11-01 22:37:36.806268067 +0100 @@ -1,4 +1,4 @@ -Test run by alx on Sun Nov 1 21:05:39 2026 +Test run by alx on Sun Nov 1 22:36:51 2026 Native configuration is x86_64-pc-linux-gnu === objc tests === --- ../cap7_b4/./gcc/testsuite/g++/g++.sum 2026-11-01 21:24:18.393431841 +0100 +++ ./gcc/testsuite/g++/g++.sum 2026-11-01 22:55:10.418300316 +0100 @@ -1,4 +1,4 @@ -Test run by alx on Sun Nov 1 21:05:36 2026 +Test run by alx on Sun Nov 1 22:36:51 2026 Native configuration is x86_64-pc-linux-gnu === g++ tests === --- ../cap7_b4/./gcc/testsuite/gcc/gcc.sum 2026-11-01 21:30:36.935589250 +0100 +++ ./gcc/testsuite/gcc/gcc.sum 2026-11-01 23:01:22.972017943 +0100 @@ -1,4 +1,4 @@ -Test run by alx on Sun Nov 1 21:05:36 2026 +Test run by alx on Sun Nov 1 22:36:51 2026 Native configuration is x86_64-pc-linux-gnu === gcc tests === @@ -91657,27 +91657,54 @@ PASS: gcc.dg/counted-by-unary.c execution test PASS: gcc.dg/countof-compat.c (test for warnings, line 8) PASS: gcc.dg/countof-compat.c (test for excess errors) -PASS: gcc.dg/countof-compile.c (test for errors, line 114) -PASS: gcc.dg/countof-compile.c (test for errors, line 123) +PASS: gcc.dg/countof-compile.c (test for errors, line 108) +PASS: gcc.dg/countof-compile.c (test for errors, line 117) PASS: gcc.dg/countof-compile.c (test for errors, line 23) -PASS: gcc.dg/countof-compile.c (test for errors, line 27) -PASS: gcc.dg/countof-compile.c (test for errors, line 38) -PASS: gcc.dg/countof-compile.c (test for errors, line 46) +PASS: gcc.dg/countof-compile.c (test for errors, line 34) +PASS: gcc.dg/countof-compile.c (test for errors, line 40) +PASS: gcc.dg/countof-compile.c (test for errors, line 58) +PASS: gcc.dg/countof-compile.c (test for errors, line 61) PASS: gcc.dg/countof-compile.c (test for errors, line 64) -PASS: gcc.dg/countof-compile.c (test for errors, line 67) -PASS: gcc.dg/countof-compile.c (test for errors, line 70) +PASS: gcc.dg/countof-compile.c (test for errors, line 76) +PASS: gcc.dg/countof-compile.c (test for errors, line 77) +PASS: gcc.dg/countof-compile.c (test for errors, line 78) +PASS: gcc.dg/countof-compile.c (test for errors, line 79) +PASS: gcc.dg/countof-compile.c (test for errors, line 80) +PASS: gcc.dg/countof-compile.c (test for errors, line 81) PASS: gcc.dg/countof-compile.c (test for errors, line 82) PASS: gcc.dg/countof-compile.c (test for errors, line 83) PASS: gcc.dg/countof-compile.c (test for errors, line 84) -PASS: gcc.dg/countof-compile.c (test for errors, line 85) -PASS: gcc.dg/countof-compile.c (test for errors, line 86) -PASS: gcc.dg/countof-compile.c (test for errors, line 87) PASS: gcc.dg/countof-compile.c (test for errors, line 88) -PASS: gcc.dg/countof-compile.c (test for errors, line 89) -PASS: gcc.dg/countof-compile.c (test for errors, line 90) -PASS: gcc.dg/countof-compile.c (test for errors, line 94) PASS: gcc.dg/countof-compile.c (test for excess errors) PASS: gcc.dg/countof-no-compat.c (test for excess errors) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 10) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 18) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 21) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 22) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 27) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 28) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 29) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 30) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 31) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 32) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 33) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 34) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 38) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 42) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 57) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 71) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 8) +PASS: gcc.dg/countof-param-compile.c (test for errors, line 9) +PASS: gcc.dg/countof-param-compile.c (test for excess errors) +PASS: gcc.dg/countof-param-pedantic.c (test for warnings, line 10) +PASS: gcc.dg/countof-param-pedantic.c (test for warnings, line 9) +PASS: gcc.dg/countof-param-pedantic.c (test for excess errors) +PASS: gcc.dg/countof-param.c (test for warnings, line 10) +PASS: gcc.dg/countof-param.c (test for warnings, line 15) +PASS: gcc.dg/countof-param.c (test for warnings, line 16) +PASS: gcc.dg/countof-param.c (test for warnings, line 9) +PASS: gcc.dg/countof-param.c (test for excess errors) +PASS: gcc.dg/countof-param.c execution test PASS: gcc.dg/countof-pedantic-errors.c (test for errors, line 8) PASS: gcc.dg/countof-pedantic-errors.c (test for excess errors) PASS: gcc.dg/countof-pedantic.c (test for warnings, line 8) @@ -237510,7 +237537,7 @@ === gcc Summary === -# of expected passes 231295 +# of expected passes 231322 # of unexpected failures 86 # of unexpected successes 24 # of expected failures 1657 --- ../cap7_b4/./gcc/testsuite/gfortran/gfortran.sum 2026-11-01 21:21:38.542879775 +0100 +++ ./gcc/testsuite/gfortran/gfortran.sum 2026-11-01 22:51:49.534122387 +0100 @@ -1,4 +1,4 @@ -Test run by alx on Sun Nov 1 21:05:36 2026 +Test run by alx on Sun Nov 1 22:36:51 2026 Native configuration is x86_64-pc-linux-gnu === gfortran tests === Cheers, Alex > > > Have a lovely night! > Alex > > > Alejandro Colomar (2): > c: Refactor implementation of _Countof > c: Add support for array parameters in _Countof > > gcc/c/c-typeck.cc | 45 +++++++- > gcc/doc/extend.texi | 11 ++ > gcc/testsuite/gcc.dg/countof-compile.c | 8 +- > gcc/testsuite/gcc.dg/countof-param-compile.c | 104 ++++++++++++++++++ > gcc/testsuite/gcc.dg/countof-param-pedantic.c | 11 ++ > gcc/testsuite/gcc.dg/countof-param.c | 25 +++++ > 6 files changed, 191 insertions(+), 13 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/countof-param-compile.c > create mode 100644 gcc/testsuite/gcc.dg/countof-param-pedantic.c > create mode 100644 gcc/testsuite/gcc.dg/countof-param.c > > Range-diff: > 1: 31191ae061c2 ! 1: 53c196b9667d c: Refactor implementation of _Countof() > @@ Metadata > Author: Alejandro Colomar > > ## Commit message ## > - c: Refactor implementation of _Countof() > + c: Refactor implementation of _Countof > > No changes intended. This refactor prepares the code so that a future > - patch extending the semantic of _Countof() will be smaller. > + patch extending the semantics of _Countof() will be smaller. > > gcc/c/ChangeLog: > > @@ gcc/c/c-typeck.cc: c_expr_countof_expr (location_t loc, struct c_expr expr) > - tree folded_expr = c_fully_fold (expr.value, require_constant_value, > - &expr_const_operands); > - ret.value = c_countof_type (loc, TREE_TYPE (folded_expr)); > -- c_last_sizeof_arg = expr.value; > -- c_last_sizeof_loc = loc; > + c_last_sizeof_arg = expr.value; > + c_last_sizeof_loc = loc; > ret.original_code = COUNTOF_EXPR; > ret.original_type = NULL; > ret.m_decimal = 0; > -- if (is_top_array_vla (TREE_TYPE (folded_expr))) > +- if (top_array_vla_p (TREE_TYPE (folded_expr))) > + > + tree folded_expr = c_fully_fold (expr.value, require_constant_value, > + &expr_const_operands); > -+ > + tree type = TREE_TYPE (folded_expr); > + ret.value = c_countof_type (loc, type); > -+ c_last_sizeof_arg = expr.value; > -+ c_last_sizeof_loc = loc; > + > -+ if (is_top_array_vla (type)) > ++ if (top_array_vla_p (type)) > { > /* countof is evaluated when given a vla. */ > ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value), > @@ gcc/c/c-typeck.cc: c_expr_countof_expr (location_t loc, struct c_expr expr) > C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands; > SET_EXPR_LOCATION (ret.value, loc); > } > -- pop_maybe_used (is_top_array_vla (TREE_TYPE (folded_expr))); > -+ pop_maybe_used (is_top_array_vla (type)); > +- pop_maybe_used (top_array_vla_p (TREE_TYPE (folded_expr))); > ++ pop_maybe_used (top_array_vla_p (type)); > } > return ret; > } > 2: b1ca7e6c7135 ! 2: 026b76ce72ec c: Add support for array parameters in _Countof > @@ Commit message > This extension will allow using _Countof() in more places, reducing the > chances of specifying an incorrect size accidentally. > > - We should eventually add -farray-parameters-are-const to make array > - parameters be implicitly const-qualified (similar to -Wwrite-strings). > + If an array parameter has a forward declaration, it is unspecified which > + of the lengths is taken. It is generally unwise to specify the length > + in the forward declarations, and it is even more unwise to specify it > + more than once. Currently, the implementation takes the length from > + the actual declaration, and if it doesn't specify the length, it won't > + compile. In the future, we want to improve this so that the length > + from a forward declaration is taken if the actual declaration lacks one. > + But that's more complex, so let's keep it as is for now. > > Link: > > @@ Commit message > Signed-off-by: Alejandro Colomar > > ## gcc/c/c-typeck.cc ## > -@@ gcc/c/c-typeck.cc: is_top_array_vla (tree type) > - return var; > +@@ gcc/c/c-typeck.cc: top_array_vla_p (const_tree type) > + || TREE_CODE (TYPE_MIN_VALUE (d)) != INTEGER_CST; > } > > + > @@ gcc/c/c-typeck.cc: is_top_array_vla (tree type) > > struct c_expr > @@ gcc/c/c-typeck.cc: c_expr_countof_expr (location_t loc, struct c_expr expr) > + tree folded_expr = c_fully_fold (expr.value, require_constant_value, > &expr_const_operands); > - > tree type = TREE_TYPE (folded_expr); > + if (POINTER_TYPE_P (type)) > + { > -+ if (tree rv = c_array_parm_orig_type (expr.value)) > ++ if (tree t = c_array_parm_orig_type (expr.value)) > + { > + pedwarn (input_location, OPT_Wpedantic, > + "ISO C does not support array parameters in %qs", > + "_Countof"); > -+ type = rv; > ++ type = t; > + } > + } > + > ret.value = c_countof_type (loc, type); > - c_last_sizeof_arg = expr.value; > - c_last_sizeof_loc = loc; > + > + if (top_array_vla_p (type)) > > ## gcc/doc/extend.texi ## > @@ gcc/doc/extend.texi: _Countof (int [7][n++]); // integer constant expression > @@ gcc/testsuite/gcc.dg/countof-param-compile.c (new) > +{ > + a++; > + _Countof (a); > ++} > ++ > ++void > ++fwd_a_first (char a[6]; char a[]) > ++{ > ++ _Countof (a); /* { dg-error "incomplete" } */ > ++ // FIXME: This should pass: > ++ //_Static_assert (_Countof (a) == 6); > ++} > ++ > ++void > ++fwd_ap_first (char (*a)[6]; char (*a)[]) > ++{ > ++ _Static_assert (_Countof (*a) == 6); > ++} > ++ > ++void > ++fwd_a_second (char a[]; char a[7]) > ++{ > ++ _Static_assert (_Countof (a) == 7); > ++} > ++ > ++void > ++fwd_ap_second (char (*a)[]; char (*a)[7]) > ++{ > ++ _Static_assert (_Countof (*a) == 7); > ++} > ++ > ++void > ++fwd_a_both (char a[6]; char a[7]) > ++{ > ++ _Static_assert (_Countof (a) == 6 || _Countof (a) == 7); > ++} > ++ > ++void > ++fwd_ap_both (char (*a)[6]; char (*a)[6]) > ++{ > ++ _Static_assert (_Countof (*a) == 6); > +} > > ## gcc/testsuite/gcc.dg/countof-param-pedantic.c (new) ## > > base-commit: a440b382e43203857de9195eb526c4a16f21ceb1 > -- > 2.55.0 > -- -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From jvdelisle2@gmail.com Mon Nov 2 00:34:41 2026 From: jvdelisle2@gmail.com (Jerry D) Date: Sun, 1 Nov 2026 16:34:41 -0800 Subject: [PATCH] libgfortran: [PR127893] Look up cached units without the unit rwlock Message-ID: Hi all, See the attached patch. The bugzilla comments show the testing results form this change. This brought back some memories from doing the initial unit caching. It makes sense to avoid using locks when not necessary. It has been tested on Mac M4 iOS and x86_64-linux. I also tested this in an ARM container running under qemu. Regression tested. OK for mainline? Regards, Jerry --- libgfortran: [PR127893] Look up cached units without the unit rwlock Every data transfer statement takes unit_rwlock in get_gfc_unit, even when each thread does I/O on its own unit. On Darwin the rwlock thrashes under that load, so parallel I/O on separate units became many times slower than with the mutex used before r14-6425. The unit cache could not be read without unit_rwlock because closing a unit freed it, so a pointer read from the cache could dangle. Keep closed units on a free list for reuse and free them only at program exit, so a cached pointer always refers to a gfc_unit. Make the cache a direct-mapped table of 64 slots accessed atomically. get_gfc_unit and check_for_recursive trylock the cached unit and use it only if, with its lock held, it is open with the expected number; otherwise they fall back to the tree lookup under unit_rwlock. check_for_recursive now holds unit_rwlock while it searches the tree, and find_file takes it for writing before recycling a closed unit. Assisted-by: Claude Opus 5.5 PR libfortran/127893 libgfortran/ChangeLog: * io/io.h (recycle_unit): Declare. * io/unit.c (CACHE_SIZE): Increase to 64. (CACHE_SLOT): New macro. (unit_free_list): New variable. (insert_unit): Reuse a unit from the free list. (recycle_unit, probe_unit_cache, set_unit_cache): New functions. (check_for_recursive): Probe the unit cache first. Hold unit_rwlock while searching the unit tree. (get_gfc_unit): Probe the unit cache before taking unit_rwlock. Use the direct-mapped cache. Recycle a closed unit instead of freeing it. (close_unit_1): Clear the unit's cache slot. Recycle the unit instead of freeing it. (close_units): Free the units on the free list. * io/unix.c (find_file): Take unit_rwlock for writing and recycle a closed unit instead of freeing it. (flush_all_units): Recycle a closed unit instead of freeing it. libgomp/ChangeLog: * testsuite/libgomp.fortran/unit-cache-1.f90: New test. --- -------------- next part -------------- A non-text attachment was scrubbed... Name: PR127893-unit-cache-lockless-lookup.patch Type: text/x-patch Size: 15080 bytes Desc: not available URL: From stevebezalel215@gmail.com Mon Nov 2 01:13:55 2026 From: stevebezalel215@gmail.com (Steve Bezalel) Date: Mon, 2 Nov 2026 01:13:55 +0000 Subject: [PATCH] tree-optimization/127211 - Reset SCEV after predcom without unrolling In-Reply-To: References: Message-ID: <20261102011355.13576-1-stevebezalel215@gmail.com> On Thu, Oct 30, 2026, Richard Biener wrote: > OK. Thanks for the review! I don't have write access, so could you or someone else please push this for me? The patch still applies to current trunk. Thanks, Steve From rdsandiford@googlemail.com Mon Nov 2 01:28:25 2026 From: rdsandiford@googlemail.com (Richard Sandiford) Date: Mon, 2 Nov 2026 10:28:25 +0900 Subject: [PATCH] aarch64: Use optimistic worklist analysis for narrow_gp_writes In-Reply-To: References: <4F724ED5-EA27-4286-A6E1-B4FBDFAC0491@nvidia.com> <87o6d1vqlt.fsf@googlemail.com> Message-ID: On Tue, 27 Oct 2026 at 04:19, Soumya AR wrote: > On on Sat, 10 Oct 2026 10:42:38 +0100, Richard Sandiford wrote: > > How about handling this as follows: > > > > (1) Remove the initial_defs argument from def_propagation::propagate. > > > > (2) Instead, make the first pass of def_propagation::propagate > > iterate over all definitions itself. Like the existing loop, > > this would involve calling process_def, but it would only enqueue > > uses that occur earlier than the current instruction. (Later uses > > will be processed later in the first pass.) > > Done. propagate now takes just the client and walks the EBBs in RPO > itself. > > I think this should also mean that we only need to look at phi uses > during the first pass since all regular nondebug insn uses for a def > would occur after it anyway. I've written it that way in the updated > patch. Yeah, agreed. > > (3) Expose can_track_nonzero_bits_p to def_propagation with an > > appropriate abstraction (e.g. can_process_insn_p, but better > > names welcome). Use it to skip processing of instructions in (2). > > > > Ended up with can_process_insn_p. I assume we still need > can_process_def_p though, so there are three callbacks now. Yeah, we still need can_process_def_p. But I think we should require the propagation engine to check can_process_insn_p before can_process_def_p, so that can_process_def_p does not call can_process_insn_p itself. AFAICT that's already the case as far as the engine goes (since the client always has to process phis). > > (4) Add a new parameter to process_def that indicates whether it is > > being called during the first pass. > > > > (5) Treat backedges optimistically on the first pass. This would only > > affect calculate_phi_mask. > > > > (6) Similarly, make process_def assume that the definition's current > > mask is 0 rather than GET_MODE_MASK during the first pass. > > Perhaps a helper would be good, given that (5) and (6) need > > the same thing. > > > > (7) Make process_def remove items from m_nonzero_masks rather than > > storing a superset of GET_MODE_MASK. > > Done. The map now only holds useful masks and a missing entry (for defs > that have already been visited) implies the full mode mask. The diff contains some code rearrangement as well as the substantive changes. That makes it quite hard to read. Sorry to ask, but: could you split it into two patches: one NFC patch that rearranges the code as you'd like and a second patch that implements the new algorithm? > +/* Process DEF if the CLIENT handles it. If its result changes, enqueue the > + affected defs. > + > + FIRST_PASS is true during the initial RPO scan and false when revisiting a > + definition from the worklist. */ > +template > +void > +def_propagation::maybe_enqueue (def_info *def, Client &client, bool first_pass) I think this is more maybe_process_def. It acts immediately rather than enqueuing for later. > +{ > + set_info *set = dyn_cast (def); > + if (!set || !client.can_process_def_p (set)) > + return; > + if (client.process_def (set, first_pass)) > + enqueue_affected_defs (set, client, first_pass); I think the last two lines should be split out as process_def and used... > +} > + > +/* Process eligible definitions in RPO, then revisit affected defs until the > + worklist is empty. */ > +template > +void > +def_propagation::propagate (Client &client) > +{ > + for (ebb_info *ebb : crtl->ssa->ebbs ()) > + { > + for (phi_info *phi : ebb->phis ()) > + maybe_enqueue (phi, client, true); > + > + for (insn_info *insn : ebb->nondebug_insns ()) > + { > + if (!client.can_process_insn_p (insn)) > + continue; > + for (def_info *def : insn->defs ()) > + maybe_enqueue (def, client, true); > + } > + } > + > + while (m_worklist_head < m_worklist.length ()) > + maybe_enqueue (dequeue (), client, false); ...here, where we already know that we have a set_info that we want to process. Thanks, Richard From kaelfandrew@gmail.com Mon Nov 2 01:32:33 2026 From: kaelfandrew@gmail.com (Kael Andrew Franco) Date: Sun, 1 Nov 2026 20:32:33 -0500 Subject: [PATCH] gcc: Remove gcc_AC_C_ENUM_BF_UNSIGNED. [PR127224] Message-ID: <20261102013233.404388-1-kaelfandrew@gmail.com> Since r17-3931, ENUM_BITFIELD is no longer used, making gcc_AC_C_ENUM_BF_UNSIGNED unused. Bootstrapped on x86_64-pc-linux-gnu. PR bootstrap/127224 gcc/ChangeLog: * acinclude.m4 (gcc_AC_C_ENUM_BF_UNSIGNED): Remove. * configure.ac (gcc_AC_C_ENUM_BF_UNSIGNED): Remove. * configure: Regenerate. --- gcc/acinclude.m4 | 20 -------------------- gcc/configure | 5 ++--- gcc/configure.ac | 3 --- 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4 index c72a6c9e121..1ba785eba46 100644 --- a/gcc/acinclude.m4 +++ b/gcc/acinclude.m4 @@ -220,26 +220,6 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' AC_SUBST(INSTALL_DATA)dnl ]) -dnl Determine if enumerated bitfields are unsigned. ISO C says they can -dnl be either signed or unsigned. -dnl -AC_DEFUN([gcc_AC_C_ENUM_BF_UNSIGNED], -[AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned, -[AC_RUN_IFELSE([AC_LANG_SOURCE([#include -enum t { BLAH = 128 } ; -struct s_t { enum t member : 8; } s ; -int main(void) -{ - s.member = BLAH; - if (s.member < 0) exit(1); - exit(0); - -}])], gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)]) -if test $gcc_cv_enum_bf_unsigned = yes; then - AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1, - [Define if enumerated bitfields are treated as unsigned values.]) -fi]) - dnl Probe number of bits in a byte. dnl Note C89 requires CHAR_BIT >= 8. dnl diff --git a/gcc/configure b/gcc/configure index a60ae0ffbcc..f4bafc11c46 100755 --- a/gcc/configure +++ b/gcc/configure @@ -10760,7 +10760,6 @@ $as_echo "#define HAVE_ZSTD_H 1" >>confdefs.h fi - for ac_func in times kill getrlimit setrlimit atoq \ popen sysconf strsignal getrusage nl_langinfo \ gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \ @@ -22054,7 +22053,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 22057 "configure" +#line 22056 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -22160,7 +22159,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 22163 "configure" +#line 22162 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index cc0d00e911b..0165f8268a4 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1484,9 +1484,6 @@ if test "$zstd_enabled" = yes; then [Define if you have a working header file.]) fi -dnl Disabled until we have a complete test for buggy enum bitfields. -dnl gcc_AC_C_ENUM_BF_UNSIGNED - define(gcc_UNLOCKED_FUNCS, clearerr_unlocked feof_unlocked dnl ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked dnl fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked dnl -- 2.56.0 From andrew.pinski@oss.qualcomm.com Mon Nov 2 01:41:54 2026 From: andrew.pinski@oss.qualcomm.com (Andrea Pinski) Date: Sun, 1 Nov 2026 17:41:54 -0800 Subject: [PATCH] gcc: Remove gcc_AC_C_ENUM_BF_UNSIGNED. [PR127224] In-Reply-To: <20261102013233.404388-1-kaelfandrew@gmail.com> References: <20261102013233.404388-1-kaelfandrew@gmail.com> Message-ID: On Sun, Nov 1, 2026 at 5:33?PM Kael Andrew Franco wrote: > > Since r17-3931, ENUM_BITFIELD is no longer used, > making gcc_AC_C_ENUM_BF_UNSIGNED unused. > > Bootstrapped on x86_64-pc-linux-gnu. > > PR bootstrap/127224 > > gcc/ChangeLog: > > * acinclude.m4 (gcc_AC_C_ENUM_BF_UNSIGNED): Remove. > * configure.ac (gcc_AC_C_ENUM_BF_UNSIGNED): Remove. > * configure: Regenerate. Ok. > --- > gcc/acinclude.m4 | 20 -------------------- > gcc/configure | 5 ++--- > gcc/configure.ac | 3 --- > 3 files changed, 2 insertions(+), 26 deletions(-) > > diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4 > index c72a6c9e121..1ba785eba46 100644 > --- a/gcc/acinclude.m4 > +++ b/gcc/acinclude.m4 > @@ -220,26 +220,6 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' > AC_SUBST(INSTALL_DATA)dnl > ]) > > -dnl Determine if enumerated bitfields are unsigned. ISO C says they can > -dnl be either signed or unsigned. > -dnl > -AC_DEFUN([gcc_AC_C_ENUM_BF_UNSIGNED], > -[AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned, > -[AC_RUN_IFELSE([AC_LANG_SOURCE([#include > -enum t { BLAH = 128 } ; > -struct s_t { enum t member : 8; } s ; > -int main(void) > -{ > - s.member = BLAH; > - if (s.member < 0) exit(1); > - exit(0); > - > -}])], gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)]) > -if test $gcc_cv_enum_bf_unsigned = yes; then > - AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1, > - [Define if enumerated bitfields are treated as unsigned values.]) > -fi]) > - > dnl Probe number of bits in a byte. > dnl Note C89 requires CHAR_BIT >= 8. > dnl > diff --git a/gcc/configure b/gcc/configure > index a60ae0ffbcc..f4bafc11c46 100755 > --- a/gcc/configure > +++ b/gcc/configure > @@ -10760,7 +10760,6 @@ $as_echo "#define HAVE_ZSTD_H 1" >>confdefs.h > fi > > > - > for ac_func in times kill getrlimit setrlimit atoq \ > popen sysconf strsignal getrusage nl_langinfo \ > gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \ > @@ -22054,7 +22053,7 @@ else > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > lt_status=$lt_dlunknown > cat > conftest.$ac_ext <<_LT_EOF > -#line 22057 "configure" > +#line 22056 "configure" > #include "confdefs.h" > > #if HAVE_DLFCN_H > @@ -22160,7 +22159,7 @@ else > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > lt_status=$lt_dlunknown > cat > conftest.$ac_ext <<_LT_EOF > -#line 22163 "configure" > +#line 22162 "configure" > #include "confdefs.h" > > #if HAVE_DLFCN_H > diff --git a/gcc/configure.ac b/gcc/configure.ac > index cc0d00e911b..0165f8268a4 100644 > --- a/gcc/configure.ac > +++ b/gcc/configure.ac > @@ -1484,9 +1484,6 @@ if test "$zstd_enabled" = yes; then > [Define if you have a working header file.]) > fi > > -dnl Disabled until we have a complete test for buggy enum bitfields. > -dnl gcc_AC_C_ENUM_BF_UNSIGNED > - > define(gcc_UNLOCKED_FUNCS, clearerr_unlocked feof_unlocked dnl > ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked dnl > fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked dnl > -- > 2.56.0 > From sam@gentoo.org Mon Nov 2 02:09:51 2026 From: sam@gentoo.org (Sam James) Date: Mon, 02 Nov 2026 02:09:51 +0000 Subject: [PATCH] gcc: Remove gcc_AC_C_ENUM_BF_UNSIGNED. [PR127224] In-Reply-To: <20261102013233.404388-1-kaelfandrew@gmail.com> References: <20261102013233.404388-1-kaelfandrew@gmail.com> Message-ID: <87wlqwgf0w.fsf@gentoo.org> Kael Andrew Franco writes: > Since r17-3931, ENUM_BITFIELD is no longer used, > making gcc_AC_C_ENUM_BF_UNSIGNED unused. It was unused anyway, as it's been commented out since r0-34037-g9612ab65bd2b44, but of course now it is doubly unused. > > Bootstrapped on x86_64-pc-linux-gnu. > > PR bootstrap/127224 > > gcc/ChangeLog: > > * acinclude.m4 (gcc_AC_C_ENUM_BF_UNSIGNED): Remove. > * configure.ac (gcc_AC_C_ENUM_BF_UNSIGNED): Remove. > * configure: Regenerate. > --- > gcc/acinclude.m4 | 20 -------------------- > gcc/configure | 5 ++--- > gcc/configure.ac | 3 --- > 3 files changed, 2 insertions(+), 26 deletions(-) > > diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4 > index c72a6c9e121..1ba785eba46 100644 > --- a/gcc/acinclude.m4 > +++ b/gcc/acinclude.m4 > @@ -220,26 +220,6 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' > AC_SUBST(INSTALL_DATA)dnl > ]) > > -dnl Determine if enumerated bitfields are unsigned. ISO C says they can > -dnl be either signed or unsigned. > -dnl > -AC_DEFUN([gcc_AC_C_ENUM_BF_UNSIGNED], > -[AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned, > -[AC_RUN_IFELSE([AC_LANG_SOURCE([#include > -enum t { BLAH = 128 } ; > -struct s_t { enum t member : 8; } s ; > -int main(void) > -{ > - s.member = BLAH; > - if (s.member < 0) exit(1); > - exit(0); > - > -}])], gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)]) > -if test $gcc_cv_enum_bf_unsigned = yes; then > - AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1, > - [Define if enumerated bitfields are treated as unsigned values.]) > -fi]) > - > dnl Probe number of bits in a byte. > dnl Note C89 requires CHAR_BIT >= 8. > dnl > diff --git a/gcc/configure b/gcc/configure > index a60ae0ffbcc..f4bafc11c46 100755 > --- a/gcc/configure > +++ b/gcc/configure > @@ -10760,7 +10760,6 @@ $as_echo "#define HAVE_ZSTD_H 1" >>confdefs.h > fi > > > - > for ac_func in times kill getrlimit setrlimit atoq \ > popen sysconf strsignal getrusage nl_langinfo \ > gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \ > @@ -22054,7 +22053,7 @@ else > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > lt_status=$lt_dlunknown > cat > conftest.$ac_ext <<_LT_EOF > -#line 22057 "configure" > +#line 22056 "configure" > #include "confdefs.h" > > #if HAVE_DLFCN_H > @@ -22160,7 +22159,7 @@ else > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > lt_status=$lt_dlunknown > cat > conftest.$ac_ext <<_LT_EOF > -#line 22163 "configure" > +#line 22162 "configure" > #include "confdefs.h" > > #if HAVE_DLFCN_H > diff --git a/gcc/configure.ac b/gcc/configure.ac > index cc0d00e911b..0165f8268a4 100644 > --- a/gcc/configure.ac > +++ b/gcc/configure.ac > @@ -1484,9 +1484,6 @@ if test "$zstd_enabled" = yes; then > [Define if you have a working header file.]) > fi > > -dnl Disabled until we have a complete test for buggy enum bitfields. > -dnl gcc_AC_C_ENUM_BF_UNSIGNED > - > define(gcc_UNLOCKED_FUNCS, clearerr_unlocked feof_unlocked dnl > ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked dnl > fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked dnl -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 418 bytes Desc: not available URL: From hongtao.liu@intel.com Mon Nov 2 02:48:10 2026 From: hongtao.liu@intel.com (liuhongt) Date: Sun, 1 Nov 2026 18:48:10 -0800 Subject: [PATCH] match.pd: Fold masked vector multiply to widening even/odd multiply [PR124271] Message-ID: <20261102024810.3533124-1-hongtao.liu@intel.com> (x & lowhalf_mask) * (y & lowhalf_mask) on an integer vector only multiplies the zero-extended low halves of each element. That is VEC_WIDEN_MULT_EVEN_EXPR of x and y viewed as vectors of half-width unsigned elements (VEC_WIDEN_MULT_ODD_EXPR on big-endian, where the low halves are the odd lanes). On x86 this replaces the V*DImode multiply emulation (3 pmuludq plus shifts and adds) with a single pmuludq, and replaces vpmullq when AVX512DQ is available. Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Ok for trunk? gcc/ChangeLog: PR target/124271 * match.pd ((x & lowhalf_mask) * (y & lowhalf_mask)): New simplification to VEC_WIDEN_MULT_{EVEN,ODD}_EXPR. gcc/testsuite/ChangeLog: PR target/124271 * gcc.dg/torture/pr124271.c: New test. * gcc.target/i386/pr124271-1.c: New test. * gcc.target/i386/pr124271-2.c: New test. --- gcc/match.pd | 39 ++++++++++++++ gcc/testsuite/gcc.dg/torture/pr124271.c | 63 ++++++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr124271-1.c | 32 +++++++++++ gcc/testsuite/gcc.target/i386/pr124271-2.c | 40 ++++++++++++++ 4 files changed, 174 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr124271.c create mode 100644 gcc/testsuite/gcc.target/i386/pr124271-1.c create mode 100644 gcc/testsuite/gcc.target/i386/pr124271-2.c diff --git a/gcc/match.pd b/gcc/match.pd index d1eeb283bcb..f25952c6fd8 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -474,6 +474,45 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) { zeros; }) { ones; } { zeros; }))))))))) +#if GIMPLE +/* (x & lowhalf_mask) * (y & lowhalf_mask) + -> VEC_WIDEN_MULT_EVEN (VIEW_CONVERT (x), VIEW_CONVERT (y)), or + VEC_WIDEN_MULT_ODD on big-endian targets where the low halves are the + odd lanes. */ +(simplify + (mult (bit_and @0 VECTOR_CST@2) + (bit_and @1 @2)) + (if (uniform_vector_p (@2) + /* Single-element results are excluded since targets disagree + on the mode of a vector(1) widening multiply result (V2DI -> TI + on s390 but V2DI -> V1TI on rs6000). */ + && known_gt (TYPE_VECTOR_SUBPARTS (type), 1U)) + (with + { + auto elem = wi::to_wide (uniform_vector_p (@2)); + unsigned int outer_prec = TYPE_PRECISION (TREE_TYPE (type)); + unsigned int inner_prec = outer_prec / 2; + /* The half-width lanes are zero-extended, so the multiply is + unsigned even for a signed TYPE. */ + tree inner_scalar = build_nonstandard_integer_type (inner_prec, 1); + tree inner_type + = build_vector_type (inner_scalar, TYPE_VECTOR_SUBPARTS (type) * 2); + optab op = (BYTES_BIG_ENDIAN + ? vec_widen_umult_odd_optab : vec_widen_umult_even_optab); + } + (if (elem == wi::mask (inner_prec, false, outer_prec) + /* Without a mode of exactly INNER_PREC bits (e.g. for QImode + elements) the half-width vector would be wider than TYPE. */ + && type_has_mode_precision_p (inner_scalar) + && GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_VECTOR_INT + && optab_handler (op, TYPE_MODE (inner_type)) != CODE_FOR_nothing) + (if (BYTES_BIG_ENDIAN) + (vec_widen_mult_odd (view_convert:inner_type @0) + (view_convert:inner_type @1)) + (vec_widen_mult_even (view_convert:inner_type @0) + (view_convert:inner_type @1))))))) +#endif + (for cmp (gt ge lt le) outp (convert convert negate negate) outn (negate negate convert convert) diff --git a/gcc/testsuite/gcc.dg/torture/pr124271.c b/gcc/testsuite/gcc.dg/torture/pr124271.c new file mode 100644 index 00000000000..911a50f71ed --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr124271.c @@ -0,0 +1,63 @@ +/* PR target/124271 */ +/* { dg-do run } */ + +typedef unsigned long long v2du __attribute__ ((vector_size (16))); +typedef unsigned long long v4du __attribute__ ((vector_size (32))); +typedef long long v2di __attribute__ ((vector_size (16))); +typedef unsigned int v4su __attribute__ ((vector_size (16))); +typedef unsigned short v8hu __attribute__ ((vector_size (16))); +typedef unsigned char v8qu __attribute__ ((vector_size (8))); + +#define TEST(NAME, VT, ET, UT, M) \ + __attribute__ ((noipa)) void \ + NAME (VT *r, VT *a, VT *b) \ + { \ + *r = (*a & (ET) M) * (*b & (ET) M); \ + } \ + \ + void \ + check_##NAME (void) \ + { \ + VT a, b, r; \ + for (unsigned i = 0; i < sizeof (VT) / sizeof (ET); i++) \ + { \ + a[i] = (ET) (0x9e3779b97f4a7c15ULL * (i + 1)); \ + b[i] = (ET) (0xc2b2ae3d27d4eb4fULL * (i + 3)); \ + /* Keep the signed product from overflowing. */ \ + if ((ET) -1 < 0) \ + { \ + a[i] &= (ET) ((UT) M >> 1) | ~(ET) M; \ + b[i] &= (ET) ((UT) M >> 1) | ~(ET) M; \ + } \ + } \ + NAME (&r, &a, &b); \ + for (unsigned i = 0; i < sizeof (VT) / sizeof (ET); i++) \ + if ((UT) r[i] != (UT) ((UT) (a[i] & (ET) M) \ + * (UT) (b[i] & (ET) M))) \ + __builtin_abort (); \ + } + +TEST (f1, v2du, unsigned long long, unsigned long long, 0xffffffffULL) +TEST (f2, v4du, unsigned long long, unsigned long long, 0xffffffffULL) +TEST (f3, v2di, long long, unsigned long long, 0xffffffffULL) +TEST (f4, v4su, unsigned int, unsigned int, 0xffffU) +TEST (f5, v8hu, unsigned short, unsigned short, 0xffU) +/* Not a low-half mask. */ +TEST (f6, v2du, unsigned long long, unsigned long long, 0x1ffffffffULL) +TEST (f7, v2du, unsigned long long, unsigned long long, 0x7fffffffULL) +/* No integer mode for the half-width element. */ +TEST (f8, v8qu, unsigned char, unsigned char, 0xfU) + +int +main () +{ + check_f1 (); + check_f2 (); + check_f3 (); + check_f4 (); + check_f5 (); + check_f6 (); + check_f7 (); + check_f8 (); + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/pr124271-1.c b/gcc/testsuite/gcc.target/i386/pr124271-1.c new file mode 100644 index 00000000000..00fcb561989 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr124271-1.c @@ -0,0 +1,32 @@ +/* PR target/124271 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -mavx2 -mno-avx512f -fdump-tree-optimized" } */ + +typedef __UINT64_TYPE__ uint64_t; +typedef __UINT32_TYPE__ uint32_t; + +static inline uint64_t +mul32 (uint64_t a, uint64_t b) +{ + return (uint64_t) (uint32_t) a * (uint64_t) (uint32_t) b; +} + +void +foo (uint64_t *__restrict a, const uint64_t *__restrict b) +{ + for (int i = 0; i < 1024; i++) + a[i] = mul32 (a[i], b[i]); +} + +void +bar (long long *__restrict a, const long long *__restrict b) +{ + for (int i = 0; i < 1024; i++) + a[i] = (a[i] & 0xffffffff) * (b[i] & 0xffffffff); +} + +/* { dg-final { scan-tree-dump-times "WIDEN_MULT_EVEN_EXPR" 2 "optimized" } } */ +/* { dg-final { scan-assembler-times "vpmuludq\[ \\t\]+\[^\n\]*%ymm" 2 } } */ +/* { dg-final { scan-assembler-not "vpsrlq" } } */ +/* { dg-final { scan-assembler-not "vpsllq" } } */ +/* { dg-final { scan-assembler-not "vpand" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr124271-2.c b/gcc/testsuite/gcc.target/i386/pr124271-2.c new file mode 100644 index 00000000000..fd9ed7ac699 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr124271-2.c @@ -0,0 +1,40 @@ +/* PR target/124271 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512f -mno-avx512dq" } */ + +typedef unsigned long long v2du __attribute__ ((vector_size (16))); +typedef unsigned long long v4du __attribute__ ((vector_size (32))); +typedef unsigned long long v8du __attribute__ ((vector_size (64))); +typedef long long v2di __attribute__ ((vector_size (16))); + +#define M 0xffffffffULL + +v2du +f1 (v2du x, v2du y) +{ + return (x & M) * (y & M); +} + +v4du +f2 (v4du x, v4du y) +{ + return (x & M) * (y & M); +} + +v8du +f3 (v8du x, v8du y) +{ + return (x & M) * (y & M); +} + +v2di +f4 (v2di x, v2di y) +{ + return (x & (long long) M) * (y & (long long) M); +} + +/* { dg-final { scan-assembler-times "vpmuludq\[ \\t\]+\[^\n\]*%xmm" 2 } } */ +/* { dg-final { scan-assembler-times "vpmuludq\[ \\t\]+\[^\n\]*%ymm" 1 } } */ +/* { dg-final { scan-assembler-times "vpmuludq\[ \\t\]+\[^\n\]*%zmm" 1 } } */ +/* { dg-final { scan-assembler-not "vpsrlq" } } */ +/* { dg-final { scan-assembler-not "vpsllq" } } */ -- 2.34.1 From jeffrey.law@oss.qualcomm.com Mon Nov 2 03:52:57 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 20:52:57 -0700 Subject: [PATCH v3] match.pd: Recognize X == MIN ? MIN : X - 1 as signed sat add [PR127985] In-Reply-To: References: Message-ID: <214caea7-9678-4c46-aa20-90250edcc300@oss.qualcomm.com> On 10/21/26 6:15 AM, Uttam Bhadauriya wrote: > From fb6b4d83d08d8d30b31a450d6aa410d95d1b2e89 Mon Sep 17 00:00:00 2001 > From: Uttam Singh Bhadauriya > Date: Wed, 21 Oct 2026 17:45:13 +0530 > Subject: [PATCH v3] match.pd: Recognize X == MIN ? MIN : X - 1 as signed sat add > [PR127985] > > Commit ff133b4cd22 (PR126627) simplified (X & -X) < 0 into X == INT_MIN > and (X & -X) >= 0 into X != INT_MIN. However, the signed saturating > addition pattern for IMM = -1 in match-sat-alu.pd looked for the > unsimplified (X & -X) < 0 condition. As a result, a saturating decrement > is no longer recognized as .SAT_ADD, which causes regressions in > gcc.target/riscv/sat/sat_s_add_imm-*.c. > > Because the old (X & -X) < 0 pattern can no longer match outside > -ftrapv, this patch replaces it with match patterns for the canonical > X == MIN ? MIN : X - 1 and X != MIN ? X - 1 : MIN forms. This restores > .SAT_ADD discovery on RISC-V and also captures saturating decrements > written directly with MIN comparisons. > > PR tree-optimization/127985 > > gcc/ChangeLog: > > * match-sat-alu.pd (signed_integer_sat_add): Replace obsolete > (X & -X) < 0 pattern with patterns for X == MIN ? MIN : X - 1 > and X != MIN ? X - 1 : MIN. > > gcc/testsuite/ChangeLog: > > * gcc.dg/torture/pr127985.c: New test. > * gcc.target/riscv/sat/pr127985.c: New test. > > Signed-off-by: Uttam Singh Bhadauriya > --- > Hello, > > I am presenting the v3 patch, I was able to build the cross-compiler > and test it locally( had some issues with my hardware apparently so > had to do some tweaking), the changes made are as follows: > > 1. Replaced the old obsolete pattern: > Verified that (X & -X) < 0 cannot fire after commit ff133b4cd22 (PR126627) > outside -ftrapv. The obsolete pattern has been completely replaced with > canonical matchers for both: > - X == MIN ? MIN : X - 1 > - X != MIN ? X - 1 : MIN Essentially your pattern for 126627 will not fire with -fwrapv is active, so we're still rely on the pattern you removed in this patch to optimize that case, or am I misunderstanding something?? It seems the simple solution is to just keep the old pattern and add your new one. > 5. Test Verification Summary: > - x86_64: gcc.dg/torture/pr127985.c passes runtime execution across > all optimization levels (-O0, -O1, -O2, -O3, -Os). > - RISC-V (rv64gc-lp64d): Verified on cc1 that sat_s_add_imm-1-i16.c > restores the regression (2 .SAT_ADD instances found). > - RISC-V (rv64gc-lp64d): Verified pr127985.c finds all 8 .SAT_ADD > instances and produces branchless assembly (0 branch labels). Since we're changing a generic file a full bootstrap and regression test is required on one of the major targets (x86_64 and aarch64 are the most common). Your patch fails to apply to the trunk.? I would hazard a guess there's a context difference because of other changes in this space.? Given this patch is meant to fix a regression, let's focus on getting this patch under control first. If you can repost a version that works with the trunk it'd be hugely appreciated.? Sashiko ought to pick it up and I can do some regression testing on it. Thanks! jeff From jeffrey.law@oss.qualcomm.com Mon Nov 2 04:03:31 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 21:03:31 -0700 Subject: [PATCH 1/2] RISC-V: Add ARC-V RPX-100 series pipeline description In-Reply-To: <20261030134212.2387766-1-exuro@exuro.be> References: <20261030134212.2387766-1-exuro@exuro.be> Message-ID: On 10/30/26 7:41 AM, exuro wrote: > From: Loeka Rogge > > The RPX-100 pipeline is the same design as the RHX-100 but RV64 instead > of RV32. This mtune is just an alias and adds 64 bit multiplication. > > Add a mul_part attribute to al multiplication instructions in riscv.md > to distinguish instructions that return the high and low part. > > Regtested on rv32gc, rv64gc and with rhx100 config and mtune. > > gcc/ChangeLog: > > * config/riscv/arcv-rhx100.md (arcv_rhx100_mpy_insn): Rename to > mpy32. > (arcv_rhx100_mpy32_insn): Also apply for rpx_100 tune. > (arcv_rhx100_mpy64l_insn): rpx_100 mul low part. > (arcv_rhx100_mpy64h_insn): rpx_100 mul high part. > (arcv_rhx100_mpy*_insn): Apply bypass for both size mul. > (arcv_rhx100_div_insn): Also apply for rpx_100 tune. > (riscv_store_data_bypass_p): Add store bypass > (arcv_rhx100_store_insn): Likewise. > (arcv_rhx100_load_insn): Add load bypass. > * config/riscv/riscv-cores.def (RISCV_TUNE): > Add arcv_rpx100 tune > * config/riscv/riscv-opts.h (enum riscv_microarchitecture_type): > Add arcv_rpx100 microarchitecture type > * config/riscv/riscv.md (low,high): Add low/high mul_part > attribute, default value: low. > * doc/riscv-mtune.texi: Add rpx_100 tune > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/arcv-sched-mul-mem-rpx100.c: New test. > > Signed-off-by: Loeka Rogge This looks sensible.? I *think* it can be committed without patch #2, but I'll wait for your confirmation on that before pushing. Jeff From jeffrey.law@oss.qualcomm.com Mon Nov 2 04:10:46 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 21:10:46 -0700 Subject: [PATCH 2/2] RISC-V: RPX-100: emit mulh mul pairs in that order In-Reply-To: <20261030134212.2387766-2-exuro@exuro.be> References: <20261030134212.2387766-1-exuro@exuro.be> <20261030134212.2387766-2-exuro@exuro.be> Message-ID: <997fe46f-74bb-41d0-9e8d-30e443148d99@oss.qualcomm.com> On 10/30/26 7:41 AM, exuro wrote: > From: Loeka Rogge > > RPX-100 allows a mulh(s/u) followed by a mul operation to be bonded, > saving 3 cycles in the multiplier and allowing the mul's result to be > used 1 cycle earlier than expected. > > - Adjust pipeline multiplier reservations for bonded case. Typically > mulh(s/u) is always emitted together with mul, otherwise this is a bit > optimistic. > - Define_expand mulditi3 is modified to emit the high part first for > rpx100 > - Added RISCV_FUSE_BONDED_MUL fusion > - riscv_sched_adjust_cost reflects the mul result being available 1 > cycle sooner in this case > > Regtested on rv32gc, rv64gc and with rhx100 config and mtune. > > gcc/ChangeLog: > > * config/riscv/arcv-rhx100.md: Adjust mul reservation for > typical bonded case. > * config/riscv/riscv-cores.def (RISCV_TUNE): Make rpx100 a > separate tune instead of reusing rhx100 tune > * config/riscv/riscv-fusion.cc (riscv_set_is_multiply_high_pattern_p): > Check if a set is a mulh(s/u) pattern. > (riscv_get_mulh_operands): Get operands from a mulh(s/u) > pattern. > (riscv_fuse_bonded_mul): Check for bonded mul pairs to fuse. > (riscv_depends_on_lowpart_bonded_mul_p): check if dependency is > on low part of a bonded mul operation. > * config/riscv/riscv-protos.h (enum riscv_fusion_pairs): Add > RISCV_FUSE_BONDED_MUL fusion > (riscv_depends_on_lowpart_bonded_mul_p): Add function header > for use in riscv.cc . > * config/riscv/riscv.cc (riscv_sched_adjust_cost): Adjust cost > for rpx100 bonded mul. > * config/riscv/riscv.md: Change mul mulh emit order for if the > fusion is enabled. > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/fusion-bonded-mul-1.c: New test. > > Signed-off-by: Loeka Rogge > --- > > > /* Check the common RTL for ZEXTW, ZEXTWS and ZEXTH fusion. */ > > static bool > @@ -744,6 +776,111 @@ riscv_fuse_b_alui (rtx_insn *prev, rtx_insn *curr) > return false; > } > > +/* Extract register operands and destination from multiply high-part pattern. > + Operands are returned in the order of the assembly instruction. The usmul > + pattern emits the operands in the reverse order. > + Returns true if successful. */ > + > +static bool > +riscv_get_mulh_operands (rtx set_rtx, rtx *op0, rtx *op1, rtx *dest) > +{ > + if (!riscv_set_is_multiply_high_pattern_p (set_rtx)) > + return false; > + > + rtx mulh_pattern = SET_SRC (set_rtx); > + > + rtx lshiftrt = XEXP (mulh_pattern, 0); > + rtx mult = XEXP (lshiftrt, 0); > + > + rtx operand0 = XEXP (mult, 0); > + rtx operand1 = XEXP (mult, 1); > + > + /* Swap operands for usmul pattern. */ > + if (GET_CODE (operand0) == ZERO_EXTEND > + && GET_CODE (operand1) == SIGN_EXTEND) > + std::swap (operand0, operand1); > + > + /* Strip zero_extend/sign_extend. */ > + if (GET_CODE (operand0) == ZERO_EXTEND || GET_CODE (operand0) == SIGN_EXTEND) > + operand0 = XEXP (operand0, 0); > + if (GET_CODE (operand1) == ZERO_EXTEND || GET_CODE (operand1) == SIGN_EXTEND) > + operand1 = XEXP (operand1, 0); > + > + /* Strip subreg. */ > + if (GET_CODE (operand0) == SUBREG) > + operand0 = SUBREG_REG (operand0); > + if (GET_CODE (operand1) == SUBREG) > + operand1 = SUBREG_REG (operand1); You should probably verify that you're getting the right part of the subreg expression here.? If you want the low word, here's subreg_lowpart_p to verify that's what you're really getting. > +} > + > +/* Check for RISCV_FUSE_BONDED_MUL fusion. > + prev (mulh/mulhu/mulhsu) and curr (mul) of the same inputs, with the > + high-part destination distinct from both inputs. */ > + > +static bool > +riscv_fuse_bonded_mul (rtx_insn *prev, rtx_insn *curr) You should check that PREV is not marked for fusion.? ?It's likely to be marked, but better to be sure. > + > +bool > +riscv_depends_on_lowpart_bonded_mul_p (int dep_type, rtx_insn *dep_insn) > +{ > + if (dep_type != REG_DEP_TRUE) > + return false; > + > + rtx_insn *prev_insn = prev_nondebug_insn (dep_insn); I think you want prev_nonnote_nondebug_insn here.? I think you can see things like NOTE_INSN_DELETED_DEBUG_LABEL and such here. > diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md > index eb188ff5514..c1493193a53 100644 > --- a/gcc/config/riscv/riscv.md > +++ b/gcc/config/riscv/riscv.md > @@ -1285,10 +1285,18 @@ (define_expand "mulditi3" > "(TARGET_ZMMUL || TARGET_MUL) && TARGET_64BIT" > { > rtx low = gen_reg_rtx (DImode); > - emit_insn (gen_muldi3 (low, operands[1], operands[2])); > - > rtx high = gen_reg_rtx (DImode); > - emit_insn (gen_muldi3_highpart (high, operands[1], operands[2])); > + > + if (riscv_get_fusible_ops () & RISCV_FUSE_BONDED_MUL) > + { > + emit_insn (gen_muldi3_highpart (high, operands[1], operands[2])); > + emit_insn (gen_muldi3 (low, operands[1], operands[2])); > + } > + else > + { > + emit_insn (gen_muldi3 (low, operands[1], operands[2])); > + emit_insn (gen_muldi3_highpart (high, operands[1], operands[2])); > + } > > emit_move_insn (gen_lowpart (DImode, operands[0]), low); > emit_move_insn (gen_highpart (DImode, operands[0]), high); > @@ -1317,10 +1325,18 @@ (define_expand "usmulditi3" > "(TARGET_ZMMUL || TARGET_MUL) && TARGET_64BIT" > { > rtx low = gen_reg_rtx (DImode); > - emit_insn (gen_muldi3 (low, operands[1], operands[2])); > - > rtx high = gen_reg_rtx (DImode); > - emit_insn (gen_usmuldi3_highpart (high, operands[1], operands[2])); > + > + if (riscv_get_fusible_ops () & RISCV_FUSE_BONDED_MUL) > + { > + emit_insn (gen_usmuldi3_highpart (high, operands[1], operands[2])); > + emit_insn (gen_muldi3 (low, operands[2], operands[1])); > + } > + else > + { > + emit_insn (gen_muldi3 (low, operands[1], operands[2])); > + emit_insn (gen_usmuldi3_highpart (high, operands[1], operands[2])); > + Huh?? If you're changing code generation in an expander based on FUSION things, then you're likely doing something wrong.? I'd suggest dropping these hunks for now and returning to whatever caused you to want to add it later.? It's a sign you're tackling a problem in the wrong way. Jeff From jeffrey.law@oss.qualcomm.com Mon Nov 2 04:12:31 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 21:12:31 -0700 Subject: [PATCH v2] Add null check reg_renumber in true_regnum In-Reply-To: <452e3096-82be-4c8c-807c-2d565a4a51f5@globalfoundries.com> References: <20261027063908.2845263-2-loeka@exuro.be> <452e3096-82be-4c8c-807c-2d565a4a51f5@globalfoundries.com> Message-ID: <65b64cc8-3f63-4ced-b6c9-ab106a785a21@oss.qualcomm.com> On 10/28/26 9:37 AM, Rogge, Loeka wrote: > Hi Jeff, > > Could you review the changes in jump.cc? > The Xtensa part is already OK'd. > > Loeka > > On 10/27/26 7:39 AM, loeka@exuro.be wrote: >> From: Loeka Rogge >> >> This was already added in the xtensa backend. Without the check, >> reg_renumber[REGNO (x)] >= 0 could dereference null if true_regnum >> is called before reload. >> >> Moved here so it can be reused in the RISC-V backend in the fusion >> matchers in riscv-fusion.cc >> >> Bootstrapped and regtested with all checking enabled on x86. >> >> gcc/ChangeLog: >> >> * config/xtensa/xtensa.cc (xt_true_regnum): Removed. >> (xtensa_valid_move): Use true_regnum instead of xt version. >> (print_operand): Likewise. >> (xtensa_secondary_reload): Likewise. >> * jump.cc (true_regnum): Replaced by xt version. You're not supposed to be calling true_regnum until after reload/lra has completed. Jeff From jeffrey.law@oss.qualcomm.com Mon Nov 2 04:13:54 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 21:13:54 -0700 Subject: [PING^3] tree-optimization: tighten unsigned-add range via no-overflow relation [PR127101] In-Reply-To: References: Message-ID: On 10/27/26 11:44 PM, Naveen SiddeGowda wrote: > Hi, > > Please consider this as a gentle reminder to review the patch at the > following link:- > https://gcc.gnu.org/pipermail/gcc-patches/2026-August/729404.html Recommend you directly contact Aldy Hernandez and Andrew MacLeod to see if you can get some traction here. jeff From jeffrey.law@oss.qualcomm.com Mon Nov 2 04:19:18 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 21:19:18 -0700 Subject: [PATCH v1] combine, amdgcn: Fix ICE truncating wide vectors; allow packed accesses [PR122583] In-Reply-To: References: Message-ID: On 10/30/26 6:43 AM, ams via Sourceware Forge wrote: > From: Andrew Stubbs > > GCN has been disallowing misaligned vector accesses when there are packed > structs in order to work around an ICE I couldn't previously explain. This > of course was not ideal and caused other failures, including pr122583, > indirectly. > > The original ICE occurred during the combine pass, when building testcase > gfortran.dg/recursive_alloc_comp_4.f08, but I had assumed it was caused by > something in the way the GCN port handles subregs. In general, subregs of > vectors are complicated, on GCN, because vector registers cannot be treated as > a single sequence of bits that can be subdivided and reinterpreted any which > way, which is contrary to assumptions made in various parts of the compiler. > > However, I now believe this issue to be a latent bug -- or at least a new kind > of edge case -- in the combine pass itself. > > Given > > (set (reg:SI 7) (subreg:SI (vec_merge:V4DI ...) 0)) > > force_to_mode calls "gen_lowpart_or_truncate (SImode, )". On GCN, > truncating 256 bits to 32 bits is not a no-op, so the function tries to > reinterpret the operand as an integer of the same size, using > "int_mode_for_mode (V4DImode).require ()". GCN has no integer mode wider than > TImode, so this fails. Unpatched trunk hits the same ICE in > gcc.dg/Warray-bounds-69.c, gcc.dg/Wstringop-overflow-47.c and > gfortran.fortran-torture/compile/{20080806-1,pr66251}.f90. > > This patch makes gen_lowpart_or_truncate return (clobber (const_int 0)) when > there is no suitable integer mode, so that the combination fails cleanly, and > removes the GCN workaround. > > With the ICE fixed, GCN now gives the expected pr97027 diagnostics in > Wstringop-overflow-47.c, as aarch64 does, so add amdgcn to the xfail > exceptions there. > > recursive_alloc_comp_4.f08 no longer reproduces the ICE on current trunk, so > add an RTL testcase that starts at combine. > > Assisted-By: Claude Opus 5.5 > > Claude assisted with the analysis, and generated the testcase. > > gcc/ChangeLog: > > PR target/122583 > * combine.cc (gen_lowpart_or_truncate): Return a CLOBBER if either > mode has no equivalent integer mode, instead of ICEing. > * config/gcn/gcn.cc (gcn_vectorize_support_vector_misalignment): > Allow packed accesses. > > gcc/testsuite/ChangeLog: > > PR target/122583 > * gcc.dg/Wstringop-overflow-47.c: Don't xfail pr97027 on amdgcn. > * gcc.target/gcn/pr122583.c: New test. > --- > The patch has been tested on both x86_64 and amdgcn with no regressions, but I > didn't check that it never affects code generation. However, the intention is > that it only triggers in a case where the compiler was heading for an ICE. > > OK for mainline? OK.? That's the standard way to handle these kinds of things. Sashiko noted there's other related code that might need the same kind of protection: https://gcc.sashiko.dev/#/patchset/bmm.hnp0554jqi.gcc.gcc.ams.263.1.0%40forge-stage.sourceware.org Jeff From jeffrey.law@oss.qualcomm.com Mon Nov 2 04:26:47 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 21:26:47 -0700 Subject: [PATCH] match.pd: Fold same-width signed vector averages In-Reply-To: References: Message-ID: <0e509305-347f-4167-ba60-f89bd79475ff@oss.qualcomm.com> On 10/26/26 4:16 PM, Igor Shevlyakov wrote: > (x + y) >> 1 is IFN_AVG_FLOOR (x, y) and ((x + y) + 1) >> 1 is > IFN_AVG_CEIL (x, y) whenever the sum does not wrap. The existing > IFN_AVG_FLOOR fold for vectors proves that from leading zero bits of x > and y. For a signed type whose overflow is undefined the sum cannot > wrap anyway, so code such as the column pass of a 4x4 DCT butterfly, > > for (int i = 0; i < n; i++) > r[i] = (a[i] + b[i] + c[i] + d[i] + 1) >> 1; > > is vectorized as two adds and an arithmetic shift per vector where one > add and a rounding halving add (srhadd on AArch64) would do. > vect_recog_average_pattern only handles the narrowing form, where the > sum is computed in a wider type than x and y. > > Fold (x + y) >> 1 without looking at the bits of x and y when overflow > is undefined, and add the same fold of ((x + y) + 1) >> 1 to > IFN_AVG_CEIL, with the same conditions. > > Assisted-by: Claude Opus 5.5 > > gcc/ChangeLog: > > * match.pd ((x + y) >> 1 -> IFN_AVG_FLOOR (x, y)): Also fold > when overflow is undefined. > (((x + y) + 1) >> 1 -> IFN_AVG_CEIL (x, y)): New fold. > > gcc/testsuite/ChangeLog: > > * gcc.dg/vect/vect-avg-17.c: New test. > * gcc.target/aarch64/vect_hadd_same_width_1.c: New test. > * gcc.target/aarch64/vect_hadd_same_width_2.c: New test. > > Signed-off-by: Igor Shevlyakov LGTM.? No concerns from Sashiko either. Thanks! jeff From jeffrey.law@oss.qualcomm.com Mon Nov 2 04:31:46 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 21:31:46 -0700 Subject: [PATCH v4] combine: Don't put two volatile reads into one insn [PR127851] In-Reply-To: <9ba9fbcf-b21d-44c8-bf2b-7f90d68d21f4@linux.dev> References: <20261013084407.2984553-1-vineet.gupta@linux.dev> <20261014052122.3454958-1-vineet.gupta@linux.dev> <20261014091527.3620282-1-vineet.gupta@linux.dev> <051ba417-99ec-4cc8-8407-7205334b3e3f@oss.qualcomm.com> <20261021211758.3144964-1-vineet.gupta@linux.dev> <63aa2519-de41-4fd3-bd3b-b5389a5759ae@oss.qualcomm.com> <9ba9fbcf-b21d-44c8-bf2b-7f90d68d21f4@linux.dev> Message-ID: <54200047-510f-47b4-8763-3793266814fe@oss.qualcomm.com> On 10/23/26 11:42 AM, Vineet Gupta wrote: > On 10/23/26 5:45 AM, Jeff Law wrote: >> On 10/22/26 11:56 PM, Uros Bizjak wrote: >>> On Fri, Oct 23, 2026 at 7:00?AM Uros Bizjak wrote: >>>> On Fri, Oct 23, 2026 at 1:23?AM Vineet Gupta >>>> wrote: >>>>> On 10/21/26 2:17 PM, Vineet Gupta wrote: >>>>>> With -ffuse-ops-with-volatile-access general_operand accepts >>>>>> volatile >>>>>> MEMs during combine.? For "int a = x; int b = y; return a < b;" with >>>>>> volatile x and y, combine first merges the load of y into the >>>>>> compare >>>>>> and then the load of x, giving (compare (mem/v x) (mem/v y)).? The >>>>>> operands of one insn are unordered, so whatever later reloads or >>>>>> splits >>>>>> it picks the order of the two volatile reads, and the sequence point >>>>>> between them is lost.? can_combine_p checks insns between INSN >>>>>> and I3 >>>>>> for volatile references, but not I3 itself. >>>>>> >>>>>> The x86 compare patterns now reject such operands (dc57b45e7a79), >>>>>> but >>>>>> other patterns accept them too: for "h = hi; l = lo;" combined into >>>>>> ((dw) h << N) | l, the x86 doubleword concat patterns take both >>>>>> halves >>>>>> as memory operands and their split reads lo first. Rather than >>>>>> fixing >>>>>> each pattern, refuse in combine to combine an insn that reads >>>>>> volatile >>>>>> memory directly into an I3 that already reads volatile memory. >>>>>> >>>>>> The new volatile_reads_p walks I3's pattern: every SET in a PARALLEL >>>>>> counts, and so does anything read to form a stored location (a MEM's >>>>>> address, a ZERO_EXTRACT's position and size), but a volatile MEM >>>>>> that is >>>>>> only stored to does not, since an insn does all its reads before its >>>>>> writes.? That does not hold for an asm, whose template may access >>>>>> its >>>>>> operands in any order, so for an asm I3 any volatile reference >>>>>> refuses. >>>>>> >>>>>> Bootstrapped and regression tested on x86_64-linux-gnu and >>>>>> aarch64-linux-gnu. >>>>>> >>>>>> ??????? PR rtl-optimization/127851 >>>>>> >>>>>> gcc/ChangeLog: >>>>>> >>>>>> ??????? * combine.cc (volatile_reads_p): New function. >>>>>> ??????? (can_combine_p): Use it to refuse combining an insn that >>>>>> reads >>>>>> ??????? volatile memory directly into an I3 that already reads >>>>>> volatile >>>>>> ??????? memory; for an asm I3, refuse on any volatile reference. >>>>>> >>>>>> gcc/testsuite/ChangeLog: >>>>>> >>>>>> ??????? * gcc.target/aarch64/volatile-fuse-order-1.c: New test. >>>>>> ??????? * gcc.target/aarch64/volatile-fuse-order-2.c: New test. >>>>>> ??????? * gcc.target/i386/volatile-fuse-order-4.c: New test. >>>>>> ??????? * gcc.target/i386/volatile-fuse-order-5.c: New test. >>>>>> ??????? * gcc.target/i386/volatile-fuse-order-6.c: New test. >>>>>> >>>>>> Signed-off-by: Vineet Gupta >>>>>> --- >>>>>> v4: - volatile_reads_p walks I3's pattern: every SET in a >>>>>> PARALLEL counts, >>>>>> ???????? and so do reads in a SET's destination (a MEM's address, a >>>>>> ???????? ZERO_EXTRACT's position/size); a volatile store alone >>>>>> does not >>>>>> ???????? (Jeff). >>>>>> ?????? - For an asm I3 any volatile reference refuses: its >>>>>> template may write >>>>>> ???????? an output before reading an input. >>>>>> ?????? - x86 volatile-fuse-order-1/2/3 dropped, they went in with >>>>>> ???????? dc57b45e7a79.? New x86 tests: -4/-5 (asm, including >>>>>> multi-output >>>>>> ???????? PARALLELs) and -6 (doubleword concat), which still fail >>>>>> on trunk. >>>>>> ?????? - With the i386.md part of dc57b45e7a79 reverted, -1..-6 >>>>>> still pass: >>>>>> ???????? combine refuses the merge itself. >>>>>> v3: the x86 check-function-bodies now match only the load and the >>>>>> compare; >>>>>> ?????? use ia32 / ! ia32 selectors, so -mx32 is covered too (Uros). >>>>>> v2: the x86 check-function-bodies tests now also run and check >>>>>> the bodies >>>>>> ?????? on ia32 (Uros); added -fno-pic for the global-variable ones. >>>>>> >>>>>> ??? gcc/combine.cc??????????????????????????????? | 58 >>>>>> +++++++++++++++++++ >>>>>> ??? .../aarch64/volatile-fuse-order-1.c?????????? | 24 ++++++++ >>>>>> ??? .../aarch64/volatile-fuse-order-2.c?????????? | 23 ++++++++ >>>>>> ??? .../gcc.target/i386/volatile-fuse-order-4.c?? | 49 >>>>>> ++++++++++++++++ >>>>>> ??? .../gcc.target/i386/volatile-fuse-order-5.c?? | 45 >>>>>> ++++++++++++++ >>>>>> ??? .../gcc.target/i386/volatile-fuse-order-6.c?? | 35 +++++++++++ >>>>>> ??? 6 files changed, 234 insertions(+) >>>>>> ??? create mode 100644 >>>>>> gcc/testsuite/gcc.target/aarch64/volatile-fuse-order-1.c >>>>>> ??? create mode 100644 >>>>>> gcc/testsuite/gcc.target/aarch64/volatile-fuse-order-2.c >>>>>> ??? create mode 100644 >>>>>> gcc/testsuite/gcc.target/i386/volatile-fuse-order-4.c >>>>>> ??? create mode 100644 >>>>>> gcc/testsuite/gcc.target/i386/volatile-fuse-order-5.c >>>>>> ??? create mode 100644 >>>>>> gcc/testsuite/gcc.target/i386/volatile-fuse-order-6.c >>>>>> >>>>>> diff --git a/gcc/combine.cc b/gcc/combine.cc >>>>>> index c9daefc905c3..b369914e49e4 100644 >>>>>> --- a/gcc/combine.cc >>>>>> +++ b/gcc/combine.cc >>>>>> @@ -1723,6 +1723,53 @@ set_nonzero_bits_and_sign_copies (rtx x, >>>>>> const_rtx set, void *data) >>>>>> ??????? } >>>>>> ??? } >>>>>> >>>>>> +/* Return true if insn pattern X reads volatile memory.? */ >>>>>> + >>>>>> +static bool >>>>>> +volatile_reads_p (const_rtx x) >>>>>> +{ >>>>>> +? switch (GET_CODE (x)) >>>>>> +??? { >>>>>> +??? case PARALLEL: >>>>>> +????? /* Every element counts, not just the one single_set would >>>>>> pick.? */ >>>>>> +????? for (int i = 0; i < XVECLEN (x, 0); i++) >>>>>> +???? if (volatile_reads_p (XVECEXP (x, 0, i))) >>>>>> +?????? return true; >>>>>> +????? return false; >>>>>> + >>>>>> +??? case SET: >>>>>> +????? { >>>>>> +???? /* Strip down to the stored location.? The position and >>>>>> size of a >>>>>> +??????? bit-field are read.? */ >>>>>> +???? rtx dest = SET_DEST (x); >>>>>> +???? while (GET_CODE (dest) == SUBREG >>>>>> +??????????? || GET_CODE (dest) == STRICT_LOW_PART >>>>>> +??????????? || GET_CODE (dest) == ZERO_EXTRACT) >>>>>> +?????? { >>>>>> +???????? if (GET_CODE (dest) == ZERO_EXTRACT >>>>>> +???????????? && (volatile_refs_p (XEXP (dest, 1)) >>>>>> +???????????????? || volatile_refs_p (XEXP (dest, 2)))) >>>>>> +?????????? return true; >>>>>> +???????? dest = XEXP (dest, 0); >>>>>> +?????? } >>>>>> +???? /* A stored MEM is not read, and since an insn does all its >>>>>> reads >>>>>> +??????? before its writes, a volatile store cannot move ahead of a >>>>>> +??????? volatile read in the same insn.? Its address is read, >>>>>> though, >>>>>> +??????? e.g. (mem (mem/v ...)).? */ >>>>>> +???? if (MEM_P (dest) && volatile_refs_p (XEXP (dest, 0))) >>>>>> +?????? return true; >>>>>> +???? return volatile_refs_p (SET_SRC (x)); >>>>>> +????? } >>>>>> + >>>>>> +??? case CLOBBER: >>>>>> +????? /* A clobbered MEM is not read, but its address is.? */ >>>>>> +????? return MEM_P (XEXP (x, 0)) && volatile_refs_p (XEXP (XEXP >>>>>> (x, 0), 0)); >>>>>> + >>>>>> +??? default: >>>>>> +????? return volatile_refs_p (x); >>>>>> +??? } >>>>>> +} >>>>>> + >>>>>> ??? /* See if INSN can be combined into I3.? PRED, PRED2, SUCC >>>>>> and SUCC2 are >>>>>> ?????? optionally insns that were previously combined into I3 or >>>>>> that will be >>>>>> ?????? combined into the merger of INSN and I3.? The order is >>>>>> PRED, PRED2, >>>>>> @@ -2004,6 +2051,17 @@ can_combine_p (rtx_insn *insn, rtx_insn >>>>>> *i3, rtx_insn *pred ATTRIBUTE_UNUSED, >>>>>> ??????? return false; >>>>>> ????????? if (succ != 0 && volatile_refs_p (PATTERN (succ))) >>>>>> ??????? return false; >>>>>> +????? /* Nor may INSN go straight into an I3 that already reads >>>>>> volatile >>>>>> +????? memory: the insn would hold both reads with no order >>>>>> between them. >>>>>> +????? A volatile store in I3 is fine, since all of an insn's >>>>>> reads happen >>>>>> +????? before its writes, but not in an asm, whose template may >>>>>> access its >>>>>> +????? operands in any order.? (When INSN goes through SUCC, >>>>>> combine may >>>>>> +????? split the result back into two insns that keep the reads >>>>>> ordered.)? */ >>>>>> +????? if (succ == 0 >>>>>> +?????? && (asm_noperands (PATTERN (i3)) >= 0 >>>>>> +?????????? ? volatile_refs_p (PATTERN (i3)) >>>>>> +?????????? : volatile_reads_p (PATTERN (i3)))) >>>>>> +???? return false; >>>>> I don't want to jump the gun on the due review process but seems like >>>>> there is some feedback from gcc sashiko which Uroz shared with me [1] >>>>> and the issue it found seems legit. >>>>> >>>>> [1] >>>>> https://gcc.sashiko.dev/#/patchset/20261021211758.3144964-1-vineet.gupta%40linux.dev >>>>> >>>>> >>>>> Essentially the "succ == 0" check above implies this only happens >>>>> for I2 >>>>> -> I3 combine, but leaves the 3 (or 4) combine cases broken. e.g. >>>>> Test >>>>> below on x86, z is incorrectly read before y (with my v4 and despite >>>>> Uroz's i386.md fix) >>>>> >>>>> ?????? extern volatile int x, y, z; >>>>> ?????? int noarg (void) { int t1 = x; int t2 = y; int t3 = z; >>>>> return t1 + >>>>> t2 + t3; } >>>>> >>>>> Dropping the check fixes this test above but regresses other valid >>>>> cases: the test from original introduction of >>>>> -ffuse-ops-with-volatile-access. >>>> FYI, the i386.md fix was specific to compare patterns, and as Jeff >>>> pointed out, that approach results in a maintenance hell, as it >>>> requires manually changing all RTX patterns that accept two or more >>>> memory operands with the insn check that allows at most one volatile >>>> operand. AFAICS, the same effect can be achieved in recog_for_combine >>>> with some RTX walker that rejects invalid RTXes at the point of >>>> recognition. I don't know if this is the most optimal solution, but as >>>> shown with my i386.md experiment, it works. >>> Eh, no. Combine can split insns internally, and we have to reject >>> combined insns with multiple volatile ops before they get split. >> Feels like we need to catch this class of problems when we have the >> unaltered i0..i3.? There's a ton of code to reject classes of >> combinations that aren't going to work for some reason or another, this >> feels like just another set of constraints to encode there.? Of course, >> I'm not inside the code, so I may be drastically oversimplifying. > > For v5 which I have currently tested (and bootstrapped on x86 and > arm64) this is done post split and it allows the split results only if > the orig order is maintained for which it needs to snapshot the order > before. > > What Uros and you are suggesting here is to check pre-split and if I > understand correctly reject whenever the combine pattern has volatile > reads from two different insns, w/o worrying about the ordering at all > ? This might actually be simpler, as it avoids the snapshoting. Let me > give this a try. > > But in the mean time I can send out v5 as it now. I was coming at it from the angle of you can't know order once you start those SUBST calls.? So ISTM that you want to check fairly early. Jeff From jeffrey.law@oss.qualcomm.com Mon Nov 2 04:34:15 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 21:34:15 -0700 Subject: [PATCH] gcse: Don't hoist an expression across a jump that modifies it [PR127847] In-Reply-To: References: <20261013025133.2628132-1-vineet.gupta@linux.dev> <3fc445aa-8142-437f-9b6b-bf701c24430a@oss.qualcomm.com> Message-ID: On 10/23/26 5:45 PM, Vineet Gupta wrote: > > It seems prune_expressions is for pruning blocks with an incoming > abnormal edge. the right place for this handling. asm goto has > ordinary edges: bb 2 -> bb 3 is fallthru and bb 2 -> bb 4 (label) has > no flags. Correct, but it's going to be hard to split edges out of an asm goto.? So in many respects it's like an abnormal, hence the desire to use those mechansisms rth put into gcse.c so many years ago. > > In fact looking in prune_expressions' comment, > > " It would > ? be best to implement this check along the lines of > ? should_hoist_expr_to_dom where the target block is already known > ? and, hence, there's no need to conservatively prune expressions on > ? "intermediate" set-and-jump instructions." > > which is what this patch does. Oh ;-)? You can tell it's been a long time since I looked at this stuff. Jeff From jeffrey.law@oss.qualcomm.com Mon Nov 2 04:36:58 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 21:36:58 -0700 Subject: [PATCH] libiberty: Update Makefile dependencies In-Reply-To: <20261101214808.388949-2-pietro@sociotechnical.xyz> References: <20261101214808.388949-2-pietro@sociotechnical.xyz> Message-ID: On 11/1/26 2:48 PM, Pietro Monteiro wrote: > Autoconf macros from config/hwcaps.m4, config/clang-plugin.m4, and > config/mmap.m4 were added to configure.ac, in commits > r14-5993-gf2c52c0dfde581, r16-4178-g6051a849aa1e8e, and > r17-5270-gd58a2bf47606f0, respectively. But they weren't added to > Makefile.in aclocal_deps. Add them so the files are tracked when > maintainer mode is enabled. > > I also ran a build with maintainer mode enabled and the liibterty make > targets maint-missing, maint-undoc, and maint-deps, which updated some > Makefile targets dependencies and regenerated the documentation. > > libiberty/ChangeLog: > > * Makefile.in (aclocal_deps): Depend on > ../config/clang-plugin.m4, ../config/hwcaps.m4, and > ../config/mmap.m4. > (./filedescriptor.$(objext)): Update dependencies. > (./filename_cmp.$(objext)): Likewise. > (./memrchr.$(objext)): Likewise. > ( ./pex-unix.$(objext)): Likewise. > (./setenv.$(objext)): Likewise. > ( ./xmalloc.$(objext)): Likewise. > * acinclude.m4: Stop including ../config/mmap.m4. > * aclocal.m4: Regenerate. > * functions.texi: Likewise. > > Signed-off-by: Pietro Monteiro LGTM and no issues from Sashiko either. Jeff From jeffrey.law@oss.qualcomm.com Mon Nov 2 04:42:16 2026 From: jeffrey.law@oss.qualcomm.com (Jeff Law) Date: Sun, 1 Nov 2026 21:42:16 -0700 Subject: [PATCH 2/2] tree-optimization/128102 - fix -Wuninitialized FPs from lowering switches late In-Reply-To: <20261029090402.3747255-3-yansendao@126.com> References: <20261029090402.3747255-1-yansendao@126.com> <20261029090402.3747255-3-yansendao@126.com> Message-ID: <4a6ca9e0-46a6-4c87-aa5e-286e932c7e78@oss.qualcomm.com> On 10/29/26 3:04 AM, Sendao Yan wrote: > Moving pass_lower_switch after the late jump threading changed the > control flow seen by the uninitialized warning pass, exposing two > false positives (PR107919 and PR44547). Both stem from the same > defect in uninit_analysis::is_use_guarded. > > is_use_guarded treats an empty use predicate (the PHI is defined and > used in the same block) as an unguarded use because init_use_preds > returns false when the predicate is empty. That is wrong: whether > such a use is guarded depends solely on the definition predicate, so > fall through and compute it. > > An empty (TRUE) use predicate is then matched by m_phi_def_preds being > TRUE, i.e. the value is defined on every path. Two spots made this > mismatch on a TRUE use predicate: > - predicate::simplify_2 folded a tautological disjunction to TRUE by > clearing m_preds but forgot to set m_cval, so a definition > predicate that simplified to TRUE was misread as FALSE ("never > defined"). Set m_cval as well. > - the fallback path only recognized an implied guard when the > relaxed definition predicate was a superset of the use predicate, > which is vacuous for a TRUE use predicate; simplify and normalize > the relaxed predicate and check relaxed.is_true () instead. > > gcc/ChangeLog: > > * gimple-predicate-analysis.cc (predicate::simplify_2): Set > m_cval when a disjunction simplifies to true. > (uninit_analysis::is_use_guarded): Do not return early for an > empty use predicate; skip the overlap pruning and use an > is_true-based superset test for an unconditional use; simplify > and normalize the relaxed definition predicate in the fallback > and test it with is_true for an unconditional use. Sashiko noted several medium/low issues.? Can you take a look at its output and either adjust your patch if the issues are real or if they're not real issues, just note it as a followup comment?? I'm not going to get to this tonight, but we might as well address whatever Sashiko found proactively. https://gcc.sashiko.dev/#/patchset/20261029090402.3747255-1-yansendao%40126.com Thanks, jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: From crazylht@gmail.com Mon Nov 2 06:04:01 2026 From: crazylht@gmail.com (Hongtao Liu) Date: Sun, 01 Nov 2026 22:04:01 -0800 Subject: [PATCH 0/3] i386: Fix AVX512 ISA checks for vextract and vpextrw/vpinsrw [PR128169] In-Reply-To: <20261029014242.3984641-1-lin1.hu@intel.com> References: <20261029014242.3984641-1-lin1.hu@intel.com> Message-ID: On Wed Oct 28, 2026 at 6:42 PM PDT, Hu, Lin1 wrote: > Hi, > > r17-5483 broke the ia32 vpinsrw scan in vect-bfloat16-2b.c (PR128169), > a -mavx512f -mno-avx512bw test. AVX-512BW is practically a baseline > for all AVX-512 capable processors, so this series doesn't tune codegen > for that configuration. It fixes two places that emit instructions > requiring an ISA that is not enabled, and adjusts the test. > > 1/3: Use zmm sources and 32x4 vextract forms without AVX512VL/DQ. > 2/3: Avoid xmm16-xmm31 for vpextrw/vpinsrw without AVX512BW. > 3/3: Only scan vpinsrw for 64-bit targets. > > Regtested on x86_64-pc-linux-gnu {-m32,}. > > Ok for trunk? Ok. > > Hu, Lin1 (3): > i386: Don't emit AVX512VL/AVX512DQ vextract forms without those ISAs > i386: Don't use xmm16-xmm31 for vpextrw/vpinsrw without AVX512BW > testsuite: Only scan vpinsrw for 64-bit in vect-bfloat16-2b.c > [PR128169] > > gcc/config/i386/i386.md | 8 ++-- > gcc/config/i386/sse.md | 18 +++++--- > .../i386/avx512f-vec-extract-novl-1.c | 17 ++++++++ > .../i386/avx512f-vec-extract-novl-2.c | 16 ++++++++ > .../i386/avx512vl-no-avx512bw-pextrw-1.c | 41 +++++++++++++++++++ > .../gcc.target/i386/vect-bfloat16-2b.c | 2 +- > 6 files changed, 91 insertions(+), 11 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/i386/avx512f-vec-extract-novl-1.c > create mode 100644 gcc/testsuite/gcc.target/i386/avx512f-vec-extract-novl-2.c > create mode 100644 gcc/testsuite/gcc.target/i386/avx512vl-no-avx512bw-pextrw-1.c > > -- > 2.31.1 From torbjorn.svensson@foss.st.com Mon Nov 2 06:10:36 2026 From: torbjorn.svensson@foss.st.com (Torbjorn SVENSSON) Date: Mon, 2 Nov 2026 07:10:36 +0100 Subject: [PATCH] testsuite: Use gcc-nm for symbol scans In-Reply-To: References: <20261101141813.2019428-1-torbjorn.svensson@foss.st.com> Message-ID: <789714dc-6b64-45fc-b138-aa97e4e78a2a@foss.st.com> On 2026-11-01 19:02, Mike Stump wrote: > On Nov 1, 2026, at 6:15?AM, Torbj?rn SVENSSON wrote: >> This fixes the following error for arm-none-eabi (probably other targets too): >> >> ERROR: gcc.dg/builtin-pi-linkage.c: error executing dg-final: arm-none-eabi-nm: builtin-pi-linkage.o: plugin needed to handle lto object >> >> Ok for trunk? > > Ok. > Pushed as r17-5796-gcfb45bb1e58aed. Kind regards, Torbj?rn From torbjorn.svensson@foss.st.com Mon Nov 2 06:11:34 2026 From: torbjorn.svensson@foss.st.com (Torbjorn SVENSSON) Date: Mon, 2 Nov 2026 07:11:34 +0100 Subject: [PATCH] testsuite: XFAIL pr125734.c on targets without CLZ support In-Reply-To: <7d6e00ea-c16f-4abf-a5e3-41f4603b83f9@oss.qualcomm.com> References: <20261101092433.1988785-1-torbjorn.svensson@foss.st.com> <7d6e00ea-c16f-4abf-a5e3-41f4603b83f9@oss.qualcomm.com> Message-ID: <3d2fdc60-8ed2-4f77-bcb2-b2d5de0e2e9b@foss.st.com> On 2026-11-01 15:01, Jeff Law wrote: > > > On 11/1/26 2:19 AM, Torbj?rn SVENSSON wrote: >> Hi, >> >> The test fails for Cortex-M0 (arm-none-eabi) for, what I belive, the same reason as >> the xfail on hppa*-*-hpux* in r17-4470-ge741ce45698e48. >> >> spawn -ignore SIGHUP /build/r17-5743-ge33129b871c302/bin/arm-none-eabi-gcc /build/gcc_src/gcc/testsuite/gcc.dg/tree-ssa/pr125734.c -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -mfpu=auto -fdiagnostics-plain-output -O2 -fdump-tree-optimized -S -o pr125734.s >> ... >> PASS: gcc.dg/tree-ssa/pr125734.c (test for excess errors) >> gcc.dg/tree-ssa/pr125734.c: pattern found 0 times >> FAIL: gcc.dg/tree-ssa/pr125734.c scan-tree-dump-times optimized "\\.CLZ" 1 >> >> Ok for trunk? >> >> -- >> >> The test fails on targets without CLZ support. >> >> gcc/testsuite/ChangeLog: >> >> ????* gcc.dg/tree-ssa/pr125734.c: XFAIl on !clz. > OK > jeff Pushed as r17-5797-g68f08cc10a7647. Kind regards, Torbj?rn From haochen.jiang@intel.com Mon Nov 2 06:16:23 2026 From: haochen.jiang@intel.com (Jiang, Haochen) Date: Mon, 2 Nov 2026 06:16:23 +0000 Subject: [PATCH v3 1/4] [X86]: Initial support for AVX10V1AUX In-Reply-To: <20261101134756.351245-2-Dipesh.Sharma@amd.com> References: <20261101134756.351245-1-Dipesh.Sharma@amd.com> <20261101134756.351245-2-Dipesh.Sharma@amd.com> Message-ID: > From: Dipesh Sharma > Sent: Sunday, November 1, 2026 9:48 PM > LGTM with minor comments resolved. > gcc/ChangeLog: > > * common/config/i386/cpuinfo.h (get_available_features): Add > AVX10V1AUX. > * common/config/i386/i386-common.cc > (OPTION_MASK_ISA2_AVX10V1AUX_SET): New. > (OPTION_MASK_ISA2_AVX10_1_UNSET): Disable AVX10V1AUX. > (OPTION_MASK_ISA2_AVX10V2AUX_UNSET): Disable ACEV1. You did not touch this line. > (OPTION_MASK_ISA2_AVX10V1AUX_UNSET): Disable ACEV1. > (ix86_handle_option): Handle AVX10V1AUX. > * common/config/i386/i386-cpuinfo.h (enum processor_features): > Add FEATURE_AVX10V1AUX. > * common/config/i386/i386-isas.h: Handle avx10v1aux. > * config/i386/cpuid.h (bit_AVX10V1AUX): New. > * config/i386/i386-c.cc (ix86_target_macros_internal): Handle > avx10v1aux. > * config/i386/i386-isa.def (AVX10V1AUX): New. > * config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p): > Handle Ditto.. What do you mean by this? > * config/i386/i386.h: Add PTA_AVX10V1AUX to targets using > PTA_AVX10_2. > * config/i386/i386.opt: Add avx10v1aux. > * config/i386/i386.opt.urls: Regenerated. > * doc/extend.texi: Add avx10v1aux documentation. > * doc/invoke.texi: Ditto. > * doc/sourcebuild.texi: Ditto. > > diff --git a/gcc/common/config/i386/i386-common.cc > b/gcc/common/config/i386/i386-common.cc > index ed126f4c70dc..2ca4f9a911e8 100644 > --- a/gcc/common/config/i386/i386-common.cc > +++ b/gcc/common/config/i386/i386-common.cc > @@ -142,6 +143,8 @@ along with GCC; see the file COPYING3. If not see > (OPTION_MASK_ISA2_AVX10_1_SET | OPTION_MASK_ISA2_AVX10V2AUX) > #define OPTION_MASK_ISA2_ACEV1_SET \ > (OPTION_MASK_ISA2_AVX10V2AUX_SET | OPTION_MASK_ISA2_ACEV1) You could also set AVX10V1AUX here since we use imply now and ... > +#define OPTION_MASK_ISA2_AVX10V1AUX_SET \ > + (OPTION_MASK_ISA2_AVX10_1_SET | > OPTION_MASK_ISA2_AVX10V1AUX) > > @@ -338,6 +341,9 @@ along with GCC; see the file COPYING3. If not see > #define OPTION_MASK_ISA2_AVX10V2AUX_UNSET \ > (OPTION_MASK_ISA2_AVX10V2AUX | OPTION_MASK_ISA2_ACEV1_UNSET) > #define OPTION_MASK_ISA2_ACEV1_UNSET OPTION_MASK_ISA2_ACEV1 > +#define OPTION_MASK_ISA2_AVX10V1AUX_UNSET \ > + (OPTION_MASK_ISA2_AVX10V1AUX | OPTION_MASK_ISA2_AVX10_2_UNSET \ > + | OPTION_MASK_ISA2_ACEV1_UNSET) ... you also unset acev1 for avx10v1aux here. Thx, Haochen From haochen.jiang@intel.com Mon Nov 2 06:17:46 2026 From: haochen.jiang@intel.com (Jiang, Haochen) Date: Mon, 2 Nov 2026 06:17:46 +0000 Subject: [PATCH v3 2/4] [X86]: Move shared AVX10.2 convert intrinsics to AVX10V1AUX. In-Reply-To: <20261101134756.351245-3-Dipesh.Sharma@amd.com> References: <20261101134756.351245-1-Dipesh.Sharma@amd.com> <20261101134756.351245-3-Dipesh.Sharma@amd.com> Message-ID: > From: Dipesh Sharma > Sent: Sunday, November 1, 2026 9:48 PM LGTM. Thx, Haochen > > gcc/ChangeLog: > > * config.gcc: Add avx10v1auxintrin.h. > * config/i386/avx10_2convertintrin.h: Moved convert intrins to > avx10v1auxintrin.h. > * config/i386/i386-builtin.def (BDESC): Updated option mask for > convert builtins. > * config/i386/immintrin.h: Include avx10v1auxintrin.h. > * config/i386/sse.md: Retarget avx10.2 subset convert patterns to > AVX10V1AUX. > * config/i386/avx10v1auxintrin.h: New file. > > gcc/testsuite/ChangeLog: > > * gcc.target/i386/funcspec-56.inc: Check for avx10v1aux. > * lib/target-supports.exp: Ditto. > * gcc.target/i386/avx10v1aux-1a.c: New test. > > Co-authored-by: Venkataramanan Kumar > > --- > gcc/config.gcc | 2 +- > gcc/config/i386/avx10_2convertintrin.h | 1376 ---------------- > gcc/config/i386/avx10v1auxintrin.h | 1427 +++++++++++++++++ > gcc/config/i386/i386-builtin.def | 92 +- > gcc/config/i386/immintrin.h | 2 + > gcc/config/i386/sse.md | 37 +- > gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c | 375 +++++ > gcc/testsuite/gcc.target/i386/funcspec-56.inc | 2 + > gcc/testsuite/lib/target-supports.exp | 11 + > 9 files changed, 1881 insertions(+), 1443 deletions(-) > create mode 100644 gcc/config/i386/avx10v1auxintrin.h > create mode 100644 gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c > > diff --git a/gcc/config.gcc b/gcc/config.gcc > index d651c3aae37e..4369ebd3f6d9 100644 > --- a/gcc/config.gcc > +++ b/gcc/config.gcc > @@ -489,7 +489,7 @@ i[34567]86-*-* | x86_64-*-*) > avx10_2minmaxintrin.h avx10_2copyintrin.h > amxavx512intrin.h amxfp8intrin.h movrsintrin.h > amxmovrsintrin.h avx512bmmintrin.h > avx512bmmvlintrin.h > - avx10v2auxintrin.h acev1intrin.h" > + avx10v2auxintrin.h avx10v1auxintrin.h acev1intrin.h" > ;; > ia64-*-*) > extra_headers=ia64intrin.h > diff --git a/gcc/config/i386/avx10_2convertintrin.h > b/gcc/config/i386/avx10_2convertintrin.h > index fad82e75ca39..aebb5cd8d7c2 100644 > --- a/gcc/config/i386/avx10_2convertintrin.h > +++ b/gcc/config/i386/avx10_2convertintrin.h > @@ -34,1382 +34,6 @@ > #define __DISABLE_AVX10_2__ > #endif /* __AVX10_2__ */ > > -extern __inline __m128h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvtx2ps_ph (__m128 __A, __m128 __B) > -{ > - return (__m128h) __builtin_ia32_vcvt2ps2phx128_mask ((__v4sf) __A, > - (__v4sf) __B, > - (__v8hf) > - _mm_setzero_ph (), > - (__mmask8) -1); > -} > - > -extern __inline __m128h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvtx2ps_ph (__m128h __W, __mmask8 __U, __m128 __A, > __m128 __B) > -{ > - return (__m128h) __builtin_ia32_vcvt2ps2phx128_mask ((__v4sf) __A, > - (__v4sf) __B, > - (__v8hf) __W, > - (__mmask8) __U); > -} > - > -extern __inline __m128h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvtx2ps_ph (__mmask8 __U, __m128 __A, __m128 __B) > -{ > - return (__m128h) __builtin_ia32_vcvt2ps2phx128_mask ((__v4sf) __A, > - (__v4sf) __B, > - (__v8hf) > - _mm_setzero_ph (), > - (__mmask8) __U); > -} > - > -extern __inline __m256h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvtx2ps_ph (__m256 __A, __m256 __B) > -{ > - return (__m256h) __builtin_ia32_vcvt2ps2phx256_mask ((__v8sf) __A, > - (__v8sf) __B, > - (__v16hf) > - _mm256_setzero_ph (), > - (__mmask16) -1); > -} > - > -extern __inline __m256h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvtx2ps_ph (__m256h __W, __mmask16 __U, __m256 __A, > __m256 __B) > -{ > - return (__m256h) __builtin_ia32_vcvt2ps2phx256_mask ((__v8sf) __A, > - (__v8sf) __B, > - (__v16hf) __W, > - (__mmask16) __U); > -} > - > -extern __inline __m256h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvtx2ps_ph ( __mmask16 __U, __m256 __A, __m256 __B) > -{ > - return (__m256h) __builtin_ia32_vcvt2ps2phx256_mask ((__v8sf) __A, > - (__v8sf) __B, > - (__v16hf) > - _mm256_setzero_ph (), > - (__mmask16) __U); > -} > - > -extern __inline __m512h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvtx2ps_ph (__m512 __A, __m512 __B) > -{ > - return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) > __A, > - (__v16sf) __B, > - (__v32hf) > - > _mm512_setzero_ph (), > - (__mmask32) -1, > - > _MM_FROUND_CUR_DIRECTION); > -} > - > -extern __inline __m512h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvtx2ps_ph (__m512h __W, __mmask32 __U, __m512 __A, > - __m512 __B) > -{ > - return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) > __A, > - (__v16sf) __B, > - (__v32hf) __W, > - (__mmask32) __U, > - > _MM_FROUND_CUR_DIRECTION); > -} > - > -extern __inline __m512h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvtx2ps_ph (__mmask32 __U, __m512 __A, __m512 __B) > -{ > - return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) > __A, > - (__v16sf) __B, > - (__v32hf) > - > _mm512_setzero_ph (), > - (__mmask32) __U, > - > _MM_FROUND_CUR_DIRECTION); > -} > - > -#ifdef __OPTIMIZE__ > -extern __inline __m512h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvtx_round2ps_ph (__m512 __A, __m512 __B, const int __R) > -{ > - return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) > __A, > - (__v16sf) __B, > - (__v32hf) > - > _mm512_setzero_ph (), > - (__mmask32) -1, > - __R); > -} > - > -extern __inline __m512h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvtx_round2ps_ph (__m512h __W, __mmask32 __U, > __m512 __A, > - __m512 __B, const int __R) > -{ > - return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) > __A, > - (__v16sf) __B, > - (__v32hf) __W, > - (__mmask32) __U, > - __R); > -} > - > -extern __inline __m512h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvtx_round2ps_ph (__mmask32 __U, __m512 __A, > - __m512 __B, const int __R) > -{ > - return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) > __A, > - (__v16sf) __B, > - (__v32hf) > - > _mm512_setzero_ph (), > - (__mmask32) __U, > - __R); > -} > - > -#else > -#define _mm512_cvtx_round2ps_ph(A, B, R) \ > - ((__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) (A), \ > - (__v16sf) (B), \ > - (__v32hf) \ > - (_mm512_setzero_ph ()), > \ > - (__mmask32) (-1), \ > - (R))) > -#define _mm512_mask_cvtx_round2ps_ph(W, U, A, B, R) \ > - ((__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) (A), \ > - (__v16sf) (B), \ > - (__v32hf) (W), \ > - (__mmask32) (U), \ > - (R))) > -#define _mm512_maskz_cvtx_round2ps_ph(U, A, B, R) \ > - ((__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) (A), \ > - (__v16sf) (B), \ > - (__v32hf) \ > - (_mm512_setzero_ph ()), > \ > - (__mmask32) (U), \ > - (R))) > -#endif /* __OPTIMIZE__ */ > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvtbiasph_bf8 (__m128i __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2bf8128 ((__v16qi) __A, > - (__v8hf) __B); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvtbiasph_bf8 (__m128i __W, __mmask8 __U, __m128i __A, > - __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2bf8128_mask ((__v16qi) __A, > - (__v8hf) __B, > - (__v16qi)(__m128i) > __W, > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvtbiasph_bf8 (__mmask8 __U, __m128i __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2bf8128_mask ((__v16qi) __A, > - (__v8hf) __B, > - (__v16qi)(__m128i) > - _mm_setzero_si128 > (), > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvtbiasph_bf8 (__m256i __A, __m256h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2bf8256_mask ((__v32qi) __A, > - (__v16hf) __B, > - (__v16qi)(__m128i) > - > _mm_undefined_si128 (), > - (__mmask16) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvtbiasph_bf8 (__m128i __W, __mmask16 __U, __m256i > __A, > - __m256h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2bf8256_mask ((__v32qi) __A, > - (__v16hf) __B, > - (__v16qi)(__m128i) > __W, > - (__mmask16) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvtbiasph_bf8 (__mmask16 __U, __m256i __A, __m256h > __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2bf8256_mask ((__v32qi) __A, > - (__v16hf) __B, > - (__v16qi)(__m128i) > - _mm_setzero_si128 > (), > - (__mmask16) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvtbiasph_bf8 (__m512i __A, __m512h __B) > -{ > - return (__m256i) __builtin_ia32_vcvtbiasph2bf8512_mask ((__v64qi) __A, > - (__v32hf) __B, > - (__v32qi)(__m256i) > - > _mm256_undefined_si256 (), > - (__mmask32) -1); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvtbiasph_bf8 (__m256i __W, __mmask32 __U, > - __m512i __A, __m512h __B) > -{ > - return (__m256i) __builtin_ia32_vcvtbiasph2bf8512_mask ((__v64qi) __A, > - (__v32hf) __B, > - (__v32qi)(__m256i) > __W, > - (__mmask32) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvtbiasph_bf8 (__mmask32 __U, __m512i __A, __m512h > __B) > -{ > - return (__m256i) __builtin_ia32_vcvtbiasph2bf8512_mask ((__v64qi) __A, > - (__v32hf) __B, > - (__v32qi)(__m256i) > - > _mm256_setzero_si256 (), > - (__mmask32) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvts_biasph_bf8 (__m128i __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2bf8s128 ((__v16qi) __A, > - (__v8hf) __B); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvts_biasph_bf8 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2bf8s128_mask ((__v16qi) __A, > - (__v8hf) __B, > - (__v16qi)(__m128i) > __W, > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvts_biasph_bf8 (__mmask8 __U, __m128i __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2bf8s128_mask ((__v16qi) __A, > - (__v8hf) __B, > - (__v16qi)(__m128i) > - _mm_setzero_si128 > (), > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvts_biasph_bf8 (__m256i __A, __m256h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2bf8s256_mask ((__v32qi) __A, > - (__v16hf) __B, > - (__v16qi)(__m128i) > - > _mm_undefined_si128 (), > - (__mmask16) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvts_biasph_bf8 (__m128i __W, __mmask16 __U, > - __m256i __A, __m256h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2bf8s256_mask ((__v32qi) __A, > - (__v16hf) __B, > - (__v16qi)(__m128i) > __W, > - (__mmask16) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvts_biasph_bf8 (__mmask16 __U, __m256i __A, __m256h > __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2bf8s256_mask ((__v32qi) __A, > - (__v16hf) __B, > - (__v16qi)(__m128i) > - _mm_setzero_si128 > (), > - (__mmask16) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvts_biasph_bf8 (__m512i __A, __m512h __B) > -{ > - return (__m256i) __builtin_ia32_vcvtbiasph2bf8s512_mask ((__v64qi) __A, > - (__v32hf) __B, > - (__v32qi)(__m256i) > - > _mm256_undefined_si256 (), > - (__mmask32) -1); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvts_biasph_bf8 (__m256i __W, __mmask32 __U, > - __m512i __A, __m512h __B) > -{ > - return (__m256i) __builtin_ia32_vcvtbiasph2bf8s512_mask ((__v64qi) __A, > - (__v32hf) __B, > - (__v32qi)(__m256i) > __W, > - (__mmask32) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvts_biasph_bf8 (__mmask32 __U, __m512i __A, __m512h > __B) > -{ > - return (__m256i) __builtin_ia32_vcvtbiasph2bf8s512_mask ((__v64qi) __A, > - (__v32hf) __B, > - (__v32qi)(__m256i) > - > _mm256_setzero_si256 (), > - (__mmask32) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvtbiasph_hf8 (__m128i __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2hf8128 ((__v16qi) __A, > - (__v8hf) __B); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvtbiasph_hf8 (__m128i __W, __mmask8 __U, __m128i __A, > - __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2hf8128_mask ((__v16qi) __A, > - (__v8hf) __B, > - (__v16qi)(__m128i) > __W, > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvtbiasph_hf8 (__mmask8 __U, __m128i __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2hf8128_mask ((__v16qi) __A, > - (__v8hf) __B, > - (__v16qi)(__m128i) > - _mm_setzero_si128 > (), > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvtbiasph_hf8 (__m256i __A, __m256h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2hf8256_mask ((__v32qi) __A, > - (__v16hf) __B, > - (__v16qi)(__m128i) > - > _mm_undefined_si128 (), > - (__mmask16) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvtbiasph_hf8 (__m128i __W, __mmask16 __U, > - __m256i __A, __m256h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2hf8256_mask ((__v32qi) __A, > - (__v16hf) __B, > - (__v16qi)(__m128i) > __W, > - (__mmask16) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvtbiasph_hf8 (__mmask16 __U, __m256i __A, __m256h > __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2hf8256_mask ((__v32qi) __A, > - (__v16hf) __B, > - (__v16qi)(__m128i) > - _mm_setzero_si128 > (), > - (__mmask16) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvtbiasph_hf8 (__m512i __A, __m512h __B) > -{ > - return (__m256i) __builtin_ia32_vcvtbiasph2hf8512_mask ((__v64qi) __A, > - (__v32hf) __B, > - (__v32qi)(__m256i) > - > _mm256_undefined_si256 (), > - (__mmask32) -1); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvtbiasph_hf8 (__m256i __W, __mmask32 __U, __m512i > __A, > - __m512h __B) > -{ > - return (__m256i) __builtin_ia32_vcvtbiasph2hf8512_mask ((__v64qi) __A, > - (__v32hf) __B, > - (__v32qi)(__m256i) > __W, > - (__mmask32) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvtbiasph_hf8 (__mmask32 __U, __m512i __A, __m512h > __B) > -{ > - return (__m256i) __builtin_ia32_vcvtbiasph2hf8512_mask ((__v64qi) __A, > - (__v32hf) __B, > - (__v32qi)(__m256i) > - > _mm256_setzero_si256 (), > - (__mmask32) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvts_biasph_hf8 (__m128i __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2hf8s128 ((__v16qi) __A, > - (__v8hf) __B); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvts_biasph_hf8 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2hf8s128_mask ((__v16qi) __A, > - (__v8hf) __B, > - (__v16qi)(__m128i) > __W, > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvts_biasph_hf8 (__mmask8 __U, __m128i __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2hf8s128_mask ((__v16qi) __A, > - (__v8hf) __B, > - (__v16qi)(__m128i) > - _mm_setzero_si128 > (), > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvts_biasph_hf8 (__m256i __A, __m256h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2hf8s256_mask ((__v32qi) __A, > - (__v16hf) __B, > - (__v16qi)(__m128i) > - > _mm_undefined_si128 (), > - (__mmask16) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvts_biasph_hf8 (__m128i __W, __mmask16 __U, > - __m256i __A, __m256h __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2hf8s256_mask ((__v32qi) __A, > - (__v16hf) __B, > - (__v16qi)(__m128i) > __W, > - (__mmask16) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvts_biasph_hf8 (__mmask16 __U, __m256i __A, __m256h > __B) > -{ > - return (__m128i) __builtin_ia32_vcvtbiasph2hf8s256_mask ((__v32qi) __A, > - (__v16hf) __B, > - (__v16qi)(__m128i) > - _mm_setzero_si128 > (), > - (__mmask16) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvts_biasph_hf8 (__m512i __A, __m512h __B) > -{ > - return (__m256i) __builtin_ia32_vcvtbiasph2hf8s512_mask ((__v64qi) __A, > - (__v32hf) __B, > - (__v32qi)(__m256i) > - > _mm256_undefined_si256 (), > - (__mmask32) -1); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvts_biasph_hf8 (__m256i __W, __mmask32 __U, > - __m512i __A, __m512h __B) > -{ > - return (__m256i) __builtin_ia32_vcvtbiasph2hf8s512_mask ((__v64qi) __A, > - (__v32hf) __B, > - (__v32qi)(__m256i) > __W, > - (__mmask32) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvts_biasph_hf8 (__mmask32 __U, __m512i __A, __m512h > __B) > -{ > - return (__m256i) __builtin_ia32_vcvtbiasph2hf8s512_mask ((__v64qi) __A, > - (__v32hf) __B, > - (__v32qi)(__m256i) > - > _mm256_setzero_si256 (), > - (__mmask32) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvt2ph_bf8 (__m128h __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvt2ph2bf8128_mask ((__v8hf) __A, > - (__v8hf) __B, > - (__v16qi) > - _mm_setzero_si128 (), > - (__mmask16) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvt2ph_bf8 (__m128i __W, __mmask16 __U, > - __m128h __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvt2ph2bf8128_mask ((__v8hf) __A, > - (__v8hf) __B, > - (__v16qi) __W, > - (__mmask16) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvt2ph_bf8 (__mmask16 __U, __m128h __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvt2ph2bf8128_mask ((__v8hf) __A, > - (__v8hf) __B, > - (__v16qi) > - _mm_setzero_si128 (), > - (__mmask16) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvt2ph_bf8 (__m256h __A, __m256h __B) > -{ > - return (__m256i) __builtin_ia32_vcvt2ph2bf8256_mask ((__v16hf) __A, > - (__v16hf) __B, > - (__v32qi) > - _mm256_setzero_si256 > (), > - (__mmask32) -1); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvt2ph_bf8 (__m256i __W, __mmask32 __U, > - __m256h __A, __m256h __B) > -{ > - return (__m256i) __builtin_ia32_vcvt2ph2bf8256_mask ((__v16hf) __A, > - (__v16hf) __B, > - (__v32qi) __W, > - (__mmask32) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvt2ph_bf8 (__mmask32 __U, __m256h __A, __m256h > __B) > -{ > - return (__m256i) __builtin_ia32_vcvt2ph2bf8256_mask ((__v16hf) __A, > - (__v16hf) __B, > - (__v32qi) > - _mm256_setzero_si256 > (), > - (__mmask32) __U); > -} > - > -extern __inline__ __m512i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvt2ph_bf8 (__m512h __A, __m512h __B) > -{ > - return (__m512i) __builtin_ia32_vcvt2ph2bf8512_mask ((__v32hf) __A, > - (__v32hf) __B, > - (__v64qi) > - _mm512_setzero_si512 > (), > - (__mmask64) -1); > -} > - > -extern __inline__ __m512i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvt2ph_bf8 (__m512i __W, __mmask64 __U, > - __m512h __A, __m512h __B) > -{ > - return (__m512i) __builtin_ia32_vcvt2ph2bf8512_mask ((__v32hf) __A, > - (__v32hf) __B, > - (__v64qi) __W, > - (__mmask64) __U); > -} > - > -extern __inline__ __m512i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvt2ph_bf8 (__mmask64 __U, __m512h __A, __m512h > __B) > -{ > - return (__m512i) __builtin_ia32_vcvt2ph2bf8512_mask ((__v32hf) __A, > - (__v32hf) __B, > - (__v64qi) > - _mm512_setzero_si512 > (), > - (__mmask64) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvts_2ph_bf8 (__m128h __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvt2ph2bf8s128_mask ((__v8hf) __A, > - (__v8hf) __B, > - (__v16qi) > - _mm_setzero_si128 > (), > - (__mmask16) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvts_2ph_bf8 (__m128i __W, __mmask16 __U, > - __m128h __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvt2ph2bf8s128_mask ((__v8hf) __A, > - (__v8hf) __B, > - (__v16qi) __W, > - (__mmask16) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvts_2ph_bf8 (__mmask16 __U, __m128h __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvt2ph2bf8s128_mask ((__v8hf) __A, > - (__v8hf) __B, > - (__v16qi) > - _mm_setzero_si128 > (), > - (__mmask16) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvts_2ph_bf8 (__m256h __A, __m256h __B) > -{ > - return (__m256i) __builtin_ia32_vcvt2ph2bf8s256_mask ((__v16hf) __A, > - (__v16hf) __B, > - (__v32qi) > - > _mm256_setzero_si256 (), > - (__mmask32) -1); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvts_2ph_bf8 (__m256i __W, __mmask32 __U, > - __m256h __A, __m256h __B) > -{ > - return (__m256i) __builtin_ia32_vcvt2ph2bf8s256_mask ((__v16hf) __A, > - (__v16hf) __B, > - (__v32qi) __W, > - (__mmask32) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvts_2ph_bf8 (__mmask32 __U, __m256h __A, __m256h > __B) > -{ > - return (__m256i) __builtin_ia32_vcvt2ph2bf8s256_mask ((__v16hf) __A, > - (__v16hf) __B, > - (__v32qi) > - > _mm256_setzero_si256 (), > - (__mmask32) __U); > -} > - > -extern __inline__ __m512i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvts_2ph_bf8 (__m512h __A, __m512h __B) > -{ > - return (__m512i) __builtin_ia32_vcvt2ph2bf8s512_mask ((__v32hf) __A, > - (__v32hf) __B, > - (__v64qi) > - > _mm512_setzero_si512 (), > - (__mmask64) -1); > -} > - > -extern __inline__ __m512i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvts_2ph_bf8 (__m512i __W, __mmask64 __U, > - __m512h __A, __m512h __B) > -{ > - return (__m512i) __builtin_ia32_vcvt2ph2bf8s512_mask ((__v32hf) __A, > - (__v32hf) __B, > - (__v64qi) __W, > - (__mmask64) __U); > -} > - > -extern __inline__ __m512i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvts_2ph_bf8 (__mmask64 __U, __m512h __A, __m512h > __B) > -{ > - return (__m512i) __builtin_ia32_vcvt2ph2bf8s512_mask ((__v32hf) __A, > - (__v32hf) __B, > - (__v64qi) > - > _mm512_setzero_si512 (), > - (__mmask64) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvt2ph_hf8 (__m128h __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvt2ph2hf8128_mask ((__v8hf) __A, > - (__v8hf) __B, > - (__v16qi) > - _mm_setzero_si128 (), > - (__mmask16) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvt2ph_hf8 (__m128i __W, __mmask16 __U, > - __m128h __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvt2ph2hf8128_mask ((__v8hf) __A, > - (__v8hf) __B, > - (__v16qi) __W, > - (__mmask16) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvt2ph_hf8 (__mmask16 __U, __m128h __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvt2ph2hf8128_mask ((__v8hf) __A, > - (__v8hf) __B, > - (__v16qi) > - _mm_setzero_si128 (), > - (__mmask16) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvt2ph_hf8 (__m256h __A, __m256h __B) > -{ > - return (__m256i) __builtin_ia32_vcvt2ph2hf8256_mask ((__v16hf) __A, > - (__v16hf) __B, > - (__v32qi) > - _mm256_setzero_si256 > (), > - (__mmask32) -1); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvt2ph_hf8 (__m256i __W, __mmask32 __U, > - __m256h __A, __m256h __B) > -{ > - return (__m256i) __builtin_ia32_vcvt2ph2hf8256_mask ((__v16hf) __A, > - (__v16hf) __B, > - (__v32qi) __W, > - (__mmask32) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvt2ph_hf8 (__mmask32 __U, __m256h __A, __m256h > __B) > -{ > - return (__m256i) __builtin_ia32_vcvt2ph2hf8256_mask ((__v16hf) __A, > - (__v16hf) __B, > - (__v32qi) > - _mm256_setzero_si256 > (), > - (__mmask32) __U); > -} > - > -extern __inline__ __m512i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvt2ph_hf8 (__m512h __A, __m512h __B) > -{ > - return (__m512i) __builtin_ia32_vcvt2ph2hf8512_mask ((__v32hf) __A, > - (__v32hf) __B, > - (__v64qi) > - _mm512_setzero_si512 > (), > - (__mmask64) -1); > -} > - > -extern __inline__ __m512i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvt2ph_hf8 (__m512i __W, __mmask64 __U, > - __m512h __A, __m512h __B) > -{ > - return (__m512i) __builtin_ia32_vcvt2ph2hf8512_mask ((__v32hf) __A, > - (__v32hf) __B, > - (__v64qi) __W, > - (__mmask64) __U); > -} > - > -extern __inline__ __m512i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvt2ph_hf8 (__mmask64 __U, __m512h __A, __m512h > __B) > -{ > - return (__m512i) __builtin_ia32_vcvt2ph2hf8512_mask ((__v32hf) __A, > - (__v32hf) __B, > - (__v64qi) > - _mm512_setzero_si512 > (), > - (__mmask64) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvts_2ph_hf8 (__m128h __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvt2ph2hf8s128_mask ((__v8hf) __A, > - (__v8hf) __B, > - (__v16qi) > - _mm_setzero_si128 > (), > - (__mmask16) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvts_2ph_hf8 (__m128i __W, __mmask16 __U, > - __m128h __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvt2ph2hf8s128_mask ((__v8hf) __A, > - (__v8hf) __B, > - (__v16qi) __W, > - (__mmask16) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvts_2ph_hf8 (__mmask16 __U, __m128h __A, __m128h __B) > -{ > - return (__m128i) __builtin_ia32_vcvt2ph2hf8s128_mask ((__v8hf) __A, > - (__v8hf) __B, > - (__v16qi) > - _mm_setzero_si128 > (), > - (__mmask16) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvts_2ph_hf8 (__m256h __A, __m256h __B) > -{ > - return (__m256i) __builtin_ia32_vcvt2ph2hf8s256_mask ((__v16hf) __A, > - (__v16hf) __B, > - (__v32qi) > - > _mm256_setzero_si256 (), > - (__mmask32) -1); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvts_2ph_hf8 (__m256i __W, __mmask32 __U, > - __m256h __A, __m256h __B) > -{ > - return (__m256i) __builtin_ia32_vcvt2ph2hf8s256_mask ((__v16hf) __A, > - (__v16hf) __B, > - (__v32qi) __W, > - (__mmask32) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvts_2ph_hf8 (__mmask32 __U, __m256h __A, __m256h > __B) > -{ > - return (__m256i) __builtin_ia32_vcvt2ph2hf8s256_mask ((__v16hf) __A, > - (__v16hf) __B, > - (__v32qi) > - > _mm256_setzero_si256 (), > - (__mmask32) __U); > -} > - > -extern __inline__ __m512i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvts_2ph_hf8 (__m512h __A, __m512h __B) > -{ > - return (__m512i) __builtin_ia32_vcvt2ph2hf8s512_mask ((__v32hf) __A, > - (__v32hf) __B, > - (__v64qi) > - > _mm512_setzero_si512 (), > - (__mmask64) -1); > -} > - > -extern __inline__ __m512i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvts_2ph_hf8 (__m512i __W, __mmask64 __U, > - __m512h __A, __m512h __B) > -{ > - return (__m512i) __builtin_ia32_vcvt2ph2hf8s512_mask ((__v32hf) __A, > - (__v32hf) __B, > - (__v64qi) __W, > - (__mmask64) __U); > -} > - > -extern __inline__ __m512i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvts_2ph_hf8 (__mmask64 __U, __m512h __A, __m512h > __B) > -{ > - return (__m512i) __builtin_ia32_vcvt2ph2hf8s512_mask ((__v32hf) __A, > - (__v32hf) __B, > - (__v64qi) > - > _mm512_setzero_si512 (), > - (__mmask64) __U); > -} > - > -extern __inline__ __m128h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvthf8_ph (__m128i __A) > -{ > - return (__m128h) __builtin_ia32_vcvthf82ph128_mask ((__v16qi) __A, > - (__v8hf)(__m128h) > - _mm_undefined_ph (), > - (__mmask8) -1); > -} > - > -extern __inline__ __m128h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvthf8_ph (__m128h __W, __mmask8 __U, __m128i __A) > -{ > - return (__m128h) __builtin_ia32_vcvthf82ph128_mask ((__v16qi) __A, > - (__v8hf)(__m128h) __W, > - (__mmask8) __U); > -} > - > -extern __inline__ __m128h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvthf8_ph (__mmask8 __U, __m128i __A) > -{ > - return (__m128h) __builtin_ia32_vcvthf82ph128_mask ((__v16qi) __A, > - (__v8hf)(__m128h) > - _mm_setzero_ph (), > - (__mmask8) __U); > -} > - > -extern __inline__ __m256h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvthf8_ph (__m128i __A) > -{ > - return (__m256h) __builtin_ia32_vcvthf82ph256_mask ((__v16qi) __A, > - (__v16hf)(__m256h) > - _mm256_undefined_ph (), > - (__mmask16) -1); > -} > - > -extern __inline__ __m256h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvthf8_ph (__m256h __W, __mmask16 __U, __m128i __A) > -{ > - return (__m256h) __builtin_ia32_vcvthf82ph256_mask ((__v16qi) __A, > - (__v16hf)(__m256h) __W, > - (__mmask16) __U); > -} > - > -extern __inline__ __m256h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvthf8_ph (__mmask16 __U, __m128i __A) > -{ > - return (__m256h) __builtin_ia32_vcvthf82ph256_mask ((__v16qi) __A, > - (__v16hf)(__m256h) > - _mm256_setzero_ph (), > - (__mmask16) __U); > -} > - > -extern __inline__ __m512h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvthf8_ph (__m256i __A) > -{ > - return (__m512h) __builtin_ia32_vcvthf82ph512_mask ((__v32qi) __A, > - (__v32hf) (__m512h) > - _mm512_undefined_ph (), > - (__mmask32) -1); > -} > - > -extern __inline__ __m512h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvthf8_ph (__m512h __W, __mmask32 __U, __m256i __A) > -{ > - return (__m512h) __builtin_ia32_vcvthf82ph512_mask ((__v32qi) __A, > - (__v32hf) (__m512h) __W, > - (__mmask32) __U); > -} > - > -extern __inline__ __m512h > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvthf8_ph (__mmask32 __U, __m256i __A) > -{ > - return (__m512h) __builtin_ia32_vcvthf82ph512_mask ((__v32qi) __A, > - (__v32hf) (__m512h) > - _mm512_setzero_ph (), > - (__mmask32) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvtph_bf8 (__m128h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2bf8128_mask ((__v8hf) __A, > - (__v16qi)(__m128i) > - _mm_undefined_si128 (), > - (__mmask8) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvtph_bf8 (__m128i __W, __mmask8 __U, __m128h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2bf8128_mask ((__v8hf) __A, > - (__v16qi)(__m128i) __W, > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvtph_bf8 (__mmask8 __U, __m128h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2bf8128_mask ((__v8hf) __A, > - (__v16qi)(__m128i) > - _mm_setzero_si128 (), > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvtph_bf8 (__m256h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2bf8256_mask ((__v16hf) __A, > - (__v16qi)(__m128i) > - _mm_undefined_si128 (), > - (__mmask16) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvtph_bf8 (__m128i __W, __mmask16 __U, __m256h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2bf8256_mask ((__v16hf) __A, > - (__v16qi)(__m128i) __W, > - (__mmask16) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvtph_bf8 (__mmask16 __U, __m256h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2bf8256_mask ((__v16hf) __A, > - (__v16qi)(__m128i) > - _mm_setzero_si128 (), > - (__mmask16) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvtph_bf8 (__m512h __A) > -{ > - return (__m256i) __builtin_ia32_vcvtph2bf8512_mask ((__v32hf) __A, > - (__v32qi) (__m256i) > - _mm256_undefined_si256 > (), > - (__mmask32) -1); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvtph_bf8 (__m256i __W, __mmask32 __U, __m512h __A) > -{ > - return (__m256i) __builtin_ia32_vcvtph2bf8512_mask ((__v32hf) __A, > - (__v32qi) (__m256i) __W, > - (__mmask32) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvtph_bf8 (__mmask32 __U, __m512h __A) > -{ > - return (__m256i) __builtin_ia32_vcvtph2bf8512_mask ((__v32hf) __A, > - (__v32qi) (__m256i) > - _mm256_setzero_si256 (), > - (__mmask32) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvts_ph_bf8 (__m128h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2bf8s128_mask ((__v8hf) __A, > - (__v16qi)(__m128i) > - _mm_undefined_si128 (), > - (__mmask8) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvts_ph_bf8 (__m128i __W, __mmask8 __U, __m128h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2bf8s128_mask ((__v8hf) __A, > - (__v16qi)(__m128i) __W, > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvts_ph_bf8 (__mmask8 __U, __m128h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2bf8s128_mask ((__v8hf) __A, > - (__v16qi)(__m128i) > - _mm_setzero_si128 (), > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvts_ph_bf8 (__m256h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2bf8s256_mask ((__v16hf) __A, > - (__v16qi)(__m128i) > - _mm_undefined_si128 (), > - (__mmask16) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvts_ph_bf8 (__m128i __W, __mmask16 __U, __m256h > __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2bf8s256_mask ((__v16hf) __A, > - (__v16qi)(__m128i) __W, > - (__mmask16) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvts_ph_bf8 (__mmask16 __U, __m256h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2bf8s256_mask ((__v16hf) __A, > - (__v16qi)(__m128i) > - _mm_setzero_si128 (), > - (__mmask16) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvts_ph_bf8 (__m512h __A) > -{ > - return (__m256i) __builtin_ia32_vcvtph2bf8s512_mask ((__v32hf) __A, > - (__v32qi) (__m256i) > - > _mm256_undefined_si256 (), > - (__mmask32) -1); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvts_ph_bf8 (__m256i __W, __mmask32 __U, __m512h > __A) > -{ > - return (__m256i) __builtin_ia32_vcvtph2bf8s512_mask ((__v32hf) __A, > - (__v32qi) (__m256i) __W, > - (__mmask32) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvts_ph_bf8 (__mmask32 __U, __m512h __A) > -{ > - return (__m256i) __builtin_ia32_vcvtph2bf8s512_mask ((__v32hf) __A, > - (__v32qi) (__m256i) > - _mm256_setzero_si256 > (), > - (__mmask32) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvtph_hf8 (__m128h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2hf8128_mask ((__v8hf) __A, > - (__v16qi)(__m128i) > - _mm_undefined_si128 (), > - (__mmask8) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvtph_hf8 (__m128i __W, __mmask8 __U, __m128h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2hf8128_mask ((__v8hf) __A, > - (__v16qi)(__m128i) __W, > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvtph_hf8 (__mmask8 __U, __m128h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2hf8128_mask ((__v8hf) __A, > - (__v16qi)(__m128i) > - _mm_setzero_si128 (), > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvtph_hf8 (__m256h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2hf8256_mask ((__v16hf) __A, > - (__v16qi)(__m128i) > - _mm_undefined_si128 (), > - (__mmask16) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvtph_hf8 (__m128i __W, __mmask16 __U, __m256h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2hf8256_mask ((__v16hf) __A, > - (__v16qi)(__m128i) __W, > - (__mmask16) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvtph_hf8 (__mmask16 __U, __m256h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2hf8256_mask ((__v16hf) __A, > - (__v16qi)(__m128i) > - _mm_setzero_si128 (), > - (__mmask16) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvtph_hf8 (__m512h __A) > -{ > - return (__m256i) __builtin_ia32_vcvtph2hf8512_mask ((__v32hf) __A, > - (__v32qi) (__m256i) > - _mm256_undefined_si256 > (), > - (__mmask32) -1); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvtph_hf8 (__m256i __W, __mmask32 __U, __m512h __A) > -{ > - return (__m256i) __builtin_ia32_vcvtph2hf8512_mask ((__v32hf) __A, > - (__v32qi)(__m256i) __W, > - (__mmask32) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvtph_hf8 (__mmask32 __U, __m512h __A) > -{ > - return (__m256i) __builtin_ia32_vcvtph2hf8512_mask ((__v32hf) __A, > - (__v32qi) (__m256i) > - _mm256_setzero_si256 (), > - (__mmask32) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_cvts_ph_hf8 (__m128h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2hf8s128_mask ((__v8hf) __A, > - (__v16qi)(__m128i) > - _mm_undefined_si128 (), > - (__mmask8) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_cvts_ph_hf8 (__m128i __W, __mmask8 __U, __m128h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2hf8s128_mask ((__v8hf) __A, > - (__v16qi)(__m128i) __W, > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_cvts_ph_hf8 (__mmask8 __U, __m128h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2hf8s128_mask ((__v8hf) __A, > - (__v16qi)(__m128i) > - _mm_setzero_si128 (), > - (__mmask8) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_cvts_ph_hf8 (__m256h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2hf8s256_mask ((__v16hf) __A, > - (__v16qi)(__m128i) > - _mm_undefined_si128 (), > - (__mmask16) -1); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_cvts_ph_hf8 (__m128i __W, __mmask16 __U, __m256h > __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2hf8s256_mask ((__v16hf) __A, > - (__v16qi)(__m128i) __W, > - (__mmask16) __U); > -} > - > -extern __inline__ __m128i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_cvts_ph_hf8 (__mmask16 __U, __m256h __A) > -{ > - return (__m128i) __builtin_ia32_vcvtph2hf8s256_mask ((__v16hf) __A, > - (__v16qi)(__m128i) > - _mm_setzero_si128 (), > - (__mmask16) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_cvts_ph_hf8 (__m512h __A) > -{ > - return (__m256i) __builtin_ia32_vcvtph2hf8s512_mask ((__v32hf) __A, > - (__v32qi) (__m256i) > - > _mm256_undefined_si256 (), > - (__mmask32) -1); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_cvts_ph_hf8 (__m256i __W, __mmask32 __U, __m512h > __A) > -{ > - return (__m256i) __builtin_ia32_vcvtph2hf8s512_mask ((__v32hf) __A, > - (__v32qi) (__m256i) __W, > - (__mmask32) __U); > -} > - > -extern __inline__ __m256i > -__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_cvts_ph_hf8 (__mmask32 __U, __m512h __A) > -{ > - return (__m256i) __builtin_ia32_vcvtph2hf8s512_mask ((__v32hf) __A, > - (__v32qi) (__m256i) > - _mm256_setzero_si256 > (), > - (__mmask32) __U); > -} > - > extern __inline __m128h > __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > _mm_cvtbf8_ph (__m128i __A) > diff --git a/gcc/config/i386/avx10v1auxintrin.h > b/gcc/config/i386/avx10v1auxintrin.h > new file mode 100644 > index 000000000000..9929e926ba07 > --- /dev/null > +++ b/gcc/config/i386/avx10v1auxintrin.h > @@ -0,0 +1,1427 @@ > +/* Copyright (C) 2026 Free Software Foundation, Inc. > + > + This file is part of GCC. > + > + GCC is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3, or (at your option) > + any later version. > + > + GCC is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + Under Section 7 of GPL version 3, you are granted additional > + permissions described in the GCC Runtime Library Exception, version > + 3.1, as published by the Free Software Foundation. > + > + You should have received a copy of the GNU General Public License and > + a copy of the GCC Runtime Library Exception along with this program; > + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > + . */ > + > +#if !defined _IMMINTRIN_H_INCLUDED > +#error "Never use directly; include > instead." > +#endif > + > +#ifndef _AVX10V1AUXINTRIN_H_INCLUDED > +#define _AVX10V1AUXINTRIN_H_INCLUDED > + > +#if !defined(__AVX10V1AUX__) > +#pragma GCC push_options > +#pragma GCC target("avx10v1aux") > +#define __DISABLE_AVX10V1AUX__ > +#endif /* __AVX10V1AUX__ */ > + > +/* FP16 to FP8 converts(Single-source). */ > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvtph_bf8 (__m128h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2bf8128_mask ((__v8hf) __A, > + (__v16qi)(__m128i) > + _mm_undefined_si128 (), > + (__mmask8) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvtph_bf8 (__m128i __W, __mmask8 __U, __m128h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2bf8128_mask ((__v8hf) __A, > + (__v16qi)(__m128i) __W, > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvtph_bf8 (__mmask8 __U, __m128h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2bf8128_mask ((__v8hf) __A, > + (__v16qi)(__m128i) > + _mm_setzero_si128 (), > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvtph_bf8 (__m256h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2bf8256_mask ((__v16hf) __A, > + (__v16qi)(__m128i) > + _mm_undefined_si128 (), > + (__mmask16) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvtph_bf8 (__m128i __W, __mmask16 __U, __m256h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2bf8256_mask ((__v16hf) __A, > + (__v16qi)(__m128i) __W, > + (__mmask16) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvtph_bf8 (__mmask16 __U, __m256h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2bf8256_mask ((__v16hf) __A, > + (__v16qi)(__m128i) > + _mm_setzero_si128 (), > + (__mmask16) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvtph_bf8 (__m512h __A) > +{ > + return (__m256i) __builtin_ia32_vcvtph2bf8512_mask ((__v32hf) __A, > + (__v32qi) (__m256i) > + _mm256_undefined_si256 > (), > + (__mmask32) -1); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvtph_bf8 (__m256i __W, __mmask32 __U, __m512h __A) > +{ > + return (__m256i) __builtin_ia32_vcvtph2bf8512_mask ((__v32hf) __A, > + (__v32qi) (__m256i) __W, > + (__mmask32) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvtph_bf8 (__mmask32 __U, __m512h __A) > +{ > + return (__m256i) __builtin_ia32_vcvtph2bf8512_mask ((__v32hf) __A, > + (__v32qi) (__m256i) > + _mm256_setzero_si256 (), > + (__mmask32) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvts_ph_bf8 (__m128h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2bf8s128_mask ((__v8hf) __A, > + (__v16qi)(__m128i) > + _mm_undefined_si128 (), > + (__mmask8) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvts_ph_bf8 (__m128i __W, __mmask8 __U, __m128h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2bf8s128_mask ((__v8hf) __A, > + (__v16qi)(__m128i) __W, > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvts_ph_bf8 (__mmask8 __U, __m128h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2bf8s128_mask ((__v8hf) __A, > + (__v16qi)(__m128i) > + _mm_setzero_si128 (), > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvts_ph_bf8 (__m256h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2bf8s256_mask ((__v16hf) __A, > + (__v16qi)(__m128i) > + _mm_undefined_si128 (), > + (__mmask16) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvts_ph_bf8 (__m128i __W, __mmask16 __U, __m256h > __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2bf8s256_mask ((__v16hf) __A, > + (__v16qi)(__m128i) __W, > + (__mmask16) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvts_ph_bf8 (__mmask16 __U, __m256h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2bf8s256_mask ((__v16hf) __A, > + (__v16qi)(__m128i) > + _mm_setzero_si128 (), > + (__mmask16) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvts_ph_bf8 (__m512h __A) > +{ > + return (__m256i) __builtin_ia32_vcvtph2bf8s512_mask ((__v32hf) __A, > + (__v32qi) (__m256i) > + > _mm256_undefined_si256 (), > + (__mmask32) -1); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvts_ph_bf8 (__m256i __W, __mmask32 __U, __m512h > __A) > +{ > + return (__m256i) __builtin_ia32_vcvtph2bf8s512_mask ((__v32hf) __A, > + (__v32qi) (__m256i) __W, > + (__mmask32) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvts_ph_bf8 (__mmask32 __U, __m512h __A) > +{ > + return (__m256i) __builtin_ia32_vcvtph2bf8s512_mask ((__v32hf) __A, > + (__v32qi) (__m256i) > + _mm256_setzero_si256 > (), > + (__mmask32) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvtph_hf8 (__m128h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2hf8128_mask ((__v8hf) __A, > + (__v16qi)(__m128i) > + _mm_undefined_si128 (), > + (__mmask8) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvtph_hf8 (__m128i __W, __mmask8 __U, __m128h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2hf8128_mask ((__v8hf) __A, > + (__v16qi)(__m128i) __W, > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvtph_hf8 (__mmask8 __U, __m128h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2hf8128_mask ((__v8hf) __A, > + (__v16qi)(__m128i) > + _mm_setzero_si128 (), > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvtph_hf8 (__m256h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2hf8256_mask ((__v16hf) __A, > + (__v16qi)(__m128i) > + _mm_undefined_si128 (), > + (__mmask16) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvtph_hf8 (__m128i __W, __mmask16 __U, __m256h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2hf8256_mask ((__v16hf) __A, > + (__v16qi)(__m128i) __W, > + (__mmask16) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvtph_hf8 (__mmask16 __U, __m256h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2hf8256_mask ((__v16hf) __A, > + (__v16qi)(__m128i) > + _mm_setzero_si128 (), > + (__mmask16) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvtph_hf8 (__m512h __A) > +{ > + return (__m256i) __builtin_ia32_vcvtph2hf8512_mask ((__v32hf) __A, > + (__v32qi) (__m256i) > + _mm256_undefined_si256 > (), > + (__mmask32) -1); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvtph_hf8 (__m256i __W, __mmask32 __U, __m512h __A) > +{ > + return (__m256i) __builtin_ia32_vcvtph2hf8512_mask ((__v32hf) __A, > + (__v32qi)(__m256i) __W, > + (__mmask32) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvtph_hf8 (__mmask32 __U, __m512h __A) > +{ > + return (__m256i) __builtin_ia32_vcvtph2hf8512_mask ((__v32hf) __A, > + (__v32qi) (__m256i) > + _mm256_setzero_si256 (), > + (__mmask32) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvts_ph_hf8 (__m128h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2hf8s128_mask ((__v8hf) __A, > + (__v16qi)(__m128i) > + _mm_undefined_si128 (), > + (__mmask8) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvts_ph_hf8 (__m128i __W, __mmask8 __U, __m128h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2hf8s128_mask ((__v8hf) __A, > + (__v16qi)(__m128i) __W, > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvts_ph_hf8 (__mmask8 __U, __m128h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2hf8s128_mask ((__v8hf) __A, > + (__v16qi)(__m128i) > + _mm_setzero_si128 (), > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvts_ph_hf8 (__m256h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2hf8s256_mask ((__v16hf) __A, > + (__v16qi)(__m128i) > + _mm_undefined_si128 (), > + (__mmask16) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvts_ph_hf8 (__m128i __W, __mmask16 __U, __m256h > __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2hf8s256_mask ((__v16hf) __A, > + (__v16qi)(__m128i) __W, > + (__mmask16) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvts_ph_hf8 (__mmask16 __U, __m256h __A) > +{ > + return (__m128i) __builtin_ia32_vcvtph2hf8s256_mask ((__v16hf) __A, > + (__v16qi)(__m128i) > + _mm_setzero_si128 (), > + (__mmask16) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvts_ph_hf8 (__m512h __A) > +{ > + return (__m256i) __builtin_ia32_vcvtph2hf8s512_mask ((__v32hf) __A, > + (__v32qi) (__m256i) > + > _mm256_undefined_si256 (), > + (__mmask32) -1); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvts_ph_hf8 (__m256i __W, __mmask32 __U, __m512h > __A) > +{ > + return (__m256i) __builtin_ia32_vcvtph2hf8s512_mask ((__v32hf) __A, > + (__v32qi) (__m256i) __W, > + (__mmask32) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvts_ph_hf8 (__mmask32 __U, __m512h __A) > +{ > + return (__m256i) __builtin_ia32_vcvtph2hf8s512_mask ((__v32hf) __A, > + (__v32qi) (__m256i) > + _mm256_setzero_si256 > (), > + (__mmask32) __U); > +} > + > +/* FP16 to FP8 converts(Two-source). */ > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvt2ph_bf8 (__m128h __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvt2ph2bf8128_mask ((__v8hf) __A, > + (__v8hf) __B, > + (__v16qi) > + _mm_setzero_si128 (), > + (__mmask16) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvt2ph_bf8 (__m128i __W, __mmask16 __U, > + __m128h __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvt2ph2bf8128_mask ((__v8hf) __A, > + (__v8hf) __B, > + (__v16qi) __W, > + (__mmask16) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvt2ph_bf8 (__mmask16 __U, __m128h __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvt2ph2bf8128_mask ((__v8hf) __A, > + (__v8hf) __B, > + (__v16qi) > + _mm_setzero_si128 (), > + (__mmask16) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvt2ph_bf8 (__m256h __A, __m256h __B) > +{ > + return (__m256i) __builtin_ia32_vcvt2ph2bf8256_mask ((__v16hf) __A, > + (__v16hf) __B, > + (__v32qi) > + _mm256_setzero_si256 > (), > + (__mmask32) -1); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvt2ph_bf8 (__m256i __W, __mmask32 __U, > + __m256h __A, __m256h __B) > +{ > + return (__m256i) __builtin_ia32_vcvt2ph2bf8256_mask ((__v16hf) __A, > + (__v16hf) __B, > + (__v32qi) __W, > + (__mmask32) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvt2ph_bf8 (__mmask32 __U, __m256h __A, __m256h > __B) > +{ > + return (__m256i) __builtin_ia32_vcvt2ph2bf8256_mask ((__v16hf) __A, > + (__v16hf) __B, > + (__v32qi) > + _mm256_setzero_si256 > (), > + (__mmask32) __U); > +} > + > +extern __inline__ __m512i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvt2ph_bf8 (__m512h __A, __m512h __B) > +{ > + return (__m512i) __builtin_ia32_vcvt2ph2bf8512_mask ((__v32hf) __A, > + (__v32hf) __B, > + (__v64qi) > + _mm512_setzero_si512 > (), > + (__mmask64) -1); > +} > + > +extern __inline__ __m512i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvt2ph_bf8 (__m512i __W, __mmask64 __U, > + __m512h __A, __m512h __B) > +{ > + return (__m512i) __builtin_ia32_vcvt2ph2bf8512_mask ((__v32hf) __A, > + (__v32hf) __B, > + (__v64qi) __W, > + (__mmask64) __U); > +} > + > +extern __inline__ __m512i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvt2ph_bf8 (__mmask64 __U, __m512h __A, __m512h > __B) > +{ > + return (__m512i) __builtin_ia32_vcvt2ph2bf8512_mask ((__v32hf) __A, > + (__v32hf) __B, > + (__v64qi) > + _mm512_setzero_si512 > (), > + (__mmask64) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvts_2ph_bf8 (__m128h __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvt2ph2bf8s128_mask ((__v8hf) __A, > + (__v8hf) __B, > + (__v16qi) > + _mm_setzero_si128 > (), > + (__mmask16) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvts_2ph_bf8 (__m128i __W, __mmask16 __U, > + __m128h __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvt2ph2bf8s128_mask ((__v8hf) __A, > + (__v8hf) __B, > + (__v16qi) __W, > + (__mmask16) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvts_2ph_bf8 (__mmask16 __U, __m128h __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvt2ph2bf8s128_mask ((__v8hf) __A, > + (__v8hf) __B, > + (__v16qi) > + _mm_setzero_si128 > (), > + (__mmask16) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvts_2ph_bf8 (__m256h __A, __m256h __B) > +{ > + return (__m256i) __builtin_ia32_vcvt2ph2bf8s256_mask ((__v16hf) __A, > + (__v16hf) __B, > + (__v32qi) > + > _mm256_setzero_si256 (), > + (__mmask32) -1); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvts_2ph_bf8 (__m256i __W, __mmask32 __U, > + __m256h __A, __m256h __B) > +{ > + return (__m256i) __builtin_ia32_vcvt2ph2bf8s256_mask ((__v16hf) __A, > + (__v16hf) __B, > + (__v32qi) __W, > + (__mmask32) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvts_2ph_bf8 (__mmask32 __U, __m256h __A, __m256h > __B) > +{ > + return (__m256i) __builtin_ia32_vcvt2ph2bf8s256_mask ((__v16hf) __A, > + (__v16hf) __B, > + (__v32qi) > + > _mm256_setzero_si256 (), > + (__mmask32) __U); > +} > + > +extern __inline__ __m512i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvts_2ph_bf8 (__m512h __A, __m512h __B) > +{ > + return (__m512i) __builtin_ia32_vcvt2ph2bf8s512_mask ((__v32hf) __A, > + (__v32hf) __B, > + (__v64qi) > + > _mm512_setzero_si512 (), > + (__mmask64) -1); > +} > + > +extern __inline__ __m512i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvts_2ph_bf8 (__m512i __W, __mmask64 __U, > + __m512h __A, __m512h __B) > +{ > + return (__m512i) __builtin_ia32_vcvt2ph2bf8s512_mask ((__v32hf) __A, > + (__v32hf) __B, > + (__v64qi) __W, > + (__mmask64) __U); > +} > + > +extern __inline__ __m512i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvts_2ph_bf8 (__mmask64 __U, __m512h __A, __m512h > __B) > +{ > + return (__m512i) __builtin_ia32_vcvt2ph2bf8s512_mask ((__v32hf) __A, > + (__v32hf) __B, > + (__v64qi) > + > _mm512_setzero_si512 (), > + (__mmask64) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvt2ph_hf8 (__m128h __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvt2ph2hf8128_mask ((__v8hf) __A, > + (__v8hf) __B, > + (__v16qi) > + _mm_setzero_si128 (), > + (__mmask16) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvt2ph_hf8 (__m128i __W, __mmask16 __U, > + __m128h __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvt2ph2hf8128_mask ((__v8hf) __A, > + (__v8hf) __B, > + (__v16qi) __W, > + (__mmask16) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvt2ph_hf8 (__mmask16 __U, __m128h __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvt2ph2hf8128_mask ((__v8hf) __A, > + (__v8hf) __B, > + (__v16qi) > + _mm_setzero_si128 (), > + (__mmask16) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvt2ph_hf8 (__m256h __A, __m256h __B) > +{ > + return (__m256i) __builtin_ia32_vcvt2ph2hf8256_mask ((__v16hf) __A, > + (__v16hf) __B, > + (__v32qi) > + _mm256_setzero_si256 > (), > + (__mmask32) -1); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvt2ph_hf8 (__m256i __W, __mmask32 __U, > + __m256h __A, __m256h __B) > +{ > + return (__m256i) __builtin_ia32_vcvt2ph2hf8256_mask ((__v16hf) __A, > + (__v16hf) __B, > + (__v32qi) __W, > + (__mmask32) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvt2ph_hf8 (__mmask32 __U, __m256h __A, __m256h > __B) > +{ > + return (__m256i) __builtin_ia32_vcvt2ph2hf8256_mask ((__v16hf) __A, > + (__v16hf) __B, > + (__v32qi) > + _mm256_setzero_si256 > (), > + (__mmask32) __U); > +} > + > +extern __inline__ __m512i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvt2ph_hf8 (__m512h __A, __m512h __B) > +{ > + return (__m512i) __builtin_ia32_vcvt2ph2hf8512_mask ((__v32hf) __A, > + (__v32hf) __B, > + (__v64qi) > + _mm512_setzero_si512 > (), > + (__mmask64) -1); > +} > + > +extern __inline__ __m512i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvt2ph_hf8 (__m512i __W, __mmask64 __U, > + __m512h __A, __m512h __B) > +{ > + return (__m512i) __builtin_ia32_vcvt2ph2hf8512_mask ((__v32hf) __A, > + (__v32hf) __B, > + (__v64qi) __W, > + (__mmask64) __U); > +} > + > +extern __inline__ __m512i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvt2ph_hf8 (__mmask64 __U, __m512h __A, __m512h > __B) > +{ > + return (__m512i) __builtin_ia32_vcvt2ph2hf8512_mask ((__v32hf) __A, > + (__v32hf) __B, > + (__v64qi) > + _mm512_setzero_si512 > (), > + (__mmask64) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvts_2ph_hf8 (__m128h __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvt2ph2hf8s128_mask ((__v8hf) __A, > + (__v8hf) __B, > + (__v16qi) > + _mm_setzero_si128 > (), > + (__mmask16) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvts_2ph_hf8 (__m128i __W, __mmask16 __U, > + __m128h __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvt2ph2hf8s128_mask ((__v8hf) __A, > + (__v8hf) __B, > + (__v16qi) __W, > + (__mmask16) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvts_2ph_hf8 (__mmask16 __U, __m128h __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvt2ph2hf8s128_mask ((__v8hf) __A, > + (__v8hf) __B, > + (__v16qi) > + _mm_setzero_si128 > (), > + (__mmask16) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvts_2ph_hf8 (__m256h __A, __m256h __B) > +{ > + return (__m256i) __builtin_ia32_vcvt2ph2hf8s256_mask ((__v16hf) __A, > + (__v16hf) __B, > + (__v32qi) > + > _mm256_setzero_si256 (), > + (__mmask32) -1); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvts_2ph_hf8 (__m256i __W, __mmask32 __U, > + __m256h __A, __m256h __B) > +{ > + return (__m256i) __builtin_ia32_vcvt2ph2hf8s256_mask ((__v16hf) __A, > + (__v16hf) __B, > + (__v32qi) __W, > + (__mmask32) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvts_2ph_hf8 (__mmask32 __U, __m256h __A, __m256h > __B) > +{ > + return (__m256i) __builtin_ia32_vcvt2ph2hf8s256_mask ((__v16hf) __A, > + (__v16hf) __B, > + (__v32qi) > + > _mm256_setzero_si256 (), > + (__mmask32) __U); > +} > + > +extern __inline__ __m512i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvts_2ph_hf8 (__m512h __A, __m512h __B) > +{ > + return (__m512i) __builtin_ia32_vcvt2ph2hf8s512_mask ((__v32hf) __A, > + (__v32hf) __B, > + (__v64qi) > + > _mm512_setzero_si512 (), > + (__mmask64) -1); > +} > + > +extern __inline__ __m512i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvts_2ph_hf8 (__m512i __W, __mmask64 __U, > + __m512h __A, __m512h __B) > +{ > + return (__m512i) __builtin_ia32_vcvt2ph2hf8s512_mask ((__v32hf) __A, > + (__v32hf) __B, > + (__v64qi) __W, > + (__mmask64) __U); > +} > + > +extern __inline__ __m512i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvts_2ph_hf8 (__mmask64 __U, __m512h __A, __m512h > __B) > +{ > + return (__m512i) __builtin_ia32_vcvt2ph2hf8s512_mask ((__v32hf) __A, > + (__v32hf) __B, > + (__v64qi) > + > _mm512_setzero_si512 (), > + (__mmask64) __U); > +} > + > +/* FP16 to FP8 Converts (Biased) */ > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvtbiasph_bf8 (__m128i __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2bf8128 ((__v16qi) __A, > + (__v8hf) __B); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvtbiasph_bf8 (__m128i __W, __mmask8 __U, __m128i __A, > + __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2bf8128_mask ((__v16qi) __A, > + (__v8hf) __B, > + (__v16qi)(__m128i) > __W, > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvtbiasph_bf8 (__mmask8 __U, __m128i __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2bf8128_mask ((__v16qi) __A, > + (__v8hf) __B, > + (__v16qi)(__m128i) > + _mm_setzero_si128 > (), > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvtbiasph_bf8 (__m256i __A, __m256h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2bf8256_mask ((__v32qi) __A, > + (__v16hf) __B, > + (__v16qi)(__m128i) > + > _mm_undefined_si128 (), > + (__mmask16) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvtbiasph_bf8 (__m128i __W, __mmask16 __U, __m256i > __A, > + __m256h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2bf8256_mask ((__v32qi) __A, > + (__v16hf) __B, > + (__v16qi)(__m128i) > __W, > + (__mmask16) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvtbiasph_bf8 (__mmask16 __U, __m256i __A, __m256h > __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2bf8256_mask ((__v32qi) __A, > + (__v16hf) __B, > + (__v16qi)(__m128i) > + _mm_setzero_si128 > (), > + (__mmask16) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvtbiasph_bf8 (__m512i __A, __m512h __B) > +{ > + return (__m256i) __builtin_ia32_vcvtbiasph2bf8512_mask ((__v64qi) __A, > + (__v32hf) __B, > + (__v32qi)(__m256i) > + > _mm256_undefined_si256 (), > + (__mmask32) -1); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvtbiasph_bf8 (__m256i __W, __mmask32 __U, > + __m512i __A, __m512h __B) > +{ > + return (__m256i) __builtin_ia32_vcvtbiasph2bf8512_mask ((__v64qi) __A, > + (__v32hf) __B, > + (__v32qi)(__m256i) > __W, > + (__mmask32) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvtbiasph_bf8 (__mmask32 __U, __m512i __A, __m512h > __B) > +{ > + return (__m256i) __builtin_ia32_vcvtbiasph2bf8512_mask ((__v64qi) __A, > + (__v32hf) __B, > + (__v32qi)(__m256i) > + > _mm256_setzero_si256 (), > + (__mmask32) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvts_biasph_bf8 (__m128i __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2bf8s128 ((__v16qi) __A, > + (__v8hf) __B); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvts_biasph_bf8 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2bf8s128_mask ((__v16qi) > __A, > + (__v8hf) __B, > + (__v16qi)(__m128i) > __W, > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvts_biasph_bf8 (__mmask8 __U, __m128i __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2bf8s128_mask ((__v16qi) > __A, > + (__v8hf) __B, > + (__v16qi)(__m128i) > + _mm_setzero_si128 > (), > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvts_biasph_bf8 (__m256i __A, __m256h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2bf8s256_mask ((__v32qi) > __A, > + (__v16hf) __B, > + (__v16qi)(__m128i) > + > _mm_undefined_si128 (), > + (__mmask16) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvts_biasph_bf8 (__m128i __W, __mmask16 __U, > + __m256i __A, __m256h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2bf8s256_mask ((__v32qi) > __A, > + (__v16hf) __B, > + (__v16qi)(__m128i) > __W, > + (__mmask16) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvts_biasph_bf8 (__mmask16 __U, __m256i __A, > __m256h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2bf8s256_mask ((__v32qi) > __A, > + (__v16hf) __B, > + (__v16qi)(__m128i) > + _mm_setzero_si128 > (), > + (__mmask16) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvts_biasph_bf8 (__m512i __A, __m512h __B) > +{ > + return (__m256i) __builtin_ia32_vcvtbiasph2bf8s512_mask ((__v64qi) > __A, > + (__v32hf) __B, > + (__v32qi)(__m256i) > + > _mm256_undefined_si256 (), > + (__mmask32) -1); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvts_biasph_bf8 (__m256i __W, __mmask32 __U, > + __m512i __A, __m512h __B) > +{ > + return (__m256i) __builtin_ia32_vcvtbiasph2bf8s512_mask ((__v64qi) > __A, > + (__v32hf) __B, > + (__v32qi)(__m256i) > __W, > + (__mmask32) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvts_biasph_bf8 (__mmask32 __U, __m512i __A, > __m512h __B) > +{ > + return (__m256i) __builtin_ia32_vcvtbiasph2bf8s512_mask ((__v64qi) > __A, > + (__v32hf) __B, > + (__v32qi)(__m256i) > + > _mm256_setzero_si256 (), > + (__mmask32) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvtbiasph_hf8 (__m128i __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2hf8128 ((__v16qi) __A, > + (__v8hf) __B); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvtbiasph_hf8 (__m128i __W, __mmask8 __U, __m128i __A, > + __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2hf8128_mask ((__v16qi) __A, > + (__v8hf) __B, > + (__v16qi)(__m128i) > __W, > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvtbiasph_hf8 (__mmask8 __U, __m128i __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2hf8128_mask ((__v16qi) __A, > + (__v8hf) __B, > + (__v16qi)(__m128i) > + _mm_setzero_si128 > (), > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvtbiasph_hf8 (__m256i __A, __m256h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2hf8256_mask ((__v32qi) __A, > + (__v16hf) __B, > + (__v16qi)(__m128i) > + > _mm_undefined_si128 (), > + (__mmask16) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvtbiasph_hf8 (__m128i __W, __mmask16 __U, > + __m256i __A, __m256h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2hf8256_mask ((__v32qi) __A, > + (__v16hf) __B, > + (__v16qi)(__m128i) > __W, > + (__mmask16) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvtbiasph_hf8 (__mmask16 __U, __m256i __A, __m256h > __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2hf8256_mask ((__v32qi) __A, > + (__v16hf) __B, > + (__v16qi)(__m128i) > + _mm_setzero_si128 > (), > + (__mmask16) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvtbiasph_hf8 (__m512i __A, __m512h __B) > +{ > + return (__m256i) __builtin_ia32_vcvtbiasph2hf8512_mask ((__v64qi) __A, > + (__v32hf) __B, > + (__v32qi)(__m256i) > + > _mm256_undefined_si256 (), > + (__mmask32) -1); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvtbiasph_hf8 (__m256i __W, __mmask32 __U, __m512i > __A, > + __m512h __B) > +{ > + return (__m256i) __builtin_ia32_vcvtbiasph2hf8512_mask ((__v64qi) __A, > + (__v32hf) __B, > + (__v32qi)(__m256i) > __W, > + (__mmask32) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvtbiasph_hf8 (__mmask32 __U, __m512i __A, __m512h > __B) > +{ > + return (__m256i) __builtin_ia32_vcvtbiasph2hf8512_mask ((__v64qi) __A, > + (__v32hf) __B, > + (__v32qi)(__m256i) > + > _mm256_setzero_si256 (), > + (__mmask32) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvts_biasph_hf8 (__m128i __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2hf8s128 ((__v16qi) __A, > + (__v8hf) __B); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvts_biasph_hf8 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2hf8s128_mask ((__v16qi) > __A, > + (__v8hf) __B, > + (__v16qi)(__m128i) > __W, > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvts_biasph_hf8 (__mmask8 __U, __m128i __A, __m128h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2hf8s128_mask ((__v16qi) > __A, > + (__v8hf) __B, > + (__v16qi)(__m128i) > + _mm_setzero_si128 > (), > + (__mmask8) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvts_biasph_hf8 (__m256i __A, __m256h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2hf8s256_mask ((__v32qi) > __A, > + (__v16hf) __B, > + (__v16qi)(__m128i) > + > _mm_undefined_si128 (), > + (__mmask16) -1); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvts_biasph_hf8 (__m128i __W, __mmask16 __U, > + __m256i __A, __m256h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2hf8s256_mask ((__v32qi) > __A, > + (__v16hf) __B, > + (__v16qi)(__m128i) > __W, > + (__mmask16) __U); > +} > + > +extern __inline__ __m128i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvts_biasph_hf8 (__mmask16 __U, __m256i __A, > __m256h __B) > +{ > + return (__m128i) __builtin_ia32_vcvtbiasph2hf8s256_mask ((__v32qi) > __A, > + (__v16hf) __B, > + (__v16qi)(__m128i) > + _mm_setzero_si128 > (), > + (__mmask16) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvts_biasph_hf8 (__m512i __A, __m512h __B) > +{ > + return (__m256i) __builtin_ia32_vcvtbiasph2hf8s512_mask ((__v64qi) > __A, > + (__v32hf) __B, > + (__v32qi)(__m256i) > + > _mm256_undefined_si256 (), > + (__mmask32) -1); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvts_biasph_hf8 (__m256i __W, __mmask32 __U, > + __m512i __A, __m512h __B) > +{ > + return (__m256i) __builtin_ia32_vcvtbiasph2hf8s512_mask ((__v64qi) > __A, > + (__v32hf) __B, > + (__v32qi)(__m256i) > __W, > + (__mmask32) __U); > +} > + > +extern __inline__ __m256i > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvts_biasph_hf8 (__mmask32 __U, __m512i __A, > __m512h __B) > +{ > + return (__m256i) __builtin_ia32_vcvtbiasph2hf8s512_mask ((__v64qi) > __A, > + (__v32hf) __B, > + (__v32qi)(__m256i) > + > _mm256_setzero_si256 (), > + (__mmask32) __U); > +} > + > +/* FP8 to FP16 Converts */ > + > +extern __inline__ __m128h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvthf8_ph (__m128i __A) > +{ > + return (__m128h) __builtin_ia32_vcvthf82ph128_mask ((__v16qi) __A, > + (__v8hf)(__m128h) > + _mm_undefined_ph (), > + (__mmask8) -1); > +} > + > +extern __inline__ __m128h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvthf8_ph (__m128h __W, __mmask8 __U, __m128i __A) > +{ > + return (__m128h) __builtin_ia32_vcvthf82ph128_mask ((__v16qi) __A, > + (__v8hf)(__m128h) __W, > + (__mmask8) __U); > +} > + > +extern __inline__ __m128h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvthf8_ph (__mmask8 __U, __m128i __A) > +{ > + return (__m128h) __builtin_ia32_vcvthf82ph128_mask ((__v16qi) __A, > + (__v8hf)(__m128h) > + _mm_setzero_ph (), > + (__mmask8) __U); > +} > + > +extern __inline__ __m256h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvthf8_ph (__m128i __A) > +{ > + return (__m256h) __builtin_ia32_vcvthf82ph256_mask ((__v16qi) __A, > + (__v16hf)(__m256h) > + _mm256_undefined_ph (), > + (__mmask16) -1); > +} > + > +extern __inline__ __m256h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvthf8_ph (__m256h __W, __mmask16 __U, __m128i __A) > +{ > + return (__m256h) __builtin_ia32_vcvthf82ph256_mask ((__v16qi) __A, > + (__v16hf)(__m256h) __W, > + (__mmask16) __U); > +} > + > +extern __inline__ __m256h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvthf8_ph (__mmask16 __U, __m128i __A) > +{ > + return (__m256h) __builtin_ia32_vcvthf82ph256_mask ((__v16qi) __A, > + (__v16hf)(__m256h) > + _mm256_setzero_ph (), > + (__mmask16) __U); > +} > + > +extern __inline__ __m512h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvthf8_ph (__m256i __A) > +{ > + return (__m512h) __builtin_ia32_vcvthf82ph512_mask ((__v32qi) __A, > + (__v32hf) (__m512h) > + _mm512_undefined_ph (), > + (__mmask32) -1); > +} > + > +extern __inline__ __m512h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvthf8_ph (__m512h __W, __mmask32 __U, __m256i __A) > +{ > + return (__m512h) __builtin_ia32_vcvthf82ph512_mask ((__v32qi) __A, > + (__v32hf) (__m512h) __W, > + (__mmask32) __U); > +} > + > +extern __inline__ __m512h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvthf8_ph (__mmask32 __U, __m256i __A) > +{ > + return (__m512h) __builtin_ia32_vcvthf82ph512_mask ((__v32qi) __A, > + (__v32hf) (__m512h) > + _mm512_setzero_ph (), > + (__mmask32) __U); > +} > + > +/* FP32-Pair to FP16 Converts */ > +extern __inline __m128h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_cvtx2ps_ph (__m128 __A, __m128 __B) > +{ > + return (__m128h) __builtin_ia32_vcvt2ps2phx128_mask ((__v4sf) __A, > + (__v4sf) __B, > + (__v8hf) > + _mm_setzero_ph (), > + (__mmask8) -1); > +} > + > +extern __inline __m128h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_cvtx2ps_ph (__m128h __W, __mmask8 __U, __m128 __A, > __m128 __B) > +{ > + return (__m128h) __builtin_ia32_vcvt2ps2phx128_mask ((__v4sf) __A, > + (__v4sf) __B, > + (__v8hf) __W, > + (__mmask8) __U); > +} > + > +extern __inline __m128h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_cvtx2ps_ph (__mmask8 __U, __m128 __A, __m128 __B) > +{ > + return (__m128h) __builtin_ia32_vcvt2ps2phx128_mask ((__v4sf) __A, > + (__v4sf) __B, > + (__v8hf) > + _mm_setzero_ph (), > + (__mmask8) __U); > +} > + > +extern __inline __m256h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_cvtx2ps_ph (__m256 __A, __m256 __B) > +{ > + return (__m256h) __builtin_ia32_vcvt2ps2phx256_mask ((__v8sf) __A, > + (__v8sf) __B, > + (__v16hf) > + _mm256_setzero_ph (), > + (__mmask16) -1); > +} > + > +extern __inline __m256h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_cvtx2ps_ph (__m256h __W, __mmask16 __U, __m256 __A, > __m256 __B) > +{ > + return (__m256h) __builtin_ia32_vcvt2ps2phx256_mask ((__v8sf) __A, > + (__v8sf) __B, > + (__v16hf) __W, > + (__mmask16) __U); > +} > + > +extern __inline __m256h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_cvtx2ps_ph ( __mmask16 __U, __m256 __A, __m256 __B) > +{ > + return (__m256h) __builtin_ia32_vcvt2ps2phx256_mask ((__v8sf) __A, > + (__v8sf) __B, > + (__v16hf) > + _mm256_setzero_ph (), > + (__mmask16) __U); > +} > + > +extern __inline __m512h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvtx2ps_ph (__m512 __A, __m512 __B) > +{ > + return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) > __A, > + (__v16sf) __B, > + (__v32hf) > + > _mm512_setzero_ph (), > + (__mmask32) -1, > + > _MM_FROUND_CUR_DIRECTION); > +} > + > +extern __inline __m512h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvtx2ps_ph (__m512h __W, __mmask32 __U, __m512 __A, > + __m512 __B) > +{ > + return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) > __A, > + (__v16sf) __B, > + (__v32hf) __W, > + (__mmask32) __U, > + > _MM_FROUND_CUR_DIRECTION); > +} > + > +extern __inline __m512h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvtx2ps_ph (__mmask32 __U, __m512 __A, __m512 __B) > +{ > + return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) > __A, > + (__v16sf) __B, > + (__v32hf) > + > _mm512_setzero_ph (), > + (__mmask32) __U, > + > _MM_FROUND_CUR_DIRECTION); > +} > + > +#ifdef __OPTIMIZE__ > +extern __inline __m512h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_cvtx_round2ps_ph (__m512 __A, __m512 __B, const int __R) > +{ > + return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) > __A, > + (__v16sf) __B, > + (__v32hf) > + > _mm512_setzero_ph (), > + (__mmask32) -1, > + __R); > +} > + > +extern __inline __m512h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_cvtx_round2ps_ph (__m512h __W, __mmask32 __U, > __m512 __A, > + __m512 __B, const int __R) > +{ > + return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) > __A, > + (__v16sf) __B, > + (__v32hf) __W, > + (__mmask32) __U, > + __R); > +} > + > +extern __inline __m512h > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_cvtx_round2ps_ph (__mmask32 __U, __m512 __A, > + __m512 __B, const int __R) > +{ > + return (__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) > __A, > + (__v16sf) __B, > + (__v32hf) > + > _mm512_setzero_ph (), > + (__mmask32) __U, > + __R); > +} > + > +#else > +#define _mm512_cvtx_round2ps_ph(A, B, R) \ > + ((__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) (A), \ > + (__v16sf) (B), \ > + (__v32hf) \ > + (_mm512_setzero_ph ()), > \ > + (__mmask32) (-1), \ > + (R))) > +#define _mm512_mask_cvtx_round2ps_ph(W, U, A, B, R) \ > + ((__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) (A), \ > + (__v16sf) (B), \ > + (__v32hf) (W), \ > + (__mmask32) (U), \ > + (R))) > +#define _mm512_maskz_cvtx_round2ps_ph(U, A, B, R) \ > + ((__m512h) __builtin_ia32_vcvt2ps2phx512_mask_round ((__v16sf) (A), \ > + (__v16sf) (B), \ > + (__v32hf) \ > + (_mm512_setzero_ph ()), > \ > + (__mmask32) (U), \ > + (R))) > +#endif /* __OPTIMIZE__ */ > + > +#ifdef __DISABLE_AVX10V1AUX__ > +#undef __DISABLE_AVX10V1AUX__ > +#pragma GCC pop_options > +#endif /* __DISABLE_AVX10V1AUX__ */ > + > +#endif /* __AVX10V1AUXINTRIN_H_INCLUDED */ > diff --git a/gcc/config/i386/i386-builtin.def b/gcc/config/i386/i386- > builtin.def > index e2b7714d4c3e..fc8475b3e6a7 100644 > --- a/gcc/config/i386/i386-builtin.def > +++ b/gcc/config/i386/i386-builtin.def > @@ -3148,51 +3148,51 @@ BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_avx10_2_mpsadbw, "__builtin_ia32_mp > BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_avx10_2_mpsadbw_mask, "__builtin_ia32_mpsadbw512_mask", > IX86_BUILTIN_VMPSADBW_V32HI_MASK, UNKNOWN, (int) > V32HI_FTYPE_V64QI_V64QI_INT_V32HI_USI) > BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_avx2_mpsadbw_mask, "__builtin_ia32_mpsadbw256_mask", > IX86_BUILTIN_VMPSADBW_V16HI_MASK, UNKNOWN, (int) > V16HI_FTYPE_V32QI_V32QI_INT_V16HI_UHI) > BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_sse4_1_mpsadbw_mask, "__builtin_ia32_mpsadbw128_mask", > IX86_BUILTIN_VMPSADBW_V8HI_MASK, UNKNOWN, (int) > V8HI_FTYPE_V16QI_V16QI_INT_V8HI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_avx10_2_cvt2ps2phx_v16hf_mask, > "__builtin_ia32_vcvt2ps2phx256_mask", > IX86_BUILTIN_VCVT2PS2PHX_V16HF_MASK, UNKNOWN, (int) > V16HF_FTYPE_V8SF_V8SF_V16HF_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_avx10_2_cvt2ps2phx_v8hf_mask, > "__builtin_ia32_vcvt2ps2phx128_mask", > IX86_BUILTIN_VCVT2PS2PHX_V8HF_MASK, UNKNOWN, (int) > V8HF_FTYPE_V4SF_V4SF_V8HF_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2bf8v8hf, > "__builtin_ia32_vcvtbiasph2bf8128", IX86_BUILTIN_VCVTBIASPH2BF8128, > UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtbiasph2bf8v8hf_mask, > "__builtin_ia32_vcvtbiasph2bf8128_mask", > IX86_BUILTIN_VCVTBIASPH2BF8128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16QI_V8HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtbiasph2bf8v16hf_mask, > "__builtin_ia32_vcvtbiasph2bf8256_mask", > IX86_BUILTIN_VCVTBIASPH2BF8256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V32QI_V16HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtbiasph2bf8v32hf_mask, > "__builtin_ia32_vcvtbiasph2bf8512_mask", > IX86_BUILTIN_VCVTBIASPH2BF8512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V64QI_V32HF_V32QI_USI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2bf8sv8hf, > "__builtin_ia32_vcvtbiasph2bf8s128", IX86_BUILTIN_VCVTBIASPH2BF8S128, > UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtbiasph2bf8sv8hf_mask, > "__builtin_ia32_vcvtbiasph2bf8s128_mask", > IX86_BUILTIN_VCVTBIASPH2BF8S128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16QI_V8HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtbiasph2bf8sv16hf_mask, > "__builtin_ia32_vcvtbiasph2bf8s256_mask", > IX86_BUILTIN_VCVTBIASPH2BF8S256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V32QI_V16HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtbiasph2bf8sv32hf_mask, > "__builtin_ia32_vcvtbiasph2bf8s512_mask", > IX86_BUILTIN_VCVTBIASPH2BF8S512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V64QI_V32HF_V32QI_USI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2hf8v8hf, > "__builtin_ia32_vcvtbiasph2hf8128", IX86_BUILTIN_VCVTBIASPH2HF8128, > UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtbiasph2hf8v8hf_mask, > "__builtin_ia32_vcvtbiasph2hf8128_mask", > IX86_BUILTIN_VCVTBIASPH2HF8128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16QI_V8HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtbiasph2hf8v16hf_mask, > "__builtin_ia32_vcvtbiasph2hf8256_mask", > IX86_BUILTIN_VCVTBIASPH2HF8256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V32QI_V16HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtbiasph2hf8v32hf_mask, > "__builtin_ia32_vcvtbiasph2hf8512_mask", > IX86_BUILTIN_VCVTBIASPH2HF8512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V64QI_V32HF_V32QI_USI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vcvtbiasph2hf8sv8hf, > "__builtin_ia32_vcvtbiasph2hf8s128", IX86_BUILTIN_VCVTBIASPH2HF8S128, > UNKNOWN, (int) V16QI_FTYPE_V16QI_V8HF) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtbiasph2hf8sv8hf_mask, > "__builtin_ia32_vcvtbiasph2hf8s128_mask", > IX86_BUILTIN_VCVTBIASPH2HF8S128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16QI_V8HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtbiasph2hf8sv16hf_mask, > "__builtin_ia32_vcvtbiasph2hf8s256_mask", > IX86_BUILTIN_VCVTBIASPH2HF8S256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V32QI_V16HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtbiasph2hf8sv32hf_mask, > "__builtin_ia32_vcvtbiasph2hf8s512_mask", > IX86_BUILTIN_VCVTBIASPH2HF8S512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V64QI_V32HF_V32QI_USI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvt2ph2bf8v8hf_mask, > "__builtin_ia32_vcvt2ph2bf8128_mask", > IX86_BUILTIN_VCVT2PH2BF8128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V8HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvt2ph2bf8v16hf_mask, > "__builtin_ia32_vcvt2ph2bf8256_mask", > IX86_BUILTIN_VCVT2PH2BF8256_MASK, UNKNOWN, (int) > V32QI_FTYPE_V16HF_V16HF_V32QI_USI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvt2ph2bf8v32hf_mask, > "__builtin_ia32_vcvt2ph2bf8512_mask", > IX86_BUILTIN_VCVT2PH2BF8512_MASK, UNKNOWN, (int) > V64QI_FTYPE_V32HF_V32HF_V64QI_UDI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvt2ph2bf8sv8hf_mask, > "__builtin_ia32_vcvt2ph2bf8s128_mask", > IX86_BUILTIN_VCVT2PH2BF8S128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V8HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvt2ph2bf8sv16hf_mask, > "__builtin_ia32_vcvt2ph2bf8s256_mask", > IX86_BUILTIN_VCVT2PH2BF8S256_MASK, UNKNOWN, (int) > V32QI_FTYPE_V16HF_V16HF_V32QI_USI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvt2ph2bf8sv32hf_mask, > "__builtin_ia32_vcvt2ph2bf8s512_mask", > IX86_BUILTIN_VCVT2PH2BF8S512_MASK, UNKNOWN, (int) > V64QI_FTYPE_V32HF_V32HF_V64QI_UDI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvt2ph2hf8v8hf_mask, > "__builtin_ia32_vcvt2ph2hf8128_mask", > IX86_BUILTIN_VCVT2PH2HF8128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V8HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvt2ph2hf8v16hf_mask, > "__builtin_ia32_vcvt2ph2hf8256_mask", > IX86_BUILTIN_VCVT2PH2HF8256_MASK, UNKNOWN, (int) > V32QI_FTYPE_V16HF_V16HF_V32QI_USI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvt2ph2hf8v32hf_mask, > "__builtin_ia32_vcvt2ph2hf8512_mask", > IX86_BUILTIN_VCVT2PH2HF8512_MASK, UNKNOWN, (int) > V64QI_FTYPE_V32HF_V32HF_V64QI_UDI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvt2ph2hf8sv8hf_mask, > "__builtin_ia32_vcvt2ph2hf8s128_mask", > IX86_BUILTIN_VCVT2PH2HF8S128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V8HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvt2ph2hf8sv16hf_mask, > "__builtin_ia32_vcvt2ph2hf8s256_mask", > IX86_BUILTIN_VCVT2PH2HF8S256_MASK, UNKNOWN, (int) > V32QI_FTYPE_V16HF_V16HF_V32QI_USI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvt2ph2hf8sv32hf_mask, > "__builtin_ia32_vcvt2ph2hf8s512_mask", > IX86_BUILTIN_VCVT2PH2HF8S512_MASK, UNKNOWN, (int) > V64QI_FTYPE_V32HF_V32HF_V64QI_UDI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtph2bf8v8hf_mask, "__builtin_ia32_vcvtph2bf8128_mask", > IX86_BUILTIN_VCVTPH2BF8128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V16QI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtph2bf8v16hf_mask, "__builtin_ia32_vcvtph2bf8256_mask", > IX86_BUILTIN_VCVTPH2BF8256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtph2bf8v32hf_mask, "__builtin_ia32_vcvtph2bf8512_mask", > IX86_BUILTIN_VCVTPH2BF8512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V32HF_V32QI_USI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtph2bf8sv8hf_mask, "__builtin_ia32_vcvtph2bf8s128_mask", > IX86_BUILTIN_VCVTPH2BF8S128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V16QI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtph2bf8sv16hf_mask, > "__builtin_ia32_vcvtph2bf8s256_mask", > IX86_BUILTIN_VCVTPH2BF8S256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtph2bf8sv32hf_mask, > "__builtin_ia32_vcvtph2bf8s512_mask", > IX86_BUILTIN_VCVTPH2BF8S512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V32HF_V32QI_USI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtph2hf8v8hf_mask, "__builtin_ia32_vcvtph2hf8128_mask", > IX86_BUILTIN_VCVTPH2HF8128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V16QI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtph2hf8v16hf_mask, "__builtin_ia32_vcvtph2hf8256_mask", > IX86_BUILTIN_VCVTPH2HF8256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtph2hf8v32hf_mask, "__builtin_ia32_vcvtph2hf8512_mask", > IX86_BUILTIN_VCVTPH2HF8512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V32HF_V32QI_USI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtph2hf8sv8hf_mask, "__builtin_ia32_vcvtph2hf8s128_mask", > IX86_BUILTIN_VCVTPH2HF8S128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V16QI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtph2hf8sv16hf_mask, > "__builtin_ia32_vcvtph2hf8s256_mask", > IX86_BUILTIN_VCVTPH2HF8S256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16HF_V16QI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvtph2hf8sv32hf_mask, > "__builtin_ia32_vcvtph2hf8s512_mask", > IX86_BUILTIN_VCVTPH2HF8S512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V32HF_V32QI_USI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvthf82phv8hf_mask, "__builtin_ia32_vcvthf82ph128_mask", > IX86_BUILTIN_VCVTHF82PH128_MASK, UNKNOWN, (int) > V8HF_FTYPE_V16QI_V8HF_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvthf82phv16hf_mask, "__builtin_ia32_vcvthf82ph256_mask", > IX86_BUILTIN_VCVTHF82PH256_MASK, UNKNOWN, (int) > V16HF_FTYPE_V16QI_V16HF_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vcvthf82phv32hf_mask, "__builtin_ia32_vcvthf82ph512_mask", > IX86_BUILTIN_VCVTHF82PH512_MASK, UNKNOWN, (int) > V32HF_FTYPE_V32QI_V32HF_USI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_avx10v1aux_cvt2ps2phx_v16hf_mask, > "__builtin_ia32_vcvt2ps2phx256_mask", > IX86_BUILTIN_VCVT2PS2PHX_V16HF_MASK, UNKNOWN, (int) > V16HF_FTYPE_V8SF_V8SF_V16HF_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_avx10v1aux_cvt2ps2phx_v8hf_mask, > "__builtin_ia32_vcvt2ps2phx128_mask", > IX86_BUILTIN_VCVT2PS2PHX_V8HF_MASK, UNKNOWN, (int) > V8HF_FTYPE_V4SF_V4SF_V8HF_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2bf8v8hf, "__builtin_ia32_vcvtbiasph2bf8128", > IX86_BUILTIN_VCVTBIASPH2BF8128, UNKNOWN, (int) > V16QI_FTYPE_V16QI_V8HF) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2bf8v8hf_mask, > "__builtin_ia32_vcvtbiasph2bf8128_mask", > IX86_BUILTIN_VCVTBIASPH2BF8128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16QI_V8HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2bf8v16hf_mask, > "__builtin_ia32_vcvtbiasph2bf8256_mask", > IX86_BUILTIN_VCVTBIASPH2BF8256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V32QI_V16HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2bf8v32hf_mask, > "__builtin_ia32_vcvtbiasph2bf8512_mask", > IX86_BUILTIN_VCVTBIASPH2BF8512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V64QI_V32HF_V32QI_USI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2bf8sv8hf, "__builtin_ia32_vcvtbiasph2bf8s128", > IX86_BUILTIN_VCVTBIASPH2BF8S128, UNKNOWN, (int) > V16QI_FTYPE_V16QI_V8HF) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2bf8sv8hf_mask, > "__builtin_ia32_vcvtbiasph2bf8s128_mask", > IX86_BUILTIN_VCVTBIASPH2BF8S128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16QI_V8HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2bf8sv16hf_mask, > "__builtin_ia32_vcvtbiasph2bf8s256_mask", > IX86_BUILTIN_VCVTBIASPH2BF8S256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V32QI_V16HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2bf8sv32hf_mask, > "__builtin_ia32_vcvtbiasph2bf8s512_mask", > IX86_BUILTIN_VCVTBIASPH2BF8S512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V64QI_V32HF_V32QI_USI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2hf8v8hf, "__builtin_ia32_vcvtbiasph2hf8128", > IX86_BUILTIN_VCVTBIASPH2HF8128, UNKNOWN, (int) > V16QI_FTYPE_V16QI_V8HF) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2hf8v8hf_mask, > "__builtin_ia32_vcvtbiasph2hf8128_mask", > IX86_BUILTIN_VCVTBIASPH2HF8128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16QI_V8HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2hf8v16hf_mask, > "__builtin_ia32_vcvtbiasph2hf8256_mask", > IX86_BUILTIN_VCVTBIASPH2HF8256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V32QI_V16HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2hf8v32hf_mask, > "__builtin_ia32_vcvtbiasph2hf8512_mask", > IX86_BUILTIN_VCVTBIASPH2HF8512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V64QI_V32HF_V32QI_USI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2hf8sv8hf, "__builtin_ia32_vcvtbiasph2hf8s128", > IX86_BUILTIN_VCVTBIASPH2HF8S128, UNKNOWN, (int) > V16QI_FTYPE_V16QI_V8HF) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2hf8sv8hf_mask, > "__builtin_ia32_vcvtbiasph2hf8s128_mask", > IX86_BUILTIN_VCVTBIASPH2HF8S128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16QI_V8HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2hf8sv16hf_mask, > "__builtin_ia32_vcvtbiasph2hf8s256_mask", > IX86_BUILTIN_VCVTBIASPH2HF8S256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V32QI_V16HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtbiasph2hf8sv32hf_mask, > "__builtin_ia32_vcvtbiasph2hf8s512_mask", > IX86_BUILTIN_VCVTBIASPH2HF8S512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V64QI_V32HF_V32QI_USI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvt2ph2bf8v8hf_mask, > "__builtin_ia32_vcvt2ph2bf8128_mask", > IX86_BUILTIN_VCVT2PH2BF8128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V8HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvt2ph2bf8v16hf_mask, > "__builtin_ia32_vcvt2ph2bf8256_mask", > IX86_BUILTIN_VCVT2PH2BF8256_MASK, UNKNOWN, (int) > V32QI_FTYPE_V16HF_V16HF_V32QI_USI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvt2ph2bf8v32hf_mask, > "__builtin_ia32_vcvt2ph2bf8512_mask", > IX86_BUILTIN_VCVT2PH2BF8512_MASK, UNKNOWN, (int) > V64QI_FTYPE_V32HF_V32HF_V64QI_UDI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvt2ph2bf8sv8hf_mask, > "__builtin_ia32_vcvt2ph2bf8s128_mask", > IX86_BUILTIN_VCVT2PH2BF8S128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V8HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvt2ph2bf8sv16hf_mask, > "__builtin_ia32_vcvt2ph2bf8s256_mask", > IX86_BUILTIN_VCVT2PH2BF8S256_MASK, UNKNOWN, (int) > V32QI_FTYPE_V16HF_V16HF_V32QI_USI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvt2ph2bf8sv32hf_mask, > "__builtin_ia32_vcvt2ph2bf8s512_mask", > IX86_BUILTIN_VCVT2PH2BF8S512_MASK, UNKNOWN, (int) > V64QI_FTYPE_V32HF_V32HF_V64QI_UDI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvt2ph2hf8v8hf_mask, > "__builtin_ia32_vcvt2ph2hf8128_mask", > IX86_BUILTIN_VCVT2PH2HF8128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V8HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvt2ph2hf8v16hf_mask, > "__builtin_ia32_vcvt2ph2hf8256_mask", > IX86_BUILTIN_VCVT2PH2HF8256_MASK, UNKNOWN, (int) > V32QI_FTYPE_V16HF_V16HF_V32QI_USI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvt2ph2hf8v32hf_mask, > "__builtin_ia32_vcvt2ph2hf8512_mask", > IX86_BUILTIN_VCVT2PH2HF8512_MASK, UNKNOWN, (int) > V64QI_FTYPE_V32HF_V32HF_V64QI_UDI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvt2ph2hf8sv8hf_mask, > "__builtin_ia32_vcvt2ph2hf8s128_mask", > IX86_BUILTIN_VCVT2PH2HF8S128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V8HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvt2ph2hf8sv16hf_mask, > "__builtin_ia32_vcvt2ph2hf8s256_mask", > IX86_BUILTIN_VCVT2PH2HF8S256_MASK, UNKNOWN, (int) > V32QI_FTYPE_V16HF_V16HF_V32QI_USI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvt2ph2hf8sv32hf_mask, > "__builtin_ia32_vcvt2ph2hf8s512_mask", > IX86_BUILTIN_VCVT2PH2HF8S512_MASK, UNKNOWN, (int) > V64QI_FTYPE_V32HF_V32HF_V64QI_UDI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtph2bf8v8hf_mask, "__builtin_ia32_vcvtph2bf8128_mask", > IX86_BUILTIN_VCVTPH2BF8128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V16QI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtph2bf8v16hf_mask, "__builtin_ia32_vcvtph2bf8256_mask", > IX86_BUILTIN_VCVTPH2BF8256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtph2bf8v32hf_mask, "__builtin_ia32_vcvtph2bf8512_mask", > IX86_BUILTIN_VCVTPH2BF8512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V32HF_V32QI_USI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtph2bf8sv8hf_mask, "__builtin_ia32_vcvtph2bf8s128_mask", > IX86_BUILTIN_VCVTPH2BF8S128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V16QI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtph2bf8sv16hf_mask, > "__builtin_ia32_vcvtph2bf8s256_mask", > IX86_BUILTIN_VCVTPH2BF8S256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtph2bf8sv32hf_mask, > "__builtin_ia32_vcvtph2bf8s512_mask", > IX86_BUILTIN_VCVTPH2BF8S512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V32HF_V32QI_USI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtph2hf8v8hf_mask, "__builtin_ia32_vcvtph2hf8128_mask", > IX86_BUILTIN_VCVTPH2HF8128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V16QI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtph2hf8v16hf_mask, "__builtin_ia32_vcvtph2hf8256_mask", > IX86_BUILTIN_VCVTPH2HF8256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtph2hf8v32hf_mask, "__builtin_ia32_vcvtph2hf8512_mask", > IX86_BUILTIN_VCVTPH2HF8512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V32HF_V32QI_USI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtph2hf8sv8hf_mask, "__builtin_ia32_vcvtph2hf8s128_mask", > IX86_BUILTIN_VCVTPH2HF8S128_MASK, UNKNOWN, (int) > V16QI_FTYPE_V8HF_V16QI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtph2hf8sv16hf_mask, > "__builtin_ia32_vcvtph2hf8s256_mask", > IX86_BUILTIN_VCVTPH2HF8S256_MASK, UNKNOWN, (int) > V16QI_FTYPE_V16HF_V16QI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvtph2hf8sv32hf_mask, > "__builtin_ia32_vcvtph2hf8s512_mask", > IX86_BUILTIN_VCVTPH2HF8S512_MASK, UNKNOWN, (int) > V32QI_FTYPE_V32HF_V32QI_USI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvthf82phv8hf_mask, "__builtin_ia32_vcvthf82ph128_mask", > IX86_BUILTIN_VCVTHF82PH128_MASK, UNKNOWN, (int) > V8HF_FTYPE_V16QI_V8HF_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvthf82phv16hf_mask, "__builtin_ia32_vcvthf82ph256_mask", > IX86_BUILTIN_VCVTHF82PH256_MASK, UNKNOWN, (int) > V16HF_FTYPE_V16QI_V16HF_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vcvthf82phv32hf_mask, "__builtin_ia32_vcvthf82ph512_mask", > IX86_BUILTIN_VCVTHF82PH512_MASK, UNKNOWN, (int) > V32HF_FTYPE_V32QI_V32HF_USI) > BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_avx10_2_addbf16_v32bf, "__builtin_ia32_addbf16512", > IX86_BUILTIN_ADDBF16512, UNKNOWN, (int) V32BF_FTYPE_V32BF_V32BF) > BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_avx10_2_addbf16_v32bf_mask, > "__builtin_ia32_addbf16512_mask", IX86_BUILTIN_ADDBF16512_MASK, > UNKNOWN, (int) V32BF_FTYPE_V32BF_V32BF_V32BF_USI) > BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_avx10_2_addbf16_v16bf, "__builtin_ia32_addbf16256", > IX86_BUILTIN_ADDBF16256, UNKNOWN, (int) V16BF_FTYPE_V16BF_V16BF) > @@ -3738,7 +3738,7 @@ BDESC (0, OPTION_MASK_ISA2_AVX512FP16, > CODE_FOR_avx512fp16_fmulcsh_v8hf_round, " > BDESC (0, OPTION_MASK_ISA2_AVX512FP16, > CODE_FOR_avx512fp16_fmulcsh_v8hf_mask_round, > "__builtin_ia32_vfmulcsh_mask_round", > IX86_BUILTIN_VFMULCSH_MASK_ROUND, UNKNOWN, (int) > V8HF_FTYPE_V8HF_V8HF_V8HF_UQI_INT) > > /* AVX10.2. */ > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_avx10_2_cvt2ps2phx_v32hf_mask_round, > "__builtin_ia32_vcvt2ps2phx512_mask_round", > IX86_BUILTIN_VCVT2PS2PHX_V32HF_MASK_ROUND, UNKNOWN, (int) > V32HF_FTYPE_V16SF_V16SF_V32HF_USI_INT) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_avx10v1aux_cvt2ps2phx_v32hf_mask_round, > "__builtin_ia32_vcvt2ps2phx512_mask_round", > IX86_BUILTIN_VCVT2PS2PHX_V32HF_MASK_ROUND, UNKNOWN, (int) > V32HF_FTYPE_V16SF_V16SF_V32HF_USI_INT) > BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_avx10_2_cvtph2ibsv32hf_mask_round, > "__builtin_ia32_cvtph2ibs512_mask_round", > IX86_BUILTIN_CVTPH2IBS512_MASK_ROUND, UNKNOWN, (int) > V32HI_FTYPE_V32HF_V32HI_USI_INT) > BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_avx10_2_cvtph2iubsv32hf_mask_round, > "__builtin_ia32_cvtph2iubs512_mask_round", > IX86_BUILTIN_CVTPH2IUBS512_MASK_ROUND, UNKNOWN, (int) > V32HI_FTYPE_V32HF_V32HI_USI_INT) > BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_avx10_2_cvtps2ibsv16sf_mask_round, > "__builtin_ia32_cvtps2ibs512_mask_round", > IX86_BUILTIN_CVTPS2IBS512_MASK_ROUND, UNKNOWN, (int) > V16SI_FTYPE_V16SF_V16SI_UHI_INT) > diff --git a/gcc/config/i386/immintrin.h b/gcc/config/i386/immintrin.h > index 63db4fddca65..74063ee40532 100644 > --- a/gcc/config/i386/immintrin.h > +++ b/gcc/config/i386/immintrin.h > @@ -148,6 +148,8 @@ > > #include > > +#include > + > #include > > #include > diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md > index c1e8b2562958..a223acc606d7 100644 > --- a/gcc/config/i386/sse.md > +++ b/gcc/config/i386/sse.md > @@ -33436,14 +33436,14 @@ > (set_attr "addr" "gpr16") > (set_attr "mode" "")]) > > -(define_insn "avx10_2_cvt2ps2phx_" > +(define_insn > "avx10v1aux_cvt2ps2phx_" > [(set (match_operand:VHF_AVX512VL 0 "register_operand" "=v") > (vec_concat:VHF_AVX512VL > (float_truncate: > (match_operand: 2 "" > "")) > (float_truncate: > (match_operand: 1 "register_operand" "v"))))] > - "TARGET_AVX10_2 && " > + "TARGET_AVX10V1AUX && " > > "vcvt2ps2phx\t{%2, %1, %0|%0 _operand3>, %1, %2}") > > (define_mode_attr ssebvecmode > @@ -33465,7 +33465,7 @@ > [(match_operand:VHF_AVX512VL 1 "register_operand" "v") > (match_operand:VHF_AVX512VL 2 "nonimmediate_operand" > "vm")] > UNSPEC_CONVERTFP8_PACK))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > > "vcvt\t{%2, %1, %0|%0 3>, %1, %2}" > [(set_attr "prefix" "evex")]) > > @@ -33494,7 +33494,7 @@ > (match_operand:V8HF 2 "nonimmediate_operand")] > UNSPEC_VCVTBIASPH2FP8_PACK) > (match_dup 3)))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > "operands[3] = CONST0_RTX (V8QImode);") > > (define_insn "*vcvtv8hf" > @@ -33505,7 +33505,7 @@ > (match_operand:V8HF 2 "nonimmediate_operand" "vm")] > UNSPEC_VCVTBIASPH2FP8_PACK) > (match_operand:V8QI 3 "const0_operand")))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > "vcvt\t{%2, %1, %0|%0, %1, %2}" > [(set_attr "prefix" "evex") > (set_attr "mode" "HF")]) > @@ -33526,7 +33526,7 @@ > (const_int 6) (const_int 7)])) > (match_operand:QI 4 "register_operand" "C")) > (match_dup 5)))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > "operands[5] = CONST0_RTX (V8QImode);") > > (define_insn "*vcvtv8hf_mask" > @@ -33545,26 +33545,23 @@ > (const_int 6) (const_int 7)])) > (match_operand:QI 4 "register_operand" "Yk")) > (match_operand:V8QI 5 "const0_operand")))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > > "vcvt\t{%2, %1, %0%{%4%}%N3|%0%{%4%}%N3, %1, % > 2}" > [(set_attr "prefix" "evex")]) > > -(define_mode_iterator VHF_AVX10_2_2 > - [V32HF V16HF]) > +(define_mode_iterator VHF_256_512 > + [V16HF (V32HF "TARGET_AVX10V1AUX")]) > > (define_insn "vcvt" > [(set (match_operand: 0 "register_operand" "=v") > (unspec: > [(match_operand: 1 "register_operand" "v") > - (match_operand:VHF_AVX10_2_2 2 "nonimmediate_operand" > "vm")] > + (match_operand:VHF_256_512 2 "nonimmediate_operand" "vm")] > UNSPEC_VCVTBIASPH2FP8_PACK))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > > "vcvt\t{%2, %1, %0|%0 d3>, %1, %2}" > [(set_attr "prefix" "evex")]) > > -(define_mode_iterator VHF_256_512 > - [V16HF (V32HF "TARGET_AVX10_2")]) > - > (define_mode_attr ph2fp8suff > [(V32HF "") (V16HF "{y}") (V8HF "{x}")]) > > @@ -33585,7 +33582,7 @@ > [(match_operand:V8HF 1 "nonimmediate_operand")] > UNSPEC_CONVERTPH2FP8) > (match_dup 2)))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > "operands[2] = CONST0_RTX (V8QImode);") > > (define_insn "*vcvtv8hf" > @@ -33595,7 +33592,7 @@ > [(match_operand:V8HF 1 "nonimmediate_operand" "vm")] > UNSPEC_CONVERTPH2FP8) > (match_operand:V8QI 2 "const0_operand")))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > "vcvt{x}\t{%1, %0|%0, %1}" > [(set_attr "prefix" "evex") > (set_attr "mode" "HF")]) > @@ -33615,7 +33612,7 @@ > (const_int 6) (const_int 7)])) > (match_operand:QI 3 "register_operand")) > (match_dup 4)))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > "operands[4] = CONST0_RTX (V8QImode);") > > (define_insn "*vcvtv8hf_mask" > @@ -33633,7 +33630,7 @@ > (const_int 6) (const_int 7)])) > (match_operand:QI 3 "register_operand" "Yk")) > (match_operand:V8QI 4 "const0_operand")))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > "vcvt{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}" > [(set_attr "prefix" "evex")]) > > @@ -33642,7 +33639,7 @@ > (unspec: > [(match_operand:VHF_256_512 1 "nonimmediate_operand" "vm")] > UNSPEC_CONVERTPH2FP8))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > > "vcvt\t{%1, %0|%0 operand2>, %1}" > [(set_attr "prefix" "evex")]) > > @@ -33651,7 +33648,7 @@ > (unspec:VHF_AVX512VL > [(match_operand: 1 "nonimmediate_operand" > "vm")] > UNSPEC_VCVTHF82PH))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > > "vcvthf82ph\t{%1, %0|%0, % ec_2>1}" > [(set_attr "prefix" "evex")]) > > diff --git a/gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c > b/gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c > new file mode 100644 > index 000000000000..369ec969dde5 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c > @@ -0,0 +1,375 @@ > +/* { dg-do compile } */ > +/* { dg-options "-mavx10v1aux -O2 -fno-fuse-ops-with-volatile-access" } */ > +/* { dg-final { scan-assembler-times > "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0- > 9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0- > 9\]+\[^\n\r]*%xmm\[0-9\]+\{%k\[0-9\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0- > 9\]+\[^\n\r]*%xmm\[0-9\]+\{%k\[0-9\]\}\{z\}\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } > */ > +/* { dg-final { scan-assembler-times > "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0- > 9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0- > 9\]+\[^\n\r]*%ymm\[0-9\]+\{%k\[0-9\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0- > 9\]+\[^\n\r]*%ymm\[0-9\]+\{%k\[0-9\]\}\{z\}\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } > */ > +/* { dg-final { scan-assembler-times > "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0- > 9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0- > 9\]+\[^\n\r]*%zmm\[0-9\]+\{%k\[0-9\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ps2phx\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0- > 9\]+\[^\n\r]*%zmm\[0-9\]+\{%k\[0-9\]\}\{z\}\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } > */ > +/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\{rn- > sae\}\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0- > 9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\{rn- > sae\}\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0- > 9\]+\{%k\[0-9\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvt2ps2phx\[ \\t\]+\{rn- > sae\}\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0- > 9\]+\{%k\[0-9\]\}\{z\}\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2bf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvtbiasph2hf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2bf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+,\[^\{\n\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+,\[^\{\n\]*%ymm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times > "vcvt2ph2hf8s\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+,\[^\{\n\]*%zmm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvthf82ph\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8x\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8x\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8x\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8y\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8y\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8y\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8\[ \\t\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8\[ \\t\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8\[ \\t\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8sx\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8sx\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8sx\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8sy\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8sy\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8sy\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8s\[ \\t\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8s\[ \\t\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2bf8s\[ \\t\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8x\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8x\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8x\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8y\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8y\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8y\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8\[ \\t\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8\[ \\t\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8\[ \\t\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8sx\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8sx\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8sx\[ \\t\]*%xmm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8sy\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8sy\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8sy\[ \\t\]*%ymm\[0- > 9\]+,\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8s\[ \\t\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8s\[ \\t\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ > +/* { dg-final { scan-assembler-times "vcvtph2hf8s\[ \\t\]*%zmm\[0- > 9\]+,\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ > + > +#include > + > +volatile __m128 a1,b1; > +volatile __m256 a2,b2; > +volatile __m512 a3,b3; > +volatile __m128h y,x128h,z; > +volatile __m256h y2,x256h,z2; > +volatile __m512h y3,x512h,z4; > +volatile __m128i x128i,z3; > +volatile __m256i x256i,z1; > +volatile __m512i x512i; > +volatile __mmask8 m8; > +volatile __mmask16 m16; > +volatile __mmask32 m32; > +volatile __mmask64 m64; > + > +void extern > +avx10v1aux_test (void) > +{ > + y = _mm_cvtx2ps_ph (a1, b1); > + y = _mm_mask_cvtx2ps_ph (y, m8, a1, b1); > + y = _mm_maskz_cvtx2ps_ph (m8, a1, b1); > + > + y2 = _mm256_cvtx2ps_ph (a2, b2); > + y2 = _mm256_mask_cvtx2ps_ph (y2, m16, a2, b2); > + y2 = _mm256_maskz_cvtx2ps_ph (m16, a2, b2); > + > + y3 = _mm512_cvtx2ps_ph (a3, b3); > + y3 = _mm512_mask_cvtx2ps_ph (y3, m32, a3, b3); > + y3 = _mm512_maskz_cvtx2ps_ph (m32, a3, b3); > + > + y3 = _mm512_cvtx_round2ps_ph (a3, b3, 8); > + y3 = _mm512_mask_cvtx_round2ps_ph (y3, m32, a3, b3, 8); > + y3 = _mm512_maskz_cvtx_round2ps_ph (m32, a3, b3, 8); > +} > + > +void extern > +avx10v1aux_vcvtbiasph2bf8_test (void) > +{ > + x128i = _mm_cvtbiasph_bf8 (x128i, x128h); > + x128i = _mm_mask_cvtbiasph_bf8 (x128i, m8, x128i, x128h); > + x128i = _mm_maskz_cvtbiasph_bf8 (m8, x128i, x128h); > + > + x128i = _mm256_cvtbiasph_bf8 (x256i, x256h); > + x128i = _mm256_mask_cvtbiasph_bf8 (x128i, m16, x256i, x256h); > + x128i = _mm256_maskz_cvtbiasph_bf8 (m16, x256i, x256h); > + > + x256i = _mm512_cvtbiasph_bf8 (x512i, x512h); > + x256i = _mm512_mask_cvtbiasph_bf8 (x256i, m32, x512i, x512h); > + x256i = _mm512_maskz_cvtbiasph_bf8 (m32, x512i, x512h); > +} > + > +void extern > +avx10v1aux_vcvtbiasph2bf8s_test (void) > +{ > + x128i = _mm_cvts_biasph_bf8 (x128i, x128h); > + x128i = _mm_mask_cvts_biasph_bf8 (x128i, m8, x128i, x128h); > + x128i = _mm_maskz_cvts_biasph_bf8 (m8, x128i, x128h); > + > + x128i = _mm256_cvts_biasph_bf8 (x256i, x256h); > + x128i = _mm256_mask_cvts_biasph_bf8 (x128i, m16, x256i, x256h); > + x128i = _mm256_maskz_cvts_biasph_bf8 (m16, x256i, x256h); > + > + x256i = _mm512_cvts_biasph_bf8 (x512i, x512h); > + x256i = _mm512_mask_cvts_biasph_bf8 (x256i, m32, x512i, x512h); > + x256i = _mm512_maskz_cvts_biasph_bf8 (m32, x512i, x512h); > +} > + > +void extern > +avx10v1aux_vcvtbiasph2hf8_test (void) > +{ > + x128i = _mm_cvtbiasph_hf8 (x128i, x128h); > + x128i = _mm_mask_cvtbiasph_hf8 (x128i, m8, x128i, x128h); > + x128i = _mm_maskz_cvtbiasph_hf8 (m8, x128i, x128h); > + > + x128i = _mm256_cvtbiasph_hf8 (x256i, x256h); > + x128i = _mm256_mask_cvtbiasph_hf8 (x128i, m16, x256i, x256h); > + x128i = _mm256_maskz_cvtbiasph_hf8 (m16, x256i, x256h); > + > + x256i = _mm512_cvtbiasph_hf8 (x512i, x512h); > + x256i = _mm512_mask_cvtbiasph_hf8 (x256i, m32, x512i, x512h); > + x256i = _mm512_maskz_cvtbiasph_hf8 (m32, x512i, x512h); > +} > + > +void extern > +avx10v1aux_vcvtbiasph2hf8s_test (void) > +{ > + x128i = _mm_cvts_biasph_hf8 (x128i, x128h); > + x128i = _mm_mask_cvts_biasph_hf8 (x128i, m8, x128i, x128h); > + x128i = _mm_maskz_cvts_biasph_hf8 (m8, x128i, x128h); > + > + x128i = _mm256_cvts_biasph_hf8 (x256i, x256h); > + x128i = _mm256_mask_cvts_biasph_hf8 (x128i, m16, x256i, x256h); > + x128i = _mm256_maskz_cvts_biasph_hf8 (m16, x256i, x256h); > + > + x256i = _mm512_cvts_biasph_hf8 (x512i, x512h); > + x256i = _mm512_mask_cvts_biasph_hf8 (x256i, m32, x512i, x512h); > + x256i = _mm512_maskz_cvts_biasph_hf8 (m32, x512i, x512h); > +} > + > +void extern > +avx10v1aux_vcvt2ph2bf8_test (void) > +{ > + x128i = _mm_cvt2ph_bf8 (x128h, x128h); > + x128i = _mm_mask_cvt2ph_bf8 (x128i, m16, x128h, x128h); > + x128i = _mm_maskz_cvt2ph_bf8 (m16, x128h, x128h); > + > + x256i = _mm256_cvt2ph_bf8 (x256h, x256h); > + x256i = _mm256_mask_cvt2ph_bf8 (x256i, m32, x256h, x256h); > + x256i = _mm256_maskz_cvt2ph_bf8 (m32, x256h, x256h); > + > + x512i = _mm512_cvt2ph_bf8 (x512h, x512h); > + x512i = _mm512_mask_cvt2ph_bf8 (x512i, m64, x512h, x512h); > + x512i = _mm512_maskz_cvt2ph_bf8 (m64, x512h, x512h); > +} > + > +void extern > +avx10v1aux_vcvt2ph2bf8s_test (void) > +{ > + x128i = _mm_cvts_2ph_bf8 (x128h, x128h); > + x128i = _mm_mask_cvts_2ph_bf8 (x128i, m16, x128h, x128h); > + x128i = _mm_maskz_cvts_2ph_bf8 (m16, x128h, x128h); > + > + x256i = _mm256_cvts_2ph_bf8 (x256h, x256h); > + x256i = _mm256_mask_cvts_2ph_bf8 (x256i, m32, x256h, x256h); > + x256i = _mm256_maskz_cvts_2ph_bf8 (m32, x256h, x256h); > + > + x512i = _mm512_cvts_2ph_bf8 (x512h, x512h); > + x512i = _mm512_mask_cvts_2ph_bf8 (x512i, m64, x512h, x512h); > + x512i = _mm512_maskz_cvts_2ph_bf8 (m64, x512h, x512h); > +} > + > +void extern > +avx10v1aux_vcvt2ph2hf8_test (void) > +{ > + x128i = _mm_cvt2ph_hf8 (x128h, x128h); > + x128i = _mm_mask_cvt2ph_hf8 (x128i, m16, x128h, x128h); > + x128i = _mm_maskz_cvt2ph_hf8 (m16, x128h, x128h); > + > + x256i = _mm256_cvt2ph_hf8 (x256h, x256h); > + x256i = _mm256_mask_cvt2ph_hf8 (x256i, m32, x256h, x256h); > + x256i = _mm256_maskz_cvt2ph_hf8 (m32, x256h, x256h); > + > + x512i = _mm512_cvt2ph_hf8 (x512h, x512h); > + x512i = _mm512_mask_cvt2ph_hf8 (x512i, m64, x512h, x512h); > + x512i = _mm512_maskz_cvt2ph_hf8 (m64, x512h, x512h); > +} > + > +void extern > +avx10v1aux_vcvt2ph2hf8s_test (void) > +{ > + x128i = _mm_cvts_2ph_hf8 (x128h, x128h); > + x128i = _mm_mask_cvts_2ph_hf8 (x128i, m16, x128h, x128h); > + x128i = _mm_maskz_cvts_2ph_hf8 (m16, x128h, x128h); > + > + x256i = _mm256_cvts_2ph_hf8 (x256h, x256h); > + x256i = _mm256_mask_cvts_2ph_hf8 (x256i, m32, x256h, x256h); > + x256i = _mm256_maskz_cvts_2ph_hf8 (m32, x256h, x256h); > + > + x512i = _mm512_cvts_2ph_hf8 (x512h, x512h); > + x512i = _mm512_mask_cvts_2ph_hf8 (x512i, m64, x512h, x512h); > + x512i = _mm512_maskz_cvts_2ph_hf8 (m64, x512h, x512h); > +} > + > +void extern > +avx10v1aux_vcvthf82ph_test (void) > +{ > + x128h = _mm_cvthf8_ph (x128i); > + x128h = _mm_mask_cvthf8_ph (x128h, m8, x128i); > + x128h = _mm_maskz_cvthf8_ph (m8, x128i); > + > + x256h = _mm256_cvthf8_ph (x128i); > + x256h = _mm256_mask_cvthf8_ph (x256h, m16, x128i); > + x256h = _mm256_maskz_cvthf8_ph (m16, x128i); > + > + x512h = _mm512_cvthf8_ph (x256i); > + x512h = _mm512_mask_cvthf8_ph (x512h, m32, x256i); > + x512h = _mm512_maskz_cvthf8_ph (m32, x256i); > +} > + > +void extern > +avx10v1aux_vcvtph2bf8_test (void) > +{ > + x128i = _mm_cvtph_bf8 (x128h); > + x128i = _mm_mask_cvtph_bf8 (x128i, m8, x128h); > + x128i = _mm_maskz_cvtph_bf8 (m8, x128h); > + > + x128i = _mm256_cvtph_bf8 (x256h); > + x128i = _mm256_mask_cvtph_bf8 (x128i, m16, x256h); > + x128i = _mm256_maskz_cvtph_bf8 (m16, x256h); > + > + x256i = _mm512_cvtph_bf8 (x512h); > + x256i = _mm512_mask_cvtph_bf8 (x256i, m32, x512h); > + x256i = _mm512_maskz_cvtph_bf8 (m32, x512h); > +} > + > +void extern > +avx10v1aux_vcvtph2bf8s_test (void) > +{ > + x128i = _mm_cvts_ph_bf8 (x128h); > + x128i = _mm_mask_cvts_ph_bf8 (x128i, m8, x128h); > + x128i = _mm_maskz_cvts_ph_bf8 (m8, x128h); > + > + x128i = _mm256_cvts_ph_bf8 (x256h); > + x128i = _mm256_mask_cvts_ph_bf8 (x128i, m16, x256h); > + x128i = _mm256_maskz_cvts_ph_bf8 (m16, x256h); > + > + x256i = _mm512_cvts_ph_bf8 (x512h); > + x256i = _mm512_mask_cvts_ph_bf8 (x256i, m32, x512h); > + x256i = _mm512_maskz_cvts_ph_bf8 (m32, x512h); > +} > + > +void extern > +avx10v1aux_vcvtph2hf8_test (void) > +{ > + x128i = _mm_cvtph_hf8 (x128h); > + x128i = _mm_mask_cvtph_hf8 (x128i, m8, x128h); > + x128i = _mm_maskz_cvtph_hf8 (m8, x128h); > + > + x128i = _mm256_cvtph_hf8 (x256h); > + x128i = _mm256_mask_cvtph_hf8 (x128i, m16, x256h); > + x128i = _mm256_maskz_cvtph_hf8 (m16, x256h); > + > + x256i = _mm512_cvtph_hf8 (x512h); > + x256i = _mm512_mask_cvtph_hf8 (x256i, m32, x512h); > + x256i = _mm512_maskz_cvtph_hf8 (m32, x512h); > +} > + > +void extern > +avx10v1aux_vcvtph2hf8s_test (void) > +{ > + x128i = _mm_cvts_ph_hf8 (x128h); > + x128i = _mm_mask_cvts_ph_hf8 (x128i, m8, x128h); > + x128i = _mm_maskz_cvts_ph_hf8 (m8, x128h); > + > + x128i = _mm256_cvts_ph_hf8 (x256h); > + x128i = _mm256_mask_cvts_ph_hf8 (x128i, m16, x256h); > + x128i = _mm256_maskz_cvts_ph_hf8 (m16, x256h); > + > + x256i = _mm512_cvts_ph_hf8 (x512h); > + x256i = _mm512_mask_cvts_ph_hf8 (x256i, m32, x512h); > + x256i = _mm512_maskz_cvts_ph_hf8 (m32, x512h); > +} > diff --git a/gcc/testsuite/gcc.target/i386/funcspec-56.inc > b/gcc/testsuite/gcc.target/i386/funcspec-56.inc > index f18778025753..0a364ff43d3a 100644 > --- a/gcc/testsuite/gcc.target/i386/funcspec-56.inc > +++ b/gcc/testsuite/gcc.target/i386/funcspec-56.inc > @@ -94,6 +94,7 @@ extern void test_movrs (void) > __attribute__((__target__("movrs"))); > extern void test_amx_movrs (void) > __attribute__((__target__("amx-movrs"))); > extern void test_avx10v2aux (void) > __attribute__((__target__("avx10v2aux"))); > extern void test_acev1 (void) > __attribute__((__target__("acev1"))); > +extern void test_avx10v1aux (void) > __attribute__((__target__("avx10v1aux"))); > > extern void test_no_sgx (void) > __attribute__((__target__("no-sgx"))); > extern void test_no_avx512vpopcntdq(void) > __attribute__((__target__("no-avx512vpopcntdq"))); > @@ -189,6 +190,7 @@ extern void test_no_movrs (void) > __attribute__((__target__("no-movrs"))); > extern void test_no_amx_movrs (void) > __attribute__((__target__("no-amx-movrs"))); > extern void test_no_avx10v2aux (void) > __attribute__((__target__("no-avx10v2aux"))); > extern void test_no_acev1 (void) > __attribute__((__target__("no-acev1"))); > +extern void test_no_avx10v1aux (void) > __attribute__((__target__("no-avx10v1aux"))); > > extern void test_arch_nocona (void) > __attribute__((__target__("arch=nocona"))); > extern void test_arch_core2 (void) > __attribute__((__target__("arch=core2"))); > diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target- > supports.exp > index ae04b6a8daa1..1485d1bef81b 100644 > --- a/gcc/testsuite/lib/target-supports.exp > +++ b/gcc/testsuite/lib/target-supports.exp > @@ -11767,6 +11767,17 @@ proc check_effective_target_avx10v2aux { } { > } "-mavx10v2aux" ] > } > > +# Return 1 if avx10v1aux instructions can be compiled. > +proc check_effective_target_avx10v1aux { } { > + return [check_no_compiler_messages avx10v1aux object { > + void > + foo () > + { > + __asm__ volatile > ("vcvt2ph2bf8\t{%%zmm2, %%zmm1, %%zmm1|%%zmm1, %%zmm1, %%z > mm2}"); > + } > + } "-mavx10v1aux" ] > +} > + > # Return 1 if amx-avx512 instructions can be compiled. > proc check_effective_target_amx_avx512 { } { > return [check_no_compiler_messages amx_avx512 object { > -- > 2.34.1 From haochen.jiang@intel.com Mon Nov 2 06:18:20 2026 From: haochen.jiang@intel.com (Jiang, Haochen) Date: Mon, 2 Nov 2026 06:18:20 +0000 Subject: [PATCH v3 3/4] [X86]: Move shared AVX10.2 and VNNI byte and word intrinsics to AVX10V1AUX. In-Reply-To: <20261101134756.351245-4-Dipesh.Sharma@amd.com> References: <20261101134756.351245-1-Dipesh.Sharma@amd.com> <20261101134756.351245-4-Dipesh.Sharma@amd.com> Message-ID: > From: Dipesh Sharma > Sent: Sunday, November 1, 2026 9:48 PM > To: gcc-patches@gcc.gnu.org > LGTM. Thx, Haochen > gcc/ChangeLog: > > * config/i386/avx10_2mediaintrin.h: Moved VNNI byte and word > intrinsics to avx10v1auxintrin.h. > * config/i386/avx10v1auxintrin.h: Added VNNI byte and word > intrinsics. > * config/i386/i386-builtin.def (BDESC): Updated option mask for > VNNIINT{8,16} and 10.2 builtins. > * config/i386/i386.md: Add target avx10v1aux. > * config/i386/i386-expand.cc (ix86_check_builtin_isa_match): Share > builtins between > VNNIINT{8,16} and AVX10V1AUX. > * config/i386/i386.cc (ix86_vector_costs::add_stmt_cost): Update > target guard > from AVX10_2 to AVX10V1AUX. > * config/i386/sse.md: Retarget avx10.2 subset VNNI > byte and word patterns to AVX10V1AUX. > > Co-authored-by: Venkataramanan Kumar > > --- > gcc/config/i386/avx10_2mediaintrin.h | 1032 -------------------------- > gcc/config/i386/avx10v1auxintrin.h | 1032 > ++++++++++++++++++++++++++ > gcc/config/i386/i386-builtin.def | 216 +++--- > gcc/config/i386/i386-expand.cc | 8 +- > gcc/config/i386/i386.cc | 4 +- > gcc/config/i386/i386.md | 4 +- > gcc/config/i386/sse.md | 125 ++-- > 7 files changed, 1213 insertions(+), 1208 deletions(-) > > diff --git a/gcc/config/i386/avx10_2mediaintrin.h > b/gcc/config/i386/avx10_2mediaintrin.h > index 24af37954166..ffc1cbf66a56 100644 > --- a/gcc/config/i386/avx10_2mediaintrin.h > +++ b/gcc/config/i386/avx10_2mediaintrin.h > @@ -34,1038 +34,6 @@ > #define __DISABLE_AVX10_2__ > #endif /* __AVX10_2__ */ > > -#define _mm_dpbssd_epi32(W, A, B) \ > - (__m128i) __builtin_ia32_vpdpbssd128 ((__v4si) (W), (__v4si) (A), (__v4si) > (B)) > - > -#define _mm_dpbssds_epi32(W, A, B) \ > - (__m128i) __builtin_ia32_vpdpbssds128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > - > -#define _mm_dpbsud_epi32(W, A, B) \ > - (__m128i) __builtin_ia32_vpdpbsud128 ((__v4si) (W), (__v4si) (A), (__v4si) > (B)) > - > -#define _mm_dpbsuds_epi32(W, A, B) \ > - (__m128i) __builtin_ia32_vpdpbsuds128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > - > -#define _mm_dpbuud_epi32(W, A, B) \ > - (__m128i) __builtin_ia32_vpdpbuud128 ((__v4si) (W), (__v4si) (A), (__v4si) > (B)) > - > -#define _mm_dpbuuds_epi32(W, A, B) \ > - (__m128i) __builtin_ia32_vpdpbuuds128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > - > -#define _mm256_dpbssd_epi32(W, A, B) \ > - (__m256i) __builtin_ia32_vpdpbssd256 ((__v8si) (W), (__v8si) (A), (__v8si) > (B)) > - > -#define _mm256_dpbssds_epi32(W, A, B) \ > - (__m256i) __builtin_ia32_vpdpbssds256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > - > -#define _mm256_dpbsud_epi32(W, A, B) \ > - (__m256i) __builtin_ia32_vpdpbsud256 ((__v8si) (W), (__v8si) (A), (__v8si) > (B)) > - > -#define _mm256_dpbsuds_epi32(W, A, B) \ > - (__m256i) __builtin_ia32_vpdpbsuds256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > - > -#define _mm256_dpbuud_epi32(W, A, B) \ > - (__m256i) __builtin_ia32_vpdpbuud256 ((__v8si) (W), (__v8si) (A), (__v8si) > (B)) > - > -#define _mm256_dpbuuds_epi32(W, A, B) \ > - (__m256i) __builtin_ia32_vpdpbuuds256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > - > -#define _mm_dpwsud_epi32(W, A, B) \ > - (__m128i) __builtin_ia32_vpdpwsud128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > - > -#define _mm_dpwsuds_epi32(W, A, B) \ > - (__m128i) __builtin_ia32_vpdpwsuds128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > - > -#define _mm_dpwusd_epi32(W, A, B) \ > - (__m128i) __builtin_ia32_vpdpwusd128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > - > -#define _mm_dpwusds_epi32(W, A, B) \ > - (__m128i) __builtin_ia32_vpdpwusds128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > - > -#define _mm_dpwuud_epi32(W, A, B) \ > - (__m128i) __builtin_ia32_vpdpwuud128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > - > -#define _mm_dpwuuds_epi32(W, A, B) \ > - (__m128i) __builtin_ia32_vpdpwuuds128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > - > -#define _mm256_dpwsud_epi32(W, A, B) \ > - (__m256i) __builtin_ia32_vpdpwsud256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > - > -#define _mm256_dpwsuds_epi32(W, A, B) \ > - (__m256i) __builtin_ia32_vpdpwsuds256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > - > -#define _mm256_dpwusd_epi32(W, A, B) \ > - (__m256i) __builtin_ia32_vpdpwusd256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > - > -#define _mm256_dpwusds_epi32(W, A, B) \ > - (__m256i) __builtin_ia32_vpdpwusds256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > - > -#define _mm256_dpwuud_epi32(W, A, B) \ > - (__m256i) __builtin_ia32_vpdpwuud256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > - > -#define _mm256_dpwuuds_epi32(W, A, B) \ > - (__m256i) __builtin_ia32_vpdpwuuds256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_dpbssd_epi32 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpbssd_v4si_mask ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_dpbssd_epi32 (__mmask8 __U, __m128i __W, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpbssd_v4si_maskz ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_dpbssds_epi32 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpbssds_v4si_mask ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_dpbssds_epi32 (__mmask8 __U, __m128i __W, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpbssds_v4si_maskz ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_dpbsud_epi32 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpbsud_v4si_mask ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_dpbsud_epi32 (__mmask8 __U, __m128i __W, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpbsud_v4si_maskz ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_dpbsuds_epi32 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpbsuds_v4si_mask ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_dpbsuds_epi32 (__mmask8 __U, __m128i __W, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpbsuds_v4si_maskz ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_dpbuud_epi32 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpbuud_v4si_mask ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_dpbuud_epi32 (__mmask8 __U, __m128i __W, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpbuud_v4si_maskz ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_dpbuuds_epi32 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpbuuds_v4si_mask ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_dpbuuds_epi32 (__mmask8 __U, __m128i __W, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpbuuds_v4si_maskz ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_dpbssd_epi32 (__m256i __W, __mmask8 __U, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpbssd_v8si_mask ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_dpbssd_epi32 (__mmask8 __U, __m256i __W, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpbssd_v8si_maskz ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_dpbssds_epi32 (__m256i __W, __mmask8 __U, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpbssds_v8si_mask ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_dpbssds_epi32 (__mmask8 __U, __m256i __W, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpbssds_v8si_maskz ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_dpbsud_epi32 (__m256i __W, __mmask8 __U, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpbsud_v8si_mask ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_dpbsud_epi32 (__mmask8 __U, __m256i __W, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpbsud_v8si_maskz ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_dpbsuds_epi32 (__m256i __W, __mmask8 __U, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpbsuds_v8si_mask ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_dpbsuds_epi32 (__mmask8 __U, __m256i __W, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpbsuds_v8si_maskz ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_dpbuud_epi32 (__m256i __W, __mmask8 __U, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpbuud_v8si_mask ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_dpbuud_epi32 (__mmask8 __U, __m256i __W, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpbuud_v8si_maskz ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_dpbuuds_epi32 (__m256i __W, __mmask8 __U, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpbuuds_v8si_mask ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_dpbuuds_epi32 (__mmask8 __U, __m256i __W, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpbuuds_v8si_maskz ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_dpbssd_epi32 (__m512i __W, __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbssd512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_dpbssd_epi32 (__m512i __W, __mmask16 __U, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbssd_v16si_mask ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_dpbssd_epi32 (__mmask16 __U, __m512i __W, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbssd_v16si_maskz ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_dpbssds_epi32 (__m512i __W, __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbssds512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_dpbssds_epi32 (__m512i __W, __mmask16 __U, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbssds_v16si_mask ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_dpbssds_epi32 (__mmask16 __U, __m512i __W, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbssds_v16si_maskz ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_dpbsud_epi32 (__m512i __W, __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbsud512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_dpbsud_epi32 (__m512i __W, __mmask16 __U, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbsud_v16si_mask ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_dpbsud_epi32 (__mmask16 __U, __m512i __W, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbsud_v16si_maskz ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_dpbsuds_epi32 (__m512i __W, __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbsuds512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_dpbsuds_epi32 (__m512i __W, __mmask16 __U, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbsuds_v16si_mask ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_dpbsuds_epi32 (__mmask16 __U, __m512i __W, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbsuds_v16si_maskz ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_dpbuud_epi32 (__m512i __W, __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbuud512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_dpbuud_epi32 (__m512i __W, __mmask16 __U, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbuud_v16si_mask ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_dpbuud_epi32 (__mmask16 __U, __m512i __W, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbuud_v16si_maskz ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_dpbuuds_epi32 (__m512i __W, __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbuuds512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_dpbuuds_epi32 (__m512i __W, __mmask16 __U, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbuuds_v16si_mask ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_dpbuuds_epi32 (__mmask16 __U, __m512i __W, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpbuuds_v16si_maskz ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_dpwsud_epi32 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpwsud_v4si_mask ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_dpwsud_epi32 (__mmask8 __U, __m128i __W, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpwsud_v4si_maskz ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_dpwsuds_epi32 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpwsuds_v4si_mask ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_dpwsuds_epi32 (__mmask8 __U, __m128i __W, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpwsuds_v4si_maskz ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_dpwusd_epi32 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpwusd_v4si_mask ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_dpwusd_epi32 (__mmask8 __U, __m128i __W, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpwusd_v4si_maskz ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_dpwusds_epi32 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpwusds_v4si_mask ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_dpwusds_epi32 (__mmask8 __U, __m128i __W, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpwusds_v4si_maskz ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_dpwuud_epi32 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpwuud_v4si_mask ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_dpwuud_epi32 (__mmask8 __U, __m128i __W, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpwuud_v4si_maskz ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_mask_dpwuuds_epi32 (__m128i __W, __mmask8 __U, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpwuuds_v4si_mask ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m128i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm_maskz_dpwuuds_epi32 (__mmask8 __U, __m128i __W, > - __m128i __A, __m128i __B) > -{ > - return (__m128i) > - __builtin_ia32_vpdpwuuds_v4si_maskz ((__v4si) __W, > - (__v4si) __A, > - (__v4si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_dpwsud_epi32 (__m256i __W, __mmask8 __U, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpwsud_v8si_mask ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_dpwsud_epi32 (__mmask8 __U, __m256i __W, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpwsud_v8si_maskz ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_dpwsuds_epi32 (__m256i __W, __mmask8 __U, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpwsuds_v8si_mask ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_dpwsuds_epi32 (__mmask8 __U, __m256i __W, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpwsuds_v8si_maskz ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_dpwusd_epi32 (__m256i __W, __mmask8 __U, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpwusd_v8si_mask ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_dpwusd_epi32 (__mmask8 __U, __m256i __W, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpwusd_v8si_maskz ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_dpwusds_epi32 (__m256i __W, __mmask8 __U, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpwusds_v8si_mask ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_dpwusds_epi32 (__mmask8 __U, __m256i __W, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpwusds_v8si_maskz ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_dpwuud_epi32 (__m256i __W, __mmask8 __U, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpwuud_v8si_mask ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_dpwuud_epi32 (__mmask8 __U, __m256i __W, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpwuud_v8si_maskz ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_mask_dpwuuds_epi32 (__m256i __W, __mmask8 __U, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpwuuds_v8si_mask ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m256i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm256_maskz_dpwuuds_epi32 (__mmask8 __U, __m256i __W, > - __m256i __A, __m256i __B) > -{ > - return (__m256i) > - __builtin_ia32_vpdpwuuds_v8si_maskz ((__v8si) __W, > - (__v8si) __A, > - (__v8si) __B, > - (__mmask8) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_dpwsud_epi32 (__m512i __W, __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwsud512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_dpwsud_epi32 (__m512i __W, __mmask16 __U, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwsud_v16si_mask ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_dpwsud_epi32 (__mmask16 __U, __m512i __W, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwsud_v16si_maskz ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_dpwsuds_epi32 (__m512i __W, __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwsuds512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_dpwsuds_epi32 (__m512i __W, __mmask16 __U, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwsuds_v16si_mask ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_dpwsuds_epi32 (__mmask16 __U, __m512i __W, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwsuds_v16si_maskz ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_dpwusd_epi32 (__m512i __W, __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwusd512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_dpwusd_epi32 (__m512i __W, __mmask16 __U, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwusd_v16si_mask ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_dpwusd_epi32 (__mmask16 __U, __m512i __W, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwusd_v16si_maskz ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_dpwusds_epi32 (__m512i __W, __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwusds512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_dpwusds_epi32 (__m512i __W, __mmask16 __U, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwusds_v16si_mask ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_dpwusds_epi32 (__mmask16 __U, __m512i __W, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwusds_v16si_maskz ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_dpwuud_epi32 (__m512i __W, __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwuud512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_dpwuud_epi32 (__m512i __W, __mmask16 __U, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwuud_v16si_mask ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_dpwuud_epi32 (__mmask16 __U, __m512i __W, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwuud_v16si_maskz ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_dpwuuds_epi32 (__m512i __W, __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwuuds512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_mask_dpwuuds_epi32 (__m512i __W, __mmask16 __U, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwuuds_v16si_mask ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > -extern __inline __m512i > -__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > -_mm512_maskz_dpwuuds_epi32 (__mmask16 __U, __m512i __W, > - __m512i __A, __m512i __B) > -{ > - return (__m512i) > - __builtin_ia32_vpdpwuuds_v16si_maskz ((__v16si) __W, > - (__v16si) __A, > - (__v16si) __B, > - (__mmask16) __U); > -} > - > extern __inline __m512 > __attribute__((__gnu_inline__, __always_inline__, __artificial__)) > _mm512_dpph_ps (__m512 __W, __m512h __A, __m512h __B) > diff --git a/gcc/config/i386/avx10v1auxintrin.h > b/gcc/config/i386/avx10v1auxintrin.h > index 9929e926ba07..61bf6c02e60e 100644 > --- a/gcc/config/i386/avx10v1auxintrin.h > +++ b/gcc/config/i386/avx10v1auxintrin.h > @@ -1419,6 +1419,1038 @@ _mm512_maskz_cvtx_round2ps_ph > (__mmask32 __U, __m512 __A, > (R))) > #endif /* __OPTIMIZE__ */ > > +#define _mm_dpbssd_epi32(W, A, B) \ > + (__m128i) __builtin_ia32_vpdpbssd128 ((__v4si) (W), (__v4si) (A), (__v4si) > (B)) > + > +#define _mm_dpbssds_epi32(W, A, B) \ > + (__m128i) __builtin_ia32_vpdpbssds128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > + > +#define _mm_dpbsud_epi32(W, A, B) \ > + (__m128i) __builtin_ia32_vpdpbsud128 ((__v4si) (W), (__v4si) (A), (__v4si) > (B)) > + > +#define _mm_dpbsuds_epi32(W, A, B) \ > + (__m128i) __builtin_ia32_vpdpbsuds128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > + > +#define _mm_dpbuud_epi32(W, A, B) \ > + (__m128i) __builtin_ia32_vpdpbuud128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > + > +#define _mm_dpbuuds_epi32(W, A, B) \ > + (__m128i) __builtin_ia32_vpdpbuuds128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > + > +#define _mm256_dpbssd_epi32(W, A, B) \ > + (__m256i) __builtin_ia32_vpdpbssd256 ((__v8si) (W), (__v8si) (A), (__v8si) > (B)) > + > +#define _mm256_dpbssds_epi32(W, A, B) \ > + (__m256i) __builtin_ia32_vpdpbssds256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > + > +#define _mm256_dpbsud_epi32(W, A, B) \ > + (__m256i) __builtin_ia32_vpdpbsud256 ((__v8si) (W), (__v8si) (A), (__v8si) > (B)) > + > +#define _mm256_dpbsuds_epi32(W, A, B) \ > + (__m256i) __builtin_ia32_vpdpbsuds256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > + > +#define _mm256_dpbuud_epi32(W, A, B) \ > + (__m256i) __builtin_ia32_vpdpbuud256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > + > +#define _mm256_dpbuuds_epi32(W, A, B) \ > + (__m256i) __builtin_ia32_vpdpbuuds256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > + > +#define _mm_dpwsud_epi32(W, A, B) \ > + (__m128i) __builtin_ia32_vpdpwsud128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > + > +#define _mm_dpwsuds_epi32(W, A, B) \ > + (__m128i) __builtin_ia32_vpdpwsuds128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > + > +#define _mm_dpwusd_epi32(W, A, B) \ > + (__m128i) __builtin_ia32_vpdpwusd128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > + > +#define _mm_dpwusds_epi32(W, A, B) \ > + (__m128i) __builtin_ia32_vpdpwusds128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > + > +#define _mm_dpwuud_epi32(W, A, B) \ > + (__m128i) __builtin_ia32_vpdpwuud128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > + > +#define _mm_dpwuuds_epi32(W, A, B) \ > + (__m128i) __builtin_ia32_vpdpwuuds128 ((__v4si) (W), (__v4si) (A), > (__v4si) (B)) > + > +#define _mm256_dpwsud_epi32(W, A, B) \ > + (__m256i) __builtin_ia32_vpdpwsud256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > + > +#define _mm256_dpwsuds_epi32(W, A, B) \ > + (__m256i) __builtin_ia32_vpdpwsuds256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > + > +#define _mm256_dpwusd_epi32(W, A, B) \ > + (__m256i) __builtin_ia32_vpdpwusd256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > + > +#define _mm256_dpwusds_epi32(W, A, B) \ > + (__m256i) __builtin_ia32_vpdpwusds256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > + > +#define _mm256_dpwuud_epi32(W, A, B) \ > + (__m256i) __builtin_ia32_vpdpwuud256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > + > +#define _mm256_dpwuuds_epi32(W, A, B) \ > + (__m256i) __builtin_ia32_vpdpwuuds256 ((__v8si) (W), (__v8si) (A), > (__v8si) (B)) > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_dpbssd_epi32 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpbssd_v4si_mask ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_dpbssd_epi32 (__mmask8 __U, __m128i __W, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpbssd_v4si_maskz ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_dpbssds_epi32 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpbssds_v4si_mask ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_dpbssds_epi32 (__mmask8 __U, __m128i __W, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpbssds_v4si_maskz ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_dpbsud_epi32 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpbsud_v4si_mask ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_dpbsud_epi32 (__mmask8 __U, __m128i __W, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpbsud_v4si_maskz ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_dpbsuds_epi32 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpbsuds_v4si_mask ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_dpbsuds_epi32 (__mmask8 __U, __m128i __W, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpbsuds_v4si_maskz ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_dpbuud_epi32 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpbuud_v4si_mask ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_dpbuud_epi32 (__mmask8 __U, __m128i __W, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpbuud_v4si_maskz ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_dpbuuds_epi32 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpbuuds_v4si_mask ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_dpbuuds_epi32 (__mmask8 __U, __m128i __W, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpbuuds_v4si_maskz ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_dpbssd_epi32 (__m256i __W, __mmask8 __U, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpbssd_v8si_mask ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_dpbssd_epi32 (__mmask8 __U, __m256i __W, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpbssd_v8si_maskz ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_dpbssds_epi32 (__m256i __W, __mmask8 __U, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpbssds_v8si_mask ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_dpbssds_epi32 (__mmask8 __U, __m256i __W, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpbssds_v8si_maskz ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_dpbsud_epi32 (__m256i __W, __mmask8 __U, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpbsud_v8si_mask ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_dpbsud_epi32 (__mmask8 __U, __m256i __W, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpbsud_v8si_maskz ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_dpbsuds_epi32 (__m256i __W, __mmask8 __U, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpbsuds_v8si_mask ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_dpbsuds_epi32 (__mmask8 __U, __m256i __W, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpbsuds_v8si_maskz ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_dpbuud_epi32 (__m256i __W, __mmask8 __U, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpbuud_v8si_mask ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_dpbuud_epi32 (__mmask8 __U, __m256i __W, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpbuud_v8si_maskz ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_dpbuuds_epi32 (__m256i __W, __mmask8 __U, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpbuuds_v8si_mask ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_dpbuuds_epi32 (__mmask8 __U, __m256i __W, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpbuuds_v8si_maskz ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_dpbssd_epi32 (__m512i __W, __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbssd512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_dpbssd_epi32 (__m512i __W, __mmask16 __U, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbssd_v16si_mask ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_dpbssd_epi32 (__mmask16 __U, __m512i __W, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbssd_v16si_maskz ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_dpbssds_epi32 (__m512i __W, __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbssds512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_dpbssds_epi32 (__m512i __W, __mmask16 __U, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbssds_v16si_mask ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_dpbssds_epi32 (__mmask16 __U, __m512i __W, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbssds_v16si_maskz ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_dpbsud_epi32 (__m512i __W, __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbsud512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_dpbsud_epi32 (__m512i __W, __mmask16 __U, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbsud_v16si_mask ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_dpbsud_epi32 (__mmask16 __U, __m512i __W, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbsud_v16si_maskz ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_dpbsuds_epi32 (__m512i __W, __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbsuds512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_dpbsuds_epi32 (__m512i __W, __mmask16 __U, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbsuds_v16si_mask ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_dpbsuds_epi32 (__mmask16 __U, __m512i __W, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbsuds_v16si_maskz ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_dpbuud_epi32 (__m512i __W, __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbuud512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_dpbuud_epi32 (__m512i __W, __mmask16 __U, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbuud_v16si_mask ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_dpbuud_epi32 (__mmask16 __U, __m512i __W, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbuud_v16si_maskz ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_dpbuuds_epi32 (__m512i __W, __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbuuds512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_dpbuuds_epi32 (__m512i __W, __mmask16 __U, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbuuds_v16si_mask ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_dpbuuds_epi32 (__mmask16 __U, __m512i __W, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpbuuds_v16si_maskz ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_dpwsud_epi32 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpwsud_v4si_mask ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_dpwsud_epi32 (__mmask8 __U, __m128i __W, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpwsud_v4si_maskz ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_dpwsuds_epi32 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpwsuds_v4si_mask ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_dpwsuds_epi32 (__mmask8 __U, __m128i __W, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpwsuds_v4si_maskz ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_dpwusd_epi32 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpwusd_v4si_mask ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_dpwusd_epi32 (__mmask8 __U, __m128i __W, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpwusd_v4si_maskz ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_dpwusds_epi32 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpwusds_v4si_mask ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_dpwusds_epi32 (__mmask8 __U, __m128i __W, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpwusds_v4si_maskz ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_dpwuud_epi32 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpwuud_v4si_mask ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_dpwuud_epi32 (__mmask8 __U, __m128i __W, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpwuud_v4si_maskz ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_mask_dpwuuds_epi32 (__m128i __W, __mmask8 __U, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpwuuds_v4si_mask ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m128i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm_maskz_dpwuuds_epi32 (__mmask8 __U, __m128i __W, > + __m128i __A, __m128i __B) > +{ > + return (__m128i) > + __builtin_ia32_vpdpwuuds_v4si_maskz ((__v4si) __W, > + (__v4si) __A, > + (__v4si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_dpwsud_epi32 (__m256i __W, __mmask8 __U, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpwsud_v8si_mask ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_dpwsud_epi32 (__mmask8 __U, __m256i __W, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpwsud_v8si_maskz ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_dpwsuds_epi32 (__m256i __W, __mmask8 __U, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpwsuds_v8si_mask ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_dpwsuds_epi32 (__mmask8 __U, __m256i __W, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpwsuds_v8si_maskz ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_dpwusd_epi32 (__m256i __W, __mmask8 __U, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpwusd_v8si_mask ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_dpwusd_epi32 (__mmask8 __U, __m256i __W, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpwusd_v8si_maskz ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_dpwusds_epi32 (__m256i __W, __mmask8 __U, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpwusds_v8si_mask ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_dpwusds_epi32 (__mmask8 __U, __m256i __W, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpwusds_v8si_maskz ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_dpwuud_epi32 (__m256i __W, __mmask8 __U, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpwuud_v8si_mask ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_dpwuud_epi32 (__mmask8 __U, __m256i __W, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpwuud_v8si_maskz ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_mask_dpwuuds_epi32 (__m256i __W, __mmask8 __U, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpwuuds_v8si_mask ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m256i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm256_maskz_dpwuuds_epi32 (__mmask8 __U, __m256i __W, > + __m256i __A, __m256i __B) > +{ > + return (__m256i) > + __builtin_ia32_vpdpwuuds_v8si_maskz ((__v8si) __W, > + (__v8si) __A, > + (__v8si) __B, > + (__mmask8) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_dpwsud_epi32 (__m512i __W, __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwsud512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_dpwsud_epi32 (__m512i __W, __mmask16 __U, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwsud_v16si_mask ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_dpwsud_epi32 (__mmask16 __U, __m512i __W, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwsud_v16si_maskz ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_dpwsuds_epi32 (__m512i __W, __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwsuds512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_dpwsuds_epi32 (__m512i __W, __mmask16 __U, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwsuds_v16si_mask ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_dpwsuds_epi32 (__mmask16 __U, __m512i __W, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwsuds_v16si_maskz ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_dpwusd_epi32 (__m512i __W, __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwusd512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_dpwusd_epi32 (__m512i __W, __mmask16 __U, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwusd_v16si_mask ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_dpwusd_epi32 (__mmask16 __U, __m512i __W, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwusd_v16si_maskz ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_dpwusds_epi32 (__m512i __W, __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwusds512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_dpwusds_epi32 (__m512i __W, __mmask16 __U, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwusds_v16si_mask ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_dpwusds_epi32 (__mmask16 __U, __m512i __W, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwusds_v16si_maskz ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_dpwuud_epi32 (__m512i __W, __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwuud512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_dpwuud_epi32 (__m512i __W, __mmask16 __U, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwuud_v16si_mask ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_dpwuud_epi32 (__mmask16 __U, __m512i __W, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwuud_v16si_maskz ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_dpwuuds_epi32 (__m512i __W, __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwuuds512 ((__v16si) __W, (__v16si) __A, (__v16si) > __B); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_mask_dpwuuds_epi32 (__m512i __W, __mmask16 __U, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwuuds_v16si_mask ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > +extern __inline __m512i > +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) > +_mm512_maskz_dpwuuds_epi32 (__mmask16 __U, __m512i __W, > + __m512i __A, __m512i __B) > +{ > + return (__m512i) > + __builtin_ia32_vpdpwuuds_v16si_maskz ((__v16si) __W, > + (__v16si) __A, > + (__v16si) __B, > + (__mmask16) __U); > +} > + > #ifdef __DISABLE_AVX10V1AUX__ > #undef __DISABLE_AVX10V1AUX__ > #pragma GCC pop_options > diff --git a/gcc/config/i386/i386-builtin.def b/gcc/config/i386/i386- > builtin.def > index fc8475b3e6a7..6afae026040e 100644 > --- a/gcc/config/i386/i386-builtin.def > +++ b/gcc/config/i386/i386-builtin.def > @@ -2773,32 +2773,32 @@ BDESC (OPTION_MASK_ISA_AVX512VNNI | > OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_vpdpws > BDESC (OPTION_MASK_ISA_AVX512VNNI | OPTION_MASK_ISA_AVX512VL, > 0, CODE_FOR_vpdpwssds_v4si_maskz, > "__builtin_ia32_vpdpwssds_v4si_maskz", > IX86_BUILTIN_VPDPWSSDSV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > > /* AVXVNNIINT8 */ > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssd_v8si, > "__builtin_ia32_vpdpbssd256", IX86_BUILTIN_VPDPBSSDV8SI, UNKNOWN, > (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssds_v8si, > "__builtin_ia32_vpdpbssds256", IX86_BUILTIN_VPDPBSSDSV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsud_v8si, > "__builtin_ia32_vpdpbsud256", IX86_BUILTIN_VPDPBSUDV8SI, UNKNOWN, > (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsuds_v8si, > "__builtin_ia32_vpdpbsuds256", IX86_BUILTIN_VPDPBSUDSV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuud_v8si, > "__builtin_ia32_vpdpbuud256", IX86_BUILTIN_VPDPBUUDV8SI, UNKNOWN, > (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuuds_v8si, > "__builtin_ia32_vpdpbuuds256", IX86_BUILTIN_VPDPBUUDSV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssd_v4si, > "__builtin_ia32_vpdpbssd128", IX86_BUILTIN_VPDPBSSDV4SI, UNKNOWN, > (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssds_v4si, > "__builtin_ia32_vpdpbssds128", IX86_BUILTIN_VPDPBSSDSV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsud_v4si, > "__builtin_ia32_vpdpbsud128", IX86_BUILTIN_VPDPBSUDV4SI, UNKNOWN, > (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsuds_v4si, > "__builtin_ia32_vpdpbsuds128", IX86_BUILTIN_VPDPBSUDSV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuud_v4si, > "__builtin_ia32_vpdpbuud128", IX86_BUILTIN_VPDPBUUDV4SI, UNKNOWN, > (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuuds_v4si, > "__builtin_ia32_vpdpbuuds128", IX86_BUILTIN_VPDPBUUDSV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssd_v8si, > "__builtin_ia32_vpdpbssd256", IX86_BUILTIN_VPDPBSSDV8SI, UNKNOWN, > (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssds_v8si, > "__builtin_ia32_vpdpbssds256", IX86_BUILTIN_VPDPBSSDSV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsud_v8si, > "__builtin_ia32_vpdpbsud256", IX86_BUILTIN_VPDPBSUDV8SI, UNKNOWN, > (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsuds_v8si, > "__builtin_ia32_vpdpbsuds256", IX86_BUILTIN_VPDPBSUDSV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuud_v8si, > "__builtin_ia32_vpdpbuud256", IX86_BUILTIN_VPDPBUUDV8SI, UNKNOWN, > (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuuds_v8si, > "__builtin_ia32_vpdpbuuds256", IX86_BUILTIN_VPDPBUUDSV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssd_v4si, > "__builtin_ia32_vpdpbssd128", IX86_BUILTIN_VPDPBSSDV4SI, UNKNOWN, > (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssds_v4si, > "__builtin_ia32_vpdpbssds128", IX86_BUILTIN_VPDPBSSDSV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsud_v4si, > "__builtin_ia32_vpdpbsud128", IX86_BUILTIN_VPDPBSUDV4SI, UNKNOWN, > (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbsuds_v4si, > "__builtin_ia32_vpdpbsuds128", IX86_BUILTIN_VPDPBSUDSV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuud_v4si, > "__builtin_ia32_vpdpbuud128", IX86_BUILTIN_VPDPBUUDV4SI, UNKNOWN, > (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT8 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbuuds_v4si, > "__builtin_ia32_vpdpbuuds128", IX86_BUILTIN_VPDPBUUDSV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > > /* AVXVNNIINT16 */ > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusd_v8si, > "__builtin_ia32_vpdpwusd256", IX86_BUILTIN_VPDPWUSDV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusds_v8si, > "__builtin_ia32_vpdpwusds256", IX86_BUILTIN_VPDPWUSDSV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsud_v8si, > "__builtin_ia32_vpdpwsud256", IX86_BUILTIN_VPDPWSUDV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsuds_v8si, > "__builtin_ia32_vpdpwsuds256", IX86_BUILTIN_VPDPWSUDSV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuud_v8si, > "__builtin_ia32_vpdpwuud256", IX86_BUILTIN_VPDPWUUDV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuuds_v8si, > "__builtin_ia32_vpdpwuuds256", IX86_BUILTIN_VPDPWUUDSV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusd_v4si, > "__builtin_ia32_vpdpwusd128", IX86_BUILTIN_VPDPWUSDV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusds_v4si, > "__builtin_ia32_vpdpwusds128", IX86_BUILTIN_VPDPWUSDSV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsud_v4si, > "__builtin_ia32_vpdpwsud128", IX86_BUILTIN_VPDPWSUDV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsuds_v4si, > "__builtin_ia32_vpdpwsuds128", IX86_BUILTIN_VPDPWSUDSV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuud_v4si, > "__builtin_ia32_vpdpwuud128", IX86_BUILTIN_VPDPWUUDV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > -BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuuds_v4si, > "__builtin_ia32_vpdpwuuds128", IX86_BUILTIN_VPDPWUUDSV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusd_v8si, > "__builtin_ia32_vpdpwusd256", IX86_BUILTIN_VPDPWUSDV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusds_v8si, > "__builtin_ia32_vpdpwusds256", IX86_BUILTIN_VPDPWUSDSV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsud_v8si, > "__builtin_ia32_vpdpwsud256", IX86_BUILTIN_VPDPWSUDV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsuds_v8si, > "__builtin_ia32_vpdpwsuds256", IX86_BUILTIN_VPDPWSUDSV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuud_v8si, > "__builtin_ia32_vpdpwuud256", IX86_BUILTIN_VPDPWUUDV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuuds_v8si, > "__builtin_ia32_vpdpwuuds256", IX86_BUILTIN_VPDPWUUDSV8SI, > UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_V8SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusd_v4si, > "__builtin_ia32_vpdpwusd128", IX86_BUILTIN_VPDPWUSDV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwusds_v4si, > "__builtin_ia32_vpdpwusds128", IX86_BUILTIN_VPDPWUSDSV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsud_v4si, > "__builtin_ia32_vpdpwsud128", IX86_BUILTIN_VPDPWSUDV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwsuds_v4si, > "__builtin_ia32_vpdpwsuds128", IX86_BUILTIN_VPDPWSUDSV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuud_v4si, > "__builtin_ia32_vpdpwuud128", IX86_BUILTIN_VPDPWUUDV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > +BDESC (0, OPTION_MASK_ISA2_AVXVNNIINT16 | > OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpwuuds_v4si, > "__builtin_ia32_vpdpwuuds128", IX86_BUILTIN_VPDPWUUDSV4SI, > UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI_V4SI) > > /* VPCLMULQDQ */ > BDESC (OPTION_MASK_ISA_VPCLMULQDQ | > OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_vpclmulqdq_v2di, > "__builtin_ia32_vpclmulqdq_v2di", IX86_BUILTIN_VPCLMULQDQ2, > UNKNOWN, (int) V2DI_FTYPE_V2DI_V2DI_INT) > @@ -3054,90 +3054,90 @@ BDESC (OPTION_MASK_ISA_AVX512VL, > OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512vl_ > BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, > CODE_FOR_avx512vl_fmulc_v16hf_mask, > "__builtin_ia32_vfmulcph256_mask", IX86_BUILTIN_VFMULCPH256_MASK, > UNKNOWN, (int) V16HF_FTYPE_V16HF_V16HF_V16HF_UQI) > > /* AVX10.2. */ > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssd_v16si, > "__builtin_ia32_vpdpbssd512", IX86_BUILTIN_VPDPBSSDV16SI, UNKNOWN, > (int) V16SI_FTYPE_V16SI_V16SI_V16SI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbssds_v16si, > "__builtin_ia32_vpdpbssds512", IX86_BUILTIN_VPDPBSSDSV16SI, > UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsud_v16si, > "__builtin_ia32_vpdpbsud512", IX86_BUILTIN_VPDPBSUDV16SI, > UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbsuds_v16si, > "__builtin_ia32_vpdpbsuds512", IX86_BUILTIN_VPDPBSUDSV16SI, > UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuud_v16si, > "__builtin_ia32_vpdpbuud512", IX86_BUILTIN_VPDPBUUDV16SI, > UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpbuuds_v16si, > "__builtin_ia32_vpdpbuuds512", IX86_BUILTIN_VPDPBUUDSV16SI, > UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbssd_v16si_mask, "__builtin_ia32_vpdpbssd_v16si_mask", > IX86_BUILTIN_VPDPBSSDV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbssd_v16si_maskz, > "__builtin_ia32_vpdpbssd_v16si_maskz", > IX86_BUILTIN_VPDPBSSDV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbssds_v16si_mask, > "__builtin_ia32_vpdpbssds_v16si_mask", > IX86_BUILTIN_VPDPBSSDSV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbssds_v16si_maskz, > "__builtin_ia32_vpdpbssds_v16si_maskz", > IX86_BUILTIN_VPDPBSSDSV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbsud_v16si_mask, "__builtin_ia32_vpdpbsud_v16si_mask", > IX86_BUILTIN_VPDPBSUDV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbsud_v16si_maskz, > "__builtin_ia32_vpdpbsud_v16si_maskz", > IX86_BUILTIN_VPDPBSUDV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbsuds_v16si_mask, > "__builtin_ia32_vpdpbsuds_v16si_mask", > IX86_BUILTIN_VPDPBSUDSV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbsuds_v16si_maskz, > "__builtin_ia32_vpdpbsuds_v16si_maskz", > IX86_BUILTIN_VPDPBSUDSV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbuud_v16si_mask, "__builtin_ia32_vpdpbuud_v16si_mask", > IX86_BUILTIN_VPDPBUUDV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbuud_v16si_maskz, > "__builtin_ia32_vpdpbuud_v16si_maskz", > IX86_BUILTIN_VPDPBUUDV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbuuds_v16si_mask, > "__builtin_ia32_vpdpbuuds_v16si_mask", > IX86_BUILTIN_VPDPBUUDSV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbuuds_v16si_maskz, > "__builtin_ia32_vpdpbuuds_v16si_maskz", > IX86_BUILTIN_VPDPBUUDSV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbssd_v8si_mask, "__builtin_ia32_vpdpbssd_v8si_mask", > IX86_BUILTIN_VPDPBSSDV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbssd_v8si_maskz, "__builtin_ia32_vpdpbssd_v8si_maskz", > IX86_BUILTIN_VPDPBSSDV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbssds_v8si_mask, "__builtin_ia32_vpdpbssds_v8si_mask", > IX86_BUILTIN_VPDPBSSDSV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbssds_v8si_maskz, "__builtin_ia32_vpdpbssds_v8si_maskz", > IX86_BUILTIN_VPDPBSSDSV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbsud_v8si_mask, "__builtin_ia32_vpdpbsud_v8si_mask", > IX86_BUILTIN_VPDPBSUDV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbsud_v8si_maskz, "__builtin_ia32_vpdpbsud_v8si_maskz", > IX86_BUILTIN_VPDPBSUDV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbsuds_v8si_mask, "__builtin_ia32_vpdpbsuds_v8si_mask", > IX86_BUILTIN_VPDPBSUDSV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbsuds_v8si_maskz, > "__builtin_ia32_vpdpbsuds_v8si_maskz", > IX86_BUILTIN_VPDPBSUDSV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbuud_v8si_mask, "__builtin_ia32_vpdpbuud_v8si_mask", > IX86_BUILTIN_VPDPBUUDV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbuud_v8si_maskz, "__builtin_ia32_vpdpbuud_v8si_maskz", > IX86_BUILTIN_VPDPBUUDV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbuuds_v8si_mask, "__builtin_ia32_vpdpbuuds_v8si_mask", > IX86_BUILTIN_VPDPBUUDSV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbuuds_v8si_maskz, > "__builtin_ia32_vpdpbuuds_v8si_maskz", > IX86_BUILTIN_VPDPBUUDSV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbssd_v4si_mask, "__builtin_ia32_vpdpbssd_v4si_mask", > IX86_BUILTIN_VPDPBSSDV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbssd_v4si_maskz, "__builtin_ia32_vpdpbssd_v4si_maskz", > IX86_BUILTIN_VPDPBSSDV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbssds_v4si_mask, "__builtin_ia32_vpdpbssds_v4si_mask", > IX86_BUILTIN_VPDPBSSDSV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbssds_v4si_maskz, "__builtin_ia32_vpdpbssds_v4si_maskz", > IX86_BUILTIN_VPDPBSSDSV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbsud_v4si_mask, "__builtin_ia32_vpdpbsud_v4si_mask", > IX86_BUILTIN_VPDPBSUDV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbsud_v4si_maskz, "__builtin_ia32_vpdpbsud_v4si_maskz", > IX86_BUILTIN_VPDPBSUDV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbsuds_v4si_mask, "__builtin_ia32_vpdpbsuds_v4si_mask", > IX86_BUILTIN_VPDPBSUDSV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbsuds_v4si_maskz, > "__builtin_ia32_vpdpbsuds_v4si_maskz", > IX86_BUILTIN_VPDPBSUDSV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbuud_v4si_mask, "__builtin_ia32_vpdpbuud_v4si_mask", > IX86_BUILTIN_VPDPBUUDV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbuud_v4si_maskz, "__builtin_ia32_vpdpbuud_v4si_maskz", > IX86_BUILTIN_VPDPBUUDV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbuuds_v4si_mask, "__builtin_ia32_vpdpbuuds_v4si_mask", > IX86_BUILTIN_VPDPBUUDSV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpbuuds_v4si_maskz, > "__builtin_ia32_vpdpbuuds_v4si_maskz", > IX86_BUILTIN_VPDPBUUDSV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsud_v16si, > "__builtin_ia32_vpdpwsud512", IX86_BUILTIN_VPDPWSUDV16SI, > UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwsuds_v16si, > "__builtin_ia32_vpdpwsuds512", IX86_BUILTIN_VPDPWSUDSV16SI, > UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusd_v16si, > "__builtin_ia32_vpdpwusd512", IX86_BUILTIN_VPDPWUSDV16SI, > UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwusds_v16si, > "__builtin_ia32_vpdpwusds512", IX86_BUILTIN_VPDPWUSDSV16SI, > UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuud_v16si, > "__builtin_ia32_vpdpwuud512", IX86_BUILTIN_VPDPWUUDV16SI, > UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vpdpwuuds_v16si, > "__builtin_ia32_vpdpwuuds512", IX86_BUILTIN_VPDPWUUDSV16SI, > UNKNOWN, (int) V16SI_FTYPE_V16SI_V16SI_V16SI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwsud_v16si_mask, > "__builtin_ia32_vpdpwsud_v16si_mask", > IX86_BUILTIN_VPDPWSUDV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwsud_v16si_maskz, > "__builtin_ia32_vpdpwsud_v16si_maskz", > IX86_BUILTIN_VPDPWSUDV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwsuds_v16si_mask, > "__builtin_ia32_vpdpwsuds_v16si_mask", > IX86_BUILTIN_VPDPWSUDSV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwsuds_v16si_maskz, > "__builtin_ia32_vpdpwsuds_v16si_maskz", > IX86_BUILTIN_VPDPWSUDSV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwusd_v16si_mask, > "__builtin_ia32_vpdpwusd_v16si_mask", > IX86_BUILTIN_VPDPWUSDV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwusd_v16si_maskz, > "__builtin_ia32_vpdpwusd_v16si_maskz", > IX86_BUILTIN_VPDPWUSDV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwusds_v16si_mask, > "__builtin_ia32_vpdpwusds_v16si_mask", > IX86_BUILTIN_VPDPWUSDSV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwusds_v16si_maskz, > "__builtin_ia32_vpdpwusds_v16si_maskz", > IX86_BUILTIN_VPDPWUSDSV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwuud_v16si_mask, > "__builtin_ia32_vpdpwuud_v16si_mask", > IX86_BUILTIN_VPDPWUUDV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwuud_v16si_maskz, > "__builtin_ia32_vpdpwuud_v16si_maskz", > IX86_BUILTIN_VPDPWUUDV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwuuds_v16si_mask, > "__builtin_ia32_vpdpwuuds_v16si_mask", > IX86_BUILTIN_VPDPWUUDSV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwuuds_v16si_maskz, > "__builtin_ia32_vpdpwuuds_v16si_maskz", > IX86_BUILTIN_VPDPWUUDSV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwsud_v8si_mask, "__builtin_ia32_vpdpwsud_v8si_mask", > IX86_BUILTIN_VPDPWSUDV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwsud_v8si_maskz, "__builtin_ia32_vpdpwsud_v8si_maskz", > IX86_BUILTIN_VPDPWSUDV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwsuds_v8si_mask, "__builtin_ia32_vpdpwsuds_v8si_mask", > IX86_BUILTIN_VPDPWSUDSV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwsuds_v8si_maskz, > "__builtin_ia32_vpdpwsuds_v8si_maskz", > IX86_BUILTIN_VPDPWSUDSV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwusd_v8si_mask, "__builtin_ia32_vpdpwusd_v8si_mask", > IX86_BUILTIN_VPDPWUSDV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwusd_v8si_maskz, "__builtin_ia32_vpdpwusd_v8si_maskz", > IX86_BUILTIN_VPDPWUSDV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwusds_v8si_mask, "__builtin_ia32_vpdpwusds_v8si_mask", > IX86_BUILTIN_VPDPWUSDSV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwusds_v8si_maskz, > "__builtin_ia32_vpdpwusds_v8si_maskz", > IX86_BUILTIN_VPDPWUSDSV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwuud_v8si_mask, "__builtin_ia32_vpdpwuud_v8si_mask", > IX86_BUILTIN_VPDPWUUDV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwuud_v8si_maskz, > "__builtin_ia32_vpdpwuud_v8si_maskz", > IX86_BUILTIN_VPDPWUUDV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwuuds_v8si_mask, > "__builtin_ia32_vpdpwuuds_v8si_mask", > IX86_BUILTIN_VPDPWUUDSV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwuuds_v8si_maskz, > "__builtin_ia32_vpdpwuuds_v8si_maskz", > IX86_BUILTIN_VPDPWUUDSV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwsud_v4si_mask, "__builtin_ia32_vpdpwsud_v4si_mask", > IX86_BUILTIN_VPDPWSUDV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwsud_v4si_maskz, "__builtin_ia32_vpdpwsud_v4si_maskz", > IX86_BUILTIN_VPDPWSUDV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwsuds_v4si_mask, "__builtin_ia32_vpdpwsuds_v4si_mask", > IX86_BUILTIN_VPDPWSUDSV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwsuds_v4si_maskz, > "__builtin_ia32_vpdpwsuds_v4si_maskz", > IX86_BUILTIN_VPDPWSUDSV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwusd_v4si_mask, "__builtin_ia32_vpdpwusd_v4si_mask", > IX86_BUILTIN_VPDPWUSDV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwusd_v4si_maskz, "__builtin_ia32_vpdpwusd_v4si_maskz", > IX86_BUILTIN_VPDPWUSDV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwusds_v4si_mask, "__builtin_ia32_vpdpwusds_v4si_mask", > IX86_BUILTIN_VPDPWUSDSV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwusds_v4si_maskz, > "__builtin_ia32_vpdpwusds_v4si_maskz", > IX86_BUILTIN_VPDPWUSDSV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwuud_v4si_mask, "__builtin_ia32_vpdpwuud_v4si_mask", > IX86_BUILTIN_VPDPWUUDV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwuud_v4si_maskz, > "__builtin_ia32_vpdpwuud_v4si_maskz", > IX86_BUILTIN_VPDPWUUDV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwuuds_v4si_mask, > "__builtin_ia32_vpdpwuuds_v4si_mask", > IX86_BUILTIN_VPDPWUUDSV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > -BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vpdpwuuds_v4si_maskz, > "__builtin_ia32_vpdpwuuds_v4si_maskz", > IX86_BUILTIN_VPDPWUUDSV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, CODE_FOR_vpdpbssd_v16si, > "__builtin_ia32_vpdpbssd512", IX86_BUILTIN_VPDPBSSDV16SI, UNKNOWN, > (int) V16SI_FTYPE_V16SI_V16SI_V16SI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbssds_v16si, "__builtin_ia32_vpdpbssds512", > IX86_BUILTIN_VPDPBSSDSV16SI, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsud_v16si, "__builtin_ia32_vpdpbsud512", > IX86_BUILTIN_VPDPBSUDV16SI, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsuds_v16si, "__builtin_ia32_vpdpbsuds512", > IX86_BUILTIN_VPDPBSUDSV16SI, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuud_v16si, "__builtin_ia32_vpdpbuud512", > IX86_BUILTIN_VPDPBUUDV16SI, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuuds_v16si, "__builtin_ia32_vpdpbuuds512", > IX86_BUILTIN_VPDPBUUDSV16SI, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbssd_v16si_mask, "__builtin_ia32_vpdpbssd_v16si_mask", > IX86_BUILTIN_VPDPBSSDV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbssd_v16si_maskz, > "__builtin_ia32_vpdpbssd_v16si_maskz", > IX86_BUILTIN_VPDPBSSDV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbssds_v16si_mask, > "__builtin_ia32_vpdpbssds_v16si_mask", > IX86_BUILTIN_VPDPBSSDSV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbssds_v16si_maskz, > "__builtin_ia32_vpdpbssds_v16si_maskz", > IX86_BUILTIN_VPDPBSSDSV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsud_v16si_mask, "__builtin_ia32_vpdpbsud_v16si_mask", > IX86_BUILTIN_VPDPBSUDV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsud_v16si_maskz, > "__builtin_ia32_vpdpbsud_v16si_maskz", > IX86_BUILTIN_VPDPBSUDV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsuds_v16si_mask, > "__builtin_ia32_vpdpbsuds_v16si_mask", > IX86_BUILTIN_VPDPBSUDSV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsuds_v16si_maskz, > "__builtin_ia32_vpdpbsuds_v16si_maskz", > IX86_BUILTIN_VPDPBSUDSV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuud_v16si_mask, "__builtin_ia32_vpdpbuud_v16si_mask", > IX86_BUILTIN_VPDPBUUDV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuud_v16si_maskz, > "__builtin_ia32_vpdpbuud_v16si_maskz", > IX86_BUILTIN_VPDPBUUDV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuuds_v16si_mask, > "__builtin_ia32_vpdpbuuds_v16si_mask", > IX86_BUILTIN_VPDPBUUDSV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuuds_v16si_maskz, > "__builtin_ia32_vpdpbuuds_v16si_maskz", > IX86_BUILTIN_VPDPBUUDSV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbssd_v8si_mask, "__builtin_ia32_vpdpbssd_v8si_mask", > IX86_BUILTIN_VPDPBSSDV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbssd_v8si_maskz, "__builtin_ia32_vpdpbssd_v8si_maskz", > IX86_BUILTIN_VPDPBSSDV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbssds_v8si_mask, "__builtin_ia32_vpdpbssds_v8si_mask", > IX86_BUILTIN_VPDPBSSDSV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbssds_v8si_maskz, "__builtin_ia32_vpdpbssds_v8si_maskz", > IX86_BUILTIN_VPDPBSSDSV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsud_v8si_mask, "__builtin_ia32_vpdpbsud_v8si_mask", > IX86_BUILTIN_VPDPBSUDV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsud_v8si_maskz, "__builtin_ia32_vpdpbsud_v8si_maskz", > IX86_BUILTIN_VPDPBSUDV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsuds_v8si_mask, "__builtin_ia32_vpdpbsuds_v8si_mask", > IX86_BUILTIN_VPDPBSUDSV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsuds_v8si_maskz, > "__builtin_ia32_vpdpbsuds_v8si_maskz", > IX86_BUILTIN_VPDPBSUDSV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuud_v8si_mask, "__builtin_ia32_vpdpbuud_v8si_mask", > IX86_BUILTIN_VPDPBUUDV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuud_v8si_maskz, "__builtin_ia32_vpdpbuud_v8si_maskz", > IX86_BUILTIN_VPDPBUUDV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuuds_v8si_mask, "__builtin_ia32_vpdpbuuds_v8si_mask", > IX86_BUILTIN_VPDPBUUDSV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuuds_v8si_maskz, > "__builtin_ia32_vpdpbuuds_v8si_maskz", > IX86_BUILTIN_VPDPBUUDSV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbssd_v4si_mask, "__builtin_ia32_vpdpbssd_v4si_mask", > IX86_BUILTIN_VPDPBSSDV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbssd_v4si_maskz, "__builtin_ia32_vpdpbssd_v4si_maskz", > IX86_BUILTIN_VPDPBSSDV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbssds_v4si_mask, "__builtin_ia32_vpdpbssds_v4si_mask", > IX86_BUILTIN_VPDPBSSDSV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbssds_v4si_maskz, "__builtin_ia32_vpdpbssds_v4si_maskz", > IX86_BUILTIN_VPDPBSSDSV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsud_v4si_mask, "__builtin_ia32_vpdpbsud_v4si_mask", > IX86_BUILTIN_VPDPBSUDV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsud_v4si_maskz, "__builtin_ia32_vpdpbsud_v4si_maskz", > IX86_BUILTIN_VPDPBSUDV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsuds_v4si_mask, "__builtin_ia32_vpdpbsuds_v4si_mask", > IX86_BUILTIN_VPDPBSUDSV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbsuds_v4si_maskz, > "__builtin_ia32_vpdpbsuds_v4si_maskz", > IX86_BUILTIN_VPDPBSUDSV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuud_v4si_mask, "__builtin_ia32_vpdpbuud_v4si_mask", > IX86_BUILTIN_VPDPBUUDV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuud_v4si_maskz, "__builtin_ia32_vpdpbuud_v4si_maskz", > IX86_BUILTIN_VPDPBUUDV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuuds_v4si_mask, "__builtin_ia32_vpdpbuuds_v4si_mask", > IX86_BUILTIN_VPDPBUUDSV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpbuuds_v4si_maskz, > "__builtin_ia32_vpdpbuuds_v4si_maskz", > IX86_BUILTIN_VPDPBUUDSV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsud_v16si, "__builtin_ia32_vpdpwsud512", > IX86_BUILTIN_VPDPWSUDV16SI, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsuds_v16si, "__builtin_ia32_vpdpwsuds512", > IX86_BUILTIN_VPDPWSUDSV16SI, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusd_v16si, "__builtin_ia32_vpdpwusd512", > IX86_BUILTIN_VPDPWUSDV16SI, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusds_v16si, "__builtin_ia32_vpdpwusds512", > IX86_BUILTIN_VPDPWUSDSV16SI, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuud_v16si, "__builtin_ia32_vpdpwuud512", > IX86_BUILTIN_VPDPWUUDV16SI, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuuds_v16si, "__builtin_ia32_vpdpwuuds512", > IX86_BUILTIN_VPDPWUUDSV16SI, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsud_v16si_mask, > "__builtin_ia32_vpdpwsud_v16si_mask", > IX86_BUILTIN_VPDPWSUDV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsud_v16si_maskz, > "__builtin_ia32_vpdpwsud_v16si_maskz", > IX86_BUILTIN_VPDPWSUDV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsuds_v16si_mask, > "__builtin_ia32_vpdpwsuds_v16si_mask", > IX86_BUILTIN_VPDPWSUDSV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsuds_v16si_maskz, > "__builtin_ia32_vpdpwsuds_v16si_maskz", > IX86_BUILTIN_VPDPWSUDSV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusd_v16si_mask, > "__builtin_ia32_vpdpwusd_v16si_mask", > IX86_BUILTIN_VPDPWUSDV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusd_v16si_maskz, > "__builtin_ia32_vpdpwusd_v16si_maskz", > IX86_BUILTIN_VPDPWUSDV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusds_v16si_mask, > "__builtin_ia32_vpdpwusds_v16si_mask", > IX86_BUILTIN_VPDPWUSDSV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusds_v16si_maskz, > "__builtin_ia32_vpdpwusds_v16si_maskz", > IX86_BUILTIN_VPDPWUSDSV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuud_v16si_mask, > "__builtin_ia32_vpdpwuud_v16si_mask", > IX86_BUILTIN_VPDPWUUDV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuud_v16si_maskz, > "__builtin_ia32_vpdpwuud_v16si_maskz", > IX86_BUILTIN_VPDPWUUDV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuuds_v16si_mask, > "__builtin_ia32_vpdpwuuds_v16si_mask", > IX86_BUILTIN_VPDPWUUDSV16SI_MASK, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuuds_v16si_maskz, > "__builtin_ia32_vpdpwuuds_v16si_maskz", > IX86_BUILTIN_VPDPWUUDSV16SI_MASKZ, UNKNOWN, (int) > V16SI_FTYPE_V16SI_V16SI_V16SI_UHI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsud_v8si_mask, "__builtin_ia32_vpdpwsud_v8si_mask", > IX86_BUILTIN_VPDPWSUDV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsud_v8si_maskz, "__builtin_ia32_vpdpwsud_v8si_maskz", > IX86_BUILTIN_VPDPWSUDV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsuds_v8si_mask, "__builtin_ia32_vpdpwsuds_v8si_mask", > IX86_BUILTIN_VPDPWSUDSV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsuds_v8si_maskz, > "__builtin_ia32_vpdpwsuds_v8si_maskz", > IX86_BUILTIN_VPDPWSUDSV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusd_v8si_mask, "__builtin_ia32_vpdpwusd_v8si_mask", > IX86_BUILTIN_VPDPWUSDV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusd_v8si_maskz, "__builtin_ia32_vpdpwusd_v8si_maskz", > IX86_BUILTIN_VPDPWUSDV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusds_v8si_mask, "__builtin_ia32_vpdpwusds_v8si_mask", > IX86_BUILTIN_VPDPWUSDSV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusds_v8si_maskz, > "__builtin_ia32_vpdpwusds_v8si_maskz", > IX86_BUILTIN_VPDPWUSDSV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuud_v8si_mask, "__builtin_ia32_vpdpwuud_v8si_mask", > IX86_BUILTIN_VPDPWUUDV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuud_v8si_maskz, > "__builtin_ia32_vpdpwuud_v8si_maskz", > IX86_BUILTIN_VPDPWUUDV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuuds_v8si_mask, > "__builtin_ia32_vpdpwuuds_v8si_mask", > IX86_BUILTIN_VPDPWUUDSV8SI_MASK, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuuds_v8si_maskz, > "__builtin_ia32_vpdpwuuds_v8si_maskz", > IX86_BUILTIN_VPDPWUUDSV8SI_MASKZ, UNKNOWN, (int) > V8SI_FTYPE_V8SI_V8SI_V8SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsud_v4si_mask, "__builtin_ia32_vpdpwsud_v4si_mask", > IX86_BUILTIN_VPDPWSUDV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsud_v4si_maskz, "__builtin_ia32_vpdpwsud_v4si_maskz", > IX86_BUILTIN_VPDPWSUDV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsuds_v4si_mask, "__builtin_ia32_vpdpwsuds_v4si_mask", > IX86_BUILTIN_VPDPWSUDSV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwsuds_v4si_maskz, > "__builtin_ia32_vpdpwsuds_v4si_maskz", > IX86_BUILTIN_VPDPWSUDSV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusd_v4si_mask, "__builtin_ia32_vpdpwusd_v4si_mask", > IX86_BUILTIN_VPDPWUSDV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusd_v4si_maskz, "__builtin_ia32_vpdpwusd_v4si_maskz", > IX86_BUILTIN_VPDPWUSDV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusds_v4si_mask, "__builtin_ia32_vpdpwusds_v4si_mask", > IX86_BUILTIN_VPDPWUSDSV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwusds_v4si_maskz, > "__builtin_ia32_vpdpwusds_v4si_maskz", > IX86_BUILTIN_VPDPWUSDSV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuud_v4si_mask, "__builtin_ia32_vpdpwuud_v4si_mask", > IX86_BUILTIN_VPDPWUUDV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuud_v4si_maskz, > "__builtin_ia32_vpdpwuud_v4si_maskz", > IX86_BUILTIN_VPDPWUUDV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuuds_v4si_mask, > "__builtin_ia32_vpdpwuuds_v4si_mask", > IX86_BUILTIN_VPDPWUUDSV4SI_MASK, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > +BDESC (0, OPTION_MASK_ISA2_AVX10V1AUX, > CODE_FOR_vpdpwuuds_v4si_maskz, > "__builtin_ia32_vpdpwuuds_v4si_maskz", > IX86_BUILTIN_VPDPWUUDSV4SI_MASKZ, UNKNOWN, (int) > V4SI_FTYPE_V4SI_V4SI_V4SI_UQI) > BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vdpphps_v16sf_mask, "__builtin_ia32_vdpphps512_mask", > IX86_BUILTIN_VDPPHPS512_MASK, UNKNOWN, (int) > V16SF_FTYPE_V16SF_V16SF_V16SF_UHI) > BDESC (0, OPTION_MASK_ISA2_AVX10_2, > CODE_FOR_vdpphps_v16sf_maskz, "__builtin_ia32_vdpphps512_maskz", > IX86_BUILTIN_VDPPHPS512_MASKZ, UNKNOWN, (int) > V16SF_FTYPE_V16SF_V16SF_V16SF_UHI) > BDESC (0, OPTION_MASK_ISA2_AVX10_2, CODE_FOR_vdpphps_v8sf_mask, > "__builtin_ia32_vdpphps256_mask", IX86_BUILTIN_VDPPHPS256_MASK, > UNKNOWN, (int) V8SF_FTYPE_V8SF_V8SF_V8SF_UQI) > diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc > index a81993c29c52..285227a3f943 100644 > --- a/gcc/config/i386/i386-expand.cc > +++ b/gcc/config/i386/i386-expand.cc > @@ -14995,8 +14995,8 @@ ix86_check_builtin_isa_match (unsigned int > fcode, > (OPTION_MASK_ISA_AVX512VL | OPTION_MASK_ISA2_AVX512BF16) or > OPTION_MASK_ISA2_AVXNECONVERT > OPTION_MASK_ISA_AES or (OPTION_MASK_ISA_AVX512VL | > OPTION_MASK_ISA2_VAES) > - OPTION_MASK_ISA2_AVX10_2 or OPTION_MASK_ISA2_AVXVNNIINT8 > - OPTION_MASK_ISA2_AVX10_2 or OPTION_MASK_ISA2_AVXVNNIINT16 > + OPTION_MASK_ISA2_AVX10V1AUX or > OPTION_MASK_ISA2_AVXVNNIINT8 > + OPTION_MASK_ISA2_AVX10V1AUX or > OPTION_MASK_ISA2_AVXVNNIINT16 > OPTION_MASK_ISA2_AMX_TILE or OPTION_MASK_ISA2_ACEV1 > where for each such pair it is sufficient if either of the ISAs is > enabled, plus if it is ored with other options also those others. > @@ -15024,9 +15024,9 @@ ix86_check_builtin_isa_match (unsigned int > fcode, > SHARE_BUILTIN (OPTION_MASK_ISA_AES, 0, > OPTION_MASK_ISA_AVX512VL, > OPTION_MASK_ISA2_VAES); > SHARE_BUILTIN (0, OPTION_MASK_ISA2_AVXVNNIINT8, 0, > - OPTION_MASK_ISA2_AVX10_2); > + OPTION_MASK_ISA2_AVX10V1AUX); > SHARE_BUILTIN (0, OPTION_MASK_ISA2_AVXVNNIINT16, 0, > - OPTION_MASK_ISA2_AVX10_2); > + OPTION_MASK_ISA2_AVX10V1AUX); > SHARE_BUILTIN (0, OPTION_MASK_ISA2_AMX_TILE, 0, > OPTION_MASK_ISA2_ACEV1); > isa = tmp_isa; > isa2 = tmp_isa2; > diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc > index 2aad91ecf46e..21ef8d5b4b13 100644 > --- a/gcc/config/i386/i386.cc > +++ b/gcc/config/i386/i386.cc > @@ -27092,8 +27092,8 @@ ix86_vector_costs::add_stmt_cost (int count, > vect_cost_for_stmt kind, > /* vpdpbssd. */ > native_vnni_p > = (GET_MODE_SIZE (mode) == 64 > - ? TARGET_AVX10_2 > - : (TARGET_AVXVNNIINT8 || TARGET_AVX10_2)); > + ? TARGET_AVX10V1AUX > + : (TARGET_AVXVNNIINT8 || > TARGET_AVX10V1AUX)); > } > m_num_reduc[X86_REDUC_DOT_PROD] += count * scale; > > diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md > index d5b90291fc9c..1fff2f0a277c 100644 > --- a/gcc/config/i386/i386.md > +++ b/gcc/config/i386/i386.md > @@ -613,7 +613,8 @@ > > avx512bw,noavx512bw,avx512dq,noavx512dq,fma_or_avx512vl, > > avx512vl,noavx512vl,avxvnni,avxvnniint8,avx512vnnivl,avx512fp16,avxifma, > avx512ifmavl,avxneconvert,avx512bf16vl,vpclmulqdqvl, > - > avx_noavx512f,avx_noavx512vl,vaes_avx512vl,noapx_nf,avx10_2" > + > avx_noavx512f,avx_noavx512vl,vaes_avx512vl,noapx_nf,avx10_2, > + avx10v1aux" > (const_string "base")) > > ;; The (bounding maximum) length of an instruction immediate. > @@ -1015,6 +1016,7 @@ > (eq_attr "isa" "vaes_avx512vl") > (symbol_ref "TARGET_VAES && TARGET_AVX512VL") > (eq_attr "isa" "avx10_2") (symbol_ref "TARGET_AVX10_2") > + (eq_attr "isa" "avx10v1aux") (symbol_ref "TARGET_AVX10V1AUX") > > (eq_attr "mmx_isa" "native") > (symbol_ref "!TARGET_MMX_WITH_SSE") > diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md > index a223acc606d7..b4a41d7abd53 100644 > --- a/gcc/config/i386/sse.md > +++ b/gcc/config/i386/sse.md > @@ -695,8 +695,8 @@ > (define_mode_iterator VI2_AVX512F > [(V32HI "TARGET_AVX512F") (V16HI "TARGET_AVX2") V8HI]) > > -(define_mode_iterator VI2_AVX10_2 > - [(V32HI "TARGET_AVX10_2") (V16HI "TARGET_AVX2") V8HI]) > +(define_mode_iterator VI2_AVX10V1AUX > + [(V32HI "TARGET_AVX10V1AUX") (V16HI "TARGET_AVX2") V8HI]) > > (define_mode_iterator VI2_AVX512VNNIBW > [(V32HI "TARGET_AVX512BW || TARGET_AVX512VNNI") > @@ -717,6 +717,9 @@ > (define_mode_iterator VI4_AVX10_2 > [(V16SI "TARGET_AVX10_2") V8SI V4SI]) > > +(define_mode_iterator VI4_AVX10V1AUX > + [(V16SI "TARGET_AVX10V1AUX") V8SI V4SI]) > + > (define_mode_iterator VI48_AVX512F_AVX512VL > [V4SI V8SI (V16SI "TARGET_AVX512F") > (V2DI "TARGET_AVX512VL") (V4DI "TARGET_AVX512VL") > @@ -33200,8 +33203,8 @@ > (match_operand: 3 "register_operand")] > "TARGET_SSE2" > { > - if (( == 64 && TARGET_AVX10_2) > - || ( < 64 && (TARGET_AVXVNNIINT8 || > TARGET_AVX10_2))) > + if (( == 64 && TARGET_AVX10V1AUX) > + || ( < 64 && (TARGET_AVXVNNIINT8 || > TARGET_AVX10V1AUX))) > { > operands[1] = lowpart_subreg (mode, > force_reg (mode, operands[1]), > @@ -33248,8 +33251,8 @@ > (match_operand: 3 "register_operand")] > "TARGET_SSE2" > { > - if (( == 64 && TARGET_AVX10_2) > - || ( < 64 && (TARGET_AVXVNNIINT8 || > TARGET_AVX10_2))) > + if (( == 64 && TARGET_AVX10V1AUX) > + || ( < 64 && (TARGET_AVXVNNIINT8 || > TARGET_AVX10V1AUX))) > { > operands[1] = lowpart_subreg (mode, > force_reg (mode, operands[1]), > @@ -33296,11 +33299,11 @@ > (match_operand:VI4_AVX 2 "register_operand" "x,v") > (match_operand:VI4_AVX 3 "nonimmediate_operand" "xjm,vm")] > VPDOTPROD))] > - "TARGET_AVXVNNIINT8 || TARGET_AVX10_2" > + "TARGET_AVXVNNIINT8 || TARGET_AVX10V1AUX" > "vpdp\t{%3, %2, %0|%0, %2, %3}" > [(set_attr "prefix" "maybe_evex") > (set_attr "addr" "gpr16,*") > - (set_attr "isa" "avxvnniint8,avx10_2")]) > + (set_attr "isa" "avxvnniint8,avx10v1aux")]) > > (define_insn "vpdp_v16si" > [(set (match_operand:V16SI 0 "register_operand" "=v") > @@ -33309,48 +33312,48 @@ > (match_operand:V16SI 2 "register_operand" "v") > (match_operand:V16SI 3 "nonimmediate_operand" "vm")] > VPDOTPROD))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > "vpdp\t{%3, %2, %0|%0, %2, %3}" > [(set_attr "prefix" "evex")]) > > (define_insn "vpdp__mask" > - [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=v") > - (vec_merge:VI4_AVX10_2 > - (unspec:VI4_AVX10_2 > - [(match_operand:VI4_AVX10_2 1 "register_operand" "0") > - (match_operand:VI4_AVX10_2 2 "register_operand" "v") > - (match_operand:VI4_AVX10_2 3 "nonimmediate_operand" "vm")] > + [(set (match_operand:VI4_AVX10V1AUX 0 "register_operand" "=v") > + (vec_merge:VI4_AVX10V1AUX > + (unspec:VI4_AVX10V1AUX > + [(match_operand:VI4_AVX10V1AUX 1 "register_operand" "0") > + (match_operand:VI4_AVX10V1AUX 2 "register_operand" "v") > + (match_operand:VI4_AVX10V1AUX 3 "nonimmediate_operand" > "vm")] > VPDOTPROD) > (match_dup 1) > (match_operand: 4 "register_operand" "Yk")))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > "vpdp\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}" > [(set_attr "prefix" "evex")]) > > (define_expand "vpdp__maskz" > - [(set (match_operand:VI4_AVX10_2 0 "register_operand") > - (vec_merge:VI4_AVX10_2 > - (unspec:VI4_AVX10_2 > - [(match_operand:VI4_AVX10_2 1 "register_operand") > - (match_operand:VI4_AVX10_2 2 "register_operand") > - (match_operand:VI4_AVX10_2 3 "nonimmediate_operand")] > + [(set (match_operand:VI4_AVX10V1AUX 0 "register_operand") > + (vec_merge:VI4_AVX10V1AUX > + (unspec:VI4_AVX10V1AUX > + [(match_operand:VI4_AVX10V1AUX 1 "register_operand") > + (match_operand:VI4_AVX10V1AUX 2 "register_operand") > + (match_operand:VI4_AVX10V1AUX 3 "nonimmediate_operand")] > VPDOTPROD) > (match_dup 5) > (match_operand: 4 "register_operand")))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > "operands[5] = CONST0_RTX (mode);") > > (define_insn "*vpdp__maskz" > - [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=v") > - (vec_merge:VI4_AVX10_2 > - (unspec:VI4_AVX10_2 > - [(match_operand:VI4_AVX10_2 1 "register_operand" "0") > - (match_operand:VI4_AVX10_2 2 "register_operand" "v") > - (match_operand:VI4_AVX10_2 3 "nonimmediate_operand" "vm")] > + [(set (match_operand:VI4_AVX10V1AUX 0 "register_operand" "=v") > + (vec_merge:VI4_AVX10V1AUX > + (unspec:VI4_AVX10V1AUX > + [(match_operand:VI4_AVX10V1AUX 1 "register_operand" "0") > + (match_operand:VI4_AVX10V1AUX 2 "register_operand" "v") > + (match_operand:VI4_AVX10V1AUX 3 "nonimmediate_operand" > "vm")] > VPDOTPROD) > - (match_operand:VI4_AVX10_2 5 "const0_operand" "C") > + (match_operand:VI4_AVX10V1AUX 5 "const0_operand" "C") > (match_operand: 4 "register_operand" "Yk")))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > > "vpdp\t{%3, %2, %0%{%4%}%N5|%0%{%4%}%N5, %2, %3 > }" > [(set_attr "prefix" "evex")]) > > @@ -33667,10 +33670,10 @@ > > (define_expand "usdot_prod" > [(match_operand: 0 "register_operand") > - (match_operand:VI2_AVX10_2 1 "register_operand") > - (match_operand:VI2_AVX10_2 2 "register_operand") > + (match_operand:VI2_AVX10V1AUX 1 "register_operand") > + (match_operand:VI2_AVX10V1AUX 2 "register_operand") > (match_operand: 3 "register_operand")] > - "TARGET_AVXVNNIINT16 || TARGET_AVX10_2" > + "TARGET_AVXVNNIINT16 || TARGET_AVX10V1AUX" > { > operands[1] = lowpart_subreg (mode, > force_reg (mode, operands[1]), > @@ -33685,10 +33688,10 @@ > > (define_expand "udot_prod" > [(match_operand: 0 "register_operand") > - (match_operand:VI2_AVX10_2 1 "register_operand") > - (match_operand:VI2_AVX10_2 2 "register_operand") > + (match_operand:VI2_AVX10V1AUX 1 "register_operand") > + (match_operand:VI2_AVX10V1AUX 2 "register_operand") > (match_operand: 3 "register_operand")] > - "TARGET_AVXVNNIINT16 || TARGET_AVX10_2" > + "TARGET_AVXVNNIINT16 || TARGET_AVX10V1AUX" > { > operands[1] = lowpart_subreg (mode, > force_reg (mode, operands[1]), > @@ -33708,7 +33711,7 @@ > (match_operand:VI4_AVX 2 "register_operand" "v") > (match_operand:VI4_AVX 3 "nonimmediate_operand" "vm")] > VPDPWPROD))] > - "TARGET_AVXVNNIINT16 || TARGET_AVX10_2" > + "TARGET_AVXVNNIINT16 || TARGET_AVX10V1AUX" > "vpdp\t{%3, %2, %0|%0, %2, %3}" > [(set_attr "prefix" "maybe_evex")]) > > @@ -33719,48 +33722,48 @@ > (match_operand:V16SI 2 "register_operand" "v") > (match_operand:V16SI 3 "nonimmediate_operand" "vm")] > VPDPWPROD))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > "vpdp\t{%3, %2, %0|%0, %2, %3}" > [(set_attr "prefix" "evex")]) > > (define_insn "vpdp__mask" > - [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=v") > - (vec_merge:VI4_AVX10_2 > - (unspec:VI4_AVX10_2 > - [(match_operand:VI4_AVX10_2 1 "register_operand" "0") > - (match_operand:VI4_AVX10_2 2 "register_operand" "v") > - (match_operand:VI4_AVX10_2 3 "nonimmediate_operand" "vm")] > + [(set (match_operand:VI4_AVX10V1AUX 0 "register_operand" "=v") > + (vec_merge:VI4_AVX10V1AUX > + (unspec:VI4_AVX10V1AUX > + [(match_operand:VI4_AVX10V1AUX 1 "register_operand" "0") > + (match_operand:VI4_AVX10V1AUX 2 "register_operand" "v") > + (match_operand:VI4_AVX10V1AUX 3 "nonimmediate_operand" > "vm")] > VPDPWPROD) > (match_dup 1) > (match_operand: 4 "register_operand" "Yk")))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > "vpdp\t{%3, %2, %0%{%4%}|%0%{%4%}, %2, %3}" > [(set_attr "prefix" "evex")]) > > (define_expand "vpdp__maskz" > - [(set (match_operand:VI4_AVX10_2 0 "register_operand") > - (vec_merge:VI4_AVX10_2 > - (unspec:VI4_AVX10_2 > - [(match_operand:VI4_AVX10_2 1 "register_operand") > - (match_operand:VI4_AVX10_2 2 "register_operand") > - (match_operand:VI4_AVX10_2 3 "nonimmediate_operand")] > + [(set (match_operand:VI4_AVX10V1AUX 0 "register_operand") > + (vec_merge:VI4_AVX10V1AUX > + (unspec:VI4_AVX10V1AUX > + [(match_operand:VI4_AVX10V1AUX 1 "register_operand") > + (match_operand:VI4_AVX10V1AUX 2 "register_operand") > + (match_operand:VI4_AVX10V1AUX 3 "nonimmediate_operand")] > VPDPWPROD) > (match_dup 5) > (match_operand: 4 "register_operand")))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > "operands[5] = CONST0_RTX (mode);") > > (define_insn "*vpdp__maskz" > - [(set (match_operand:VI4_AVX10_2 0 "register_operand" "=v") > - (vec_merge:VI4_AVX10_2 > - (unspec:VI4_AVX10_2 > - [(match_operand:VI4_AVX10_2 1 "register_operand" "0") > - (match_operand:VI4_AVX10_2 2 "register_operand" "v") > - (match_operand:VI4_AVX10_2 3 "nonimmediate_operand" "vm")] > + [(set (match_operand:VI4_AVX10V1AUX 0 "register_operand" "=v") > + (vec_merge:VI4_AVX10V1AUX > + (unspec:VI4_AVX10V1AUX > + [(match_operand:VI4_AVX10V1AUX 1 "register_operand" "0") > + (match_operand:VI4_AVX10V1AUX 2 "register_operand" "v") > + (match_operand:VI4_AVX10V1AUX 3 "nonimmediate_operand" > "vm")] > VPDPWPROD) > - (match_operand:VI4_AVX10_2 5 "const0_operand" "C") > + (match_operand:VI4_AVX10V1AUX 5 "const0_operand" "C") > (match_operand: 4 "register_operand" "Yk")))] > - "TARGET_AVX10_2" > + "TARGET_AVX10V1AUX" > > "vpdp\t{%3, %2, %0%{%4%}%N5|%0%{%4%}%N5, %2, % > 3}" > [(set_attr "prefix" "evex")]) > > -- > 2.34.1 From haochen.jiang@intel.com Mon Nov 2 06:20:34 2026 From: haochen.jiang@intel.com (Jiang, Haochen) Date: Mon, 2 Nov 2026 06:20:34 +0000 Subject: [PATCH v3 4/4] [X86]: Add AVX10V1AUX tests for VNNIINT8/16. In-Reply-To: <20261101134756.351245-5-Dipesh.Sharma@amd.com> References: <20261101134756.351245-1-Dipesh.Sharma@amd.com> <20261101134756.351245-5-Dipesh.Sharma@amd.com> Message-ID: > From: Dipesh Sharma > Sent: Sunday, November 1, 2026 9:48 PM > > Since avx10.2 implies avx10v1aux, I feel passing avx10v1aux on > top of avx10.2 in several testfiles{ e.g. sse-*.c} is redundant. I am okay with either passing or not passing. LGTM with one minor comment. > diff --git a/gcc/testsuite/gcc.target/i386/avx10_2-builtin-1.c > b/gcc/testsuite/gcc.target/i386/avx10_2-builtin-1.c > index 2c793cfa0a98..867a439364b1 100644 > --- a/gcc/testsuite/gcc.target/i386/avx10_2-builtin-1.c > +++ b/gcc/testsuite/gcc.target/i386/avx10_2-builtin-1.c > @@ -1,5 +1,5 @@ > /* { dg-do compile } */ > -/* { dg-options "-O0 -march=x86-64-v3 -mavx10.2 -mno-avxvnniint8" } */ > +/* { dg-options "-O0 -march=x86-64-v3 -mavx10v1aux -mno-avx10.2 -mno- > avxvnniint8" } */ > typedef int v8si __attribute__ ((vector_size (32))); > v8si > foo (v8si a, v8si b, v8si c) > diff --git a/gcc/testsuite/gcc.target/i386/avx10_2-builtin-2.c > b/gcc/testsuite/gcc.target/i386/avx10_2-builtin-2.c > index 6eeb20e034f0..73e32fe4f9fa 100644 > --- a/gcc/testsuite/gcc.target/i386/avx10_2-builtin-2.c > +++ b/gcc/testsuite/gcc.target/i386/avx10_2-builtin-2.c > @@ -1,5 +1,5 @@ > /* { dg-do compile } */ > -/* { dg-options "-O0 -march=x86-64-v3 -mavx10.2 -mno-avxvnniint16" } */ > +/* { dg-options "-O0 -march=x86-64-v3 -mavx10v1aux -mno-avx10.2 -mno- > avxvnniint16" } */ > typedef int v8si __attribute__ ((vector_size (32))); > v8si > foo (v8si a, v8si b, v8si c) Please do not disable avx10.2. It might cause confusion. Thx, Haochen From haochen.jiang@intel.com Mon Nov 2 07:32:33 2026 From: haochen.jiang@intel.com (Haochen Jiang) Date: Mon, 2 Nov 2026 15:32:33 +0800 Subject: [PATCH] i386: Emit mask fma for conditional fma [PR128221] Message-ID: <20261102073233.196185-1-haochen.jiang@intel.com> Hi all, Previosly on trunk, we will emit fma + masked mov for conditional fma, it will get the correct result, but those masked values causing exception will be calculated under this scenario. Those thrown out excpetions are not expected. Use mask fma instead of fma to do that. After using mask fma, we lose some ablitiy to merge, do it directly in the new ix86_expand_cond_fma for some scenarios to avoid extra moves. Regtested on x86-64. Ok for trunk (and maybe backport)? Thx, Haochen gcc/ChangeLog: PR target/128221 * config/i386/i386-expand.cc (ix86_expand_cond_fma): New function to expand conditional fma. * config/i386/i386-protos.h (ix86_expand_cond_fma): Ditto. * config/i386/sse.md (cond_fma): Use new ix86_expand_cond_fma. (cond_fms): Ditto. (cond_fnma): Ditto. (cond_fnms): Ditto. gcc/testsuite/ChangeLog: PR target/128221 * gcc.target/i386/pr128221-1a.c: New test. * gcc.target/i386/pr128221-1b.c: Ditto. * gcc.target/i386/pr128221-2.c: Ditto. --- gcc/config/i386/i386-expand.cc | 37 ++++++++++++++ gcc/config/i386/i386-protos.h | 1 + gcc/config/i386/sse.md | 40 ++------------- gcc/testsuite/gcc.target/i386/pr128221-1a.c | 26 ++++++++++ gcc/testsuite/gcc.target/i386/pr128221-1b.c | 39 +++++++++++++++ gcc/testsuite/gcc.target/i386/pr128221-2.c | 55 +++++++++++++++++++++ 6 files changed, 162 insertions(+), 36 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr128221-1a.c create mode 100644 gcc/testsuite/gcc.target/i386/pr128221-1b.c create mode 100644 gcc/testsuite/gcc.target/i386/pr128221-2.c diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index 8a6f0280ac6..68b19ec624d 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -4767,6 +4767,43 @@ ix86_expand_fp_movcc (rtx operands[]) return true; } +/* Expand a conditional fma: operands[0] = operands[1] + ? fma (operands[2], operands[3], operands[4]) : operands[5]. */ + +void +ix86_expand_cond_fma (rtx operands[], bool neg_mult, bool neg_add) +{ + machine_mode mode = GET_MODE (operands[0]); + rtx mask = operands[1]; + rtx op1 = operands[2], op2 = operands[3], op3 = operands[4]; + rtx op4 = operands[5]; + rtx tmp, fma; + + /* The multiplication is commutative, so an else value equal to the + second operand for mult can be merged just like first operand + after swapping. */ + if (rtx_equal_p (op4, op2)) + std::swap (op1, op2); + + fma = gen_rtx_FMA (mode, neg_mult ? gen_rtx_NEG (mode, op1) : op1, + op2, neg_add ? gen_rtx_NEG (mode, op3) : op3); + + /* Do not emit an extra move. */ + if (rtx_equal_p (op4, op1) + || rtx_equal_p (op4, op3) + || op4 == CONST0_RTX (mode)) + { + emit_insn (gen_rtx_SET (operands[0], + gen_rtx_VEC_MERGE (mode, fma, op4, mask))); + return; + } + + tmp = gen_reg_rtx (mode); + emit_insn (gen_rtx_SET (tmp, gen_rtx_VEC_MERGE (mode, fma, + CONST0_RTX (mode), mask))); + emit_move_insn (operands[0], gen_rtx_VEC_MERGE (mode, tmp, op4, mask)); +} + /* Helper for ix86_cmp_code_to_pcmp_immediate for int modes. */ static int diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 949f6296462..788ad443b44 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -158,6 +158,7 @@ extern void ix86_expand_branch (enum rtx_code, rtx, rtx, rtx); extern void ix86_expand_setcc (rtx, enum rtx_code, rtx, rtx); extern bool ix86_expand_int_movcc (rtx[]); extern bool ix86_expand_fp_movcc (rtx[]); +extern void ix86_expand_cond_fma (rtx[], bool, bool); extern bool ix86_expand_fp_vcond (rtx[]); extern bool ix86_expand_int_vcond (rtx[]); extern void ix86_expand_vec_perm (rtx[]); diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 1456c92e498..705e45d1c94 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -6412,15 +6412,7 @@ (match_operand: 1 "register_operand")))] "TARGET_AVX512F" { - rtx tmp = gen_reg_rtx (mode); - emit_insn (gen_fma4 (tmp, - operands[2], - operands[3], - operands[4])); - emit_move_insn (operands[0], gen_rtx_VEC_MERGE (mode, - tmp, - operands[5], - operands[1])); + ix86_expand_cond_fma (operands, false, false); DONE; }) @@ -6517,15 +6509,7 @@ (match_operand: 1 "register_operand")))] "TARGET_AVX512F" { - rtx tmp = gen_reg_rtx (mode); - emit_insn (gen_fms4 (tmp, - operands[2], - operands[3], - operands[4])); - emit_move_insn (operands[0], gen_rtx_VEC_MERGE (mode, - tmp, - operands[5], - operands[1])); + ix86_expand_cond_fma (operands, false, true); DONE; }) @@ -6624,15 +6608,7 @@ (match_operand: 1 "register_operand")))] "TARGET_AVX512F" { - rtx tmp = gen_reg_rtx (mode); - emit_insn (gen_fnma4 (tmp, - operands[2], - operands[3], - operands[4])); - emit_move_insn (operands[0], gen_rtx_VEC_MERGE (mode, - tmp, - operands[5], - operands[1])); + ix86_expand_cond_fma (operands, true, false); DONE; }) @@ -6734,15 +6710,7 @@ (match_operand: 1 "register_operand")))] "TARGET_AVX512F" { - rtx tmp = gen_reg_rtx (mode); - emit_insn (gen_fnms4 (tmp, - operands[2], - operands[3], - operands[4])); - emit_move_insn (operands[0], gen_rtx_VEC_MERGE (mode, - tmp, - operands[5], - operands[1])); + ix86_expand_cond_fma (operands, true, true); DONE; }) diff --git a/gcc/testsuite/gcc.target/i386/pr128221-1a.c b/gcc/testsuite/gcc.target/i386/pr128221-1a.c new file mode 100644 index 00000000000..1cdc64d7ee7 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr128221-1a.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -mavx512f -mprefer-vector-width=512" } */ + +#define N 1024 + +double a[N], b[N], c[N]; +int m[N]; + +#define DEF_COND_FMA(NAME, EXPR) \ + void \ + NAME (double w, double e) \ + { \ + for (int i = 0; i < N; i++) \ + a[i] = m[i] ? (EXPR) : e; \ + } + +DEF_COND_FMA (fma_test, a[i] + b[i] * w) +DEF_COND_FMA (fms_test, b[i] * w - c[i]) +DEF_COND_FMA (fnma_test, c[i] - b[i] * w) +DEF_COND_FMA (fnms_test, -b[i] * w - c[i]) + +/* { dg-final { scan-assembler "vfmadd\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ +/* { dg-final { scan-assembler "vfmsub\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ +/* { dg-final { scan-assembler "vfnmadd\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ +/* { dg-final { scan-assembler "vfnmsub\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ +/* { dg-final { scan-assembler-not "vfn?m(?:add|sub)\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr128221-1b.c b/gcc/testsuite/gcc.target/i386/pr128221-1b.c new file mode 100644 index 00000000000..e876b78d8e1 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr128221-1b.c @@ -0,0 +1,39 @@ +/* PR target/128221 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -mavx512f -mprefer-vector-width=512" } */ + +#define N 1024 + +double a[N], b[N], c[N], d[N]; +int m[N]; + +#define DEF_COND_FMA(NAME, EXPR, ELSE) \ + void \ + NAME (void) \ + { \ + for (int i = 0; i < N; i++) \ + a[i] = m[i] ? (EXPR) : (ELSE); \ + } + +#define DEF_COND_FMA_ALL(NAME, EXPR) \ + DEF_COND_FMA (NAME##_z, EXPR, 0.0) \ + DEF_COND_FMA (NAME##_mul1, EXPR, b[i]) \ + DEF_COND_FMA (NAME##_mul2, EXPR, c[i]) \ + DEF_COND_FMA (NAME##_add, EXPR, d[i]) + +DEF_COND_FMA_ALL (fma, b[i] * c[i] + d[i]) +DEF_COND_FMA_ALL (fms, b[i] * c[i] - d[i]) +DEF_COND_FMA_ALL (fnma, d[i] - b[i] * c[i]) +DEF_COND_FMA_ALL (fnms, -b[i] * c[i] - d[i]) + +/* { dg-final { scan-assembler "vfmadd\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ +/* { dg-final { scan-assembler "vfmadd\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" } } */ +/* { dg-final { scan-assembler "vfmsub\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ +/* { dg-final { scan-assembler "vfmsub\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" } } */ +/* { dg-final { scan-assembler "vfnmadd\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ +/* { dg-final { scan-assembler "vfnmadd\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" } } */ +/* { dg-final { scan-assembler "vfnmsub\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ +/* { dg-final { scan-assembler "vfnmsub\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" } } */ +/* { dg-final { scan-assembler-not "vfn?m(?:add|sub)\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" } } */ +/* { dg-final { scan-assembler-not "vblendm" } } */ +/* { dg-final { scan-assembler-not "vmov\[a-z0-9\]+\[ \\t\]+%zmm\[0-9\]+, %zmm\[0-9\]+\{%k" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr128221-2.c b/gcc/testsuite/gcc.target/i386/pr128221-2.c new file mode 100644 index 00000000000..5fbc9410a0d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr128221-2.c @@ -0,0 +1,55 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -mavx512f -mprefer-vector-width=512" } */ +/* { dg-require-effective-target avx512f } */ +/* { dg-require-effective-target fenv_exceptions } */ + +#include +#include "avx512f-check.h" +#include "pr128221-1.c" + +#define W 1800.0 +#define E -1e34 + +static void +check (void (*fn) (double, double), int op) +{ + for (int i = 0; i < N; i++) + { + m[i] = i & 1; + /* Overflows only in the lanes where m[i] is zero. */ + b[i] = m[i] ? 1.0 : 1e307; + a[i] = 2.0; + c[i] = 3.0; + } + + feclearexcept (FE_ALL_EXCEPT); + fn (W, E); + if (fetestexcept (FE_OVERFLOW)) + abort (); + + for (int i = 0; i < N; i++) + { + double r; + if (!m[i]) + r = E; + else if (op == 0) + r = 2.0 + W; + else if (op == 1) + r = W - 3.0; + else if (op == 2) + r = 3.0 - W; + else + r = -W - 3.0; + if (a[i] != r) + abort (); + } +} + +static void +avx512f_test (void) +{ + check (fma_test, 0); + check (fms_test, 1); + check (fnma_test, 2); + check (fnms_test, 3); +} -- 2.31.1 From crazylht@gmail.com Mon Nov 2 07:43:26 2026 From: crazylht@gmail.com (Hongtao Liu) Date: Sun, 01 Nov 2026 23:43:26 -0800 Subject: [PATCH v3 0/4][X86] Add support for AVX10V1AUX. In-Reply-To: <20261101134756.351245-1-Dipesh.Sharma@amd.com> References: <20261101134756.351245-1-Dipesh.Sharma@amd.com> Message-ID: On Sun Nov 1, 2026 at 5:47 AM PST, Dipesh Sharma wrote: > This patch series adds support for AVX10V1AUX. > > > This revision addresses the comments on the > previous(V2) revision: https://gcc.gnu.org/pipermail/gcc-patches/2026-October/736257.html Ok for the series after addressing haocheng's comments. > > > Dipesh Sharma (4): > [X86]: Initial support for AVX10V1AUX > [X86]: Move shared AVX10.2 convert intrinsics to AVX10V1AUX. > [X86]: Move shared AVX10.2 and VNNI byte and word intrinsics to > AVX10V1AUX. > [X86]: Add AVX10V1AUX tests for VNNIINT8/16. > > gcc/common/config/i386/cpuinfo.h | 15 +- > gcc/common/config/i386/i386-common.cc | 27 +- > gcc/common/config/i386/i386-cpuinfo.h | 1 + > gcc/common/config/i386/i386-isas.h | 2 + > gcc/config.gcc | 2 +- > gcc/config/i386/avx10_2convertintrin.h | 1376 --------- > gcc/config/i386/avx10_2mediaintrin.h | 1032 ------- > gcc/config/i386/avx10v1auxintrin.h | 2459 +++++++++++++++++ > gcc/config/i386/cpuid.h | 1 + > gcc/config/i386/i386-builtin.def | 308 +-- > gcc/config/i386/i386-c.cc | 2 + > gcc/config/i386/i386-expand.cc | 8 +- > gcc/config/i386/i386-isa.def | 1 + > gcc/config/i386/i386-options.cc | 4 +- > gcc/config/i386/i386.cc | 4 +- > gcc/config/i386/i386.h | 5 +- > gcc/config/i386/i386.md | 4 +- > gcc/config/i386/i386.opt | 5 + > gcc/config/i386/i386.opt.urls | 3 + > gcc/config/i386/immintrin.h | 2 + > gcc/config/i386/sse.md | 162 +- > gcc/doc/extend.texi | 5 + > gcc/doc/invoke.texi | 8 +- > gcc/doc/sourcebuild.texi | 3 + > gcc/testsuite/gcc.target/i386/avx-1.c | 2 +- > .../gcc.target/i386/avx10_2-builtin-1.c | 2 +- > .../gcc.target/i386/avx10_2-builtin-2.c | 2 +- > gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c | 375 +++ > gcc/testsuite/gcc.target/i386/avx10v1aux-1b.c | 267 ++ > gcc/testsuite/gcc.target/i386/funcspec-56.inc | 2 + > gcc/testsuite/gcc.target/i386/sse-13.c | 2 +- > gcc/testsuite/gcc.target/i386/sse-14.c | 2 +- > gcc/testsuite/gcc.target/i386/sse-22.c | 2 +- > gcc/testsuite/gcc.target/i386/sse-23.c | 2 +- > gcc/testsuite/lib/target-supports.exp | 13 + > 35 files changed, 3441 insertions(+), 2669 deletions(-) > create mode 100644 gcc/config/i386/avx10v1auxintrin.h > create mode 100644 gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c > create mode 100644 gcc/testsuite/gcc.target/i386/avx10v1aux-1b.c > > -- > 2.34.1 From yansendao@126.com Mon Nov 2 07:48:08 2026 From: yansendao@126.com (Sendao Yan) Date: Mon, 2 Nov 2026 15:48:08 +0800 Subject: [PATCH v2 0/2] tree-optimization/128102 - restore binascii_a2b_base64 performance Message-ID: <20261102074810.2976046-1-yansendao@126.com> This series fixes PR128102, where the state-machine loop in CPython's binascii_a2b_base64 regressed from ~2.1 to ~4.1 cycles/byte between GCC 11 and GCC 12. The backward jump threader fails to thread the loop because pass_lower_switch has already lowered the GIMPLE_SWITCH into a decision tree by the time the late FSM threading runs, and the duplication limits are tight for the resulting branch sequence. Patch 1 moves pass_lower_switch after pass_thread_jumps_full so the backward threader still sees the switch; pass_dominator and pass_strlen keep their place relative to the jump threaders, so the only change is the position of pass_lower_switch. Moving the lowering changes the control flow seen by the -Wuninitialized warning pass and exposes two latent false positives (PR107919 and PR44547). Patch 2 fixes uninit_analysis::is_use_guarded, which wrongly treats an empty (unconditional) use predicate as an unguarded use; an unconditional use is now guarded exactly when its definition predicate is TRUE. Changes since v1: - Patch 2/2: in the fallback path, a definition predicate that simplifies to TRUE (the value is defined on every path) now guards any use, not just an unconditional one. v1 checked only the superset relation there, which is vacuous for a TRUE predicate and so missed the conditional-use case. (Spotted by Sashiko.) Bootstrapped and regression-tested on x86_64-linux-gnu and aarch64-linux-gnu (bootstrap-debug, stage2/stage3 compare clean; check-c and check-c++). PR44547 and PR107919 pass on both. The remaining unexpected failures on each target are pre-existing and unrelated to this series. Sendao Yan Sendao Yan (2): tree-optimization/128102 - lower switches after the late jump threading tree-optimization/128102 - fix -Wuninitialized FPs from lowering switches late gcc/gimple-predicate-analysis.cc | 40 +++++++++---- gcc/passes.def | 4 +- gcc/testsuite/gcc.dg/tree-ssa/pr128102.c | 69 ++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr128102.c -- 2.34.1 From yansendao@126.com Mon Nov 2 07:48:09 2026 From: yansendao@126.com (Sendao Yan) Date: Mon, 2 Nov 2026 15:48:09 +0800 Subject: [PATCH v2 1/2] tree-optimization/128102 - lower switches after the late jump threading In-Reply-To: <20261102074810.2976046-1-yansendao@126.com> References: <20261102074810.2976046-1-yansendao@126.com> Message-ID: <20261102074810.2976046-2-yansendao@126.com> The backward jump threader fails to thread the state-machine loop in binascii_a2b_base64 because the switch has already been lowered to a decision tree by the time the late FSM threading runs, and the duplication limits are tight for the resulting branch sequence. Move the switch lowering after the backward jump threader so it still sees the GIMPLE_SWITCH. pass_dominator and pass_strlen keep their place relative to the jump threaders, so the only change is the position of pass_lower_switch. This restores the GCC 11 performance for the state machine in PR128102. gcc/ * passes.def (pass_lower_switch): Move after pass_thread_jumps_full. gcc/testsuite/ * gcc.dg/tree-ssa/pr128102.c: New test. --- gcc/passes.def | 4 +- gcc/testsuite/gcc.dg/tree-ssa/pr128102.c | 69 ++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr128102.c diff --git a/gcc/passes.def b/gcc/passes.def index 9095c134f49..64b8f8102d2 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -346,7 +346,6 @@ along with GCC; see the file COPYING3. If not see POP_INSERT_PASSES () NEXT_PASS (pass_simduid_cleanup); NEXT_PASS (pass_lower_vector_ssa); - NEXT_PASS (pass_lower_switch); NEXT_PASS (pass_cse_sincos); NEXT_PASS (pass_cse_reciprocals); NEXT_PASS (pass_reassoc, false /* early_p */); @@ -355,10 +354,13 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_fre, false /* may_iterate */); /* After late FRE we rewrite no longer addressed locals into SSA form if possible. */ + /* Thread the loop with the backward threader before lowering + switches so it still sees the GIMPLE_SWITCH. */ NEXT_PASS (pass_thread_jumps, /*first=*/false); NEXT_PASS (pass_dominator, false /* may_peel_loop_headers_p */); NEXT_PASS (pass_strlen); NEXT_PASS (pass_thread_jumps_full, /*first=*/false); + NEXT_PASS (pass_lower_switch); NEXT_PASS (pass_vrp, true /* final_p */); /* Run CCP to compute alignment and nonzero bits. */ NEXT_PASS (pass_ccp, true /* nonzero_p */); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr128102.c b/gcc/testsuite/gcc.dg/tree-ssa/pr128102.c new file mode 100644 index 00000000000..29374fc3a73 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr128102.c @@ -0,0 +1,69 @@ +/* PR tree-optimization/128102 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +typedef __SIZE_TYPE__ size_t; +typedef unsigned char u8; + +static u8 table_a2b_base64[256]; + +__attribute__ ((noinline, noclone)) size_t +decode_b64 (const u8 *restrict src, size_t len, u8 *restrict dst) +{ + u8 *out = dst; + int quad_pos = 0; + u8 leftchar = 0; + + for (size_t i = 0; i < len; i++) + { + u8 this_ch = src[i]; + + if (this_ch == '=') + continue; + + this_ch = table_a2b_base64[this_ch]; + if (this_ch >= 64) + continue; + + switch (quad_pos) + { + case 0: + quad_pos = 1; + leftchar = this_ch; + break; + case 1: + quad_pos = 2; + *out++ = (u8) ((leftchar << 2) | (this_ch >> 4)); + leftchar = this_ch & 0x0f; + break; + case 2: + quad_pos = 3; + *out++ = (u8) ((leftchar << 4) | (this_ch >> 2)); + leftchar = this_ch & 0x03; + break; + case 3: + quad_pos = 0; + *out++ = (u8) ((leftchar << 6) | this_ch); + leftchar = 0; + break; + } + } + return (size_t) (out - dst); +} + +int +main (void) +{ + static u8 src[256], dst[256]; + + for (int i = 0; i < 256; i++) + table_a2b_base64[i] = (u8) (i & 63); + + return (int) decode_b64 (src, sizeof src, dst); +} + +/* Threading the loop back edge replicates the loop body, and quad_pos + becomes a constant on every copy, so the '=' test of the source loop + is left 11 times. Without the fix the loop stays rolled and the test + appears only once. */ +/* { dg-final { scan-tree-dump-times "== 61" 11 "optimized" } } */ -- 2.34.1 From yansendao@126.com Mon Nov 2 07:48:10 2026 From: yansendao@126.com (Sendao Yan) Date: Mon, 2 Nov 2026 15:48:10 +0800 Subject: [PATCH v2 2/2] tree-optimization/128102 - fix -Wuninitialized FPs from lowering switches late In-Reply-To: <20261102074810.2976046-1-yansendao@126.com> References: <20261102074810.2976046-1-yansendao@126.com> Message-ID: <20261102074810.2976046-3-yansendao@126.com> Moving pass_lower_switch after the late jump threading changed the control flow seen by the uninitialized warning pass, exposing two false positives (PR107919 and PR44547). Both stem from the same defect in uninit_analysis::is_use_guarded. is_use_guarded treats an empty use predicate (the PHI is defined and used in the same block) as an unguarded use because init_use_preds returns false when the predicate is empty. That is wrong: whether such a use is guarded depends solely on the definition predicate, so fall through and compute it. An empty (TRUE) use predicate is then matched by m_phi_def_preds being TRUE, i.e. the value is defined on every path. Two spots made this mismatch on a TRUE use predicate: - predicate::simplify_2 folded a tautological disjunction to TRUE by clearing m_preds but forgot to set m_cval, so a definition predicate that simplified to TRUE was misread as FALSE ("never defined"). Set m_cval as well. - the fallback path only recognized an implied guard when the relaxed definition predicate was a superset of the use predicate, which is vacuous for a TRUE use predicate; simplify and normalize the relaxed predicate and, if it is TRUE (defined on every path), treat it as guarding any use, otherwise fall back to superset_of for a conditional use. gcc/ChangeLog: * gimple-predicate-analysis.cc (predicate::simplify_2): Set m_cval when a disjunction simplifies to true. (uninit_analysis::is_use_guarded): Do not return early for an empty use predicate; skip the overlap pruning and use an is_true-based superset test for an unconditional use; simplify and normalize the relaxed definition predicate in the fallback and treat a TRUE relaxed predicate as guarding any use. --- gcc/gimple-predicate-analysis.cc | 40 +++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index 6ecb1bc0387..91383ae0feb 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -1402,6 +1402,8 @@ predicate::simplify_2 () for (unsigned k = 0; k < m_preds.length (); ++k) m_preds[k].release (); m_preds.truncate (0); + /* The whole disjunction has simplified to true. */ + m_cval = true; } break; } @@ -2257,18 +2259,22 @@ uninit_analysis::is_use_guarded (gimple *use_stmt, basic_block use_bb, into its use. This will be empty if the PHI is defined and used in the same bb. */ predicate use_preds (true); - if (!init_use_preds (use_preds, def_bb, use_bb)) - return false; + init_use_preds (use_preds, def_bb, use_bb); + /* init_use_preds() returns false for an empty (unconditional) use + predicate. That does not make the use unguarded: whether it is + guarded then depends solely on the definition predicate, which is + computed below. */ use_preds.simplify (use_stmt, /*is_use=*/true); use_preds.normalize (use_stmt, /*is_use=*/true); if (use_preds.is_false ()) return true; - if (use_preds.is_true ()) - return false; - /* Try to prune the dead incoming phi edges. */ - if (!overlap (phi, opnds, visited, use_preds)) + /* Try to prune the dead incoming phi edges. This requires a non-trivial + use predicate; an unconditional use (USE_PREDS is TRUE) has nothing to + check against. */ + if (!use_preds.is_true () + && !overlap (phi, opnds, visited, use_preds)) { if (DEBUG_PREDICATE_ANALYZER && dump_file) fputs ("found predicate overlap\n", dump_file); @@ -2292,8 +2298,11 @@ uninit_analysis::is_use_guarded (gimple *use_stmt, basic_block use_bb, /* Return true if the predicate guarding the valid definition (i.e., *THIS) is a superset of the predicate guarding the use (i.e., - USE_PREDS). */ - if (m_phi_def_preds.superset_of (use_preds)) + USE_PREDS). An unconditional use (USE_PREDS is TRUE) is guarded only + if the value is defined on every path, i.e. the definition predicate + is TRUE; superset_of() is vacuous for a TRUE use predicate. */ + if (use_preds.is_true () ? m_phi_def_preds.is_true () + : m_phi_def_preds.superset_of (use_preds)) return true; /* The superset test fails when a guard that distinguishes the defined from @@ -2329,9 +2338,18 @@ uninit_analysis::is_use_guarded (gimple *use_stmt, basic_block use_bb, if (!edge_conds.is_empty ()) { predicate relaxed (m_phi_def_preds); - if (relaxed.drop_conjuncts_implied_by (edge_conds) - && relaxed.superset_of (use_preds)) - return true; + if (relaxed.drop_conjuncts_implied_by (edge_conds)) + { + relaxed.simplify (phi); + relaxed.normalize (phi); + /* A definition predicate that simplifies to TRUE guards any use; + conversely an unconditional use (USE_PREDS is TRUE) is guarded + only by a TRUE definition predicate, for which superset_of() + is vacuous. */ + if (relaxed.is_true () + || (!use_preds.is_true () && relaxed.superset_of (use_preds))) + return true; + } } return false; -- 2.34.1 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:42 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:42 -0500 Subject: [PATCH 01/25] Pass an rtx_insn * to _fatal_insn_not_found In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-2-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * rtl.h (_fatal_insn_not_found): Take a const rtx_insn *. * rtl-error.cc (_fatal_insn_not_found): Likewise. --- gcc/rtl-error.cc | 2 +- gcc/rtl.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/rtl-error.cc b/gcc/rtl-error.cc index 9ebfca111af..73f7c6d6a12 100644 --- a/gcc/rtl-error.cc +++ b/gcc/rtl-error.cc @@ -109,7 +109,7 @@ _fatal_insn (const char *msgid, const_rtx insn, const char *file, int line, } void -_fatal_insn_not_found (const_rtx insn, const char *file, int line, +_fatal_insn_not_found (const rtx_insn *insn, const char *file, int line, const char *function) { if (INSN_CODE (insn) < 0) diff --git a/gcc/rtl.h b/gcc/rtl.h index 6bc14f65747..f3c3708fbb6 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -4696,7 +4696,8 @@ extern location_t curr_insn_location (void); extern void set_insn_locations (rtx_insn *, location_t); /* rtl-error.cc */ -extern void _fatal_insn_not_found (const_rtx, const char *, int, const char *) +extern void _fatal_insn_not_found (const rtx_insn *, const char *, int, + const char *) ATTRIBUTE_NORETURN ATTRIBUTE_COLD; extern void _fatal_insn (const char *, const_rtx, const char *, int, const char *) ATTRIBUTE_NORETURN ATTRIBUTE_COLD; -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:44 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:44 -0500 Subject: [PATCH 03/25] Use label_ref_label instead of XEXP on a LABEL_REF In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-4-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * config/arm/minipool.cc (print_value): Use label_ref_label instead of XEXP on a LABEL_REF. * config/avr/avr.cc (avr_jump_mode, jump_over_one_insn_p): Likewise. * config/bfin/bfin.cc (branch_dest): Likewise. * config/csky/csky.cc (print_csky_value): Likewise. * config/frv/frv.cc (frv_print_operand_jump_hint): Likewise. * config/pa/pa.md: Likewise. * config/rs6000/rs6000.cc (rs6000_hash_constant): Likewise. * config/s390/s390.cc (s390_chunkify_start, s390_fix_long_loop_prediction): Likewise. * config/sh/sh.cc (untangle_mova, gen_block_redirect, split_branches, branch_dest, sh_mark_label): Likewise. * final.cc (shorten_branches): Likewise. --- gcc/config/arm/minipool.cc | 2 +- gcc/config/avr/avr.cc | 4 ++-- gcc/config/bfin/bfin.cc | 3 +-- gcc/config/csky/csky.cc | 2 +- gcc/config/frv/frv.cc | 2 +- gcc/config/pa/pa.md | 4 ++-- gcc/config/rs6000/rs6000.cc | 2 +- gcc/config/s390/s390.cc | 6 +++--- gcc/config/sh/sh.cc | 21 ++++++++++++--------- gcc/final.cc | 4 ++-- 10 files changed, 26 insertions(+), 24 deletions(-) diff --git a/gcc/config/arm/minipool.cc b/gcc/config/arm/minipool.cc index 0a95ae378a2..ec20ca94d34 100644 --- a/gcc/config/arm/minipool.cc +++ b/gcc/config/arm/minipool.cc @@ -390,7 +390,7 @@ print_value (FILE *f, rtx x) return; case LABEL_REF: - fprintf (f, "L%d", INSN_UID (XEXP (x, 0))); + fprintf (f, "L%d", INSN_UID (label_ref_label (x))); return; case CONST: diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index 95343ad417d..09a1e63f6c3 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -2949,7 +2949,7 @@ int avr_jump_mode (rtx x, rtx_insn *insn, int extra) { int dest_addr = INSN_ADDRESSES (INSN_UID (GET_CODE (x) == LABEL_REF - ? XEXP (x, 0) : x)); + ? label_ref_label (x) : x)); int cur_addr = INSN_ADDRESSES (INSN_UID (insn)); int jump_distance = cur_addr - dest_addr; @@ -14564,7 +14564,7 @@ bool jump_over_one_insn_p (rtx_insn *insn, rtx dest) { int uid = INSN_UID (GET_CODE (dest) == LABEL_REF - ? XEXP (dest, 0) + ? label_ref_label (dest) : dest); int jump_addr = INSN_ADDRESSES (INSN_UID (insn)); int dest_addr = INSN_ADDRESSES (uid); diff --git a/gcc/config/bfin/bfin.cc b/gcc/config/bfin/bfin.cc index 68b9cf9240c..e52df8b3ae1 100644 --- a/gcc/config/bfin/bfin.cc +++ b/gcc/config/bfin/bfin.cc @@ -2442,8 +2442,7 @@ branch_dest (rtx_insn *branch) dest = SET_SRC (pat); if (GET_CODE (dest) == IF_THEN_ELSE) dest = XEXP (dest, 1); - dest = XEXP (dest, 0); - dest_uid = INSN_UID (dest); + dest_uid = INSN_UID (label_ref_label (dest)); return INSN_ADDRESSES (dest_uid); } diff --git a/gcc/config/csky/csky.cc b/gcc/config/csky/csky.cc index eb0d3e5b0a4..8e203d54b25 100644 --- a/gcc/config/csky/csky.cc +++ b/gcc/config/csky/csky.cc @@ -1319,7 +1319,7 @@ print_csky_value (FILE *f, rtx x) return; case LABEL_REF: - fprintf (f, "L%d", INSN_UID (XEXP (x, 0))); + fprintf (f, "L%d", INSN_UID (label_ref_label (x))); return; case CONST: diff --git a/gcc/config/frv/frv.cc b/gcc/config/frv/frv.cc index cc461c8f39e..033eafb366a 100644 --- a/gcc/config/frv/frv.cc +++ b/gcc/config/frv/frv.cc @@ -2616,7 +2616,7 @@ frv_print_operand_jump_hint (rtx_insn *insn) labelref = condjump_label (insn); if (labelref) { - rtx label = XEXP (labelref, 0); + rtx_insn *label = label_ref_label (labelref); jump_type = (insn_current_address > INSN_ADDRESSES (INSN_UID (label)) ? BACKWARD : FORWARD); diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md index a7f8ff1448d..a94b2eaf8ea 100644 --- a/gcc/config/pa/pa.md +++ b/gcc/config/pa/pa.md @@ -2630,7 +2630,7 @@ /* If we're trying to load the address of a label that happens to be close, then we can use a shorter sequence. */ if (INSN_ADDRESSES_SET_P () - && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0))) + && abs (INSN_ADDRESSES (INSN_UID (label_ref_label (operands[1]))) - INSN_ADDRESSES (INSN_UID (insn))) < 8100) output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands); else @@ -2681,7 +2681,7 @@ /* If we're trying to load the address of a label that happens to be close, then we can use a shorter sequence. */ if (INSN_ADDRESSES_SET_P () - && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0))) + && abs (INSN_ADDRESSES (INSN_UID (label_ref_label (operands[1]))) - INSN_ADDRESSES (INSN_UID (insn))) < 8100) output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands); else diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 5e73f03148f..7c5b335755c 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -17524,7 +17524,7 @@ rs6000_hash_constant (rtx k) switch (code) { case LABEL_REF: - return result * 1231 + (unsigned) INSN_UID (XEXP (k, 0)); + return result * 1231 + (unsigned) INSN_UID (label_ref_label (k)); case CONST_WIDE_INT: { diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 8d10a12783f..cd952e9f880 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -10329,7 +10329,7 @@ s390_chunkify_start (void) for (i = 0; i < XVECLEN (vec_pat, diff_p); i++) { - rtx label = XEXP (XVECEXP (vec_pat, diff_p, i), 0); + rtx_insn *label = label_ref_label (XVECEXP (vec_pat, diff_p, i)); if (s390_find_pool (pool_list, label) != s390_find_pool (pool_list, insn)) @@ -14917,7 +14917,7 @@ static bool s390_fix_long_loop_prediction (rtx_insn *insn) { rtx set = single_set (insn); - rtx code_label, label_ref; + rtx label_ref; rtx_insn *uncond_jump; rtx_insn *cur_insn; rtx tmp; @@ -14945,7 +14945,7 @@ s390_fix_long_loop_prediction (rtx_insn *insn) gcc_assert (GET_CODE (label_ref) == LABEL_REF); - code_label = XEXP (label_ref, 0); + rtx_insn *code_label = label_ref_label (label_ref); if (INSN_ADDRESSES (INSN_UID (code_label)) == -1 || INSN_ADDRESSES (INSN_UID (insn)) == -1 diff --git a/gcc/config/sh/sh.cc b/gcc/config/sh/sh.cc index 71342153874..07574f9a00b 100644 --- a/gcc/config/sh/sh.cc +++ b/gcc/config/sh/sh.cc @@ -4904,7 +4904,8 @@ untangle_mova (int *num_mova, rtx_insn **first_mova, rtx_insn *new_mova) return -1; n_addr = INSN_ADDRESSES (INSN_UID (new_mova)); - n_target = INSN_ADDRESSES (INSN_UID (XEXP (MOVA_LABELREF (new_mova), 0))); + n_target = INSN_ADDRESSES + (INSN_UID (label_ref_label (MOVA_LABELREF (new_mova)))); if (n_addr > n_target || n_addr + 1022 < n_target) { /* Change the mova into a load. @@ -4920,7 +4921,8 @@ untangle_mova (int *num_mova, rtx_insn **first_mova, rtx_insn *new_mova) } if (!optimize || ((f_target - = INSN_ADDRESSES (INSN_UID (XEXP (MOVA_LABELREF (*first_mova), 0)))) + = INSN_ADDRESSES + (INSN_UID (label_ref_label (MOVA_LABELREF (*first_mova))))) >= n_target)) return -1; @@ -5500,7 +5502,7 @@ gen_block_redirect (rtx_insn *jump, int addr, int need_block) } /* We can't use JUMP_LABEL here because it might be undefined when not optimizing. */ - rtx dest = XEXP (SET_SRC (PATTERN (jump)), 0); + rtx_insn *dest = label_ref_label (SET_SRC (PATTERN (jump))); /* If the branch is out of range, try to find a scratch register for it. */ if (optimize && (INSN_ADDRESSES (INSN_UID (dest)) - addr + (unsigned) 4092 @@ -5569,13 +5571,13 @@ gen_block_redirect (rtx_insn *jump, int addr, int need_block) else if (optimize && need_block >= 0) { - rtx_insn *next = next_active_insn (as_a (dest)); + rtx_insn *next = next_active_insn (dest); next = next_active_insn (next); if (next && JUMP_P (next) && GET_CODE (PATTERN (next)) == SET && recog_memoized (next) == CODE_FOR_jump_compact) { - dest = JUMP_LABEL (next); + dest = JUMP_LABEL_AS_INSN (next); if (dest && (INSN_ADDRESSES (INSN_UID (dest)) - addr + (unsigned) 4092 > 4092 + 4098)) @@ -6472,7 +6474,8 @@ split_branches (rtx_insn *first) && GET_CODE (PATTERN (beyond)) == SET && recog_memoized (beyond) == CODE_FOR_jump_compact && ((INSN_ADDRESSES - (INSN_UID (XEXP (SET_SRC (PATTERN (beyond)), 0))) + (INSN_UID (label_ref_label + (SET_SRC (PATTERN (beyond))))) - INSN_ADDRESSES (INSN_UID (insn)) + (unsigned) 252) > 252 + 258 + 2)) gen_block_redirect (beyond, @@ -6488,7 +6491,7 @@ split_branches (rtx_insn *first) && GET_CODE (PATTERN (next)) == SET && recog_memoized (next) == CODE_FOR_jump_compact && ((INSN_ADDRESSES - (INSN_UID (XEXP (SET_SRC (PATTERN (next)), 0))) + (INSN_UID (label_ref_label (SET_SRC (PATTERN (next))))) - INSN_ADDRESSES (INSN_UID (insn)) + (unsigned) 252) > 252 + 258 + 2)) gen_block_redirect (next, INSN_ADDRESSES (INSN_UID (next)), 1); @@ -8732,7 +8735,7 @@ branch_dest (rtx branch) if (GET_CODE (dest) == IF_THEN_ELSE) dest = XEXP (dest, 1); - return INSN_ADDRESSES (INSN_UID (XEXP (dest, 0))); + return INSN_ADDRESSES (INSN_UID (label_ref_label (dest))); } /* Return nonzero if REG is not used after INSN. @@ -10653,7 +10656,7 @@ sh_mark_label (rtx address, int nuses) } if (GET_CODE (address) == LABEL_REF && LABEL_P (XEXP (address, 0))) - LABEL_NUSES (XEXP (address, 0)) += nuses; + LABEL_NUSES (label_ref_label (address)) += nuses; } /* Compute extra cost of moving data between one register class diff --git a/gcc/final.cc b/gcc/final.cc index 0204332ee34..c3c45715263 100644 --- a/gcc/final.cc +++ b/gcc/final.cc @@ -962,7 +962,7 @@ shorten_branches (rtx_insn *first) min_align = MAX_CODE_ALIGN; for (min = max_shuid, max = min_shuid, i = len - 1; i >= 0; i--) { - rtx lab = XEXP (XVECEXP (pat, 1, i), 0); + rtx_insn *lab = label_ref_label (XVECEXP (pat, 1, i)); int shuid = INSN_SHUID (lab); if (shuid < min) { @@ -982,7 +982,7 @@ shorten_branches (rtx_insn *first) XEXP (pat, 2) = gen_rtx_LABEL_REF (Pmode, min_lab); XEXP (pat, 3) = gen_rtx_LABEL_REF (Pmode, max_lab); insn_shuid = INSN_SHUID (insn); - rel = INSN_SHUID (XEXP (XEXP (pat, 0), 0)); + rel = INSN_SHUID (label_ref_label (XEXP (pat, 0))); memset (&flags, 0, sizeof (flags)); flags.min_align = min_align; flags.base_after_vec = rel > insn_shuid; -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:45 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:45 -0500 Subject: [PATCH 04/25] Use rtx_jump_insn * for locals set by emit_jump_insn_before/after In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-5-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * config/microblaze/microblaze.cc (microblaze_expand_divide): Use rtx_jump_insn * for locals set by emit_jump_insn_before or emit_jump_insn_after. * config/mips/mips.cc (mips16_lay_out_constants): Likewise. * config/mn10300/mn10300.cc (mn10300_insert_setlb_lcc): Likewise. * config/pru/pru.cc (pru_reorg_loop): Likewise. * config/s390/s390.cc (s390_fix_long_loop_prediction): Likewise. --- gcc/config/microblaze/microblaze.cc | 6 +++--- gcc/config/mips/mips.cc | 4 ++-- gcc/config/mn10300/mn10300.cc | 2 +- gcc/config/pru/pru.cc | 4 ++-- gcc/config/s390/s390.cc | 3 +-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc index 63d8064f93f..c89cba77994 100644 --- a/gcc/config/microblaze/microblaze.cc +++ b/gcc/config/microblaze/microblaze.cc @@ -3735,10 +3735,10 @@ microblaze_expand_divide (rtx operands[]) rtx div_table_rtx = gen_rtx_SYMBOL_REF (QImode,"_divsi3_table"); rtx mem_rtx; rtx ret; - rtx_insn *jump, *cjump, *insn; + rtx_insn *insn; insn = emit_insn (gen_iorsi3 (regt1, operands[1], operands[2])); - cjump = emit_jump_insn_after (gen_cbranchsi4 ( + rtx_jump_insn *cjump = emit_jump_insn_after (gen_cbranchsi4 ( gen_rtx_GTU (SImode, regt1, GEN_INT (15)), regt1, GEN_INT (15), div_label), insn); LABEL_NUSES (div_label) = 1; @@ -3752,7 +3752,7 @@ microblaze_expand_divide (rtx operands[]) insn = emit_insn (gen_movqi (regqi, mem_rtx)); insn = emit_insn (gen_movsi (operands[0], gen_rtx_SUBREG (SImode, regqi, 0))); - jump = emit_jump_insn_after (gen_jump (div_end_label), insn); + rtx_jump_insn *jump = emit_jump_insn_after (gen_jump (div_end_label), insn); JUMP_LABEL (jump) = div_end_label; LABEL_NUSES (div_end_label) = 1; emit_barrier (); diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc index e54a310b2b4..c7c3781976a 100644 --- a/gcc/config/mips/mips.cc +++ b/gcc/config/mips/mips.cc @@ -18124,11 +18124,11 @@ mips16_lay_out_constants (bool split_p) if (barrier == 0 && pool.insn_address + 4 > pool.highest_address) { rtx_code_label *label; - rtx_insn *jump; label = gen_label_rtx (); - jump = emit_jump_insn_before (gen_jump (label), insn); + rtx_jump_insn *jump + = emit_jump_insn_before (gen_jump (label), insn); JUMP_LABEL (jump) = label; LABEL_NUSES (label) = 1; barrier = emit_barrier_after (jump); diff --git a/gcc/config/mn10300/mn10300.cc b/gcc/config/mn10300/mn10300.cc index c95d126f6ec..57c7a5cc567 100644 --- a/gcc/config/mn10300/mn10300.cc +++ b/gcc/config/mn10300/mn10300.cc @@ -3193,7 +3193,7 @@ mn10300_insert_setlb_lcc (rtx_insn *label, rtx_insn *branch) else lcc = gen_Lcc (comparison, label); - rtx_insn *jump = emit_jump_insn_before (lcc, branch); + rtx_jump_insn *jump = emit_jump_insn_before (lcc, branch); mark_jump_label (XVECEXP (lcc, 0, 0), jump, 0); JUMP_LABEL (jump) = label; DUMP ("Replacing branch insn...", branch); diff --git a/gcc/config/pru/pru.cc b/gcc/config/pru/pru.cc index 80101b0f1a9..4c85bed1443 100644 --- a/gcc/config/pru/pru.cc +++ b/gcc/config/pru/pru.cc @@ -2914,8 +2914,8 @@ pru_reorg_loop (rtx_insn *insns) /* Replace the others with branches to REPEAT_LABEL. */ for (end = loop->end->next; end != 0; end = end->next) { - rtx_insn *newjmp; - newjmp = emit_jump_insn_before (gen_jump (repeat_label), end->insn); + rtx_jump_insn *newjmp + = emit_jump_insn_before (gen_jump (repeat_label), end->insn); JUMP_LABEL (newjmp) = repeat_label; delete_insn (end->insn); delete_insn (end->fallthrough); diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index cd952e9f880..11858c2f0cb 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -14918,7 +14918,6 @@ s390_fix_long_loop_prediction (rtx_insn *insn) { rtx set = single_set (insn); rtx label_ref; - rtx_insn *uncond_jump; rtx_insn *cur_insn; rtx tmp; int distance; @@ -14960,7 +14959,7 @@ s390_fix_long_loop_prediction (rtx_insn *insn) return false; rtx_code_label *new_label = gen_label_rtx (); - uncond_jump = emit_jump_insn_after ( + rtx_jump_insn *uncond_jump = emit_jump_insn_after ( gen_rtx_SET (pc_rtx, gen_rtx_LABEL_REF (VOIDmode, code_label)), insn); -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:43 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:43 -0500 Subject: [PATCH 02/25] Use rtx_code_label * for locals set by gen_label_rtx In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-3-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * calls.cc (prepare_call_address): Use rtx_code_label * for a local set only by gen_label_rtx. * config/aarch64/aarch64.cc (aarch64_expand_fp_spaceship): Likewise. * config/alpha/alpha.cc (alpha_emit_floatuns): Likewise. * config/alpha/alpha.md (@reload_out_safe_bwa, reload_out_aligned): Likewise. * config/arc/arc.cc (arc_expand_compare_and_swap_qh, arc_split_compare_and_swap, hwloop_optimize): Likewise. * config/avr/avr.cc (avr_emit_skip_clear, avr_emit_skip_pixop): Likewise. * config/avr/avr.md (flash_segment): Likewise. * config/bfin/bfin.cc (hwloop_optimize): Likewise. * config/cris/cris.cc (cris_emit_trap_for_misalignment): Likewise. * config/csky/csky.cc (csky_expand_prologue): Likewise. * config/csky/csky.md (builtin_setjmp_receiver): Likewise. * config/gcn/gcn-valu.md (fold_extract_last_): Likewise. * config/gcn/gcn.cc (gcn_expand_builtin_1): Likewise. * config/gcn/gcn.md (ti3): Likewise. * config/i386/i386-expand.cc (ix86_expand_fp_spaceship): Likewise. * config/ia64/ia64.cc (ia64_expand_atomic_op): Likewise. * config/nds32/nds32-memory-manipulation.cc (emit_setmem_byte_loop, emit_setmem_doubleword_loop, nds32_expand_cpymemsi_loop_known_size, nds32_expand_cpymemsi_loop_unknown_size, nds32_expand_setmem_loop_v3m, nds32_expand_strlen): Likewise. * config/pa/pa.cc (pa_return_addr_rtx): Likewise. * config/pa/pa.md (clear_cache): Likewise. * config/pru/pru.md (cbranchdi4): Likewise. * config/riscv/riscv-string.cc (expand_block_move, expand_rawmemchr, expand_strcmp, riscv_block_move_loop, riscv_expand_block_compare_scalar, riscv_expand_strcmp_scalar, riscv_expand_strlen_scalar): Likewise. * config/riscv/riscv-v.cc (expand_fold_extract_last, expand_mask_reduction): Likewise. * config/riscv/riscv.cc (riscv_allocate_and_probe_stack_loop): Likewise. * config/riscv/riscv.md (2, restore_stack_nonlocal): Likewise. * config/rs6000/rs6000-builtin.cc (rs6000_expand_builtin): Likewise. * config/rs6000/rs6000-call.cc (setup_incoming_varargs): Likewise. * config/rs6000/rs6000-logue.cc (emit_split_stack_prologue, rs6000_emit_load_toc_table, rs6000_emit_prologue, rs6000_expand_split_stack_prologue): Likewise. * config/rs6000/rs6000-string.cc (expand_block_compare, expand_block_compare_gpr, expand_compare_loop, expand_strn_compare): Likewise. * config/rs6000/rs6000.cc (rs6000_call_darwin_1, rs6000_generate_compare, rs6000_legitimize_tls_address): Likewise. * config/rs6000/rs6000.md (strlensi, floatdisf2, abs2): Likewise. * config/s390/s390.cc (s390_expand_vec_strlen, s390_expand_vec_movstr, s390_expand_int_spaceship, s390_expand_cstoreti4, s390_expand_fp_spaceship, s390_rawmemchr): Likewise. * config/stormy16/stormy16.cc (xstormy16_emit_cbranch): Likewise. * config/vax/builtins.md (ffs2, sync_lock_test_and_set, sync_lock_release): Likewise. * config/xtensa/xtensa.cc (xtensa_return_addr): Likewise. * explow.cc (anti_adjust_stack_and_probe_stack_clash): Likewise. * rtl-tests.cc (test_dumping_insns, test_uncond_jump): Likewise. --- gcc/calls.cc | 2 +- gcc/config/aarch64/aarch64.cc | 8 ++--- gcc/config/alpha/alpha.cc | 3 +- gcc/config/alpha/alpha.md | 4 +-- gcc/config/arc/arc.cc | 14 ++++---- gcc/config/avr/avr.cc | 4 +-- gcc/config/avr/avr.md | 2 +- gcc/config/bfin/bfin.cc | 4 +-- gcc/config/cris/cris.cc | 5 +-- gcc/config/csky/csky.cc | 2 +- gcc/config/csky/csky.md | 2 +- gcc/config/gcn/gcn-valu.md | 4 +-- gcc/config/gcn/gcn.cc | 4 +-- gcc/config/gcn/gcn.md | 2 +- gcc/config/i386/i386-expand.cc | 8 ++--- gcc/config/ia64/ia64.cc | 4 +-- gcc/config/nds32/nds32-memory-manipulation.cc | 21 +++++++----- gcc/config/pa/pa.cc | 2 +- gcc/config/pa/pa.md | 2 +- gcc/config/pru/pru.md | 6 ++-- gcc/config/riscv/riscv-string.cc | 26 +++++++------- gcc/config/riscv/riscv-v.cc | 8 ++--- gcc/config/riscv/riscv.cc | 2 +- gcc/config/riscv/riscv.md | 14 ++++---- gcc/config/rs6000/rs6000-builtin.cc | 2 +- gcc/config/rs6000/rs6000-call.cc | 2 +- gcc/config/rs6000/rs6000-logue.cc | 16 +++++---- gcc/config/rs6000/rs6000-string.cc | 34 +++++++++---------- gcc/config/rs6000/rs6000.cc | 8 ++--- gcc/config/rs6000/rs6000.md | 11 +++--- gcc/config/s390/s390.cc | 30 ++++++++-------- gcc/config/stormy16/stormy16.cc | 4 +-- gcc/config/vax/builtins.md | 8 ++--- gcc/config/xtensa/xtensa.cc | 3 +- gcc/explow.cc | 2 +- gcc/rtl-tests.cc | 4 +-- 36 files changed, 142 insertions(+), 135 deletions(-) diff --git a/gcc/calls.cc b/gcc/calls.cc index d4f66bc47f2..b7e5d74fc49 100644 --- a/gcc/calls.cc +++ b/gcc/calls.cc @@ -232,7 +232,7 @@ prepare_call_address (tree fndecl_or_type, rtx funexp, rtx static_chain_value, if ((flags & ECF_BY_DESCRIPTOR) && !flag_trampolines) { const int bit_val = targetm.calls.custom_function_descriptors; - rtx call_lab = gen_label_rtx (); + rtx_code_label *call_lab = gen_label_rtx (); gcc_assert (fndecl_or_type && TYPE_P (fndecl_or_type)); fndecl_or_type diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 5b1c78462a3..cc5950b8ebe 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -34010,10 +34010,10 @@ aarch64_expand_fp_spaceship (rtx dest, rtx op0, rtx op1, rtx hint) if (hint == const0_rtx) { - rtx un_label = gen_label_rtx (); - rtx lt_label = gen_label_rtx (); - rtx gt_label = gen_label_rtx (); - rtx end_label = gen_label_rtx (); + rtx_code_label *un_label = gen_label_rtx (); + rtx_code_label *lt_label = gen_label_rtx (); + rtx_code_label *gt_label = gen_label_rtx (); + rtx_code_label *end_label = gen_label_rtx (); rtx temp = gen_rtx_IF_THEN_ELSE (VOIDmode, cc_un, gen_rtx_LABEL_REF (Pmode, un_label), pc_rtx); diff --git a/gcc/config/alpha/alpha.cc b/gcc/config/alpha/alpha.cc index 3165a1e8d4a..6c9087910af 100644 --- a/gcc/config/alpha/alpha.cc +++ b/gcc/config/alpha/alpha.cc @@ -2560,7 +2560,8 @@ alpha_expand_movmisalign (machine_mode mode, rtx *operands) void alpha_emit_floatuns (rtx operands[2]) { - rtx neglab, donelab, i0, i1, f0, in, out; + rtx_code_label *neglab, *donelab; + rtx i0, i1, f0, in, out; machine_mode mode; out = operands[0]; diff --git a/gcc/config/alpha/alpha.md b/gcc/config/alpha/alpha.md index 269e2afe470..80bc27556bd 100644 --- a/gcc/config/alpha/alpha.md +++ b/gcc/config/alpha/alpha.md @@ -4589,7 +4589,7 @@ emit_move_insn (areg, addr); emit_move_insn (aligned_addr, gen_rtx_AND (DImode, areg, GEN_INT (-8))); - rtx label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); emit_label (label); LABEL_NUSES (label) = 1; @@ -4643,7 +4643,7 @@ get_aligned_mem (operands[0], &aligned_mem, &bitnum); if (TARGET_SAFE_BWA) { - rtx label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); emit_label (label); LABEL_NUSES (label) = 1; diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc index e1a4aa6cfc2..60419b5d661 100644 --- a/gcc/config/arc/arc.cc +++ b/gcc/config/arc/arc.cc @@ -8000,7 +8000,7 @@ hwloop_optimize (hwloop_info loop) edge entry_edge; basic_block entry_bb, bb; rtx iter_reg; - rtx_insn *insn, *seq, *entry_after, *last_insn, *end_label; + rtx_insn *insn, *seq, *entry_after, *last_insn; unsigned int length; bool need_fix = false; rtx lp_reg = gen_rtx_REG (SImode, LP_COUNT); @@ -8224,7 +8224,7 @@ hwloop_optimize (hwloop_info loop) return false; } /* The loop is good. */ - end_label = gen_label_rtx (); + rtx_code_label *end_label = gen_label_rtx (); loop->end_label = end_label; /* Place the zero_cost_loop_start instruction before the loop. */ @@ -10359,7 +10359,9 @@ arc_expand_compare_and_swap_qh (rtx bool_result, rtx result, rtx mem, rtx newvalue = gen_reg_rtx (SImode); rtx res = gen_reg_rtx (SImode); rtx resv = gen_reg_rtx (SImode); - rtx memsi, val, mask, end_label, loop_label, cc, x; + rtx memsi, val, mask; + rtx_code_label *end_label, *loop_label; + rtx cc, x; machine_mode mode; bool is_weak = (weak != const0_rtx); @@ -10529,7 +10531,7 @@ arc_split_compare_and_swap (rtx operands[]) machine_mode mode; enum memmodel mod_s, mod_f; bool is_weak; - rtx label1, label2, x, cond; + rtx x, cond; rval = operands[0]; mem = operands[1]; @@ -10545,13 +10547,13 @@ arc_split_compare_and_swap (rtx operands[]) arc_pre_atomic_barrier (mod_s); - label1 = NULL_RTX; + rtx_code_label *label1 = nullptr; if (!is_weak) { label1 = gen_label_rtx (); emit_label (label1); } - label2 = gen_label_rtx (); + rtx_code_label *label2 = gen_label_rtx (); /* Load exclusive. */ emit_insn (gen_arc_load_exclusivesi (rval, mem)); diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index f6aef849bd3..95343ad417d 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -15175,7 +15175,7 @@ avr_emit_skip_pixop (rtx_code pix, rtx dest, rtx op0, rtx op1, emit_move_insn (dest, op0); // Skip if bits.bitno bitno. - rtx xlabel = gen_label_rtx (); + rtx_code_label *xlabel = gen_label_rtx (); rtx zerox = gen_rtx_ZERO_EXTRACT (QImode, bits, const1_rtx, GEN_INT (bitno)); rtx cond = gen_rtx_fmt_ee (eqne, VOIDmode, zerox, const0_rtx); emit (gen_sbrx_branchqi_split (cond, bits, const0_rtx, xlabel)); @@ -15220,7 +15220,7 @@ avr_emit_skip_clear (rtx dest, rtx src, rtx_code eqne, rtx bits, int bitno) emit_move_insn (dest, src); // Skip if bits.bitno bitno. - rtx xlabel = gen_label_rtx (); + rtx_code_label *xlabel = gen_label_rtx (); rtx zerox = gen_rtx_ZERO_EXTRACT (QImode, bits, const1_rtx, GEN_INT (bitno)); rtx cond = gen_rtx_fmt_ee (eqne, VOIDmode, zerox, const0_rtx); emit (gen_sbrx_branchqi_split (cond, bits, const0_rtx, xlabel)); diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md index a19f387c017..f94e98c4b81 100644 --- a/gcc/config/avr/avr.md +++ b/gcc/config/avr/avr.md @@ -8646,7 +8646,7 @@ (match_operand:PSI 1 "register_operand" "")])] "" { - rtx label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); emit (gen_flash_segment1 (operands[0], operands[1], label)); emit_label (label); DONE; diff --git a/gcc/config/bfin/bfin.cc b/gcc/config/bfin/bfin.cc index c8511dde7a9..68b9cf9240c 100644 --- a/gcc/config/bfin/bfin.cc +++ b/gcc/config/bfin/bfin.cc @@ -3453,7 +3453,7 @@ hwloop_optimize (hwloop_info loop) { basic_block bb; rtx_insn *insn, *last_insn; - rtx loop_init, start_label, end_label; + rtx loop_init, start_label; rtx iter_reg, scratchreg, scratch_init; rtx_insn *scratch_init_insn; rtx lc_reg, lt_reg, lb_reg; @@ -3676,7 +3676,7 @@ hwloop_optimize (hwloop_info loop) /* The loop is good for replacement. */ start_label = loop->start_label; - end_label = gen_label_rtx (); + rtx_code_label *end_label = gen_label_rtx (); iter_reg = loop->iter_reg; if (loop->depth == 1 && !clobber1) diff --git a/gcc/config/cris/cris.cc b/gcc/config/cris/cris.cc index 2112ceb0e66..c2d6c32d400 100644 --- a/gcc/config/cris/cris.cc +++ b/gcc/config/cris/cris.cc @@ -1860,7 +1860,8 @@ cris_simple_epilogue (void) void cris_emit_trap_for_misalignment (rtx mem) { - rtx addr, reg, ok_label, andop; + rtx addr, reg; + rtx andop; rtx_insn *jmp; int natural_alignment; gcc_assert (MEM_P (mem)); @@ -1868,7 +1869,7 @@ cris_emit_trap_for_misalignment (rtx mem) natural_alignment = GET_MODE_SIZE (GET_MODE (mem)); addr = XEXP (mem, 0); reg = force_reg (Pmode, addr); - ok_label = gen_label_rtx (); + rtx_code_label *ok_label = gen_label_rtx (); /* This will yield a btstq without a separate register used, usually - with the exception for PRE hoisting the "and" but not the branch diff --git a/gcc/config/csky/csky.cc b/gcc/config/csky/csky.cc index f266ad53b5d..eb0d3e5b0a4 100644 --- a/gcc/config/csky/csky.cc +++ b/gcc/config/csky/csky.cc @@ -5789,7 +5789,7 @@ csky_expand_prologue (void) "Function Prologue for PIC". */ if (flag_pic && (reg_mask & (1 << PIC_OFFSET_TABLE_REGNUM))) { - rtx l1 = gen_label_rtx (); + rtx_code_label *l1 = gen_label_rtx (); rtx grs_label = gen_rtx_LABEL_REF (SImode, l1); rtx reg_gb = gen_rtx_REG (SImode, PIC_OFFSET_TABLE_REGNUM); rtx reg_temp = gen_rtx_REG (SImode, 13); diff --git a/gcc/config/csky/csky.md b/gcc/config/csky/csky.md index 9d6cfd429a6..dea5fd0cc2d 100644 --- a/gcc/config/csky/csky.md +++ b/gcc/config/csky/csky.md @@ -3548,7 +3548,7 @@ [(label_ref (match_operand 0 "" ""))] "flag_pic" "{ - rtx l1 = gen_label_rtx(); + rtx_code_label *l1 = gen_label_rtx (); rtx grs_label = gen_rtx_LABEL_REF (SImode, l1); rtx reg_gb = gen_rtx_REG (SImode, PIC_OFFSET_TABLE_REGNUM); rtx reg_temp = gen_rtx_REG (SImode, 12); diff --git a/gcc/config/gcn/gcn-valu.md b/gcc/config/gcn/gcn-valu.md index 9c14a489ad0..36e38ce9f2e 100644 --- a/gcc/config/gcn/gcn-valu.md +++ b/gcc/config/gcn/gcn-valu.md @@ -1091,8 +1091,8 @@ rtx default_value = operands[1]; rtx mask = operands[2]; rtx vect = operands[3]; - rtx else_label = gen_label_rtx (); - rtx end_label = gen_label_rtx (); + rtx_code_label *else_label = gen_label_rtx (); + rtx_code_label *end_label = gen_label_rtx (); rtx cond = gen_rtx_EQ (VOIDmode, mask, const0_rtx); emit_jump_insn (gen_cbranchdi4 (cond, mask, const0_rtx, else_label)); diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc index 83b1a9f9c78..93af11aa37e 100644 --- a/gcc/config/gcn/gcn.cc +++ b/gcc/config/gcn/gcn.cc @@ -4912,7 +4912,7 @@ gcn_expand_builtin_1 (tree exp, rtx target, rtx /*subtarget */ , SImode, EXPAND_NORMAL)); rtx wavefront = gcn_oacc_dim_pos (1); rtx cond = gen_rtx_NE (VOIDmode, wavefront, const0_rtx); - rtx not_zero = gen_label_rtx (); + rtx_code_label *not_zero = gen_label_rtx (); emit_insn (gen_cbranchsi4 (cond, wavefront, const0_rtx, not_zero)); emit_move_insn (blk, const0_rtx); emit_label (not_zero); @@ -5026,7 +5026,7 @@ gcn_expand_builtin_1 (tree exp, rtx target, rtx /*subtarget */ , emit_move_insn (result, const0_rtx); if (cfun->machine->args.reg[QUEUE_PTR_ARG] >= 0) { - rtx not_first = gen_label_rtx (); + rtx_code_label *not_first = gen_label_rtx (); rtx reg = gen_rtx_REG (DImode, cfun->machine->args.reg[QUEUE_PTR_ARG]); reg = gcn_operand_part (DImode, reg, 1); diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md index c014582885f..29d63425a0b 100644 --- a/gcc/config/gcn/gcn.md +++ b/gcc/config/gcn/gcn.md @@ -1847,7 +1847,7 @@ : shiftval < 64 ? SMALL : LARGE); - rtx large_label, zero_label, exit_label; + rtx_code_label *large_label, *zero_label, *exit_label; if (shiftcomparison == RUNTIME) { diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index 8a6f0280ac6..9473cc1f253 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -3187,10 +3187,10 @@ ix86_expand_fp_spaceship (rtx dest, rtx op0, rtx op1, rtx op2) && GET_MODE (dest) == SImode) zero = force_reg (SImode, const0_rtx); rtx gt = ix86_expand_fp_compare (GT, op0, op1); - rtx l0 = op2 == const0_rtx ? gen_label_rtx () : NULL_RTX; - rtx l1 = op2 == const0_rtx ? gen_label_rtx () : NULL_RTX; - rtx l2 = TARGET_IEEE_FP ? gen_label_rtx () : NULL_RTX; - rtx lend = gen_label_rtx (); + rtx_code_label *l0 = op2 == const0_rtx ? gen_label_rtx () : nullptr; + rtx_code_label *l1 = op2 == const0_rtx ? gen_label_rtx () : nullptr; + rtx_code_label *l2 = TARGET_IEEE_FP ? gen_label_rtx () : nullptr; + rtx_code_label *lend = gen_label_rtx (); rtx tmp; rtx_insn *jmp; if (l2) diff --git a/gcc/config/ia64/ia64.cc b/gcc/config/ia64/ia64.cc index 292c6b3d939..624d06f72f1 100644 --- a/gcc/config/ia64/ia64.cc +++ b/gcc/config/ia64/ia64.cc @@ -2375,7 +2375,7 @@ ia64_expand_atomic_op (enum rtx_code code, rtx mem, rtx val, rtx old_dst, rtx new_dst, enum memmodel model) { machine_mode mode = GET_MODE (mem); - rtx old_reg, new_reg, cmp_reg, ar_ccv, label; + rtx old_reg, new_reg, cmp_reg, ar_ccv; enum insn_code icode; /* Special case for using fetchadd. */ @@ -2438,7 +2438,7 @@ ia64_expand_atomic_op (enum rtx_code code, rtx mem, rtx val, old_reg = gen_reg_rtx (DImode); cmp_reg = gen_reg_rtx (DImode); - label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); if (mode != DImode) { diff --git a/gcc/config/nds32/nds32-memory-manipulation.cc b/gcc/config/nds32/nds32-memory-manipulation.cc index bc9644cd4b6..16c5ef7870e 100644 --- a/gcc/config/nds32/nds32-memory-manipulation.cc +++ b/gcc/config/nds32/nds32-memory-manipulation.cc @@ -160,7 +160,10 @@ nds32_expand_cpymemsi_loop_unknown_size (rtx dstmem, rtx srcmem, rtx dst_end; rtx size_least_3_bit; rtx double_word_end; - rtx double_word_mode_loop, byte_mode_entry, byte_mode_loop, end_label; + rtx_code_label *double_word_mode_loop; + rtx_code_label *byte_mode_entry; + rtx_code_label *byte_mode_loop; + rtx_code_label *end_label; rtx tmp; rtx mask_least_3_bit; int start_regno; @@ -261,7 +264,7 @@ nds32_expand_cpymemsi_loop_known_size (rtx dstmem, rtx srcmem, rtx dst_itr, src_itr; rtx dstmem_m, srcmem_m, dst_itr_m, src_itr_m; rtx dst_end; - rtx double_word_mode_loop, byte_mode_loop; + rtx_code_label *double_word_mode_loop, *byte_mode_loop; rtx tmp; int start_regno; bool align_to_4_bytes = (INTVAL (alignment) & 3) == 0; @@ -632,8 +635,8 @@ nds32_gen_dup_8_byte_to_double_word_value (rtx value) static rtx emit_setmem_doubleword_loop (rtx itr, rtx size, rtx value) { - rtx word_mode_label = gen_label_rtx (); - rtx word_mode_end_label = gen_label_rtx (); + rtx_code_label *word_mode_label = gen_label_rtx (); + rtx_code_label *word_mode_end_label = gen_label_rtx (); rtx byte_mode_size = gen_reg_rtx (SImode); rtx byte_mode_size_tmp = gen_reg_rtx (SImode); rtx word_mode_end = gen_reg_rtx (SImode); @@ -679,8 +682,8 @@ static rtx emit_setmem_byte_loop (rtx itr, rtx size, rtx value, bool need_end) { rtx end = gen_reg_rtx (Pmode); - rtx byte_mode_label = gen_label_rtx (); - rtx end_label = gen_label_rtx (); + rtx_code_label *byte_mode_label = gen_label_rtx (); + rtx_code_label *end_label = gen_label_rtx (); value = force_reg (QImode, value); @@ -805,7 +808,7 @@ nds32_expand_setmem_loop_v3m (rtx dstmem, rtx size, rtx value) rtx new_base_reg; rtx value4byte, value4doubleword; rtx byte_mode_size; - rtx last_byte_loop_label = gen_label_rtx (); + rtx_code_label *last_byte_loop_label = gen_label_rtx (); size = force_reg (SImode, size); @@ -1010,7 +1013,7 @@ nds32_expand_strlen (rtx result, rtx str, rtx base_reg, backup_base_reg; rtx ffb_result; rtx target_char_ptr, length; - rtx loop_label, tmp; + rtx tmp; if (optimize_size || optimize < 3) return false; @@ -1019,7 +1022,7 @@ nds32_expand_strlen (rtx result, rtx str, gcc_assert (CONST_INT_P (target_char) || REG_P (target_char)); base_reg = copy_to_mode_reg (SImode, XEXP (str, 0)); - loop_label = gen_label_rtx (); + rtx_code_label *loop_label = gen_label_rtx (); ffb_result = gen_reg_rtx (Pmode); tmp = gen_reg_rtx (SImode); diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc index d6576812574..90ca2a23950 100644 --- a/gcc/config/pa/pa.cc +++ b/gcc/config/pa/pa.cc @@ -5065,7 +5065,7 @@ hppa_profile_hook (int label_no) rtx pa_return_addr_rtx (int count, rtx frameaddr) { - rtx label; + rtx_code_label *label; rtx rp; rtx saved_rp; rtx ins; diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md index e91522ea9cc..a7f8ff1448d 100644 --- a/gcc/config/pa/pa.md +++ b/gcc/config/pa/pa.md @@ -10029,7 +10029,7 @@ add,l %2,%3,%3\;bv,n %%r0(%3)" { rtx start = gen_reg_rtx (Pmode); rtx line_size = gen_reg_rtx (Pmode); - rtx lab = gen_label_rtx (); + rtx_code_label *lab = gen_label_rtx (); rtx op0 = operands[0]; rtx op1 = operands[1]; diff --git a/gcc/config/pru/pru.md b/gcc/config/pru/pru.md index 93638963d29..4c3c9c554c0 100644 --- a/gcc/config/pru/pru.md +++ b/gcc/config/pru/pru.md @@ -1627,7 +1627,7 @@ if (code == EQ) { - rtx label_fallthrough = gen_label_rtx (); + rtx_code_label *label_fallthrough = gen_label_rtx (); rtx label_fallthrough_ref = gen_rtx_LABEL_REF (Pmode, label_fallthrough); rtx cond_hi = gen_rtx_fmt_ee (NE, VOIDmode, op1_hi, op2_hi); @@ -1682,7 +1682,7 @@ LABEL_NUSES (label3)++; /* Check for "DI comparison obviously not true". */ - rtx label_fallthrough = gen_label_rtx (); + rtx_code_label *label_fallthrough = gen_label_rtx (); rtx label_fallthrough_ref = gen_rtx_LABEL_REF (Pmode, label_fallthrough); rtx cond_hine = gen_rtx_fmt_ee (NE, VOIDmode, op1_hi, op2_hi); rtx check_hine = gen_rtx_IF_THEN_ELSE (VOIDmode, cond_hine, @@ -1709,7 +1709,7 @@ { /* Check for "DI comparison obviously not true". */ const enum rtx_code reversed_code = reverse_condition (code); - rtx label_fallthrough = gen_label_rtx (); + rtx_code_label *label_fallthrough = gen_label_rtx (); rtx label_fallthrough_ref = gen_rtx_LABEL_REF (Pmode, label_fallthrough); rtx cond_hi = gen_rtx_fmt_ee (pru_noteq_condition (reversed_code), VOIDmode, op1_hi, op2_hi); diff --git a/gcc/config/riscv/riscv-string.cc b/gcc/config/riscv/riscv-string.cc index 5ca9f4e1f82..e1ce5929219 100644 --- a/gcc/config/riscv/riscv-string.cc +++ b/gcc/config/riscv/riscv-string.cc @@ -426,9 +426,9 @@ riscv_expand_strcmp_scalar (rtx result, rtx src1, rtx src2, rtx data1 = gen_reg_rtx (Xmode); rtx data2 = gen_reg_rtx (Xmode); rtx orc1 = gen_reg_rtx (Xmode); - rtx nonul_end_label = gen_label_rtx (); - rtx end_label = gen_label_rtx (); - rtx final_label = gen_label_rtx (); + rtx_code_label *nonul_end_label = gen_label_rtx (); + rtx_code_label *end_label = gen_label_rtx (); + rtx_code_label *final_label = gen_label_rtx (); /* Generate a sequence of zbb instructions to compare out to the length specified. */ @@ -546,7 +546,7 @@ static bool riscv_expand_strlen_scalar (rtx result, rtx src, rtx align) { rtx testval, addr, addr_plus_regsz, word, zeros; - rtx loop_label, cond; + rtx cond; gcc_assert (TARGET_ZBB || TARGET_XTHEADBB); @@ -567,7 +567,7 @@ riscv_expand_strlen_scalar (rtx result, rtx src, rtx align) do_add3 (addr_plus_regsz, addr, GEN_INT (UNITS_PER_WORD)); - loop_label = gen_label_rtx (); + rtx_code_label *loop_label = gen_label_rtx (); emit_label (loop_label); /* Load a word and use orc.b/th.tstnbz to find a zero-byte. */ @@ -761,8 +761,8 @@ riscv_expand_block_compare_scalar (rtx result, rtx src1, rtx src2, rtx nbytes) rtx data1 = gen_reg_rtx (Xmode); rtx data2 = gen_reg_rtx (Xmode); - rtx diff_label = gen_label_rtx (); - rtx final_label = gen_label_rtx (); + rtx_code_label *diff_label = gen_label_rtx (); + rtx_code_label *final_label = gen_label_rtx (); /* Generate a sequence of zbb instructions to compare out to the length specified. */ @@ -912,7 +912,7 @@ riscv_block_move_loop (rtx dest, rtx src, unsigned HOST_WIDE_INT length, unsigned HOST_WIDE_INT align, unsigned HOST_WIDE_INT bytes_per_iter) { - rtx label, src_reg, dest_reg, final_src, test; + rtx src_reg, dest_reg, final_src, test; unsigned HOST_WIDE_INT leftover; leftover = length % bytes_per_iter; @@ -928,7 +928,7 @@ riscv_block_move_loop (rtx dest, rtx src, unsigned HOST_WIDE_INT length, 0, 0, OPTAB_WIDEN); /* Emit the start of the loop. */ - label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); emit_label (label); /* Emit the loop body. */ @@ -1459,7 +1459,7 @@ expand_block_move (rtx dst_in, rtx src_in, rtx length_in, bool overlap_p) /* avl holds the (remaining) length of the required copy. cnt holds the length we copy with the current load/store pair. */ rtx cnt = info.avl; - rtx label = NULL_RTX; + rtx_code_label *label = nullptr; rtx dst_addr = copy_addr_to_reg (XEXP (dst_in, 0)); rtx src_addr = copy_addr_to_reg (XEXP (src_in, 0)); @@ -1575,7 +1575,7 @@ expand_rawmemchr (machine_mode mode, rtx dst, rtx haystack, rtx needle, rtx src_addr = copy_addr_to_reg (XEXP (haystack, 0)); rtx start_addr = copy_addr_to_reg (XEXP (haystack, 0)); - rtx loop = gen_label_rtx (); + rtx_code_label *loop = gen_label_rtx (); emit_label (loop); rtx vsrc = change_address (haystack, vmode, src_addr); @@ -1676,8 +1676,8 @@ expand_strcmp (rtx result, rtx src1, rtx src2, rtx nbytes, rtx vec1 = gen_reg_rtx (vmode); rtx vec2 = gen_reg_rtx (vmode); - rtx done = gen_label_rtx (); - rtx loop = gen_label_rtx (); + rtx_code_label *done = gen_label_rtx (); + rtx_code_label *loop = gen_label_rtx (); emit_label (loop); /* Bump the pointers. */ diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc index 7cccc09dc22..f3df248d2fc 100644 --- a/gcc/config/riscv/riscv-v.cc +++ b/gcc/config/riscv/riscv-v.cc @@ -5074,8 +5074,8 @@ expand_mask_reduction (rtx *ops, rtx_code code) else gcc_unreachable (); - rtx els = gen_label_rtx (); - rtx end = gen_label_rtx (); + rtx_code_label *els = gen_label_rtx (); + rtx_code_label *end = gen_label_rtx (); riscv_expand_conditional_branch (els, eq_zero ? EQ : NE, tmp, const0_rtx); emit_move_insn (dest, const0_rtx); @@ -5184,8 +5184,8 @@ expand_fold_extract_last (rtx *ops) rtx anchor = gen_reg_rtx (Pmode); rtx index = gen_reg_rtx (Pmode); rtx vect = ops[3]; - rtx else_label = gen_label_rtx (); - rtx end_label = gen_label_rtx (); + rtx_code_label *else_label = gen_label_rtx (); + rtx_code_label *end_label = gen_label_rtx (); rtx len = ops[4]; machine_mode mode = GET_MODE (vect); machine_mode mask_mode = GET_MODE (mask); diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index ec3a0342196..2adeec1492e 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -10246,7 +10246,7 @@ riscv_allocate_and_probe_stack_loop (rtx tmp, enum rtx_code code, tmp = riscv_force_temporary (tmp, gen_int_mode (offset, Pmode)); /* Loop. */ - rtx label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); emit_label (label); /* Allocate and probe stack. */ diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index da6394d1ae6..31d2d098444 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -2331,10 +2331,10 @@ else { rtx reg; - rtx label1 = gen_label_rtx (); - rtx label2 = gen_label_rtx (); - rtx label3 = gen_label_rtx (); - rtx end_label = gen_label_rtx (); + rtx_code_label *label1 = gen_label_rtx (); + rtx_code_label *label2 = gen_label_rtx (); + rtx_code_label *label3 = gen_label_rtx (); + rtx_code_label *end_label = gen_label_rtx (); rtx abs_reg = gen_reg_rtx (mode); rtx coeff_reg = gen_reg_rtx (mode); rtx tmp_reg = gen_reg_rtx (mode); @@ -4571,11 +4571,11 @@ emit_insn (gen_ssrdp (word_mode, cur_ssp)); /* Compare and jump over adjustment code. */ - rtx noadj_label = gen_label_rtx (); + rtx_code_label *noadj_label = gen_label_rtx (); emit_cmp_and_jump_insns (cur_ssp, const0_rtx, EQ, NULL_RTX, word_mode, 1, noadj_label); - rtx loop_label = gen_label_rtx (); + rtx_code_label *loop_label = gen_label_rtx (); emit_label (loop_label); LABEL_NUSES (loop_label) = 1; @@ -4599,7 +4599,7 @@ emit_barrier (); /* Adjust the ssp in a loop. */ - rtx cmp_4k_label = gen_label_rtx (); + rtx_code_label *cmp_4k_label = gen_label_rtx (); emit_label (cmp_4k_label); LABEL_NUSES (cmp_4k_label) = 1; diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc index f5f823074c6..33c82b94952 100644 --- a/gcc/config/rs6000/rs6000-builtin.cc +++ b/gcc/config/rs6000/rs6000-builtin.cc @@ -3534,7 +3534,7 @@ rs6000_expand_builtin (tree exp, rtx target, rtx /* subtarget */, error ("invalid arguments to builtin"); // Create a label for the end of the function. - rtx done_label = gen_label_rtx (); + rtx_code_label *done_label = gen_label_rtx (); /* Standard Semantics: Update 'expected' ONLY on failure. If target (the boolean result) is NOT 0, the CAS succeeded. diff --git a/gcc/config/rs6000/rs6000-call.cc b/gcc/config/rs6000/rs6000-call.cc index 3f9629514a5..742751465fa 100644 --- a/gcc/config/rs6000/rs6000-call.cc +++ b/gcc/config/rs6000/rs6000-call.cc @@ -2410,7 +2410,7 @@ setup_incoming_varargs (cumulative_args_t cum, { int fregno = next_cum.fregno, nregs; rtx cr1 = gen_rtx_REG (CCmode, CR1_REGNO); - rtx lab = gen_label_rtx (); + rtx_code_label *lab = gen_label_rtx (); int off = (GP_ARG_NUM_REG * reg_size) + ((fregno - FP_ARG_MIN_REG) * UNITS_PER_FP_WORD); diff --git a/gcc/config/rs6000/rs6000-logue.cc b/gcc/config/rs6000/rs6000-logue.cc index 960280caff0..4c0b939d43c 100644 --- a/gcc/config/rs6000/rs6000-logue.cc +++ b/gcc/config/rs6000/rs6000-logue.cc @@ -1303,11 +1303,11 @@ rs6000_emit_load_toc_table (int fromprolog) } else { - rtx tocsym, lab; + rtx tocsym; tocsym = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (toc_label_name)); need_toc_init = 1; - lab = gen_label_rtx (); + rtx_code_label *lab = gen_label_rtx (); emit_insn (gen_load_toc_v4_PIC_1b (tocsym, lab)); emit_move_insn (dest, gen_rtx_REG (Pmode, LR_REGNO)); if (TARGET_LINK_STACK) @@ -2973,7 +2973,7 @@ emit_split_stack_prologue (rs6000_stack_t *info, rtx_insn *sp_adjust, rtx r12 = gen_rtx_REG (Pmode, 12); rtx r29 = gen_rtx_REG (Pmode, 29); rtx cr7 = gen_rtx_REG (CCUNSmode, CR7_REGNO); - rtx not_more = gen_label_rtx (); + rtx_code_label *not_more = gen_label_rtx (); rtx jump; jump = gen_rtx_IF_THEN_ELSE (VOIDmode, @@ -3449,7 +3449,8 @@ rs6000_emit_prologue (void) /* In AIX ABI we need to make sure r2 is really saved. */ if (TARGET_AIX && crtl->calls_eh_return) { - rtx tmp_reg, tmp_reg_si, hi, lo, compare_result, toc_save_done, jump; + rtx tmp_reg, tmp_reg_si, hi, lo, compare_result; + rtx jump; rtx join_insn, note; rtx_insn *save_insn; long toc_restore_insn; @@ -3479,7 +3480,7 @@ rs6000_emit_prologue (void) lo = gen_int_mode (toc_restore_insn & 0xffff, SImode); emit_insn (gen_rtx_SET (compare_result, gen_rtx_COMPARE (CCUNSmode, tmp_reg_si, lo))); - toc_save_done = gen_label_rtx (); + rtx_code_label *toc_save_done = gen_label_rtx (); jump = gen_rtx_IF_THEN_ELSE (VOIDmode, gen_rtx_EQ (VOIDmode, compare_result, const0_rtx), @@ -5551,7 +5552,8 @@ rs6000_expand_split_stack_prologue (void) rs6000_stack_t *info = rs6000_stack_info (); unsigned HOST_WIDE_INT allocate; long alloc_hi, alloc_lo; - rtx r0, r1, r12, lr, ok_label, compare, jump, call_fusage; + rtx r0, r1, r12, lr; + rtx compare, jump, call_fusage; rtx_insn *insn; gcc_assert (flag_split_stack && reload_completed); @@ -5616,7 +5618,7 @@ rs6000_expand_split_stack_prologue (void) compare = gen_rtx_REG (CCUNSmode, CR7_REGNO); emit_insn (gen_rtx_SET (compare, gen_rtx_COMPARE (CCUNSmode, r12, r0))); - ok_label = gen_label_rtx (); + rtx_code_label *ok_label = gen_label_rtx (); jump = gen_rtx_IF_THEN_ELSE (VOIDmode, gen_rtx_GEU (VOIDmode, compare, const0_rtx), gen_rtx_LABEL_REF (VOIDmode, ok_label), diff --git a/gcc/config/rs6000/rs6000-string.cc b/gcc/config/rs6000/rs6000-string.cc index 062ff1e2465..ee10e447417 100644 --- a/gcc/config/rs6000/rs6000-string.cc +++ b/gcc/config/rs6000/rs6000-string.cc @@ -1030,11 +1030,11 @@ expand_compare_loop (rtx operands[]) return false; bool no_remainder_code = false; - rtx final_label = gen_label_rtx (); + rtx_code_label *final_label = gen_label_rtx (); rtx final_ref = gen_rtx_LABEL_REF (VOIDmode, final_label); - rtx diff_label = gen_label_rtx (); - rtx library_call_label = NULL; - rtx cleanup_label = gen_label_rtx (); + rtx_code_label *diff_label = gen_label_rtx (); + rtx_code_label *library_call_label = nullptr; + rtx_code_label *cleanup_label = gen_label_rtx (); rtx cr; @@ -1170,7 +1170,7 @@ expand_compare_loop (rtx operands[]) } else { - rtx lab_after = gen_label_rtx (); + rtx_code_label *lab_after = gen_label_rtx (); do_ifelse (CCmode, LE, bytes_rtx, GEN_INT (max_bytes), NULL_RTX, lab_after, profile_probability::even ()); emit_move_insn (loop_cmp, mb_reg); @@ -1206,7 +1206,7 @@ expand_compare_loop (rtx operands[]) emit_move_insn (iv2, GEN_INT (load_mode_size)); /* inner loop to compare 2*word_mode */ - rtx loop_top_label = gen_label_rtx (); + rtx_code_label *loop_top_label = gen_label_rtx (); emit_label (loop_top_label); rtx src1_ix1 = gen_rtx_PLUS (word_mode, src1_addr, iv1); @@ -1330,7 +1330,7 @@ expand_compare_loop (rtx operands[]) NULL_RTX, final_label, profile_probability::unlikely ()); } - rtx final_cleanup = gen_label_rtx (); + rtx_code_label *final_cleanup = gen_label_rtx (); rtx cmp_rem_before = gen_reg_rtx (word_mode); /* Compare one more word_mode chunk if needed. */ if (!bytes_is_const || bytes_remaining >= load_mode_size) @@ -1426,8 +1426,8 @@ expand_compare_loop (rtx operands[]) } else if (!bytes_is_const) { - rtx handle4k_label = gen_label_rtx (); - rtx nonconst_overlap = gen_label_rtx (); + rtx_code_label *handle4k_label = gen_label_rtx (); + rtx_code_label *nonconst_overlap = gen_label_rtx (); emit_label (nonconst_overlap); /* Here we have to handle the case where we have runtime @@ -1508,7 +1508,7 @@ expand_compare_loop (rtx operands[]) rtx d1 = gen_reg_rtx (word_mode); rtx d2 = gen_reg_rtx (word_mode); - rtx fc_loop = gen_label_rtx (); + rtx_code_label *fc_loop = gen_label_rtx (); emit_label (fc_loop); do_load_for_compare_from_addr (QImode, d1, src1_ix, orig_src1); @@ -1739,8 +1739,8 @@ expand_block_compare_gpr(unsigned HOST_WIDE_INT bytes, unsigned int base_align, rtx tmp_reg_src1 = gen_reg_rtx (word_mode); rtx tmp_reg_src2 = gen_reg_rtx (word_mode); bool need_6432_conv = false; - rtx convert_label = NULL; - rtx final_label = NULL; + rtx_code_label *convert_label = nullptr; + rtx_code_label *final_label = nullptr; machine_mode load_mode; while (bytes > 0) @@ -2025,7 +2025,7 @@ expand_block_compare (rtx operands[]) if (use_vec) { - rtx final_move_label = gen_label_rtx (); + rtx_code_label *final_move_label = gen_label_rtx (); rtx s1addr = gen_reg_rtx (Pmode); rtx s2addr = gen_reg_rtx (Pmode); rtx off_reg = gen_reg_rtx (Pmode); @@ -2517,15 +2517,15 @@ expand_strn_compare (rtx operands[], int no_length) } rtx result_reg = gen_reg_rtx (word_mode); - rtx final_move_label = gen_label_rtx (); - rtx final_label = gen_label_rtx (); - rtx begin_compare_label = NULL; + rtx_code_label *final_move_label = gen_label_rtx (); + rtx_code_label *final_label = gen_label_rtx (); + rtx_code_label *begin_compare_label = nullptr; if (base_align < required_align) { /* Generate code that checks distance to 4k boundary for this case. */ begin_compare_label = gen_label_rtx (); - rtx strncmp_label = gen_label_rtx (); + rtx_code_label *strncmp_label = gen_label_rtx (); rtx jmp; /* Strncmp for power8 in glibc does this: diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 2002abb96ba..5e73f03148f 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -9795,12 +9795,12 @@ rs6000_legitimize_tls_address (rtx addr, enum tls_model model) rs6000_emit_move (got, gsym, Pmode); else { - rtx mem, lab; + rtx mem; tmp1 = gen_reg_rtx (Pmode); tmp2 = gen_reg_rtx (Pmode); mem = gen_const_mem (Pmode, tmp1); - lab = gen_label_rtx (); + rtx_code_label *lab = gen_label_rtx (); emit_insn (gen_load_toc_v4_PIC_1b (gsym, lab)); emit_move_insn (tmp1, gen_rtx_REG (Pmode, LR_REGNO)); if (TARGET_LINK_STACK) @@ -15646,7 +15646,7 @@ rs6000_generate_compare (rtx cmp, machine_mode mode) { rtx ne_rtx, normal_dest, unord_dest; rtx unord_func = optab_libfunc (unord_optab, mode); - rtx join_label = gen_label_rtx (); + rtx_code_label *join_label = gen_label_rtx (); rtx join_ref = gen_rtx_LABEL_REF (VOIDmode, join_label); rtx unord_cmp = gen_reg_rtx (comp_mode); @@ -26639,7 +26639,7 @@ rs6000_call_darwin_1 (rtx value, rtx func_desc, rtx tlsarg, if (no_previous_def (funname)) { - rtx label_rtx = gen_label_rtx (); + rtx_code_label *label_rtx = gen_label_rtx (); char *label_buf, temp_buf[256]; ASM_GENERATE_INTERNAL_LABEL (temp_buf, "L", CODE_LABEL_NUMBER (label_rtx)); diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index c9727f2e6d8..60751c3f174 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -1827,7 +1827,7 @@ rtx search_char = operands[2]; rtx align = operands[3]; rtx addr, scratch_string, word1, word2, scratch_dlmzb; - rtx loop_label, end_label, mem, cr0, cond; + rtx mem, cr0, cond; if (search_char != const0_rtx || !CONST_INT_P (align) || INTVAL (align) < 8) @@ -1836,8 +1836,8 @@ word2 = gen_reg_rtx (SImode); scratch_dlmzb = gen_reg_rtx (SImode); scratch_string = gen_reg_rtx (Pmode); - loop_label = gen_label_rtx (); - end_label = gen_label_rtx (); + rtx_code_label *loop_label = gen_label_rtx (); + rtx_code_label *end_label = gen_label_rtx (); addr = force_reg (Pmode, XEXP (src, 0)); emit_move_insn (scratch_string, addr); emit_label (loop_label); @@ -7174,7 +7174,7 @@ rtx val = operands[1]; if (!flag_unsafe_math_optimizations) { - rtx label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); val = gen_reg_rtx (DImode); emit_insn (gen_floatdisf2_internal2 (val, operands[1], label)); emit_label (label); @@ -9371,7 +9371,6 @@ "FLOAT128_IEEE_P (mode) || (FLOAT128_IBM_P (mode) && TARGET_HARD_FLOAT)" { - rtx label; if (FLOAT128_IEEE_P (mode)) { @@ -9390,7 +9389,7 @@ FAIL; } - label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); emit_insn (gen_abs2_internal (mode, operands[0], operands[1], label)); emit_label (label); DONE; diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 61ca55161f9..8d10a12783f 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -6668,9 +6668,9 @@ s390_expand_vec_strlen (rtx target, rtx string, rtx alignment) rtx str_addr_base_reg = gen_reg_rtx (Pmode); rtx str_idx_reg = gen_reg_rtx (Pmode); rtx result_reg = gen_reg_rtx (V16QImode); - rtx is_aligned_label = gen_label_rtx (); - rtx into_loop_label = NULL_RTX; - rtx loop_start_label = gen_label_rtx (); + rtx_code_label *is_aligned_label = gen_label_rtx (); + rtx_code_label *into_loop_label = nullptr; + rtx_code_label *loop_start_label = gen_label_rtx (); rtx temp; rtx len = gen_reg_rtx (QImode); rtx cond; @@ -6779,10 +6779,10 @@ s390_expand_vec_movstr (rtx result, rtx dst, rtx src) rtx loadlen = gen_reg_rtx (SImode); rtx gpos_qi = gen_reg_rtx(QImode); rtx gpos = gen_reg_rtx (SImode); - rtx done_label = gen_label_rtx (); - rtx loop_label = gen_label_rtx (); - rtx exit_label = gen_label_rtx (); - rtx full_label = gen_label_rtx (); + rtx_code_label *done_label = gen_label_rtx (); + rtx_code_label *loop_label = gen_label_rtx (); + rtx_code_label *exit_label = gen_label_rtx (); + rtx_code_label *full_label = gen_label_rtx (); /* Perform a quick check for string ending on the first up to 16 bytes and exit early if successful. */ @@ -7318,7 +7318,7 @@ s390_expand_cstoreti4 (rtx dst, rtx cmp, rtx op1, rtx op2) gen_rtx_VEC_SELECT (DImode, op1, lane0), gen_rtx_VEC_SELECT (DImode, op2, lane0)))); rtx ccs_reg = gen_rtx_REG (CCSmode, CC_REGNUM); - rtx lab = gen_label_rtx (); + rtx_code_label *lab = gen_label_rtx (); s390_emit_jump (lab, gen_rtx_NE (VOIDmode, ccs_reg, const0_rtx)); /* At this point we have that high(op1) == high(op2). Thus, test the low part, now. For unsigned comparisons @@ -8299,7 +8299,7 @@ s390_expand_int_spaceship (rtx op0, rtx op1, rtx op2, rtx op3) = force_reg (V2DImode, simplify_gen_subreg (V2DImode, op1, TImode, 0)); op2 = force_reg (V2DImode, simplify_gen_subreg (V2DImode, op2, TImode, 0)); - rtx lab = gen_label_rtx (); + rtx_code_label *lab = gen_label_rtx (); rtx ccz = gen_rtx_REG (CCZmode, CC_REGNUM); /* Compare high halves for equality. VEC[L]G op1, op2 sets @@ -8398,10 +8398,10 @@ s390_expand_fp_spaceship (rtx op0, rtx op1, rtx op2, rtx op3) rtx cond_eq = gen_rtx_EQ (mode, cc_reg, const0_rtx); rtx cond_gt = gen_rtx_GT (mode, cc_reg, const0_rtx); rtx_insn *insn; - rtx l_unordered = gen_label_rtx (); - rtx l_eq = gen_label_rtx (); - rtx l_gt = gen_label_rtx (); - rtx l_end = gen_label_rtx (); + rtx_code_label *l_unordered = gen_label_rtx (); + rtx_code_label *l_eq = gen_label_rtx (); + rtx_code_label *l_gt = gen_label_rtx (); + rtx_code_label *l_end = gen_label_rtx (); s390_emit_compare (VOIDmode, LTGT, op1, op2); if (!flag_finite_math_only) @@ -17325,8 +17325,8 @@ s390_rawmemchr (machine_mode elt_mode, rtx dst, rtx src, rtx pat) 16 / GET_MODE_SIZE (elt_mode)).require(); rtx lens = gen_reg_rtx (V16QImode); rtx pattern = gen_reg_rtx (vec_mode); - rtx loop_start = gen_label_rtx (); - rtx loop_end = gen_label_rtx (); + rtx_code_label *loop_start = gen_label_rtx (); + rtx_code_label *loop_end = gen_label_rtx (); rtx addr = gen_reg_rtx (Pmode); rtx offset = gen_reg_rtx (Pmode); rtx loadlen = gen_reg_rtx (SImode); diff --git a/gcc/config/stormy16/stormy16.cc b/gcc/config/stormy16/stormy16.cc index 7ea8327aa41..67ca65ebcad 100644 --- a/gcc/config/stormy16/stormy16.cc +++ b/gcc/config/stormy16/stormy16.cc @@ -311,7 +311,7 @@ xstormy16_emit_cbranch (enum rtx_code code, rtx op0, rtx op1, rtx loc) { int unsigned_p = (code == GTU || code == LEU); int gt_p = (code == GT || code == GTU); - rtx lab = NULL_RTX; + rtx_code_label *lab = nullptr; if (gt_p) lab = gen_label_rtx (); @@ -328,7 +328,7 @@ xstormy16_emit_cbranch (enum rtx_code code, rtx op0, rtx op1, rtx loc) && op1 != const0_rtx) { rtx op0_word, op1_word; - rtx lab = NULL_RTX; + rtx_code_label *lab = nullptr; int num_words = GET_MODE_BITSIZE (mode) / BITS_PER_WORD; int i; diff --git a/gcc/config/vax/builtins.md b/gcc/config/vax/builtins.md index 45f45046062..2af0cbbee1a 100644 --- a/gcc/config/vax/builtins.md +++ b/gcc/config/vax/builtins.md @@ -37,7 +37,7 @@ "" " { - rtx label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label); rtx cond = gen_rtx_NE (VOIDmode, operands[1], const0_rtx); rtx target = gen_rtx_IF_THEN_ELSE (VOIDmode, cond, label_ref, pc_rtx); @@ -167,12 +167,11 @@ "" " { - rtx label; if (operands[2] != const1_rtx) FAIL; - label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); emit_move_insn (operands[0], const1_rtx); emit_jump_insn (gen_jbbssi (operands[1], const0_rtx, label)); emit_move_insn (operands[0], const0_rtx); @@ -186,12 +185,11 @@ "" " { - rtx label; if (operands[1] != const0_rtx) FAIL; - label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); emit_jump_insn (gen_jbbcci (operands[0], const0_rtx, label)); emit_label (label); DONE; diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index d0a5042ba2d..6e2e575acb3 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -4019,7 +4019,8 @@ xtensa_set_return_address (rtx address, rtx scratch) rtx xtensa_return_addr (int count, rtx frame) { - rtx result, retaddr, curaddr, label; + rtx result, retaddr, curaddr; + rtx_code_label *label; if (!TARGET_WINDOWED_ABI) { diff --git a/gcc/explow.cc b/gcc/explow.cc index 6acecc701c7..134771446aa 100644 --- a/gcc/explow.cc +++ b/gcc/explow.cc @@ -2143,7 +2143,7 @@ anti_adjust_stack_and_probe_stack_clash (rtx size) if (residual != CONST0_RTX (Pmode)) { - rtx label = NULL_RTX; + rtx_code_label *label = nullptr; /* RESIDUAL could be zero at runtime and in that case *sp could hold live data. Furthermore, we do not want to probe into the red zone. diff --git a/gcc/rtl-tests.cc b/gcc/rtl-tests.cc index a0c6661818d..fe7f9e3dda0 100644 --- a/gcc/rtl-tests.cc +++ b/gcc/rtl-tests.cc @@ -119,7 +119,7 @@ test_dumping_insns () ASSERT_RTL_DUMP_EQ ("(cbarrier 0)\n", barrier); /* Labels. */ - rtx_insn *label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); CODE_LABEL_NUMBER (label) = 42; ASSERT_RTL_DUMP_EQ ("(clabel 0 42)\n", label); @@ -199,7 +199,7 @@ static void test_uncond_jump () { set_new_first_and_last_insn (NULL, NULL); - rtx_insn *label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); rtx jump_pat = gen_rtx_SET (pc_rtx, gen_rtx_LABEL_REF (VOIDmode, label)); -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:47 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:47 -0500 Subject: [PATCH 06/25] Pass an rtx_insn * to find_reg_equal_equiv_note In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-7-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * rtl.h (find_reg_equal_equiv_note): Take a const rtx_insn *. * rtlanal.cc (find_reg_equal_equiv_note): Likewise. * cse.cc (count_reg_usage): Pass an rtx_insn * from the insn arm. --- gcc/cse.cc | 2 +- gcc/rtl.h | 2 +- gcc/rtlanal.cc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/cse.cc b/gcc/cse.cc index d3ada53db3e..230f4706a8e 100644 --- a/gcc/cse.cc +++ b/gcc/cse.cc @@ -7165,7 +7165,7 @@ count_reg_usage (rtx x, int *counts, rtx dest, int incr) /* Things used in a REG_EQUAL note aren't dead since loop may try to use them. */ - note = find_reg_equal_equiv_note (x); + note = find_reg_equal_equiv_note (as_a (x)); if (note) { rtx eqv = XEXP (note, 0); diff --git a/gcc/rtl.h b/gcc/rtl.h index f3c3708fbb6..fba89b3187e 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3755,7 +3755,7 @@ extern bool dead_or_set_p (const rtx_insn *, const_rtx); extern bool dead_or_set_regno_p (const rtx_insn *, unsigned int); extern rtx find_reg_note (const_rtx, enum reg_note, const_rtx); extern rtx find_regno_note (const_rtx, enum reg_note, unsigned int); -extern rtx find_reg_equal_equiv_note (const_rtx); +extern rtx find_reg_equal_equiv_note (const rtx_insn *); extern rtx find_constant_src (const rtx_insn *); extern bool find_reg_fusage (const_rtx, enum rtx_code, const_rtx); extern bool find_regno_fusage (const_rtx, enum rtx_code, unsigned int); diff --git a/gcc/rtlanal.cc b/gcc/rtlanal.cc index 98e0481cf79..5e00623d993 100644 --- a/gcc/rtlanal.cc +++ b/gcc/rtlanal.cc @@ -2568,7 +2568,7 @@ find_regno_note (const_rtx insn, enum reg_note kind, unsigned int regno) has such a note. */ rtx -find_reg_equal_equiv_note (const_rtx insn) +find_reg_equal_equiv_note (const rtx_insn *insn) { rtx link; @@ -2586,7 +2586,7 @@ find_reg_equal_equiv_note (const_rtx insn) This should be changed into an assert. */ if (GET_CODE (PATTERN (insn)) == PARALLEL - && multiple_sets (as_a (insn))) + && multiple_sets (insn)) return 0; return link; } -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:46 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:46 -0500 Subject: [PATCH 05/25] Use rtx_insn * for locals that already hold an insn In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-6-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_pushwb_single_reg, aarch64_expand_epilogue): Use rtx_insn * for locals that already hold an insn. * config/alpha/alpha.cc (alpha_expand_prologue, alpha_expand_epilogue): Likewise. * config/arc/arc.cc (arc_dwarf_emit_irq_save_regs, push_reg, pop_reg, arc_expand_epilogue, hwloop_fail): Likewise. * config/arm/arm.cc (cmse_clear_registers, arm_emit_call_insn, thumb2_emit_strd_push, thumb_set_frame_pointer): Likewise. * config/bfin/bfin.cc (hwloop_optimize, hwloop_fail): Likewise. * config/c6x/c6x.cc (reorg_emit_nops): Likewise. * config/cris/cris.cc (cris_split_movdx, cris_expand_epilogue, cris_emit_movem_store): Likewise. * config/cris/cris.md (movdi): Likewise. * config/csky/csky.cc (get_csky_barrier_cost, csky_expand_prologue): Likewise. * config/fr30/fr30.cc (fr30_expand_prologue, fr30_move_double): Likewise. * config/frv/frv.cc (frv_frame_insn, frv_split_scc, frv_split_cond_move, frv_split_minmax, frv_split_abs): Likewise. * config/ft32/ft32.cc (ft32_expand_prologue): Likewise. * config/gcn/gcn.cc (move_callee_saved_registers, gcn_expand_prologue): Likewise. * config/ia64/ia64.cc (ia64_split_tmode_move): Likewise. * config/lm32/lm32.cc (emit_add): Likewise. * config/loongarch/loongarch.cc (loongarch_set_frame_expr, loongarch_expand_epilogue): Likewise. * config/loongarch/loongarch.md (sibcall, sibcall_value): Likewise. * config/m32r/m32r.cc (gen_split_move_double, pop): Likewise. * config/mmix/mmix.cc (mmix_expand_prologue, mmix_emit_sp_add): Likewise. * config/moxie/moxie.cc (moxie_expand_prologue): Likewise. * config/nds32/nds32-md-auxiliary.cc (nds32_emit_push_fpr_callee_saved, nds32_emit_pop_fpr_callee_saved, nds32_emit_v3pop_fpr_callee_saved, nds32_legitimize_tls_address): Likewise. * config/nds32/nds32.cc (nds32_expand_epilogue): Likewise. * config/nds32/nds32.md (call, call_value): Likewise. * config/nvptx/nvptx.cc (nvptx_propagate): Likewise. * config/or1k/or1k.cc (or1k_save_reg, or1k_expand_prologue, or1k_expand_epilogue): Likewise. * config/pru/pru.cc (pru_add3_frame_adjust): Likewise. * config/pru/pru.md (insv, lshrdi3, ashldi3): Likewise. * config/riscv/riscv.cc (riscv_set_frame_expr, riscv_for_each_saved_v_reg, riscv_gen_multi_pop_insn, riscv_expand_epilogue): Likewise. * config/riscv/thead.cc (th_mempair_save_regs, th_mempair_restore_regs): Likewise. * config/rs6000/rs6000-logue.cc (rs6000_emit_prologue, restore_saved_cr): Likewise. * config/rs6000/rs6000-string.cc (expand_block_compare_gpr, expand_strncmp_gpr_sequence, expand_strn_compare): Likewise. * config/rx/rx.cc (gen_safe_add, push_regs): Likewise. * config/s390/s390.cc (save_fpr): Likewise. * config/sh/sh.cc (sh_reorg): Likewise. * config/sh/sh_treg_combine.cc (trace_reg_uses_1): Likewise. * config/sparc/sparc.cc (empty_delay_slot, sparc_output_mi_thunk): Likewise. * config/stormy16/stormy16.cc (xstormy16_split_move, emit_addhi3_postreload): Likewise. * config/v850/v850.cc (expand_prologue, expand_epilogue): Likewise. * config/vax/vax.cc (vax_expand_prologue): Likewise. * config/visium/visium.cc (empty_delay_slot): Likewise. * config/xtensa/xtensa.cc (xtensa_copy_incoming_a7, xtensa_set_return_address): Likewise. * final.cc (shorten_branches): Likewise. * reorg.cc (try_merge_delay_insns, fill_slots_from_thread, make_return_insns): Likewise. * tree-outof-ssa.cc (insert_value_copy_on_edge): Likewise. --- gcc/config/aarch64/aarch64.cc | 6 +++--- gcc/config/alpha/alpha.cc | 5 +++-- gcc/config/arc/arc.cc | 11 +++++----- gcc/config/arm/arm.cc | 17 +++++++-------- gcc/config/bfin/bfin.cc | 9 ++++---- gcc/config/c6x/c6x.cc | 6 +++--- gcc/config/cris/cris.cc | 29 +++++++++++--------------- gcc/config/cris/cris.md | 3 +-- gcc/config/csky/csky.cc | 7 ++++--- gcc/config/fr30/fr30.cc | 5 ++--- gcc/config/frv/frv.cc | 10 ++++----- gcc/config/ft32/ft32.cc | 2 +- gcc/config/gcn/gcn.cc | 23 +++++++++++--------- gcc/config/ia64/ia64.cc | 3 ++- gcc/config/lm32/lm32.cc | 2 +- gcc/config/loongarch/loongarch.cc | 6 ++---- gcc/config/loongarch/loongarch.md | 12 ++++++----- gcc/config/m32r/m32r.cc | 8 +++---- gcc/config/mmix/mmix.cc | 8 +++---- gcc/config/moxie/moxie.cc | 2 +- gcc/config/nds32/nds32-md-auxiliary.cc | 9 ++++---- gcc/config/nds32/nds32.cc | 2 +- gcc/config/nds32/nds32.md | 4 ++-- gcc/config/nvptx/nvptx.cc | 2 +- gcc/config/or1k/or1k.cc | 7 ++++--- gcc/config/pru/pru.cc | 2 +- gcc/config/pru/pru.md | 25 ++++++++++------------ gcc/config/riscv/riscv.cc | 14 ++++++------- gcc/config/riscv/thead.cc | 6 ++++-- gcc/config/rs6000/rs6000-logue.cc | 9 ++++---- gcc/config/rs6000/rs6000-string.cc | 8 +++---- gcc/config/rx/rx.cc | 4 ++-- gcc/config/s390/s390.cc | 2 +- gcc/config/sh/sh.cc | 5 +++-- gcc/config/sh/sh_treg_combine.cc | 2 +- gcc/config/sparc/sparc.cc | 6 +++--- gcc/config/stormy16/stormy16.cc | 7 ++++--- gcc/config/v850/v850.cc | 5 ++--- gcc/config/vax/vax.cc | 2 +- gcc/config/visium/visium.cc | 3 +-- gcc/config/xtensa/xtensa.cc | 4 ++-- gcc/final.cc | 3 ++- gcc/reorg.cc | 8 ++++--- gcc/tree-outof-ssa.cc | 4 ++-- 44 files changed, 159 insertions(+), 158 deletions(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index cc5950b8ebe..512795fd769 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -9410,14 +9410,14 @@ aarch64_pushwb_single_reg (machine_mode mode, unsigned regno, HOST_WIDE_INT adjustment) { rtx base_rtx = stack_pointer_rtx; - rtx insn, reg, mem; + rtx reg, mem; reg = gen_rtx_REG (mode, regno); mem = gen_rtx_PRE_MODIFY (Pmode, base_rtx, plus_constant (Pmode, base_rtx, -adjustment)); mem = gen_frame_mem (mode, mem); - insn = emit_move_insn (mem, reg); + rtx_insn *insn = emit_move_insn (mem, reg); RTX_FRAME_RELATED_P (insn) = 1; } @@ -11255,7 +11255,7 @@ aarch64_expand_epilogue (rtx_call_insn *sibcall) rtx_code_label *label = gen_label_rtx (); rtx x = aarch64_gen_compare_zero_and_branch (EQ, EH_RETURN_TAKEN_RTX, label); - rtx jump = emit_jump_insn (x); + rtx_insn *jump = emit_jump_insn (x); JUMP_LABEL (jump) = label; LABEL_NUSES (label)++; emit_insn (gen_add2_insn (stack_pointer_rtx, diff --git a/gcc/config/alpha/alpha.cc b/gcc/config/alpha/alpha.cc index 6c9087910af..cc2b1fe95e7 100644 --- a/gcc/config/alpha/alpha.cc +++ b/gcc/config/alpha/alpha.cc @@ -8613,7 +8613,7 @@ alpha_expand_prologue (void) HOST_WIDE_INT leftover = probed_size + 4096 - blocks * 8192; rtx ptr = gen_rtx_REG (DImode, 22); rtx count = gen_rtx_REG (DImode, 23); - rtx seq; + rtx_insn *seq; emit_move_insn (count, GEN_INT (blocks)); emit_insn (gen_adddi3 (ptr, stack_pointer_rtx, GEN_INT (4096))); @@ -8963,7 +8963,8 @@ alpha_expand_epilogue (void) HOST_WIDE_INT reg_offset; int fp_is_frame_pointer, fp_offset; rtx sa_reg, sa_reg_exp = NULL; - rtx sp_adj1, sp_adj2, mem, reg, insn; + rtx sp_adj1, sp_adj2, mem, reg; + rtx_insn *insn; rtx eh_ofs; rtx cfa_restores = NULL_RTX; diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc index 60419b5d661..ad6a2337f58 100644 --- a/gcc/config/arc/arc.cc +++ b/gcc/config/arc/arc.cc @@ -2904,7 +2904,8 @@ arc_compute_frame_size (void) static void arc_dwarf_emit_irq_save_regs (void) { - rtx tmp, par, insn, reg; + rtx tmp, par, reg; + rtx_insn *insn; int i, offset, j; par = gen_rtx_SEQUENCE (VOIDmode, @@ -3001,7 +3002,7 @@ push_reg (rtx reg) { rtx stkslot = gen_rtx_MEM (GET_MODE (reg), gen_rtx_PRE_DEC (Pmode, stack_pointer_rtx)); - rtx insn = emit_move_insn (stkslot, reg); + rtx_insn *insn = emit_move_insn (stkslot, reg); RTX_FRAME_RELATED_P (insn) = 1; add_reg_note (insn, REG_CFA_ADJUST_CFA, gen_rtx_SET (stack_pointer_rtx, @@ -3055,7 +3056,7 @@ pop_reg (rtx reg) { rtx stkslot = gen_rtx_MEM (GET_MODE (reg), gen_rtx_POST_INC (Pmode, stack_pointer_rtx)); - rtx insn = emit_move_insn (reg, stkslot); + rtx_insn *insn = emit_move_insn (reg, stkslot); RTX_FRAME_RELATED_P (insn) = 1; add_reg_note (insn, REG_CFA_ADJUST_CFA, gen_rtx_SET (stack_pointer_rtx, @@ -3930,7 +3931,7 @@ arc_expand_epilogue (int sibcall_p) /* Restore accumulator registers. */ if (arc_must_save_register (R58_REG, cfun, true)) { - rtx insn; + rtx_insn *insn; rtx reg0 = gen_rtx_REG (SImode, R0_REG); rtx reg1 = gen_rtx_REG (SImode, R1_REG); size_to_deallocate -= pop_reg (reg0); @@ -7932,7 +7933,7 @@ static void hwloop_fail (hwloop_info loop) { rtx test; - rtx insn = loop->loop_end; + rtx_insn *insn = loop->loop_end; if (TARGET_DBNZ && (loop->length && (loop->length <= ARC_MAX_LOOP_LENGTH)) diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 940c689b21e..599c4e4925e 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -18086,7 +18086,8 @@ cmse_clear_registers (sbitmap to_clear_bitmap, uint32_t *padding_bits_to_clear, { rtvec vunspec_vec; int i, j, k, nb_regs; - rtx use_seq, par, reg, set, vunspec; + rtx_insn *use_seq; + rtx par, reg, set, vunspec; int to_clear_bitmap_size = SBITMAP_SIZE (to_clear_bitmap); auto_sbitmap core_regs_bitmap (to_clear_bitmap_size); auto_sbitmap to_clear_core_bitmap (to_clear_bitmap_size); @@ -19038,9 +19039,7 @@ detect_cmse_nonsecure_call (tree addr) void arm_emit_call_insn (rtx pat, rtx addr, bool sibcall) { - rtx insn; - - insn = emit_call_insn (pat); + rtx_insn *insn = emit_call_insn (pat); /* The PIC register is live on entry to VxWorks PIC PLT entries. If the call might use such an entry, add a use of the PIC register @@ -21078,7 +21077,7 @@ thumb2_emit_strd_push (unsigned long saved_regs_mask) 64-bit aligned). */ if ((num_regs & 1) != 0) { - rtx reg, mem, insn; + rtx reg, mem; reg = gen_rtx_REG (SImode, regno); if (num_regs == 1) @@ -21093,7 +21092,7 @@ thumb2_emit_strd_push (unsigned long saved_regs_mask) tmp = gen_rtx_SET (mem, reg); RTX_FRAME_RELATED_P (tmp) = 1; - insn = emit_insn (tmp); + rtx_insn *insn = emit_insn (tmp); RTX_FRAME_RELATED_P (insn) = 1; add_reg_note (insn, REG_FRAME_RELATED_EXPR, dwarf); tmp = gen_rtx_SET (gen_frame_mem (Pmode, stack_pointer_rtx), reg); @@ -21121,7 +21120,6 @@ thumb2_emit_strd_push (unsigned long saved_regs_mask) if (first) { - rtx insn; first = false; mem1 = gen_frame_mem (Pmode, plus_constant (Pmode, @@ -21142,7 +21140,7 @@ thumb2_emit_strd_push (unsigned long saved_regs_mask) XVECEXP (par, 0, 0) = tmp0; XVECEXP (par, 0, 1) = tmp1; XVECEXP (par, 0, 2) = tmp2; - insn = emit_insn (par); + rtx_insn *insn = emit_insn (par); RTX_FRAME_RELATED_P (insn) = 1; add_reg_note (insn, REG_FRAME_RELATED_EXPR, dwarf); } @@ -22377,7 +22375,8 @@ static void thumb_set_frame_pointer (arm_stack_offsets *offsets) { HOST_WIDE_INT amount; - rtx insn, dwarf; + rtx_insn *insn; + rtx dwarf; amount = offsets->outgoing_args - offsets->locals_base; if (amount < 1024) diff --git a/gcc/config/bfin/bfin.cc b/gcc/config/bfin/bfin.cc index e52df8b3ae1..81fa48eacde 100644 --- a/gcc/config/bfin/bfin.cc +++ b/gcc/config/bfin/bfin.cc @@ -3456,7 +3456,7 @@ hwloop_optimize (hwloop_info loop) rtx iter_reg, scratchreg, scratch_init; rtx_insn *scratch_init_insn; rtx lc_reg, lt_reg, lb_reg; - rtx seq_end; + rtx_insn *seq_end; rtx_insn *seq; int length; bool clobber0, clobber1; @@ -3853,13 +3853,14 @@ hwloop_optimize (hwloop_info loop) static void hwloop_fail (hwloop_info loop) { - rtx insn = loop->loop_end; + rtx_insn *insn = loop->loop_end; if (DPREG_P (loop->iter_reg)) { /* If loop->iter_reg is a DREG or PREG, we can split it here without scratch register. */ - rtx insn, test; + rtx_insn *insn; + rtx test; emit_insn_before (gen_addsi3 (loop->iter_reg, loop->iter_reg, @@ -3879,7 +3880,7 @@ hwloop_fail (hwloop_info loop) else { splitting_loops = 1; - try_split (PATTERN (insn), safe_as_a (insn), 1); + try_split (PATTERN (insn), insn, 1); splitting_loops = 0; } } diff --git a/gcc/config/c6x/c6x.cc b/gcc/config/c6x/c6x.cc index c96a405ba7d..ca213d8b66f 100644 --- a/gcc/config/c6x/c6x.cc +++ b/gcc/config/c6x/c6x.cc @@ -4989,7 +4989,7 @@ static void reorg_emit_nops (rtx_code_label **call_labels) { bool first; - rtx last_call; + rtx_insn *last_call; rtx_insn *prev; int prev_clock, earliest_bb_end; int prev_implicit_nops; @@ -5054,7 +5054,7 @@ reorg_emit_nops (rtx_code_label **call_labels) && insn_get_clock (last_call) + 6 <= this_clock) { emit_label_before (call_labels[INSN_UID (last_call)], insn); - last_call = NULL_RTX; + last_call = nullptr; } prev_implicit_nops = 0; } @@ -5106,7 +5106,7 @@ reorg_emit_nops (rtx_code_label **call_labels) if (last_call) emit_label_after (call_labels[INSN_UID (last_call)], prev); - last_call = NULL_RTX; + last_call = nullptr; } insn = next; } diff --git a/gcc/config/cris/cris.cc b/gcc/config/cris/cris.cc index c2d6c32d400..425300aca8b 100644 --- a/gcc/config/cris/cris.cc +++ b/gcc/config/cris/cris.cc @@ -2542,7 +2542,7 @@ cris_split_movdx (rtx *operands) machine_mode mode = GET_MODE (operands[0]); rtx dest = operands[0]; rtx src = operands[1]; - rtx val; + rtx_insn *val; /* We used to have to handle (SUBREG (MEM)) here, but that should no longer happen; after reload there are no SUBREGs any more, and we're @@ -2598,14 +2598,14 @@ cris_split_movdx (rtx *operands) if (GET_CODE (addr) == POST_INC) { rtx mem; - rtx insn; /* Whenever we emit insns with post-incremented addresses ourselves, we must add a post-inc note manually. */ mem = change_address (src, SImode, addr); - insn = emit_move_insn (operand_subword (dest, 0, TRUE, mode), - mem); + rtx_insn *insn + = emit_move_insn (operand_subword (dest, 0, TRUE, mode), + mem); if (GET_CODE (XEXP (mem, 0)) == POST_INC) REG_NOTES (insn) = alloc_EXPR_LIST (REG_INC, XEXP (XEXP (mem, 0), 0), @@ -2654,12 +2654,12 @@ cris_split_movdx (rtx *operands) if (GET_CODE (addr) == POST_INC) { rtx mem; - rtx insn; /* Whenever we emit insns with post-incremented addresses ourselves, we must add a post-inc note manually. */ mem = change_address (dest, SImode, addr); - insn = emit_move_insn (mem, operand_subword (src, 0, TRUE, mode)); + rtx_insn *insn + = emit_move_insn (mem, operand_subword (src, 0, TRUE, mode)); if (GET_CODE (XEXP (mem, 0)) == POST_INC) REG_NOTES (insn) = alloc_EXPR_LIST (REG_INC, XEXP (XEXP (mem, 0), 0), @@ -3158,7 +3158,6 @@ cris_expand_epilogue (void) regno--) if (cris_reg_saved_in_regsave_area (regno)) { - rtx insn; if (argspace_offset) { @@ -3173,7 +3172,7 @@ cris_expand_epilogue (void) mem = gen_rtx_MEM (SImode, gen_rtx_POST_INC (SImode, stack_pointer_rtx)); set_mem_alias_set (mem, get_frame_alias_set ()); - insn = emit_move_insn (gen_raw_REG (SImode, regno), mem); + rtx_insn *insn = emit_move_insn (gen_raw_REG (SImode, regno), mem); /* Whenever we emit insns with post-incremented addresses ourselves, we must add a post-inc note manually. */ @@ -3184,7 +3183,6 @@ cris_expand_epilogue (void) /* If we have any movem-restore, do it now. */ if (last_movem_reg != -1) { - rtx insn; if (argspace_offset) { @@ -3195,7 +3193,7 @@ cris_expand_epilogue (void) mem = gen_rtx_MEM (SImode, gen_rtx_POST_INC (SImode, stack_pointer_rtx)); set_mem_alias_set (mem, get_frame_alias_set ()); - insn + rtx_insn *insn = emit_insn (cris_gen_movem_load (mem, GEN_INT (last_movem_reg + 1))); /* Whenever we emit insns with post-incremented addresses ourselves, we must add a post-inc note manually. */ @@ -3217,7 +3215,6 @@ cris_expand_epilogue (void) /* Restore frame pointer if necessary. */ if (frame_pointer_needed) { - rtx insn; emit_insn (gen_cris_frame_deallocated_barrier ()); @@ -3225,7 +3222,7 @@ cris_expand_epilogue (void) mem = gen_rtx_MEM (SImode, gen_rtx_POST_INC (SImode, stack_pointer_rtx)); set_mem_alias_set (mem, get_frame_alias_set ()); - insn = emit_move_insn (hard_frame_pointer_rtx, mem); + rtx_insn *insn = emit_move_insn (hard_frame_pointer_rtx, mem); /* Whenever we emit insns with post-incremented addresses ourselves, we must add a post-inc note manually. */ @@ -3254,13 +3251,12 @@ cris_expand_epilogue (void) if (crtl->calls_eh_return) { rtx mem; - rtx insn; rtx srpreg = gen_raw_REG (SImode, CRIS_SRP_REGNUM); mem = gen_rtx_MEM (SImode, gen_rtx_POST_INC (SImode, stack_pointer_rtx)); set_mem_alias_set (mem, get_frame_alias_set ()); - insn = emit_move_insn (srpreg, mem); + rtx_insn *insn = emit_move_insn (srpreg, mem); /* Whenever we emit insns with post-incremented addresses ourselves, we must add a post-inc note manually. */ @@ -3287,13 +3283,12 @@ cris_expand_epilogue (void) { rtx mem; rtx srpreg = gen_raw_REG (SImode, CRIS_SRP_REGNUM); - rtx insn; mem = gen_rtx_MEM (SImode, gen_rtx_POST_INC (SImode, stack_pointer_rtx)); set_mem_alias_set (mem, get_frame_alias_set ()); - insn = emit_move_insn (srpreg, mem); + rtx_insn *insn = emit_move_insn (srpreg, mem); /* Whenever we emit insns with post-incremented addresses ourselves, we must add a post-inc note manually. */ @@ -3385,7 +3380,7 @@ cris_emit_movem_store (rtx dest, rtx nregs_rtx, int increment, rtvec vec; int eltno = 1; int i; - rtx insn; + rtx_insn *insn; rtx destreg = XEXP (dest, 0); unsigned int regno = nregs - 1; int regno_inc = -1; diff --git a/gcc/config/cris/cris.md b/gcc/config/cris/cris.md index 1bb6ae96b1f..98963800df1 100644 --- a/gcc/config/cris/cris.md +++ b/gcc/config/cris/cris.md @@ -535,7 +535,6 @@ && ! reload_completed && ! lra_in_progress) { - rtx insns; rtx op0 = operands[0]; rtx op1 = operands[1]; @@ -544,7 +543,7 @@ operand_subword (op1, 0, 1, DImode)); emit_move_insn (operand_subword (op0, 1, 1, DImode), operand_subword (op1, 1, 1, DImode)); - insns = end_sequence (); + rtx_insn *insns = end_sequence (); emit_insn (insns); DONE; diff --git a/gcc/config/csky/csky.cc b/gcc/config/csky/csky.cc index 8e203d54b25..29193e287a3 100644 --- a/gcc/config/csky/csky.cc +++ b/gcc/config/csky/csky.cc @@ -1160,7 +1160,7 @@ get_csky_barrier_cost (rtx_insn *insn) but at the moment, the basic block information seems to be corrupt by this stage of the compilation. */ int base_cost = 50; - rtx next = next_nonnote_insn (insn); + rtx_insn *next = next_nonnote_insn (insn); if (next != NULL && GET_CODE (next) == CODE_LABEL) base_cost -= 20; @@ -5743,8 +5743,9 @@ csky_expand_prologue (void) plus_constant (Pmode, stack_pointer_rtx, offset)); - rtx insn = emit_insn (gen_movsi (dst, - gen_rtx_REG (SImode, regno))); + rtx_insn *insn = emit_insn (gen_movsi (dst, + gen_rtx_REG (SImode, + regno))); RTX_FRAME_RELATED_P (insn) = 1; if (offset == stm_size) break; diff --git a/gcc/config/fr30/fr30.cc b/gcc/config/fr30/fr30.cc index 40b269d8c81..d1d10079188 100644 --- a/gcc/config/fr30/fr30.cc +++ b/gcc/config/fr30/fr30.cc @@ -280,7 +280,7 @@ void fr30_expand_prologue (void) { int regno; - rtx insn; + rtx_insn *insn; if (! current_frame_info.initialised) fr30_compute_frame_size (0, 0); @@ -886,7 +886,6 @@ fr30_move_double (rtx * operands) enum rtx_code src_code = GET_CODE (src); enum rtx_code dest_code = GET_CODE (dest); machine_mode mode = GET_MODE (dest); - rtx val; start_sequence (); @@ -976,7 +975,7 @@ fr30_move_double (rtx * operands) /* This should have been prevented by the constraints on movdi_insn. */ gcc_unreachable (); - val = end_sequence (); + rtx_insn *val = end_sequence (); return val; } diff --git a/gcc/config/frv/frv.cc b/gcc/config/frv/frv.cc index 033eafb366a..c223ee8674b 100644 --- a/gcc/config/frv/frv.cc +++ b/gcc/config/frv/frv.cc @@ -1557,7 +1557,7 @@ frv_dwarf_store (rtx reg, int offset) static void frv_frame_insn (rtx pattern, rtx dwarf_pattern) { - rtx insn = emit_insn (pattern); + rtx_insn *insn = emit_insn (pattern); RTX_FRAME_RELATED_P (insn) = 1; REG_NOTES (insn) = alloc_EXPR_LIST (REG_FRAME_RELATED_EXPR, dwarf_pattern, @@ -4737,7 +4737,7 @@ frv_emit_scc (rtx operands[]) rtx frv_split_scc (rtx dest, rtx test, rtx cc_reg, rtx cr_reg, HOST_WIDE_INT value) { - rtx ret; + rtx_insn *ret; start_sequence (); @@ -4854,7 +4854,7 @@ frv_split_cond_move (rtx operands[]) rtx src1 = operands[3]; rtx src2 = operands[4]; rtx cr_reg = operands[5]; - rtx ret; + rtx_insn *ret; machine_mode cr_mode = GET_MODE (cr_reg); start_sequence (); @@ -5003,7 +5003,7 @@ frv_split_minmax (rtx operands[]) rtx src2 = operands[3]; rtx cc_reg = operands[4]; rtx cr_reg = operands[5]; - rtx ret; + rtx_insn *ret; enum rtx_code test_code; machine_mode cr_mode = GET_MODE (cr_reg); @@ -5075,7 +5075,7 @@ frv_split_abs (rtx operands[]) rtx src = operands[1]; rtx cc_reg = operands[2]; rtx cr_reg = operands[3]; - rtx ret; + rtx_insn *ret; start_sequence (); diff --git a/gcc/config/ft32/ft32.cc b/gcc/config/ft32/ft32.cc index abaa125de73..79ddab205a9 100644 --- a/gcc/config/ft32/ft32.cc +++ b/gcc/config/ft32/ft32.cc @@ -437,7 +437,7 @@ void ft32_expand_prologue (void) { int regno; - rtx insn; + rtx_insn *insn; ft32_compute_frame (); diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc index 93af11aa37e..22ac7f75a81 100644 --- a/gcc/config/gcn/gcn.cc +++ b/gcc/config/gcn/gcn.cc @@ -3208,7 +3208,7 @@ move_callee_saved_registers (rtx sp, machine_function *offsets, saved_scalars++; } - rtx move_scalars = end_sequence (); + rtx_insn *move_scalars = end_sequence (); start_sequence (); /* Ensure that all vector lanes are moved. */ @@ -3258,9 +3258,10 @@ move_callee_saved_registers (rtx sp, machine_function *offsets, if (prologue) { - rtx insn = emit_insn (gen_movv64si_exec (vspmem, reg, - gcn_gen_undef (V64SImode), - exec)); + rtx_insn *insn + = emit_insn (gen_movv64si_exec (vspmem, reg, + gcn_gen_undef (V64SImode), + exec)); /* Add CFI metadata. */ rtx note; @@ -3345,7 +3346,7 @@ move_callee_saved_registers (rtx sp, machine_function *offsets, offset += size; } - rtx move_vectors = end_sequence (); + rtx_insn *move_vectors = end_sequence (); if (prologue) { @@ -3434,8 +3435,9 @@ gcn_expand_prologue () the note. */ rtx scc = gen_rtx_REG (BImode, SCC_REG); rtx adjustment = gen_int_mode (sp_adjust, SImode); - rtx insn = emit_insn (gen_addsi3_scalar_carry (sp_lo, sp_lo, - adjustment, scc)); + rtx_insn *insn = emit_insn (gen_addsi3_scalar_carry (sp_lo, sp_lo, + adjustment, + scc)); if (!offsets->need_frame_pointer) { RTX_FRAME_RELATED_P (insn) = 1; @@ -3455,8 +3457,9 @@ gcn_expand_prologue () rtx scc = gen_rtx_REG (BImode, SCC_REG); int fp_adjust = -(offsets->local_vars + offsets->outgoing_args_size); rtx adjustment = gen_int_mode (fp_adjust, SImode); - rtx insn = emit_insn (gen_addsi3_scalar_carry(fp_lo, sp_lo, - adjustment, scc)); + rtx_insn *insn = emit_insn (gen_addsi3_scalar_carry (fp_lo, sp_lo, + adjustment, + scc)); emit_insn (gen_addcsi3_scalar (fp_hi, sp_hi, (fp_adjust < 0 ? GEN_INT (-1) : const0_rtx), @@ -3581,7 +3584,7 @@ gcn_expand_prologue () make a notional adjustment to the DWARF frame offset here. */ rtx dbg_adjustment = gen_int_mode (sp_adjust + offsets->callee_saves, DImode); - rtx insn; + rtx_insn *insn; if (sp_adjust > 0) { rtx scc = gen_rtx_REG (BImode, SCC_REG); diff --git a/gcc/config/ia64/ia64.cc b/gcc/config/ia64/ia64.cc index 624d06f72f1..e2e00348bdc 100644 --- a/gcc/config/ia64/ia64.cc +++ b/gcc/config/ia64/ia64.cc @@ -1584,7 +1584,8 @@ ia64_split_tmode (rtx out[2], rtx in, bool reversed, bool dead) void ia64_split_tmode_move (rtx operands[]) { - rtx in[2], out[2], insn; + rtx in[2], out[2]; + rtx_insn *insn; rtx fixup[2]; bool dead = false; bool reversed = false; diff --git a/gcc/config/lm32/lm32.cc b/gcc/config/lm32/lm32.cc index 620a162e0b1..21e78a961d6 100644 --- a/gcc/config/lm32/lm32.cc +++ b/gcc/config/lm32/lm32.cc @@ -166,7 +166,7 @@ lm32_return_in_memory (tree type) static rtx emit_add (rtx dest, rtx src0, rtx src1) { - rtx insn; + rtx_insn *insn; insn = emit_insn (gen_addsi3 (dest, src0, src1)); return insn; } diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index b0f7abc0483..3cbc288ab75 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -799,9 +799,7 @@ loongarch_setup_incoming_varargs (cumulative_args_t cum, static void loongarch_set_frame_expr (rtx frame_pattern) { - rtx insn; - - insn = get_last_insn (); + rtx_insn *insn = get_last_insn (); RTX_FRAME_RELATED_P (insn) = 1; REG_NOTES (insn) = alloc_EXPR_LIST (REG_FRAME_RELATED_EXPR, frame_pattern, REG_NOTES (insn)); @@ -1447,7 +1445,7 @@ loongarch_expand_epilogue (int style) HOST_WIDE_INT step1 = frame->total_size; HOST_WIDE_INT step2 = 0; rtx ra = gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM); - rtx insn; + rtx_insn *insn; /* We need to add memory barrier to prevent read from deallocated stack. */ bool need_barrier_p diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md index cccb0ed8612..ceacc5995e6 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -4148,7 +4148,8 @@ operands[1])); else { - rtx call = emit_call_insn (gen_sibcall_internal (target, operands[1])); + rtx_insn *call + = emit_call_insn (gen_sibcall_internal (target, operands[1])); if (TARGET_CMODEL_MEDIUM && !REG_P (target)) clobber_reg (&CALL_INSN_FUNCTION_USAGE (call), @@ -4219,7 +4220,7 @@ arg2)); else { - rtx call + rtx_insn *call = emit_call_insn (gen_sibcall_value_multiple_internal (arg1, target, operands[2], @@ -4243,9 +4244,10 @@ operands[2])); else { - rtx call = emit_call_insn (gen_sibcall_value_internal (operands[0], - target, - operands[2])); + rtx_insn *call + = emit_call_insn (gen_sibcall_value_internal (operands[0], + target, + operands[2])); if (TARGET_CMODEL_MEDIUM && !REG_P (target)) clobber_reg (&CALL_INSN_FUNCTION_USAGE (call), diff --git a/gcc/config/m32r/m32r.cc b/gcc/config/m32r/m32r.cc index 232bdc6ecd4..a9ec37aebe6 100644 --- a/gcc/config/m32r/m32r.cc +++ b/gcc/config/m32r/m32r.cc @@ -1052,7 +1052,7 @@ gen_split_move_double (rtx operands[]) machine_mode mode = GET_MODE (operands[0]); rtx dest = operands[0]; rtx src = operands[1]; - rtx val; + rtx_insn *val; /* We might have (SUBREG (MEM)) here, so just get rid of the subregs to make this code simpler. It is safe to call @@ -1777,10 +1777,8 @@ m32r_output_function_prologue (FILE * file) static void pop (int regno) { - rtx x; - - x = emit_insn (gen_movsi_pop (gen_rtx_REG (Pmode, regno), - stack_pointer_rtx)); + rtx_insn *x = emit_insn (gen_movsi_pop (gen_rtx_REG (Pmode, regno), + stack_pointer_rtx)); add_reg_note (x, REG_INC, stack_pointer_rtx); } diff --git a/gcc/config/mmix/mmix.cc b/gcc/config/mmix/mmix.cc index 8b27dee035a..fa7a40c17e6 100644 --- a/gcc/config/mmix/mmix.cc +++ b/gcc/config/mmix/mmix.cc @@ -2127,7 +2127,7 @@ mmix_expand_prologue (void) if (frame_pointer_needed) { - rtx insn; + rtx_insn *insn; if (offset < 0) { @@ -2159,7 +2159,7 @@ mmix_expand_prologue (void) if (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS) { rtx tmpreg, retreg; - rtx insn; + rtx_insn *insn; /* Store the return-address, if one is needed on the stack. We usually store it in a register when needed, but that doesn't work @@ -2260,7 +2260,7 @@ mmix_expand_prologue (void) && df_regs_ever_live_p (regno) && !call_used_or_fixed_reg_p (regno)) || IS_MMIX_EH_RETURN_DATA_REG (regno)) { - rtx insn; + rtx_insn *insn; if (offset < 0) { @@ -2570,7 +2570,7 @@ mmix_gen_compare_reg (RTX_CODE code, rtx x, rtx y) static void mmix_emit_sp_add (HOST_WIDE_INT offset) { - rtx insn; + rtx_insn *insn; if (offset < 0) { diff --git a/gcc/config/moxie/moxie.cc b/gcc/config/moxie/moxie.cc index d86ef313248..4f79f4b2e3f 100644 --- a/gcc/config/moxie/moxie.cc +++ b/gcc/config/moxie/moxie.cc @@ -278,7 +278,7 @@ void moxie_expand_prologue (void) { int regno; - rtx insn; + rtx_insn *insn; moxie_compute_frame (); diff --git a/gcc/config/nds32/nds32-md-auxiliary.cc b/gcc/config/nds32/nds32-md-auxiliary.cc index f45f63daa7d..d8378b9af78 100644 --- a/gcc/config/nds32/nds32-md-auxiliary.cc +++ b/gcc/config/nds32/nds32-md-auxiliary.cc @@ -1227,7 +1227,7 @@ nds32_expand_float_movcc (rtx *operands) void nds32_emit_push_fpr_callee_saved (int base_offset) { - rtx fpu_insn; + rtx_insn *fpu_insn; rtx reg, mem; unsigned int regno = cfun->machine->callee_saved_first_fpr_regno; unsigned int last_fpr = cfun->machine->callee_saved_last_fpr_regno; @@ -1249,7 +1249,7 @@ nds32_emit_push_fpr_callee_saved (int base_offset) void nds32_emit_pop_fpr_callee_saved (int gpr_padding_size) { - rtx fpu_insn; + rtx_insn *fpu_insn; rtx reg, mem, addr; rtx dwarf, adjust_sp_rtx; unsigned int regno = cfun->machine->callee_saved_first_fpr_regno; @@ -1289,7 +1289,7 @@ nds32_emit_v3pop_fpr_callee_saved (int base) { int fpu_base_addr = base; int regno; - rtx fpu_insn; + rtx_insn *fpu_insn; rtx reg, mem; rtx dwarf; @@ -3672,7 +3672,8 @@ nds32_legitimize_tls_address (rtx x) { rtx tmp_reg; rtx tp_reg = gen_rtx_REG (Pmode, TP_REGNUM); - rtx pat, insns, reg0; + rtx pat, reg0; + rtx_insn *insns; int relax_group_id = nds32_alloc_relax_group_id (); if (GET_CODE (x) == SYMBOL_REF) diff --git a/gcc/config/nds32/nds32.cc b/gcc/config/nds32/nds32.cc index 7156baca4f2..0aae1112507 100644 --- a/gcc/config/nds32/nds32.cc +++ b/gcc/config/nds32/nds32.cc @@ -4986,7 +4986,7 @@ nds32_expand_epilogue (bool sibcall_p) CFA is described using $ta then SP is modified. */ rtx ta_reg; - rtx insn; + rtx_insn *insn; ta_reg = gen_rtx_REG (SImode, TA_REGNUM); diff --git a/gcc/config/nds32/nds32.md b/gcc/config/nds32/nds32.md index 4b05c5f30a2..aaca31660a5 100644 --- a/gcc/config/nds32/nds32.md +++ b/gcc/config/nds32/nds32.md @@ -1501,7 +1501,7 @@ (clobber (reg:SI TA_REGNUM))])] "" { - rtx insn; + rtx_insn *insn; rtx sym = XEXP (operands[0], 0); if (TARGET_ICT_MODEL_LARGE @@ -1587,7 +1587,7 @@ (clobber (reg:SI TA_REGNUM))])] "" { - rtx insn; + rtx_insn *insn; rtx sym = XEXP (operands[1], 0); if (TARGET_ICT_MODEL_LARGE diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index 39ea6e6f923..7177328c1e8 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -4602,7 +4602,7 @@ nvptx_propagate (bool is_call, basic_block block, rtx_insn *insn, } emit_insn (gen_rtx_CLOBBER (GET_MODE (tmp), tmp)); emit_insn (gen_rtx_CLOBBER (GET_MODE (ptr), ptr)); - rtx cpy = end_sequence (); + rtx_insn *cpy = end_sequence (); insn = emit_insn_after (cpy, insn); } diff --git a/gcc/config/or1k/or1k.cc b/gcc/config/or1k/or1k.cc index 89076ae02fc..52dbb57a51c 100644 --- a/gcc/config/or1k/or1k.cc +++ b/gcc/config/or1k/or1k.cc @@ -190,7 +190,7 @@ or1k_save_reg (int regno, HOST_WIDE_INT offset) rtx reg = gen_rtx_REG (Pmode, regno); rtx mem = gen_frame_mem (SImode, plus_constant (Pmode, stack_pointer_rtx, offset)); - rtx insn = emit_move_insn (mem, reg); + rtx_insn *insn = emit_move_insn (mem, reg); RTX_FRAME_RELATED_P (insn) = 1; } @@ -214,7 +214,7 @@ or1k_expand_prologue (void) { HOST_WIDE_INT sp_offset = -cfun->machine->total_size; HOST_WIDE_INT reg_offset, this_offset; - rtx insn; + rtx_insn *insn; if (flag_stack_usage_info) current_function_static_stack_size = -sp_offset; @@ -324,7 +324,8 @@ void or1k_expand_epilogue (void) { HOST_WIDE_INT reg_offset, sp_offset; - rtx insn, cfa_restores = NULL; + rtx_insn *insn; + rtx cfa_restores = NULL; sp_offset = cfun->machine->total_size; if (sp_offset == 0) diff --git a/gcc/config/pru/pru.cc b/gcc/config/pru/pru.cc index 4c85bed1443..d6348ec296b 100644 --- a/gcc/config/pru/pru.cc +++ b/gcc/config/pru/pru.cc @@ -165,7 +165,7 @@ static rtx pru_add3_frame_adjust (rtx op0, rtx op1, int addendum, const enum reg_note kind) { - rtx insn; + rtx_insn *insn; rtx op0_adjust = gen_rtx_SET (op0, plus_constant (Pmode, op1, addendum)); diff --git a/gcc/config/pru/pru.md b/gcc/config/pru/pru.md index 4c3c9c554c0..0487409326e 100644 --- a/gcc/config/pru/pru.md +++ b/gcc/config/pru/pru.md @@ -619,7 +619,6 @@ if (nbits == 1) { - rtx j; rtx src = gen_reg_rtx (mode); rtx dst = operands[0]; @@ -631,7 +630,7 @@ mode))); rtx_code_label *skip_set_label = gen_label_rtx (); - j = emit_jump_insn (gen_cbranch_qbbx_eq4 ( + rtx_insn *j = emit_jump_insn (gen_cbranch_qbbx_eq4 ( src, GEN_INT (0), skip_set_label)); @@ -934,18 +933,17 @@ if (nshifts == 1) { rtx_code_label *skip_hiset_label; - rtx j; emit_insn (gen_rtx_SET (dst_lo, gen_rtx_LSHIFTRT (SImode, src_lo, const1_rtx))); /* The code generated by `genemit' would create a LABEL_REF. */ skip_hiset_label = gen_label_rtx (); - j = emit_jump_insn (gen_cbranch_qbbx_const (EQ, - SImode, - src_hi, - GEN_INT (0), - skip_hiset_label)); + rtx_insn *j = emit_jump_insn (gen_cbranch_qbbx_const (EQ, + SImode, + src_hi, + GEN_INT (0), + skip_hiset_label)); JUMP_LABEL (j) = skip_hiset_label; LABEL_NUSES (skip_hiset_label)++; @@ -1025,17 +1023,16 @@ if (nshifts == 1) { rtx_code_label *skip_hiset_label; - rtx j; emit_insn (gen_rtx_SET (dst_hi, gen_rtx_ASHIFT (SImode, src_hi, const1_rtx))); skip_hiset_label = gen_label_rtx (); - j = emit_jump_insn (gen_cbranch_qbbx_const (EQ, - SImode, - src_lo, - GEN_INT (31), - skip_hiset_label)); + rtx_insn *j = emit_jump_insn (gen_cbranch_qbbx_const (EQ, + SImode, + src_lo, + GEN_INT (31), + skip_hiset_label)); JUMP_LABEL (j) = skip_hiset_label; LABEL_NUSES (skip_hiset_label)++; diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 2adeec1492e..701bd3e5784 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -9196,9 +9196,7 @@ riscv_elf_select_rtx_section (machine_mode mode, rtx x, static void riscv_set_frame_expr (rtx frame_pattern) { - rtx insn; - - insn = get_last_insn (); + rtx_insn *insn = get_last_insn (); RTX_FRAME_RELATED_P (insn) = 1; REG_NOTES (insn) = alloc_EXPR_LIST (REG_FRAME_RELATED_EXPR, frame_pattern, @@ -9998,7 +9996,7 @@ riscv_for_each_saved_v_reg (poly_int64 &remaining_size, else { vlen = RISCV_PROLOGUE_TEMP (Pmode); - rtx insn + rtx_insn *insn = emit_move_insn (vlen, gen_int_mode (UNITS_PER_V_REG, Pmode)); RTX_FRAME_RELATED_P (insn) = 1; } @@ -10017,7 +10015,7 @@ riscv_for_each_saved_v_reg (poly_int64 &remaining_size, bool handle_reg = !cfun->machine->reg_is_wrapped_separately[regno]; if (handle_reg) { - rtx insn = NULL_RTX; + rtx_insn *insn = nullptr; if (CONST_INT_P (vlen)) { gcc_assert (SMALL_OPERAND (-INTVAL (vlen))); @@ -10046,7 +10044,7 @@ riscv_for_each_saved_v_reg (poly_int64 &remaining_size, if (handle_reg) { riscv_save_restore_reg (m1_mode, regno, 0, fn); - rtx insn = emit_insn ( + rtx_insn *insn = emit_insn ( gen_add3_insn (stack_pointer_rtx, stack_pointer_rtx, vlen)); gcc_assert (insn != NULL_RTX); RTX_FRAME_RELATED_P (insn) = 1; @@ -10784,7 +10782,7 @@ static void riscv_gen_multi_pop_insn (bool use_popret, unsigned mask, unsigned multipop_size) { - rtx insn; + rtx_insn *insn; unsigned regs_count = riscv_multi_push_regs_count (mask); if (!use_popret) @@ -10831,7 +10829,7 @@ riscv_expand_epilogue (int style) rtx ra = gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM); rtx t0 = gen_rtx_REG (Pmode, RISCV_PROLOGUE_TEMP_REGNUM); unsigned th_int_mask = 0; - rtx insn; + rtx_insn *insn; /* Avoid referencing an unused frame pointer. */ rtx stack_tie_reg = frame_pointer_needed diff --git a/gcc/config/riscv/thead.cc b/gcc/config/riscv/thead.cc index acf661f83e7..33d9dc28dd4 100644 --- a/gcc/config/riscv/thead.cc +++ b/gcc/config/riscv/thead.cc @@ -347,7 +347,8 @@ th_mempair_save_regs (rtx operands[4]) rtx set1 = gen_rtx_SET (operands[0], operands[1]); rtx set2 = gen_rtx_SET (operands[2], operands[3]); rtx dwarf = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (2)); - rtx insn = emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, set1, set2))); + rtx_insn *insn = emit_insn (gen_rtx_PARALLEL (VOIDmode, + gen_rtvec (2, set1, set2))); RTX_FRAME_RELATED_P (insn) = 1; XVECEXP (dwarf, 0, 0) = copy_rtx (set1); @@ -365,7 +366,8 @@ th_mempair_restore_regs (rtx operands[4]) { rtx set1 = gen_rtx_SET (operands[0], operands[1]); rtx set2 = gen_rtx_SET (operands[2], operands[3]); - rtx insn = emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, set1, set2))); + rtx_insn *insn = emit_insn (gen_rtx_PARALLEL (VOIDmode, + gen_rtvec (2, set1, set2))); RTX_FRAME_RELATED_P (insn) = 1; add_reg_note (insn, REG_CFA_RESTORE, operands[0]); add_reg_note (insn, REG_CFA_RESTORE, operands[2]); diff --git a/gcc/config/rs6000/rs6000-logue.cc b/gcc/config/rs6000/rs6000-logue.cc index 4c0b939d43c..9366ddd2880 100644 --- a/gcc/config/rs6000/rs6000-logue.cc +++ b/gcc/config/rs6000/rs6000-logue.cc @@ -3451,7 +3451,7 @@ rs6000_emit_prologue (void) { rtx tmp_reg, tmp_reg_si, hi, lo, compare_result; rtx jump; - rtx join_insn, note; + rtx note; rtx_insn *save_insn; long toc_restore_insn; @@ -3512,7 +3512,7 @@ rs6000_emit_prologue (void) copy_rtx (PATTERN (save_insn)), NULL_RTX); RTX_FRAME_RELATED_P (save_insn) = 0; - join_insn = emit_insn (gen_blockage ()); + rtx_insn *join_insn = emit_insn (gen_blockage ()); REG_NOTES (join_insn) = note; RTX_FRAME_RELATED_P (join_insn) = 1; @@ -4182,8 +4182,9 @@ restore_saved_cr (rtx reg, bool using_mfcr_multiple, bool exit_func) for (i = 0; i < 8; i++) if (save_reg_p (CR0_REGNO + i)) { - rtx insn = emit_insn (gen_movsi_to_cr_one - (gen_rtx_REG (CCmode, CR0_REGNO + i), reg)); + rtx_insn *insn = emit_insn (gen_movsi_to_cr_one + (gen_rtx_REG (CCmode, CR0_REGNO + i), + reg)); /* For the ELFv2 ABI we generate a CFA_RESTORE for each CR field separately, attached to the insn that in fact diff --git a/gcc/config/rs6000/rs6000-string.cc b/gcc/config/rs6000/rs6000-string.cc index ee10e447417..c22db95d6e2 100644 --- a/gcc/config/rs6000/rs6000-string.cc +++ b/gcc/config/rs6000/rs6000-string.cc @@ -1853,7 +1853,7 @@ expand_block_compare_gpr(unsigned HOST_WIDE_INT bytes, unsigned int base_align, if (final_label) { rtx fin_ref = gen_rtx_LABEL_REF (VOIDmode, final_label); - rtx j = emit_jump_insn (gen_rtx_SET (pc_rtx, fin_ref)); + rtx_insn *j = emit_jump_insn (gen_rtx_SET (pc_rtx, fin_ref)); JUMP_LABEL (j) = final_label; LABEL_NUSES (final_label) += 1; emit_barrier (); @@ -2305,7 +2305,7 @@ expand_strncmp_gpr_sequence (unsigned HOST_WIDE_INT bytes_to_compare, do_sub3 (result_reg, tmp_reg_src1, tmp_reg_src2); rtx fin_ref = gen_rtx_LABEL_REF (VOIDmode, final_move_label); - rtx j = emit_jump_insn (gen_rtx_SET (pc_rtx, fin_ref)); + rtx_insn *j = emit_jump_insn (gen_rtx_SET (pc_rtx, fin_ref)); JUMP_LABEL (j) = final_move_label; LABEL_NUSES (final_move_label) += 1; emit_barrier (); @@ -2526,7 +2526,7 @@ expand_strn_compare (rtx operands[], int no_length) /* Generate code that checks distance to 4k boundary for this case. */ begin_compare_label = gen_label_rtx (); rtx_code_label *strncmp_label = gen_label_rtx (); - rtx jmp; + rtx_insn *jmp; /* Strncmp for power8 in glibc does this: rldicl r8,r3,0,52 @@ -2657,7 +2657,7 @@ expand_strn_compare (rtx operands[], int no_length) } rtx fin_ref = gen_rtx_LABEL_REF (VOIDmode, final_label); - rtx jmp = emit_jump_insn (gen_rtx_SET (pc_rtx, fin_ref)); + rtx_insn *jmp = emit_jump_insn (gen_rtx_SET (pc_rtx, fin_ref)); JUMP_LABEL (jmp) = final_label; LABEL_NUSES (final_label) += 1; emit_barrier (); diff --git a/gcc/config/rx/rx.cc b/gcc/config/rx/rx.cc index a7ddfead32c..9cf7c1ca42c 100644 --- a/gcc/config/rx/rx.cc +++ b/gcc/config/rx/rx.cc @@ -1715,7 +1715,7 @@ ok_for_max_constant (HOST_WIDE_INT val) static void gen_safe_add (rtx dest, rtx src, rtx val, bool is_frame_related) { - rtx insn; + rtx_insn *insn; if (val == NULL_RTX || INTVAL (val) == 0) { @@ -1748,7 +1748,7 @@ gen_safe_add (rtx dest, rtx src, rtx val, bool is_frame_related) static void push_regs (unsigned int high, unsigned int low) { - rtx insn; + rtx_insn *insn; if (low == high) insn = emit_insn (gen_stack_push (gen_rtx_REG (SImode, low))); diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 11858c2f0cb..77dbdb83058 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -11755,7 +11755,7 @@ static rtx save_fpr (rtx base, int offset, int regnum) { rtx addr; - rtx insn; + rtx_insn *insn; addr = gen_rtx_MEM (DFmode, plus_constant (Pmode, base, offset)); diff --git a/gcc/config/sh/sh.cc b/gcc/config/sh/sh.cc index 07574f9a00b..d33da7bfb1c 100644 --- a/gcc/config/sh/sh.cc +++ b/gcc/config/sh/sh.cc @@ -5933,7 +5933,8 @@ sh_reorg (void) for (insn = first; insn; insn = NEXT_INSN (insn)) { - rtx pattern, reg, set, dies; + rtx pattern, reg, set; + rtx_insn *dies; rtx_code_label *label; rtx_insn *link, *scan; int rescan = 0, foundinsn = 0; @@ -6006,7 +6007,7 @@ sh_reorg (void) by reload, since there may not be a REG_DEAD note for the register. */ - dies = NULL_RTX; + dies = nullptr; for (scan = NEXT_INSN (link); scan; scan = NEXT_INSN (scan)) { rtx scanset; diff --git a/gcc/config/sh/sh_treg_combine.cc b/gcc/config/sh/sh_treg_combine.cc index 05225365b99..ffa0932b746 100644 --- a/gcc/config/sh/sh_treg_combine.cc +++ b/gcc/config/sh/sh_treg_combine.cc @@ -361,7 +361,7 @@ trace_reg_uses_1 (rtx reg, rtx_insn *start_insn, basic_block bb, int& count, if (start_insn == NULL_RTX) log_return_void ("[bb %d] start_insn is null\n", bb->index); - rtx end_insn = NEXT_INSN (BB_END (bb)); + rtx_insn *end_insn = NEXT_INSN (BB_END (bb)); if (end_insn == NULL_RTX) log_return_void ("[bb %d] end_insn is null\n", bb->index); diff --git a/gcc/config/sparc/sparc.cc b/gcc/config/sparc/sparc.cc index 9b191ad492d..108dc71b8bc 100644 --- a/gcc/config/sparc/sparc.cc +++ b/gcc/config/sparc/sparc.cc @@ -3976,13 +3976,12 @@ emit_tfmode_cvt (enum rtx_code code, rtx *operands) int empty_delay_slot (rtx_insn *insn) { - rtx seq; /* If no previous instruction (should not happen), return true. */ if (PREV_INSN (insn) == NULL) return 1; - seq = NEXT_INSN (PREV_INSN (insn)); + rtx_insn *seq = NEXT_INSN (PREV_INSN (insn)); if (GET_CODE (PATTERN (seq)) == SEQUENCE) return 0; @@ -12506,7 +12505,8 @@ sparc_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED, { /* The hoops we have to jump through in order to generate a sibcall without using delay slots... */ - rtx spill_reg, seq, scratch = gen_rtx_REG (Pmode, 1); + rtx spill_reg, scratch = gen_rtx_REG (Pmode, 1); + rtx_insn *seq; if (flag_pic) { diff --git a/gcc/config/stormy16/stormy16.cc b/gcc/config/stormy16/stormy16.cc index 67ca65ebcad..6b5d7f72691 100644 --- a/gcc/config/stormy16/stormy16.cc +++ b/gcc/config/stormy16/stormy16.cc @@ -964,7 +964,7 @@ xstormy16_split_move (machine_mode mode, rtx dest, rtx src) end = direction < 0 ? -1 : num_words; for (i = direction < 0 ? num_words - 1 : 0; i != end; i += direction) { - rtx w_src, w_dest, insn; + rtx w_src, w_dest; if (src_modifies) w_src = gen_rtx_MEM (word_mode, mem_operand); @@ -984,7 +984,7 @@ xstormy16_split_move (machine_mode mode, rtx dest, rtx src) gcc_assert (GET_CODE (w_src) != SUBREG && GET_CODE (w_dest) != SUBREG); - insn = emit_insn (gen_rtx_SET (w_dest, w_src)); + rtx_insn *insn = emit_insn (gen_rtx_SET (w_dest, w_src)); if (auto_inc_reg_rtx) REG_NOTES (insn) = alloc_EXPR_LIST (REG_INC, auto_inc_reg_rtx, @@ -1164,7 +1164,8 @@ xstormy16_initial_elimination_offset (int from, int to) static rtx emit_addhi3_postreload (rtx dest, rtx src0, rtx src1) { - rtx set, clobber, insn; + rtx set, clobber; + rtx_insn *insn; set = gen_rtx_SET (dest, gen_rtx_PLUS (HImode, src0, src1)); clobber = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (BImode, CARRY_REGNUM)); diff --git a/gcc/config/v850/v850.cc b/gcc/config/v850/v850.cc index cd6ba13b4b3..d608469b714 100644 --- a/gcc/config/v850/v850.cc +++ b/gcc/config/v850/v850.cc @@ -1726,7 +1726,7 @@ expand_prologue (void) code = recog (save_all, NULL, NULL); if (code >= 0) { - rtx insn = emit_insn (save_all); + rtx_insn *insn = emit_insn (save_all); INSN_CODE (insn) = code; actual_fsize -= alloc_stack; @@ -1873,12 +1873,11 @@ expand_epilogue (void) if (code >= 0) { - rtx insn; actual_fsize -= alloc_stack; increment_stack (actual_fsize, false); - insn = emit_jump_insn (restore_all); + rtx_insn *insn = emit_jump_insn (restore_all); INSN_CODE (insn) = code; } else diff --git a/gcc/config/vax/vax.cc b/gcc/config/vax/vax.cc index 47bdfadfde1..3cb5d828f1a 100644 --- a/gcc/config/vax/vax.cc +++ b/gcc/config/vax/vax.cc @@ -185,7 +185,7 @@ vax_expand_prologue (void) int regno, offset; int mask = 0; HOST_WIDE_INT size; - rtx insn; + rtx_insn *insn; for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) if (df_regs_ever_live_p (regno) && !call_used_or_fixed_reg_p (regno)) diff --git a/gcc/config/visium/visium.cc b/gcc/config/visium/visium.cc index d59f95ca6d1..5ba6f0d7984 100644 --- a/gcc/config/visium/visium.cc +++ b/gcc/config/visium/visium.cc @@ -980,13 +980,12 @@ ok_for_simple_arith_logic_operands (rtx *, machine_mode) int empty_delay_slot (rtx_insn *insn) { - rtx seq; /* If no previous instruction (should not happen), return true. */ if (PREV_INSN (insn) == NULL) return 1; - seq = NEXT_INSN (PREV_INSN (insn)); + rtx_insn *seq = NEXT_INSN (PREV_INSN (insn)); if (GET_CODE (PATTERN (seq)) == SEQUENCE) return 0; diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index 6e2e575acb3..cee66607498 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -1290,7 +1290,7 @@ xtensa_emit_move_sequence (rtx *operands, machine_mode mode) rtx xtensa_copy_incoming_a7 (rtx opnd) { - rtx entry_insns = 0; + rtx_insn *entry_insns = 0; rtx reg, tmp; machine_mode mode; @@ -4002,7 +4002,7 @@ xtensa_set_return_address (rtx address, rtx scratch) total_size - UNITS_PER_WORD); rtx note = gen_rtx_SET (gen_frame_mem (SImode, a0_addr), gen_rtx_REG (SImode, A0_REG)); - rtx insn; + rtx_insn *insn; if (total_size > 1024) { diff --git a/gcc/final.cc b/gcc/final.cc index c3c45715263..af167319beb 100644 --- a/gcc/final.cc +++ b/gcc/final.cc @@ -948,7 +948,8 @@ shorten_branches (rtx_insn *first) for (insn = first; insn != 0; insn = NEXT_INSN (insn)) { - rtx min_lab = NULL_RTX, max_lab = NULL_RTX, pat; + rtx_insn *min_lab = nullptr, *max_lab = nullptr; + rtx pat; int len, i, min, max, insn_shuid; int min_align; addr_diff_vec_flags flags; diff --git a/gcc/reorg.cc b/gcc/reorg.cc index 5bda9435a17..22d23746d11 100644 --- a/gcc/reorg.cc +++ b/gcc/reorg.cc @@ -1225,7 +1225,7 @@ try_merge_delay_insns (rtx_insn *insn, rtx_insn *thread) for (trial = thread; !stop_search_p (trial, true); trial = next_trial) { rtx pat = PATTERN (trial); - rtx oldtrial = trial; + rtx_insn *oldtrial = trial; next_trial = next_nonnote_insn (trial); @@ -2340,7 +2340,8 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition, ! stop_search_p (trial, ! thread_if_true) && (! lose || own_thread); trial = next_nonnote_insn (trial)) { - rtx pat, old_trial; + rtx pat; + rtx_insn *old_trial; /* If we have passed a label, we no longer own this thread. */ if (LABEL_P (trial)) @@ -3501,7 +3502,8 @@ make_return_insns (rtx_insn *first) for (insn = first; insn; insn = NEXT_INSN (insn)) { int flags; - rtx kind, real_label; + rtx kind; + rtx_insn *real_label; /* Only look at filled JUMP_INSNs that go to the end of function label. */ diff --git a/gcc/tree-outof-ssa.cc b/gcc/tree-outof-ssa.cc index f113709e50d..c78b70914c7 100644 --- a/gcc/tree-outof-ssa.cc +++ b/gcc/tree-outof-ssa.cc @@ -308,7 +308,7 @@ insert_partition_copy_on_edge (edge e, int dest, int src, location_t locus) static void insert_value_copy_on_edge (edge e, int dest, tree src, location_t locus) { - rtx dest_rtx, seq, x; + rtx dest_rtx, x; machine_mode dest_mode, src_mode; int unsignedp; @@ -356,7 +356,7 @@ insert_value_copy_on_edge (edge e, int dest, tree src, location_t locus) emit_move_insn (dest_rtx, x); do_pending_stack_adjust (); - seq = end_sequence (); + rtx_insn *seq = end_sequence (); insert_insn_on_edge (seq, e); } -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:48 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:48 -0500 Subject: [PATCH 07/25] Use rtx_insn * for returns that are already an insn In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-8-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * compare-elim.cc (try_validate_parallel): Return an rtx_insn *. * config/aarch64/aarch64.cc (aarch64_emit_move): Likewise. * config/alpha/alpha-protos.h (alpha_emit_unlikely_jump): Likewise. * config/alpha/alpha.cc (alpha_emit_unlikely_jump): Likewise. * config/arc/arc.cc (frame_insn, frame_move, frame_move_inc, frame_add, frame_stack_add): Likewise. * config/arm/arm.cc (emit_multi_reg_push): Likewise. * config/cris/cris-protos.h (cris_split_movdx, cris_emit_movem_store): Likewise. * config/cris/cris.cc (cris_split_movdx, cris_emit_movem_store): Likewise. * config/csky/csky.cc (emit_csky_regs_push): Likewise. * config/fr30/fr30-protos.h (fr30_move_double): Likewise. * config/fr30/fr30.cc (fr30_move_double): Likewise. * config/frv/frv-protos.h (frv_split_scc, frv_split_cond_move, frv_split_minmax, frv_split_abs): Likewise. * config/frv/frv.cc (frv_split_scc, frv_split_cond_move, frv_split_minmax, frv_split_abs): Likewise. * config/h8300/h8300.cc (push, pop): Likewise. * config/i386/i386.cc (pro_epilogue_adjust_stack): Likewise. * config/lm32/lm32.cc (emit_add): Likewise. * config/loongarch/loongarch-protos.h (loongarch_emit_move): Likewise. * config/loongarch/loongarch.cc (loongarch_emit_move): Likewise. * config/m32r/m32r-protos.h (gen_split_move_double): Likewise. * config/m32r/m32r.cc (gen_split_move_double): Likewise. * config/pru/pru.cc (pru_add3_frame_adjust, pru_add_to_sp): Likewise. * config/riscv/riscv-protos.h (riscv_emit_move): Likewise. * config/riscv/riscv.cc (riscv_emit_move): Likewise. * config/rs6000/rs6000-logue.cc (rs6000_emit_stack_reset): Likewise. * config/s390/s390.cc (save_fpr, restore_fpr, s390_prologue_plus_offset): Likewise. * config/sh/sh.cc (push, emit_load_ptr): Likewise. * config/sh/sh_treg_combine.cc (make_not_reg_insn): Likewise. * config/stormy16/stormy16.cc (emit_addhi3_postreload): Likewise. * config/visium/visium.cc (emit_frame_insn): Likewise. --- gcc/compare-elim.cc | 4 ++-- gcc/config/aarch64/aarch64.cc | 2 +- gcc/config/alpha/alpha-protos.h | 2 +- gcc/config/alpha/alpha.cc | 2 +- gcc/config/arc/arc.cc | 22 +++++++++++----------- gcc/config/arm/arm.cc | 10 +++++----- gcc/config/cris/cris-protos.h | 4 ++-- gcc/config/cris/cris.cc | 4 ++-- gcc/config/csky/csky.cc | 10 +++++----- gcc/config/fr30/fr30-protos.h | 2 +- gcc/config/fr30/fr30.cc | 2 +- gcc/config/frv/frv-protos.h | 8 ++++---- gcc/config/frv/frv.cc | 8 ++++---- gcc/config/h8300/h8300.cc | 16 ++++++++-------- gcc/config/i386/i386.cc | 2 +- gcc/config/lm32/lm32.cc | 4 ++-- gcc/config/loongarch/loongarch-protos.h | 2 +- gcc/config/loongarch/loongarch.cc | 2 +- gcc/config/m32r/m32r-protos.h | 2 +- gcc/config/m32r/m32r.cc | 2 +- gcc/config/pru/pru.cc | 4 ++-- gcc/config/riscv/riscv-protos.h | 2 +- gcc/config/riscv/riscv.cc | 2 +- gcc/config/rs6000/rs6000-logue.cc | 6 +++--- gcc/config/s390/s390.cc | 6 +++--- gcc/config/sh/sh.cc | 14 +++++++------- gcc/config/sh/sh_treg_combine.cc | 4 ++-- gcc/config/stormy16/stormy16.cc | 4 ++-- gcc/config/visium/visium.cc | 8 ++++---- 29 files changed, 80 insertions(+), 80 deletions(-) diff --git a/gcc/compare-elim.cc b/gcc/compare-elim.cc index 6218324e1ab..85eac146238 100644 --- a/gcc/compare-elim.cc +++ b/gcc/compare-elim.cc @@ -660,7 +660,7 @@ can_merge_compare_into_arith (rtx_insn *cmp_insn, rtx_insn *arith_insn) a recognizable pattern when emitted in parallel. Return that parallel if so. Otherwise return NULL. */ -static rtx +static rtx_insn * try_validate_parallel (rtx set_a, rtx set_b) { rtx par = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, set_a, set_b)); @@ -669,7 +669,7 @@ try_validate_parallel (rtx set_a, rtx set_b) if (insn_invalid_p (insn, false)) { crtl->emit.x_cur_insn_uid--; - return NULL_RTX; + return nullptr; } SET_PREV_INSN (insn) = NULL_RTX; diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 512795fd769..62532719724 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -3809,7 +3809,7 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm, important because, unlike emit_move_insn, the move expanders know how to force Pmode objects into the constant pool even when the constant pool address is not itself legitimate. */ -static rtx +static rtx_insn * aarch64_emit_move (rtx dest, rtx src) { return (can_create_pseudo_p () diff --git a/gcc/config/alpha/alpha-protos.h b/gcc/config/alpha/alpha-protos.h index 66a1b5a6a6b..bb81d856d0d 100644 --- a/gcc/config/alpha/alpha-protos.h +++ b/gcc/config/alpha/alpha-protos.h @@ -74,7 +74,7 @@ extern rtx alpha_expand_zap_mask (HOST_WIDE_INT); extern void alpha_expand_builtin_vector_binop (rtx (*)(rtx, rtx, rtx), machine_mode, rtx, rtx, rtx); -extern rtx alpha_emit_unlikely_jump (rtx, rtx); +extern rtx_insn *alpha_emit_unlikely_jump (rtx, rtx); extern void alpha_expand_builtin_establish_vms_condition_handler (rtx, rtx); extern void alpha_expand_builtin_revert_vms_condition_handler (rtx); diff --git a/gcc/config/alpha/alpha.cc b/gcc/config/alpha/alpha.cc index cc2b1fe95e7..ab29b254d30 100644 --- a/gcc/config/alpha/alpha.cc +++ b/gcc/config/alpha/alpha.cc @@ -5120,7 +5120,7 @@ alpha_expand_builtin_vector_binop (rtx (*gen) (rtx, rtx, rtx), /* A subroutine of the atomic operation splitters. Jump to LABEL if COND is true. Mark the jump as unlikely to be taken. */ -rtx +rtx_insn * alpha_emit_unlikely_jump (rtx cond, rtx label) { rtx x = gen_rtx_IF_THEN_ELSE (VOIDmode, cond, label, pc_rtx); diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc index ad6a2337f58..cab30948a33 100644 --- a/gcc/config/arc/arc.cc +++ b/gcc/config/arc/arc.cc @@ -588,7 +588,7 @@ static rtx arc_delegitimize_address (rtx); static bool arc_can_follow_jump (const rtx_insn *follower, const rtx_insn *followee); -static rtx frame_insn (rtx); +static rtx_insn *frame_insn (rtx); static void arc_function_arg_advance (cumulative_args_t, const function_arg_info &); static rtx arc_legitimize_address_0 (rtx, rtx, machine_mode mode); @@ -2488,17 +2488,17 @@ arc_address_cost (rtx addr, machine_mode, addr_space_t, bool speed) /* Emit instruction X with the frame related bit set. */ -static rtx +static rtx_insn * frame_insn (rtx x) { - x = emit_insn (x); - RTX_FRAME_RELATED_P (x) = 1; - return x; + rtx_insn *insn = emit_insn (x); + RTX_FRAME_RELATED_P (insn) = 1; + return insn; } /* Emit a frame insn to move SRC to DST. */ -static rtx +static rtx_insn * frame_move (rtx dst, rtx src) { rtx tmp = gen_rtx_SET (dst, src); @@ -2509,10 +2509,10 @@ frame_move (rtx dst, rtx src) /* Like frame_move, but add a REG_INC note for REG if ADDR contains an auto increment address, or is zero. */ -static rtx +static rtx_insn * frame_move_inc (rtx dst, rtx src, rtx reg, rtx addr) { - rtx insn = frame_move (dst, src); + rtx_insn *insn = frame_move (dst, src); if (!addr || GET_CODE (addr) == PRE_DEC || GET_CODE (addr) == POST_INC @@ -2523,18 +2523,18 @@ frame_move_inc (rtx dst, rtx src, rtx reg, rtx addr) /* Emit a frame insn which adjusts a frame address register REG by OFFSET. */ -static rtx +static rtx_insn * frame_add (rtx reg, HOST_WIDE_INT offset) { gcc_assert ((offset & 0x3) == 0); if (!offset) - return NULL_RTX; + return nullptr; return frame_move (reg, plus_constant (Pmode, reg, offset)); } /* Emit a frame insn which adjusts stack pointer by OFFSET. */ -static rtx +static rtx_insn * frame_stack_add (HOST_WIDE_INT offset) { return frame_add (stack_pointer_rtx, offset); diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 599c4e4925e..fdb0bd792c0 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -173,7 +173,7 @@ static int arm_memory_move_cost (machine_mode, reg_class_t, bool); static void emit_constant_insn (rtx cond, rtx pattern); static rtx_insn *emit_set_insn (rtx, rtx); static void arm_add_cfa_adjust_cfa_note (rtx, int, rtx, rtx); -static rtx emit_multi_reg_push (unsigned long, unsigned long); +static rtx_insn *emit_multi_reg_push (unsigned long, unsigned long); static void arm_emit_multi_reg_pop (unsigned long); static int vfp_emit_fstmd (int, int); static void arm_emit_vfp_multi_reg_pop (int, int, rtx); @@ -21334,7 +21334,7 @@ arm_emit_strd_push (unsigned long saved_regs_mask) of DWARF2 frame unwind information. DWARF_REGS_MASK is a subset of MASK for registers that should be annotated for DWARF2 frame unwind information. */ -static rtx +static rtx_insn * emit_multi_reg_push (unsigned long mask, unsigned long dwarf_regs_mask) { int num_regs = 0; @@ -21486,16 +21486,16 @@ emit_multi_reg_push (unsigned long mask, unsigned long dwarf_regs_mask) } } - par = emit_insn (par); + rtx_insn *insn = emit_insn (par); tmp = gen_rtx_SET (stack_pointer_rtx, plus_constant (Pmode, stack_pointer_rtx, -4 * num_regs)); RTX_FRAME_RELATED_P (tmp) = 1; XVECEXP (dwarf, 0, 0) = tmp; - add_reg_note (par, REG_FRAME_RELATED_EXPR, dwarf); + add_reg_note (insn, REG_FRAME_RELATED_EXPR, dwarf); - return par; + return insn; } /* Add a REG_CFA_ADJUST_CFA REG note to INSN. diff --git a/gcc/config/cris/cris-protos.h b/gcc/config/cris/cris-protos.h index bc5ee6022a0..b92df785146 100644 --- a/gcc/config/cris/cris-protos.h +++ b/gcc/config/cris/cris-protos.h @@ -29,7 +29,7 @@ extern int cris_side_effect_mode_ok (enum rtx_code, rtx *, int, int, int, int, int); extern rtx cris_return_addr_rtx (int, rtx); extern rtx cris_eh_return_handler_rtx (); -extern rtx cris_split_movdx (rtx *); +extern rtx_insn *cris_split_movdx (rtx *); extern bool cris_base_p (const_rtx, bool); extern bool cris_base_or_autoincr_p (const_rtx, bool); extern bool cris_bdap_index_p (const_rtx, bool); @@ -41,7 +41,7 @@ extern bool cris_movem_load_rest_p (rtx); extern void cris_asm_output_symbol_ref (FILE *, rtx); extern void cris_asm_output_case_end (FILE *, int, rtx_insn *); extern rtx cris_gen_movem_load (rtx, rtx); -extern rtx cris_emit_movem_store (rtx, rtx, int, bool); +extern rtx_insn *cris_emit_movem_store (rtx, rtx, int, bool); extern rtx_insn *cris_emit_insn (rtx x); extern void cris_order_for_addsi3 (rtx *, int); extern void cris_emit_trap_for_misalignment (rtx); diff --git a/gcc/config/cris/cris.cc b/gcc/config/cris/cris.cc index 425300aca8b..45886ec6351 100644 --- a/gcc/config/cris/cris.cc +++ b/gcc/config/cris/cris.cc @@ -2536,7 +2536,7 @@ cris_init_machine_status (void) /* Split a 2 word move (DI or presumably DF) into component parts. Originally a copy of gen_split_move_double in m32r.cc. */ -rtx +rtx_insn * cris_split_movdx (rtx *operands) { machine_mode mode = GET_MODE (operands[0]); @@ -3372,7 +3372,7 @@ cris_emit_insn (rtx x) /* Worker function for generating movem to mem. If FRAME_RELATED, notes are added that the dwarf2 machinery understands. */ -rtx +rtx_insn * cris_emit_movem_store (rtx dest, rtx nregs_rtx, int increment, bool frame_related) { diff --git a/gcc/config/csky/csky.cc b/gcc/config/csky/csky.cc index 29193e287a3..a1744c8547d 100644 --- a/gcc/config/csky/csky.cc +++ b/gcc/config/csky/csky.cc @@ -5501,7 +5501,7 @@ expand_csky_stack_adjust (int offset) MASK for registers that should be annotated for DWARF2 frame unwind information. */ -static rtx +static rtx_insn * emit_csky_regs_push (unsigned long mask) { int num_regs = 0; @@ -5597,17 +5597,17 @@ emit_csky_regs_push (unsigned long mask) j++; } - par = emit_insn (par); + rtx_insn *insn = emit_insn (par); tmp = gen_rtx_SET (stack_pointer_rtx, plus_constant (Pmode, stack_pointer_rtx, -4 * num_regs)); RTX_FRAME_RELATED_P (tmp) = 1; XVECEXP (dwarf, 0, 0) = tmp; - add_reg_note (par, REG_FRAME_RELATED_EXPR, dwarf); - RTX_FRAME_RELATED_P (par) = 1; + add_reg_note (insn, REG_FRAME_RELATED_EXPR, dwarf); + RTX_FRAME_RELATED_P (insn) = 1; - return par; + return insn; } diff --git a/gcc/config/fr30/fr30-protos.h b/gcc/config/fr30/fr30-protos.h index 393d929b965..e922e98ef16 100644 --- a/gcc/config/fr30/fr30-protos.h +++ b/gcc/config/fr30/fr30-protos.h @@ -25,7 +25,7 @@ extern unsigned int fr30_compute_frame_size (int, int); extern int fr30_check_multiple_regs (rtx *, int, int); extern void fr30_print_operand (FILE *, rtx, int); extern void fr30_print_operand_address (FILE *, rtx); -extern rtx fr30_move_double (rtx *); +extern rtx_insn *fr30_move_double (rtx *); #ifdef HAVE_MACHINE_MODES extern int fr30_const_double_is_zero (rtx); #endif /* HAVE_MACHINE_MODES */ diff --git a/gcc/config/fr30/fr30.cc b/gcc/config/fr30/fr30.cc index d1d10079188..f2e22cfae1a 100644 --- a/gcc/config/fr30/fr30.cc +++ b/gcc/config/fr30/fr30.cc @@ -878,7 +878,7 @@ fr30_const_double_is_zero (rtx operand) address of the second word into the second destination register before we can use it. */ -rtx +rtx_insn * fr30_move_double (rtx * operands) { rtx src = operands[1]; diff --git a/gcc/config/frv/frv-protos.h b/gcc/config/frv/frv-protos.h index 2e15d7492eb..49220cb74d9 100644 --- a/gcc/config/frv/frv-protos.h +++ b/gcc/config/frv/frv-protos.h @@ -54,11 +54,11 @@ extern const char *output_condmove_single (rtx *, rtx); extern int frv_emit_cond_branch (rtx *); extern int frv_emit_scc (rtx *); -extern rtx frv_split_scc (rtx, rtx, rtx, rtx, HOST_WIDE_INT); +extern rtx_insn *frv_split_scc (rtx, rtx, rtx, rtx, HOST_WIDE_INT); extern int frv_emit_cond_move (rtx, rtx, rtx, rtx); -extern rtx frv_split_cond_move (rtx *); -extern rtx frv_split_minmax (rtx *); -extern rtx frv_split_abs (rtx *); +extern rtx_insn *frv_split_cond_move (rtx *); +extern rtx_insn *frv_split_minmax (rtx *); +extern rtx_insn *frv_split_abs (rtx *); extern void frv_split_double_load (rtx, rtx); extern void frv_split_double_store (rtx, rtx); #ifdef BB_HEAD diff --git a/gcc/config/frv/frv.cc b/gcc/config/frv/frv.cc index c223ee8674b..43e9620c9c5 100644 --- a/gcc/config/frv/frv.cc +++ b/gcc/config/frv/frv.cc @@ -4734,7 +4734,7 @@ frv_emit_scc (rtx operands[]) /* Split a SCC instruction into component parts, returning a SEQUENCE to hold the separate insns. */ -rtx +rtx_insn * frv_split_scc (rtx dest, rtx test, rtx cc_reg, rtx cr_reg, HOST_WIDE_INT value) { rtx_insn *ret; @@ -4845,7 +4845,7 @@ frv_emit_cond_move (rtx dest, rtx test_rtx, rtx src1, rtx src2) /* Split a conditional move into constituent parts, returning a SEQUENCE containing all of the insns. */ -rtx +rtx_insn * frv_split_cond_move (rtx operands[]) { rtx dest = operands[0]; @@ -4994,7 +4994,7 @@ frv_split_double_store (rtx dest, rtx source) /* Split a min/max operation returning a SEQUENCE containing all of the insns. */ -rtx +rtx_insn * frv_split_minmax (rtx operands[]) { rtx dest = operands[0]; @@ -5068,7 +5068,7 @@ frv_split_minmax (rtx operands[]) /* Split an integer abs operation returning a SEQUENCE containing all of the insns. */ -rtx +rtx_insn * frv_split_abs (rtx operands[]) { rtx dest = operands[0]; diff --git a/gcc/config/h8300/h8300.cc b/gcc/config/h8300/h8300.cc index 1598a86996e..cbdf9fe34e7 100644 --- a/gcc/config/h8300/h8300.cc +++ b/gcc/config/h8300/h8300.cc @@ -573,7 +573,7 @@ compute_saved_regs (void) /* Emit an insn to push register RN. */ -static rtx +static rtx_insn * push (int rn) { rtx reg = gen_rtx_REG (word_mode, rn); @@ -583,14 +583,14 @@ push (int rn) x = gen_push_h8300hs_advanced (reg); else x = gen_push_h8300hs_normal (reg); - x = F (emit_insn (x), 0); - add_reg_note (x, REG_INC, stack_pointer_rtx); - return x; + rtx_insn *insn = F (emit_insn (x), 0); + add_reg_note (insn, REG_INC, stack_pointer_rtx); + return insn; } /* Emit an insn to pop register RN. */ -static rtx +static rtx_insn * pop (int rn) { rtx reg = gen_rtx_REG (word_mode, rn); @@ -600,9 +600,9 @@ pop (int rn) x = gen_pop_h8300hs_advanced (reg); else x = gen_pop_h8300hs_normal (reg); - x = emit_insn (x); - add_reg_note (x, REG_INC, stack_pointer_rtx); - return x; + rtx_insn *insn = emit_insn (x); + add_reg_note (insn, REG_INC, stack_pointer_rtx); + return insn; } /* Emit an instruction to push or pop NREGS consecutive registers diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index fd664fae18e..c9f8a97fae4 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -7863,7 +7863,7 @@ ix86_add_queued_cfa_restore_notes (rtx insn) zero if %r11 register is live and cannot be freely used and positive otherwise. */ -static rtx +static rtx_insn * pro_epilogue_adjust_stack (rtx dest, rtx src, rtx offset, int style, bool set_cfa) { diff --git a/gcc/config/lm32/lm32.cc b/gcc/config/lm32/lm32.cc index 21e78a961d6..690880b893e 100644 --- a/gcc/config/lm32/lm32.cc +++ b/gcc/config/lm32/lm32.cc @@ -64,7 +64,7 @@ struct lm32_frame_info }; /* Prototypes for static functions. */ -static rtx emit_add (rtx dest, rtx src0, rtx src1); +static rtx_insn *emit_add (rtx dest, rtx src0, rtx src1); static void expand_save_restore (struct lm32_frame_info *info, int op); static void stack_adjust (HOST_WIDE_INT amount); static bool lm32_in_small_data_p (const_tree); @@ -163,7 +163,7 @@ lm32_return_in_memory (tree type) /* Generate an emit a word sized add instruction. */ -static rtx +static rtx_insn * emit_add (rtx dest, rtx src0, rtx src1) { rtx_insn *insn; diff --git a/gcc/config/loongarch/loongarch-protos.h b/gcc/config/loongarch/loongarch-protos.h index e67addf36e3..0289409226f 100644 --- a/gcc/config/loongarch/loongarch-protos.h +++ b/gcc/config/loongarch/loongarch-protos.h @@ -59,7 +59,7 @@ enum loongarch_symbol_type { #define NUM_SYMBOL_TYPES (SYMBOL_TLSLDM + 1) /* Routines implemented in loongarch.cc. */ -extern rtx loongarch_emit_move (rtx, rtx); +extern rtx_insn *loongarch_emit_move (rtx, rtx); extern HOST_WIDE_INT loongarch_initial_elimination_offset (int, int); extern void loongarch_expand_prologue (void); extern void loongarch_expand_epilogue (int); diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 3cbc288ab75..bae6f602bf4 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -1061,7 +1061,7 @@ loongarch_for_each_saved_reg (HOST_WIDE_INT sp_offset, how to force Pmode objects into the constant pool even when the constant pool address is not itself legitimate. */ -rtx +rtx_insn * loongarch_emit_move (rtx dest, rtx src) { return (can_create_pseudo_p () ? emit_move_insn (dest, src) diff --git a/gcc/config/m32r/m32r-protos.h b/gcc/config/m32r/m32r-protos.h index b3a3df514e1..e1b539b4443 100644 --- a/gcc/config/m32r/m32r-protos.h +++ b/gcc/config/m32r/m32r-protos.h @@ -34,7 +34,7 @@ extern int easy_di_const (rtx); extern int easy_df_const (rtx); extern rtx gen_compare (enum rtx_code, rtx, rtx, int); extern bool gen_cond_store (enum rtx_code, rtx, rtx, rtx); -extern rtx gen_split_move_double (rtx *); +extern rtx_insn *gen_split_move_double (rtx *); extern int m32r_address_code (rtx); extern void m32r_initialize_trampoline (rtx, rtx, rtx); extern int zero_and_one (rtx, rtx); diff --git a/gcc/config/m32r/m32r.cc b/gcc/config/m32r/m32r.cc index a9ec37aebe6..023c469782c 100644 --- a/gcc/config/m32r/m32r.cc +++ b/gcc/config/m32r/m32r.cc @@ -1046,7 +1046,7 @@ gen_cond_store (enum rtx_code code, rtx op0, rtx op1, rtx op2) /* Split a 2 word move (DI or DF) into component parts. */ -rtx +rtx_insn * gen_split_move_double (rtx operands[]) { machine_mode mode = GET_MODE (operands[0]); diff --git a/gcc/config/pru/pru.cc b/gcc/config/pru/pru.cc index d6348ec296b..6bc80badbab 100644 --- a/gcc/config/pru/pru.cc +++ b/gcc/config/pru/pru.cc @@ -161,7 +161,7 @@ pru_compute_frame_layout (void) addendum - Second addendum operand (a constant). kind - Note kind. REG_NOTE_MAX if no note must be added. */ -static rtx +static rtx_insn * pru_add3_frame_adjust (rtx op0, rtx op1, int addendum, const enum reg_note kind) { @@ -200,7 +200,7 @@ pru_add3_frame_adjust (rtx op0, rtx op1, int addendum, } /* Add a const_int to the stack pointer register. */ -static rtx +static rtx_insn * pru_add_to_sp (int addendum, const enum reg_note kind) { return pru_add3_frame_adjust (stack_pointer_rtx, stack_pointer_rtx, diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h index c0fb2839780..8641eec98a2 100644 --- a/gcc/config/riscv/riscv-protos.h +++ b/gcc/config/riscv/riscv-protos.h @@ -115,7 +115,7 @@ extern int riscv_address_insns (rtx, machine_mode, bool); extern int riscv_const_insns (rtx, bool); extern int riscv_split_const_insns (rtx); extern int riscv_load_store_insns (rtx, rtx_insn *); -extern rtx riscv_emit_move (rtx, rtx); +extern rtx_insn *riscv_emit_move (rtx, rtx); extern bool riscv_split_symbol (rtx, rtx, machine_mode, rtx *); extern bool riscv_split_symbol_type (enum riscv_symbol_type); extern rtx riscv_unspec_address (rtx, enum riscv_symbol_type); diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 701bd3e5784..d91dbcf5d91 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -3149,7 +3149,7 @@ riscv_load_store_insns (rtx mem, rtx_insn *insn) how to force Pmode objects into the constant pool even when the constant pool address is not itself legitimate. */ -rtx +rtx_insn * riscv_emit_move (rtx dest, rtx src) { return (can_create_pseudo_p () diff --git a/gcc/config/rs6000/rs6000-logue.cc b/gcc/config/rs6000/rs6000-logue.cc index 9366ddd2880..d617416652b 100644 --- a/gcc/config/rs6000/rs6000-logue.cc +++ b/gcc/config/rs6000/rs6000-logue.cc @@ -2360,13 +2360,13 @@ rs6000_savres_routine_sym (rs6000_stack_t *info, int sel) reset the stack pointer, but move the base of the frame into reg UPDT_REGNO for use by out-of-line register restore routines. */ -static rtx +static rtx_insn * rs6000_emit_stack_reset (rtx frame_reg_rtx, HOST_WIDE_INT frame_off, unsigned updt_regno) { /* If there is nothing to do, don't do anything. */ if (frame_off == 0 && REGNO (frame_reg_rtx) == updt_regno) - return NULL_RTX; + return nullptr; rtx updt_reg_rtx = gen_rtx_REG (Pmode, updt_regno); @@ -2386,7 +2386,7 @@ rs6000_emit_stack_reset (rtx frame_reg_rtx, HOST_WIDE_INT frame_off, else return emit_move_insn (updt_reg_rtx, frame_reg_rtx); - return NULL_RTX; + return nullptr; } /* Return the register number used as a pointer by out-of-line diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 77dbdb83058..71d72555401 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -11751,7 +11751,7 @@ s390_initial_elimination_offset (int from, int to) /* Emit insn to save fpr REGNUM at offset OFFSET relative to register BASE. Return generated insn. */ -static rtx +static rtx_insn * save_fpr (rtx base, int offset, int regnum) { rtx addr; @@ -11782,7 +11782,7 @@ save_fpr (rtx base, int offset, int regnum) /* Emit insn to restore fpr REGNUM from offset OFFSET relative to register BASE. Return generated insn. */ -static rtx +static rtx_insn * restore_fpr (rtx base, int offset, int regnum) { rtx addr; @@ -12138,7 +12138,7 @@ make_pass_s390_early_mach (gcc::context *ctxt) - push too big immediates to the literal pool and annotate the refs - emit frame related notes for stack pointer changes. */ -static rtx +static rtx_insn * s390_prologue_plus_offset (rtx target, rtx reg, rtx offset, bool frame_related_p) { rtx_insn *insn; diff --git a/gcc/config/sh/sh.cc b/gcc/config/sh/sh.cc index d33da7bfb1c..2a863d6dbb4 100644 --- a/gcc/config/sh/sh.cc +++ b/gcc/config/sh/sh.cc @@ -188,7 +188,7 @@ static void sh_option_override (void); static void sh_override_options_after_change (void); static void output_stack_adjust (int, rtx, int, HARD_REG_SET *, bool); static rtx_insn* emit_frame_insn (rtx); -static rtx push (int); +static rtx_insn *push (int); static void pop (int); static void push_regs (HARD_REG_SET* mask, bool interrupt_handler); static int calc_live_regs (HARD_REG_SET *); @@ -6841,7 +6841,7 @@ emit_frame_insn (rtx x) } /* Output RTL to push register RN onto the stack. */ -static rtx +static rtx_insn * push (int rn) { rtx x; @@ -6853,7 +6853,7 @@ push (int rn) && ! TARGET_FPU_SINGLE && FP_OR_XD_REGISTER_P (rn)) { if (FP_REGISTER_P (rn) && (rn - FIRST_FP_REG) & 1) - return NULL_RTX; + return nullptr; x = gen_push_4 (gen_rtx_REG (DFmode, rn)); } else if (TARGET_SH2E && FP_REGISTER_P (rn)) @@ -6861,9 +6861,9 @@ push (int rn) else x = gen_push (gen_rtx_REG (SImode, rn)); - x = emit_frame_insn (x); - add_reg_note (x, REG_INC, gen_rtx_REG (SImode, STACK_POINTER_REGNUM)); - return x; + rtx_insn *insn = emit_frame_insn (x); + add_reg_note (insn, REG_INC, gen_rtx_REG (SImode, STACK_POINTER_REGNUM)); + return insn; } /* Output RTL to pop register RN from the stack. */ @@ -10732,7 +10732,7 @@ sh_register_move_cost (machine_mode mode, return 2 * ((GET_MODE_SIZE (mode) + 3) / 4U); } -static rtx +static rtx_insn * emit_load_ptr (rtx reg, rtx addr) { rtx mem = gen_const_mem (ptr_mode, addr); diff --git a/gcc/config/sh/sh_treg_combine.cc b/gcc/config/sh/sh_treg_combine.cc index ffa0932b746..a8a8a355eba 100644 --- a/gcc/config/sh/sh_treg_combine.cc +++ b/gcc/config/sh/sh_treg_combine.cc @@ -586,7 +586,7 @@ private: // Create an insn rtx that performs a logical not (test != 0) on the src_reg // and stores the result in dst_reg. - rtx make_not_reg_insn (rtx dst_reg, rtx src_reg) const; + rtx_insn *make_not_reg_insn (rtx dst_reg, rtx src_reg) const; // Create an insn rtx that inverts the ccreg. rtx_insn *make_inv_ccreg_insn (void) const; @@ -919,7 +919,7 @@ sh_treg_combine::can_remove_comparison (const bb_entry& e, return true; } -rtx +rtx_insn * sh_treg_combine::make_not_reg_insn (rtx dst_reg, rtx src_reg) const { // On SH we can do only SImode and DImode comparisons. diff --git a/gcc/config/stormy16/stormy16.cc b/gcc/config/stormy16/stormy16.cc index 6b5d7f72691..6b3bfe6836d 100644 --- a/gcc/config/stormy16/stormy16.cc +++ b/gcc/config/stormy16/stormy16.cc @@ -54,7 +54,7 @@ /* This file should be included last. */ #include "target-def.h" -static rtx emit_addhi3_postreload (rtx, rtx, rtx); +static rtx_insn *emit_addhi3_postreload (rtx, rtx, rtx); static void xstormy16_asm_out_constructor (rtx, int); static void xstormy16_asm_out_destructor (rtx, int); static void xstormy16_asm_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, @@ -1161,7 +1161,7 @@ xstormy16_initial_elimination_offset (int from, int to) return result; } -static rtx +static rtx_insn * emit_addhi3_postreload (rtx dest, rtx src0, rtx src1) { rtx set, clobber; diff --git a/gcc/config/visium/visium.cc b/gcc/config/visium/visium.cc index 5ba6f0d7984..99b4f9dd4c4 100644 --- a/gcc/config/visium/visium.cc +++ b/gcc/config/visium/visium.cc @@ -3748,12 +3748,12 @@ visium_epilogue_uses (int regno) /* Wrapper around emit_insn that sets RTX_FRAME_RELATED_P on the insn. */ -static rtx +static rtx_insn * emit_frame_insn (rtx x) { - x = emit_insn (x); - RTX_FRAME_RELATED_P (x) = 1; - return x; + rtx_insn *insn = emit_insn (x); + RTX_FRAME_RELATED_P (insn) = 1; + return insn; } /* Allocate ALLOC bytes on the stack and save the registers LOW_REGNO to -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:49 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:49 -0500 Subject: [PATCH 08/25] Pass a const rtx_insn * to the EH throw helpers In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-9-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * except.cc (insn_could_throw_p, get_eh_region_and_lp_from_rtx, get_eh_landing_pad_from_rtx, can_throw_internal, can_throw_external, insn_nothrow_p, convert_to_eh_region_ranges): Take a const rtx_insn *. * except.h (get_eh_landing_pad_from_rtx): Likewise. * rtl.h (can_throw_internal, can_throw_external, insn_could_throw_p, insn_nothrow_p): Likewise. * cse.cc (count_reg_usage): Likewise. * reorg.cc (relax_delay_slots): Likewise. --- gcc/cse.cc | 3 ++- gcc/except.cc | 22 +++++++++++----------- gcc/except.h | 2 +- gcc/reorg.cc | 2 +- gcc/rtl.h | 8 ++++---- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/gcc/cse.cc b/gcc/cse.cc index 230f4706a8e..53483b967ed 100644 --- a/gcc/cse.cc +++ b/gcc/cse.cc @@ -7155,7 +7155,8 @@ count_reg_usage (rtx x, int *counts, rtx dest, int incr) /* We expect dest to be NULL_RTX here. If the insn may throw, or if it cannot be deleted due to side-effects, mark this fact by setting DEST to pc_rtx. */ - if ((!cfun->can_delete_dead_exceptions && !insn_nothrow_p (x)) + if ((!cfun->can_delete_dead_exceptions + && !insn_nothrow_p (as_a (x))) || side_effects_p (PATTERN (x))) dest = pc_rtx; if (code == CALL_INSN) diff --git a/gcc/except.cc b/gcc/except.cc index 0a15d747162..1a7ff2b21ce 100644 --- a/gcc/except.cc +++ b/gcc/except.cc @@ -209,7 +209,7 @@ action_record_hasher::equal (const action_record *entry, typedef hash_table action_hash_type; -static bool get_eh_region_and_lp_from_rtx (const_rtx, eh_region *, +static bool get_eh_region_and_lp_from_rtx (const rtx_insn *, eh_region *, eh_landing_pad *); static void dw2_build_landing_pads (void); @@ -1752,7 +1752,7 @@ make_reg_eh_region_note_nothrow_nononlocal (rtx_insn *insn) to the contrary. */ bool -insn_could_throw_p (const_rtx insn) +insn_could_throw_p (const rtx_insn *insn) { if (!flag_exceptions) return false; @@ -1817,7 +1817,7 @@ copy_reg_eh_region_note_backward (rtx note_or_insn, rtx_insn *last, rtx first) was marked NOTHROW. */ static bool -get_eh_region_and_lp_from_rtx (const_rtx insn, eh_region *pr, +get_eh_region_and_lp_from_rtx (const rtx_insn *insn, eh_region *pr, eh_landing_pad *plp) { rtx note; @@ -1855,7 +1855,7 @@ get_eh_region_and_lp_from_rtx (const_rtx insn, eh_region *pr, have a reachable landing pad within this function. */ eh_landing_pad -get_eh_landing_pad_from_rtx (const_rtx insn) +get_eh_landing_pad_from_rtx (const rtx_insn *insn) { eh_landing_pad lp; eh_region r; @@ -1880,7 +1880,7 @@ get_eh_region_from_rtx (const rtx_insn *insn) /* Return true if INSN throws and is caught by something in this function. */ bool -can_throw_internal (const_rtx insn) +can_throw_internal (const rtx_insn *insn) { return get_eh_landing_pad_from_rtx (insn) != NULL; } @@ -1888,7 +1888,7 @@ can_throw_internal (const_rtx insn) /* Return true if INSN throws and escapes from the current function. */ bool -can_throw_external (const_rtx insn) +can_throw_external (const rtx_insn *insn) { eh_landing_pad lp; eh_region r; @@ -1903,7 +1903,7 @@ can_throw_external (const_rtx insn) int i, n = seq->len (); for (i = 0; i < n; i++) - if (can_throw_external (seq->element (i))) + if (can_throw_external (seq->insn (i))) return true; return false; @@ -1932,7 +1932,7 @@ can_throw_external (const_rtx insn) /* Return true if INSN cannot throw at all. */ bool -insn_nothrow_p (const_rtx insn) +insn_nothrow_p (const rtx_insn *insn) { eh_landing_pad lp; eh_region r; @@ -1946,7 +1946,7 @@ insn_nothrow_p (const_rtx insn) int i, n = seq->len (); for (i = 0; i < n; i++) - if (!insn_nothrow_p (seq->element (i))) + if (!insn_nothrow_p (seq->insn (i))) return false; return true; @@ -2569,7 +2569,7 @@ maybe_add_nop_after_section_switch (void) static unsigned int convert_to_eh_region_ranges (void) { - rtx insn; + rtx_insn *insn; rtx_insn *iter; rtx_note *note; action_hash_type ar_hash (31); @@ -2598,7 +2598,7 @@ convert_to_eh_region_ranges (void) insn = iter; rtx_sequence *seq = dyn_cast (PATTERN (insn)); if (NONJUMP_INSN_P (insn) && seq) - insn = seq->element (0); + insn = seq->insn (0); nothrow = get_eh_region_and_lp_from_rtx (insn, ®ion, &lp); if (nothrow) diff --git a/gcc/except.h b/gcc/except.h index 2757be9571a..f0e89fa15dc 100644 --- a/gcc/except.h +++ b/gcc/except.h @@ -279,7 +279,7 @@ extern tree lookup_type_for_runtime (tree); extern void assign_filter_values (void); extern eh_region get_eh_region_from_rtx (const rtx_insn *); -extern eh_landing_pad get_eh_landing_pad_from_rtx (const_rtx); +extern eh_landing_pad get_eh_landing_pad_from_rtx (const rtx_insn *); extern void finish_eh_generation (void); diff --git a/gcc/reorg.cc b/gcc/reorg.cc index 22d23746d11..1b6870b69f6 100644 --- a/gcc/reorg.cc +++ b/gcc/reorg.cc @@ -3285,7 +3285,7 @@ relax_delay_slots (rtx_insn *first) trial = next_real_nondebug_insn (as_a (target_label)); if (trial && GET_CODE (PATTERN (trial)) != SEQUENCE && redundant_insn (trial, insn, vNULL) - && ! can_throw_internal (trial)) + && ! can_throw_internal (as_a (trial))) { /* Figure out where to emit the special USE insn so we don't later incorrectly compute register live/death info. */ diff --git a/gcc/rtl.h b/gcc/rtl.h index fba89b3187e..64b53b9b342 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3774,10 +3774,10 @@ extern bool volatile_insn_p (const_rtx); extern bool may_trap_p_1 (const_rtx, unsigned); extern bool may_trap_p (const_rtx); extern bool may_trap_or_fault_p (const_rtx); -extern bool can_throw_internal (const_rtx); -extern bool can_throw_external (const_rtx); -extern bool insn_could_throw_p (const_rtx); -extern bool insn_nothrow_p (const_rtx); +extern bool can_throw_internal (const rtx_insn *); +extern bool can_throw_external (const rtx_insn *); +extern bool insn_could_throw_p (const rtx_insn *); +extern bool insn_nothrow_p (const rtx_insn *); extern bool can_nonlocal_goto (const rtx_insn *); extern void copy_reg_eh_region_note_forward (rtx, rtx_insn *, rtx); extern void copy_reg_eh_region_note_backward (rtx, rtx_insn *, rtx); -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:50 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:50 -0500 Subject: [PATCH 09/25] Use rtx_insn * for locals set from insn returns In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-10-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * compare-elim.cc (try_merge_compare): Use rtx_insn * for a local set from a function that returns an insn. * config/alpha/alpha.md (reload_out_safe_bwa, reload_out_aligned): Likewise. * config/arc/arc.cc (frame_restore_reg, arc_restore_callee_saves, arc_restore_callee_milli): Likewise. * config/arm/arm.cc (arm_expand_prologue): Likewise. * config/cris/cris.cc (cris_expand_prologue): Likewise. * config/lm32/lm32.cc (expand_save_restore, stack_adjust, lm32_expand_prologue): Likewise. * config/loongarch/loongarch.cc (loongarch_restore_reg): Likewise. * config/riscv/riscv.cc (riscv_restore_reg): Likewise. * config/s390/s390.cc (s390_emit_prologue): Likewise. * config/sh/sh_treg_combine.cc (try_combine_comparisons): Likewise. * config/stormy16/stormy16.cc (xstormy16_expand_prologue): Likewise. * config/visium/visium.cc (visium_save_regs, visium_expand_prologue, visium_restore_regs, visium_expand_epilogue): Likewise. --- gcc/compare-elim.cc | 2 +- gcc/config/alpha/alpha.md | 4 ++-- gcc/config/arc/arc.cc | 10 +++++----- gcc/config/arm/arm.cc | 19 ++++++++++--------- gcc/config/cris/cris.cc | 3 ++- gcc/config/lm32/lm32.cc | 6 +++--- gcc/config/loongarch/loongarch.cc | 2 +- gcc/config/riscv/riscv.cc | 2 +- gcc/config/s390/s390.cc | 3 ++- gcc/config/sh/sh_treg_combine.cc | 2 +- gcc/config/stormy16/stormy16.cc | 2 +- gcc/config/visium/visium.cc | 17 +++++++++-------- 12 files changed, 38 insertions(+), 34 deletions(-) diff --git a/gcc/compare-elim.cc b/gcc/compare-elim.cc index 85eac146238..e4d9d57e313 100644 --- a/gcc/compare-elim.cc +++ b/gcc/compare-elim.cc @@ -738,7 +738,7 @@ try_merge_compare (struct comparison *cmp) copy_rtx (src), CONST0_RTX (GET_MODE (src)))); rtx arith_set = copy_rtx (PATTERN (def_insn)); - rtx par = try_validate_parallel (flag_set, arith_set); + rtx_insn *par = try_validate_parallel (flag_set, arith_set); if (!par) { /* We may already have a change group going through maybe_select_cc_mode. diff --git a/gcc/config/alpha/alpha.md b/gcc/config/alpha/alpha.md index 80bc27556bd..39f25578cf4 100644 --- a/gcc/config/alpha/alpha.md +++ b/gcc/config/alpha/alpha.md @@ -4601,7 +4601,7 @@ rtx label_ref = gen_rtx_LABEL_REF (DImode, label); rtx cond = gen_rtx_EQ (DImode, status, const0_rtx); - rtx jump = alpha_emit_unlikely_jump (cond, label_ref); + rtx_insn *jump = alpha_emit_unlikely_jump (cond, label_ref); JUMP_LABEL (jump) = label; cfun->split_basic_blocks_after_reload = 1; @@ -4655,7 +4655,7 @@ rtx label_ref = gen_rtx_LABEL_REF (DImode, label); rtx cond = gen_rtx_EQ (DImode, gen_rtx_SUBREG (DImode, status, 0), const0_rtx); - rtx jump = alpha_emit_unlikely_jump (cond, label_ref); + rtx_insn *jump = alpha_emit_unlikely_jump (cond, label_ref); JUMP_LABEL (jump) = label; cfun->split_basic_blocks_after_reload = 1; diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc index cab30948a33..d799f9f265b 100644 --- a/gcc/config/arc/arc.cc +++ b/gcc/config/arc/arc.cc @@ -3018,7 +3018,7 @@ push_reg (rtx reg) static int frame_restore_reg (rtx reg, HOST_WIDE_INT offset) { - rtx addr, insn; + rtx addr; if (offset) { @@ -3032,7 +3032,7 @@ frame_restore_reg (rtx reg, HOST_WIDE_INT offset) else addr = gen_frame_mem (GET_MODE (reg), gen_rtx_POST_INC (Pmode, stack_pointer_rtx)); - insn = frame_move_inc (reg, addr, stack_pointer_rtx, 0); + rtx_insn *insn = frame_move_inc (reg, addr, stack_pointer_rtx, 0); add_reg_note (insn, REG_CFA_RESTORE, reg); if (reg == hard_frame_pointer_rtx) @@ -3199,8 +3199,8 @@ arc_restore_callee_saves (uint64_t gmask, { rtx addr = plus_constant (Pmode, stack_pointer_rtx, offs); reg = gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM); - rtx insn = frame_move_inc (reg, gen_frame_mem (Pmode, addr), - stack_pointer_rtx, NULL_RTX); + rtx_insn *insn = frame_move_inc (reg, gen_frame_mem (Pmode, addr), + stack_pointer_rtx, NULL_RTX); add_reg_note (insn, REG_CFA_RESTORE, reg); restore_blink = false; } @@ -3688,7 +3688,7 @@ arc_restore_callee_milli (uint64_t gmask, mem = gen_frame_mem (SImode, plus_constant (Pmode, stack_pointer_rtx, off)); - rtx tmp = frame_move_inc (reg, mem, stack_pointer_rtx, 0); + rtx_insn *tmp = frame_move_inc (reg, mem, stack_pointer_rtx, 0); add_reg_note (tmp, REG_CFA_RESTORE, reg); off += UNITS_PER_WORD; } diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index fdb0bd792c0..7c2e0675da0 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -22649,7 +22649,7 @@ void arm_expand_prologue (void) { rtx amount; - rtx insn; + rtx_insn *insn; rtx ip_rtx; unsigned long live_regs_mask; unsigned long func_type; @@ -22993,15 +22993,15 @@ arm_expand_prologue (void) /* Create the new frame pointer. */ if (TARGET_APCS_FRAME) { - insn = GEN_INT (-(4 + args_to_push + fp_offset)); - insn = emit_insn (gen_addsi3 (hard_frame_pointer_rtx, ip_rtx, insn)); + rtx x = GEN_INT (-(4 + args_to_push + fp_offset)); + insn = emit_insn (gen_addsi3 (hard_frame_pointer_rtx, ip_rtx, x)); RTX_FRAME_RELATED_P (insn) = 1; } else { - insn = GEN_INT (saved_regs - (4 + fp_offset)); + rtx x = GEN_INT (saved_regs - (4 + fp_offset)); insn = emit_insn (gen_addsi3 (hard_frame_pointer_rtx, - stack_pointer_rtx, insn)); + stack_pointer_rtx, x)); RTX_FRAME_RELATED_P (insn) = 1; } } @@ -23041,14 +23041,15 @@ arm_expand_prologue (void) /* Recover the static chain register. */ if (clobber_ip) { + rtx x; if (!arm_r3_live_at_start_p () || saved_pretend_args) - insn = gen_rtx_REG (SImode, 3); + x = gen_rtx_REG (SImode, 3); else { - insn = plus_constant (Pmode, hard_frame_pointer_rtx, 4); - insn = gen_frame_mem (SImode, insn); + x = plus_constant (Pmode, hard_frame_pointer_rtx, 4); + x = gen_frame_mem (SImode, x); } - emit_set_insn (ip_rtx, insn); + emit_set_insn (ip_rtx, x); emit_insn (gen_force_register_use (ip_rtx)); } diff --git a/gcc/config/cris/cris.cc b/gcc/config/cris/cris.cc index 45886ec6351..569d27accfb 100644 --- a/gcc/config/cris/cris.cc +++ b/gcc/config/cris/cris.cc @@ -2875,7 +2875,8 @@ cris_expand_prologue (void) int cfoa_size = crtl->outgoing_args_size; int last_movem_reg = -1; int framesize = 0; - rtx mem, insn; + rtx mem; + rtx_insn *insn; int return_address_on_stack = cris_return_address_on_stack (); int n_movem_regs = 0; int pretend = crtl->args.pretend_args_size; diff --git a/gcc/config/lm32/lm32.cc b/gcc/config/lm32/lm32.cc index 690880b893e..42d530451d4 100644 --- a/gcc/config/lm32/lm32.cc +++ b/gcc/config/lm32/lm32.cc @@ -308,7 +308,7 @@ expand_save_restore (struct lm32_frame_info *info, int op) unsigned int reg_save_mask = info->reg_save_mask; int regno; HOST_WIDE_INT offset; - rtx insn; + rtx_insn *insn; /* Callee saves are below locals and above outgoing arguments. */ offset = info->args_size + info->callee_size; @@ -359,7 +359,7 @@ expand_save_restore (struct lm32_frame_info *info, int op) static void stack_adjust (HOST_WIDE_INT amount) { - rtx insn; + rtx_insn *insn; if (!IN_RANGE (amount, -32776, 32768)) { @@ -387,7 +387,7 @@ stack_adjust (HOST_WIDE_INT amount) void lm32_expand_prologue (void) { - rtx insn; + rtx_insn *insn; lm32_compute_frame_size (get_frame_size ()); diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index bae6f602bf4..a753171fb8d 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -1082,7 +1082,7 @@ loongarch_save_reg (rtx reg, rtx mem) static void loongarch_restore_reg (rtx reg, rtx mem) { - rtx insn = loongarch_emit_move (reg, mem); + rtx_insn *insn = loongarch_emit_move (reg, mem); rtx dwarf = NULL_RTX; dwarf = alloc_reg_note (REG_CFA_RESTORE, reg, dwarf); REG_NOTES (insn) = dwarf; diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index d91dbcf5d91..59c2a99fe9d 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -9781,7 +9781,7 @@ riscv_save_reg (rtx reg, rtx mem) static void riscv_restore_reg (rtx reg, rtx mem) { - rtx insn = riscv_emit_move (reg, mem); + rtx_insn *insn = riscv_emit_move (reg, mem); rtx dwarf = NULL_RTX; dwarf = alloc_reg_note (REG_CFA_RESTORE, reg, dwarf); diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 71d72555401..bf4550a61fa 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -12318,7 +12318,8 @@ allocate_stack_space (rtx size, HOST_WIDE_INT last_probe_offset, void s390_emit_prologue (void) { - rtx insn, addr; + rtx_insn *insn; + rtx addr; rtx temp_reg; int i; int offset; diff --git a/gcc/config/sh/sh_treg_combine.cc b/gcc/config/sh/sh_treg_combine.cc index a8a8a355eba..26a3182a955 100644 --- a/gcc/config/sh/sh_treg_combine.cc +++ b/gcc/config/sh/sh_treg_combine.cc @@ -1236,7 +1236,7 @@ sh_treg_combine::try_combine_comparisons (cbranch_trace& trace, log_msg ("replacing comparison and cstore with inverting reg move " "in [bb %d]\n", i->bb->index); - rtx new_i = make_not_reg_insn (comp_op0, i_comp_op0); + rtx_insn *new_i = make_not_reg_insn (comp_op0, i_comp_op0); if (REG_P (i_comp_op0) && reg_dead_after_insn (i_comp_op0, i->setcc.insn)) add_reg_note (new_i, REG_DEAD, copy_rtx (i_comp_op0)); diff --git a/gcc/config/stormy16/stormy16.cc b/gcc/config/stormy16/stormy16.cc index 6b3bfe6836d..ae2c668db48 100644 --- a/gcc/config/stormy16/stormy16.cc +++ b/gcc/config/stormy16/stormy16.cc @@ -1189,7 +1189,7 @@ xstormy16_expand_prologue (void) { struct xstormy16_stack_layout layout; int regno; - rtx insn; + rtx_insn *insn; rtx mem_push_rtx; const int ifun = xstormy16_interrupt_function_p (); diff --git a/gcc/config/visium/visium.cc b/gcc/config/visium/visium.cc index 99b4f9dd4c4..2f1e3fd7c0c 100644 --- a/gcc/config/visium/visium.cc +++ b/gcc/config/visium/visium.cc @@ -3776,7 +3776,7 @@ visium_save_regs (int alloc, int offset, int low_regno, int high_regno) { enum reg_type reg_type = GET_REG_TYPE (regno); int mask_bit = 1 << (regno - first_regno[reg_type]); - rtx insn; + rtx_insn *insn; if (current_frame_info.mask[reg_type] & mask_bit) { @@ -3916,11 +3916,11 @@ visium_expand_prologue (void) if (alloc_size > 65535) { - rtx tmp = gen_rtx_REG (SImode, PROLOGUE_TMP_REGNUM), insn; + rtx tmp = gen_rtx_REG (SImode, PROLOGUE_TMP_REGNUM); emit_insn (gen_movsi (tmp, GEN_INT (alloc_size))); - insn = emit_frame_insn (gen_subsi3_flags (stack_pointer_rtx, - stack_pointer_rtx, - tmp)); + rtx_insn *insn = emit_frame_insn (gen_subsi3_flags (stack_pointer_rtx, + stack_pointer_rtx, + tmp)); add_reg_note (insn, REG_FRAME_RELATED_EXPR, gen_rtx_SET (stack_pointer_rtx, gen_rtx_PLUS (Pmode, stack_pointer_rtx, @@ -4108,7 +4108,7 @@ visium_restore_regs (int dealloc, int offset, int high_regno, int low_regno) } /* Deallocate the stack space. */ - rtx insn = emit_frame_insn (gen_stack_pop (GEN_INT (dealloc))); + rtx_insn *insn = emit_frame_insn (gen_stack_pop (GEN_INT (dealloc))); add_reg_note (insn, REG_FRAME_RELATED_EXPR, gen_rtx_SET (stack_pointer_rtx, gen_rtx_PLUS (Pmode, stack_pointer_rtx, @@ -4161,7 +4161,8 @@ visium_expand_epilogue (void) else src = gen_frame_mem (SImode, stack_pointer_rtx); - rtx insn = emit_frame_insn (gen_movsi (hard_frame_pointer_rtx, src)); + rtx_insn *insn = emit_frame_insn (gen_movsi (hard_frame_pointer_rtx, + src)); add_reg_note (insn, REG_CFA_ADJUST_CFA, gen_rtx_SET (stack_pointer_rtx, hard_frame_pointer_rtx)); @@ -4204,7 +4205,7 @@ visium_expand_epilogue (void) else if (fsize) { const int pop_size = reg_size ? local_frame_offset + var_size : fsize; - rtx insn; + rtx_insn *insn; if (pop_size > 65535) { -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:41 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:41 -0500 Subject: [PATCH 00/25] more rtx_insn *ification Message-ID: <20261102075007.317381-1-tbsaunde@tbsaunde.org> From: Trevor Saunders Hi, a bunch more of the same converting rtx to rtx_insn * or subclasses. patches individually bootstrapped and regtested on ppc64-linux-gnu, as well as bootstrapped on x86_64-linux-gnu, and aarch64-linux-gnu. Will commit in a day or so if no issues come up. Trev Trevor Saunders (25): Pass an rtx_insn * to _fatal_insn_not_found Use rtx_code_label * for locals set by gen_label_rtx Use label_ref_label instead of XEXP on a LABEL_REF Use rtx_jump_insn * for locals set by emit_jump_insn_before/after Use rtx_insn * for locals that already hold an insn Pass an rtx_insn * to find_reg_equal_equiv_note Use rtx_insn * for returns that are already an insn Pass a const rtx_insn * to the EH throw helpers Use rtx_insn * for locals set from insn returns Make argument types rtx_insn * when they always are one Pass an rtx_insn * to label_to_alignment Split pattern locals from the insns they emit Pass an rtx_insn * to add_function_usage_to Use rtx_insn * for locals that only hold an insn Hold emitted insns in rtx_insn * locals Use rtx_insn * and rtx_code_label * where the value already has that type Pass an rtx_insn * to redirect_with_delay_slots_safe_p Split locals that are overwritten with a different rtx Use rtx_insn * where it always is one Pass an rtx_insn * to update_reg_unused_notes Pass an rtx_insn * to redundant_insn Return end_sequence directly Use add_reg_note instead of a hand-built note Pass an rtx_insn * to add_reg_note Pass a const rtx_insn * to the reg-note finders gcc/builtins.cc | 4 +- gcc/builtins.h | 4 +- gcc/calls.cc | 2 +- gcc/compare-elim.cc | 6 +- gcc/config/aarch64/aarch64.cc | 38 ++-- gcc/config/aarch64/aarch64.md | 2 +- gcc/config/alpha/alpha-protos.h | 4 +- gcc/config/alpha/alpha.cc | 130 +++++++------ gcc/config/alpha/alpha.md | 8 +- gcc/config/arc/arc-protos.h | 2 +- gcc/config/arc/arc.cc | 174 +++++++++-------- gcc/config/arm/aarch-common-protos.h | 22 +-- gcc/config/arm/aarch-common.cc | 60 +++--- gcc/config/arm/arm-protos.h | 4 +- gcc/config/arm/arm.cc | 179 ++++++++---------- gcc/config/arm/arm.md | 14 +- gcc/config/arm/minipool.cc | 6 +- gcc/config/avr/avr.cc | 8 +- gcc/config/avr/avr.md | 2 +- gcc/config/bfin/bfin-protos.h | 4 +- gcc/config/bfin/bfin.cc | 23 +-- gcc/config/c6x/c6x.cc | 53 +++--- gcc/config/cris/cris-protos.h | 4 +- gcc/config/cris/cris.cc | 74 +++----- gcc/config/cris/cris.md | 3 +- gcc/config/csky/csky.cc | 23 +-- gcc/config/csky/csky.md | 2 +- gcc/config/epiphany/epiphany.md | 8 +- gcc/config/fr30/fr30-protos.h | 2 +- gcc/config/fr30/fr30.cc | 7 +- gcc/config/frv/frv-protos.h | 16 +- gcc/config/frv/frv.cc | 49 ++--- gcc/config/ft32/ft32.cc | 2 +- gcc/config/gcn/gcn-valu.md | 4 +- gcc/config/gcn/gcn.cc | 27 +-- gcc/config/gcn/gcn.md | 2 +- gcc/config/h8300/h8300.cc | 16 +- gcc/config/i386/i386-expand.cc | 8 +- gcc/config/i386/i386-features.cc | 2 +- gcc/config/i386/i386-features.h | 2 +- gcc/config/i386/i386.cc | 6 +- gcc/config/ia64/ia64.cc | 21 +- gcc/config/lm32/lm32.cc | 12 +- gcc/config/loongarch/loongarch-protos.h | 2 +- gcc/config/loongarch/loongarch.cc | 17 +- gcc/config/loongarch/loongarch.md | 12 +- gcc/config/m32r/m32r-protos.h | 4 +- gcc/config/m32r/m32r.cc | 16 +- gcc/config/m68k/m68k.md | 12 +- gcc/config/mcore/mcore.cc | 4 +- gcc/config/microblaze/microblaze.cc | 8 +- gcc/config/mips/mips-protos.h | 10 +- gcc/config/mips/mips.cc | 24 ++- gcc/config/mmix/mmix.cc | 8 +- gcc/config/mn10300/mn10300-protos.h | 2 +- gcc/config/mn10300/mn10300.cc | 4 +- gcc/config/moxie/moxie.cc | 2 +- gcc/config/msp430/msp430.cc | 17 +- gcc/config/nds32/nds32-md-auxiliary.cc | 13 +- gcc/config/nds32/nds32-memory-manipulation.cc | 21 +- gcc/config/nds32/nds32-pipelines-auxiliary.cc | 8 +- gcc/config/nds32/nds32-protos.h | 2 +- gcc/config/nds32/nds32-relax-opt.cc | 6 +- gcc/config/nds32/nds32.cc | 84 ++++---- gcc/config/nds32/nds32.md | 4 +- gcc/config/nvptx/nvptx.cc | 2 +- gcc/config/or1k/or1k.cc | 78 ++++---- gcc/config/or1k/or1k.md | 9 +- gcc/config/pa/pa.cc | 2 +- gcc/config/pa/pa.md | 6 +- gcc/config/pru/pru.cc | 10 +- gcc/config/pru/pru.md | 33 ++-- gcc/config/riscv/riscv-protos.h | 2 +- gcc/config/riscv/riscv-string.cc | 41 ++-- gcc/config/riscv/riscv-v.cc | 8 +- gcc/config/riscv/riscv.cc | 37 ++-- gcc/config/riscv/riscv.md | 14 +- gcc/config/riscv/thead.cc | 6 +- gcc/config/rl78/rl78.cc | 15 +- gcc/config/rs6000/rs6000-builtin.cc | 2 +- gcc/config/rs6000/rs6000-call.cc | 2 +- gcc/config/rs6000/rs6000-logue.cc | 35 ++-- gcc/config/rs6000/rs6000-p8swap.cc | 52 ++--- gcc/config/rs6000/rs6000-protos.h | 2 +- gcc/config/rs6000/rs6000-string.cc | 70 +++---- gcc/config/rs6000/rs6000.cc | 65 +++---- gcc/config/rs6000/rs6000.md | 16 +- gcc/config/rx/rx-protos.h | 2 +- gcc/config/rx/rx.cc | 16 +- gcc/config/s390/s390.cc | 89 ++++----- gcc/config/s390/s390.md | 6 +- gcc/config/sh/sh-protos.h | 12 +- gcc/config/sh/sh.cc | 92 ++++----- gcc/config/sh/sh.md | 55 +++--- gcc/config/sh/sh_treg_combine.cc | 42 ++-- gcc/config/sparc/sparc.cc | 10 +- gcc/config/stormy16/stormy16-protos.h | 2 +- gcc/config/stormy16/stormy16.cc | 24 +-- gcc/config/v850/v850.cc | 5 +- gcc/config/vax/builtins.md | 8 +- gcc/config/vax/vax-protos.h | 2 +- gcc/config/vax/vax.cc | 8 +- gcc/config/visium/visium.cc | 32 ++-- gcc/config/xtensa/xtensa.cc | 7 +- gcc/cse.cc | 5 +- gcc/df-problems.cc | 2 +- gcc/df.h | 2 +- gcc/dse.cc | 2 +- gcc/dwarf2out.cc | 6 +- gcc/emit-rtl.cc | 2 +- gcc/except.cc | 52 ++--- gcc/except.h | 2 +- gcc/explow.cc | 8 +- gcc/explow.h | 6 +- gcc/final.cc | 9 +- gcc/haifa-sched.cc | 2 +- gcc/ifcvt.cc | 2 +- gcc/lower-subreg.cc | 12 +- gcc/optabs.cc | 4 +- gcc/output.h | 2 +- gcc/postreload-gcse.cc | 2 +- gcc/reload.cc | 4 +- gcc/reload.h | 2 +- gcc/reload1.cc | 8 +- gcc/reorg.cc | 108 ++++++----- gcc/resource.cc | 9 +- gcc/rtl-error.cc | 2 +- gcc/rtl-tests.cc | 4 +- gcc/rtl.h | 29 +-- gcc/rtlanal.cc | 22 ++- gcc/sched-deps.cc | 2 +- gcc/sched-int.h | 2 +- gcc/sel-sched-ir.cc | 6 +- gcc/sel-sched-ir.h | 2 +- gcc/sel-sched.cc | 6 +- gcc/tree-outof-ssa.cc | 4 +- gcc/var-tracking.cc | 8 +- 137 files changed, 1311 insertions(+), 1265 deletions(-) -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:52 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:52 -0500 Subject: [PATCH 11/25] Pass an rtx_insn * to label_to_alignment In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-12-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * final.cc (label_to_alignment): Take an rtx_insn *. * output.h (label_to_alignment): Likewise. --- gcc/final.cc | 2 +- gcc/output.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/final.cc b/gcc/final.cc index af167319beb..2fc47a3edaf 100644 --- a/gcc/final.cc +++ b/gcc/final.cc @@ -491,7 +491,7 @@ static int min_labelno, max_labelno; /* For the benefit of port specific code do this also as a function. */ align_flags -label_to_alignment (rtx label) +label_to_alignment (rtx_insn *label) { if (CODE_LABEL_NUMBER (label) <= max_labelno) return LABEL_TO_ALIGNMENT (label); diff --git a/gcc/output.h b/gcc/output.h index 1f628ea2371..c78fb8a0b8c 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -96,7 +96,7 @@ extern int insn_current_reference_address (rtx_insn *); /* Find the alignment associated with a CODE_LABEL. Defined in final.cc. */ -extern align_flags label_to_alignment (rtx); +extern align_flags label_to_alignment (rtx_insn *); /* Output a LABEL_REF, or a bare CODE_LABEL, as an assembler symbol. */ extern void output_asm_label (rtx); -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:51 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:51 -0500 Subject: [PATCH 10/25] Make argument types rtx_insn * when they always are one In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-11-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * builtins.cc (expand_builtin_setjmp_setup, expand_builtin_setjmp_receiver): Take an rtx_insn *. * builtins.h (expand_builtin_setjmp_setup, expand_builtin_setjmp_receiver): Likewise. * config/aarch64/aarch64.cc (aarch_pac_insn_p): Likewise. * config/alpha/alpha-protos.h (alpha_find_lo_sum_using_gp): Likewise. * config/alpha/alpha.cc (alpha_find_lo_sum_using_gp): Likewise. * config/arc/arc-protos.h (arc_write_ext_corereg): Likewise. * config/arc/arc.cc (arc_write_ext_corereg, branch_dest): Likewise. * config/arm/aarch-common-protos.h (arm_early_load_addr_dep, arm_early_load_addr_dep_ptr, arm_early_store_addr_dep, arm_early_store_addr_dep_ptr, arm_mac_accumulator_is_mul_result, arm_no_early_alu_shift_dep, arm_no_early_alu_shift_value_dep, arm_no_early_mul_dep, arm_no_early_store_addr_dep, aarch_pac_insn_p): Likewise. * config/arm/aarch-common.cc (arm_get_set_operands, arm_early_load_addr_dep, arm_early_load_addr_dep_ptr, arm_no_early_alu_shift_dep, arm_no_early_alu_shift_value_dep, arm_no_early_mul_dep, arm_no_early_store_addr_dep, arm_early_store_addr_dep, arm_early_store_addr_dep_ptr, arm_mac_accumulator_is_mul_result): Likewise. * config/arm/arm-protos.h (arm_split_constant, use_return_insn): Likewise. * config/arm/arm.cc (use_return_insn, arm_split_constant, is_indirect_tailcall_p, aarch_pac_insn_p): Likewise. (arm32_output_mi_thunk): Pass nullptr. * config/arm/arm.md (addsi3, subsi3, andsi3, iorsi3, xorsi3, movsi, define_split): Likewise. * config/arm/minipool.cc (minipool::get_label_padding): Take an rtx_insn *. * config/bfin/bfin-protos.h (output_push_multiple, output_pop_multiple): Likewise. * config/bfin/bfin.cc (output_push_multiple, output_pop_multiple, cbranch_predicted_taken_p): Likewise. * config/csky/csky.cc (get_csky_jump_table_size): Likewise. * config/frv/frv-protos.h (output_move_single, output_move_double, output_condmove_single, frv_acc_group): Likewise. * config/frv/frv.cc (output_move_single, output_move_double, output_condmove_single, frv_acc_group, frv_ifcvt_load_value, frv_ifcvt_rewrite_mem): Likewise. * config/i386/i386.cc (ix86_add_queued_cfa_restore_notes): Likewise. * config/m32r/m32r-protos.h (m32r_output_block_move): Likewise. * config/m32r/m32r.cc (m32r_is_insn, m32r_output_block_move): Likewise. * config/mcore/mcore.cc (is_cond_candidate): Likewise. * config/microblaze/microblaze.cc (get_branch_target): Likewise. * config/mips/mips-protos.h (mips_split_move, mips_split_move_insn_p, mips_split_move_insn, mips_split_call, mips_dspalu_bypass_p): Likewise. * config/mips/mips.cc (mips_split_move, mips_insn_split_type, mips_split_move_insn_p, mips_split_move_insn, mips_split_call, mips_dspalu_bypass_p): Likewise. * config/mn10300/mn10300-protos.h (mn10300_match_ccmode): Likewise. * config/mn10300/mn10300.cc (mn10300_match_ccmode): Likewise. * config/nds32/nds32-md-auxiliary.cc (nds32_output_call): Likewise. * config/nds32/nds32-pipelines-auxiliary.cc (bpick_ra_rb_dep_p, pbsada_insn_ra_rb_dep_reg_p, pbsada_insn_rt_dep_reg_p, wext_odd_dep_p): Likewise. * config/nds32/nds32-protos.h (nds32_output_call): Likewise. * config/nds32/nds32-relax-opt.cc (nds32_group_tls_insn): Likewise. * config/rs6000/rs6000-protos.h (rs6000_loop_align): Likewise. * config/rs6000/rs6000-string.cc (expand_strncmp_align_check): Likewise. * config/rs6000/rs6000.cc (rs6000_loop_align): Likewise. * config/rx/rx-protos.h (rx_match_ccmode): Likewise. * config/rx/rx.cc (rx_match_ccmode): Likewise. * config/s390/s390.cc (s390_add_pool_insn): Likewise. * config/sh/sh-protos.h (output_movedouble, shl_and_length, shl_and_scr_length, shl_sext_length, sh_contains_memref_p, sh_loads_bankedreg_p): Likewise. * config/sh/sh.cc (output_movedouble, shl_and_length, shl_and_scr_length, shl_sext_length, sh_contains_memref_p, sh_loads_bankedreg_p, branch_dest, extract_sfunc_addr, find_insn_regmode_weight): Likewise. * config/sh/sh_treg_combine.cc (reg_dead_after_insn, reg_unused_after_insn, trace_reg_uses_1, trace_reg_uses): Likewise. * config/sparc/sparc.cc (eligible_for_restore_insn, emit_and_preserve): Likewise. * config/stormy16/stormy16-protos.h (xstormy16_output_addr_vec): Likewise. * config/stormy16/stormy16.cc (xstormy16_output_addr_vec): Likewise. * config/vax/vax-protos.h (vax_output_int_move): Likewise. * config/vax/vax.cc (vax_output_int_move, vax_add_reg_cfa_offset, split_quadword_operands): Likewise. * config/visium/visium.cc (empty_asm_p, visium_add_queued_cfa_restore_notes): Likewise. * df-problems.cc (simulate_backwards_to_point): Likewise. * df.h (simulate_backwards_to_point): Likewise. * dse.cc (get_call_args): Likewise. * dwarf2out.cc (reg_loc_descriptor, based_loc_descr, compute_frame_pointer_to_fb_displacement): Pass nullptr. * except.cc (copy_reg_eh_region_note_forward, copy_reg_eh_region_note_backward): Take an rtx_insn *. * ifcvt.cc (cond_exec_process_insns): Likewise. * lower-subreg.cc (resolve_subreg_use): Likewise. (resolve_reg_notes, resolve_simple_move): Pass nullptr. * postreload-gcse.cc (gcse_after_reload_main): Take an rtx_insn *. * reload.cc (get_secondary_mem, make_memloc): Pass nullptr. * reload.h (eliminate_regs): Take an rtx_insn *. * reload1.cc (eliminate_regs): Likewise. (reload, reload_as_needed, delete_output_reload): Pass nullptr. * reorg.cc (fix_reg_dead_note, label_before_next_insn): Take an rtx_insn *. * rtl.h (copy_reg_eh_region_note_forward, copy_reg_eh_region_note_backward): Likewise. * sched-int.h (insn_luid): Likewise. * sel-sched-ir.cc (create_insn_rtx_from_pattern): Likewise. (speculate_expr, create_copy_of_insn_rtx): Pass nullptr. * sel-sched-ir.h (create_insn_rtx_from_pattern): Take an rtx_insn *. * sel-sched.cc (create_insn_rtx_with_rhs, create_insn_rtx_with_lhs, create_speculation_check): Pass nullptr. * var-tracking.cc (vt_initialize): Likewise. --- gcc/builtins.cc | 4 ++-- gcc/builtins.h | 4 ++-- gcc/config/aarch64/aarch64.cc | 2 +- gcc/config/alpha/alpha-protos.h | 2 +- gcc/config/alpha/alpha.cc | 2 +- gcc/config/arc/arc-protos.h | 2 +- gcc/config/arc/arc.cc | 6 ++--- gcc/config/arm/aarch-common-protos.h | 20 ++++++++--------- gcc/config/arm/aarch-common.cc | 20 ++++++++--------- gcc/config/arm/arm-protos.h | 4 ++-- gcc/config/arm/arm.cc | 12 +++++----- gcc/config/arm/arm.md | 14 ++++++------ gcc/config/arm/minipool.cc | 4 ++-- gcc/config/bfin/bfin-protos.h | 4 ++-- gcc/config/bfin/bfin.cc | 6 ++--- gcc/config/csky/csky.cc | 2 +- gcc/config/frv/frv-protos.h | 8 +++---- gcc/config/frv/frv.cc | 16 +++++++------- gcc/config/i386/i386.cc | 2 +- gcc/config/m32r/m32r-protos.h | 2 +- gcc/config/m32r/m32r.cc | 6 ++--- gcc/config/mcore/mcore.cc | 4 ++-- gcc/config/microblaze/microblaze.cc | 2 +- gcc/config/mips/mips-protos.h | 10 ++++----- gcc/config/mips/mips.cc | 13 ++++++----- gcc/config/mn10300/mn10300-protos.h | 2 +- gcc/config/mn10300/mn10300.cc | 2 +- gcc/config/nds32/nds32-md-auxiliary.cc | 4 ++-- gcc/config/nds32/nds32-pipelines-auxiliary.cc | 8 +++---- gcc/config/nds32/nds32-protos.h | 2 +- gcc/config/nds32/nds32-relax-opt.cc | 2 +- gcc/config/rs6000/rs6000-protos.h | 2 +- gcc/config/rs6000/rs6000-string.cc | 3 ++- gcc/config/rs6000/rs6000.cc | 2 +- gcc/config/rx/rx-protos.h | 2 +- gcc/config/rx/rx.cc | 2 +- gcc/config/s390/s390.cc | 2 +- gcc/config/sh/sh-protos.h | 12 +++++----- gcc/config/sh/sh.cc | 22 +++++++++---------- gcc/config/sh/sh_treg_combine.cc | 8 +++---- gcc/config/sparc/sparc.cc | 4 ++-- gcc/config/stormy16/stormy16-protos.h | 2 +- gcc/config/stormy16/stormy16.cc | 3 ++- gcc/config/vax/vax-protos.h | 2 +- gcc/config/vax/vax.cc | 6 ++--- gcc/config/visium/visium.cc | 4 ++-- gcc/df-problems.cc | 2 +- gcc/df.h | 2 +- gcc/dse.cc | 2 +- gcc/dwarf2out.cc | 6 ++--- gcc/except.cc | 6 +++-- gcc/ifcvt.cc | 2 +- gcc/lower-subreg.cc | 12 +++++----- gcc/postreload-gcse.cc | 2 +- gcc/reload.cc | 4 ++-- gcc/reload.h | 2 +- gcc/reload1.cc | 8 +++---- gcc/reorg.cc | 6 ++--- gcc/rtl.h | 4 ++-- gcc/sched-int.h | 2 +- gcc/sel-sched-ir.cc | 6 ++--- gcc/sel-sched-ir.h | 2 +- gcc/sel-sched.cc | 6 ++--- gcc/var-tracking.cc | 6 ++--- 64 files changed, 176 insertions(+), 171 deletions(-) diff --git a/gcc/builtins.cc b/gcc/builtins.cc index 3127e0e82a1..5afcb8ad0af 100644 --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -884,7 +884,7 @@ static alias_set_type setjmp_alias_set = -1; exception handling code. */ void -expand_builtin_setjmp_setup (rtx buf_addr, rtx receiver_label) +expand_builtin_setjmp_setup (rtx buf_addr, rtx_insn *receiver_label) { machine_mode sa_mode = STACK_SAVEAREA_MODE (SAVE_NONLOCAL); rtx stack_save; @@ -931,7 +931,7 @@ expand_builtin_setjmp_setup (rtx buf_addr, rtx receiver_label) If RECEIVER_LABEL is NULL, instead construct a nonlocal goto handler. */ void -expand_builtin_setjmp_receiver (rtx receiver_label) +expand_builtin_setjmp_receiver (rtx_insn *receiver_label) { rtx chain; diff --git a/gcc/builtins.h b/gcc/builtins.h index 97b79908d0d..76d2bc73956 100644 --- a/gcc/builtins.h +++ b/gcc/builtins.h @@ -113,8 +113,8 @@ struct c_strlen_data extern tree c_strlen (tree, int, c_strlen_data * = NULL, unsigned = 1); extern rtx c_readstr (const char *, fixed_size_mode, bool = true); -extern void expand_builtin_setjmp_setup (rtx, rtx); -extern void expand_builtin_setjmp_receiver (rtx); +extern void expand_builtin_setjmp_setup (rtx, rtx_insn *); +extern void expand_builtin_setjmp_receiver (rtx_insn *); extern void expand_builtin_update_setjmp_buf (rtx); extern tree mathfn_built_in (tree, enum built_in_function fn); extern tree mathfn_built_in (tree, combined_fn); diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 62532719724..66af00d9141 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -9643,7 +9643,7 @@ aarch64_gcs_enabled (void) /* Check if X (or any sub-rtx of X) is a PACIASP/PACIBSP instruction. */ bool -aarch_pac_insn_p (rtx x) +aarch_pac_insn_p (rtx_insn *x) { if (!INSN_P (x)) return false; diff --git a/gcc/config/alpha/alpha-protos.h b/gcc/config/alpha/alpha-protos.h index bb81d856d0d..a496f9cff53 100644 --- a/gcc/config/alpha/alpha-protos.h +++ b/gcc/config/alpha/alpha-protos.h @@ -87,7 +87,7 @@ extern rtx alpha_va_arg (tree, tree); extern void alpha_start_function (FILE *, const char *, tree); extern void alpha_end_function (FILE *, const char *, tree); -extern bool alpha_find_lo_sum_using_gp (rtx); +extern bool alpha_find_lo_sum_using_gp (rtx_insn *); extern int alpha_store_data_bypass_p (rtx_insn *, rtx_insn *); diff --git a/gcc/config/alpha/alpha.cc b/gcc/config/alpha/alpha.cc index ab29b254d30..bcf756cfd03 100644 --- a/gcc/config/alpha/alpha.cc +++ b/gcc/config/alpha/alpha.cc @@ -8312,7 +8312,7 @@ vms_output_aligned_decl_common(FILE *file, tree decl, const char *name, #endif bool -alpha_find_lo_sum_using_gp (rtx insn) +alpha_find_lo_sum_using_gp (rtx_insn *insn) { subrtx_iterator::array_type array; FOR_EACH_SUBRTX (iter, array, PATTERN (insn), NONCONST) diff --git a/gcc/config/arc/arc-protos.h b/gcc/config/arc/arc-protos.h index 380f2c39777..81a763b91fb 100644 --- a/gcc/config/arc/arc-protos.h +++ b/gcc/config/arc/arc-protos.h @@ -75,7 +75,7 @@ extern rtx disi_highpart (rtx); extern int arc_adjust_insn_length (rtx_insn *, int, bool); extern int arc_corereg_hazard (rtx, rtx); extern int arc_hazard (rtx_insn *, rtx_insn *); -extern int arc_write_ext_corereg (rtx); +extern int arc_write_ext_corereg (rtx_insn *); extern rtx gen_acc1 (void); extern rtx gen_acc2 (void); extern bool arc_branch_size_unknown_p (void); diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc index d799f9f265b..557d30e2752 100644 --- a/gcc/config/arc/arc.cc +++ b/gcc/config/arc/arc.cc @@ -198,7 +198,7 @@ static void arc_encode_section_info (tree decl, rtx rtl, int first); static void arc_init_builtins (void); static rtx arc_expand_builtin (tree, rtx, rtx, machine_mode, int); -static int branch_dest (rtx); +static int branch_dest (rtx_insn *); static void arc_output_pic_addr_const (FILE *, rtx, int); static bool arc_function_ok_for_sibcall (tree, tree); @@ -5627,7 +5627,7 @@ arc_frame_pointer_required (void) /* Return the destination address of a branch. */ static int -branch_dest (rtx branch) +branch_dest (rtx_insn *branch) { rtx pat = PATTERN (branch); rtx dest = (GET_CODE (pat) == PARALLEL @@ -9581,7 +9581,7 @@ arc_predicate_delay_insns (void) /* Return nonzreo iff INSN writes to an extension core register. */ int -arc_write_ext_corereg (rtx insn) +arc_write_ext_corereg (rtx_insn *insn) { subrtx_iterator::array_type array; FOR_EACH_SUBRTX (iter, array, PATTERN (insn), NONCONST) diff --git a/gcc/config/arm/aarch-common-protos.h b/gcc/config/arm/aarch-common-protos.h index 10de8fafcbd..93e25d026cd 100644 --- a/gcc/config/arm/aarch-common-protos.h +++ b/gcc/config/arm/aarch-common-protos.h @@ -31,21 +31,21 @@ extern bool aarch_rev16_shleft_mask_imm_p (rtx, machine_mode); extern bool aarch_rev16_shright_mask_imm_p (rtx, machine_mode); extern bool aarch_mm_needs_acquire (rtx); extern bool aarch_mm_needs_release (rtx); -extern int arm_early_load_addr_dep (rtx, rtx); -extern int arm_early_load_addr_dep_ptr (rtx, rtx); -extern int arm_early_store_addr_dep (rtx, rtx); -extern int arm_early_store_addr_dep_ptr (rtx, rtx); -extern int arm_mac_accumulator_is_mul_result (rtx, rtx); +extern int arm_early_load_addr_dep (rtx_insn *, rtx_insn *); +extern int arm_early_load_addr_dep_ptr (rtx_insn *, rtx_insn *); +extern int arm_early_store_addr_dep (rtx_insn *, rtx_insn *); +extern int arm_early_store_addr_dep_ptr (rtx_insn *, rtx_insn *); +extern int arm_mac_accumulator_is_mul_result (rtx_insn *, rtx_insn *); extern int arm_mac_accumulator_is_result (rtx, rtx); -extern int arm_no_early_alu_shift_dep (rtx, rtx); -extern int arm_no_early_alu_shift_value_dep (rtx, rtx); -extern int arm_no_early_mul_dep (rtx, rtx); -extern int arm_no_early_store_addr_dep (rtx, rtx); +extern int arm_no_early_alu_shift_dep (rtx_insn *, rtx_insn *); +extern int arm_no_early_alu_shift_value_dep (rtx_insn *, rtx_insn *); +extern int arm_no_early_mul_dep (rtx_insn *, rtx_insn *); +extern int arm_no_early_store_addr_dep (rtx_insn *, rtx_insn *); extern bool arm_rtx_shift_left_p (rtx); extern void aarch_bti_arch_check (void); extern bool aarch_bti_enabled (void); extern bool aarch_bti_j_insn_p (rtx_insn *); -extern bool aarch_pac_insn_p (rtx); +extern bool aarch_pac_insn_p (rtx_insn *); extern rtx aarch_gen_bti_c (void); extern rtx aarch_gen_bti_j (void); extern bool aarch_fun_is_indirect_return (rtx_insn *); diff --git a/gcc/config/arm/aarch-common.cc b/gcc/config/arm/aarch-common.cc index 197952ee7df..e80bc196103 100644 --- a/gcc/config/arm/aarch-common.cc +++ b/gcc/config/arm/aarch-common.cc @@ -105,7 +105,7 @@ arm_find_shift_sub_rtx (rtx pattern) Return nonzero if we found the SET RTX we expected. */ static int -arm_get_set_operands (rtx producer, rtx consumer, +arm_get_set_operands (rtx_insn *producer, rtx_insn *consumer, rtx *set_source, rtx *set_destination) { rtx set_producer = arm_find_sub_rtx_with_code (PATTERN (producer), @@ -224,7 +224,7 @@ aarch_mm_needs_release (rtx const_int) /* Return nonzero if the CONSUMER instruction (a load) does need PRODUCER's value to calculate the address. */ int -arm_early_load_addr_dep (rtx producer, rtx consumer) +arm_early_load_addr_dep (rtx_insn *producer, rtx_insn *consumer) { rtx value, addr; @@ -238,7 +238,7 @@ arm_early_load_addr_dep (rtx producer, rtx consumer) a Pmode PRODUCER's value to calculate the address. */ int -arm_early_load_addr_dep_ptr (rtx producer, rtx consumer) +arm_early_load_addr_dep_ptr (rtx_insn *producer, rtx_insn *consumer) { rtx value = arm_find_sub_rtx_with_code (PATTERN (producer), SET, false); rtx addr = arm_find_sub_rtx_with_code (PATTERN (consumer), SET, false); @@ -256,7 +256,7 @@ arm_early_load_addr_dep_ptr (rtx producer, rtx consumer) have an early register shift value or amount dependency on the result of PRODUCER. */ int -arm_no_early_alu_shift_dep (rtx producer, rtx consumer) +arm_no_early_alu_shift_dep (rtx_insn *producer, rtx_insn *consumer) { rtx value, op; rtx early_op; @@ -274,7 +274,7 @@ arm_no_early_alu_shift_dep (rtx producer, rtx consumer) have an early register shift value dependency on the result of PRODUCER. */ int -arm_no_early_alu_shift_value_dep (rtx producer, rtx consumer) +arm_no_early_alu_shift_value_dep (rtx_insn *producer, rtx_insn *consumer) { rtx value, op; rtx early_op; @@ -294,7 +294,7 @@ arm_no_early_alu_shift_value_dep (rtx producer, rtx consumer) have an early register mult dependency on the result of PRODUCER. */ int -arm_no_early_mul_dep (rtx producer, rtx consumer) +arm_no_early_mul_dep (rtx_insn *producer, rtx_insn *consumer) { rtx value, op; @@ -316,7 +316,7 @@ arm_no_early_mul_dep (rtx producer, rtx consumer) PRODUCER's value to calculate the address. */ int -arm_no_early_store_addr_dep (rtx producer, rtx consumer) +arm_no_early_store_addr_dep (rtx_insn *producer, rtx_insn *consumer) { rtx value = arm_find_sub_rtx_with_code (PATTERN (producer), SET, false); rtx addr = arm_find_sub_rtx_with_code (PATTERN (consumer), SET, false); @@ -337,7 +337,7 @@ arm_no_early_store_addr_dep (rtx producer, rtx consumer) PRODUCER's value to calculate the address. */ int -arm_early_store_addr_dep (rtx producer, rtx consumer) +arm_early_store_addr_dep (rtx_insn *producer, rtx_insn *consumer) { return !arm_no_early_store_addr_dep (producer, consumer); } @@ -346,7 +346,7 @@ arm_early_store_addr_dep (rtx producer, rtx consumer) a Pmode PRODUCER's value to calculate the address. */ int -arm_early_store_addr_dep_ptr (rtx producer, rtx consumer) +arm_early_store_addr_dep_ptr (rtx_insn *producer, rtx_insn *consumer) { rtx value = arm_find_sub_rtx_with_code (PATTERN (producer), SET, false); rtx addr = arm_find_sub_rtx_with_code (PATTERN (consumer), SET, false); @@ -500,7 +500,7 @@ aarch_accumulator_forwarding (rtx_insn *producer, rtx_insn *consumer) has an accumulator dependency on the result of the producer (a multiplication instruction) and no other dependency on that result. */ int -arm_mac_accumulator_is_mul_result (rtx producer, rtx consumer) +arm_mac_accumulator_is_mul_result (rtx_insn *producer, rtx_insn *consumer) { rtx mul = PATTERN (producer); rtx mac = PATTERN (consumer); diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index b607cdb3fcc..2fd54f683fc 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -28,7 +28,7 @@ rtl_opt_pass *make_pass_insert_bti (gcc::context *ctxt); extern enum unwind_info_type arm_except_unwind_info (struct gcc_options *); -extern int use_return_insn (int, rtx); +extern int use_return_insn (int, rtx_insn *); extern bool use_simple_return_p (void); extern enum reg_class arm_regno_class (int); extern bool arm_check_builtin_call (location_t, vec, tree, tree, @@ -79,7 +79,7 @@ extern int const_ok_for_op (HOST_WIDE_INT, enum rtx_code); extern int const_ok_for_dimode_op (HOST_WIDE_INT, enum rtx_code); extern void thumb1_gen_const_int_rtl (rtx, HOST_WIDE_INT); extern void thumb1_gen_const_int_print (rtx, HOST_WIDE_INT); -extern int arm_split_constant (RTX_CODE, machine_mode, rtx, +extern int arm_split_constant (RTX_CODE, machine_mode, rtx_insn *, HOST_WIDE_INT, rtx, rtx, int); extern int legitimate_pic_operand_p (rtx); extern rtx legitimize_pic_address (rtx, machine_mode, rtx, rtx, bool); diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 7c2e0675da0..8a267bb7e4f 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -4388,7 +4388,7 @@ static inline bool reg_needs_saving_p (unsigned reg) call. SIBLING is the call insn, so we can examine its register usage. */ int -use_return_insn (int iscond, rtx sibling) +use_return_insn (int iscond, rtx_insn *sibling) { int regno; unsigned int func_type; @@ -4710,7 +4710,7 @@ const_ok_for_dimode_op (HOST_WIDE_INT i, enum rtx_code code) /* ??? Tweak this for thumb2. */ int -arm_split_constant (enum rtx_code code, machine_mode mode, rtx insn, +arm_split_constant (enum rtx_code code, machine_mode mode, rtx_insn *insn, HOST_WIDE_INT val, rtx target, rtx source, int subtargets) { rtx cond; @@ -21992,7 +21992,7 @@ thumb_force_lr_save (void) we do have an indirect tailcall happening in this particular case. */ static bool -is_indirect_tailcall_p (rtx call) +is_indirect_tailcall_p (rtx_insn *call) { rtx pat = PATTERN (call); @@ -28289,7 +28289,7 @@ arm32_output_mi_thunk (FILE *file, tree, HOST_WIDE_INT delta, /* Add DELTA to THIS_RTX. */ if (delta != 0) - arm_split_constant (PLUS, Pmode, NULL_RTX, + arm_split_constant (PLUS, Pmode, nullptr, delta, this_rtx, this_rtx, false); /* Add *(*THIS_RTX + VCALL_OFFSET) to THIS_RTX. */ @@ -28298,7 +28298,7 @@ arm32_output_mi_thunk (FILE *file, tree, HOST_WIDE_INT delta, /* Load *THIS_RTX. */ emit_move_insn (temp, gen_rtx_MEM (Pmode, this_rtx)); /* Compute *THIS_RTX + VCALL_OFFSET. */ - arm_split_constant (PLUS, Pmode, NULL_RTX, vcall_offset, temp, temp, + arm_split_constant (PLUS, Pmode, nullptr, vcall_offset, temp, temp, false); /* Compute *(*THIS_RTX + VCALL_OFFSET). */ emit_move_insn (temp, gen_rtx_MEM (Pmode, temp)); @@ -32266,7 +32266,7 @@ aarch_bti_j_insn_p (rtx_insn *insn) /* Check if X (or any sub-rtx of X) is a PACIASP/PACIBSP instruction. */ bool -aarch_pac_insn_p (rtx x) +aarch_pac_insn_p (rtx_insn *x) { if (!x || !INSN_P (x)) return false; diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 785d341aa2a..e593cac0b33 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -901,7 +901,7 @@ " if (TARGET_32BIT && CONST_INT_P (operands[2])) { - arm_split_constant (PLUS, SImode, NULL_RTX, + arm_split_constant (PLUS, SImode, nullptr, INTVAL (operands[2]), operands[0], operands[1], optimize && can_create_pseudo_p ()); DONE; @@ -1995,7 +1995,7 @@ operands[1] = force_reg (SImode, operands[1]); else { - arm_split_constant (MINUS, SImode, NULL_RTX, + arm_split_constant (MINUS, SImode, nullptr, INTVAL (operands[1]), operands[0], operands[2], optimize && can_create_pseudo_p ()); @@ -2946,7 +2946,7 @@ operands[2] = force_reg (SImode, operands[2]); else { - arm_split_constant (AND, SImode, NULL_RTX, + arm_split_constant (AND, SImode, nullptr, INTVAL (operands[2]), operands[0], operands[1], optimize && can_create_pseudo_p ()); @@ -3702,7 +3702,7 @@ operands[2] = force_reg (SImode, operands[2]); else { - arm_split_constant (IOR, SImode, NULL_RTX, + arm_split_constant (IOR, SImode, nullptr, INTVAL (operands[2]), operands[0], operands[1], optimize && can_create_pseudo_p ()); @@ -3809,7 +3809,7 @@ operands[2] = force_reg (SImode, operands[2]); else { - arm_split_constant (XOR, SImode, NULL_RTX, + arm_split_constant (XOR, SImode, nullptr, INTVAL (operands[2]), operands[0], operands[1], optimize && can_create_pseudo_p ()); @@ -6477,7 +6477,7 @@ } else { - arm_split_constant (SET, SImode, NULL_RTX, + arm_split_constant (SET, SImode, nullptr, INTVAL (operands[1]), operands[0], NULL_RTX, optimize && can_create_pseudo_p ()); DONE; @@ -6565,7 +6565,7 @@ || const_ok_for_arm (~INTVAL (operands[1]))))" [(clobber (const_int 0))] " - arm_split_constant (SET, SImode, NULL_RTX, + arm_split_constant (SET, SImode, nullptr, INTVAL (operands[1]), operands[0], NULL_RTX, 0); DONE; " diff --git a/gcc/config/arm/minipool.cc b/gcc/config/arm/minipool.cc index ec20ca94d34..4dccd523d44 100644 --- a/gcc/config/arm/minipool.cc +++ b/gcc/config/arm/minipool.cc @@ -280,7 +280,7 @@ class minipool void assign_offsets (Mfix *); void dump (rtx_insn *); Mfix *create_fix_barrier (Mfix *, minipool_address); - HOST_WIDE_INT get_label_padding (rtx label) const; + HOST_WIDE_INT get_label_padding (rtx_insn *label) const; HOST_WIDE_INT get_alignment_size (void) const; minipool_address forwards (void) const { return m_max_address; } @@ -825,7 +825,7 @@ subpool::debug (void) const /* Return the maximum amount of padding that will be inserted before label LABEL. */ HOST_WIDE_INT -minipool::get_label_padding (rtx label) const +minipool::get_label_padding (rtx_insn *label) const { HOST_WIDE_INT align; diff --git a/gcc/config/bfin/bfin-protos.h b/gcc/config/bfin/bfin-protos.h index 772498306a5..d43d60b3b60 100644 --- a/gcc/config/bfin/bfin-protos.h +++ b/gcc/config/bfin/bfin-protos.h @@ -106,8 +106,8 @@ extern void bfin_expand_prologue (void); extern void bfin_expand_epilogue (int, int, bool); extern int analyze_push_multiple_operation (rtx); extern int analyze_pop_multiple_operation (rtx); -extern void output_push_multiple (rtx, rtx *); -extern void output_pop_multiple (rtx, rtx *); +extern void output_push_multiple (rtx_insn *, rtx *); +extern void output_pop_multiple (rtx_insn *, rtx *); extern int bfin_hard_regno_rename_ok (unsigned int, unsigned int); extern rtx bfin_return_addr_rtx (int); extern void bfin_hardware_loop (void); diff --git a/gcc/config/bfin/bfin.cc b/gcc/config/bfin/bfin.cc index 81fa48eacde..f81114b0bf5 100644 --- a/gcc/config/bfin/bfin.cc +++ b/gcc/config/bfin/bfin.cc @@ -2450,7 +2450,7 @@ branch_dest (rtx_insn *branch) it's a branch that's predicted taken. */ static int -cbranch_predicted_taken_p (rtx insn) +cbranch_predicted_taken_p (rtx_insn *insn) { rtx x = find_reg_note (insn, REG_BR_PROB, 0); @@ -3147,7 +3147,7 @@ analyze_pop_multiple_operation (rtx op) operands in OPERANDS. */ void -output_push_multiple (rtx insn, rtx *operands) +output_push_multiple (rtx_insn *insn, rtx *operands) { char buf[80]; int ok; @@ -3171,7 +3171,7 @@ output_push_multiple (rtx insn, rtx *operands) operands in OPERANDS. */ void -output_pop_multiple (rtx insn, rtx *operands) +output_pop_multiple (rtx_insn *insn, rtx *operands) { char buf[80]; int ok; diff --git a/gcc/config/csky/csky.cc b/gcc/config/csky/csky.cc index a1744c8547d..cc4817e7248 100644 --- a/gcc/config/csky/csky.cc +++ b/gcc/config/csky/csky.cc @@ -959,7 +959,7 @@ push_csky_minipool_barrier (rtx_insn *insn, HOST_WIDE_INT address) /* Compute the size of a vector jump table. */ static HOST_WIDE_INT -get_csky_jump_table_size (rtx insn) +get_csky_jump_table_size (rtx_insn *insn) { /* ADDR_VECs only take room if read-only data does into the text section. */ diff --git a/gcc/config/frv/frv-protos.h b/gcc/config/frv/frv-protos.h index 49220cb74d9..e455a2bb1cb 100644 --- a/gcc/config/frv/frv-protos.h +++ b/gcc/config/frv/frv-protos.h @@ -48,10 +48,10 @@ extern const char *frv_asm_output_opcode extern void frv_final_prescan_insn (rtx_insn *, rtx *, int); extern void frv_emit_move (machine_mode, rtx, rtx); extern int frv_emit_movsi (rtx, rtx); -extern const char *output_move_single (rtx *, rtx); -extern const char *output_move_double (rtx *, rtx); +extern const char *output_move_single (rtx *, rtx_insn *); +extern const char *output_move_double (rtx *, rtx_insn *); extern const char *output_condmove_single - (rtx *, rtx); + (rtx *, rtx_insn *); extern int frv_emit_cond_branch (rtx *); extern int frv_emit_scc (rtx *); extern rtx_insn *frv_split_scc (rtx, rtx, rtx, rtx, HOST_WIDE_INT); @@ -82,7 +82,7 @@ extern machine_mode frv_select_cc_mode (enum rtx_code, rtx, rtx); extern int frv_trampoline_size (void); extern int direct_return_p (void); extern int frv_issue_rate (void); -extern int frv_acc_group (rtx); +extern int frv_acc_group (rtx_insn *); #ifdef TREE_CODE extern int frv_adjust_field_align (tree, int); diff --git a/gcc/config/frv/frv.cc b/gcc/config/frv/frv.cc index 43e9620c9c5..e1307fcf01f 100644 --- a/gcc/config/frv/frv.cc +++ b/gcc/config/frv/frv.cc @@ -321,8 +321,8 @@ static rtx frv_expand_noargs_builtin (enum insn_code); static void frv_split_iacc_move (rtx, rtx); static rtx frv_emit_comparison (enum rtx_code, rtx, rtx); static void frv_ifcvt_add_insn (rtx, rtx_insn *, int); -static rtx frv_ifcvt_rewrite_mem (rtx, machine_mode, rtx); -static rtx frv_ifcvt_load_value (rtx, rtx); +static rtx frv_ifcvt_rewrite_mem (rtx, machine_mode, rtx_insn *); +static rtx frv_ifcvt_load_value (rtx, rtx_insn *); static unsigned int frv_insn_unit (rtx_insn *); static bool frv_issues_to_branch_unit_p (rtx_insn *); static int frv_cond_flags (rtx); @@ -4166,7 +4166,7 @@ frv_emit_movsi (rtx dest, rtx src) /* Return a string to output a single word move. */ const char * -output_move_single (rtx operands[], rtx insn) +output_move_single (rtx operands[], rtx_insn *insn) { rtx dest = operands[0]; rtx src = operands[1]; @@ -4380,7 +4380,7 @@ output_move_single (rtx operands[], rtx insn) /* Return a string to output a double word move. */ const char * -output_move_double (rtx operands[], rtx insn) +output_move_double (rtx operands[], rtx_insn *insn) { rtx dest = operands[0]; rtx src = operands[1]; @@ -4511,7 +4511,7 @@ output_move_double (rtx operands[], rtx insn) Operand3 -- source */ const char * -output_condmove_single (rtx operands[], rtx insn) +output_condmove_single (rtx operands[], rtx_insn *insn) { rtx dest = operands[2]; rtx src = operands[3]; @@ -5640,7 +5640,7 @@ frv_ifcvt_modify_multiple_tests (ce_if_block *ce_info, that use constants to ones that just use registers. */ static rtx -frv_ifcvt_load_value (rtx value, rtx insn ATTRIBUTE_UNUSED) +frv_ifcvt_load_value (rtx value, rtx_insn *insn ATTRIBUTE_UNUSED) { int num_alloc = frv_ifcvt.cur_scratch_regs; int i; @@ -5710,7 +5710,7 @@ frv_ifcvt_load_value (rtx value, rtx insn ATTRIBUTE_UNUSED) into a temporary register, or the new MEM if we were successful. */ static rtx -frv_ifcvt_rewrite_mem (rtx mem, machine_mode mode, rtx insn) +frv_ifcvt_rewrite_mem (rtx mem, machine_mode mode, rtx_insn *insn) { rtx addr = XEXP (mem, 0); @@ -6862,7 +6862,7 @@ frv_issue_rate (void) /* Return the value of INSN's acc_group attribute. */ int -frv_acc_group (rtx insn) +frv_acc_group (rtx_insn *insn) { /* This distinction only applies to the FR550 packing constraints. */ if (frv_cpu_type == FRV_CPU_FR550) diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index c9f8a97fae4..58534bcd8a7 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -7844,7 +7844,7 @@ ix86_add_cfa_restore_note (rtx_insn *insn, rtx reg, HOST_WIDE_INT cfa_offset) /* Add queued REG_CFA_RESTORE notes if any to INSN. */ static void -ix86_add_queued_cfa_restore_notes (rtx insn) +ix86_add_queued_cfa_restore_notes (rtx_insn *insn) { rtx last; if (!queued_cfa_restores) diff --git a/gcc/config/m32r/m32r-protos.h b/gcc/config/m32r/m32r-protos.h index e1b539b4443..e61a55bca1a 100644 --- a/gcc/config/m32r/m32r-protos.h +++ b/gcc/config/m32r/m32r-protos.h @@ -39,7 +39,7 @@ extern int m32r_address_code (rtx); extern void m32r_initialize_trampoline (rtx, rtx, rtx); extern int zero_and_one (rtx, rtx); extern char * emit_cond_move (rtx *, rtx); -extern void m32r_output_block_move (rtx, rtx *); +extern void m32r_output_block_move (rtx_insn *, rtx *); extern int m32r_expand_block_move (rtx *); extern int m32r_not_same_reg (rtx, rtx); extern int m32r_hard_regno_rename_ok (unsigned int, unsigned int); diff --git a/gcc/config/m32r/m32r.cc b/gcc/config/m32r/m32r.cc index 023c469782c..3de06d7e7ed 100644 --- a/gcc/config/m32r/m32r.cc +++ b/gcc/config/m32r/m32r.cc @@ -65,7 +65,7 @@ static char m32r_punct_chars[256]; static void m32r_option_override (void); static void init_reg_tables (void); static void block_move_call (rtx, rtx, rtx); -static int m32r_is_insn (rtx); +static int m32r_is_insn (rtx_insn *); static bool m32r_legitimate_address_p (machine_mode, rtx, bool, code_helper = ERROR_MARK); static rtx m32r_legitimize_address (rtx, rtx, machine_mode); @@ -1319,7 +1319,7 @@ m32r_setup_incoming_varargs (cumulative_args_t cum, /* Return true if INSN is real instruction bearing insn. */ static int -m32r_is_insn (rtx insn) +m32r_is_insn (rtx_insn *insn) { return (NONDEBUG_INSN_P (insn) && GET_CODE (PATTERN (insn)) != USE @@ -2613,7 +2613,7 @@ m32r_expand_block_move (rtx operands[]) operands[4] is a temp register. */ void -m32r_output_block_move (rtx insn ATTRIBUTE_UNUSED, rtx operands[]) +m32r_output_block_move (rtx_insn *insn ATTRIBUTE_UNUSED, rtx operands[]) { HOST_WIDE_INT bytes = INTVAL (operands[2]); int first_time; diff --git a/gcc/config/mcore/mcore.cc b/gcc/config/mcore/mcore.cc index e5ee2c1fc74..b90ca730a1a 100644 --- a/gcc/config/mcore/mcore.cc +++ b/gcc/config/mcore/mcore.cc @@ -102,7 +102,7 @@ static void layout_mcore_frame (struct mcore_frame *); static void mcore_setup_incoming_varargs (cumulative_args_t, const function_arg_info &, int *, int); -static cond_type is_cond_candidate (rtx); +static cond_type is_cond_candidate (rtx_insn *); static rtx_insn *emit_new_cond_insn (rtx_insn *, int); static rtx_insn *conditionalize_block (rtx_insn *); static void conditionalize_optimization (void); @@ -2277,7 +2277,7 @@ mcore_output_jump_label_table (void) /* Check whether insn is a candidate for a conditional. */ static cond_type -is_cond_candidate (rtx insn) +is_cond_candidate (rtx_insn *insn) { /* The only things we conditionalize are those that can be directly changed into a conditional. Only bother with SImode items. If diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc index c89cba77994..398c8ffa7ea 100644 --- a/gcc/config/microblaze/microblaze.cc +++ b/gcc/config/microblaze/microblaze.cc @@ -3829,7 +3829,7 @@ microblaze_legitimate_constant_p (machine_mode mode ATTRIBUTE_UNUSED, rtx x) } static rtx -get_branch_target (rtx branch) +get_branch_target (rtx_insn *branch) { if (CALL_P (branch)) { diff --git a/gcc/config/mips/mips-protos.h b/gcc/config/mips/mips-protos.h index 472baac8fde..d02d60c38e0 100644 --- a/gcc/config/mips/mips-protos.h +++ b/gcc/config/mips/mips-protos.h @@ -214,9 +214,9 @@ extern bool mips_legitimize_move (machine_mode, rtx, rtx); extern rtx mips_subword (rtx, bool); extern bool mips_split_move_p (rtx, rtx, enum mips_split_type); -extern void mips_split_move (rtx, rtx, enum mips_split_type, rtx); -extern bool mips_split_move_insn_p (rtx, rtx, rtx); -extern void mips_split_move_insn (rtx, rtx, rtx); +extern void mips_split_move (rtx, rtx, enum mips_split_type, rtx_insn *); +extern bool mips_split_move_insn_p (rtx, rtx, rtx_insn *); +extern void mips_split_move_insn (rtx, rtx, rtx_insn *); extern void mips_split_128bit_move (rtx, rtx); extern bool mips_split_128bit_move_p (rtx, rtx); extern void mips_split_msa_copy_d (rtx, rtx, rtx, rtx (*)(rtx, rtx, rtx)); @@ -237,7 +237,7 @@ extern void mips_expand_conditional_trap (rtx); extern bool mips_use_pic_fn_addr_reg_p (const_rtx); extern rtx_insn *mips_expand_call (enum mips_call_type, rtx, rtx, rtx, rtx, bool); -extern void mips_split_call (rtx, rtx); +extern void mips_split_call (rtx_insn *, rtx); extern bool mips_get_pic_call_symbol (rtx *, int); extern void mips_set_return_address (rtx, rtx); extern bool mips_move_by_pieces_p (unsigned HOST_WIDE_INT, unsigned int); @@ -322,7 +322,7 @@ extern const char *mips_output_probe_stack_range (rtx, rtx); extern bool mips_hard_regno_rename_ok (unsigned int, unsigned int); extern bool mips_linked_madd_p (rtx_insn *, rtx_insn *); extern bool mips_store_data_bypass_p (rtx_insn *, rtx_insn *); -extern int mips_dspalu_bypass_p (rtx, rtx); +extern int mips_dspalu_bypass_p (rtx_insn *, rtx_insn *); extern rtx mips_prefetch_cookie (rtx, rtx); extern rtx mips_loongson_ext2_prefetch_cookie (rtx, rtx); diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc index c7c3781976a..1bc9cb9c99d 100644 --- a/gcc/config/mips/mips.cc +++ b/gcc/config/mips/mips.cc @@ -5027,7 +5027,8 @@ mips_split_move_p (rtx dest, rtx src, enum mips_split_type split_type) split, if we know it, NULL otherwise. */ void -mips_split_move (rtx dest, rtx src, enum mips_split_type split_type, rtx insn_) +mips_split_move (rtx dest, rtx src, enum mips_split_type split_type, + rtx_insn *insn_) { rtx low_dest; @@ -5118,7 +5119,7 @@ mips_split_move (rtx dest, rtx src, enum mips_split_type split_type, rtx insn_) /* Return the split type for instruction INSN. */ static enum mips_split_type -mips_insn_split_type (rtx insn) +mips_insn_split_type (rtx_insn *insn) { basic_block bb = BLOCK_FOR_INSN (insn); if (bb) @@ -5329,7 +5330,7 @@ mips_split_msa_fill_d (rtx dest, rtx src) /* Return true if a move from SRC to DEST in INSN should be split. */ bool -mips_split_move_insn_p (rtx dest, rtx src, rtx insn) +mips_split_move_insn_p (rtx dest, rtx src, rtx_insn *insn) { return mips_split_move_p (dest, src, mips_insn_split_type (insn)); } @@ -5338,7 +5339,7 @@ mips_split_move_insn_p (rtx dest, rtx src, rtx insn) holds. */ void -mips_split_move_insn (rtx dest, rtx src, rtx insn) +mips_split_move_insn (rtx dest, rtx src, rtx_insn *insn) { mips_split_move (dest, src, mips_insn_split_type (insn), insn); } @@ -8308,7 +8309,7 @@ mips_expand_call (enum mips_call_type type, rtx result, rtx addr, CALL_PATTERN is the pattern of the new call. */ void -mips_split_call (rtx insn, rtx call_pattern) +mips_split_call (rtx_insn *insn, rtx call_pattern) { emit_call_insn (call_pattern); if (!find_reg_note (insn, REG_NORETURN, 0)) @@ -10035,7 +10036,7 @@ enum insn_code dspalu_bypass_table[][2] = }; int -mips_dspalu_bypass_p (rtx out_insn, rtx in_insn) +mips_dspalu_bypass_p (rtx_insn *out_insn, rtx_insn *in_insn) { int i; int num_bypass = ARRAY_SIZE (dspalu_bypass_table); diff --git a/gcc/config/mn10300/mn10300-protos.h b/gcc/config/mn10300/mn10300-protos.h index e0f4d56ad3d..80be5ac2793 100644 --- a/gcc/config/mn10300/mn10300-protos.h +++ b/gcc/config/mn10300/mn10300-protos.h @@ -34,7 +34,7 @@ extern unsigned int mn10300_store_multiple_regs (rtx); extern int mn10300_symbolic_operand (rtx, machine_mode); extern void mn10300_split_cbranch (machine_mode, rtx, rtx); extern int mn10300_split_and_operand_count (rtx); -extern bool mn10300_match_ccmode (rtx, machine_mode); +extern bool mn10300_match_ccmode (rtx_insn *, machine_mode); #endif /* RTX_CODE */ extern bool mn10300_regno_in_class_p (unsigned, int, bool); diff --git a/gcc/config/mn10300/mn10300.cc b/gcc/config/mn10300/mn10300.cc index 57c7a5cc567..8ee9a3179bb 100644 --- a/gcc/config/mn10300/mn10300.cc +++ b/gcc/config/mn10300/mn10300.cc @@ -2880,7 +2880,7 @@ mn10300_split_cbranch (machine_mode cmp_mode, rtx cmp_op, rtx label_ref) /* A helper function for matching parallels that set the flags. */ bool -mn10300_match_ccmode (rtx insn, machine_mode cc_mode) +mn10300_match_ccmode (rtx_insn *insn, machine_mode cc_mode) { rtx op1, flags; machine_mode flags_mode; diff --git a/gcc/config/nds32/nds32-md-auxiliary.cc b/gcc/config/nds32/nds32-md-auxiliary.cc index d8378b9af78..9b054edc3ab 100644 --- a/gcc/config/nds32/nds32-md-auxiliary.cc +++ b/gcc/config/nds32/nds32-md-auxiliary.cc @@ -3015,8 +3015,8 @@ nds32_symbol_binds_local_p (const_rtx x) } const char * -nds32_output_call (rtx insn, rtx *operands, rtx symbol, const char *long_call, - const char *call, bool align_p) +nds32_output_call (rtx_insn *insn, rtx *operands, rtx symbol, + const char *long_call, const char *call, bool align_p) { char pattern[100]; bool noreturn_p; diff --git a/gcc/config/nds32/nds32-pipelines-auxiliary.cc b/gcc/config/nds32/nds32-pipelines-auxiliary.cc index 13be995b3c6..5bd40a205cd 100644 --- a/gcc/config/nds32/nds32-pipelines-auxiliary.cc +++ b/gcc/config/nds32/nds32-pipelines-auxiliary.cc @@ -291,7 +291,7 @@ extract_nth_access_reg (rtx_insn *insn, int index) /* Determine if the latency is occurred when the consumer PBSADA_INSN uses the value of DEF_REG in its Ra or Rb fields. */ bool -pbsada_insn_ra_rb_dep_reg_p (rtx pbsada_insn, rtx def_reg) +pbsada_insn_ra_rb_dep_reg_p (rtx_insn *pbsada_insn, rtx def_reg) { rtx unspec_rtx = SET_SRC (PATTERN (pbsada_insn)); gcc_assert (GET_CODE (unspec_rtx) == UNSPEC); @@ -309,7 +309,7 @@ pbsada_insn_ra_rb_dep_reg_p (rtx pbsada_insn, rtx def_reg) /* Determine if the latency is occurred when the consumer PBSADA_INSN uses the value of DEF_REG in its Rt field. */ bool -pbsada_insn_rt_dep_reg_p (rtx pbsada_insn, rtx def_reg) +pbsada_insn_rt_dep_reg_p (rtx_insn *pbsada_insn, rtx def_reg) { rtx pbsada_rt = SET_DEST (PATTERN (pbsada_insn)); @@ -350,7 +350,7 @@ movd44_even_dep_p (rtx_insn *insn, rtx def_reg) /* Check if INSN is a wext insn consuming DEF_REG. */ bool -wext_odd_dep_p (rtx insn, rtx def_reg) +wext_odd_dep_p (rtx_insn *insn, rtx def_reg) { rtx shift_rtx = XEXP (SET_SRC (PATTERN (insn)), 0); rtx use_reg = XEXP (shift_rtx, 0); @@ -397,7 +397,7 @@ wext_odd_dep_p (rtx insn, rtx def_reg) /* Check if INSN is a bpick insn consuming DEF_REG. */ bool -bpick_ra_rb_dep_p (rtx insn, rtx def_reg) +bpick_ra_rb_dep_p (rtx_insn *insn, rtx def_reg) { rtx ior_rtx = SET_SRC (PATTERN (insn)); rtx and1_rtx = XEXP (ior_rtx, 0); diff --git a/gcc/config/nds32/nds32-protos.h b/gcc/config/nds32/nds32-protos.h index 42d15d9d783..396e006df35 100644 --- a/gcc/config/nds32/nds32-protos.h +++ b/gcc/config/nds32/nds32-protos.h @@ -252,7 +252,7 @@ extern const char *nds32_output_cbranchsi4_greater_less_zero (rtx_insn *, rtx *) extern const char *nds32_output_unpkd8 (rtx, rtx, rtx, rtx, bool); -extern const char *nds32_output_call (rtx, rtx *, rtx, +extern const char *nds32_output_call (rtx_insn *, rtx *, rtx, const char *, const char *, bool); extern const char *nds32_output_tls_desc (rtx *); extern const char *nds32_output_tls_ie (rtx *); diff --git a/gcc/config/nds32/nds32-relax-opt.cc b/gcc/config/nds32/nds32-relax-opt.cc index 594fb7b8b87..0ce43df5bb7 100644 --- a/gcc/config/nds32/nds32-relax-opt.cc +++ b/gcc/config/nds32/nds32-relax-opt.cc @@ -389,7 +389,7 @@ nds32_group_insns (rtx_insn *sethi) /* Convert relax group id in rtl. */ static void -nds32_group_tls_insn (rtx insn) +nds32_group_tls_insn (rtx_insn *insn) { rtx pat = PATTERN (insn); rtx unspec_relax_group = XEXP (XVECEXP (pat, 0, 1), 0); diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h index 5efca2d5834..cc5818d668d 100644 --- a/gcc/config/rs6000/rs6000-protos.h +++ b/gcc/config/rs6000/rs6000-protos.h @@ -154,7 +154,7 @@ extern void rs6000_emit_parity (rtx, rtx); extern rtx rs6000_machopic_legitimize_pic_address (rtx, machine_mode, rtx); extern rtx rs6000_allocate_stack_temp (machine_mode, bool, bool); -extern align_flags rs6000_loop_align (rtx); +extern align_flags rs6000_loop_align (rtx_insn *); extern void rs6000_split_logical (rtx [], enum rtx_code, bool, bool, bool); extern bool rs6000_function_pcrel_p (struct function *); extern bool rs6000_pcrel_p (void); diff --git a/gcc/config/rs6000/rs6000-string.cc b/gcc/config/rs6000/rs6000-string.cc index c22db95d6e2..539b898c544 100644 --- a/gcc/config/rs6000/rs6000-string.cc +++ b/gcc/config/rs6000/rs6000-string.cc @@ -2088,7 +2088,8 @@ expand_block_compare (rtx operands[]) SRC_ADDR is the string address to be examined. BYTES is the max number of bytes to compare. */ static void -expand_strncmp_align_check (rtx strncmp_label, rtx src_addr, HOST_WIDE_INT bytes) +expand_strncmp_align_check (rtx_code_label *strncmp_label, rtx src_addr, + HOST_WIDE_INT bytes) { rtx lab_ref = gen_rtx_LABEL_REF (VOIDmode, strncmp_label); rtx src_pgoff = gen_reg_rtx (GET_MODE (src_addr)); diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 7c5b335755c..6347cc5532d 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -4976,7 +4976,7 @@ rs6000_option_override (void) /* Implement LOOP_ALIGN. */ align_flags -rs6000_loop_align (rtx label) +rs6000_loop_align (rtx_insn *label) { basic_block bb; int ninsns; diff --git a/gcc/config/rx/rx-protos.h b/gcc/config/rx/rx-protos.h index 5a36ef26948..8dce64f6f96 100644 --- a/gcc/config/rx/rx-protos.h +++ b/gcc/config/rx/rx-protos.h @@ -57,7 +57,7 @@ extern char * rx_gen_move_template (rtx *, bool); extern bool rx_is_legitimate_constant (machine_mode, rtx); extern bool rx_is_restricted_memory_address (rtx, machine_mode); -extern bool rx_match_ccmode (rtx, machine_mode); +extern bool rx_match_ccmode (rtx_insn *, machine_mode); extern rtx rx_maybe_pidify_operand (rtx, int); extern void rx_notice_update_cc (rtx, rtx); extern void rx_split_cbranch (machine_mode, enum rtx_code, diff --git a/gcc/config/rx/rx.cc b/gcc/config/rx/rx.cc index 9cf7c1ca42c..192701c60e6 100644 --- a/gcc/config/rx/rx.cc +++ b/gcc/config/rx/rx.cc @@ -3308,7 +3308,7 @@ rx_split_cbranch (machine_mode cc_mode, enum rtx_code cmp1, /* A helper function for matching parallels that set the flags. */ bool -rx_match_ccmode (rtx insn, machine_mode cc_mode) +rx_match_ccmode (rtx_insn *insn, machine_mode cc_mode) { rtx op1, flags; machine_mode flags_mode; diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index bf4550a61fa..bd85fe83953 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -9830,7 +9830,7 @@ s390_end_pool (struct constant_pool *pool, rtx_insn *insn) /* Add INSN to the list of insns covered by POOL. */ static void -s390_add_pool_insn (struct constant_pool *pool, rtx insn) +s390_add_pool_insn (struct constant_pool *pool, rtx_insn *insn) { bitmap_set_bit (pool->insns, INSN_UID (insn)); } diff --git a/gcc/config/sh/sh-protos.h b/gcc/config/sh/sh-protos.h index 7379649150f..786fe368a62 100644 --- a/gcc/config/sh/sh-protos.h +++ b/gcc/config/sh/sh-protos.h @@ -45,7 +45,7 @@ extern const char *output_branch (int, rtx_insn *, rtx *); extern const char *output_ieee_ccmpeq (rtx_insn *, rtx *); extern const char *output_branchy_insn (enum rtx_code, const char *, rtx_insn *, rtx *); -extern const char *output_movedouble (rtx, rtx[], machine_mode); +extern const char *output_movedouble (rtx_insn *, rtx[], machine_mode); extern const char *output_movepcrel (rtx, rtx[], machine_mode); extern const char *output_far_jump (rtx_insn *, rtx); @@ -78,11 +78,11 @@ extern void gen_shifty_hi_op (int, rtx *); extern bool expand_ashiftrt (rtx *); extern bool sh_dynamicalize_shift_p (rtx); extern int shl_and_kind (rtx, rtx, int *); -extern int shl_and_length (rtx); -extern int shl_and_scr_length (rtx); +extern int shl_and_length (rtx_insn *); +extern int shl_and_scr_length (rtx_insn *); extern bool gen_shl_and (rtx, rtx, rtx, rtx); extern int shl_sext_kind (rtx, rtx, int *); -extern int shl_sext_length (rtx); +extern int shl_sext_length (rtx_insn *); extern bool gen_shl_sext (rtx, rtx, rtx, rtx); extern int regs_used (rtx, int); extern void fixup_addr_diff_vecs (rtx_insn *); @@ -354,8 +354,8 @@ extern void sh_init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree, signed int, machine_mode); extern rtx sh_dwarf_register_span (rtx); -extern bool sh_contains_memref_p (rtx); -extern bool sh_loads_bankedreg_p (rtx); +extern bool sh_contains_memref_p (rtx_insn *); +extern bool sh_loads_bankedreg_p (rtx_insn *); extern int sh2a_get_function_vector_number (rtx); extern bool sh2a_is_function_vector_call (rtx); extern void sh_fix_range (const char *); diff --git a/gcc/config/sh/sh.cc b/gcc/config/sh/sh.cc index 2a863d6dbb4..d26385f716f 100644 --- a/gcc/config/sh/sh.cc +++ b/gcc/config/sh/sh.cc @@ -174,7 +174,7 @@ char sh_additional_register_names[ADDREGNAMES_SIZE] \ int assembler_dialect; static void split_branches (rtx_insn *); -static int branch_dest (rtx); +static int branch_dest (rtx_insn *); static void print_slot (rtx_sequence *); static rtx_code_label *add_constant (rtx, machine_mode, rtx); static void dump_table (rtx_insn *, rtx_insn *); @@ -223,7 +223,7 @@ static int sh_adjust_cost (rtx_insn *, int, rtx_insn *, int, unsigned int); static int sh_issue_rate (void); static int sh_dfa_new_cycle (FILE *, int, rtx_insn *, int, int, int *sort_p); static short find_set_regmode_weight (rtx, machine_mode); -static short find_insn_regmode_weight (rtx, machine_mode); +static short find_insn_regmode_weight (rtx_insn *, machine_mode); static void find_regmode_weight (basic_block, machine_mode); static int find_r0_life_regions (basic_block); static void sh_md_init_global (FILE *, int, int); @@ -2481,7 +2481,7 @@ sh_emit_compare_and_set (rtx *operands, machine_mode mode) Since the SH cannot move a DI or DF in one instruction, we have to take care when we see overlapping source and dest registers. */ const char * -output_movedouble (rtx insn ATTRIBUTE_UNUSED, rtx operands[], +output_movedouble (rtx_insn *insn ATTRIBUTE_UNUSED, rtx operands[], machine_mode mode) { rtx dst = operands[0]; @@ -4039,7 +4039,7 @@ shl_and_kind (rtx left_rtx, rtx mask_rtx, int *attrp) /* This is used in length attributes of the unnamed instructions corresponding to shl_and_kind return values of 1 and 2. */ int -shl_and_length (rtx insn) +shl_and_length (rtx_insn *insn) { rtx set_src, left_rtx, mask_rtx; int attributes[3]; @@ -4053,7 +4053,7 @@ shl_and_length (rtx insn) /* This is used in length attribute of the and_shl_scratch instruction. */ int -shl_and_scr_length (rtx insn) +shl_and_scr_length (rtx_insn *insn) { rtx set_src = SET_SRC (XVECEXP (PATTERN (insn), 0, 0)); int len = ashl_lshr_seq[INTVAL (XEXP (set_src, 1)) & 31].insn_count; @@ -4295,7 +4295,7 @@ shl_sext_kind (rtx left_rtx, rtx size_rtx, int *costp) /* Function to be used in the length attribute of the instructions implementing this pattern. */ int -shl_sext_length (rtx insn) +shl_sext_length (rtx_insn *insn) { rtx set_src, left_rtx, size_rtx; int cost; @@ -8729,7 +8729,7 @@ tls_symbolic_operand (rtx op, machine_mode mode ATTRIBUTE_UNUSED) /* Return the destination address of a branch. */ static int -branch_dest (rtx branch) +branch_dest (rtx_insn *branch) { rtx dest = SET_SRC (PATTERN (branch)); @@ -9656,7 +9656,7 @@ find_set_regmode_weight (rtx x, machine_mode mode) /* Get regmode weight for insn. */ static short -find_insn_regmode_weight (rtx insn, machine_mode mode) +find_insn_regmode_weight (rtx_insn *insn, machine_mode mode) { /* Increment weight for each register born here. */ rtx x = PATTERN (insn); @@ -11041,7 +11041,7 @@ sh_expand_t_scc (rtx operands[]) /* INSN is an sfunc; return the rtx that describes the address used. */ static rtx -extract_sfunc_addr (rtx insn) +extract_sfunc_addr (rtx_insn *insn) { rtx pattern = PATTERN (insn); const int len = XVECLEN (pattern, 0); @@ -11201,7 +11201,7 @@ sh_gen_truncate (machine_mode mode, rtx x, int need_sign_ext) Return true iff INSN contains a MEM. */ bool -sh_contains_memref_p (rtx insn) +sh_contains_memref_p (rtx_insn *insn) { subrtx_iterator::array_type array; FOR_EACH_SUBRTX (iter, array, PATTERN (insn), NONCONST) @@ -11212,7 +11212,7 @@ sh_contains_memref_p (rtx insn) /* Return true iff INSN loads a banked register. */ bool -sh_loads_bankedreg_p (rtx insn) +sh_loads_bankedreg_p (rtx_insn *insn) { if (GET_CODE (PATTERN (insn)) == SET) { diff --git a/gcc/config/sh/sh_treg_combine.cc b/gcc/config/sh/sh_treg_combine.cc index 26a3182a955..ea5b92c263a 100644 --- a/gcc/config/sh/sh_treg_combine.cc +++ b/gcc/config/sh/sh_treg_combine.cc @@ -313,13 +313,13 @@ find_set_of_reg_bb (rtx reg, rtx_insn *insn) } static bool -reg_dead_after_insn (const_rtx reg, const_rtx insn) +reg_dead_after_insn (const_rtx reg, const rtx_insn *insn) { return find_regno_note (insn, REG_DEAD, REGNO (reg)) != NULL_RTX; } static bool -reg_unused_after_insn (const_rtx reg, const_rtx insn) +reg_unused_after_insn (const_rtx reg, const rtx_insn *insn) { return find_regno_note (insn, REG_UNUSED, REGNO (reg)) != NULL_RTX; } @@ -344,7 +344,7 @@ is_adjacent_bb (basic_block a, basic_block b) // Internal function of trace_reg_uses. static void trace_reg_uses_1 (rtx reg, rtx_insn *start_insn, basic_block bb, int& count, - std::vector& visited_bb, rtx abort_at_insn) + std::vector& visited_bb, rtx_insn *abort_at_insn) { if (bb == NULL) return; @@ -401,7 +401,7 @@ trace_reg_uses_1 (rtx reg, rtx_insn *start_insn, basic_block bb, int& count, // that insn. If the insn 'abort_at_insn' uses the specified reg, it is also // counted. static int -trace_reg_uses (rtx reg, rtx_insn *start_insn, rtx abort_at_insn) +trace_reg_uses (rtx reg, rtx_insn *start_insn, rtx_insn *abort_at_insn) { log_msg ("\ntrace_reg_uses\nreg = "); log_rtx (reg); diff --git a/gcc/config/sparc/sparc.cc b/gcc/config/sparc/sparc.cc index 108dc71b8bc..ae98509bddf 100644 --- a/gcc/config/sparc/sparc.cc +++ b/gcc/config/sparc/sparc.cc @@ -4035,7 +4035,7 @@ emit_cbcond_nop (rtx_insn *insn) instruction. */ static int -eligible_for_restore_insn (rtx trial, bool return_p) +eligible_for_restore_insn (rtx_insn *trial, bool return_p) { rtx pat = PATTERN (trial); rtx src = SET_SRC (pat); @@ -12339,7 +12339,7 @@ sparc_register_move_cost (machine_mode mode ATTRIBUTE_UNUSED, function calls, with the possible exception of calls to the GOT helper. */ static void -emit_and_preserve (rtx seq, rtx reg, rtx reg2) +emit_and_preserve (rtx_insn *seq, rtx reg, rtx reg2) { /* We must preserve the lowest 16 words for the register save area. */ HOST_WIDE_INT offset = 16*UNITS_PER_WORD; diff --git a/gcc/config/stormy16/stormy16-protos.h b/gcc/config/stormy16/stormy16-protos.h index 3bd771efd6a..cb0a7af3924 100644 --- a/gcc/config/stormy16/stormy16-protos.h +++ b/gcc/config/stormy16/stormy16-protos.h @@ -45,7 +45,7 @@ extern char *xstormy16_output_cbranch_hi (rtx, const char *, int, rtx_insn *); extern char *xstormy16_output_cbranch_si (rtx, const char *, int, rtx_insn *); extern void xstormy16_expand_casesi (rtx, rtx, rtx, rtx, rtx); -extern void xstormy16_output_addr_vec (FILE *, rtx, rtx); +extern void xstormy16_output_addr_vec (FILE *, rtx_insn *, rtx); extern void xstormy16_expand_call (rtx, rtx, rtx); extern void xstormy16_expand_iorqi3 (rtx *); extern void xstormy16_expand_andqi3 (rtx *); diff --git a/gcc/config/stormy16/stormy16.cc b/gcc/config/stormy16/stormy16.cc index ae2c668db48..00dce985e24 100644 --- a/gcc/config/stormy16/stormy16.cc +++ b/gcc/config/stormy16/stormy16.cc @@ -2051,7 +2051,8 @@ xstormy16_expand_casesi (rtx index, rtx lower_bound, rtx range, all reach. */ void -xstormy16_output_addr_vec (FILE *file, rtx label ATTRIBUTE_UNUSED, rtx table) +xstormy16_output_addr_vec (FILE *file, rtx_insn *label ATTRIBUTE_UNUSED, + rtx table) { int vlen, idx; diff --git a/gcc/config/vax/vax-protos.h b/gcc/config/vax/vax-protos.h index d5822d8305f..3176174a700 100644 --- a/gcc/config/vax/vax-protos.h +++ b/gcc/config/vax/vax-protos.h @@ -29,7 +29,7 @@ extern void print_operand_address (FILE *, rtx); extern void print_operand (FILE *, rtx, int); extern void vax_expand_addsub_di_operands (rtx *, enum rtx_code); extern bool vax_maybe_split_dimode_move (rtx *); -extern const char * vax_output_int_move (rtx, rtx *, machine_mode); +extern const char * vax_output_int_move (rtx_insn *, rtx *, machine_mode); extern const char * vax_output_int_add (rtx_insn *, rtx *, machine_mode); extern const char * vax_output_int_subtract (rtx_insn *, rtx *, machine_mode); #endif /* RTX_CODE */ diff --git a/gcc/config/vax/vax.cc b/gcc/config/vax/vax.cc index 3cb5d828f1a..838c64c12d9 100644 --- a/gcc/config/vax/vax.cc +++ b/gcc/config/vax/vax.cc @@ -160,7 +160,7 @@ vax_option_override (void) } static void -vax_add_reg_cfa_offset (rtx insn, int offset, rtx src) +vax_add_reg_cfa_offset (rtx_insn *insn, int offset, rtx src) { rtx x; @@ -268,7 +268,7 @@ vax_init_libfuncs (void) /* This is like nonimmediate_operand with a restriction on the type of MEM. */ static void -split_quadword_operands (rtx insn, enum rtx_code code, rtx * operands, +split_quadword_operands (rtx_insn *insn, enum rtx_code code, rtx * operands, rtx * low, int n) { int i; @@ -1246,7 +1246,7 @@ vax_maybe_split_dimode_move (rtx *operands) } const char * -vax_output_int_move (rtx insn ATTRIBUTE_UNUSED, rtx *operands, +vax_output_int_move (rtx_insn *insn ATTRIBUTE_UNUSED, rtx *operands, machine_mode mode) { rtx hi[3], lo[3]; diff --git a/gcc/config/visium/visium.cc b/gcc/config/visium/visium.cc index 2f1e3fd7c0c..538676d94be 100644 --- a/gcc/config/visium/visium.cc +++ b/gcc/config/visium/visium.cc @@ -1095,7 +1095,7 @@ gr5_hazard_bypass_p (rtx_insn *out_insn, rtx_insn *in_insn) /* Return true if INSN is an empty asm instruction. */ static bool -empty_asm_p (rtx insn) +empty_asm_p (rtx_insn *insn) { rtx body = PATTERN (insn); const char *templ; @@ -3980,7 +3980,7 @@ visium_add_cfa_restore_note (rtx reg) /* Add queued REG_CFA_RESTORE notes to INSN, if any. */ static void -visium_add_queued_cfa_restore_notes (rtx insn) +visium_add_queued_cfa_restore_notes (rtx_insn *insn) { rtx last; if (!cfa_restores) diff --git a/gcc/df-problems.cc b/gcc/df-problems.cc index f9769f8a489..49861a7766a 100644 --- a/gcc/df-problems.cc +++ b/gcc/df-problems.cc @@ -4118,7 +4118,7 @@ find_memory_stores (rtx x, const_rtx pat ATTRIBUTE_UNUSED, lifetimes, up to insn POINT. The result is stored in LIVE. */ void -simulate_backwards_to_point (basic_block bb, regset live, rtx point) +simulate_backwards_to_point (basic_block bb, regset live, rtx_insn *point) { rtx_insn *insn; bitmap_copy (live, df_get_live_out (bb)); diff --git a/gcc/df.h b/gcc/df.h index f11bb95415b..e086a2890c6 100644 --- a/gcc/df.h +++ b/gcc/df.h @@ -1057,7 +1057,7 @@ extern void df_simulate_one_insn_backwards (basic_block, rtx_insn *, bitmap); extern void df_simulate_finalize_backwards (basic_block, bitmap); extern void df_simulate_initialize_forwards (basic_block, bitmap); extern void df_simulate_one_insn_forwards (basic_block, rtx_insn *, bitmap); -extern void simulate_backwards_to_point (basic_block, regset, rtx); +extern void simulate_backwards_to_point (basic_block, regset, rtx_insn *); extern bool can_move_insns_across (rtx_insn *, rtx_insn *, rtx_insn *, rtx_insn *, basic_block, regset, diff --git a/gcc/dse.cc b/gcc/dse.cc index 68e6dd136f9..8e88cde0f42 100644 --- a/gcc/dse.cc +++ b/gcc/dse.cc @@ -2435,7 +2435,7 @@ check_mem_read_use (rtx *loc, void *data) So far it only handles arguments passed in registers. */ static bool -get_call_args (rtx call_insn, tree fn, rtx *args, int nargs) +get_call_args (rtx_insn *call_insn, tree fn, rtx *args, int nargs) { CUMULATIVE_ARGS args_so_far_v; cumulative_args_t args_so_far; diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index e8a6019f72e..9964fdc8da8 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -14632,7 +14632,7 @@ reg_loc_descriptor (rtx rtl, enum var_init_status initialized) if ((rtl == arg_pointer_rtx || rtl == frame_pointer_rtx) && (ira_use_lra_p ? lra_eliminate_regs (rtl, VOIDmode, NULL_RTX) - : eliminate_regs (rtl, VOIDmode, NULL_RTX)) != rtl) + : eliminate_regs (rtl, VOIDmode, nullptr)) != rtl) { dw_loc_descr_ref result = NULL; @@ -15198,7 +15198,7 @@ based_loc_descr (rtx reg, poly_int64 offset, { rtx elim = (ira_use_lra_p ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX) - : eliminate_regs (reg, VOIDmode, NULL_RTX)); + : eliminate_regs (reg, VOIDmode, nullptr)); if (elim != reg) { @@ -21617,7 +21617,7 @@ compute_frame_pointer_to_fb_displacement (poly_int64 offset) elim = (ira_use_lra_p ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX) - : eliminate_regs (reg, VOIDmode, NULL_RTX)); + : eliminate_regs (reg, VOIDmode, nullptr)); elim = strip_offset_and_add (elim, &offset); frame_pointer_fb_offset = -offset; diff --git a/gcc/except.cc b/gcc/except.cc index 1a7ff2b21ce..d00f033af51 100644 --- a/gcc/except.cc +++ b/gcc/except.cc @@ -1768,7 +1768,8 @@ insn_could_throw_p (const rtx_insn *insn) to look for a note, or the note itself. */ void -copy_reg_eh_region_note_forward (rtx note_or_insn, rtx_insn *first, rtx last) +copy_reg_eh_region_note_forward (rtx note_or_insn, rtx_insn *first, + rtx_insn *last) { rtx_insn *insn; rtx note = note_or_insn; @@ -1792,7 +1793,8 @@ copy_reg_eh_region_note_forward (rtx note_or_insn, rtx_insn *first, rtx last) /* Likewise, but iterate backward. */ void -copy_reg_eh_region_note_backward (rtx note_or_insn, rtx_insn *last, rtx first) +copy_reg_eh_region_note_backward (rtx note_or_insn, rtx_insn *last, + rtx_insn *first) { rtx_insn *insn; rtx note = note_or_insn; diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc index fad341ead6c..eb3a958074d 100644 --- a/gcc/ifcvt.cc +++ b/gcc/ifcvt.cc @@ -351,7 +351,7 @@ rtx_interchangeable_p (const_rtx a, const_rtx b) static bool cond_exec_process_insns (ce_if_block *ce_info ATTRIBUTE_UNUSED, - rtx_insn *start, rtx end, rtx test, + rtx_insn *start, rtx_insn *end, rtx test, profile_probability prob_val, bool mod_ok) { bool must_be_last = false; diff --git a/gcc/lower-subreg.cc b/gcc/lower-subreg.cc index e4d613c5d22..6d8d6f9103b 100644 --- a/gcc/lower-subreg.cc +++ b/gcc/lower-subreg.cc @@ -794,7 +794,7 @@ simplify_gen_subreg_concatn (machine_mode outermode, rtx op, /* Look for SUBREGs in *LOC which need to be decomposed. */ static bool -resolve_subreg_use (rtx *loc, rtx insn) +resolve_subreg_use (rtx *loc, rtx_insn *insn) { subrtx_ptr_iterator::array_type array; FOR_EACH_SUBRTX_PTR (iter, array, loc, NONCONST) @@ -841,7 +841,7 @@ resolve_reg_notes (rtx_insn *insn) if (note) { int old_count = num_validated_changes (); - if (resolve_subreg_use (&XEXP (note, 0), NULL_RTX)) + if (resolve_subreg_use (&XEXP (note, 0), nullptr)) remove_note (insn, note); else if (old_count != num_validated_changes ()) @@ -1025,7 +1025,7 @@ resolve_simple_move (rtx set, rtx_insn *insn) /* It's possible for the code to use a subreg of a decomposed register while forming an address. We need to handle that before - passing the address to emit_move_insn. We pass NULL_RTX as the + passing the address to emit_move_insn. We pass nullptr as the insn parameter to resolve_subreg_use because we cannot validate the insn yet. */ if (MEM_P (src) || MEM_P (dest)) @@ -1033,9 +1033,9 @@ resolve_simple_move (rtx set, rtx_insn *insn) int acg; if (MEM_P (src)) - resolve_subreg_use (&XEXP (src, 0), NULL_RTX); + resolve_subreg_use (&XEXP (src, 0), nullptr); if (MEM_P (dest)) - resolve_subreg_use (&XEXP (dest, 0), NULL_RTX); + resolve_subreg_use (&XEXP (dest, 0), nullptr); acg = apply_change_group (); gcc_assert (acg); } @@ -1175,7 +1175,7 @@ resolve_simple_move (rtx set, rtx_insn *insn) insns = end_sequence (); - copy_reg_eh_region_note_forward (insn, insns, NULL_RTX); + copy_reg_eh_region_note_forward (insn, insns, nullptr); emit_insn_before (insns, insn); diff --git a/gcc/postreload-gcse.cc b/gcc/postreload-gcse.cc index 2203c60ae91..5cf9191e932 100644 --- a/gcc/postreload-gcse.cc +++ b/gcc/postreload-gcse.cc @@ -1349,7 +1349,7 @@ delete_redundant_insns (void) due to spilling. */ static void -gcse_after_reload_main (rtx f ATTRIBUTE_UNUSED) +gcse_after_reload_main (rtx_insn *f ATTRIBUTE_UNUSED) { /* Disable computing transparentness if it is too expensive. */ bool do_transp diff --git a/gcc/reload.cc b/gcc/reload.cc index 284e90e40e4..71aa30598ad 100644 --- a/gcc/reload.cc +++ b/gcc/reload.cc @@ -588,7 +588,7 @@ get_secondary_mem (rtx x ATTRIBUTE_UNUSED, machine_mode mode, /* Get a version of the address doing any eliminations needed. If that didn't give us a new MEM, make a new one if it isn't valid. */ - loc = eliminate_regs (secondary_memlocs[(int) mode], VOIDmode, NULL_RTX); + loc = eliminate_regs (secondary_memlocs[(int) mode], VOIDmode, nullptr); mem_valid = strict_memory_address_addr_space_p (mode, XEXP (loc, 0), MEM_ADDR_SPACE (loc)); @@ -4818,7 +4818,7 @@ make_memloc (rtx ad, int regno) /* We must rerun eliminate_regs, in case the elimination offsets have changed. */ rtx tem - = XEXP (eliminate_regs (reg_equiv_memory_loc (regno), VOIDmode, NULL_RTX), + = XEXP (eliminate_regs (reg_equiv_memory_loc (regno), VOIDmode, nullptr), 0); /* If TEM might contain a pseudo, we must copy it to avoid diff --git a/gcc/reload.h b/gcc/reload.h index 7eb6fda5e14..4a188626d38 100644 --- a/gcc/reload.h +++ b/gcc/reload.h @@ -425,7 +425,7 @@ extern void mark_home_live (int); /* Scan X and replace any eliminable registers (such as fp) with a replacement (such as sp), plus an offset. */ -extern rtx eliminate_regs (rtx, machine_mode, rtx); +extern rtx eliminate_regs (rtx, machine_mode, rtx_insn *); extern bool elimination_target_reg_p (rtx); /* Called from the register allocator to estimate costs of eliminating diff --git a/gcc/reload1.cc b/gcc/reload1.cc index 3f338bde16a..75cb7900f93 100644 --- a/gcc/reload1.cc +++ b/gcc/reload1.cc @@ -926,7 +926,7 @@ reload (rtx_insn *first, int global) if (reg_renumber[i] < 0 && reg_equiv_memory_loc (i)) { rtx x = eliminate_regs (reg_equiv_memory_loc (i), VOIDmode, - NULL_RTX); + nullptr); if (strict_memory_address_addr_space_p (GET_MODE (regno_reg_rtx[i]), XEXP (x, 0), @@ -2941,7 +2941,7 @@ eliminate_regs_1 (rtx x, machine_mode mem_mode, rtx insn, } rtx -eliminate_regs (rtx x, machine_mode mem_mode, rtx insn) +eliminate_regs (rtx x, machine_mode mem_mode, rtx_insn *insn) { if (reg_eliminate == NULL) { @@ -4495,7 +4495,7 @@ reload_as_needed (int live_known) XEXP (XEXP (PATTERN (insn), 0), 0) = eliminate_regs (XEXP (XEXP (PATTERN (insn), 0), 0), GET_MODE (XEXP (PATTERN (insn), 0)), - NULL_RTX); + nullptr); /* If we need to do register elimination processing, do so. This might delete the insn, in which case we are done. */ @@ -8728,7 +8728,7 @@ delete_output_reload (rtx_insn *insn, int j, int last_reload_reg, if (substed) n_occurrences += count_occurrences (PATTERN (insn), eliminate_regs (substed, VOIDmode, - NULL_RTX), 0); + nullptr), 0); for (rtx i1 = reg_equiv_alt_mem_list (REGNO (reg)); i1; i1 = XEXP (i1, 1)) { gcc_assert (!rtx_equal_p (XEXP (i1, 0), substed)); diff --git a/gcc/reorg.cc b/gcc/reorg.cc index 1b6870b69f6..eee7ba364f6 100644 --- a/gcc/reorg.cc +++ b/gcc/reorg.cc @@ -212,7 +212,7 @@ static bool own_thread_p (rtx, rtx, bool); static void update_block (rtx_insn *, rtx_insn *); static bool reorg_redirect_jump (rtx_jump_insn *, rtx); static void update_reg_dead_notes (rtx_insn *, rtx_insn *); -static void fix_reg_dead_note (rtx_insn *, rtx); +static void fix_reg_dead_note (rtx_insn *, rtx_insn *); static void update_reg_unused_notes (rtx_insn *, rtx); static void fill_simple_delay_slots (bool); static void fill_slots_from_thread (rtx_jump_insn *, rtx, rtx, rtx, @@ -1704,7 +1704,7 @@ update_reg_dead_notes (rtx_insn *insn, rtx_insn *delayed_insn) confused into thinking the register is dead. */ static void -fix_reg_dead_note (rtx_insn *start_insn, rtx stop_insn) +fix_reg_dead_note (rtx_insn *start_insn, rtx_insn *stop_insn) { rtx link, next; rtx_insn *p; @@ -3024,7 +3024,7 @@ delete_jump (rtx_insn *insn) } static rtx_insn * -label_before_next_insn (rtx_insn *x, rtx scan_limit) +label_before_next_insn (rtx_insn *x, rtx_insn *scan_limit) { rtx_insn *insn = next_active_insn (x); while (insn) diff --git a/gcc/rtl.h b/gcc/rtl.h index 64b53b9b342..73c71750317 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3779,8 +3779,8 @@ extern bool can_throw_external (const rtx_insn *); extern bool insn_could_throw_p (const rtx_insn *); extern bool insn_nothrow_p (const rtx_insn *); extern bool can_nonlocal_goto (const rtx_insn *); -extern void copy_reg_eh_region_note_forward (rtx, rtx_insn *, rtx); -extern void copy_reg_eh_region_note_backward (rtx, rtx_insn *, rtx); +extern void copy_reg_eh_region_note_forward (rtx, rtx_insn *, rtx_insn *); +extern void copy_reg_eh_region_note_backward (rtx, rtx_insn *, rtx_insn *); extern rtx replace_rtx (rtx, rtx, rtx, bool = false); extern void replace_label (rtx *, rtx_insn *, rtx_insn *, bool); extern void replace_label_in_insn (rtx_insn *, rtx_insn *, rtx_insn *, bool); diff --git a/gcc/sched-int.h b/gcc/sched-int.h index ce9ab3a2a31..d64493d4801 100644 --- a/gcc/sched-int.h +++ b/gcc/sched-int.h @@ -115,7 +115,7 @@ extern vec sched_luids; /* The highest INSN_LUID. */ extern int sched_max_luid; -extern int insn_luid (rtx); +extern int insn_luid (rtx_insn *); /* This list holds ripped off notes from the current block. These notes will be attached to the beginning of the block when its scheduling is diff --git a/gcc/sel-sched-ir.cc b/gcc/sel-sched-ir.cc index c84a0a96777..79e31bbae55 100644 --- a/gcc/sel-sched-ir.cc +++ b/gcc/sel-sched-ir.cc @@ -1980,7 +1980,7 @@ speculate_expr (expr_t expr, ds_t ds) case 1: { rtx_insn *spec_insn_rtx = - create_insn_rtx_from_pattern (spec_pat, NULL_RTX); + create_insn_rtx_from_pattern (spec_pat, nullptr); vinsn_t spec_vinsn = create_vinsn_from_insn_rtx (spec_insn_rtx, false); change_vinsn_in_expr (expr, spec_vinsn); @@ -5715,7 +5715,7 @@ sel_unregister_cfg_hooks (void) /* Emit an insn rtx based on PATTERN. If a jump insn is wanted, LABEL is where this jump should be directed. */ rtx_insn * -create_insn_rtx_from_pattern (rtx pattern, rtx label) +create_insn_rtx_from_pattern (rtx pattern, rtx_insn *label) { rtx_insn *insn_rtx; @@ -5770,7 +5770,7 @@ create_copy_of_insn_rtx (rtx_insn *insn_rtx) gcc_assert (NONJUMP_INSN_P (insn_rtx)); res = create_insn_rtx_from_pattern (copy_rtx (PATTERN (insn_rtx)), - NULL_RTX); + nullptr); /* Locate the end of existing REG_NOTES in NEW_RTX. */ rtx *ptail = ®_NOTES (res); diff --git a/gcc/sel-sched-ir.h b/gcc/sel-sched-ir.h index d6af054dfb7..d4a66437806 100644 --- a/gcc/sel-sched-ir.h +++ b/gcc/sel-sched-ir.h @@ -1593,7 +1593,7 @@ extern void sel_register_cfg_hooks (void); extern void sel_unregister_cfg_hooks (void); /* Expression transformation routines. */ -extern rtx_insn *create_insn_rtx_from_pattern (rtx, rtx); +extern rtx_insn *create_insn_rtx_from_pattern (rtx, rtx_insn *); extern vinsn_t create_vinsn_from_insn_rtx (rtx_insn *, bool); extern rtx_insn *create_copy_of_insn_rtx (rtx_insn *); extern void change_vinsn_in_expr (expr_t, vinsn_t); diff --git a/gcc/sel-sched.cc b/gcc/sel-sched.cc index 5f5ac727c8f..e79b087045f 100644 --- a/gcc/sel-sched.cc +++ b/gcc/sel-sched.cc @@ -840,7 +840,7 @@ create_insn_rtx_with_rhs (vinsn_t vi, rtx rhs_rtx) lhs_rtx = copy_rtx (VINSN_LHS (vi)); pattern = gen_rtx_SET (lhs_rtx, rhs_rtx); - insn_rtx = create_insn_rtx_from_pattern (pattern, NULL_RTX); + insn_rtx = create_insn_rtx_from_pattern (pattern, nullptr); return insn_rtx; } @@ -921,7 +921,7 @@ create_insn_rtx_with_lhs (vinsn_t vi, rtx lhs_rtx) rhs_rtx = copy_rtx (VINSN_RHS (vi)); pattern = gen_rtx_SET (lhs_rtx, rhs_rtx); - insn_rtx = create_insn_rtx_from_pattern (pattern, NULL_RTX); + insn_rtx = create_insn_rtx_from_pattern (pattern, nullptr); return insn_rtx; } @@ -1816,7 +1816,7 @@ create_speculation_check (expr_t c_expr, ds_t check_ds, insn_t orig_insn) rtx twin_rtx; twin_rtx = copy_rtx (PATTERN (EXPR_INSN_RTX (c_expr))); - twin_rtx = create_insn_rtx_from_pattern (twin_rtx, NULL_RTX); + twin_rtx = create_insn_rtx_from_pattern (twin_rtx, nullptr); sel_gen_recovery_insn_from_rtx_after (twin_rtx, INSN_EXPR (orig_insn), INSN_SEQNO (insn), diff --git a/gcc/var-tracking.cc b/gcc/var-tracking.cc index 8fea25a77bd..a24de59c2a3 100644 --- a/gcc/var-tracking.cc +++ b/gcc/var-tracking.cc @@ -10145,7 +10145,7 @@ vt_initialize (void) #endif elim = (ira_use_lra_p ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX) - : eliminate_regs (reg, VOIDmode, NULL_RTX)); + : eliminate_regs (reg, VOIDmode, nullptr)); if (elim != reg) { if (GET_CODE (elim) == PLUS) @@ -10167,7 +10167,7 @@ vt_initialize (void) #endif elim = (ira_use_lra_p ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX) - : eliminate_regs (reg, VOIDmode, NULL_RTX)); + : eliminate_regs (reg, VOIDmode, nullptr)); if (elim != reg) { if (GET_CODE (elim) == PLUS) @@ -10201,7 +10201,7 @@ vt_initialize (void) #endif elim = (ira_use_lra_p ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX) - : eliminate_regs (reg, VOIDmode, NULL_RTX)); + : eliminate_regs (reg, VOIDmode, nullptr)); if (elim != reg) { if (GET_CODE (elim) == PLUS) -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:54 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:54 -0500 Subject: [PATCH 13/25] Pass an rtx_insn * to add_function_usage_to In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-14-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * emit-rtl.cc (add_function_usage_to): Take an rtx_insn *. * rtl.h (add_function_usage_to): Likewise. --- gcc/emit-rtl.cc | 2 +- gcc/rtl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/emit-rtl.cc b/gcc/emit-rtl.cc index 9e8ff55d50c..e76e0bbb264 100644 --- a/gcc/emit-rtl.cc +++ b/gcc/emit-rtl.cc @@ -4561,7 +4561,7 @@ remove_insn (rtx_insn *insn) /* Append CALL_FUSAGE to the CALL_INSN_FUNCTION_USAGE for CALL_INSN. */ void -add_function_usage_to (rtx call_insn, rtx call_fusage) +add_function_usage_to (rtx_insn *call_insn, rtx call_fusage) { gcc_assert (call_insn && CALL_P (call_insn)); diff --git a/gcc/rtl.h b/gcc/rtl.h index 73c71750317..94fab8572c2 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3450,7 +3450,7 @@ extern rtx_insn *emit_clobber (rtx); extern rtx_insn *gen_use (rtx); extern rtx_insn *emit_use (rtx); extern rtx_insn *make_insn_raw (rtx); -extern void add_function_usage_to (rtx, rtx); +extern void add_function_usage_to (rtx_insn *, rtx); extern rtx_call_insn *last_call_insn (void); extern rtx_insn *previous_insn (rtx_insn *); extern rtx_insn *next_insn (rtx_insn *); -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:53 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:53 -0500 Subject: [PATCH 12/25] Split pattern locals from the insns they emit In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-13-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * config/arc/arc.cc (arc_restore_callee_leave, arc_restore_callee_milli, arc_reorg): Split the pattern from the emitted insn. * config/arm/arm.cc (vfp_emit_fstmd, arm_emit_strd_push, arm_emit_multi_reg_pop, arm_emit_vfp_multi_reg_pop, thumb2_emit_ldrd_pop, arm_emit_ldrd_pop, arm_expand_epilogue): Likewise. * config/epiphany/epiphany.md (*ashlv2si3_i): Likewise. * config/msp430/msp430.cc (msp430_expand_helper): Likewise. * config/nds32/nds32.cc (nds32_emit_stack_push_multiple, nds32_emit_stack_pop_multiple, nds32_emit_stack_v3push, nds32_emit_stack_v3pop, nds32_emit_adjust_frame): Likewise. * config/sh/sh.cc (pop, push_regs): Likewise. --- gcc/config/arc/arc.cc | 63 +++++++++++++------------ gcc/config/arm/arm.cc | 79 +++++++++++++++---------------- gcc/config/epiphany/epiphany.md | 8 ++-- gcc/config/msp430/msp430.cc | 6 +-- gcc/config/nds32/nds32.cc | 82 ++++++++++++++++----------------- gcc/config/sh/sh.cc | 22 ++++----- 6 files changed, 132 insertions(+), 128 deletions(-) diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc index 557d30e2752..675c61e2826 100644 --- a/gcc/config/arc/arc.cc +++ b/gcc/config/arc/arc.cc @@ -3362,7 +3362,7 @@ arc_restore_callee_leave (uint64_t gmask, int start_reg = ENTER_LEAVE_START_REG; int end_reg = ENTER_LEAVE_END_REG; int regno, indx, off, nregs; - rtx insn, reg, mem; + rtx body, reg, mem; int frame_allocated = 0; for (regno = start_reg; regno <= end_reg && (gmask & (1ULL << regno));) @@ -3373,12 +3373,12 @@ arc_restore_callee_leave (uint64_t gmask, nregs += restore_blink ? 1 : 0; nregs += restore_fp ? 1 : 0; - insn = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs + 1 + body = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs + 1 + (return_p ? 1 : 0))); indx = 0; if (return_p) - XVECEXP (insn, 0, indx++) = ret_rtx; + XVECEXP (body, 0, indx++) = ret_rtx; if (restore_fp) { @@ -3402,7 +3402,7 @@ arc_restore_callee_leave (uint64_t gmask, stack_pointer_rtx, offset + nregs * UNITS_PER_WORD)); RTX_FRAME_RELATED_P (reg) = 1; - XVECEXP (insn, 0, indx++) = reg; + XVECEXP (body, 0, indx++) = reg; off = nregs * UNITS_PER_WORD; if (restore_blink) @@ -3411,8 +3411,8 @@ arc_restore_callee_leave (uint64_t gmask, mem = gen_frame_mem (Pmode, plus_constant (Pmode, stack_pointer_rtx, off)); - XVECEXP (insn, 0, indx) = gen_rtx_SET (reg, mem); - RTX_FRAME_RELATED_P (XVECEXP (insn, 0, indx++)) = 1; + XVECEXP (body, 0, indx) = gen_rtx_SET (reg, mem); + RTX_FRAME_RELATED_P (XVECEXP (body, 0, indx++)) = 1; off -= UNITS_PER_WORD; } @@ -3424,8 +3424,8 @@ arc_restore_callee_leave (uint64_t gmask, mem = gen_frame_mem (SImode, plus_constant (Pmode, stack_pointer_rtx, off)); - XVECEXP (insn, 0, indx) = gen_rtx_SET (reg, mem); - RTX_FRAME_RELATED_P (XVECEXP (insn, 0, indx)) = 1; + XVECEXP (body, 0, indx) = gen_rtx_SET (reg, mem); + RTX_FRAME_RELATED_P (XVECEXP (body, 0, indx)) = 1; gmask = gmask & ~(1ULL << regno); } @@ -3434,19 +3434,20 @@ arc_restore_callee_leave (uint64_t gmask, mem = gen_frame_mem (Pmode, plus_constant (Pmode, stack_pointer_rtx, off)); - XVECEXP (insn, 0, indx) = gen_rtx_SET (hard_frame_pointer_rtx, mem); - RTX_FRAME_RELATED_P (XVECEXP (insn, 0, indx++)) = 1; + XVECEXP (body, 0, indx) = gen_rtx_SET (hard_frame_pointer_rtx, mem); + RTX_FRAME_RELATED_P (XVECEXP (body, 0, indx++)) = 1; off -= UNITS_PER_WORD; } gcc_assert (off == 0); + rtx_insn *insn; if (return_p) { - insn = emit_jump_insn (insn); + insn = emit_jump_insn (body); RTX_FRAME_RELATED_P (insn) = 1; } else - insn = frame_insn (insn); + insn = frame_insn (body); add_reg_note (insn, REG_INC, stack_pointer_rtx); @@ -3612,7 +3613,7 @@ arc_restore_callee_milli (uint64_t gmask, int start_reg = 13; int end_reg = 25; int regno, indx, off, nregs; - rtx insn, reg, mem; + rtx body, reg, mem; int frame_allocated = 0; for (regno = start_reg; regno <= end_reg && (gmask & (1ULL << regno));) @@ -3643,7 +3644,7 @@ arc_restore_callee_milli (uint64_t gmask, } /* Start generate millicode call. */ - insn = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc ((return_p ? 1 : 0) + body = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc ((return_p ? 1 : 0) + nregs + 1)); indx = 0; @@ -3652,17 +3653,17 @@ arc_restore_callee_milli (uint64_t gmask, /* sibling call, the blink is restored with the help of the value held into r12. */ reg = gen_rtx_REG (Pmode, 12); - XVECEXP (insn, 0, indx++) = ret_rtx; - XVECEXP (insn, 0, indx++) = - gen_rtx_SET (stack_pointer_rtx, - gen_rtx_PLUS (Pmode, stack_pointer_rtx, reg)); + XVECEXP (body, 0, indx++) = ret_rtx; + XVECEXP (body, 0, indx++) + = gen_rtx_SET (stack_pointer_rtx, + gen_rtx_PLUS (Pmode, stack_pointer_rtx, reg)); frame_allocated += UNITS_PER_WORD; } else { /* This is a call, we clobber blink. */ - XVECEXP (insn, 0, nregs) = - gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM)); + XVECEXP (body, 0, nregs) + = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM)); } for (regno = start_reg, off = 0; @@ -3673,8 +3674,8 @@ arc_restore_callee_milli (uint64_t gmask, mem = gen_frame_mem (SImode, plus_constant (Pmode, stack_pointer_rtx, off)); - XVECEXP (insn, 0, indx) = gen_rtx_SET (reg, mem); - RTX_FRAME_RELATED_P (XVECEXP (insn, 0, indx)) = 1; + XVECEXP (body, 0, indx) = gen_rtx_SET (reg, mem); + RTX_FRAME_RELATED_P (XVECEXP (body, 0, indx)) = 1; gmask = gmask & ~(1ULL << regno); } @@ -3694,16 +3695,17 @@ arc_restore_callee_milli (uint64_t gmask, } /* Emit millicode call. */ + rtx_insn *insn; if (return_p) { reg = gen_rtx_REG (Pmode, 12); frame_insn (gen_rtx_SET (reg, GEN_INT (off))); frame_allocated += off; - insn = emit_jump_insn (insn); + insn = emit_jump_insn (body); RTX_FRAME_RELATED_P (insn) = 1; } else - insn = frame_insn (insn); + insn = frame_insn (body); /* Add DWARF info. */ for (regno = start_reg; regno <= end_reg; regno++) @@ -8581,7 +8583,7 @@ arc_reorg (void) else { /* Check if this is a data dependency. */ - rtx op, cc_clob_rtx, op0, op1, brcc_insn, note; + rtx op, cc_clob_rtx, op0, op1, brcc_body, note; rtx cmp0, cmp1; /* Make sure we can use it for brcc insns. */ @@ -8661,14 +8663,15 @@ arc_reorg (void) else cc_clob_rtx = gen_rtx_REG (CCmode, CC_REG); - brcc_insn + brcc_body = gen_rtx_IF_THEN_ELSE (VOIDmode, op, label, pc_rtx); - brcc_insn = gen_rtx_SET (pc_rtx, brcc_insn); + brcc_body = gen_rtx_SET (pc_rtx, brcc_body); cc_clob_rtx = gen_rtx_CLOBBER (VOIDmode, cc_clob_rtx); - brcc_insn + brcc_body = gen_rtx_PARALLEL - (VOIDmode, gen_rtvec (2, brcc_insn, cc_clob_rtx)); - brcc_insn = emit_jump_insn_before (brcc_insn, insn); + (VOIDmode, gen_rtvec (2, brcc_body, cc_clob_rtx)); + rtx_jump_insn *brcc_insn + = emit_jump_insn_before (brcc_body, insn); JUMP_LABEL (brcc_insn) = JUMP_LABEL (insn); note = find_reg_note (insn, REG_BR_PROB, 0); diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 8a267bb7e4f..2b3ab29a10e 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -19009,9 +19009,9 @@ vfp_emit_fstmd (int base_reg, int count) XVECEXP (dwarf, 0, i + 1) = tmp; } - par = emit_insn (par); - add_reg_note (par, REG_FRAME_RELATED_EXPR, dwarf); - RTX_FRAME_RELATED_P (par) = 1; + rtx_insn *insn = emit_insn (par); + add_reg_note (insn, REG_FRAME_RELATED_EXPR, dwarf); + RTX_FRAME_RELATED_P (insn) = 1; return count * 8; } @@ -21253,11 +21253,11 @@ arm_emit_strd_push (unsigned long saved_regs_mask) tmp = gen_rtx_SET (mem, gen_rtx_REG (DImode, j)); RTX_FRAME_RELATED_P (tmp) = 1; - tmp = emit_insn (tmp); + rtx_insn *tmp1 = emit_insn (tmp); /* Record the first store insn. */ if (dwarf_index == 1) - insn = tmp; + insn = tmp1; /* Generate dwarf info. */ mem = gen_frame_mem (SImode, @@ -21300,11 +21300,11 @@ arm_emit_strd_push (unsigned long saved_regs_mask) tmp = gen_rtx_SET (mem, gen_rtx_REG (SImode, j)); RTX_FRAME_RELATED_P (tmp) = 1; - tmp = emit_insn (tmp); + rtx_insn *tmp1 = emit_insn (tmp); /* Record the first store insn. */ if (dwarf_index == 1) - insn = tmp; + insn = tmp1; /* Generate dwarf info. */ mem = gen_frame_mem (SImode, @@ -21611,14 +21611,14 @@ arm_emit_multi_reg_pop (unsigned long saved_regs_mask) elt++; } - par = return_in_pc ? emit_jump_insn (par) : emit_insn (par); - REG_NOTES (par) = dwarf; + rtx_insn *insn = return_in_pc ? emit_jump_insn (par) : emit_insn (par); + REG_NOTES (insn) = dwarf; if (!return_in_pc && emit_update) - arm_add_cfa_adjust_cfa_note (par, UNITS_PER_WORD * num_regs, + arm_add_cfa_adjust_cfa_note (insn, UNITS_PER_WORD * num_regs, stack_pointer_rtx, stack_pointer_rtx); else if (!return_in_pc) - RTX_FRAME_RELATED_P (par) = 1; + RTX_FRAME_RELATED_P (insn) = 1; } /* Generate and emit an insn pattern that we will recognize as a pop_multi @@ -21684,17 +21684,17 @@ arm_emit_vfp_multi_reg_pop (int first_reg, int num_regs, rtx base_reg) j++; } - par = emit_insn (par); - REG_NOTES (par) = dwarf; + rtx_insn *insn = emit_insn (par); + REG_NOTES (insn) = dwarf; /* Make sure cfa doesn't leave with IP_REGNUM to allow unwinding from FP. */ if (REGNO (base_reg) == IP_REGNUM) { - RTX_FRAME_RELATED_P (par) = 1; - add_reg_note (par, REG_CFA_DEF_CFA, hard_frame_pointer_rtx); + RTX_FRAME_RELATED_P (insn) = 1; + add_reg_note (insn, REG_CFA_DEF_CFA, hard_frame_pointer_rtx); } else - arm_add_cfa_adjust_cfa_note (par, 2 * UNITS_PER_WORD * num_regs, + arm_add_cfa_adjust_cfa_note (insn, 2 * UNITS_PER_WORD * num_regs, base_reg, base_reg); } @@ -21767,9 +21767,9 @@ thumb2_emit_ldrd_pop (unsigned long saved_regs_mask) /* When saved-register index (i) is odd, RTXs for both the registers to be loaded are generated in above given LDRD pattern, and the pattern can be emitted now. */ - par = emit_insn (par); - REG_NOTES (par) = dwarf; - RTX_FRAME_RELATED_P (par) = 1; + rtx_insn *insn = emit_insn (par); + REG_NOTES (insn) = dwarf; + RTX_FRAME_RELATED_P (insn) = 1; } i++; @@ -21785,10 +21785,10 @@ thumb2_emit_ldrd_pop (unsigned long saved_regs_mask) tmp = gen_rtx_SET (stack_pointer_rtx, plus_constant (Pmode, stack_pointer_rtx, 4 * i)); RTX_FRAME_RELATED_P (tmp) = 1; - tmp = emit_insn (tmp); + rtx_insn *insn = emit_insn (tmp); if (!return_in_pc) { - arm_add_cfa_adjust_cfa_note (tmp, UNITS_PER_WORD * i, + arm_add_cfa_adjust_cfa_note (insn, UNITS_PER_WORD * i, stack_pointer_rtx, stack_pointer_rtx); } @@ -21823,9 +21823,9 @@ thumb2_emit_ldrd_pop (unsigned long saved_regs_mask) } else { - par = emit_insn (tmp); - REG_NOTES (par) = dwarf; - arm_add_cfa_adjust_cfa_note (par, UNITS_PER_WORD, + rtx_insn *insn = emit_insn (tmp); + REG_NOTES (insn) = dwarf; + arm_add_cfa_adjust_cfa_note (insn, UNITS_PER_WORD, stack_pointer_rtx, stack_pointer_rtx); } @@ -21882,8 +21882,8 @@ arm_emit_ldrd_pop (unsigned long saved_regs_mask) mem = gen_frame_mem (DImode, stack_pointer_rtx); tmp = gen_rtx_SET (gen_rtx_REG (DImode, j), mem); - tmp = emit_insn (tmp); - RTX_FRAME_RELATED_P (tmp) = 1; + rtx_insn *insn = emit_insn (tmp); + RTX_FRAME_RELATED_P (insn) = 1; /* Generate dwarf info. */ @@ -21894,7 +21894,7 @@ arm_emit_ldrd_pop (unsigned long saved_regs_mask) gen_rtx_REG (SImode, j + 1), dwarf); - REG_NOTES (tmp) = dwarf; + REG_NOTES (insn) = dwarf; offset += 8; j += 2; @@ -21911,11 +21911,11 @@ arm_emit_ldrd_pop (unsigned long saved_regs_mask) mem = gen_frame_mem (SImode, stack_pointer_rtx); tmp = gen_rtx_SET (gen_rtx_REG (SImode, j), mem); - tmp = emit_insn (tmp); - RTX_FRAME_RELATED_P (tmp) = 1; + rtx_insn *insn = emit_insn (tmp); + RTX_FRAME_RELATED_P (insn) = 1; /* Generate dwarf info. */ - REG_NOTES (tmp) = alloc_reg_note (REG_CFA_RESTORE, + REG_NOTES (insn) = alloc_reg_note (REG_CFA_RESTORE, gen_rtx_REG (SImode, j), NULL_RTX); @@ -21935,8 +21935,8 @@ arm_emit_ldrd_pop (unsigned long saved_regs_mask) plus_constant (Pmode, stack_pointer_rtx, offset)); - tmp = emit_insn (tmp); - arm_add_cfa_adjust_cfa_note (tmp, offset, + rtx_insn *insn = emit_insn (tmp); + arm_add_cfa_adjust_cfa_note (insn, offset, stack_pointer_rtx, stack_pointer_rtx); offset = 0; } @@ -21952,14 +21952,14 @@ arm_emit_ldrd_pop (unsigned long saved_regs_mask) stack_pointer_rtx))); RTX_FRAME_RELATED_P (tmp) = 1; XVECEXP (par, 0, 1) = tmp; - par = emit_jump_insn (par); + rtx_insn *insn = emit_jump_insn (par); /* Generate dwarf info. */ dwarf = alloc_reg_note (REG_CFA_RESTORE, gen_rtx_REG (SImode, PC_REGNUM), NULL_RTX); - REG_NOTES (par) = dwarf; - arm_add_cfa_adjust_cfa_note (par, UNITS_PER_WORD, + REG_NOTES (insn) = dwarf; + arm_add_cfa_adjust_cfa_note (insn, UNITS_PER_WORD, stack_pointer_rtx, stack_pointer_rtx); } } @@ -27127,12 +27127,13 @@ arm_expand_epilogue (bool really_return) } else { - insn = emit_insn (gen_movsi (gen_rtx_REG (SImode, i), - addr)); - REG_NOTES (insn) = alloc_reg_note (REG_CFA_RESTORE, + rtx_insn *move + = emit_insn (gen_movsi (gen_rtx_REG (SImode, i), + addr)); + REG_NOTES (move) = alloc_reg_note (REG_CFA_RESTORE, gen_rtx_REG (SImode, i), NULL_RTX); - arm_add_cfa_adjust_cfa_note (insn, UNITS_PER_WORD, + arm_add_cfa_adjust_cfa_note (move, UNITS_PER_WORD, stack_pointer_rtx, stack_pointer_rtx); } diff --git a/gcc/config/epiphany/epiphany.md b/gcc/config/epiphany/epiphany.md index 934c1949b93..2114827c439 100644 --- a/gcc/config/epiphany/epiphany.md +++ b/gcc/config/epiphany/epiphany.md @@ -2623,7 +2623,7 @@ gcc_assert (!reg_overlap_mentioned_p (operands[5], operands[4])); operands[9] = XVECEXP (operands[3], 0, XVECLEN (operands[3], 0) - 2); operands[10] = XVECEXP (operands[3], 0, XVECLEN (operands[3], 0) - 1); - rtx insn + rtx body = (gen_rtx_PARALLEL (VOIDmode, gen_rtvec @@ -2632,10 +2632,10 @@ gen_rtx_MULT (SImode, operands[6], operands[4])), gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CC_FPmode, CCFP_REGNUM)), operands[9], operands[10]))); - insn = emit_insn (insn); + rtx_insn *insn = emit_insn (body); add_reg_note (insn, REG_EQUAL, gen_rtx_ASHIFT (SImode, operands[6], operands[2])); - insn + body = (gen_rtx_PARALLEL (VOIDmode, gen_rtvec @@ -2644,7 +2644,7 @@ gen_rtx_MULT (SImode, operands[8], operands[4])), gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CC_FPmode, CCFP_REGNUM)), operands[9], operands[10]))); - insn = emit_insn (insn); + insn = emit_insn (body); add_reg_note (insn, REG_EQUAL, gen_rtx_ASHIFT (SImode, operands[7], operands[2])); DONE; diff --git a/gcc/config/msp430/msp430.cc b/gcc/config/msp430/msp430.cc index 343041257ed..bf9fdcba7c8 100644 --- a/gcc/config/msp430/msp430.cc +++ b/gcc/config/msp430/msp430.cc @@ -3321,8 +3321,8 @@ msp430_expand_helper (rtx *operands, const char *helper_name, c = gen_call_value_internal (gen_rtx_REG (arg0mode, 12), fsym, GEN_INT (0)); - c = emit_call_insn (c); - RTL_CONST_CALL_P (c) = 1; + rtx_insn *call = emit_call_insn (c); + RTL_CONST_CALL_P (call) = 1; /* Add register usage information for the arguments to the call. */ fusage = NULL; @@ -3336,7 +3336,7 @@ msp430_expand_helper (rtx *operands, const char *helper_name, else use_regs (&fusage, arg2, arg1sz); } - add_function_usage_to (c, fusage); + add_function_usage_to (call, fusage); emit_move_insn (operands[0], /* Return value will always start in R12. */ diff --git a/gcc/config/nds32/nds32.cc b/gcc/config/nds32/nds32.cc index 0aae1112507..1c84f21122e 100644 --- a/gcc/config/nds32/nds32.cc +++ b/gcc/config/nds32/nds32.cc @@ -733,7 +733,7 @@ nds32_emit_stack_push_multiple (unsigned Rb, unsigned Re, rtx mem; rtx push_rtx; rtx adjust_sp_rtx; - rtx parallel_insn; + rtx parallel_body; rtx dwarf; /* We need to provide a customized rtx which contains @@ -771,7 +771,7 @@ nds32_emit_stack_push_multiple (unsigned Rb, unsigned Re, /* In addition to used registers, we need one more space for (set sp sp-x) rtx. */ - parallel_insn = gen_rtx_PARALLEL (VOIDmode, + parallel_body = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (num_use_regs + 1)); par_index = 0; @@ -791,7 +791,7 @@ nds32_emit_stack_push_multiple (unsigned Rb, unsigned Re, stack_pointer_rtx, offset)); push_rtx = gen_rtx_SET (mem, reg); - XVECEXP (parallel_insn, 0, par_index) = push_rtx; + XVECEXP (parallel_body, 0, par_index) = push_rtx; RTX_FRAME_RELATED_P (push_rtx) = 1; offset = offset + 4; par_index++; @@ -805,7 +805,7 @@ nds32_emit_stack_push_multiple (unsigned Rb, unsigned Re, stack_pointer_rtx, offset)); push_rtx = gen_rtx_SET (mem, reg); - XVECEXP (parallel_insn, 0, par_index) = push_rtx; + XVECEXP (parallel_body, 0, par_index) = push_rtx; RTX_FRAME_RELATED_P (push_rtx) = 1; offset = offset + 4; par_index++; @@ -817,7 +817,7 @@ nds32_emit_stack_push_multiple (unsigned Rb, unsigned Re, stack_pointer_rtx, offset)); push_rtx = gen_rtx_SET (mem, reg); - XVECEXP (parallel_insn, 0, par_index) = push_rtx; + XVECEXP (parallel_body, 0, par_index) = push_rtx; RTX_FRAME_RELATED_P (push_rtx) = 1; offset = offset + 4; par_index++; @@ -829,7 +829,7 @@ nds32_emit_stack_push_multiple (unsigned Rb, unsigned Re, stack_pointer_rtx, offset)); push_rtx = gen_rtx_SET (mem, reg); - XVECEXP (parallel_insn, 0, par_index) = push_rtx; + XVECEXP (parallel_body, 0, par_index) = push_rtx; RTX_FRAME_RELATED_P (push_rtx) = 1; offset = offset + 4; par_index++; @@ -842,10 +842,10 @@ nds32_emit_stack_push_multiple (unsigned Rb, unsigned Re, adjust_sp_rtx = gen_rtx_SET (stack_pointer_rtx, plus_constant (Pmode, stack_pointer_rtx, offset)); - XVECEXP (parallel_insn, 0, par_index) = adjust_sp_rtx; + XVECEXP (parallel_body, 0, par_index) = adjust_sp_rtx; RTX_FRAME_RELATED_P (adjust_sp_rtx) = 1; - parallel_insn = emit_insn (parallel_insn); + rtx_insn *parallel_insn = emit_insn (parallel_body); /* The insn rtx 'parallel_insn' will change frame layout. We need to use RTX_FRAME_RELATED_P so that GCC is able to @@ -881,7 +881,7 @@ nds32_emit_stack_pop_multiple (unsigned Rb, unsigned Re, rtx mem; rtx pop_rtx; rtx adjust_sp_rtx; - rtx parallel_insn; + rtx parallel_body; rtx dwarf = NULL_RTX; /* We need to provide a customized rtx which contains @@ -919,7 +919,7 @@ nds32_emit_stack_pop_multiple (unsigned Rb, unsigned Re, /* In addition to used registers, we need one more space for (set sp sp+x) rtx. */ - parallel_insn = gen_rtx_PARALLEL (VOIDmode, + parallel_body = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (num_use_regs + 1)); par_index = 0; @@ -939,7 +939,7 @@ nds32_emit_stack_pop_multiple (unsigned Rb, unsigned Re, stack_pointer_rtx, offset)); pop_rtx = gen_rtx_SET (reg, mem); - XVECEXP (parallel_insn, 0, par_index) = pop_rtx; + XVECEXP (parallel_body, 0, par_index) = pop_rtx; RTX_FRAME_RELATED_P (pop_rtx) = 1; offset = offset + 4; par_index++; @@ -955,7 +955,7 @@ nds32_emit_stack_pop_multiple (unsigned Rb, unsigned Re, stack_pointer_rtx, offset)); pop_rtx = gen_rtx_SET (reg, mem); - XVECEXP (parallel_insn, 0, par_index) = pop_rtx; + XVECEXP (parallel_body, 0, par_index) = pop_rtx; RTX_FRAME_RELATED_P (pop_rtx) = 1; offset = offset + 4; par_index++; @@ -969,7 +969,7 @@ nds32_emit_stack_pop_multiple (unsigned Rb, unsigned Re, stack_pointer_rtx, offset)); pop_rtx = gen_rtx_SET (reg, mem); - XVECEXP (parallel_insn, 0, par_index) = pop_rtx; + XVECEXP (parallel_body, 0, par_index) = pop_rtx; RTX_FRAME_RELATED_P (pop_rtx) = 1; offset = offset + 4; par_index++; @@ -983,7 +983,7 @@ nds32_emit_stack_pop_multiple (unsigned Rb, unsigned Re, stack_pointer_rtx, offset)); pop_rtx = gen_rtx_SET (reg, mem); - XVECEXP (parallel_insn, 0, par_index) = pop_rtx; + XVECEXP (parallel_body, 0, par_index) = pop_rtx; RTX_FRAME_RELATED_P (pop_rtx) = 1; offset = offset + 4; par_index++; @@ -997,12 +997,12 @@ nds32_emit_stack_pop_multiple (unsigned Rb, unsigned Re, adjust_sp_rtx = gen_rtx_SET (stack_pointer_rtx, plus_constant (Pmode, stack_pointer_rtx, offset)); - XVECEXP (parallel_insn, 0, par_index) = adjust_sp_rtx; + XVECEXP (parallel_body, 0, par_index) = adjust_sp_rtx; /* Tell gcc we adjust SP in this insn. */ dwarf = alloc_reg_note (REG_CFA_ADJUST_CFA, copy_rtx (adjust_sp_rtx), dwarf); - parallel_insn = emit_insn (parallel_insn); + rtx_insn *parallel_insn = emit_insn (parallel_body); /* The insn rtx 'parallel_insn' will change frame layout. We need to use RTX_FRAME_RELATED_P so that GCC is able to @@ -1032,7 +1032,7 @@ nds32_emit_stack_v3push (unsigned Rb, rtx mem; rtx push_rtx; rtx adjust_sp_rtx; - rtx parallel_insn; + rtx parallel_body; /* We need to provide a customized rtx which contains necessary information for data analysis, @@ -1062,7 +1062,7 @@ nds32_emit_stack_v3push (unsigned Rb, /* In addition to used registers, we need one more space for (set sp sp-x-imm8u) rtx. */ - parallel_insn = gen_rtx_PARALLEL (VOIDmode, + parallel_body = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (num_use_regs + 1)); par_index = 0; @@ -1079,7 +1079,7 @@ nds32_emit_stack_v3push (unsigned Rb, stack_pointer_rtx, offset)); push_rtx = gen_rtx_SET (mem, reg); - XVECEXP (parallel_insn, 0, par_index) = push_rtx; + XVECEXP (parallel_body, 0, par_index) = push_rtx; RTX_FRAME_RELATED_P (push_rtx) = 1; offset = offset + 4; par_index++; @@ -1091,7 +1091,7 @@ nds32_emit_stack_v3push (unsigned Rb, stack_pointer_rtx, offset)); push_rtx = gen_rtx_SET (mem, reg); - XVECEXP (parallel_insn, 0, par_index) = push_rtx; + XVECEXP (parallel_body, 0, par_index) = push_rtx; RTX_FRAME_RELATED_P (push_rtx) = 1; offset = offset + 4; par_index++; @@ -1101,7 +1101,7 @@ nds32_emit_stack_v3push (unsigned Rb, stack_pointer_rtx, offset)); push_rtx = gen_rtx_SET (mem, reg); - XVECEXP (parallel_insn, 0, par_index) = push_rtx; + XVECEXP (parallel_body, 0, par_index) = push_rtx; RTX_FRAME_RELATED_P (push_rtx) = 1; offset = offset + 4; par_index++; @@ -1111,7 +1111,7 @@ nds32_emit_stack_v3push (unsigned Rb, stack_pointer_rtx, offset)); push_rtx = gen_rtx_SET (mem, reg); - XVECEXP (parallel_insn, 0, par_index) = push_rtx; + XVECEXP (parallel_body, 0, par_index) = push_rtx; RTX_FRAME_RELATED_P (push_rtx) = 1; offset = offset + 4; par_index++; @@ -1125,10 +1125,10 @@ nds32_emit_stack_v3push (unsigned Rb, plus_constant (Pmode, stack_pointer_rtx, offset - imm8u)); - XVECEXP (parallel_insn, 0, par_index) = adjust_sp_rtx; + XVECEXP (parallel_body, 0, par_index) = adjust_sp_rtx; RTX_FRAME_RELATED_P (adjust_sp_rtx) = 1; - parallel_insn = emit_insn (parallel_insn); + rtx_insn *parallel_insn = emit_insn (parallel_body); /* The insn rtx 'parallel_insn' will change frame layout. We need to use RTX_FRAME_RELATED_P so that GCC is able to @@ -1155,7 +1155,7 @@ nds32_emit_stack_v3pop (unsigned Rb, rtx mem; rtx pop_rtx; rtx adjust_sp_rtx; - rtx parallel_insn; + rtx parallel_body; rtx dwarf = NULL_RTX; /* We need to provide a customized rtx which contains @@ -1186,7 +1186,7 @@ nds32_emit_stack_v3pop (unsigned Rb, /* In addition to used registers, we need one more space for (set sp sp+x+imm8u) rtx. */ - parallel_insn = gen_rtx_PARALLEL (VOIDmode, + parallel_body = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (num_use_regs + 1)); par_index = 0; @@ -1203,7 +1203,7 @@ nds32_emit_stack_v3pop (unsigned Rb, stack_pointer_rtx, offset)); pop_rtx = gen_rtx_SET (reg, mem); - XVECEXP (parallel_insn, 0, par_index) = pop_rtx; + XVECEXP (parallel_body, 0, par_index) = pop_rtx; RTX_FRAME_RELATED_P (pop_rtx) = 1; offset = offset + 4; par_index++; @@ -1217,7 +1217,7 @@ nds32_emit_stack_v3pop (unsigned Rb, stack_pointer_rtx, offset)); pop_rtx = gen_rtx_SET (reg, mem); - XVECEXP (parallel_insn, 0, par_index) = pop_rtx; + XVECEXP (parallel_body, 0, par_index) = pop_rtx; RTX_FRAME_RELATED_P (pop_rtx) = 1; offset = offset + 4; par_index++; @@ -1229,7 +1229,7 @@ nds32_emit_stack_v3pop (unsigned Rb, stack_pointer_rtx, offset)); pop_rtx = gen_rtx_SET (reg, mem); - XVECEXP (parallel_insn, 0, par_index) = pop_rtx; + XVECEXP (parallel_body, 0, par_index) = pop_rtx; RTX_FRAME_RELATED_P (pop_rtx) = 1; offset = offset + 4; par_index++; @@ -1241,7 +1241,7 @@ nds32_emit_stack_v3pop (unsigned Rb, stack_pointer_rtx, offset)); pop_rtx = gen_rtx_SET (reg, mem); - XVECEXP (parallel_insn, 0, par_index) = pop_rtx; + XVECEXP (parallel_body, 0, par_index) = pop_rtx; RTX_FRAME_RELATED_P (pop_rtx) = 1; offset = offset + 4; par_index++; @@ -1255,7 +1255,7 @@ nds32_emit_stack_v3pop (unsigned Rb, plus_constant (Pmode, stack_pointer_rtx, offset + imm8u)); - XVECEXP (parallel_insn, 0, par_index) = adjust_sp_rtx; + XVECEXP (parallel_body, 0, par_index) = adjust_sp_rtx; if (frame_pointer_needed) { @@ -1273,7 +1273,7 @@ nds32_emit_stack_v3pop (unsigned Rb, copy_rtx (adjust_sp_rtx), dwarf); } - parallel_insn = emit_insn (parallel_insn); + rtx_insn *parallel_insn = emit_insn (parallel_body); /* The insn rtx 'parallel_insn' will change frame layout. We need to use RTX_FRAME_RELATED_P so that GCC is able to @@ -1324,7 +1324,7 @@ static void nds32_emit_adjust_frame (rtx to_reg, rtx from_reg, int adjust_value) { rtx tmp_reg; - rtx frame_adjust_insn; + rtx_insn *frame_adjust_insn; rtx adjust_value_rtx = GEN_INT (adjust_value); if (adjust_value == 0) @@ -1344,11 +1344,11 @@ nds32_emit_adjust_frame (rtx to_reg, rtx from_reg, int adjust_value) emit_move_insn (tmp_reg, adjust_value_rtx); /* Create new 'add' rtx. */ - frame_adjust_insn = gen_addsi3 (to_reg, - from_reg, - tmp_reg); + rtx adj_pat = gen_addsi3 (to_reg, + from_reg, + tmp_reg); /* Emit rtx into insn list and receive its transformed insn rtx. */ - frame_adjust_insn = emit_insn (frame_adjust_insn); + frame_adjust_insn = emit_insn (adj_pat); /* Because (tmp_reg <- full_value) may be split into two rtl patterns, we cannot set its RTX_FRAME_RELATED_P. @@ -1367,11 +1367,11 @@ nds32_emit_adjust_frame (rtx to_reg, rtx from_reg, int adjust_value) else { /* Generate sp adjustment instruction if and only if sp_adjust != 0. */ - frame_adjust_insn = gen_addsi3 (to_reg, - from_reg, - adjust_value_rtx); + rtx adj_pat = gen_addsi3 (to_reg, + from_reg, + adjust_value_rtx); /* Emit rtx into instructions list and receive INSN rtx form. */ - frame_adjust_insn = emit_insn (frame_adjust_insn); + frame_adjust_insn = emit_insn (adj_pat); } /* The insn rtx 'sp_adjust_insn' will change frame layout. diff --git a/gcc/config/sh/sh.cc b/gcc/config/sh/sh.cc index d26385f716f..5487e05339a 100644 --- a/gcc/config/sh/sh.cc +++ b/gcc/config/sh/sh.cc @@ -6887,19 +6887,19 @@ pop (int rn) else x = gen_pop (gen_rtx_REG (SImode, rn)); - x = emit_insn (x); + rtx_insn *insn = emit_insn (x); sp_reg = gen_rtx_REG (SImode, STACK_POINTER_REGNUM); - reg = copy_rtx (GET_CODE (PATTERN (x)) == PARALLEL - ? SET_DEST (XVECEXP (PATTERN (x), 0, 0)) - : SET_DEST (PATTERN (x))); - add_reg_note (x, REG_CFA_RESTORE, reg); - add_reg_note (x, REG_CFA_ADJUST_CFA, + reg = copy_rtx (GET_CODE (PATTERN (insn)) == PARALLEL + ? SET_DEST (XVECEXP (PATTERN (insn), 0, 0)) + : SET_DEST (PATTERN (insn))); + add_reg_note (insn, REG_CFA_RESTORE, reg); + add_reg_note (insn, REG_CFA_ADJUST_CFA, gen_rtx_SET (sp_reg, plus_constant (SImode, sp_reg, GET_MODE_SIZE (GET_MODE (reg))))); - add_reg_note (x, REG_INC, gen_rtx_REG (SImode, STACK_POINTER_REGNUM)); - RTX_FRAME_RELATED_P (x) = 1; + add_reg_note (insn, REG_INC, gen_rtx_REG (SImode, STACK_POINTER_REGNUM)); + RTX_FRAME_RELATED_P (insn) = 1; } /* Generate code to push the regs specified in the mask. */ @@ -6970,16 +6970,16 @@ push_regs (HARD_REG_SET *mask, bool interrupt_handler) insns. */ emit_insn (gen_blockage ()); x = gen_movml_push_banked (sp_reg); - x = emit_frame_insn (x); + rtx_insn *insn = emit_frame_insn (x); for (int i = FIRST_BANKED_REG; i <= LAST_BANKED_REG; i++) { mem = gen_rtx_MEM (SImode, plus_constant (Pmode, sp_reg, i * 4)); reg = gen_rtx_REG (SImode, i); - add_reg_note (x, REG_CFA_OFFSET, gen_rtx_SET (mem, reg)); + add_reg_note (insn, REG_CFA_OFFSET, gen_rtx_SET (mem, reg)); } set = gen_rtx_SET (sp_reg, plus_constant (Pmode, sp_reg, - 32)); - add_reg_note (x, REG_CFA_ADJUST_CFA, set); + add_reg_note (insn, REG_CFA_ADJUST_CFA, set); emit_insn (gen_blockage ()); } else -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:55 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:55 -0500 Subject: [PATCH 14/25] Use rtx_insn * for locals that only hold an insn In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-15-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * config/arm/arm.cc (arm_emit_strd_push, get_scratch_register_on_entry, release_scratch_register_on_entry): Use an rtx_insn * for a local that only holds an insn. * config/i386/i386.cc (ix86_adjust_stack_and_probe): Likewise. * config/rs6000/rs6000-logue.cc (rs6000_emit_epilogue): Likewise. * config/sh/sh.cc (output_stack_adjust): Likewise. * config/sh/sh.md (define_split): Likewise. --- gcc/config/arm/arm.cc | 6 +++--- gcc/config/i386/i386.cc | 2 +- gcc/config/rs6000/rs6000-logue.cc | 4 ++-- gcc/config/sh/sh.cc | 2 +- gcc/config/sh/sh.md | 24 ++++++++++++++---------- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 2b3ab29a10e..724c5fe3153 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -21201,7 +21201,7 @@ arm_emit_strd_push (unsigned long saved_regs_mask) int i, j, dwarf_index = 0; int offset = 0; rtx dwarf = NULL_RTX; - rtx insn = NULL_RTX; + rtx_insn *insn = nullptr; rtx tmp, mem; /* TODO: A more efficient code can be emitted by changing the @@ -22459,7 +22459,7 @@ get_scratch_register_on_entry (struct scratch_reg *sr, unsigned int regno1, if (sr->saved) { rtx addr = gen_rtx_PRE_DEC (Pmode, stack_pointer_rtx); - rtx insn = emit_set_insn (gen_frame_mem (SImode, addr), sr->reg); + rtx_insn *insn = emit_set_insn (gen_frame_mem (SImode, addr), sr->reg); rtx x = gen_rtx_SET (stack_pointer_rtx, plus_constant (Pmode, stack_pointer_rtx, -4)); RTX_FRAME_RELATED_P (insn) = 1; @@ -22475,7 +22475,7 @@ release_scratch_register_on_entry (struct scratch_reg *sr) if (sr->saved) { rtx addr = gen_rtx_POST_INC (Pmode, stack_pointer_rtx); - rtx insn = emit_set_insn (sr->reg, gen_frame_mem (SImode, addr)); + rtx_insn *insn = emit_set_insn (sr->reg, gen_frame_mem (SImode, addr)); rtx x = gen_rtx_SET (stack_pointer_rtx, plus_constant (Pmode, stack_pointer_rtx, 4)); RTX_FRAME_RELATED_P (insn) = 1; diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 58534bcd8a7..9b5c792699e 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -8365,7 +8365,7 @@ ix86_adjust_stack_and_probe (HOST_WIDE_INT size, for (i = probe_interval; i <= size; i += probe_interval) { /* Allocate PROBE_INTERVAL bytes. */ - rtx insn + rtx_insn *insn = pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx, GEN_INT (-probe_interval), -1, m->fs.cfa_reg == stack_pointer_rtx); diff --git a/gcc/config/rs6000/rs6000-logue.cc b/gcc/config/rs6000/rs6000-logue.cc index d617416652b..100c462a40b 100644 --- a/gcc/config/rs6000/rs6000-logue.cc +++ b/gcc/config/rs6000/rs6000-logue.cc @@ -4299,7 +4299,7 @@ rs6000_emit_epilogue (enum epilogue_type epilogue_type) rtx sp_reg_rtx = gen_rtx_REG (Pmode, 1); rtx frame_reg_rtx = sp_reg_rtx; rtx cfa_restores = NULL_RTX; - rtx insn; + rtx_insn *insn; rtx cr_save_reg = NULL_RTX; machine_mode reg_mode = Pmode; int reg_size = TARGET_32BIT ? 4 : 8; @@ -4577,7 +4577,7 @@ rs6000_emit_epilogue (enum epilogue_type epilogue_type) emit_insn (generate_set_vrsave (reg, info, 1)); } - insn = NULL_RTX; + insn = nullptr; /* If we have a large stack frame, restore the old stack pointer using the backchain. */ if (use_backchain_to_restore_sp) diff --git a/gcc/config/sh/sh.cc b/gcc/config/sh/sh.cc index 5487e05339a..3eb5900d791 100644 --- a/gcc/config/sh/sh.cc +++ b/gcc/config/sh/sh.cc @@ -6706,7 +6706,7 @@ output_stack_adjust (int size, rtx reg, int epilogue_p, else { rtx const_reg; - rtx insn; + rtx_insn *insn; int temp = epilogue_p ? 7 : 1; int i; diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index 5acca403608..61db40f2a3a 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -5719,10 +5719,10 @@ && (true_regnum (operands[0]) < 16) != (true_regnum (operands[1]) < 16)" [(const_int 0)] { - rtx insn, tos; + rtx tos; tos = gen_tmp_stack_mem (DFmode, gen_rtx_PRE_DEC (Pmode, stack_pointer_rtx)); - insn = emit_insn (gen_movdf_i4 (tos, operands[1])); + rtx_insn *insn = emit_insn (gen_movdf_i4 (tos, operands[1])); add_reg_note (insn, REG_INC, stack_pointer_rtx); tos = gen_tmp_stack_mem (DFmode, gen_rtx_POST_INC (Pmode, stack_pointer_rtx)); insn = emit_insn (gen_movdf_i4 (operands[0], tos)); @@ -5880,13 +5880,13 @@ [(const_int 0)] { int regno = true_regnum (operands[0]); - rtx insn; rtx mem = SET_SRC (XVECEXP (PATTERN (curr_insn), 0, 0)); rtx mem2 = change_address (mem, SFmode, gen_rtx_POST_INC (Pmode, operands[1])); - insn = emit_insn (gen_movsf_ie (gen_rtx_REG (SFmode, - regno + SH_REG_MSW_OFFSET), - mem2)); + rtx_insn *insn + = emit_insn (gen_movsf_ie (gen_rtx_REG (SFmode, + regno + SH_REG_MSW_OFFSET), + mem2)); add_reg_note (insn, REG_INC, operands[1]); insn = emit_insn (gen_movsf_ie (gen_rtx_REG (SFmode, regno + SH_REG_LSW_OFFSET), @@ -5904,7 +5904,8 @@ [(const_int 0)] { int regno = true_regnum (operands[0]); - rtx addr, insn; + rtx addr; + rtx_insn *insn; rtx mem2 = change_address (operands[1], SFmode, NULL_RTX); rtx reg0 = gen_rtx_REG (SFmode, regno + SH_REG_MSW_OFFSET); rtx reg1 = gen_rtx_REG (SFmode, regno + SH_REG_LSW_OFFSET); @@ -5971,7 +5972,8 @@ [(const_int 0)] { int regno = true_regnum (operands[1]); - rtx insn, addr; + rtx_insn *insn; + rtx addr; rtx reg0 = gen_rtx_REG (SFmode, regno + SH_REG_MSW_OFFSET); rtx reg1 = gen_rtx_REG (SFmode, regno + SH_REG_LSW_OFFSET); @@ -6503,7 +6505,8 @@ [(const_int 0)] { int regno = true_regnum (operands[0]); - rtx addr, insn; + rtx addr; + rtx_insn *insn; rtx mem2 = change_address (operands[1], SFmode, NULL_RTX); rtx reg0 = gen_rtx_REG (SFmode, regno + SH_REG_MSW_OFFSET); rtx reg1 = gen_rtx_REG (SFmode, regno + SH_REG_LSW_OFFSET); @@ -6567,7 +6570,8 @@ [(const_int 0)] { int regno = true_regnum (operands[1]); - rtx insn, addr; + rtx_insn *insn; + rtx addr; rtx reg0 = gen_rtx_REG (SFmode, regno + SH_REG_MSW_OFFSET); rtx reg1 = gen_rtx_REG (SFmode, regno + SH_REG_LSW_OFFSET); -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:56 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:56 -0500 Subject: [PATCH 15/25] Hold emitted insns in rtx_insn * locals In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-16-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * config/arc/arc.cc (arc_save_callee_enter, arc_save_callee_milli): Hold the emitted insn in an rtx_insn *. * config/arm/arm.cc (arm_emit_multi_reg_pop): Likewise. * config/msp430/msp430.cc (F, msp430_expand_prologue, msp430_expand_epilogue): Likewise. * config/riscv/riscv.cc (riscv_v_adjust_scalable_frame, riscv_allocate_and_probe_stack_space): Likewise. * config/rl78/rl78.cc (F, rl78_expand_prologue): Likewise. * config/s390/s390.cc (s390_emit_epilogue): Likewise. * config/sh/sh_treg_combine.cc (try_combine_comparisons): Likewise. --- gcc/config/arc/arc.cc | 40 ++++++++++++++++---------------- gcc/config/arm/arm.cc | 8 +++---- gcc/config/msp430/msp430.cc | 11 +++++++-- gcc/config/riscv/riscv.cc | 13 +++++++---- gcc/config/rl78/rl78.cc | 8 +++---- gcc/config/s390/s390.cc | 19 ++++++++------- gcc/config/sh/sh_treg_combine.cc | 18 +++++++------- 7 files changed, 64 insertions(+), 53 deletions(-) diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc index 675c61e2826..d735024dff7 100644 --- a/gcc/config/arc/arc.cc +++ b/gcc/config/arc/arc.cc @@ -3270,7 +3270,7 @@ arc_save_callee_enter (uint64_t gmask, int start_reg = ENTER_LEAVE_START_REG; int end_reg = ENTER_LEAVE_END_REG; int regno, indx, off, nregs; - rtx insn, reg, mem; + rtx reg, mem; int frame_allocated = 0; for (regno = start_reg; regno <= end_reg && (gmask & (1ULL << regno));) @@ -3284,8 +3284,8 @@ arc_save_callee_enter (uint64_t gmask, if (offset) frame_stack_add (offset); - insn = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs + (save_fp ? 1 : 0) - + 1)); + rtx body = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs + (save_fp ? 1 : 0) + + 1)); indx = 0; reg = gen_rtx_SET (stack_pointer_rtx, @@ -3293,7 +3293,7 @@ arc_save_callee_enter (uint64_t gmask, stack_pointer_rtx, -nregs * UNITS_PER_WORD)); RTX_FRAME_RELATED_P (reg) = 1; - XVECEXP (insn, 0, indx++) = reg; + XVECEXP (body, 0, indx++) = reg; off = nregs * UNITS_PER_WORD; if (save_blink) @@ -3302,8 +3302,8 @@ arc_save_callee_enter (uint64_t gmask, mem = gen_frame_mem (Pmode, plus_constant (Pmode, stack_pointer_rtx, -off)); - XVECEXP (insn, 0, indx) = gen_rtx_SET (mem, reg); - RTX_FRAME_RELATED_P (XVECEXP (insn, 0, indx++)) = 1; + XVECEXP (body, 0, indx) = gen_rtx_SET (mem, reg); + RTX_FRAME_RELATED_P (XVECEXP (body, 0, indx++)) = 1; off -= UNITS_PER_WORD; save_blink = false; } @@ -3316,8 +3316,8 @@ arc_save_callee_enter (uint64_t gmask, mem = gen_frame_mem (SImode, plus_constant (Pmode, stack_pointer_rtx, -off)); - XVECEXP (insn, 0, indx) = gen_rtx_SET (mem, reg); - RTX_FRAME_RELATED_P (XVECEXP (insn, 0, indx)) = 1; + XVECEXP (body, 0, indx) = gen_rtx_SET (mem, reg); + RTX_FRAME_RELATED_P (XVECEXP (body, 0, indx)) = 1; gmask = gmask & ~(1ULL << regno); } @@ -3326,18 +3326,18 @@ arc_save_callee_enter (uint64_t gmask, mem = gen_frame_mem (Pmode, plus_constant (Pmode, stack_pointer_rtx, -off)); - XVECEXP (insn, 0, indx) = gen_rtx_SET (mem, hard_frame_pointer_rtx); - RTX_FRAME_RELATED_P (XVECEXP (insn, 0, indx++)) = 1; + XVECEXP (body, 0, indx) = gen_rtx_SET (mem, hard_frame_pointer_rtx); + RTX_FRAME_RELATED_P (XVECEXP (body, 0, indx++)) = 1; off -= UNITS_PER_WORD; - XVECEXP (insn, 0, indx) = gen_rtx_SET (hard_frame_pointer_rtx, + XVECEXP (body, 0, indx) = gen_rtx_SET (hard_frame_pointer_rtx, stack_pointer_rtx); - RTX_FRAME_RELATED_P (XVECEXP (insn, 0, indx++)) = 1; + RTX_FRAME_RELATED_P (XVECEXP (body, 0, indx++)) = 1; save_fp = false; } gcc_assert (off == 0); - insn = frame_insn (insn); + rtx_insn *insn = frame_insn (body); add_reg_note (insn, REG_INC, stack_pointer_rtx); @@ -3499,7 +3499,7 @@ arc_save_callee_milli (uint64_t gmask, int start_reg = 13; int end_reg = 25; int regno, indx, off, nregs; - rtx insn, reg, mem; + rtx body, reg, mem; int frame_allocated = 0; for (regno = start_reg; regno <= end_reg && (gmask & (1ULL << regno));) @@ -3528,12 +3528,12 @@ arc_save_callee_milli (uint64_t gmask, } /* Start generate millicode call. */ - insn = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs + 1)); + body = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (nregs + 1)); indx = 0; /* This is a call, we clobber blink. */ - XVECEXP (insn, 0, nregs) = - gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM)); + XVECEXP (body, 0, nregs) + = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM)); for (regno = start_reg, indx = 0, off = 0; regno <= end_reg; @@ -3543,11 +3543,11 @@ arc_save_callee_milli (uint64_t gmask, mem = gen_frame_mem (SImode, plus_constant (Pmode, stack_pointer_rtx, off)); - XVECEXP (insn, 0, indx) = gen_rtx_SET (mem, reg); - RTX_FRAME_RELATED_P (XVECEXP (insn, 0, indx)) = 1; + XVECEXP (body, 0, indx) = gen_rtx_SET (mem, reg); + RTX_FRAME_RELATED_P (XVECEXP (body, 0, indx)) = 1; gmask = gmask & ~(1ULL << regno); } - insn = frame_insn (insn); + rtx_insn *insn = frame_insn (body); /* Add DWARF info. */ for (regno = start_reg, off = 0; diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 724c5fe3153..ffdd9465025 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -21557,10 +21557,10 @@ arm_emit_multi_reg_pop (unsigned long saved_regs_mask) tmp = gen_frame_mem (SImode, gen_rtx_POST_INC (Pmode, stack_pointer_rtx)); - tmp = emit_insn (gen_rtx_SET (reg, tmp)); - REG_NOTES (tmp) = alloc_reg_note (REG_CFA_RESTORE, dwarf_reg, - dwarf); - arm_add_cfa_adjust_cfa_note (tmp, UNITS_PER_WORD, + rtx_insn *insn = emit_insn (gen_rtx_SET (reg, tmp)); + REG_NOTES (insn) = alloc_reg_note (REG_CFA_RESTORE, dwarf_reg, + dwarf); + arm_add_cfa_adjust_cfa_note (insn, UNITS_PER_WORD, stack_pointer_rtx, stack_pointer_rtx); return; } diff --git a/gcc/config/msp430/msp430.cc b/gcc/config/msp430/msp430.cc index bf9fdcba7c8..a46a4a96f3d 100644 --- a/gcc/config/msp430/msp430.cc +++ b/gcc/config/msp430/msp430.cc @@ -1707,6 +1707,13 @@ msp430_insn_cost (rtx_insn *insn, bool speed ATTRIBUTE_UNUSED) /* We use this to wrap all emitted insns in the prologue, so they get the "frame-related" (/f) flag set. */ +static rtx_insn * +F (rtx_insn *x) +{ + RTX_FRAME_RELATED_P (x) = 1; + return x; +} + static rtx F (rtx x) { @@ -2886,7 +2893,7 @@ msp430_expand_prologue (void) that there is a single rtx representing the stack pointer, namely stack_pointer_rtx, and uses == to recognize it. */ rtx sp = stack_pointer_rtx; - rtx p; + rtx_insn *p; if (is_naked_func ()) { @@ -3007,7 +3014,7 @@ msp430_expand_epilogue (int is_eh) int i, j; int fs; rtx sp = stack_pointer_rtx; - rtx p; + rtx_insn *p; int helper_n = 0; if (is_naked_func ()) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 59c2a99fe9d..698881148ec 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -10271,7 +10271,8 @@ riscv_v_adjust_scalable_frame (rtx target, poly_int64 offset, bool epilogue) { rtx tmp = RISCV_PROLOGUE_TEMP (Pmode); rtx adjust_size = RISCV_PROLOGUE_TEMP2 (Pmode); - rtx insn, dwarf, adjust_frame_rtx; + rtx dwarf, adjust_frame_rtx; + rtx_insn *insn; riscv_legitimize_poly_move (Pmode, adjust_size, tmp, gen_int_mode (offset, Pmode)); @@ -10332,12 +10333,13 @@ riscv_v_adjust_scalable_frame (rtx target, poly_int64 offset, bool epilogue) return; } + rtx pat; if (epilogue) - insn = gen_add3_insn (target, target, adjust_size); + pat = gen_add3_insn (target, target, adjust_size); else - insn = gen_sub3_insn (target, target, adjust_size); + pat = gen_sub3_insn (target, target, adjust_size); - insn = emit_insn (insn); + insn = emit_insn (pat); RTX_FRAME_RELATED_P (insn) = 1; @@ -10481,7 +10483,8 @@ riscv_allocate_and_probe_stack_space (rtx temp1, HOST_WIDE_INT size) /* Compute the ending address. */ rtx temp2 = gen_rtx_REG (Pmode, RISCV_PROLOGUE_TEMP2_REGNUM); temp2 = riscv_force_temporary (temp2, gen_int_mode (rounded_size, Pmode)); - insn = emit_insn (gen_sub3_insn (temp2, stack_pointer_rtx, temp2)); + rtx_insn *insn + = emit_insn (gen_sub3_insn (temp2, stack_pointer_rtx, temp2)); /* The size does not represent actual stack pointer address shift from the top of the frame, as it might be lowered before. diff --git a/gcc/config/rl78/rl78.cc b/gcc/config/rl78/rl78.cc index 193a5fa080b..dffb06095d2 100644 --- a/gcc/config/rl78/rl78.cc +++ b/gcc/config/rl78/rl78.cc @@ -746,8 +746,8 @@ need_to_save (unsigned int regno) } /* We use this to wrap all emitted insns in the prologue. */ -static rtx -F (rtx x) +static rtx_insn * +F (rtx_insn *x) { RTX_FRAME_RELATED_P (x) = 1; return x; @@ -1474,11 +1474,9 @@ rl78_expand_prologue (void) smaller to move SP into AX and perform the subtraction there. */ if (fs > 254 * 3) { - rtx insn; - emit_move_insn (ax, sp); emit_insn (gen_subhi3 (ax, ax, GEN_INT (fs))); - insn = F (emit_move_insn (sp, ax)); + rtx_insn *insn = F (emit_move_insn (sp, ax)); add_reg_note (insn, REG_FRAME_RELATED_EXPR, gen_rtx_SET (sp, gen_rtx_PLUS (HImode, sp, GEN_INT (-fs)))); diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index bd85fe83953..870df09816f 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -12727,7 +12727,8 @@ s390_emit_epilogue (bool sibcall) if (cfun_frame_layout.first_restore_gpr != -1) { - rtx insn, addr; + rtx addr; + rtx_insn *insn; int i; /* Check for global register and save them @@ -12794,14 +12795,14 @@ s390_emit_epilogue (bool sibcall) cfun_frame_layout.save_return_addr_p = true; } - insn = restore_gprs (frame_pointer, - offset + cfun_frame_layout.gprs_offset - + (cfun_frame_layout.first_restore_gpr - - cfun_frame_layout.first_save_gpr_slot) - * UNITS_PER_WORD, - cfun_frame_layout.first_restore_gpr, - cfun_frame_layout.last_restore_gpr); - insn = emit_insn (insn); + rtx pat = restore_gprs (frame_pointer, + offset + cfun_frame_layout.gprs_offset + + (cfun_frame_layout.first_restore_gpr + - cfun_frame_layout.first_save_gpr_slot) + * UNITS_PER_WORD, + cfun_frame_layout.first_restore_gpr, + cfun_frame_layout.last_restore_gpr); + insn = emit_insn (pat); REG_NOTES (insn) = cfa_restores; add_reg_note (insn, REG_CFA_DEF_CFA, plus_constant (Pmode, stack_pointer_rtx, diff --git a/gcc/config/sh/sh_treg_combine.cc b/gcc/config/sh/sh_treg_combine.cc index ea5b92c263a..13efadcc1bb 100644 --- a/gcc/config/sh/sh_treg_combine.cc +++ b/gcc/config/sh/sh_treg_combine.cc @@ -1186,8 +1186,9 @@ sh_treg_combine::try_combine_comparisons (cbranch_trace& trace, log_rtx (common_comp_pat); log_msg ("\n"); - rtx common_comp_insn = touched_insn (emit_insn_after (common_comp_pat, - trace.setcc.insn)); + rtx_insn *common_comp_insn + = emit_insn_after (common_comp_pat, trace.setcc.insn); + touched_insn (common_comp_insn); if (REG_P (comp_op0)) add_reg_note (common_comp_insn, REG_DEAD, copy_rtx (comp_op0)); @@ -1211,9 +1212,10 @@ sh_treg_combine::try_combine_comparisons (cbranch_trace& trace, log_msg ("replacing comparison and cstore with reg move " "in [bb %d]\n", i->bb->index); - rtx new_i = touched_insn ( - emit_insn_after (gen_move_insn (comp_op0, i_comp_op0), - i->setcc.insn)); + rtx_insn *new_i + = emit_insn_after (gen_move_insn (comp_op0, i_comp_op0), + i->setcc.insn); + touched_insn (new_i); if (REG_P (i_comp_op0) && reg_dead_after_insn (i_comp_op0, i->setcc.insn)) @@ -1223,9 +1225,9 @@ sh_treg_combine::try_combine_comparisons (cbranch_trace& trace, // Otherwise assume it's a const_int and just reference it. if (REG_P (comp_op1)) { - new_i = touched_insn ( - emit_insn_after (gen_move_insn (comp_op1, i_comp_op1), - i->setcc.insn)); + new_i = emit_insn_after (gen_move_insn (comp_op1, i_comp_op1), + i->setcc.insn); + touched_insn (new_i); if (reg_dead_after_insn (i_comp_op1, i->setcc.insn)) add_reg_note (new_i, REG_DEAD, copy_rtx (i_comp_op1)); -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:58 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:58 -0500 Subject: [PATCH 17/25] Pass an rtx_insn * to redirect_with_delay_slots_safe_p In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-18-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * reorg.cc (redirect_with_delay_slots_safe_p): Pass an rtx_insn *. --- gcc/reorg.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/reorg.cc b/gcc/reorg.cc index eee7ba364f6..07f8115a337 100644 --- a/gcc/reorg.cc +++ b/gcc/reorg.cc @@ -189,7 +189,7 @@ static int get_jump_flags (const rtx_insn *, rtx); static int mostly_true_jump (rtx_insn *); static rtx get_branch_condition (const rtx_insn *, rtx); static bool condition_dominates_p (rtx, const rtx_insn *); -static bool redirect_with_delay_slots_safe_p (rtx_insn *, rtx, rtx); +static bool redirect_with_delay_slots_safe_p (rtx_insn *, rtx, rtx_insn *); static bool redirect_with_delay_list_safe_p (rtx_insn *, rtx, const vec &); static bool check_annul_list_true_false (bool, const vec &); @@ -878,7 +878,7 @@ condition_dominates_p (rtx condition, const rtx_insn *insn) any insns already in the delay slot of JUMP. */ static bool -redirect_with_delay_slots_safe_p (rtx_insn *jump, rtx newlabel, rtx seq) +redirect_with_delay_slots_safe_p (rtx_insn *jump, rtx newlabel, rtx_insn *seq) { int flags, i; rtx_sequence *pat = as_a (PATTERN (seq)); -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:57 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:57 -0500 Subject: [PATCH 16/25] Use rtx_insn * and rtx_code_label * where the value already has that type In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-17-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_guard_switch_pstate_sm, aarch64_expand_prologue, aarch64_expand_epilogue, aarch64_switch_pstate_sm_for_landing_pad, aarch64_switch_pstate_sm_for_jump, aarch64_switch_pstate_sm_for_call): Use an rtx_code_label * for the guard label. (aarch64_expand_cpymem): Use an rtx_insn * for locals that only hold an insn. * config/arm/arm.cc (arm_add_cfa_adjust_cfa_note, cmse_nonsecure_call_inline_register_clear): Pass an rtx_insn * and use one for a local that already holds an insn. * config/bfin/bfin.cc (hwloop_optimize): Use an rtx_insn * for a local that only holds an insn. * config/c6x/c6x.cc (condjump_opposite_condition, duplicate_cond, reorg_emit_nops, try_rename_operands, hwloop_optimize): Pass an rtx_insn * and use one for a local that already holds an insn. * explow.cc (emit_stack_clash_protection_probe_loop_start, anti_adjust_stack_and_probe_stack_clash): Pass an rtx_code_label ** and use one for a local that only holds a label. * explow.h (emit_stack_clash_protection_probe_loop_start): Pass an rtx_code_label **. * haifa-sched.cc (move_insn): Pass an rtx_insn *. * optabs.cc (expand_compare_and_swap_loop): Likewise. (maybe_emit_compare_and_swap_exchange_loop): Pass nullptr. * config/i386/i386-features.cc (emit_conversion_insns): Pass an rtx_insn *. * config/i386/i386-features.h (emit_conversion_insns): Likewise. * config/ia64/ia64.cc (get_insn_spec_code, try_issue_insn): Likewise. * config/m68k/m68k.md (negdf2, negxf2, absdf2, absxf2): Use an rtx_insn * for a local that only holds an insn. * config/mips/mips.cc (mips_expand_prologue): Use an rtx_insn * for a local that only holds an insn. * config/pru/pru.md (cbranchdi4): Likewise. * config/riscv/riscv-string.cc (emit_strcmp_scalar_compare_byte, emit_strcmp_scalar_compare_subword, emit_strcmp_scalar_compare_word, emit_strcmp_scalar_load_and_compare, emit_memcmp_scalar_load_and_compare): Pass an rtx_code_label *. * config/rl78/rl78.cc (rl78_note_reg_uses, rl78_note_reg_set): Pass an rtx_insn *. * config/rs6000/rs6000-p8swap.cc (union_defs, union_uses, insn_is_load_p, insn_is_store_p, insn_is_swap_p, quad_aligned_load_p, quad_aligned_store_p, swap_feeds_both_load_and_store, const_load_sequence_p, insn_is_swappable_p, chain_contains_only_swaps, mark_swaps_for_removal, replace_swapped_aligned_load, replace_swapped_load_constant, rs6000_analyze_swaps): Pass an rtx_insn * and use one for locals that already hold an insn. * config/rs6000/rs6000.cc (is_load_insn, is_store_insn, rs6000_is_costly_dependence, is_costly_group): Likewise. * config/rs6000/rs6000-string.cc (do_ifelse, expand_cmp_vec_sequence, expand_strncmp_gpr_sequence, expand_block_compare, expand_strn_compare): Pass an rtx_code_label * and use one for locals that only hold a label. * config/rs6000/rs6000.md (allocate_stack): Use an rtx_code_label * for a local that only holds a label. * config/s390/s390.cc (s390_emit_tls_call_insn, s390_expand_tbegin): Use an rtx_insn * for a local that only holds an insn. * config/sh/sh.cc (sh_expand_prologue, sh_reorg): Use an rtx_code_label * for a local that only holds a label. * config/sh/sh.md (symGOT2reg, symGOTFUNCDESC2reg, sibcall_pcrel_fdpic, sibcall_value_pcrel, sibcall_value_pcrel_fdpic): Use an rtx_insn * for a local that only holds an insn. * config/sh/sh_treg_combine.cc (touched_insn, try_combine_comparisons): Pass and return an rtx_insn *, and use one for a local that already holds an insn. --- gcc/config/aarch64/aarch64.cc | 20 ++++++------ gcc/config/arm/arm.cc | 8 ++--- gcc/config/bfin/bfin.cc | 3 +- gcc/config/c6x/c6x.cc | 10 +++--- gcc/config/i386/i386-features.cc | 2 +- gcc/config/i386/i386-features.h | 2 +- gcc/config/ia64/ia64.cc | 6 ++-- gcc/config/m68k/m68k.md | 12 +++---- gcc/config/mips/mips.cc | 4 ++- gcc/config/pru/pru.md | 2 +- gcc/config/riscv/riscv-string.cc | 15 +++++---- gcc/config/rl78/rl78.cc | 4 +-- gcc/config/rs6000/rs6000-p8swap.cc | 52 +++++++++++++++--------------- gcc/config/rs6000/rs6000-string.cc | 25 +++++++------- gcc/config/rs6000/rs6000.cc | 16 ++++----- gcc/config/rs6000/rs6000.md | 2 +- gcc/config/s390/s390.cc | 4 +-- gcc/config/sh/sh.cc | 6 ++-- gcc/config/sh/sh.md | 29 +++++++++-------- gcc/config/sh/sh_treg_combine.cc | 8 ++--- gcc/explow.cc | 6 ++-- gcc/explow.h | 6 ++-- gcc/haifa-sched.cc | 2 +- gcc/optabs.cc | 4 +-- 24 files changed, 128 insertions(+), 120 deletions(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 66af00d9141..4f61fcc5961 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -5907,7 +5907,7 @@ aarch64_sub_sp (rtx temp1, rtx temp2, poly_int64 delta, Emit instructions to branch around the mode switch if PSTATE.SM already matches LOCAL_MODE. Return the label that the branch jumps to. */ -static rtx_insn * +static rtx_code_label * aarch64_guard_switch_pstate_sm (rtx old_svcr, aarch64_isa_mode local_mode) { local_mode &= AARCH64_ISA_MODE_SM_STATE; @@ -10717,7 +10717,7 @@ aarch64_read_old_svcr (unsigned int regno) load the incoming value of SVCR from its save slot into temporary register REGNO. */ -static rtx_insn * +static rtx_code_label * aarch64_guard_switch_pstate_sm (unsigned int regno, aarch64_isa_mode local_mode) { @@ -11023,7 +11023,7 @@ aarch64_expand_prologue (void) /* Enable PSTATE.SM, if required. */ if (aarch64_cfun_enables_pstate_sm ()) { - rtx_insn *guard_label = nullptr; + rtx_code_label *guard_label = nullptr; if (known_ge (cfun->machine->frame.old_svcr_offset, 0)) { /* The current function is streaming-compatible. Save the @@ -11137,7 +11137,7 @@ aarch64_expand_epilogue (rtx_call_insn *sibcall) /* Reset PSTATE.SM, if required. */ if (aarch64_cfun_enables_pstate_sm ()) { - rtx_insn *guard_label = nullptr; + rtx_code_label *guard_label = nullptr; if (known_ge (cfun->machine->frame.old_svcr_offset, 0)) guard_label = aarch64_guard_switch_pstate_sm (IP0_REGNUM, AARCH64_ISA_MODE); @@ -29591,8 +29591,8 @@ aarch64_expand_cpymem (rtx *operands, bool is_memmove) mode = V4SImode; rtx reg = gen_reg_rtx (mode); - rtx load = gen_move_insn (reg, adjust_address (src, mode, offset)); - rtx store = gen_move_insn (adjust_address (dst, mode, offset), reg); + rtx_insn *load = gen_move_insn (reg, adjust_address (src, mode, offset)); + rtx_insn *store = gen_move_insn (adjust_address (dst, mode, offset), reg); ops.safe_push ({ load, store }); size -= mode_bytes; offset += mode_bytes; @@ -33523,7 +33523,7 @@ aarch64_switch_pstate_sm_for_landing_pad (basic_block bb) return false; start_sequence (); - rtx_insn *guard_label = nullptr; + rtx_code_label *guard_label = nullptr; if (TARGET_STREAMING_COMPATIBLE) guard_label = aarch64_guard_switch_pstate_sm (IP0_REGNUM, AARCH64_ISA_MODE_SM_OFF); @@ -33550,7 +33550,7 @@ aarch64_switch_pstate_sm_for_jump (rtx_insn *jump) return false; start_sequence (); - rtx_insn *guard_label = nullptr; + rtx_code_label *guard_label = nullptr; if (TARGET_STREAMING_COMPATIBLE) guard_label = aarch64_guard_switch_pstate_sm (IP0_REGNUM, AARCH64_ISA_MODE_SM_OFF); @@ -33580,7 +33580,7 @@ aarch64_switch_pstate_sm_for_call (rtx_call_insn *call) /* Switch mode before the call, preserving any argument registers across the switch. */ start_sequence (); - rtx_insn *args_guard_label = nullptr; + rtx_code_label *args_guard_label = nullptr; if (TARGET_STREAMING_COMPATIBLE) args_guard_label = aarch64_guard_switch_pstate_sm (IP0_REGNUM, callee_isa_mode); @@ -33600,7 +33600,7 @@ aarch64_switch_pstate_sm_for_call (rtx_call_insn *call) /* Switch mode after the call, preserving any return registers across the switch. */ start_sequence (); - rtx_insn *return_guard_label = nullptr; + rtx_code_label *return_guard_label = nullptr; if (TARGET_STREAMING_COMPATIBLE) return_guard_label = aarch64_guard_switch_pstate_sm (IP0_REGNUM, callee_isa_mode); diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index ffdd9465025..16bad70944e 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -172,7 +172,7 @@ static int arm_register_move_cost (machine_mode, reg_class_t, reg_class_t); static int arm_memory_move_cost (machine_mode, reg_class_t, bool); static void emit_constant_insn (rtx cond, rtx pattern); static rtx_insn *emit_set_insn (rtx, rtx); -static void arm_add_cfa_adjust_cfa_note (rtx, int, rtx, rtx); +static void arm_add_cfa_adjust_cfa_note (rtx_insn *, int, rtx, rtx); static rtx_insn *emit_multi_reg_push (unsigned long, unsigned long); static void arm_emit_multi_reg_pop (unsigned long); static int vfp_emit_fstmd (int, int); @@ -18368,8 +18368,8 @@ cmse_nonsecure_call_inline_register_clear (void) if (clear_callee_saved) { - rtx push_insn = - emit_multi_reg_push (callee_saved_mask, callee_saved_mask); + rtx_insn *push_insn + = emit_multi_reg_push (callee_saved_mask, callee_saved_mask); /* Disable frame debug info in push because it needs to be disabled for pop (see below). */ RTX_FRAME_RELATED_P (push_insn) = 0; @@ -21502,7 +21502,7 @@ emit_multi_reg_push (unsigned long mask, unsigned long dwarf_regs_mask) SIZE is the offset to be adjusted. DEST and SRC might be stack_pointer_rtx or hard_frame_pointer_rtx. */ static void -arm_add_cfa_adjust_cfa_note (rtx insn, int size, rtx dest, rtx src) +arm_add_cfa_adjust_cfa_note (rtx_insn *insn, int size, rtx dest, rtx src) { rtx dwarf; diff --git a/gcc/config/bfin/bfin.cc b/gcc/config/bfin/bfin.cc index f81114b0bf5..015ba054029 100644 --- a/gcc/config/bfin/bfin.cc +++ b/gcc/config/bfin/bfin.cc @@ -3452,7 +3452,8 @@ hwloop_optimize (hwloop_info loop) { basic_block bb; rtx_insn *insn, *last_insn; - rtx loop_init, start_label; + rtx loop_init; + rtx_insn *start_label; rtx iter_reg, scratchreg, scratch_init; rtx_insn *scratch_init_insn; rtx lc_reg, lt_reg, lb_reg; diff --git a/gcc/config/c6x/c6x.cc b/gcc/config/c6x/c6x.cc index ca213d8b66f..2209b16cb5f 100644 --- a/gcc/config/c6x/c6x.cc +++ b/gcc/config/c6x/c6x.cc @@ -3400,7 +3400,7 @@ get_unit_operand_masks (rtx_insn *insn, unsigned int *pmask1, it only if we managed to improve the balance. */ static void try_rename_operands (rtx_insn *head, rtx_insn *tail, unit_req_table reqs, - rtx insn, + rtx_insn *insn, insn_rr_info *info, unsigned int op_mask, int orig_side) { enum reg_class super_class = orig_side == 0 ? B_REGS : A_REGS; @@ -3726,7 +3726,7 @@ insn_get_clock (rtx insn) the opposite of the condition in which it branches. Otherwise, return NULL_RTX. */ static rtx -condjump_opposite_condition (rtx insn) +condjump_opposite_condition (rtx_insn *insn) { rtx pat = PATTERN (insn); int icode = INSN_CODE (insn); @@ -4786,7 +4786,7 @@ find_next_cycle_insn (rtx_insn *insn, int clock) around PAT. Return PAT either unchanged or modified in this way. */ static rtx -duplicate_cond (rtx pat, rtx cond_insn) +duplicate_cond (rtx pat, rtx_insn *cond_insn) { rtx cond_pat = PATTERN (cond_insn); if (GET_CODE (cond_pat) == COND_EXEC) @@ -5044,7 +5044,7 @@ reorg_emit_nops (rtx_code_label **call_labels) cycles -= prev_implicit_nops; if (cycles > 1) { - rtx nop = emit_nop_after (cycles - 1, prev); + rtx_insn *nop = emit_nop_after (cycles - 1, prev); insn_set_clock (nop, prev_clock + prev_implicit_nops + 1); } } @@ -5671,7 +5671,7 @@ hwloop_optimize (hwloop_info loop) for (i = 0; i < n_real_insns; i++) { - rtx insn = insn_copies[0][i]; + rtx_insn *insn = insn_copies[0][i]; int uid = INSN_UID (insn); int stage = insn_uid_get_clock (uid) / sp_ii; diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc index f95bc41fb47..f1eeadf23b2 100644 --- a/gcc/config/i386/i386-features.cc +++ b/gcc/config/i386/i386-features.cc @@ -914,7 +914,7 @@ general_scalar_chain::compute_convert_gain () instruction has EH region attached. */ void -scalar_chain::emit_conversion_insns (rtx insns, rtx_insn *after) +scalar_chain::emit_conversion_insns (rtx_insn *insns, rtx_insn *after) { if (!control_flow_insn_p (after)) { diff --git a/gcc/config/i386/i386-features.h b/gcc/config/i386/i386-features.h index febcf62e72d..61b2393b7ea 100644 --- a/gcc/config/i386/i386-features.h +++ b/gcc/config/i386/i386-features.h @@ -164,7 +164,7 @@ class scalar_chain protected: void add_to_queue (unsigned insn_uid); - void emit_conversion_insns (rtx insns, rtx_insn *pos); + void emit_conversion_insns (rtx_insn *insns, rtx_insn *pos); rtx convert_compare (rtx op1, rtx op2, rtx_insn *insn); void mark_dual_mode_def (df_ref def); void convert_reg (rtx_insn *insn, rtx dst, rtx src); diff --git a/gcc/config/ia64/ia64.cc b/gcc/config/ia64/ia64.cc index e2e00348bdc..9ed9118b435 100644 --- a/gcc/config/ia64/ia64.cc +++ b/gcc/config/ia64/ia64.cc @@ -266,7 +266,7 @@ static int insert_bundle_state (struct bundle_state *); static void initiate_bundle_state_table (void); static void finish_bundle_state_table (void); static int try_issue_nops (struct bundle_state *, int); -static int try_issue_insn (struct bundle_state *, rtx); +static int try_issue_insn (struct bundle_state *, rtx_insn *); static void issue_nops_and_insn (struct bundle_state *, int, rtx_insn *, int, int); static int get_max_pos (state_t); @@ -8257,7 +8257,7 @@ ia64_skip_rtx_p (const_rtx x) /* If INSN is a speculative load, return its UNSPEC code. Return -1 otherwise. */ static int -get_insn_spec_code (const_rtx insn) +get_insn_spec_code (const rtx_insn *insn) { rtx pat, reg, mem; @@ -8849,7 +8849,7 @@ try_issue_nops (struct bundle_state *curr_state, int nops_num) function returns FALSE and frees the current state. */ static int -try_issue_insn (struct bundle_state *curr_state, rtx insn) +try_issue_insn (struct bundle_state *curr_state, rtx_insn *insn) { if (insn && state_transition (curr_state->dfa_state, insn) >= 0) { diff --git a/gcc/config/m68k/m68k.md b/gcc/config/m68k/m68k.md index 227399feeee..be7a28cc7c5 100644 --- a/gcc/config/m68k/m68k.md +++ b/gcc/config/m68k/m68k.md @@ -4085,7 +4085,6 @@ { rtx result; rtx target; - rtx insns; start_sequence (); target = operand_subword (operands[0], 0, 1, DFmode); @@ -4100,7 +4099,7 @@ emit_move_insn (operand_subword (operands[0], 1, 1, DFmode), operand_subword_force (operands[1], 1, DFmode)); - insns = end_sequence (); + rtx_insn *insns = end_sequence (); emit_insn (insns); DONE; @@ -4116,7 +4115,6 @@ { rtx result; rtx target; - rtx insns; start_sequence (); target = operand_subword (operands[0], 0, 1, XFmode); @@ -4133,7 +4131,7 @@ emit_move_insn (operand_subword (operands[0], 2, 1, XFmode), operand_subword_force (operands[1], 2, XFmode)); - insns = end_sequence (); + rtx_insn *insns = end_sequence (); emit_insn (insns); DONE; @@ -4236,7 +4234,6 @@ { rtx result; rtx target; - rtx insns; start_sequence (); target = operand_subword (operands[0], 0, 1, DFmode); @@ -4251,7 +4248,7 @@ emit_move_insn (operand_subword (operands[0], 1, 1, DFmode), operand_subword_force (operands[1], 1, DFmode)); - insns = end_sequence (); + rtx_insn *insns = end_sequence (); emit_insn (insns); DONE; @@ -4267,7 +4264,6 @@ { rtx result; rtx target; - rtx insns; start_sequence (); target = operand_subword (operands[0], 0, 1, XFmode); @@ -4284,7 +4280,7 @@ emit_move_insn (operand_subword (operands[0], 2, 1, XFmode), operand_subword_force (operands[1], 2, XFmode)); - insns = end_sequence (); + rtx_insn *insns = end_sequence (); emit_insn (insns); DONE; diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc index 1bc9cb9c99d..31afbb22eb0 100644 --- a/gcc/config/mips/mips.cc +++ b/gcc/config/mips/mips.cc @@ -12846,7 +12846,9 @@ mips_expand_prologue (void) offset = frame->hard_frame_pointer_offset; if (offset == 0) { - rtx insn = mips_emit_move (hard_frame_pointer_rtx, stack_pointer_rtx); + rtx_insn *insn + = mips_emit_move (hard_frame_pointer_rtx, + stack_pointer_rtx); RTX_FRAME_RELATED_P (insn) = 1; } else if (SMALL_OPERAND (offset)) diff --git a/gcc/config/pru/pru.md b/gcc/config/pru/pru.md index 0487409326e..23df113fb8b 100644 --- a/gcc/config/pru/pru.md +++ b/gcc/config/pru/pru.md @@ -1620,7 +1620,7 @@ rtx op1_hi = simplify_gen_subreg (SImode, operands[1], DImode, 4); rtx op2_lo = simplify_gen_subreg (SImode, operands[2], DImode, 0); rtx op2_hi = simplify_gen_subreg (SImode, operands[2], DImode, 4); - rtx j; + rtx_insn *j; if (code == EQ) { diff --git a/gcc/config/riscv/riscv-string.cc b/gcc/config/riscv/riscv-string.cc index e1ce5929219..e7ab72482b1 100644 --- a/gcc/config/riscv/riscv-string.cc +++ b/gcc/config/riscv/riscv-string.cc @@ -138,7 +138,7 @@ do_load_from_addr (machine_mode mode, rtx dest, rtx addr_reg, rtx addr) static void emit_strcmp_scalar_compare_byte (rtx result, rtx data1, rtx data2, - rtx final_label) + rtx_code_label *final_label) { do_sub3 (result, data1, data2); emit_jump_insn (gen_jump (final_label)); @@ -156,7 +156,7 @@ emit_strcmp_scalar_compare_byte (rtx result, rtx data1, rtx data2, static void emit_strcmp_scalar_compare_subword (rtx data1, rtx data2, rtx orc1, unsigned HOST_WIDE_INT cmp_bytes, - rtx end_label) + rtx_code_label *end_label) { /* Set a NUL-byte after the relevant data (behind the string). */ long long im = -256ll; @@ -186,7 +186,8 @@ emit_strcmp_scalar_compare_subword (rtx data1, rtx data2, rtx orc1, static void emit_strcmp_scalar_compare_word (rtx data1, rtx data2, rtx orc1, rtx testval, - rtx end_label, rtx nonul_end_label) + rtx_code_label *end_label, + rtx_code_label *nonul_end_label) { /* Check if data1 contains a NUL character. */ if (TARGET_ZBB) @@ -221,8 +222,9 @@ static void emit_strcmp_scalar_load_and_compare (rtx result, rtx src1, rtx src2, unsigned HOST_WIDE_INT nbytes, rtx data1, rtx data2, rtx orc1, - rtx end_label, rtx nonul_end_label, - rtx final_label) + rtx_code_label *end_label, + rtx_code_label *nonul_end_label, + rtx_code_label *final_label) { const unsigned HOST_WIDE_INT xlen = GET_MODE_SIZE (Xmode); unsigned HOST_WIDE_INT offset = 0; @@ -635,7 +637,8 @@ static void emit_memcmp_scalar_load_and_compare (rtx result, rtx src1, rtx src2, unsigned HOST_WIDE_INT nbytes, rtx data1, rtx data2, - rtx diff_label, rtx final_label) + rtx_code_label *diff_label, + rtx_code_label *final_label) { const unsigned HOST_WIDE_INT xlen = GET_MODE_SIZE (Xmode); unsigned HOST_WIDE_INT offset = 0; diff --git a/gcc/config/rl78/rl78.cc b/gcc/config/rl78/rl78.cc index dffb06095d2..56976aab353 100644 --- a/gcc/config/rl78/rl78.cc +++ b/gcc/config/rl78/rl78.cc @@ -3822,7 +3822,7 @@ rl78_alloc_physical_registers (void) encounter when scanning backwards) triggers a REG_DEAD note if the reg was previously in DEAD[]. */ static void -rl78_note_reg_uses (char *dead, rtx s, rtx insn) +rl78_note_reg_uses (char *dead, rtx s, rtx_insn *insn) { const char *fmt; int i, r; @@ -3884,7 +3884,7 @@ rl78_note_reg_uses (char *dead, rtx s, rtx insn) /* Like the previous function, but scan for SETs instead. */ static void -rl78_note_reg_set (char *dead, rtx d, rtx insn) +rl78_note_reg_set (char *dead, rtx d, rtx_insn *insn) { int r, i; bool is_dead; diff --git a/gcc/config/rs6000/rs6000-p8swap.cc b/gcc/config/rs6000/rs6000-p8swap.cc index 046207e73f6..de1cf8596f2 100644 --- a/gcc/config/rs6000/rs6000-p8swap.cc +++ b/gcc/config/rs6000/rs6000-p8swap.cc @@ -206,7 +206,7 @@ enum special_handling_values { /* Union INSN with all insns containing definitions that reach USE. Detect whether USE is live-in to the current function. */ static void -union_defs (swap_web_entry *insn_entry, rtx insn, df_ref use) +union_defs (swap_web_entry *insn_entry, rtx_insn *insn, df_ref use) { struct df_link *link = DF_REF_CHAIN (use); @@ -220,7 +220,7 @@ union_defs (swap_web_entry *insn_entry, rtx insn, df_ref use) if (DF_REF_INSN_INFO (link->ref)) { - rtx def_insn = DF_REF_INSN (link->ref); + rtx_insn *def_insn = DF_REF_INSN (link->ref); gcc_assert (NONDEBUG_INSN_P (def_insn)); unionfind_union (insn_entry + INSN_UID (insn), insn_entry + INSN_UID (def_insn)); @@ -233,7 +233,7 @@ union_defs (swap_web_entry *insn_entry, rtx insn, df_ref use) /* Union INSN with all insns containing uses reached from DEF. Detect whether DEF is live-out from the current function. */ static void -union_uses (swap_web_entry *insn_entry, rtx insn, df_ref def) +union_uses (swap_web_entry *insn_entry, rtx_insn *insn, df_ref def) { struct df_link *link = DF_REF_CHAIN (def); @@ -249,7 +249,7 @@ union_uses (swap_web_entry *insn_entry, rtx insn, df_ref def) if (DF_REF_INSN_INFO (link->ref)) { - rtx use_insn = DF_REF_INSN (link->ref); + rtx_insn *use_insn = DF_REF_INSN (link->ref); if (NONDEBUG_INSN_P (use_insn)) unionfind_union (insn_entry + INSN_UID (insn), insn_entry + INSN_UID (use_insn)); @@ -277,7 +277,7 @@ pattern_is_rotate64 (rtx pat) /* Return 1 iff INSN is a load insn, including permuting loads that represent an lvxd2x instruction; else return 0. */ static unsigned int -insn_is_load_p (rtx insn) +insn_is_load_p (rtx_insn *insn) { rtx body = PATTERN (insn); @@ -310,7 +310,7 @@ insn_is_load_p (rtx insn) /* Return 1 iff INSN is a store insn, including permuting stores that represent an stvxd2x instruction; else return 0. */ static unsigned int -insn_is_store_p (rtx insn) +insn_is_store_p (rtx_insn *insn) { rtx body = PATTERN (insn); if (GET_CODE (body) == SET && MEM_P (SET_DEST (body))) @@ -326,7 +326,7 @@ insn_is_store_p (rtx insn) /* Return 1 iff INSN swaps doublewords. This may be a reg-reg swap, a permuting load, or a permuting store. */ static unsigned int -insn_is_swap_p (rtx insn) +insn_is_swap_p (rtx_insn *insn) { rtx body = PATTERN (insn); if (GET_CODE (body) != SET) @@ -410,7 +410,7 @@ quad_aligned_load_p (swap_web_entry *insn_entry, rtx_insn *insn) || def_link->next) return false; - rtx def_insn = DF_REF_INSN (def_link->ref); + rtx_insn *def_insn = DF_REF_INSN (def_link->ref); unsigned uid2 = INSN_UID (def_insn); /* We're looking for a load-with-swap insn. If this is not that, return false. */ @@ -469,7 +469,7 @@ quad_aligned_store_p (swap_web_entry *insn_entry, rtx_insn *insn) || def_link->next) return false; - rtx def_insn = DF_REF_INSN (def_link->ref); + rtx_insn *def_insn = DF_REF_INSN (def_link->ref); unsigned uid2 = INSN_UID (def_insn); /* If this source value is not a simple swap, return false */ @@ -499,7 +499,7 @@ quad_aligned_store_p (swap_web_entry *insn_entry, rtx_insn *insn) static unsigned int swap_feeds_both_load_and_store (swap_web_entry *insn_entry) { - rtx insn = insn_entry->insn; + rtx_insn *insn = insn_entry->insn; struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn); df_ref def, use; struct df_link *link = 0; @@ -528,7 +528,7 @@ swap_feeds_both_load_and_store (swap_web_entry *insn_entry) /* Return TRUE if insn is a swap fed by a load from the constant pool. */ static bool -const_load_sequence_p (swap_web_entry *insn_entry, rtx insn) +const_load_sequence_p (swap_web_entry *insn_entry, rtx_insn *insn) { unsigned uid = INSN_UID (insn); if (!insn_entry[uid].is_swap || insn_entry[uid].is_load) @@ -551,7 +551,7 @@ const_load_sequence_p (swap_web_entry *insn_entry, rtx insn) || def_link->next) return false; - rtx def_insn = DF_REF_INSN (def_link->ref); + rtx_insn *def_insn = DF_REF_INSN (def_link->ref); unsigned uid2 = INSN_UID (def_insn); /* If this is not a load or is not a swap, return false. */ if (!insn_entry[uid2].is_load || !insn_entry[uid2].is_swap) @@ -594,7 +594,7 @@ const_load_sequence_p (swap_web_entry *insn_entry, rtx insn) if (DF_REF_IS_ARTIFICIAL (base_def_link->ref)) return false; - rtx tocrel_insn = DF_REF_INSN (base_def_link->ref); + rtx_insn *tocrel_insn = DF_REF_INSN (base_def_link->ref); rtx tocrel_body = PATTERN (tocrel_insn); rtx base, offset; if (GET_CODE (tocrel_body) != SET) @@ -871,7 +871,7 @@ rtx_is_swappable_p (rtx op, unsigned int *special) if vector doublewords are swapped in memory (in which case *SPECIAL is changed to a value indicating how). */ static unsigned int -insn_is_swappable_p (swap_web_entry *insn_entry, rtx insn, +insn_is_swappable_p (swap_web_entry *insn_entry, rtx_insn *insn, unsigned int *special) { /* Calls are always bad. */ @@ -945,7 +945,7 @@ insn_is_swappable_p (swap_web_entry *insn_entry, rtx insn, return 0; for (; link; link = link->next) { - rtx use_insn = DF_REF_INSN (link->ref); + rtx_insn *use_insn = DF_REF_INSN (link->ref); rtx use_body = PATTERN (use_insn); if (GET_CODE (use_body) != SET || GET_CODE (SET_SRC (use_body)) != UNSPEC @@ -1031,7 +1031,7 @@ chain_contains_only_swaps (swap_web_entry *insn_entry, struct df_link *link, if (DF_REF_IS_ARTIFICIAL (link->ref)) return false; - rtx reached_insn = DF_REF_INSN (link->ref); + rtx_insn *reached_insn = DF_REF_INSN (link->ref); unsigned uid = INSN_UID (reached_insn); struct df_insn_info *insn_info = DF_INSN_INFO_GET (reached_insn); @@ -1051,7 +1051,7 @@ chain_contains_only_swaps (swap_web_entry *insn_entry, struct df_link *link, if (DF_REF_IS_ARTIFICIAL (link->ref)) return false; - rtx swap_def_insn = DF_REF_INSN (swap_link->ref); + rtx_insn *swap_def_insn = DF_REF_INSN (swap_link->ref); unsigned uid2 = INSN_UID (swap_def_insn); /* Only permuting loads are allowed. */ @@ -1074,7 +1074,7 @@ chain_contains_only_swaps (swap_web_entry *insn_entry, struct df_link *link, if (DF_REF_IS_ARTIFICIAL (link->ref)) return false; - rtx swap_use_insn = DF_REF_INSN (swap_link->ref); + rtx_insn *swap_use_insn = DF_REF_INSN (swap_link->ref); unsigned uid2 = INSN_UID (swap_use_insn); /* Permuting stores or register swaps are allowed. */ @@ -1097,7 +1097,7 @@ chain_contains_only_swaps (swap_web_entry *insn_entry, struct df_link *link, static void mark_swaps_for_removal (swap_web_entry *insn_entry, unsigned int i) { - rtx insn = insn_entry[i].insn; + rtx_insn *insn = insn_entry[i].insn; struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn); if (insn_entry[i].is_load) @@ -1111,7 +1111,7 @@ mark_swaps_for_removal (swap_web_entry *insn_entry, unsigned int i) them confidently. */ while (link) { - rtx use_insn = DF_REF_INSN (link->ref); + rtx_insn *use_insn = DF_REF_INSN (link->ref); insn_entry[INSN_UID (use_insn)].will_delete = 1; link = link->next; } @@ -1133,7 +1133,7 @@ mark_swaps_for_removal (swap_web_entry *insn_entry, unsigned int i) them confidently. */ while (link) { - rtx def_insn = DF_REF_INSN (link->ref); + rtx_insn *def_insn = DF_REF_INSN (link->ref); insn_entry[INSN_UID (def_insn)].will_delete = 1; link = link->next; } @@ -1749,7 +1749,7 @@ rs6000_gen_lvx (enum machine_mode mode, rtx dest_exp, rtx src_exp) load-with-swap, replace the load with an aligned load (without swap) and replace the swap with a copy insn. */ static void -replace_swapped_aligned_load (swap_web_entry *insn_entry, rtx swap_insn) +replace_swapped_aligned_load (swap_web_entry *insn_entry, rtx_insn *swap_insn) { /* Find the load. */ unsigned uid = INSN_UID (swap_insn); @@ -1866,7 +1866,7 @@ replace_swapped_aligned_load (swap_web_entry *insn_entry, rtx swap_insn) A better solution is to fix the code generator to emit lvx/stvx for those. */ static void -replace_swapped_load_constant (swap_web_entry *insn_entry, rtx swap_insn) +replace_swapped_load_constant (swap_web_entry *insn_entry, rtx_insn *swap_insn) { /* Find the load. */ struct df_insn_info *insn_info = DF_INSN_INFO_GET (swap_insn); @@ -2476,7 +2476,7 @@ rs6000_analyze_swaps (function *fun) use. */ if (mode == DImode && DF_REF_INSN_INFO (mention)) { - rtx feeder = DF_REF_INSN (mention); + rtx_insn *feeder = DF_REF_INSN (mention); /* FIXME: It is pretty hard to get from the df mention to the mode of the use in the insn. We arbitrarily pick a vector mode here, even though the use might @@ -2602,7 +2602,7 @@ rs6000_analyze_swaps (function *fun) by a register swap, the optimization isn't appropriate. */ else if (insn_entry[i].is_load && insn_entry[i].is_swap) { - rtx insn = insn_entry[i].insn; + rtx_insn *insn = insn_entry[i].insn; struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn); df_ref def; @@ -2619,7 +2619,7 @@ rs6000_analyze_swaps (function *fun) } else if (insn_entry[i].is_store && insn_entry[i].is_swap) { - rtx insn = insn_entry[i].insn; + rtx_insn *insn = insn_entry[i].insn; struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn); df_ref use; diff --git a/gcc/config/rs6000/rs6000-string.cc b/gcc/config/rs6000/rs6000-string.cc index 539b898c544..2b6552dbb6a 100644 --- a/gcc/config/rs6000/rs6000-string.cc +++ b/gcc/config/rs6000/rs6000-string.cc @@ -380,7 +380,8 @@ do_load_for_compare_from_addr (machine_mode mode, rtx dest, rtx addr, static void do_ifelse (machine_mode cmpmode, rtx_code comparison, - rtx a, rtx b, rtx cr, rtx true_label, profile_probability br_prob) + rtx a, rtx b, rtx cr, + rtx_code_label *true_label, profile_probability br_prob) { gcc_assert ((a == NULL_RTX && b == NULL_RTX && cr != NULL_RTX) || (a != NULL_RTX && b != NULL_RTX)); @@ -645,8 +646,9 @@ expand_cmp_vec_sequence (unsigned HOST_WIDE_INT bytes_to_compare, rtx orig_src1, rtx orig_src2, rtx s1addr, rtx s2addr, rtx off_reg, rtx s1data, rtx s2data, rtx vec_result, - bool equality_compare_rest, rtx *p_cleanup_label, - rtx final_move_label, bool checkzero) + bool equality_compare_rest, + rtx_code_label **p_cleanup_label, + rtx_code_label *final_move_label, bool checkzero) { machine_mode load_mode; unsigned int load_mode_size; @@ -655,7 +657,7 @@ expand_cmp_vec_sequence (unsigned HOST_WIDE_INT bytes_to_compare, rtx zero_reg = NULL; gcc_assert (p_cleanup_label != NULL); - rtx cleanup_label = *p_cleanup_label; + rtx_code_label *cleanup_label = *p_cleanup_label; emit_move_insn (s1addr, force_reg (Pmode, XEXP (orig_src1, 0))); emit_move_insn (s2addr, force_reg (Pmode, XEXP (orig_src2, 0))); @@ -752,7 +754,7 @@ expand_cmp_vec_sequence (unsigned HOST_WIDE_INT bytes_to_compare, bool branch_to_cleanup = (remain > 0 || equality_compare_rest); rtx cr6 = gen_rtx_REG (CCmode, CR6_REGNO); - rtx dst_label; + rtx_code_label *dst_label; rtx cmp_rtx; if (branch_to_cleanup) { @@ -2029,7 +2031,7 @@ expand_block_compare (rtx operands[]) rtx s1addr = gen_reg_rtx (Pmode); rtx s2addr = gen_reg_rtx (Pmode); rtx off_reg = gen_reg_rtx (Pmode); - rtx cleanup_label = NULL; + rtx_code_label *cleanup_label = NULL; rtx vec_result = gen_reg_rtx (V16QImode); rtx s1data = gen_reg_rtx (V16QImode); rtx s2data = gen_reg_rtx (V16QImode); @@ -2127,8 +2129,9 @@ expand_strncmp_gpr_sequence (unsigned HOST_WIDE_INT bytes_to_compare, unsigned int base_align, rtx orig_src1, rtx orig_src2, rtx tmp_reg_src1, rtx tmp_reg_src2, rtx result_reg, - bool equality_compare_rest, rtx *p_cleanup_label, - rtx final_move_label) + bool equality_compare_rest, + rtx_code_label **p_cleanup_label, + rtx_code_label *final_move_label) { unsigned int word_mode_size = GET_MODE_SIZE (word_mode); machine_mode load_mode; @@ -2138,7 +2141,7 @@ expand_strncmp_gpr_sequence (unsigned HOST_WIDE_INT bytes_to_compare, rtx src1_addr = force_reg (Pmode, XEXP (orig_src1, 0)); rtx src2_addr = force_reg (Pmode, XEXP (orig_src2, 0)); gcc_assert (p_cleanup_label != NULL); - rtx cleanup_label = *p_cleanup_label; + rtx_code_label *cleanup_label = *p_cleanup_label; while (bytes_to_compare > 0) { @@ -2241,7 +2244,7 @@ expand_strncmp_gpr_sequence (unsigned HOST_WIDE_INT bytes_to_compare, A == B: branch to result 0. A != B: cleanup code to compute result. */ - rtx dst_label; + rtx_code_label *dst_label; if (remain > 0 || equality_compare_rest) { /* Branch to cleanup code, otherwise fall through to do @@ -2601,7 +2604,7 @@ expand_strn_compare (rtx operands[], int no_length) emit_label (begin_compare_label); } - rtx cleanup_label = NULL; + rtx_code_label *cleanup_label = NULL; rtx s1addr = NULL, s2addr = NULL, off_reg = NULL, vec_result = NULL; /* Generate a sequence of GPR or VEC/VSX instructions to compare out diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 6347cc5532d..a0f4be91980 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -1130,8 +1130,8 @@ static int rs6000_debug_adjust_cost (rtx_insn *, int, rtx_insn *, int, static bool is_microcoded_insn (rtx_insn *); static bool is_nonpipeline_insn (rtx_insn *); static bool is_cracked_insn (rtx_insn *); -static bool is_load_insn (rtx, rtx *); -static bool is_store_insn (rtx, rtx *); +static bool is_load_insn (rtx_insn *, rtx *); +static bool is_store_insn (rtx_insn *, rtx *); static bool set_to_load_agen (rtx_insn *,rtx_insn *); static bool insn_terminates_group_p (rtx_insn *, enum group_termination); static bool insn_must_be_first_in_group (rtx_insn *); @@ -19124,7 +19124,7 @@ is_load_insn1 (rtx pat, rtx *load_mem) /* Determine if INSN loads from memory. */ static bool -is_load_insn (rtx insn, rtx *load_mem) +is_load_insn (rtx_insn *insn, rtx *load_mem) { if (!insn || !INSN_P (insn)) return false; @@ -19166,7 +19166,7 @@ is_store_insn1 (rtx pat, rtx *str_mem) /* Determine if INSN stores to memory. */ static bool -is_store_insn (rtx insn, rtx *str_mem) +is_store_insn (rtx_insn *insn, rtx *str_mem) { if (!insn || !INSN_P (insn)) return false; @@ -19202,8 +19202,6 @@ is_power9_pairable_vec_type (enum attr_type type) static bool rs6000_is_costly_dependence (dep_t dep, int cost, int distance) { - rtx insn; - rtx next; rtx load_mem, str_mem; /* If the flag is not enabled - no dependence is considered costly; @@ -19218,8 +19216,8 @@ rs6000_is_costly_dependence (dep_t dep, int cost, int distance) if (rs6000_sched_costly_dep == all_deps_costly) return true; - insn = DEP_PRO (dep); - next = DEP_CON (dep); + rtx_insn *insn = DEP_PRO (dep); + rtx_insn *next = DEP_CON (dep); if (rs6000_sched_costly_dep == store_to_load_dep_costly && is_load_insn (next, &load_mem) @@ -20105,7 +20103,7 @@ is_costly_group (rtx_insn **group_insns, rtx next_insn) FOR_EACH_DEP (insn, SD_LIST_RES_FORW, sd_it, dep) { - rtx next = DEP_CON (dep); + rtx_insn *next = DEP_CON (dep); if (next == next_insn && rs6000_is_costly_dependence (dep, dep_cost (dep), 0)) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 60751c3f174..135e21ea99f 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -11149,7 +11149,7 @@ as well do a reasonable job when we obviously can. */ if (rounded_size != const0_rtx) { - rtx loop_lab, end_loop; + rtx_code_label *loop_lab, *end_loop; bool rotated = CONST_INT_P (rounded_size); rtx update = GEN_INT (-probe_interval); if (probe_interval > 32768) diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 870df09816f..a73cc5cdf66 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -5619,7 +5619,7 @@ static GTY(()) rtx s390_tls_symbol; static void s390_emit_tls_call_insn (rtx result_reg, rtx tls_call) { - rtx insn; + rtx_insn *insn; if (!flag_pic) emit_insn (s390_load_got ()); @@ -13973,7 +13973,7 @@ s390_expand_tbegin (rtx dest, rtx tdb, rtx retry, bool clobber_fprs_p) const int CC0 = 1 << 3; const int CC1 = 1 << 2; const int CC3 = 1 << 0; - rtx jump; + rtx_insn *jump; rtx count = gen_reg_rtx (SImode); rtx_code_label *leave_label = gen_label_rtx (); diff --git a/gcc/config/sh/sh.cc b/gcc/config/sh/sh.cc index 3eb5900d791..0a49b650615 100644 --- a/gcc/config/sh/sh.cc +++ b/gcc/config/sh/sh.cc @@ -6200,7 +6200,7 @@ sh_reorg (void) { rtx *patp = &PATTERN (scan), pat = *patp; rtx src, dst; - rtx lab; + rtx_code_label *lab; rtx newsrc; machine_mode mode; @@ -7169,14 +7169,14 @@ sh_expand_prologue (void) /* If we're supposed to switch stacks at function entry, do so now. */ if (sp_switch_attr) { - rtx lab, newsrc; + rtx newsrc; /* The argument specifies a variable holding the address of the stack the interrupt function should switch to/from at entry/exit. */ tree arg = TREE_VALUE ( TREE_VALUE (sp_switch_attr)); const char* s = ggc_strdup (TREE_STRING_POINTER (arg)); rtx sp_switch = gen_rtx_SYMBOL_REF (Pmode, s); - lab = add_constant (sp_switch, SImode, 0); + rtx_code_label *lab = add_constant (sp_switch, SImode, 0); newsrc = gen_rtx_LABEL_REF (VOIDmode, lab); emit_insn (gen_sp_switch_1 (newsrc)); diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index 61db40f2a3a..82304cb9dbb 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -7332,8 +7332,9 @@ rtx lab = PATTERN (gen_call_site ()); sh_expand_sym_label2reg (operands[2], operands[0], lab, true); - rtx i = emit_call_insn (gen_sibcalli_pcrel_fdpic (operands[2], operands[1], - copy_rtx (lab))); + rtx_insn *i + = emit_call_insn (gen_sibcalli_pcrel_fdpic (operands[2], operands[1], + copy_rtx (lab))); SIBLING_CALL_P (i) = 1; DONE; } @@ -7472,10 +7473,11 @@ rtx tmp = gen_rtx_REG (SImode, R1_REG); sh_expand_sym_label2reg (tmp, operands[1], lab, true); - rtx call_insn = emit_call_insn (gen_sibcall_valuei_pcrel (operands[0], - tmp, - operands[2], - copy_rtx (lab))); + rtx_insn *call_insn + = emit_call_insn (gen_sibcall_valuei_pcrel (operands[0], + tmp, + operands[2], + copy_rtx (lab))); SIBLING_CALL_P (call_insn) = 1; DONE; } @@ -7504,10 +7506,11 @@ rtx tmp = gen_rtx_REG (SImode, R1_REG); sh_expand_sym_label2reg (tmp, operands[1], lab, true); - rtx i = emit_call_insn (gen_sibcall_valuei_pcrel_fdpic (operands[0], - tmp, - operands[2], - copy_rtx (lab))); + rtx_insn *i + = emit_call_insn (gen_sibcall_valuei_pcrel_fdpic (operands[0], + tmp, + operands[2], + copy_rtx (lab))); SIBLING_CALL_P (i) = 1; DONE; } @@ -7838,11 +7841,11 @@ [(match_operand 0 "" "") (match_operand 1 "" "")] "" { - rtx gotsym, insn; + rtx gotsym; gotsym = gen_sym2GOT (operands[1]); PUT_MODE (gotsym, Pmode); - insn = emit_insn (gen_symGOT_load (operands[0], gotsym)); + rtx_insn *insn = emit_insn (gen_symGOT_load (operands[0], gotsym)); MEM_READONLY_P (SET_SRC (PATTERN (insn))) = 1; @@ -7859,7 +7862,7 @@ { rtx gotsym = gen_sym2GOTFUNCDESC (operands[1]); PUT_MODE (gotsym, Pmode); - rtx insn = emit_insn (gen_symGOT_load (operands[0], gotsym)); + rtx_insn *insn = emit_insn (gen_symGOT_load (operands[0], gotsym)); MEM_READONLY_P (SET_SRC (PATTERN (insn))) = 1; diff --git a/gcc/config/sh/sh_treg_combine.cc b/gcc/config/sh/sh_treg_combine.cc index 13efadcc1bb..8fa6843ef6c 100644 --- a/gcc/config/sh/sh_treg_combine.cc +++ b/gcc/config/sh/sh_treg_combine.cc @@ -593,7 +593,7 @@ private: // Adds the specified insn to the set of modified or newly added insns that // might need splitting at the end of the pass. - rtx touched_insn (rtx i); + rtx_insn *touched_insn (rtx_insn *i); // Try to invert the branch condition of the specified trace. bool try_invert_branch_condition (cbranch_trace& trace); @@ -959,8 +959,8 @@ sh_treg_combine::make_inv_ccreg_insn (void) const return i; } -rtx -sh_treg_combine::touched_insn (rtx i) +rtx_insn * +sh_treg_combine::touched_insn (rtx_insn *i) { m_touched_insns.push_back (i); return i; @@ -1078,7 +1078,7 @@ sh_treg_combine::try_combine_comparisons (cbranch_trace& trace, // Check that all ccset insns are comparisons and all comparison types in // all BBs are the same and could be combined into one single comparison. rtx comp = NULL_RTX; - rtx comp_insn = NULL_RTX; + rtx_insn *comp_insn = nullptr; for (std::list::const_iterator i = trace.bb_entries.begin (); i != trace.bb_entries.end (); ++i) diff --git a/gcc/explow.cc b/gcc/explow.cc index 134771446aa..3469b733bc9 100644 --- a/gcc/explow.cc +++ b/gcc/explow.cc @@ -2020,8 +2020,8 @@ compute_stack_clash_protection_loop_data (rtx *rounded_size, rtx *last_addr, LAST addr is the value for SP which stops the loop. */ void -emit_stack_clash_protection_probe_loop_start (rtx *loop_lab, - rtx *end_lab, +emit_stack_clash_protection_probe_loop_start (rtx_code_label **loop_lab, + rtx_code_label **end_lab, rtx last_addr, bool rotated) { @@ -2122,7 +2122,7 @@ anti_adjust_stack_and_probe_stack_clash (rtx size) } else { - rtx loop_lab, end_loop; + rtx_code_label *loop_lab, *end_loop; bool rotate_loop = CONST_INT_P (rounded_size); emit_stack_clash_protection_probe_loop_start (&loop_lab, &end_loop, last_addr, rotate_loop); diff --git a/gcc/explow.h b/gcc/explow.h index 67b29a57c18..7d3eb4f6951 100644 --- a/gcc/explow.h +++ b/gcc/explow.h @@ -81,8 +81,10 @@ extern void anti_adjust_stack_and_probe_stack_clash (rtx); protection of dynamically allocated stack space. */ extern void compute_stack_clash_protection_loop_data (rtx *, rtx *, rtx *, HOST_WIDE_INT *, rtx); -extern void emit_stack_clash_protection_probe_loop_start (rtx *, rtx *, - rtx, bool); +extern void +emit_stack_clash_protection_probe_loop_start (rtx_code_label **, + rtx_code_label **, + rtx, bool); extern void emit_stack_clash_protection_probe_loop_end (rtx, rtx, rtx, bool); diff --git a/gcc/haifa-sched.cc b/gcc/haifa-sched.cc index e0505e9db64..1382713121a 100644 --- a/gcc/haifa-sched.cc +++ b/gcc/haifa-sched.cc @@ -5477,7 +5477,7 @@ reemit_notes (rtx_insn *insn) /* Move INSN. Reemit notes if needed. Update CFG, if needed. */ static void -move_insn (rtx_insn *insn, rtx_insn *last, rtx nt) +move_insn (rtx_insn *insn, rtx_insn *last, rtx_insn *nt) { if (PREV_INSN (insn) != last) { diff --git a/gcc/optabs.cc b/gcc/optabs.cc index 3b7cf55a81b..91771fc34fc 100644 --- a/gcc/optabs.cc +++ b/gcc/optabs.cc @@ -7225,7 +7225,7 @@ find_cc_set (rtx x, const_rtx pat, void *data) loop was generated successfully. */ static bool -expand_compare_and_swap_loop (rtx mem, rtx old_reg, rtx new_reg, rtx seq) +expand_compare_and_swap_loop (rtx mem, rtx old_reg, rtx new_reg, rtx_insn *seq) { machine_mode mode = GET_MODE (mem); rtx_code_label *label; @@ -7373,7 +7373,7 @@ maybe_emit_compare_and_swap_exchange_loop (rtx target, rtx mem, rtx val) val = force_reg (mode, val); if (!target || !register_operand (target, mode)) target = gen_reg_rtx (mode); - if (expand_compare_and_swap_loop (mem, target, val, NULL_RTX)) + if (expand_compare_and_swap_loop (mem, target, val, nullptr)) return target; else delete_insns_since (start); -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:38:00 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:38:00 -0500 Subject: [PATCH 19/25] Use rtx_insn * where it always is one In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-20-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * config/aarch64/aarch64.md (doloop_end): Use an rtx_insn *. * config/c6x/c6x.cc (insn_set_clock, insn_get_clock): Pass an rtx_insn *. * config/ia64/ia64.cc (ia64_gen_spec_load): Likewise. * config/mips/mips.cc (mips16_copy_fpr_return_value): Use an rtx_insn *. * config/rs6000/rs6000.md (allocate_stack): Likewise. * config/s390/s390.cc (s390_find_execute): Pass an rtx_insn *. * config/sh/sh.md (sibcall_pcrel): Use an rtx_insn *. * var-tracking.cc (reemit_marker_as_note): Use an rtx_note *. --- gcc/config/aarch64/aarch64.md | 2 +- gcc/config/c6x/c6x.cc | 4 ++-- gcc/config/ia64/ia64.cc | 2 +- gcc/config/mips/mips.cc | 3 ++- gcc/config/rs6000/rs6000.md | 3 ++- gcc/config/s390/s390.cc | 2 +- gcc/config/sh/sh.md | 2 +- gcc/var-tracking.cc | 2 +- 8 files changed, 11 insertions(+), 9 deletions(-) diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 8d0e50db272..98239223098 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -8538,7 +8538,7 @@ rtx bcomp; rtx loc_ref; rtx cc_reg; - rtx insn; + rtx_insn *insn; rtx cmp; /* Currently SMS relies on the do-loop pattern to recognize loops diff --git a/gcc/config/c6x/c6x.cc b/gcc/config/c6x/c6x.cc index 936f3c88593..49ff3087ed6 100644 --- a/gcc/config/c6x/c6x.cc +++ b/gcc/config/c6x/c6x.cc @@ -3695,7 +3695,7 @@ record_jump (int cycle, rtx cond) /* Set the clock cycle of INSN to CYCLE. Also clears the insn's entry in new_conditions. */ static void -insn_set_clock (rtx insn, int cycle) +insn_set_clock (rtx_insn *insn, int cycle) { unsigned uid = INSN_UID (insn); @@ -3717,7 +3717,7 @@ insn_uid_get_clock (int uid) /* Return the clock cycle we set for INSN. */ static int -insn_get_clock (rtx insn) +insn_get_clock (rtx_insn *insn) { return insn_uid_get_clock (INSN_UID (insn)); } diff --git a/gcc/config/ia64/ia64.cc b/gcc/config/ia64/ia64.cc index 9ee3ab5ed40..221388c43c8 100644 --- a/gcc/config/ia64/ia64.cc +++ b/gcc/config/ia64/ia64.cc @@ -8334,7 +8334,7 @@ ia64_get_insn_checked_ds (rtx_insn *insn) MODE_NO and with ZERO_EXTEND (if EXTEND_P is true). If GEN_P is false, just calculate the index of needed speculation check. */ static rtx -ia64_gen_spec_load (rtx insn, ds_t ts, int mode_no) +ia64_gen_spec_load (rtx_insn *insn, ds_t ts, int mode_no) { rtx pat, new_pat; gen_func_t gen_load; diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc index 31afbb22eb0..1f918d51c45 100644 --- a/gcc/config/mips/mips.cc +++ b/gcc/config/mips/mips.cc @@ -7865,7 +7865,8 @@ mips16_build_function_stub (void) static void mips16_copy_fpr_return_value (void) { - rtx fn, insn, retval; + rtx fn, retval; + rtx_insn *insn; tree return_type; machine_mode return_mode; const char *name; diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 135e21ea99f..7fc5d745a89 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -11108,7 +11108,8 @@ rtx chain = gen_reg_rtx (Pmode); rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx); rtx neg_op0; - rtx insn, par, set, mem; + rtx_insn *insn; + rtx par, set, mem; /* By allowing reg_or_cint_operand as the predicate we can get better code for stack-clash-protection because we do not lose diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index a73cc5cdf66..fb17029bac3 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -9950,7 +9950,7 @@ s390_execute_label (rtx insn) the pool to the location of the execute target. */ static rtx -s390_find_execute (struct constant_pool *pool, rtx insn) +s390_find_execute (struct constant_pool *pool, rtx_insn *insn) { struct constant *c; diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index 82304cb9dbb..1f5830ba3af 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -7303,7 +7303,7 @@ [(const_int 0)] { rtx lab = PATTERN (gen_call_site ()); - rtx call_insn; + rtx_insn *call_insn; sh_expand_sym_label2reg (operands[2], operands[0], lab, true); call_insn = emit_call_insn (gen_sibcalli_pcrel (operands[2], operands[1], diff --git a/gcc/var-tracking.cc b/gcc/var-tracking.cc index a24de59c2a3..9781dd33de2 100644 --- a/gcc/var-tracking.cc +++ b/gcc/var-tracking.cc @@ -10025,7 +10025,7 @@ reemit_marker_as_note (rtx_insn *insn) case NOTE_INSN_BEGIN_STMT: case NOTE_INSN_INLINE_ENTRY: { - rtx_insn *note = NULL; + rtx_note *note = NULL; if (cfun->debug_nonbind_markers) { note = emit_note_before (kind, insn); -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:38:01 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:38:01 -0500 Subject: [PATCH 20/25] Pass an rtx_insn * to update_reg_unused_notes In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-21-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * reorg.cc (update_reg_unused_notes): Take an rtx_insn *. (fill_slots_from_thread): Keep the scan cursor in an rtx_insn *. --- gcc/reorg.cc | 63 ++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/gcc/reorg.cc b/gcc/reorg.cc index 07f8115a337..7412fb1dbcb 100644 --- a/gcc/reorg.cc +++ b/gcc/reorg.cc @@ -213,7 +213,7 @@ static void update_block (rtx_insn *, rtx_insn *); static bool reorg_redirect_jump (rtx_jump_insn *, rtx); static void update_reg_dead_notes (rtx_insn *, rtx_insn *); static void fix_reg_dead_note (rtx_insn *, rtx_insn *); -static void update_reg_unused_notes (rtx_insn *, rtx); +static void update_reg_unused_notes (rtx_insn *, rtx_insn *); static void fill_simple_delay_slots (bool); static void fill_slots_from_thread (rtx_jump_insn *, rtx, rtx, rtx, bool, bool, bool, int, @@ -1734,7 +1734,7 @@ fix_reg_dead_note (rtx_insn *start_insn, rtx_insn *stop_insn) make sure that INSN calculates as many results as OTHER_INSN does. */ static void -update_reg_unused_notes (rtx_insn *insn, rtx other_insn) +update_reg_unused_notes (rtx_insn *insn, rtx_insn *other_insn) { rtx link, next; @@ -2274,7 +2274,7 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition, bool thread_if_true, bool own_thread, int slots_to_fill, int *pslots_filled, vec *delay_list) { - rtx new_thread; + rtx_insn *new_thread; struct resources opposite_needed, set, needed; rtx_insn *trial; bool lose = false; @@ -2528,8 +2528,7 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition, to call update_block and delete_insn. */ fix_reg_dead_note (prior_insn, insn); update_reg_unused_notes (prior_insn, new_thread); - new_thread - = next_active_insn (as_a (new_thread)); + new_thread = next_active_insn (new_thread); } break; } @@ -2593,6 +2592,8 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition, } } + /* Past here the thread can be a RETURN or a label. */ + rtx thread_tail = new_thread; /* If we stopped on a branch insn that has delay slots, see if we can steal some of the insns in those slots. */ if (trial && NONJUMP_INSN_P (trial) @@ -2602,17 +2603,17 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition, rtx_sequence *sequence = as_a (PATTERN (trial)); /* If this is the `true' thread, we will want to follow the jump, so we can only do this if we have taken everything up to here. */ - if (thread_if_true && trial == new_thread) + if (thread_if_true && trial == thread_tail) { steal_delay_list_from_target (insn, condition, sequence, delay_list, &set, &needed, &opposite_needed, slots_to_fill, pslots_filled, &must_annul, - &new_thread); + &thread_tail); /* If we owned the thread and are told that it branched elsewhere, make sure we own the thread at the new location. */ - if (own_thread && trial != new_thread) - own_thread = own_thread_p (new_thread, new_thread, false); + if (own_thread && trial != thread_tail) + own_thread = own_thread_p (thread_tail, thread_tail, false); } else if (! thread_if_true) steal_delay_list_from_fallthrough (insn, condition, sequence, @@ -2628,19 +2629,19 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition, arithmetic insn after the jump insn and put the arithmetic insn in the delay slot. If we can't do this, return. */ if (delay_list->is_empty () && likely - && new_thread - && !ANY_RETURN_P (new_thread) - && NONJUMP_INSN_P (new_thread) - && !RTX_FRAME_RELATED_P (new_thread) - && GET_CODE (PATTERN (new_thread)) != ASM_INPUT - && asm_noperands (PATTERN (new_thread)) < 0) + && thread_tail + && !ANY_RETURN_P (thread_tail) + && NONJUMP_INSN_P (thread_tail) + && !RTX_FRAME_RELATED_P (thread_tail) + && GET_CODE (PATTERN (thread_tail)) != ASM_INPUT + && asm_noperands (PATTERN (thread_tail)) < 0) { rtx dest; rtx src; - /* We know "new_thread" is an insn due to NONJUMP_INSN_P (new_thread) + /* We know "thread_tail" is an insn due to NONJUMP_INSN_P (thread_tail) above. */ - trial = as_a (new_thread); + trial = as_a (thread_tail); rtx pat = PATTERN (trial); if (!NONJUMP_INSN_P (trial) @@ -2687,13 +2688,13 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition, if (trial == thread) { thread = next_active_insn (thread); - if (new_thread == trial) - new_thread = thread; + if (thread_tail == trial) + thread_tail = thread; } delete_related_insns (trial); } else - new_thread = next_active_insn (trial); + thread_tail = next_active_insn (trial); ninsn = own_thread ? trial : copy_delay_slot_insn (trial); if (thread_if_true) @@ -2710,28 +2711,28 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition, /* If we are to branch into the middle of this thread, find an appropriate label or make a new one if none, and redirect INSN to it. If we hit the end of the function, use the end-of-function label. */ - if (new_thread != thread) + if (thread_tail != thread) { rtx label; bool crossing = false; gcc_assert (thread_if_true); - if (new_thread - && simplejump_or_return_p (new_thread) + if (thread_tail + && simplejump_or_return_p (thread_tail) && redirect_with_delay_list_safe_p (insn, - JUMP_LABEL (new_thread), + JUMP_LABEL (thread_tail), *delay_list)) - new_thread = follow_jumps (JUMP_LABEL (new_thread), insn, &crossing); + thread_tail = follow_jumps (JUMP_LABEL (thread_tail), insn, &crossing); - if (!new_thread) + if (!thread_tail) label = find_end_label (simple_return_rtx); - else if (ANY_RETURN_P (new_thread)) - label = find_end_label (new_thread); - else if (LABEL_P (new_thread)) - label = new_thread; + else if (ANY_RETURN_P (thread_tail)) + label = find_end_label (thread_tail); + else if (LABEL_P (thread_tail)) + label = thread_tail; else - label = get_label_before (as_a (new_thread), + label = get_label_before (as_a (thread_tail), JUMP_LABEL (insn)); if (label) -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:37:59 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:37:59 -0500 Subject: [PATCH 18/25] Split locals that are overwritten with a different rtx In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-19-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * config/alpha/alpha.cc (alpha_expand_mov_safe_bwa, alpha_expand_unaligned_store_safe_partial, alpha_expand_unaligned_store_words_safe_partial, alpha_expand_clear_safe_partial_nobwx, alpha_split_atomic_op, alpha_split_compare_and_swap, alpha_split_compare_and_swap_12, alpha_split_atomic_exchange, alpha_split_atomic_exchange_12): Keep the code label separate from the LABEL_REF. * config/arc/arc.cc (arc_expand_atomic_op): Likewise. * config/or1k/or1k.cc (or1k_expand_atomic_compare_and_swap, or1k_expand_atomic_compare_and_swap_qihi, or1k_expand_atomic_exchange, or1k_expand_atomic_exchange_qihi, or1k_expand_atomic_op, or1k_expand_atomic_op_qihi): Likewise. * config/or1k/or1k.md (*cmov): Likewise. * config/rs6000/rs6000.cc (rs6000_expand_atomic_compare_and_swap, rs6000_expand_atomic_exchange, rs6000_expand_atomic_op): Likewise. * config/s390/s390.md (indirect_jump, casesi_jump): Likewise. * config/arm/aarch-common.cc (arm_mac_accumulator_is_result): Keep the producer and consumer patterns in separate locals. * config/arm/aarch-common-protos.h (arm_mac_accumulator_is_result): Pass an rtx_insn *. * config/arm/arm.cc (emit_multi_reg_push): Keep the PARALLEL separate from the emitted insn. * config/c6x/c6x.cc (reorg_split_calls): Keep each pattern separate from the emitted insn. * config/ia64/ia64.cc (ia64_spec_check_p): Keep the pattern in a separate local. * config/nds32/nds32-relax-opt.cc (nds32_pic_tls_symbol_type): Likewise. * config/rx/rx.cc (mark_frame_related): Likewise. --- gcc/config/alpha/alpha.cc | 118 +++++++++++++++------------ gcc/config/arc/arc.cc | 8 +- gcc/config/arm/aarch-common-protos.h | 2 +- gcc/config/arm/aarch-common.cc | 40 ++++----- gcc/config/arm/arm.cc | 14 ++-- gcc/config/c6x/c6x.cc | 33 ++++---- gcc/config/ia64/ia64.cc | 6 +- gcc/config/nds32/nds32-relax-opt.cc | 4 +- gcc/config/or1k/or1k.cc | 71 ++++++++-------- gcc/config/or1k/or1k.md | 9 +- gcc/config/rs6000/rs6000.cc | 37 +++++---- gcc/config/rx/rx.cc | 10 +-- gcc/config/s390/s390.md | 6 +- 13 files changed, 195 insertions(+), 163 deletions(-) diff --git a/gcc/config/alpha/alpha.cc b/gcc/config/alpha/alpha.cc index bcf756cfd03..d0fb7eee92f 100644 --- a/gcc/config/alpha/alpha.cc +++ b/gcc/config/alpha/alpha.cc @@ -2427,8 +2427,9 @@ alpha_expand_mov_safe_bwa (machine_mode mode, rtx *operands) { if (aligned_memory_operand (operands[0], mode)) { - rtx label = gen_rtx_LABEL_REF (DImode, gen_label_rtx ()); - emit_label (XEXP (label, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (DImode, label); + emit_label (label); rtx aligned_mem, bitnum; rtx status = gen_reg_rtx (SImode); @@ -2440,7 +2441,7 @@ alpha_expand_mov_safe_bwa (machine_mode mode, rtx *operands) rtx cond = gen_rtx_EQ (DImode, gen_rtx_SUBREG (DImode, status, 0), const0_rtx); - alpha_emit_unlikely_jump (cond, label); + alpha_emit_unlikely_jump (cond, label_ref); } else { @@ -2451,8 +2452,9 @@ alpha_expand_mov_safe_bwa (machine_mode mode, rtx *operands) emit_insn (gen_rtx_SET (aligned_addr, gen_rtx_AND (DImode, addr, GEN_INT (-8)))); - rtx label = gen_rtx_LABEL_REF (DImode, gen_label_rtx ()); - emit_label (XEXP (label, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (DImode, label); + emit_label (label); rtx status = gen_reg_rtx (DImode); rtx temp = gen_reg_rtx (DImode); @@ -2462,7 +2464,7 @@ alpha_expand_mov_safe_bwa (machine_mode mode, rtx *operands) emit_insn (seq); rtx cond = gen_rtx_EQ (DImode, status, const0_rtx); - alpha_emit_unlikely_jump (cond, label); + alpha_emit_unlikely_jump (cond, label_ref); } return true; } @@ -3916,8 +3918,9 @@ alpha_expand_unaligned_store_safe_partial (rtx dst, rtx src, gcc_unreachable (); } - rtx labelh = gen_rtx_LABEL_REF (DImode, gen_label_rtx ()); - emit_label (XEXP (labelh, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (DImode, label); + emit_label (label); rtx dsth = gen_reg_rtx (DImode); emit_insn (gen_load_locked (DImode, dsth, memh)); @@ -3951,7 +3954,8 @@ alpha_expand_unaligned_store_safe_partial (rtx dst, rtx src, emit_insn (gen_store_conditional (DImode, dsth, memh, dsth)); - alpha_emit_unlikely_jump (gen_rtx_EQ (DImode, dsth, const0_rtx), labelh); + alpha_emit_unlikely_jump (gen_rtx_EQ (DImode, dsth, const0_rtx), + label_ref); } /* Now handle low. */ @@ -4023,8 +4027,9 @@ alpha_expand_unaligned_store_safe_partial (rtx dst, rtx src, gcc_unreachable (); } - rtx labell = gen_rtx_LABEL_REF (DImode, gen_label_rtx ()); - emit_label (XEXP (labell, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (DImode, label); + emit_label (label); rtx dstl = gen_reg_rtx (DImode); emit_insn (gen_load_locked (DImode, dstl, meml)); @@ -4062,7 +4067,7 @@ alpha_expand_unaligned_store_safe_partial (rtx dst, rtx src, emit_insn (gen_store_conditional (DImode, dstl, meml, dstl)); - alpha_emit_unlikely_jump (gen_rtx_EQ (DImode, dstl, const0_rtx), labell); + alpha_emit_unlikely_jump (gen_rtx_EQ (DImode, dstl, const0_rtx), label_ref); } /* The block move code tries to maximize speed by separating loads and @@ -4293,8 +4298,9 @@ alpha_expand_unaligned_store_words_safe_partial (rtx *data_regs, rtx dmem, expand_simple_binop (Pmode, AND, dreg, im8, NULL_RTX, 1, OPTAB_DIRECT)); - rtx label = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); - emit_label (XEXP (label, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label); + emit_label (label); emit_insn (gen_load_locked (DImode, temp, mem)); emit_insn (gen_mskql (temp, temp, dreg)); @@ -4303,7 +4309,8 @@ alpha_expand_unaligned_store_words_safe_partial (rtx *data_regs, rtx dmem, temp, 1, OPTAB_DIRECT); emit_insn (gen_store_conditional (DImode, temp, mem, temp)); - alpha_emit_unlikely_jump (gen_rtx_EQ (DImode, temp, const0_rtx), label); + alpha_emit_unlikely_jump (gen_rtx_EQ (DImode, temp, const0_rtx), + label_ref); } for (i = words - 1; i > 0; --i) @@ -4327,8 +4334,9 @@ alpha_expand_unaligned_store_words_safe_partial (rtx *data_regs, rtx dmem, expand_simple_binop (Pmode, AND, addr, im8, NULL_RTX, 1, OPTAB_DIRECT)); - rtx label = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); - emit_label (XEXP (label, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label); + emit_label (label); emit_insn (gen_load_locked (DImode, temp, mem)); emit_insn (gen_mskqh (temp, temp, dreg)); @@ -4337,7 +4345,8 @@ alpha_expand_unaligned_store_words_safe_partial (rtx *data_regs, rtx dmem, temp, 1, OPTAB_DIRECT); emit_insn (gen_store_conditional (DImode, temp, mem, temp)); - alpha_emit_unlikely_jump (gen_rtx_EQ (DImode, temp, const0_rtx), label); + alpha_emit_unlikely_jump (gen_rtx_EQ (DImode, temp, const0_rtx), + label_ref); } } @@ -4755,8 +4764,9 @@ static void alpha_expand_clear_safe_partial_nobwx (rtx mem, machine_mode mode, HOST_WIDE_INT mask) { - rtx label = gen_rtx_LABEL_REF (DImode, gen_label_rtx ()); - emit_label (XEXP (label, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (DImode, label); + emit_label (label); rtx temp = gen_reg_rtx (mode); rtx status = mode == DImode ? temp : gen_rtx_SUBREG (DImode, temp, 0); @@ -4765,7 +4775,7 @@ alpha_expand_clear_safe_partial_nobwx (rtx mem, machine_mode mode, emit_insn (gen_rtx_SET (temp, gen_rtx_AND (mode, temp, GEN_INT (mask)))); emit_insn (gen_store_conditional (mode, status, mem, temp)); - alpha_emit_unlikely_jump (gen_rtx_EQ (DImode, status, const0_rtx), label); + alpha_emit_unlikely_jump (gen_rtx_EQ (DImode, status, const0_rtx), label_ref); } int @@ -5190,13 +5200,13 @@ alpha_split_atomic_op (enum rtx_code code, rtx mem, rtx val, rtx before, rtx after, rtx scratch, enum memmodel model) { machine_mode mode = GET_MODE (mem); - rtx label, x, cond = gen_rtx_REG (DImode, REGNO (scratch)); + rtx x, cond = gen_rtx_REG (DImode, REGNO (scratch)); alpha_pre_atomic_barrier (model); - label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); emit_label (label); - label = gen_rtx_LABEL_REF (DImode, label); + rtx label_ref = gen_rtx_LABEL_REF (DImode, label); if (before == NULL) before = scratch; @@ -5218,7 +5228,7 @@ alpha_split_atomic_op (enum rtx_code code, rtx mem, rtx val, rtx before, emit_insn (gen_store_conditional (mode, cond, mem, scratch)); x = gen_rtx_EQ (DImode, cond, const0_rtx); - alpha_emit_unlikely_jump (x, label); + alpha_emit_unlikely_jump (x, label_ref); alpha_post_atomic_barrier (model); } @@ -5232,7 +5242,7 @@ alpha_split_compare_and_swap (rtx operands[]) bool is_weak; enum memmodel mod_s, mod_f; machine_mode mode; - rtx label1, label2, x; + rtx label_ref1, x; cond = operands[0]; retval = operands[1]; @@ -5246,13 +5256,15 @@ alpha_split_compare_and_swap (rtx operands[]) alpha_pre_atomic_barrier (mod_s); - label1 = NULL_RTX; + label_ref1 = NULL_RTX; if (!is_weak) { - label1 = gen_rtx_LABEL_REF (DImode, gen_label_rtx ()); - emit_label (XEXP (label1, 0)); + rtx_code_label *label1 = gen_label_rtx (); + label_ref1 = gen_rtx_LABEL_REF (DImode, label1); + emit_label (label1); } - label2 = gen_rtx_LABEL_REF (DImode, gen_label_rtx ()); + rtx_code_label *label2 = gen_label_rtx (); + rtx label_ref2 = gen_rtx_LABEL_REF (DImode, label2); emit_insn (gen_load_locked (mode, retval, mem)); @@ -5268,7 +5280,7 @@ alpha_split_compare_and_swap (rtx operands[]) emit_insn (gen_rtx_SET (cond, x)); x = gen_rtx_EQ (DImode, cond, const0_rtx); } - alpha_emit_unlikely_jump (x, label2); + alpha_emit_unlikely_jump (x, label_ref2); emit_move_insn (cond, newval); emit_insn (gen_store_conditional @@ -5277,16 +5289,16 @@ alpha_split_compare_and_swap (rtx operands[]) if (!is_weak) { x = gen_rtx_EQ (DImode, cond, const0_rtx); - alpha_emit_unlikely_jump (x, label1); + alpha_emit_unlikely_jump (x, label_ref1); } if (!is_mm_relaxed (mod_f)) - emit_label (XEXP (label2, 0)); + emit_label (label2); alpha_post_atomic_barrier (mod_s); if (is_mm_relaxed (mod_f)) - emit_label (XEXP (label2, 0)); + emit_label (label2); } void @@ -5333,7 +5345,7 @@ alpha_split_compare_and_swap_12 (rtx operands[]) machine_mode mode; bool is_weak; enum memmodel mod_s, mod_f; - rtx label1, label2, mem, addr, width, mask, x; + rtx label_ref1, mem, addr, width, mask, x; cond = operands[0]; dest = operands[1]; @@ -5355,13 +5367,15 @@ alpha_split_compare_and_swap_12 (rtx operands[]) alpha_pre_atomic_barrier (mod_s); - label1 = NULL_RTX; + label_ref1 = NULL_RTX; if (!is_weak) { - label1 = gen_rtx_LABEL_REF (DImode, gen_label_rtx ()); - emit_label (XEXP (label1, 0)); + rtx_code_label *label1 = gen_label_rtx (); + label_ref1 = gen_rtx_LABEL_REF (DImode, label1); + emit_label (label1); } - label2 = gen_rtx_LABEL_REF (DImode, gen_label_rtx ()); + rtx_code_label *label2 = gen_label_rtx (); + rtx label_ref2 = gen_rtx_LABEL_REF (DImode, label2); emit_insn (gen_load_locked (DImode, scratch, mem)); @@ -5380,7 +5394,7 @@ alpha_split_compare_and_swap_12 (rtx operands[]) emit_insn (gen_rtx_SET (cond, x)); x = gen_rtx_EQ (DImode, cond, const0_rtx); } - alpha_emit_unlikely_jump (x, label2); + alpha_emit_unlikely_jump (x, label_ref2); emit_insn (gen_mskxl (cond, scratch, mask, addr)); @@ -5392,16 +5406,16 @@ alpha_split_compare_and_swap_12 (rtx operands[]) if (!is_weak) { x = gen_rtx_EQ (DImode, cond, const0_rtx); - alpha_emit_unlikely_jump (x, label1); + alpha_emit_unlikely_jump (x, label_ref1); } if (!is_mm_relaxed (mod_f)) - emit_label (XEXP (label2, 0)); + emit_label (label2); alpha_post_atomic_barrier (mod_s); if (is_mm_relaxed (mod_f)) - emit_label (XEXP (label2, 0)); + emit_label (label2); } /* Expand an atomic exchange operation. */ @@ -5412,7 +5426,7 @@ alpha_split_atomic_exchange (rtx operands[]) rtx retval, mem, val, scratch; enum memmodel model; machine_mode mode; - rtx label, x, cond; + rtx x, cond; retval = operands[0]; mem = operands[1]; @@ -5424,15 +5438,16 @@ alpha_split_atomic_exchange (rtx operands[]) alpha_pre_atomic_barrier (model); - label = gen_rtx_LABEL_REF (DImode, gen_label_rtx ()); - emit_label (XEXP (label, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (DImode, label); + emit_label (label); emit_insn (gen_load_locked (mode, retval, mem)); emit_move_insn (scratch, val); emit_insn (gen_store_conditional (mode, cond, mem, scratch)); x = gen_rtx_EQ (DImode, cond, const0_rtx); - alpha_emit_unlikely_jump (x, label); + alpha_emit_unlikely_jump (x, label_ref); alpha_post_atomic_barrier (model); } @@ -5471,7 +5486,7 @@ void alpha_split_atomic_exchange_12 (rtx operands[]) { rtx dest, orig_mem, addr, val, align, scratch; - rtx label, mem, width, mask, x; + rtx mem, width, mask, x; machine_mode mode; enum memmodel model; @@ -5491,8 +5506,9 @@ alpha_split_atomic_exchange_12 (rtx operands[]) alpha_pre_atomic_barrier (model); - label = gen_rtx_LABEL_REF (DImode, gen_label_rtx ()); - emit_label (XEXP (label, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (DImode, label); + emit_label (label); emit_insn (gen_load_locked (DImode, scratch, mem)); @@ -5506,7 +5522,7 @@ alpha_split_atomic_exchange_12 (rtx operands[]) emit_insn (gen_store_conditional (DImode, scratch, mem, scratch)); x = gen_rtx_EQ (DImode, scratch, const0_rtx); - alpha_emit_unlikely_jump (x, label); + alpha_emit_unlikely_jump (x, label_ref); alpha_post_atomic_barrier (model); } diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc index d735024dff7..d22f9c70e28 100644 --- a/gcc/config/arc/arc.cc +++ b/gcc/config/arc/arc.cc @@ -10606,7 +10606,7 @@ arc_expand_atomic_op (enum rtx_code code, rtx mem, rtx val, { enum memmodel model = (enum memmodel) INTVAL (model_rtx); machine_mode mode = GET_MODE (mem); - rtx label, x, cond; + rtx x, cond; rtx before = orig_before, after = orig_after; /* ARC atomic ops work only with 32-bit aligned memories. */ @@ -10614,9 +10614,9 @@ arc_expand_atomic_op (enum rtx_code code, rtx mem, rtx val, arc_pre_atomic_barrier (model); - label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); emit_label (label); - label = gen_rtx_LABEL_REF (VOIDmode, label); + rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label); if (before == NULL_RTX) before = gen_reg_rtx (mode); @@ -10657,7 +10657,7 @@ arc_expand_atomic_op (enum rtx_code code, rtx mem, rtx val, cond = gen_rtx_REG (CC_Zmode, CC_REG); x = gen_rtx_NE (VOIDmode, cond, const0_rtx); x = gen_rtx_IF_THEN_ELSE (VOIDmode, x, - label, pc_rtx); + label_ref, pc_rtx); emit_unlikely_jump (gen_rtx_SET (pc_rtx, x)); arc_post_atomic_barrier (model); diff --git a/gcc/config/arm/aarch-common-protos.h b/gcc/config/arm/aarch-common-protos.h index 93e25d026cd..2ddc1a106e4 100644 --- a/gcc/config/arm/aarch-common-protos.h +++ b/gcc/config/arm/aarch-common-protos.h @@ -36,7 +36,7 @@ extern int arm_early_load_addr_dep_ptr (rtx_insn *, rtx_insn *); extern int arm_early_store_addr_dep (rtx_insn *, rtx_insn *); extern int arm_early_store_addr_dep_ptr (rtx_insn *, rtx_insn *); extern int arm_mac_accumulator_is_mul_result (rtx_insn *, rtx_insn *); -extern int arm_mac_accumulator_is_result (rtx, rtx); +extern int arm_mac_accumulator_is_result (rtx_insn *, rtx_insn *); extern int arm_no_early_alu_shift_dep (rtx_insn *, rtx_insn *); extern int arm_no_early_alu_shift_value_dep (rtx_insn *, rtx_insn *); extern int arm_no_early_mul_dep (rtx_insn *, rtx_insn *); diff --git a/gcc/config/arm/aarch-common.cc b/gcc/config/arm/aarch-common.cc index e80bc196103..54f79540f47 100644 --- a/gcc/config/arm/aarch-common.cc +++ b/gcc/config/arm/aarch-common.cc @@ -365,48 +365,48 @@ arm_early_store_addr_dep_ptr (rtx_insn *producer, rtx_insn *consumer) result of the producer and no other dependency on that result. It does not check if the producer is multiply-accumulate instruction. */ int -arm_mac_accumulator_is_result (rtx producer, rtx consumer) +arm_mac_accumulator_is_result (rtx_insn *producer, rtx_insn *consumer) { rtx result; rtx op0, op1, acc; - producer = PATTERN (producer); - consumer = PATTERN (consumer); + rtx producer_pat = PATTERN (producer); + rtx consumer_pat = PATTERN (consumer); - if (GET_CODE (producer) == COND_EXEC) - producer = COND_EXEC_CODE (producer); - if (GET_CODE (consumer) == COND_EXEC) - consumer = COND_EXEC_CODE (consumer); + if (GET_CODE (producer_pat) == COND_EXEC) + producer_pat = COND_EXEC_CODE (producer_pat); + if (GET_CODE (consumer_pat) == COND_EXEC) + consumer_pat = COND_EXEC_CODE (consumer_pat); - if (GET_CODE (producer) != SET) + if (GET_CODE (producer_pat) != SET) return 0; - result = XEXP (producer, 0); + result = XEXP (producer_pat, 0); - if (GET_CODE (consumer) != SET) + if (GET_CODE (consumer_pat) != SET) return 0; /* Check that the consumer is of the form (set (...) (plus (mult ...) (...))) or (set (...) (minus (...) (mult ...))). */ - if (GET_CODE (XEXP (consumer, 1)) == PLUS) + if (GET_CODE (XEXP (consumer_pat, 1)) == PLUS) { - if (GET_CODE (XEXP (XEXP (consumer, 1), 0)) != MULT) + if (GET_CODE (XEXP (XEXP (consumer_pat, 1), 0)) != MULT) return 0; - op0 = XEXP (XEXP (XEXP (consumer, 1), 0), 0); - op1 = XEXP (XEXP (XEXP (consumer, 1), 0), 1); - acc = XEXP (XEXP (consumer, 1), 1); + op0 = XEXP (XEXP (XEXP (consumer_pat, 1), 0), 0); + op1 = XEXP (XEXP (XEXP (consumer_pat, 1), 0), 1); + acc = XEXP (XEXP (consumer_pat, 1), 1); } - else if (GET_CODE (XEXP (consumer, 1)) == MINUS) + else if (GET_CODE (XEXP (consumer_pat, 1)) == MINUS) { - if (GET_CODE (XEXP (XEXP (consumer, 1), 1)) != MULT) + if (GET_CODE (XEXP (XEXP (consumer_pat, 1), 1)) != MULT) return 0; - op0 = XEXP (XEXP (XEXP (consumer, 1), 1), 0); - op1 = XEXP (XEXP (XEXP (consumer, 1), 1), 1); - acc = XEXP (XEXP (consumer, 1), 0); + op0 = XEXP (XEXP (XEXP (consumer_pat, 1), 1), 0); + op1 = XEXP (XEXP (XEXP (consumer_pat, 1), 1), 1); + acc = XEXP (XEXP (consumer_pat, 1), 0); } else return 0; diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 16bad70944e..ff239312049 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -21340,7 +21340,7 @@ emit_multi_reg_push (unsigned long mask, unsigned long dwarf_regs_mask) int num_regs = 0; int num_dwarf_regs = 0; int i, j; - rtx par; + rtx_insn *par; rtx dwarf; int dwarf_par_index; rtx tmp, reg; @@ -21399,7 +21399,7 @@ emit_multi_reg_push (unsigned long mask, unsigned long dwarf_regs_mask) For more see PR43399. */ - par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (num_regs)); + rtx parallel = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (num_regs)); dwarf = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (num_dwarf_regs + 1)); dwarf_par_index = 1; @@ -21435,7 +21435,7 @@ emit_multi_reg_push (unsigned long mask, unsigned long dwarf_regs_mask) if (arm_current_function_pac_enabled_p () && i == IP_REGNUM) dwarf_reg = gen_rtx_REG (SImode, RA_AUTH_CODE); - XVECEXP (par, 0, 0) + XVECEXP (parallel, 0, 0) = gen_rtx_SET (gen_frame_mem (BLKmode, gen_rtx_PRE_MODIFY (Pmode, @@ -21468,7 +21468,7 @@ emit_multi_reg_push (unsigned long mask, unsigned long dwarf_regs_mask) if (arm_current_function_pac_enabled_p () && i == IP_REGNUM) dwarf_reg = gen_rtx_REG (SImode, RA_AUTH_CODE); - XVECEXP (par, 0, j) = gen_rtx_USE (VOIDmode, reg); + XVECEXP (parallel, 0, j) = gen_rtx_USE (VOIDmode, reg); if (dwarf_regs_mask & (1 << i)) { @@ -21486,16 +21486,16 @@ emit_multi_reg_push (unsigned long mask, unsigned long dwarf_regs_mask) } } - rtx_insn *insn = emit_insn (par); + par = emit_insn (parallel); tmp = gen_rtx_SET (stack_pointer_rtx, plus_constant (Pmode, stack_pointer_rtx, -4 * num_regs)); RTX_FRAME_RELATED_P (tmp) = 1; XVECEXP (dwarf, 0, 0) = tmp; - add_reg_note (insn, REG_FRAME_RELATED_EXPR, dwarf); + add_reg_note (par, REG_FRAME_RELATED_EXPR, dwarf); - return insn; + return par; } /* Add a REG_CFA_ADJUST_CFA REG note to INSN. diff --git a/gcc/config/c6x/c6x.cc b/gcc/config/c6x/c6x.cc index 2209b16cb5f..936f3c88593 100644 --- a/gcc/config/c6x/c6x.cc +++ b/gcc/config/c6x/c6x.cc @@ -4938,13 +4938,14 @@ reorg_split_calls (rtx_code_label **call_labels) if (TARGET_INSNS_64) { rtx x1 = gen_addkpc (reg, labelref, const0_rtx); - x1 = emit_insn_after (duplicate_cond (x1, insn), after1); - insn_set_clock (x1, this_clock + 1); - INSN_INFO_ENTRY (INSN_UID (x1)).reservation = RESERVATION_S2; + rtx_insn *i1 + = emit_insn_after (duplicate_cond (x1, insn), after1); + insn_set_clock (i1, this_clock + 1); + INSN_INFO_ENTRY (INSN_UID (i1)).reservation = RESERVATION_S2; if (after1 == last_same_clock) - PUT_MODE (x1, TImode); + PUT_MODE (i1, TImode); else - INSN_INFO_ENTRY (INSN_UID (x1)).unit_mask + INSN_INFO_ENTRY (INSN_UID (i1)).unit_mask = INSN_INFO_ENTRY (INSN_UID (after1)).unit_mask; } else @@ -4955,22 +4956,24 @@ reorg_split_calls (rtx_code_label **call_labels) if (after2 == NULL_RTX) after2 = after1; x2 = gen_movsi_lo_sum (reg, reg, labelref); - x2 = emit_insn_after (duplicate_cond (x2, insn), after2); + rtx_insn *i2 + = emit_insn_after (duplicate_cond (x2, insn), after2); x1 = gen_movsi_high (reg, labelref); - x1 = emit_insn_after (duplicate_cond (x1, insn), after1); - insn_set_clock (x1, this_clock + 1); - insn_set_clock (x2, this_clock + 2); - INSN_INFO_ENTRY (INSN_UID (x1)).reservation = RESERVATION_S2; - INSN_INFO_ENTRY (INSN_UID (x2)).reservation = RESERVATION_S2; + rtx_insn *i1 + = emit_insn_after (duplicate_cond (x1, insn), after1); + insn_set_clock (i1, this_clock + 1); + insn_set_clock (i2, this_clock + 2); + INSN_INFO_ENTRY (INSN_UID (i1)).reservation = RESERVATION_S2; + INSN_INFO_ENTRY (INSN_UID (i2)).reservation = RESERVATION_S2; if (after1 == last_same_clock) - PUT_MODE (x1, TImode); + PUT_MODE (i1, TImode); else - INSN_INFO_ENTRY (INSN_UID (x1)).unit_mask + INSN_INFO_ENTRY (INSN_UID (i1)).unit_mask = INSN_INFO_ENTRY (INSN_UID (after1)).unit_mask; if (after1 == after2) - PUT_MODE (x2, TImode); + PUT_MODE (i2, TImode); else - INSN_INFO_ENTRY (INSN_UID (x2)).unit_mask + INSN_INFO_ENTRY (INSN_UID (i2)).unit_mask = INSN_INFO_ENTRY (INSN_UID (after2)).unit_mask; } } diff --git a/gcc/config/ia64/ia64.cc b/gcc/config/ia64/ia64.cc index 9ed9118b435..9ee3ab5ed40 100644 --- a/gcc/config/ia64/ia64.cc +++ b/gcc/config/ia64/ia64.cc @@ -178,7 +178,7 @@ static bool ia64_skip_rtx_p (const_rtx); static int ia64_speculate_insn (rtx_insn *, ds_t, rtx *); static bool ia64_needs_block_p (ds_t); static rtx ia64_gen_spec_check (rtx_insn *, rtx_insn *, ds_t); -static int ia64_spec_check_p (rtx); +static int ia64_spec_check_p (rtx_insn *); static int ia64_spec_check_src_p (rtx); static rtx gen_tls_get_addr (void); static rtx gen_thread_pointer (void); @@ -8573,9 +8573,9 @@ ia64_gen_spec_check (rtx_insn *insn, rtx_insn *label, ds_t ds) /* Return nonzero, if X is branchy recovery check. */ static int -ia64_spec_check_p (rtx x) +ia64_spec_check_p (rtx_insn *insn) { - x = PATTERN (x); + rtx x = PATTERN (insn); if (GET_CODE (x) == COND_EXEC) x = COND_EXEC_CODE (x); if (GET_CODE (x) == SET) diff --git a/gcc/config/nds32/nds32-relax-opt.cc b/gcc/config/nds32/nds32-relax-opt.cc index 0ce43df5bb7..e742f61fa2b 100644 --- a/gcc/config/nds32/nds32-relax-opt.cc +++ b/gcc/config/nds32/nds32-relax-opt.cc @@ -291,9 +291,9 @@ nds32_pic_tls_group (rtx_insn *def_insn, } static int -nds32_pic_tls_symbol_type (rtx x) +nds32_pic_tls_symbol_type (rtx_insn *insn) { - x = XEXP (SET_SRC (PATTERN (x)), 1); + rtx x = XEXP (SET_SRC (PATTERN (insn)), 1); if (GET_CODE (x) == CONST) { diff --git a/gcc/config/or1k/or1k.cc b/gcc/config/or1k/or1k.cc index 52dbb57a51c..58aba7e89b1 100644 --- a/gcc/config/or1k/or1k.cc +++ b/gcc/config/or1k/or1k.cc @@ -1837,7 +1837,7 @@ void or1k_expand_atomic_compare_and_swap (rtx operands[]) { rtx boolval, retval, mem, oldval, newval; - rtx label1, label2; + rtx label_ref1; machine_mode mode; bool is_weak; @@ -1852,24 +1852,26 @@ or1k_expand_atomic_compare_and_swap (rtx operands[]) if (reg_overlap_mentioned_p (retval, oldval)) oldval = copy_to_reg (oldval); - label1 = NULL_RTX; + label_ref1 = NULL_RTX; /* If strong, create a label to try again. */ if (!is_weak) { - label1 = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); - emit_label (XEXP (label1, 0)); + rtx_code_label *label1 = gen_label_rtx (); + label_ref1 = gen_rtx_LABEL_REF (VOIDmode, label1); + emit_label (label1); } - label2 = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); + rtx_code_label *label2 = gen_label_rtx (); + rtx label_ref2 = gen_rtx_LABEL_REF (VOIDmode, label2); emit_load_locked (mode, retval, mem); emit_compare (EQ, retval, oldval); - emit_unlikely_jump (EQ, label2); + emit_unlikely_jump (EQ, label_ref2); emit_store_conditional (mode, mem, newval); /* If strong, jump back to try again on fails. */ if (!is_weak) - emit_unlikely_jump (EQ, label1); - emit_label (XEXP (label2, 0)); + emit_unlikely_jump (EQ, label_ref1); + emit_label (label2); /* In all cases, SR_F contains 1 on success, and 0 on failure. */ emit_insn (gen_sne_sr_f (boolval)); @@ -1879,7 +1881,7 @@ void or1k_expand_atomic_compare_and_swap_qihi (rtx operands[]) { rtx boolval, orig_retval, retval, scratch, mem, oldval, newval; - rtx label1, label2, mask, shift; + rtx label_ref1, mask, shift; machine_mode mode; bool is_weak; @@ -1907,13 +1909,15 @@ or1k_expand_atomic_compare_and_swap_qihi (rtx operands[]) NULL_RTX, 1, OPTAB_LIB_WIDEN); } - label1 = NULL_RTX; + label_ref1 = NULL_RTX; if (!is_weak) { - label1 = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); - emit_label (XEXP (label1, 0)); + rtx_code_label *label1 = gen_label_rtx (); + label_ref1 = gen_rtx_LABEL_REF (VOIDmode, label1); + emit_label (label1); } - label2 = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); + rtx_code_label *label2 = gen_label_rtx (); + rtx label_ref2 = gen_rtx_LABEL_REF (VOIDmode, label2); scratch = gen_reg_rtx (SImode); emit_load_locked (SImode, scratch, mem); @@ -1924,7 +1928,7 @@ or1k_expand_atomic_compare_and_swap_qihi (rtx operands[]) scratch, 1, OPTAB_LIB_WIDEN); emit_compare (EQ, retval, oldval); - emit_unlikely_jump (EQ, label2); + emit_unlikely_jump (EQ, label_ref2); if (newval != const0_rtx) scratch = expand_binop (SImode, ior_optab, scratch, newval, @@ -1933,8 +1937,8 @@ or1k_expand_atomic_compare_and_swap_qihi (rtx operands[]) emit_store_conditional (SImode, mem, scratch); if (!is_weak) - emit_unlikely_jump (EQ, label1); - emit_label (XEXP (label2, 0)); + emit_unlikely_jump (EQ, label_ref1); + emit_label (label2); or1k_finish_atomic_subword (mode, orig_retval, retval, shift); @@ -1955,7 +1959,7 @@ or1k_expand_atomic_compare_and_swap_qihi (rtx operands[]) void or1k_expand_atomic_exchange (rtx operands[]) { - rtx retval, mem, val, label; + rtx retval, mem, val; machine_mode mode; retval = operands[0]; @@ -1966,19 +1970,20 @@ or1k_expand_atomic_exchange (rtx operands[]) if (reg_overlap_mentioned_p (retval, val)) val = copy_to_reg (val); - label = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); - emit_label (XEXP (label, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label); + emit_label (label); emit_load_locked (mode, retval, mem); emit_store_conditional (mode, mem, val); - emit_unlikely_jump (EQ, label); + emit_unlikely_jump (EQ, label_ref); } void or1k_expand_atomic_exchange_qihi (rtx operands[]) { rtx orig_retval, retval, mem, val, scratch; - rtx label, mask, shift; + rtx mask, shift; machine_mode mode; orig_retval = operands[0]; @@ -1996,8 +2001,9 @@ or1k_expand_atomic_exchange_qihi (rtx operands[]) NULL_RTX, 1, OPTAB_LIB_WIDEN); } - label = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); - emit_label (XEXP (label, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label); + emit_label (label); scratch = gen_reg_rtx (SImode); emit_load_locked (SImode, scratch, mem); @@ -2011,7 +2017,7 @@ or1k_expand_atomic_exchange_qihi (rtx operands[]) scratch, 1, OPTAB_LIB_WIDEN); emit_store_conditional (SImode, mem, scratch); - emit_unlikely_jump (EQ, label); + emit_unlikely_jump (EQ, label_ref); or1k_finish_atomic_subword (mode, orig_retval, retval, shift); } @@ -2028,10 +2034,10 @@ or1k_expand_atomic_op (rtx_code code, rtx mem, rtx val, { machine_mode mode = GET_MODE (mem); rtx before = orig_before, after = orig_after; - rtx label; - label = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); - emit_label (XEXP (label, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label); + emit_label (label); if (before == NULL_RTX) before = gen_reg_rtx (mode); @@ -2049,7 +2055,7 @@ or1k_expand_atomic_op (rtx_code code, rtx mem, rtx val, after, 1, OPTAB_LIB_WIDEN); emit_store_conditional (mode, mem, after); - emit_unlikely_jump (EQ, label); + emit_unlikely_jump (EQ, label_ref); if (orig_before) emit_move_insn (orig_before, before); @@ -2062,7 +2068,7 @@ or1k_expand_atomic_op_qihi (rtx_code code, rtx mem, rtx val, rtx orig_before, rtx orig_after) { machine_mode mode = GET_MODE (mem); - rtx label, mask, shift, x; + rtx mask, shift, x; rtx before, after, scratch; mem = or1k_adjust_atomic_subword (mem, &shift, &mask); @@ -2099,8 +2105,9 @@ or1k_expand_atomic_op_qihi (rtx_code code, rtx mem, rtx val, gcc_unreachable (); } - label = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); - emit_label (XEXP (label, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label); + emit_label (label); before = scratch = gen_reg_rtx (SImode); emit_load_locked (SImode, before, mem); @@ -2142,7 +2149,7 @@ or1k_expand_atomic_op_qihi (rtx_code code, rtx mem, rtx val, } emit_store_conditional (SImode, mem, scratch); - emit_unlikely_jump (EQ, label); + emit_unlikely_jump (EQ, label_ref); if (orig_before) or1k_finish_atomic_subword (mode, orig_before, before, shift); diff --git a/gcc/config/or1k/or1k.md b/gcc/config/or1k/or1k.md index 1af29f247d3..b43ec408f23 100644 --- a/gcc/config/or1k/or1k.md +++ b/gcc/config/or1k/or1k.md @@ -583,25 +583,26 @@ [(const_int 0)] { rtx x; - rtx label = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label); /* Generated a *cbranch pattern. */ if (rtx_equal_p (operands[0], operands[2])) { PUT_CODE (operands[3], (GET_CODE (operands[3]) == NE) ? EQ : NE); - x = gen_rtx_IF_THEN_ELSE (VOIDmode, operands[3], label, pc_rtx); + x = gen_rtx_IF_THEN_ELSE (VOIDmode, operands[3], label_ref, pc_rtx); emit_jump_insn (gen_rtx_SET (pc_rtx, x)); emit_move_insn (operands[0], operands[1]); } else { - x = gen_rtx_IF_THEN_ELSE (VOIDmode, operands[3], label, pc_rtx); + x = gen_rtx_IF_THEN_ELSE (VOIDmode, operands[3], label_ref, pc_rtx); emit_move_insn (operands[0], operands[1]); emit_jump_insn (gen_rtx_SET (pc_rtx, x)); emit_move_insn (operands[0], operands[2]); } - emit_label (XEXP (label, 0)); + emit_label (label); DONE; }) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index a0f4be91980..bdc2194d08c 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -17132,7 +17132,7 @@ void rs6000_expand_atomic_compare_and_swap (rtx operands[], bool local) { rtx boolval, retval, mem, oldval, newval, cond; - rtx label1, label2, x, mask, shift; + rtx label_ref1, x, mask, shift; machine_mode mode, orig_mode; enum memmodel mod_s, mod_f; bool is_weak; @@ -17184,13 +17184,15 @@ rs6000_expand_atomic_compare_and_swap (rtx operands[], bool local) mem = rs6000_pre_atomic_barrier (mem, mod_s); - label1 = NULL_RTX; + label_ref1 = NULL_RTX; if (!is_weak) { - label1 = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); - emit_label (XEXP (label1, 0)); + rtx_code_label *label1 = gen_label_rtx (); + label_ref1 = gen_rtx_LABEL_REF (VOIDmode, label1); + emit_label (label1); } - label2 = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); + rtx_code_label *label2 = gen_label_rtx (); + rtx label_ref2 = gen_rtx_LABEL_REF (VOIDmode, label2); emit_load_locked (mode, retval, mem, local ? const1_rtx : const0_rtx); @@ -17222,7 +17224,7 @@ rs6000_expand_atomic_compare_and_swap (rtx operands[], bool local) emit_insn (gen_rtx_SET (cond, x)); x = gen_rtx_NE (VOIDmode, cond, const0_rtx); - emit_unlikely_jump (x, label2); + emit_unlikely_jump (x, label_ref2); x = newval; if (mask) @@ -17233,16 +17235,16 @@ rs6000_expand_atomic_compare_and_swap (rtx operands[], bool local) if (!is_weak) { x = gen_rtx_NE (VOIDmode, cond, const0_rtx); - emit_unlikely_jump (x, label1); + emit_unlikely_jump (x, label_ref1); } if (!is_mm_relaxed (mod_f)) - emit_label (XEXP (label2, 0)); + emit_label (label2); rs6000_post_atomic_barrier (mod_s); if (is_mm_relaxed (mod_f)) - emit_label (XEXP (label2, 0)); + emit_label (label2); if (shift) rs6000_finish_atomic_subword (operands[1], retval, shift); @@ -17262,7 +17264,7 @@ rs6000_expand_atomic_exchange (rtx operands[]) rtx retval, mem, val, cond; machine_mode mode; enum memmodel model; - rtx label, x, mask, shift; + rtx x, mask, shift; retval = operands[0]; mem = operands[1]; @@ -17287,8 +17289,9 @@ rs6000_expand_atomic_exchange (rtx operands[]) mem = rs6000_pre_atomic_barrier (mem, model); - label = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); - emit_label (XEXP (label, 0)); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label); + emit_label (label); emit_load_locked (mode, retval, mem, const0_rtx); @@ -17300,7 +17303,7 @@ rs6000_expand_atomic_exchange (rtx operands[]) emit_store_conditional (mode, cond, mem, x); x = gen_rtx_NE (VOIDmode, cond, const0_rtx); - emit_unlikely_jump (x, label); + emit_unlikely_jump (x, label_ref); rs6000_post_atomic_barrier (model); @@ -17321,7 +17324,7 @@ rs6000_expand_atomic_op (enum rtx_code code, rtx mem, rtx val, enum memmodel model = memmodel_base (INTVAL (model_rtx)); machine_mode mode = GET_MODE (mem); machine_mode store_mode = mode; - rtx label, x, cond, mask, shift; + rtx x, cond, mask, shift; rtx before = orig_before, after = orig_after; mask = shift = NULL_RTX; @@ -17388,9 +17391,9 @@ rs6000_expand_atomic_op (enum rtx_code code, rtx mem, rtx val, mem = rs6000_pre_atomic_barrier (mem, model); - label = gen_label_rtx (); + rtx_code_label *label = gen_label_rtx (); emit_label (label); - label = gen_rtx_LABEL_REF (VOIDmode, label); + rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label); if (before == NULL_RTX) before = gen_reg_rtx (mode); @@ -17423,7 +17426,7 @@ rs6000_expand_atomic_op (enum rtx_code code, rtx mem, rtx val, emit_store_conditional (store_mode, cond, mem, x); x = gen_rtx_NE (VOIDmode, cond, const0_rtx); - emit_unlikely_jump (x, label); + emit_unlikely_jump (x, label_ref); rs6000_post_atomic_barrier (model); diff --git a/gcc/config/rx/rx.cc b/gcc/config/rx/rx.cc index 192701c60e6..216e5c70a3d 100644 --- a/gcc/config/rx/rx.cc +++ b/gcc/config/rx/rx.cc @@ -1662,17 +1662,17 @@ gen_rx_store_vector (unsigned int low, unsigned int high) then mark each element as being frame related as well. */ static void -mark_frame_related (rtx insn) +mark_frame_related (rtx_insn *insn) { RTX_FRAME_RELATED_P (insn) = 1; - insn = PATTERN (insn); + rtx body = PATTERN (insn); - if (GET_CODE (insn) == PARALLEL) + if (GET_CODE (body) == PARALLEL) { unsigned int i; - for (i = 0; i < (unsigned) XVECLEN (insn, 0); i++) - RTX_FRAME_RELATED_P (XVECEXP (insn, 0, i)) = 1; + for (i = 0; i < (unsigned) XVECLEN (body, 0); i++) + RTX_FRAME_RELATED_P (XVECEXP (body, 0, i)) = 1; } } diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 6d59795ea2e..2c648cdcab3 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -9659,7 +9659,8 @@ if (TARGET_INDIRECT_BRANCH_NOBP_JUMP_INLINE_THUNK) { operands[0] = force_reg (Pmode, operands[0]); - rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label); if (TARGET_CPU_Z10) emit_jump_insn (gen_indirect_jump_via_inlinethunkdi_z10 (operands[0], label_ref)); @@ -9800,7 +9801,8 @@ if (TARGET_INDIRECT_BRANCH_NOBP_JUMP_INLINE_THUNK) { operands[0] = force_reg (Pmode, operands[0]); - rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ()); + rtx_code_label *label = gen_label_rtx (); + rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label); if (TARGET_CPU_Z10) emit_jump_insn (gen_casesi_jump_via_inlinethunkdi_z10 (operands[0], operands[1], -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:38:03 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:38:03 -0500 Subject: [PATCH 22/25] Return end_sequence directly In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-23-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * config/cris/cris.cc (cris_split_movdx): Return end_sequence directly. * config/frv/frv.cc (frv_split_scc, frv_split_cond_move, frv_split_minmax, frv_split_abs): Likewise. --- gcc/config/cris/cris.cc | 4 +--- gcc/config/frv/frv.cc | 17 ++++------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/gcc/config/cris/cris.cc b/gcc/config/cris/cris.cc index 569d27accfb..16209bd9675 100644 --- a/gcc/config/cris/cris.cc +++ b/gcc/config/cris/cris.cc @@ -2542,7 +2542,6 @@ cris_split_movdx (rtx *operands) machine_mode mode = GET_MODE (operands[0]); rtx dest = operands[0]; rtx src = operands[1]; - rtx_insn *val; /* We used to have to handle (SUBREG (MEM)) here, but that should no longer happen; after reload there are no SUBREGs any more, and we're @@ -2693,8 +2692,7 @@ cris_split_movdx (rtx *operands) else internal_error ("unknown dest"); - val = end_sequence (); - return val; + return end_sequence (); } /* Try to split the constant WVAL into a number of separate insns of less cost diff --git a/gcc/config/frv/frv.cc b/gcc/config/frv/frv.cc index e1307fcf01f..17b0881d37c 100644 --- a/gcc/config/frv/frv.cc +++ b/gcc/config/frv/frv.cc @@ -4737,8 +4737,6 @@ frv_emit_scc (rtx operands[]) rtx_insn * frv_split_scc (rtx dest, rtx test, rtx cc_reg, rtx cr_reg, HOST_WIDE_INT value) { - rtx_insn *ret; - start_sequence (); /* Set the appropriate CCR bit. */ @@ -4759,8 +4757,7 @@ frv_split_scc (rtx dest, rtx test, rtx cc_reg, rtx cr_reg, HOST_WIDE_INT value) gen_rtx_SET (dest, const0_rtx))); /* Finish up, return sequence. */ - ret = end_sequence (); - return ret; + return end_sequence (); } @@ -4854,7 +4851,6 @@ frv_split_cond_move (rtx operands[]) rtx src1 = operands[3]; rtx src2 = operands[4]; rtx cr_reg = operands[5]; - rtx_insn *ret; machine_mode cr_mode = GET_MODE (cr_reg); start_sequence (); @@ -4930,8 +4926,7 @@ frv_split_cond_move (rtx operands[]) } /* Finish up, return sequence. */ - ret = end_sequence (); - return ret; + return end_sequence (); } @@ -5003,7 +4998,6 @@ frv_split_minmax (rtx operands[]) rtx src2 = operands[3]; rtx cc_reg = operands[4]; rtx cr_reg = operands[5]; - rtx_insn *ret; enum rtx_code test_code; machine_mode cr_mode = GET_MODE (cr_reg); @@ -5060,8 +5054,7 @@ frv_split_minmax (rtx operands[]) } /* Finish up, return sequence. */ - ret = end_sequence (); - return ret; + return end_sequence (); } @@ -5075,7 +5068,6 @@ frv_split_abs (rtx operands[]) rtx src = operands[1]; rtx cc_reg = operands[2]; rtx cr_reg = operands[3]; - rtx_insn *ret; start_sequence (); @@ -5098,8 +5090,7 @@ frv_split_abs (rtx operands[]) gen_rtx_SET (dest, src))); /* Finish up, return sequence. */ - ret = end_sequence (); - return ret; + return end_sequence (); } -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:38:02 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:38:02 -0500 Subject: [PATCH 21/25] Pass an rtx_insn * to redundant_insn In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-22-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * reorg.cc (redundant_insn): Take an rtx_insn *. (relax_delay_slots): Keep the next real insn in an rtx_insn *. --- gcc/reorg.cc | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/gcc/reorg.cc b/gcc/reorg.cc index 7412fb1dbcb..cde1a5a8303 100644 --- a/gcc/reorg.cc +++ b/gcc/reorg.cc @@ -207,7 +207,8 @@ static void steal_delay_list_from_fallthrough (rtx_insn *, rtx, rtx_sequence *, struct resources *, int, int *, bool *); static void try_merge_delay_insns (rtx_insn *, rtx_insn *); -static rtx_insn *redundant_insn (rtx, rtx_insn *, const vec &); +static rtx_insn *redundant_insn (rtx_insn *, rtx_insn *, + const vec &); static bool own_thread_p (rtx, rtx, bool); static void update_block (rtx_insn *, rtx_insn *); static bool reorg_redirect_jump (rtx_jump_insn *, rtx); @@ -1390,7 +1391,8 @@ try_merge_delay_insns (rtx_insn *insn, rtx_insn *thread) gain in rare cases. */ static rtx_insn * -redundant_insn (rtx insn, rtx_insn *target, const vec &delay_list) +redundant_insn (rtx_insn *insn, rtx_insn *target, + const vec &delay_list) { rtx target_main = target; rtx ipat = PATTERN (insn); @@ -1446,8 +1448,8 @@ redundant_insn (rtx insn, rtx_insn *target, const vec &delay_list) resource requirements as we go. */ for (i = seq->len () - 1; i > 0; i--) if (GET_CODE (seq->element (i)) == GET_CODE (insn) - && rtx_equal_p (PATTERN (seq->element (i)), ipat) - && ! find_reg_note (seq->element (i), REG_UNUSED, NULL_RTX)) + && rtx_equal_p (PATTERN (seq->insn (i)), ipat) + && ! find_reg_note (seq->insn (i), REG_UNUSED, NULL_RTX)) break; /* If found a match, exit this loop early. */ @@ -3283,23 +3285,24 @@ relax_delay_slots (rtx_insn *first) We use next_real_nondebug_insn instead of next_active_insn so we don't skip USE-markers, or we'll end up with incorrect liveness info. */ - trial = next_real_nondebug_insn (as_a (target_label)); - if (trial && GET_CODE (PATTERN (trial)) != SEQUENCE - && redundant_insn (trial, insn, vNULL) - && ! can_throw_internal (as_a (trial))) + rtx_insn *next_insn + = next_real_nondebug_insn (as_a (target_label)); + if (next_insn && GET_CODE (PATTERN (next_insn)) != SEQUENCE + && redundant_insn (next_insn, insn, vNULL) + && ! can_throw_internal (next_insn)) { /* Figure out where to emit the special USE insn so we don't later incorrectly compute register live/death info. */ - rtx_insn *tmp = next_active_insn (as_a (trial)); + rtx_insn *tmp = next_active_insn (next_insn); if (tmp == 0) tmp = find_end_label (simple_return_rtx); if (tmp) { /* Insert the special USE insn and update dataflow info. - We know "trial" is an insn here as it is the output of + We know "next_insn" is an insn here as it is the output of next_real_nondebug_insn () above. */ - update_block (as_a (trial), tmp); + update_block (next_insn, tmp); /* Now emit a label before the special USE insn, and redirect our jump to the new label. */ @@ -3313,7 +3316,7 @@ relax_delay_slots (rtx_insn *first) /* Similarly, if it is an unconditional jump with one insn in its delay list and that insn is redundant, thread the jump. */ rtx_sequence *trial_seq = - trial ? dyn_cast (PATTERN (trial)) : NULL; + next_insn ? dyn_cast (PATTERN (next_insn)) : NULL; if (trial_seq && trial_seq->len () == 2 && JUMP_P (trial_seq->insn (0)) -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:38:04 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:38:04 -0500 Subject: [PATCH 23/25] Use add_reg_note instead of a hand-built note In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-24-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * config/arm/arm.cc (arm_emit_multi_reg_pop, arm_emit_ldrd_pop, arm_expand_epilogue): Use add_reg_note. * config/cris/cris.cc (cris_split_movdx, cris_expand_epilogue): Likewise. * config/frv/frv.cc (frv_frame_insn): Likewise. * config/loongarch/loongarch.cc (loongarch_set_frame_expr, loongarch_restore_reg): Likewise. * config/riscv/riscv.cc (riscv_set_frame_expr): Likewise. * config/stormy16/stormy16.cc (xstormy16_split_move): Likewise. --- gcc/config/arm/arm.cc | 28 +++++++--------------------- gcc/config/cris/cris.cc | 31 +++++++++---------------------- gcc/config/frv/frv.cc | 4 +--- gcc/config/loongarch/loongarch.cc | 7 ++----- gcc/config/riscv/riscv.cc | 4 +--- gcc/config/stormy16/stormy16.cc | 4 +--- 6 files changed, 21 insertions(+), 57 deletions(-) diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index ff239312049..69874ac28b8 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -21558,8 +21558,7 @@ arm_emit_multi_reg_pop (unsigned long saved_regs_mask) gen_rtx_POST_INC (Pmode, stack_pointer_rtx)); rtx_insn *insn = emit_insn (gen_rtx_SET (reg, tmp)); - REG_NOTES (insn) = alloc_reg_note (REG_CFA_RESTORE, dwarf_reg, - dwarf); + add_reg_note (insn, REG_CFA_RESTORE, dwarf_reg); arm_add_cfa_adjust_cfa_note (insn, UNITS_PER_WORD, stack_pointer_rtx, stack_pointer_rtx); return; @@ -21857,7 +21856,6 @@ arm_emit_ldrd_pop (unsigned long saved_regs_mask) int j = 0; int offset = 0; rtx par = NULL_RTX; - rtx dwarf = NULL_RTX; rtx tmp, mem; /* Restore saved registers. */ @@ -21887,14 +21885,8 @@ arm_emit_ldrd_pop (unsigned long saved_regs_mask) /* Generate dwarf info. */ - dwarf = alloc_reg_note (REG_CFA_RESTORE, - gen_rtx_REG (SImode, j), - NULL_RTX); - dwarf = alloc_reg_note (REG_CFA_RESTORE, - gen_rtx_REG (SImode, j + 1), - dwarf); - - REG_NOTES (insn) = dwarf; + add_reg_note (insn, REG_CFA_RESTORE, gen_rtx_REG (SImode, j)); + add_reg_note (insn, REG_CFA_RESTORE, gen_rtx_REG (SImode, j + 1)); offset += 8; j += 2; @@ -21915,9 +21907,7 @@ arm_emit_ldrd_pop (unsigned long saved_regs_mask) RTX_FRAME_RELATED_P (insn) = 1; /* Generate dwarf info. */ - REG_NOTES (insn) = alloc_reg_note (REG_CFA_RESTORE, - gen_rtx_REG (SImode, j), - NULL_RTX); + add_reg_note (insn, REG_CFA_RESTORE, gen_rtx_REG (SImode, j)); offset += 4; j += 1; @@ -21955,10 +21945,7 @@ arm_emit_ldrd_pop (unsigned long saved_regs_mask) rtx_insn *insn = emit_jump_insn (par); /* Generate dwarf info. */ - dwarf = alloc_reg_note (REG_CFA_RESTORE, - gen_rtx_REG (SImode, PC_REGNUM), - NULL_RTX); - REG_NOTES (insn) = dwarf; + add_reg_note (insn, REG_CFA_RESTORE, gen_rtx_REG (SImode, PC_REGNUM)); arm_add_cfa_adjust_cfa_note (insn, UNITS_PER_WORD, stack_pointer_rtx, stack_pointer_rtx); } @@ -27130,9 +27117,8 @@ arm_expand_epilogue (bool really_return) rtx_insn *move = emit_insn (gen_movsi (gen_rtx_REG (SImode, i), addr)); - REG_NOTES (move) = alloc_reg_note (REG_CFA_RESTORE, - gen_rtx_REG (SImode, i), - NULL_RTX); + add_reg_note (move, REG_CFA_RESTORE, + gen_rtx_REG (SImode, i)); arm_add_cfa_adjust_cfa_note (move, UNITS_PER_WORD, stack_pointer_rtx, stack_pointer_rtx); diff --git a/gcc/config/cris/cris.cc b/gcc/config/cris/cris.cc index 16209bd9675..3cae6c949ec 100644 --- a/gcc/config/cris/cris.cc +++ b/gcc/config/cris/cris.cc @@ -2606,16 +2606,12 @@ cris_split_movdx (rtx *operands) = emit_move_insn (operand_subword (dest, 0, TRUE, mode), mem); if (GET_CODE (XEXP (mem, 0)) == POST_INC) - REG_NOTES (insn) - = alloc_EXPR_LIST (REG_INC, XEXP (XEXP (mem, 0), 0), - REG_NOTES (insn)); + add_reg_note (insn, REG_INC, XEXP (XEXP (mem, 0), 0)); mem = copy_rtx (mem); insn = emit_move_insn (operand_subword (dest, 1, TRUE, mode), mem); if (GET_CODE (XEXP (mem, 0)) == POST_INC) - REG_NOTES (insn) - = alloc_EXPR_LIST (REG_INC, XEXP (XEXP (mem, 0), 0), - REG_NOTES (insn)); + add_reg_note (insn, REG_INC, XEXP (XEXP (mem, 0), 0)); } else { @@ -2660,16 +2656,12 @@ cris_split_movdx (rtx *operands) rtx_insn *insn = emit_move_insn (mem, operand_subword (src, 0, TRUE, mode)); if (GET_CODE (XEXP (mem, 0)) == POST_INC) - REG_NOTES (insn) - = alloc_EXPR_LIST (REG_INC, XEXP (XEXP (mem, 0), 0), - REG_NOTES (insn)); + add_reg_note (insn, REG_INC, XEXP (XEXP (mem, 0), 0)); mem = copy_rtx (mem); insn = emit_move_insn (mem, operand_subword (src, 1, TRUE, mode)); if (GET_CODE (XEXP (mem, 0)) == POST_INC) - REG_NOTES (insn) - = alloc_EXPR_LIST (REG_INC, XEXP (XEXP (mem, 0), 0), - REG_NOTES (insn)); + add_reg_note (insn, REG_INC, XEXP (XEXP (mem, 0), 0)); } else { @@ -3175,8 +3167,7 @@ cris_expand_epilogue (void) /* Whenever we emit insns with post-incremented addresses ourselves, we must add a post-inc note manually. */ - REG_NOTES (insn) - = alloc_EXPR_LIST (REG_INC, stack_pointer_rtx, REG_NOTES (insn)); + add_reg_note (insn, REG_INC, stack_pointer_rtx); } /* If we have any movem-restore, do it now. */ @@ -3197,8 +3188,7 @@ cris_expand_epilogue (void) /* Whenever we emit insns with post-incremented addresses ourselves, we must add a post-inc note manually. */ if (side_effects_p (PATTERN (insn))) - REG_NOTES (insn) - = alloc_EXPR_LIST (REG_INC, stack_pointer_rtx, REG_NOTES (insn)); + add_reg_note (insn, REG_INC, stack_pointer_rtx); } /* If we don't clobber all of the allocated stack area (we've already @@ -3225,8 +3215,7 @@ cris_expand_epilogue (void) /* Whenever we emit insns with post-incremented addresses ourselves, we must add a post-inc note manually. */ - REG_NOTES (insn) - = alloc_EXPR_LIST (REG_INC, stack_pointer_rtx, REG_NOTES (insn)); + add_reg_note (insn, REG_INC, stack_pointer_rtx); } else if ((size + argspace_offset) != 0) { @@ -3259,8 +3248,7 @@ cris_expand_epilogue (void) /* Whenever we emit insns with post-incremented addresses ourselves, we must add a post-inc note manually. */ - REG_NOTES (insn) - = alloc_EXPR_LIST (REG_INC, stack_pointer_rtx, REG_NOTES (insn)); + add_reg_note (insn, REG_INC, stack_pointer_rtx); if (crtl->calls_eh_return) emit_insn (gen_add2_insn (stack_pointer_rtx, @@ -3291,8 +3279,7 @@ cris_expand_epilogue (void) /* Whenever we emit insns with post-incremented addresses ourselves, we must add a post-inc note manually. */ - REG_NOTES (insn) - = alloc_EXPR_LIST (REG_INC, stack_pointer_rtx, REG_NOTES (insn)); + add_reg_note (insn, REG_INC, stack_pointer_rtx); } emit_insn (gen_add2_insn (stack_pointer_rtx, GEN_INT (pretend))); diff --git a/gcc/config/frv/frv.cc b/gcc/config/frv/frv.cc index 17b0881d37c..a1c75d731c8 100644 --- a/gcc/config/frv/frv.cc +++ b/gcc/config/frv/frv.cc @@ -1559,9 +1559,7 @@ frv_frame_insn (rtx pattern, rtx dwarf_pattern) { rtx_insn *insn = emit_insn (pattern); RTX_FRAME_RELATED_P (insn) = 1; - REG_NOTES (insn) = alloc_EXPR_LIST (REG_FRAME_RELATED_EXPR, - dwarf_pattern, - REG_NOTES (insn)); + add_reg_note (insn, REG_FRAME_RELATED_EXPR, dwarf_pattern); } /* Emit instructions that transfer REG to or from the memory location (sp + diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index a753171fb8d..bf401602394 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -801,8 +801,7 @@ loongarch_set_frame_expr (rtx frame_pattern) { rtx_insn *insn = get_last_insn (); RTX_FRAME_RELATED_P (insn) = 1; - REG_NOTES (insn) = alloc_EXPR_LIST (REG_FRAME_RELATED_EXPR, frame_pattern, - REG_NOTES (insn)); + add_reg_note (insn, REG_FRAME_RELATED_EXPR, frame_pattern); } /* Return a frame-related rtx that stores REG at MEM. @@ -1083,9 +1082,7 @@ static void loongarch_restore_reg (rtx reg, rtx mem) { rtx_insn *insn = loongarch_emit_move (reg, mem); - rtx dwarf = NULL_RTX; - dwarf = alloc_reg_note (REG_CFA_RESTORE, reg, dwarf); - REG_NOTES (insn) = dwarf; + add_reg_note (insn, REG_CFA_RESTORE, reg); RTX_FRAME_RELATED_P (insn) = 1; } diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 698881148ec..c10c0225cc4 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -9198,9 +9198,7 @@ riscv_set_frame_expr (rtx frame_pattern) { rtx_insn *insn = get_last_insn (); RTX_FRAME_RELATED_P (insn) = 1; - REG_NOTES (insn) = alloc_EXPR_LIST (REG_FRAME_RELATED_EXPR, - frame_pattern, - REG_NOTES (insn)); + add_reg_note (insn, REG_FRAME_RELATED_EXPR, frame_pattern); } /* Return a frame-related rtx that stores REG at MEM. diff --git a/gcc/config/stormy16/stormy16.cc b/gcc/config/stormy16/stormy16.cc index 00dce985e24..906389a7d36 100644 --- a/gcc/config/stormy16/stormy16.cc +++ b/gcc/config/stormy16/stormy16.cc @@ -986,9 +986,7 @@ xstormy16_split_move (machine_mode mode, rtx dest, rtx src) rtx_insn *insn = emit_insn (gen_rtx_SET (w_dest, w_src)); if (auto_inc_reg_rtx) - REG_NOTES (insn) = alloc_EXPR_LIST (REG_INC, - auto_inc_reg_rtx, - REG_NOTES (insn)); + add_reg_note (insn, REG_INC, auto_inc_reg_rtx); } } -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:38:05 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:38:05 -0500 Subject: [PATCH 24/25] Pass an rtx_insn * to add_reg_note In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-25-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * rtl.h (add_reg_note): Take an rtx_insn *. * rtlanal.cc (add_reg_note): Likewise. * config/rl78/rl78.cc (gen_and_emit_move): Pass an rtx_insn *. * config/s390/s390.cc (save_gprs): Likewise. --- gcc/config/rl78/rl78.cc | 3 ++- gcc/config/s390/s390.cc | 12 +++++++----- gcc/rtl.h | 2 +- gcc/rtlanal.cc | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gcc/config/rl78/rl78.cc b/gcc/config/rl78/rl78.cc index 56976aab353..9ad7f2da051 100644 --- a/gcc/config/rl78/rl78.cc +++ b/gcc/config/rl78/rl78.cc @@ -2929,7 +2929,8 @@ gen_and_emit_move (rtx to, rtx from, rtx_insn *where, bool before) cf. compiling gcc.dg/pr44545.c. */ if (note != NULL_RTX) { - add_reg_note (move, REG_EH_REGION, XEXP (note, 0)); + add_reg_note (as_a (move), REG_EH_REGION, + XEXP (note, 0)); remove_note (where, note); } diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index fb17029bac3..ac376c11615 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -11799,7 +11799,8 @@ restore_fpr (rtx base, int offset, int regnum) static void save_gprs (rtx base, int offset, int first, int last, rtx_insn *before = NULL) { - rtx addr, insn, note; + rtx addr, note; + rtx_insn *insn; rtx_insn *out_insn; int i; @@ -11809,7 +11810,8 @@ save_gprs (rtx base, int offset, int first, int last, rtx_insn *before = NULL) /* Special-case single register. */ if (first == last) { - insn = gen_movdi (addr, gen_rtx_REG (Pmode, first)); + insn = as_a (gen_movdi (addr, + gen_rtx_REG (Pmode, first))); if (!global_not_special_regno_p (first)) RTX_FRAME_RELATED_P (insn) = 1; @@ -11825,9 +11827,9 @@ save_gprs (rtx base, int offset, int first, int last, rtx_insn *before = NULL) } - insn = gen_store_multiple (addr, - gen_rtx_REG (Pmode, first), - GEN_INT (last - first + 1)); + insn = as_a (gen_store_multiple (addr, + gen_rtx_REG (Pmode, first), + GEN_INT (last - first + 1))); if (first <= 6 && cfun->stdarg) for (i = 0; i < XVECLEN (PATTERN (insn), 0); i++) diff --git a/gcc/rtl.h b/gcc/rtl.h index 94fab8572c2..0851c0c4b0c 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3760,7 +3760,7 @@ extern rtx find_constant_src (const rtx_insn *); extern bool find_reg_fusage (const_rtx, enum rtx_code, const_rtx); extern bool find_regno_fusage (const_rtx, enum rtx_code, unsigned int); extern rtx alloc_reg_note (enum reg_note, rtx, rtx); -extern void add_reg_note (rtx, enum reg_note, rtx); +extern void add_reg_note (rtx_insn *, enum reg_note, rtx); extern void add_int_reg_note (rtx_insn *, enum reg_note, int); extern void add_args_size_note (rtx_insn *, poly_int64); extern void add_shallow_copy_of_reg_note (rtx_insn *, rtx); diff --git a/gcc/rtlanal.cc b/gcc/rtlanal.cc index 5e00623d993..930d9060f02 100644 --- a/gcc/rtlanal.cc +++ b/gcc/rtlanal.cc @@ -2732,7 +2732,7 @@ alloc_reg_note (enum reg_note kind, rtx datum, rtx list) /* Add register note with kind KIND and datum DATUM to INSN. */ void -add_reg_note (rtx insn, enum reg_note kind, rtx datum) +add_reg_note (rtx_insn *insn, enum reg_note kind, rtx datum) { REG_NOTES (insn) = alloc_reg_note (kind, datum, REG_NOTES (insn)); } -- 2.53.0 From tbsaunde@tbsaunde.org Mon Nov 2 07:38:06 2026 From: tbsaunde@tbsaunde.org (tbsaunde@tbsaunde.org) Date: Mon, 2 Nov 2026 02:38:06 -0500 Subject: [PATCH 25/25] Pass a const rtx_insn * to the reg-note finders In-Reply-To: <20261102075007.317381-1-tbsaunde@tbsaunde.org> References: <20261102075007.317381-1-tbsaunde@tbsaunde.org> Message-ID: <20261102075007.317381-26-tbsaunde@tbsaunde.org> From: Trevor Saunders gcc/ChangeLog: * rtl.h (find_reg_note, find_regno_note, find_reg_fusage, find_regno_fusage): Take a const rtx_insn *. * rtlanal.cc (find_reg_note, find_regno_note, find_reg_fusage, find_regno_fusage): Likewise. (reg_set_p): Pass a const rtx_insn *. * sched-deps.cc (mark_insn_reg_store): Likewise. * except.cc (copy_reg_eh_region_note_forward, copy_reg_eh_region_note_backward): Likewise. * resource.cc (mark_referenced_resources): Likewise. --- gcc/except.cc | 24 ++++++++++++------------ gcc/resource.cc | 9 +++++---- gcc/rtl.h | 8 ++++---- gcc/rtlanal.cc | 16 ++++++++++------ gcc/sched-deps.cc | 2 +- 5 files changed, 32 insertions(+), 27 deletions(-) diff --git a/gcc/except.cc b/gcc/except.cc index d00f033af51..e97e13626c4 100644 --- a/gcc/except.cc +++ b/gcc/except.cc @@ -1771,20 +1771,20 @@ void copy_reg_eh_region_note_forward (rtx note_or_insn, rtx_insn *first, rtx_insn *last) { - rtx_insn *insn; rtx note = note_or_insn; - if (INSN_P (note_or_insn)) + if (rtx_insn *insn = dyn_cast (note_or_insn)) { - note = find_reg_note (note_or_insn, REG_EH_REGION, NULL_RTX); + if (!INSN_P (insn)) + return; + + note = find_reg_note (insn, REG_EH_REGION, NULL_RTX); if (note == NULL) return; } - else if (is_a (note_or_insn)) - return; note = XEXP (note, 0); - for (insn = first; insn != last ; insn = NEXT_INSN (insn)) + for (rtx_insn *insn = first; insn != last ; insn = NEXT_INSN (insn)) if (!find_reg_note (insn, REG_EH_REGION, NULL_RTX) && insn_could_throw_p (insn)) add_reg_note (insn, REG_EH_REGION, note); @@ -1796,20 +1796,20 @@ void copy_reg_eh_region_note_backward (rtx note_or_insn, rtx_insn *last, rtx_insn *first) { - rtx_insn *insn; rtx note = note_or_insn; - if (INSN_P (note_or_insn)) + if (rtx_insn *insn = dyn_cast (note_or_insn)) { - note = find_reg_note (note_or_insn, REG_EH_REGION, NULL_RTX); + if (!INSN_P (insn)) + return; + + note = find_reg_note (insn, REG_EH_REGION, NULL_RTX); if (note == NULL) return; } - else if (is_a (note_or_insn)) - return; note = XEXP (note, 0); - for (insn = last; insn != first; insn = PREV_INSN (insn)) + for (rtx_insn *insn = last; insn != first; insn = PREV_INSN (insn)) if (insn_could_throw_p (insn)) add_reg_note (insn, REG_EH_REGION, note); } diff --git a/gcc/resource.cc b/gcc/resource.cc index d5e52ec9c22..f377fe99e51 100644 --- a/gcc/resource.cc +++ b/gcc/resource.cc @@ -299,13 +299,14 @@ mark_referenced_resources (rtx x, struct resources *res, However, we may have moved some of the parameter loading insns into the delay slot of this CALL. If so, the USE's for them don't count and should be skipped. */ - rtx_insn *insn = PREV_INSN (as_a (x)); + rtx_insn *call_insn = as_a (x); + rtx_insn *insn = PREV_INSN (call_insn); rtx_sequence *sequence = 0; int seq_size = 0; int i; /* If we are part of a delay slot sequence, point at the SEQUENCE. */ - if (NEXT_INSN (insn) != x) + if (NEXT_INSN (insn) != call_insn) { sequence = as_a (PATTERN (NEXT_INSN (insn))); seq_size = sequence->len (); @@ -333,13 +334,13 @@ mark_referenced_resources (rtx x, struct resources *res, registers ensures that a register will not be considered dead just because it crosses a setjmp call. A register should be considered dead only if the setjmp call returns nonzero. */ - if (find_reg_note (x, REG_SETJMP, NULL)) + if (find_reg_note (call_insn, REG_SETJMP, NULL)) SET_HARD_REG_SET (res->regs); { rtx link; - for (link = CALL_INSN_FUNCTION_USAGE (x); + for (link = CALL_INSN_FUNCTION_USAGE (call_insn); link; link = XEXP (link, 1)) if (GET_CODE (XEXP (link, 0)) == USE) diff --git a/gcc/rtl.h b/gcc/rtl.h index 0851c0c4b0c..3c8dd966504 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3753,12 +3753,12 @@ extern void note_stores (const rtx_insn *, extern void note_uses (rtx *, void (*) (rtx *, void *), void *); extern bool dead_or_set_p (const rtx_insn *, const_rtx); extern bool dead_or_set_regno_p (const rtx_insn *, unsigned int); -extern rtx find_reg_note (const_rtx, enum reg_note, const_rtx); -extern rtx find_regno_note (const_rtx, enum reg_note, unsigned int); +extern rtx find_reg_note (const rtx_insn *, enum reg_note, const_rtx); +extern rtx find_regno_note (const rtx_insn *, enum reg_note, unsigned int); extern rtx find_reg_equal_equiv_note (const rtx_insn *); extern rtx find_constant_src (const rtx_insn *); -extern bool find_reg_fusage (const_rtx, enum rtx_code, const_rtx); -extern bool find_regno_fusage (const_rtx, enum rtx_code, unsigned int); +extern bool find_reg_fusage (const rtx_insn *, enum rtx_code, const_rtx); +extern bool find_regno_fusage (const rtx_insn *, enum rtx_code, unsigned int); extern rtx alloc_reg_note (enum reg_note, rtx, rtx); extern void add_reg_note (rtx_insn *, enum reg_note, rtx); extern void add_int_reg_note (rtx_insn *, enum reg_note, int); diff --git a/gcc/rtlanal.cc b/gcc/rtlanal.cc index 930d9060f02..016229f112b 100644 --- a/gcc/rtlanal.cc +++ b/gcc/rtlanal.cc @@ -1233,8 +1233,12 @@ reg_set_between_p (const_rtx reg, const rtx_insn *from_insn, /* Return true if REG is set or clobbered inside INSN. */ bool -reg_set_p (const_rtx reg, const_rtx insn) +reg_set_p (const_rtx reg, const_rtx uncast_insn) { + const rtx_insn *insn = dyn_cast (uncast_insn); + if (!insn) + return set_of (reg, uncast_insn) != NULL_RTX; + /* After delay slot handling, call and branch insns might be in a sequence. Check all the elements there. */ if (INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE) @@ -1253,7 +1257,7 @@ reg_set_p (const_rtx reg, const_rtx insn) || (CALL_P (insn) && ((REG_P (reg) && REGNO (reg) < FIRST_PSEUDO_REGISTER - && (insn_callee_abi (as_a (insn)) + && (insn_callee_abi (insn) .clobbers_reg_p (GET_MODE (reg), REGNO (reg)))) || MEM_P (reg) || find_reg_fusage (insn, CLOBBER, reg))))) @@ -2516,7 +2520,7 @@ dead_or_set_regno_p (const rtx_insn *insn, unsigned int test_regno) If DATUM is nonzero, look for one whose datum is DATUM. */ rtx -find_reg_note (const_rtx insn, enum reg_note kind, const_rtx datum) +find_reg_note (const rtx_insn *insn, enum reg_note kind, const_rtx datum) { rtx link; @@ -2545,7 +2549,7 @@ find_reg_note (const_rtx insn, enum reg_note kind, const_rtx datum) it might be the case that the note overlaps REGNO. */ rtx -find_regno_note (const_rtx insn, enum reg_note kind, unsigned int regno) +find_regno_note (const rtx_insn *insn, enum reg_note kind, unsigned int regno) { rtx link; @@ -2621,7 +2625,7 @@ find_constant_src (const rtx_insn *insn) in the CALL_INSN_FUNCTION_USAGE information of INSN. */ bool -find_reg_fusage (const_rtx insn, enum rtx_code code, const_rtx datum) +find_reg_fusage (const rtx_insn *insn, enum rtx_code code, const_rtx datum) { /* If it's not a CALL_INSN, it can't possibly have a CALL_INSN_FUNCTION_USAGE field, so don't bother checking. */ @@ -2666,7 +2670,7 @@ find_reg_fusage (const_rtx insn, enum rtx_code code, const_rtx datum) in the CALL_INSN_FUNCTION_USAGE information of INSN. */ bool -find_regno_fusage (const_rtx insn, enum rtx_code code, unsigned int regno) +find_regno_fusage (const rtx_insn *insn, enum rtx_code code, unsigned int regno) { rtx link; diff --git a/gcc/sched-deps.cc b/gcc/sched-deps.cc index dfb99109df4..5b8001f64ee 100644 --- a/gcc/sched-deps.cc +++ b/gcc/sched-deps.cc @@ -2173,7 +2173,7 @@ mark_insn_reg_store (rtx reg, const_rtx setter, void *data) return; mark_insn_reg_birth ((rtx_insn *) data, reg, false, - find_reg_note ((const_rtx) data, REG_UNUSED, reg) != NULL_RTX); + find_reg_note ((const rtx_insn *) data, REG_UNUSED, reg) != NULL_RTX); } /* Like mark_insn_reg_store except notice just CLOBBERs; ignore SETs. */ -- 2.53.0 From michiel@derhaeg.be Mon Nov 2 07:59:56 2026 From: michiel@derhaeg.be (Michiel Derhaeg) Date: Mon, 02 Nov 2026 08:59:56 +0100 Subject: [PATCH 1/2] RISC-V: Add ARC-V RPX-100 series pipeline description In-Reply-To: References: <20261030134212.2387766-1-exuro@exuro.be> Message-ID: <877biv4q9v.fsf@derhaeg.be> Jeff Law writes: > On 10/30/26 7:41 AM, exuro wrote: >> From: Loeka Rogge >> >> The RPX-100 pipeline is the same design as the RHX-100 but RV64 instead >> of RV32. This mtune is just an alias and adds 64 bit multiplication. >> >> Add a mul_part attribute to al multiplication instructions in riscv.md >> to distinguish instructions that return the high and low part. >> >> Regtested on rv32gc, rv64gc and with rhx100 config and mtune. >> >> gcc/ChangeLog: >> >> * config/riscv/arcv-rhx100.md (arcv_rhx100_mpy_insn): Rename to >> mpy32. >> (arcv_rhx100_mpy32_insn): Also apply for rpx_100 tune. >> (arcv_rhx100_mpy64l_insn): rpx_100 mul low part. >> (arcv_rhx100_mpy64h_insn): rpx_100 mul high part. >> (arcv_rhx100_mpy*_insn): Apply bypass for both size mul. >> (arcv_rhx100_div_insn): Also apply for rpx_100 tune. >> (riscv_store_data_bypass_p): Add store bypass >> (arcv_rhx100_store_insn): Likewise. >> (arcv_rhx100_load_insn): Add load bypass. >> * config/riscv/riscv-cores.def (RISCV_TUNE): >> Add arcv_rpx100 tune >> * config/riscv/riscv-opts.h (enum riscv_microarchitecture_type): >> Add arcv_rpx100 microarchitecture type >> * config/riscv/riscv.md (low,high): Add low/high mul_part >> attribute, default value: low. >> * doc/riscv-mtune.texi: Add rpx_100 tune >> >> gcc/testsuite/ChangeLog: >> >> * gcc.target/riscv/arcv-sched-mul-mem-rpx100.c: New test. >> >> Signed-off-by: Loeka Rogge > This looks sensible.? I *think* it can be committed without patch #2, > but I'll wait for your confirmation on that before pushing. Hi Jeff, This indeed can be committed independently of 2/2. I'm not sure I can interpret this as an OK, so I didn't push to be safe. Thanks, Michiel From michiel@derhaeg.be Mon Nov 2 08:16:21 2026 From: michiel@derhaeg.be (Michiel Derhaeg) Date: Mon, 02 Nov 2026 09:16:21 +0100 Subject: [PATCH 2/2] RISC-V: RPX-100: emit mulh mul pairs in that order In-Reply-To: <997fe46f-74bb-41d0-9e8d-30e443148d99@oss.qualcomm.com> References: <20261030134212.2387766-1-exuro@exuro.be> <20261030134212.2387766-2-exuro@exuro.be> <997fe46f-74bb-41d0-9e8d-30e443148d99@oss.qualcomm.com> Message-ID: <8733tj4pii.fsf@derhaeg.be> Hi Jeff, Jeff Law writes: > On 10/30/26 7:41 AM, exuro wrote: >> From: Loeka Rogge >> >> RPX-100 allows a mulh(s/u) followed by a mul operation to be bonded, >> saving 3 cycles in the multiplier and allowing the mul's result to be >> used 1 cycle earlier than expected. >> >> - Adjust pipeline multiplier reservations for bonded case. Typically >> mulh(s/u) is always emitted together with mul, otherwise this is a bit >> optimistic. >> - Define_expand mulditi3 is modified to emit the high part first for >> rpx100 >> - Added RISCV_FUSE_BONDED_MUL fusion >> - riscv_sched_adjust_cost reflects the mul result being available 1 >> cycle sooner in this case >> >> Regtested on rv32gc, rv64gc and with rhx100 config and mtune. >> >> gcc/ChangeLog: >> >> * config/riscv/arcv-rhx100.md: Adjust mul reservation for >> typical bonded case. >> * config/riscv/riscv-cores.def (RISCV_TUNE): Make rpx100 a >> separate tune instead of reusing rhx100 tune >> * config/riscv/riscv-fusion.cc (riscv_set_is_multiply_high_pattern_p): >> Check if a set is a mulh(s/u) pattern. >> (riscv_get_mulh_operands): Get operands from a mulh(s/u) >> pattern. >> (riscv_fuse_bonded_mul): Check for bonded mul pairs to fuse. >> (riscv_depends_on_lowpart_bonded_mul_p): check if dependency is >> on low part of a bonded mul operation. >> * config/riscv/riscv-protos.h (enum riscv_fusion_pairs): Add >> RISCV_FUSE_BONDED_MUL fusion >> (riscv_depends_on_lowpart_bonded_mul_p): Add function header >> for use in riscv.cc . >> * config/riscv/riscv.cc (riscv_sched_adjust_cost): Adjust cost >> for rpx100 bonded mul. >> * config/riscv/riscv.md: Change mul mulh emit order for if the >> fusion is enabled. >> >> gcc/testsuite/ChangeLog: >> >> * gcc.target/riscv/fusion-bonded-mul-1.c: New test. >> >> Signed-off-by: Loeka Rogge >> --- >> >> >> /* Check the common RTL for ZEXTW, ZEXTWS and ZEXTH fusion. */ >> >> static bool >> @@ -744,6 +776,111 @@ riscv_fuse_b_alui (rtx_insn *prev, rtx_insn *curr) >> return false; >> } >> >> +/* Extract register operands and destination from multiply high-part pattern. >> + Operands are returned in the order of the assembly instruction. The usmul >> + pattern emits the operands in the reverse order. >> + Returns true if successful. */ >> + >> +static bool >> +riscv_get_mulh_operands (rtx set_rtx, rtx *op0, rtx *op1, rtx *dest) >> +{ >> + if (!riscv_set_is_multiply_high_pattern_p (set_rtx)) >> + return false; >> + >> + rtx mulh_pattern = SET_SRC (set_rtx); >> + >> + rtx lshiftrt = XEXP (mulh_pattern, 0); >> + rtx mult = XEXP (lshiftrt, 0); >> + >> + rtx operand0 = XEXP (mult, 0); >> + rtx operand1 = XEXP (mult, 1); >> + >> + /* Swap operands for usmul pattern. */ >> + if (GET_CODE (operand0) == ZERO_EXTEND >> + && GET_CODE (operand1) == SIGN_EXTEND) >> + std::swap (operand0, operand1); >> + >> + /* Strip zero_extend/sign_extend. */ >> + if (GET_CODE (operand0) == ZERO_EXTEND || GET_CODE (operand0) == SIGN_EXTEND) >> + operand0 = XEXP (operand0, 0); >> + if (GET_CODE (operand1) == ZERO_EXTEND || GET_CODE (operand1) == SIGN_EXTEND) >> + operand1 = XEXP (operand1, 0); >> + >> + /* Strip subreg. */ >> + if (GET_CODE (operand0) == SUBREG) >> + operand0 = SUBREG_REG (operand0); >> + if (GET_CODE (operand1) == SUBREG) >> + operand1 = SUBREG_REG (operand1); > You should probably verify that you're getting the right part of the > subreg expression here.? If you want the low word, here's > subreg_lowpart_p to verify that's what you're really getting. >> +} >> + >> +/* Check for RISCV_FUSE_BONDED_MUL fusion. >> + prev (mulh/mulhu/mulhsu) and curr (mul) of the same inputs, with the >> + high-part destination distinct from both inputs. */ >> + >> +static bool >> +riscv_fuse_bonded_mul (rtx_insn *prev, rtx_insn *curr) > You should check that PREV is not marked for fusion.? ?It's likely to be > marked, but better to be sure. > I presume you mean checking this in riscv_depends_on_lowpart_bonded_mul_p before calling riscv_fuse_bonded_mul. >> + >> +bool >> +riscv_depends_on_lowpart_bonded_mul_p (int dep_type, rtx_insn *dep_insn) >> +{ >> + if (dep_type != REG_DEP_TRUE) >> + return false; >> + >> + rtx_insn *prev_insn = prev_nondebug_insn (dep_insn); > I think you want prev_nonnote_nondebug_insn here.? I think you can see > things like NOTE_INSN_DELETED_DEBUG_LABEL and such here. > > >> diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md >> index eb188ff5514..c1493193a53 100644 >> --- a/gcc/config/riscv/riscv.md >> +++ b/gcc/config/riscv/riscv.md >> @@ -1285,10 +1285,18 @@ (define_expand "mulditi3" >> "(TARGET_ZMMUL || TARGET_MUL) && TARGET_64BIT" >> { >> rtx low = gen_reg_rtx (DImode); >> - emit_insn (gen_muldi3 (low, operands[1], operands[2])); >> - >> rtx high = gen_reg_rtx (DImode); >> - emit_insn (gen_muldi3_highpart (high, operands[1], operands[2])); >> + >> + if (riscv_get_fusible_ops () & RISCV_FUSE_BONDED_MUL) >> + { >> + emit_insn (gen_muldi3_highpart (high, operands[1], operands[2])); >> + emit_insn (gen_muldi3 (low, operands[1], operands[2])); >> + } >> + else >> + { >> + emit_insn (gen_muldi3 (low, operands[1], operands[2])); >> + emit_insn (gen_muldi3_highpart (high, operands[1], operands[2])); >> + } >> >> emit_move_insn (gen_lowpart (DImode, operands[0]), low); >> emit_move_insn (gen_highpart (DImode, operands[0]), high); >> @@ -1317,10 +1325,18 @@ (define_expand "usmulditi3" >> "(TARGET_ZMMUL || TARGET_MUL) && TARGET_64BIT" >> { >> rtx low = gen_reg_rtx (DImode); >> - emit_insn (gen_muldi3 (low, operands[1], operands[2])); >> - >> rtx high = gen_reg_rtx (DImode); >> - emit_insn (gen_usmuldi3_highpart (high, operands[1], operands[2])); >> + >> + if (riscv_get_fusible_ops () & RISCV_FUSE_BONDED_MUL) >> + { >> + emit_insn (gen_usmuldi3_highpart (high, operands[1], operands[2])); >> + emit_insn (gen_muldi3 (low, operands[2], operands[1])); >> + } >> + else >> + { >> + emit_insn (gen_muldi3 (low, operands[1], operands[2])); >> + emit_insn (gen_usmuldi3_highpart (high, operands[1], operands[2])); >> + > Huh?? If you're changing code generation in an expander based on FUSION > things, then you're likely doing something wrong.? I'd suggest dropping > these hunks for now and returning to whatever caused you to want to add > it later.? It's a sign you're tackling a problem in the wrong way. We really need the highpart to appear first or the fusion won't be found. The conditionals aren't really needed, this change can be made independent of the fusion being available. But now that you mention it we could probably adjust priority here instead. Know that we do have to change codegen whatever solution we pick because some highpart asm templates swap their input operands and we swap muldi3's inputs to match. Our fusion requires this order to match for both instructions. I would like to have a system to express register constraints like this for fusions, but that doesn't exist yet. Thanks, Michiel From jeevitha@linux.ibm.com Mon Nov 2 08:15:42 2026 From: jeevitha@linux.ibm.com (jeevitha) Date: Mon, 2 Nov 2026 13:45:42 +0530 Subject: [PATCH v3] rs6000: Inefficient vector splat of small V2DI constants [PR107757] In-Reply-To: References: Message-ID: Hi, Just has minor formatting nits: On 29/10/26 2:06 pm, Surya Kumari Jangala wrote: > Hi Mike, > > Changes from v2: > - Removed 'dg-do compile' and 'dg-require-effective-target powerpc_vsx' from > the testcases. > Changes from v1: > - Removed -mvsx option from the list of dg-options in the testcases. > > Below patch is bootstrapped and regtested on powerpc64le-linux and powerpc64-linux > with no regressions. > > Regards, > Surya > > rs6000: Inefficient vector splat of small V2DI constants [PR107757] > > On P8, for vector splat of double word constants, specifically -1 and 1, > gcc generates inefficient code. For -1, gcc generates two instructions > (vspltisw and vupkhsw) whereas only one instruction (vspltisw) is > sufficient. For constant 1, gcc generates a load of the constant from > .rodata instead of the instructions vspltisw and vupkhsw. > > The routine vspltisw_vupkhsw_constant_p() returns true if the constant > can be synthesized with instructions vspltisw and vupkhsw. However, for > constant 1, this routine returns false. > > For constant -1, this routine returns true. Vector splat of -1 can be > done with only one instruction, i.e., vspltisw. We do not need two > instructions. Hence this routine should return false for -1. > > With this patch, gcc generates only one instruction (vspltisw) for -1. > And for constant 1, this patch generates two instructions (vspltisw and > vupkhsw). > > 2024-11-20 Surya Kumari Jangala > > gcc/ > PR target/107757 > * config/rs6000/rs6000.cc (vspltisw_vupkhsw_constant_p): > Return false for -1 and return true for 1. ChangeLog: The description can be wrapped further to maintain its limit. > > gcc/testsuite/ > PR target/107757 > * gcc.target/powerpc/pr107757-1.c: New. > * gcc.target/powerpc/pr107757-2.c: New. > --- > gcc/config/rs6000/rs6000.cc | 2 +- > gcc/testsuite/gcc.target/powerpc/pr107757-1.c | 12 ++++++++++++ > gcc/testsuite/gcc.target/powerpc/pr107757-2.c | 11 +++++++++++ > 3 files changed, 24 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.target/powerpc/pr107757-1.c > create mode 100644 gcc/testsuite/gcc.target/powerpc/pr107757-2.c > > diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc > index bd3250f656b..5bffa2294d6 100644 > --- a/gcc/config/rs6000/rs6000.cc > +++ b/gcc/config/rs6000/rs6000.cc > @@ -6760,7 +6760,7 @@ vspltisw_vupkhsw_constant_p (rtx op, machine_mode mode, int *constant_ptr) > return false; > > value = INTVAL (elt); > - if (value == 0 || value == 1 > + if (value == 0 || value == -1 > || !EASY_VECTOR_15 (value)) > return false; > > diff --git a/gcc/testsuite/gcc.target/powerpc/pr107757-1.c b/gcc/testsuite/gcc.target/powerpc/pr107757-1.c > new file mode 100644 > index 00000000000..b33a2912b94 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr107757-1.c > @@ -0,0 +1,12 @@ > +/* { dg-options "-mdejagnu-cpu=power8 -O2" } */ > +/* { dg-final { scan-assembler {\mvspltisw\M} } } */ > +/* { dg-final { scan-assembler {\mvupkhsw\M} } } */ > +/* { dg-final { scan-assembler-not {\mlvx\M} } } */ > + > +#include > + > +vector long long > +foo () > +{ > + return vec_splats (1LL); > +} The return statement appears to have inconsistent indentation. > diff --git a/gcc/testsuite/gcc.target/powerpc/pr107757-2.c b/gcc/testsuite/gcc.target/powerpc/pr107757-2.c > new file mode 100644 > index 00000000000..4312049c20d > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr107757-2.c > @@ -0,0 +1,11 @@ > +/* { dg-options "-mdejagnu-cpu=power8 -O2" } */ > +/* { dg-final { scan-assembler {\mvspltisw\M} } } */ > +/* { dg-final { scan-assembler-not {\mvupkhsw\M} } } */ > + > +#include > + > +vector long long > +foo () > +{ > + return vec_splats (~0LL); > +} Similar indentation issue Also wanted to ask few things here, #include vector long long foo() { return vec_splats(~0LL); } vector long long foo1() { return vec_splats(0LL); } Right with above patch we are generating this foo: vspltisw 2,-1 blr foo1: vspltisw 2,0 blr instead of generating altivec is it fine to generate VSX? I'm not sure about performance impact foo: xxleqv 34, 34, 34 blr foo1: xxlxor 34, 34, 34 blr According to the POWER10 User Manual, the latency figures are: Latency (min) (max) xxlnor - 1 3 xxleqv - 1 3 vspltisw - 3 4 The VSX logical instructions appear to have lower latency. Would it be worth considering these instructions instead of vspltisw? Thanks, Jeevitha. From yansendao@126.com Mon Nov 2 08:19:43 2026 From: yansendao@126.com (Sendao Yan) Date: Mon, 2 Nov 2026 16:19:43 +0800 Subject: [PATCH 2/2] tree-optimization/128102 - fix -Wuninitialized FPs In-Reply-To: <4a6ca9e0-46a6-4c87-aa5e-286e932c7e78@oss.qualcomm.com> References: <4a6ca9e0-46a6-4c87-aa5e-286e932c7e78@oss.qualcomm.com> Message-ID: <20261102081943.2984674-1-yansendao@126.com> Hi Jeff, Thanks for pointing me at Sashiko. I triaged the five findings on patch 2/2: VF1 (Medium): real bug in the fallback path of is_use_guarded. When the definition predicate simplifies to TRUE it guards any use, but the v1 fallback only checked the superset relation, which is vacuous for a TRUE predicate, so the conditional-use case was missed. Fixed in the amended patch: the fallback now accepts a TRUE definition predicate unconditionally and only falls back to the superset check for a non-TRUE use predicate. VF2 (Medium): drop_conjuncts_implied_by can leave empty chains, but that case is already subsumed by the existing superset_of() check, so there is no observable behavior difference. Left as-is. VF3 (Medium): the b_chain leak in simplify_2's ordered_remove is real, but it predates this patch and is unrelated to 128102. I can send a one-line fix (b_chain.release() before the removal) as a separate patch, or file a separate PR, whichever you prefer. PVF1/PVF2 (Medium/Low): the m_cval inconsistency/caching issues are also pre-existing; I've noted them as follow-ups and left them out of this series. The amended v2 series is bootstrapped and regression-tested on x86_64-linux-gnu and aarch64-linux-gnu (bootstrap-debug with a clean stage2/stage3 compare; check-c and check-c++). PR128102's new test, PR44547 and PR107919 pass on both targets; the remaining unexpected failures on each target are pre-existing and unrelated. Thanks, Sendao From vov.dm.an@gmail.com Mon Nov 2 08:21:04 2026 From: vov.dm.an@gmail.com (Dmitrii Vovdenko) Date: Mon, 2 Nov 2026 11:21:04 +0300 Subject: [RFC PATCH v2] match: Expose constant factors through signed widening conversions In-Reply-To: <20261029103645.3266839-1-vov.dm.an@gmail.com> References: <20261029103645.3266839-1-vov.dm.an@gmail.com> Message-ID: <20261102082104.3745544-1-vov.dm.an@gmail.com> A signed widening conversion can hide a constant factor from the existing multiplication reassociation and constant division rules. For example, (long long) (a * 30) * b / 6 retains the narrow multiplication and division instead of becoming ((long long) a * b) * 5. Expose the inner multiplication in a multiply/multiply or multiply/divide chain when both types are signed integral types with undefined overflow and the conversion does not narrow. Exclude overflow instrumentation and use the existing single-use restrictions to avoid duplicating producers. For division, require a nonzero divisor that divides the inner constant. For multiplication, require the product of the constants to fit the destination type. Let the existing simplifications reassociate and combine the constants. gcc/ChangeLog: * match.pd: Expose constant multiplication through signed non-narrowing conversions in multiplication and division chains. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/widen-mult-const-1.c: New test. * gcc.dg/tree-ssa/widen-mult-const-2.c: Likewise. * gcc.dg/tree-ssa/widen-mult-const-3.c: Likewise. * gcc.dg/tree-ssa/widen-mult-const-4.c: Likewise. * gcc.dg/tree-ssa/widen-mult-const-5.c: Likewise. * gcc.dg/tree-ssa/widen-mult-const-6.c: Likewise. * gcc.dg/tree-ssa/widen-mult-const-7.c: Likewise. Signed-off-by: Dmitrii Vovdenko --- Hello, Changes since v1: Added widen-mult-const-7.c using the GIMPLE frontend and explicit __EXACT_DIV operations, as suggested in review. It covers full cancellation and partial cancellation, checking the optimized statements and the remaining factor of 5. The other six tests are unchanged. Removed the exclusions for zero and minus one inner factors, and retained the nonzero outer constant check only for division, following the review comments. Also corrected the explanatory expression to show the conversion of C1 explicitly. I would appreciate feedback on the correctness conditions and approach of this match.pd optimization before completing full validation. My motivation example have appeared in fixed point arithmetic library. After inlining, an example looks like this: int foo (int a, int b) { return (static_cast(a * (1 << 16)) * b) / (1 << 16); } On defined executions, it can be simplified to: int foo (int a, int b) { return static_cast(a) * b; } The conversion prevents the existing patterns from exposing and cancelling the constant factor in the original expression. The patch below addresses this with a guarded GIMPLE pattern, as described above. The pattern is restricted to GIMPLE because it relies on single-use checks to avoid duplicating shared multiplications, and the motivating code only appears after inlining. Seven regression tests cover complete and partial cancellation, including explicit exact division through the GIMPLE frontend, constant multiplication, negative and commuted operands, wrapping and trapping arithmetic, shared intermediate values, unsigned sources, and constant product overflow. Runtime checks exercise signed integer boundaries. The positive compile tests disable tree reassociation to exercise the folding patterns independently of that pass. This implementation is deliberately narrow. A more general approach could construct a temporary candidate expression after exposing the constant, simplify it using the existing machinery, and evaluate its profitability before committing the transformation. That would add considerable complexity, and I would appreciate advice on whether it is warranted. Testing status: Tested on x86_64-pc-linux-gnu with a non-bootstrapped build (C and C++), comparing against an unpatched build at the same revision. There are no new failures in the gcc, g++, libstdc++, libatomic, libitm, and libgomp testsuites, and the new tests pass. A full bootstrap and regression test is pending. The patch is based on d5b9d3a458a58766d03445441e3952d43824c402. There is no associated Bugzilla PR for this submission. Is exposing the factor through this guarded match.pd pattern an appropriate approach? Are there additional correctness or profitability restrictions that should be considered? Thank you, Dmitrii Vovdenko gcc/match.pd | 24 +++++++ .../gcc.dg/tree-ssa/widen-mult-const-1.c | 35 +++++++++ .../gcc.dg/tree-ssa/widen-mult-const-2.c | 29 ++++++++ .../gcc.dg/tree-ssa/widen-mult-const-3.c | 18 +++++ .../gcc.dg/tree-ssa/widen-mult-const-4.c | 8 ++ .../gcc.dg/tree-ssa/widen-mult-const-5.c | 35 +++++++++ .../gcc.dg/tree-ssa/widen-mult-const-6.c | 73 +++++++++++++++++++ .../gcc.dg/tree-ssa/widen-mult-const-7.c | 40 +++++++++++ 8 files changed, 262 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-1.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-2.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-3.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-4.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-5.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-6.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-7.c diff --git a/gcc/match.pd b/gcc/match.pd index f3d9e55f139..7b32940d1a1 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1125,6 +1125,30 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) wi::exact_log2 (wi::to_wide (@1))); })))) #endif +#if GIMPLE +/* Simplify (T)(X * C1) * Y op C2 -> ((T)X * (T)C1) * Y op C2, where op is a + multiplication or a division, to expose C1 to the reassociation and + constant folding patterns. This is valid when T and the type of X are + signed with undefined overflow and T is not narrower, since X * C1 then + cannot overflow. Only do this when C1 and C2 can be combined. */ +(for op (mult trunc_div exact_div) + (simplify + (op (mult:cs (convert:s (mult:s @0 INTEGER_CST@1)) @2) INTEGER_CST@3) + (if (INTEGRAL_TYPE_P (type) + && INTEGRAL_TYPE_P (TREE_TYPE (@0)) + && TYPE_PRECISION (type) >= TYPE_PRECISION (TREE_TYPE (@0)) + && TYPE_OVERFLOW_UNDEFINED (type) + && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)) + && !TYPE_OVERFLOW_SANITIZED (type) + && !TYPE_OVERFLOW_SANITIZED (TREE_TYPE (@0)) + && (op == MULT_EXPR + ? wi::fits_to_tree_p (wi::to_widest (@1) * wi::to_widest (@3), type) + : (!integer_zerop (@3) + && wi::multiple_of_p (wi::to_widest (@1), wi::to_widest (@3), + SIGNED)))) + (op (mult (mult (convert @0) (convert @1)) @2) @3)))) +#endif + (for div (trunc_div ceil_div floor_div round_div exact_div) /* Simplify (t * u) / u -> t. */ (simplify diff --git a/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-1.c b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-1.c new file mode 100644 index 00000000000..cd24da3dc69 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-1.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32 } */ +/* { dg-require-effective-target longlong64 } */ +/* { dg-options "-O2 -fno-tree-reassoc -fdump-tree-optimized-raw" } */ + +__attribute__((noipa)) long long +cancel (int a, long long b) +{ + return (long long) (a * 65536) * b / 65536; +} + +__attribute__((noipa)) long long +partial (int a, long long b) +{ + return (long long) (a * 30) * b / 6; +} + +__attribute__((noipa)) long long +negative (int a, long long b) +{ + return (long long) (a * -30) * b / 6; +} + +__attribute__((noipa)) long long +commuted (int a, long long b) +{ + return b * (long long) (-30 * a) / -30; +} + +/* { dg-final { scan-tree-dump-times { References: Message-ID: <8qrqop6o-or96-0p4r-8850-7691q7qr6s4s@fhfr.qr> On Fri, 30 Oct 2026, Jakub Jelinek wrote: > Hi! > > On Wed, Oct 28, 2026 at 01:48:35PM +0100, Richard Biener wrote: > > The documentation might benefit from one of your examples above > > being added. > > I've added example how to use the builtin into the docs now. > > On Thu, Oct 29, 2026 at 06:12:06PM -0400, Jason Merrill wrote: > > On 10/28/26 6:48 AM, Jakub Jelinek wrote: > > > --- a/gcc/cp/constexpr.cc 2026-10-23 15:12:24.052873710 +0200 > > > +++ b/gcc/cp/constexpr.cc 2026-10-27 08:41:24.586219933 +0100 > > > + location_t loc = cp_expr_loc_or_input_loc (t); > > > + if (TREE_CODE (args[0]) != INTEGER_CST > > > + || TREE_CODE (args[1]) != INTEGER_CST > > > + || !INTEGRAL_TYPE_P (TREE_TYPE (args[0])) > > > + || !TYPE_UNSIGNED (TREE_TYPE (args[0])) > > > + || !same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (args[0])), > > > + TYPE_MAIN_VARIANT (TREE_TYPE (args[1]))) > > > + || (args[2] && !POINTER_TYPE_P (TREE_TYPE (args[2])))) > > > > Aren't the types checked when building the expression in the first place? > > It is checked in build_x_clmulg when none of the operands are > type-dependent, otherwise it creates the internal fn call with > build_min_nt_call_vec. I was afraid fold_non_dependent_expr might > have this called even in that case, but thinking about it again, > I really hope it shouldn't, such call is type dependent... > > > > + tree mod = build2_loc (loc, MODIFY_EXPR, void_type_node, > > > + build_fold_addr_expr_loc (loc, args[2]), > > > > Shouldn't this be build_fold_indirect_ref_loc? > > You're right, fixed. > > > It looks like there are no constexpr tests? > > Yeah, the 2 argument calls are actually tested already in various constant > expressions and asserts, but indeed the 3 argument one wasn't and the > above spot is about the 3 argument case. > > I've added a test for this now. > > Additionally, I've added another test for x86, basically compiling and > running the main new test with -O2 -mpclmul rather than -O2 (+ making sure > it doesn't fail if the ISA isn't supported). > That revealed another bug, one of the conditions guarding the use of > the non-widening optab was bogus. > Earlier > if (prec0 > this_prec || prec1 > this_prec) > continue; > already guarantees that both the operands can be cast to cmode without > losing any non-zero bits, and in > if (optab_handler (clmul_optab, cmode) != CODE_FOR_nothing > && (prec0 + prec1 - 1 <= this_prec || prec0 + prec1 - 1 <= prec)) > the prec0 + prec1 - 1 <= this_prec check is correct, we can use the > non-widening hw insn with this_prec x this_prec -> this_prec bits > if the result clearly won't need bits beyond this_prec, but > prec0 + prec1 - 1 <= prec is bogus, that is true or false regardless of > cmode/this_prec we pick and just says that the whole expand_clmul is > computing all non-zero bits rather than just subset of those. > We want prec <= this_prec instead (i.e. whether cmode gives us everything > we need). And can use it later on for the widening case where it just uses > the low half too. > > So far lightly tested. OK for the middle-end parts. Thanks, Richard. > 2026-10-30 Jakub Jelinek > > PR middle-end/128111 > * doc/extend.texi (__builtin_clmulg): Document. > * builtins.h (fold_build_builtin_clmulg): Declare. > * fold-const-call.cc (fold_const_call_sss): Handle CFN_CLMUL. > (fold_const_call): Handle CFN_CLMUL_WIDEN. > * internal-fn.h (expand_CLMUL, expand_CLMUL_WIDEN): Declare. > * fold-const.cc (tree_call_nonnegative_p): Handle CFN_CLMUL. > * wide-int.cc (wi::bit_repeat, wi::clmul): New functions. > * wide-int.h (wi::bit_repeat, wi::clmul): Declare. > * builtins.cc (fold_build_builtin_clmulg): New function. > * internal-fn.def (CLMUL, CLMUL_WIDEN): New internal functions. > * internal-fn.cc (commutative_binary_fn_p): Handle IFN_CLMUL > and IFN_CLMUL_WIDEN. > (expand_clmul, expand_CLMUL, expand_CLMUL_WIDEN): New functions. > * optabs.def (clmul_optab, clmul_widen_optab): New optabs. > * gimple-lower-bitint.cc (struct bitint_large_huge): Declare > lower_clmul method. > (bitint_large_huge::lower_clmul): New method. > (bitint_large_huge::lower_call): Handle IFN_CLMUL. > (bitint_large_huge::lower_stmt): Likewise. > (stmt_needs_operand_addr): Likewise. > (build_bitint_stmt_ssa_conflicts): Likewise. > (gimple_lower_bitint): Lower IFN_CLMUL_WIDEN to 2 IFN_CLMUL > calls, 3 IFN_BITREVERSE calls, one shift and one COMPLEX_EXPR. > Handle IFN_CLMUL. > * match.pd (.CLMUL (X, Y) for [0, 1] Y -> X * Y, > (.CLMUL_WIDEN (X, Y) -> { .CLMUL (X, 0), 0 } if upper bits are > known to be zeros): New simplifications. > * genmatch.cc (genmatch_diag_selftests): > (commutative_op): Handle CFN_CLMUL and CFN_CLMUL_WIDEN. > * config/i386/sse.md (clmuldi3, clmul_widendi3): New expanders. > gcc/c-family/ > * c-common.h (enum rid): Add RID_BUILTIN_CLMULG enumerator. > * c-common.cc (c_common_reswords): Add __builtin_clmulg entry. > gcc/c/ > * c-parser.cc (c_parser_postfix_expression): Handle > RID_BUILTIN_CLMULG. > * c-decl.cc (names_builtin_p): Handle RID_BUILTIN_CLMULG. > gcc/cp/ > * parser.cc (cp_parser_postfix_expression): Handle RID_BUILTIN_CLMULG. > * typeck.cc (build_x_clmulg): New function. > * cp-tree.h (build_x_clmulg): Declare. > * pt.cc (tsubst_expr): Handle IFN_CLMUL. > * mangle.cc (write_expression): Likewise. > * cp-objcp-common.cc (names_builtin_p): Handle RID_BUILTIN_CLMULG. > * cp-gimplify.cc (cp_gimplify_expr): Handle IFN_CLMUL. > * constexpr.cc (cxx_eval_internal_function): Likewise. > (potential_constant_expression_1): Likewise. > gcc/testsuite/ > * c-c++-common/builtin-clmulg-1.c: New test. > * c-c++-common/builtin-clmulg-2.c: New test. > * g++.dg/ext/builtin-clmulg-1.C: New test. > * gcc.target/i386/pclmul-builtin-clmulg-1.c: New test. > > --- a/gcc/c-family/c-common.h 2026-10-27 14:32:12.567304216 +0100 > +++ b/gcc/c-family/c-common.h 2026-10-30 17:06:34.328025285 +0100 > @@ -112,7 +112,7 @@ enum rid > RID_BUILTIN_SHUFFLEVECTOR, RID_BUILTIN_CONVERTVECTOR, RID_BUILTIN_TGMATH, > RID_BUILTIN_HAS_ATTRIBUTE, RID_BUILTIN_ASSOC_BARRIER, RID_BUILTIN_STDC, > RID_BUILTIN_COUNTED_BY_REF, RID_BUILTIN_BSWAPG, > - RID_BUILTIN_BITREVERSEG, > + RID_BUILTIN_BITREVERSEG, RID_BUILTIN_CLMULG, > RID_DFLOAT32, RID_DFLOAT64, RID_DFLOAT128, RID_DFLOAT64X, > > /* TS 18661-3 keywords, in the same sequence as the TI_* values. */ > --- a/gcc/c-family/c-common.cc 2026-10-30 17:05:21.661552875 +0100 > +++ b/gcc/c-family/c-common.cc 2026-10-30 17:06:34.328833881 +0100 > @@ -439,6 +439,7 @@ const struct c_common_resword c_common_r > { "__builtin_call_with_static_chain", > RID_BUILTIN_CALL_WITH_STATIC_CHAIN, D_CONLY }, > { "__builtin_choose_expr", RID_CHOOSE_EXPR, D_CONLY }, > + { "__builtin_clmulg", RID_BUILTIN_CLMULG, 0 }, > { "__builtin_complex", RID_BUILTIN_COMPLEX, D_CONLY }, > { "__builtin_convertvector", RID_BUILTIN_CONVERTVECTOR, 0 }, > { "__builtin_counted_by_ref", RID_BUILTIN_COUNTED_BY_REF, D_CONLY }, > --- a/gcc/c/c-parser.cc 2026-10-27 14:32:12.572304150 +0100 > +++ b/gcc/c/c-parser.cc 2026-10-30 17:06:34.330615332 +0100 > @@ -13556,15 +13556,29 @@ c_parser_postfix_expression (c_parser *p > } > case RID_BUILTIN_BSWAPG: > case RID_BUILTIN_BITREVERSEG: > + case RID_BUILTIN_CLMULG: > { > vec *cexpr_list; > location_t close_paren_loc; > - internal_fn ifn > - = (c_parser_peek_token (parser)->keyword == RID_BUILTIN_BSWAPG > - ? IFN_BSWAP : IFN_BITREVERSE); > - const char *name > - = (ifn == IFN_BSWAP ? "__builtin_bswapg" > - : "__builtin_bitreverseg"); > + internal_fn ifn; > + const char *name; > + switch (c_parser_peek_token (parser)->keyword) > + { > + case RID_BUILTIN_BSWAPG: > + ifn = IFN_BSWAP; > + name = "__builtin_bswapg"; > + break; > + case RID_BUILTIN_BITREVERSEG: > + ifn = IFN_BITREVERSE; > + name = "__builtin_bitreverseg"; > + break; > + case RID_BUILTIN_CLMULG: > + ifn = IFN_CLMUL; > + name = "__builtin_clmulg"; > + break; > + default: > + gcc_unreachable (); > + } > > c_parser_consume_token (parser); > if (!c_parser_get_builtin_args (parser, name, &cexpr_list, false, > @@ -13574,7 +13588,8 @@ c_parser_postfix_expression (c_parser *p > break; > } > > - if (vec_safe_length (cexpr_list) != 1) > + if (vec_safe_length (cexpr_list) < (ifn == IFN_CLMUL ? 2 : 1) > + || vec_safe_length (cexpr_list) > (ifn == IFN_CLMUL ? 3 : 1)) > { > error_at (loc, "wrong number of arguments to %qs", name); > expr.set_error (); > @@ -13626,7 +13641,70 @@ c_parser_postfix_expression (c_parser *p > break; > } > arg = c_fully_fold (arg, false, NULL); > - expr.value = fold_build_builtin_bswapg_bitreverseg (loc, ifn, arg); > + if (ifn == IFN_CLMUL) > + { > + arg_p = &(*cexpr_list)[1]; > + *arg_p = convert_lvalue_to_rvalue (loc, *arg_p, true, true); > + tree arg2 = arg_p->value; > + if (error_operand_p (arg2)) > + { > + expr.set_error (); > + break; > + } > + if (!comptypes_same_p (type, > + TYPE_MAIN_VARIANT (TREE_TYPE (arg2)))) > + { > + error_at (loc, "arguments 1 and 2 to function %qs " > + "have different types %qT and %qT", > + name, type, > + TYPE_MAIN_VARIANT (TREE_TYPE (arg2))); > + expr.set_error (); > + break; > + } > + arg2 = c_fully_fold (arg2, false, NULL); > + tree arg3 = NULL_TREE; > + if (vec_safe_length (cexpr_list) == 3) > + { > + arg_p = &(*cexpr_list)[2]; > + *arg_p = convert_lvalue_to_rvalue (loc, *arg_p, > + true, true); > + arg3 = arg_p->value; > + if (error_operand_p (arg3)) > + { > + expr.set_error (); > + break; > + } > + if (!POINTER_TYPE_P (TREE_TYPE (arg3))) > + { > + error_at (loc, > + "argument 3 to function %qs does not have " > + "pointer type", name); > + expr.set_error (); > + break; > + } > + tree htype = TREE_TYPE (TREE_TYPE (arg3)); > + if (!comptypes_same_p (type, TYPE_MAIN_VARIANT (htype))) > + { > + error_at (loc, "arguments 1 and 3 to function %qs " > + "have incompatible types %qT and %qT", > + name, type, TREE_TYPE (arg3)); > + expr.set_error (); > + break; > + } > + if (TYPE_READONLY (htype)) > + { > + error_at (loc, "arguments 3 to function %qs " > + "have pointer to % type %qT", > + name, TREE_TYPE (arg3)); > + expr.set_error (); > + break; > + } > + } > + expr.value = fold_build_builtin_clmulg (loc, arg, arg2, arg3); > + } > + else > + expr.value = fold_build_builtin_bswapg_bitreverseg (loc, ifn, > + arg); > set_c_expr_source_range (&expr, loc, close_paren_loc); > break; > } > --- a/gcc/c/c-decl.cc 2026-10-27 14:32:12.568304203 +0100 > +++ b/gcc/c/c-decl.cc 2026-10-30 17:06:34.332930406 +0100 > @@ -11936,6 +11936,7 @@ names_builtin_p (const char *name) > case RID_BUILTIN_ASSOC_BARRIER: > case RID_BUILTIN_BITREVERSEG: > case RID_BUILTIN_BSWAPG: > + case RID_BUILTIN_CLMULG: > case RID_BUILTIN_CONVERTVECTOR: > case RID_BUILTIN_HAS_ATTRIBUTE: > case RID_BUILTIN_SHUFFLE: > --- a/gcc/config/i386/sse.md 2026-10-29 10:04:45.902698675 +0100 > +++ b/gcc/config/i386/sse.md 2026-10-30 17:06:34.369614829 +0100 > @@ -28902,6 +28902,49 @@ (define_insn "pclmulqdq" > (set_attr "c86_decode" "*,vector,vector") > (set_attr "mode" "TI")]) > > +(define_expand "clmuldi3" > + [(match_operand:DI 0 "register_operand") > + (match_operand:DI 1 "register_operand") > + (match_operand:DI 2 "register_operand")] > + "TARGET_PCLMUL" > +{ > + rtx x = gen_reg_rtx (V2DImode); > + rtx y = gen_reg_rtx (V2DImode); > + rtx z = gen_reg_rtx (V2DImode); > + emit_move_insn (x, gen_rtx_VEC_CONCAT (V2DImode, operands[1], const0_rtx)); > + emit_move_insn (y, gen_rtx_VEC_CONCAT (V2DImode, operands[2], const0_rtx)); > + emit_insn (gen_pclmulqdq (z, x, y, const0_rtx)); > + rtvec tmp = rtvec_alloc (1); > + RTVEC_ELT (tmp, 0) = const0_rtx; > + rtx selector = gen_rtx_PARALLEL (VOIDmode, tmp); > + emit_move_insn (operands[0], gen_rtx_VEC_SELECT (DImode, z, selector)); > + DONE; > +}) > + > +(define_expand "clmul_widendi3" > + [(match_operand:DI 0 "register_operand") > + (match_operand:DI 1 "register_operand") > + (match_operand:DI 2 "register_operand") > + (match_operand:DI 3 "register_operand")] > + "TARGET_PCLMUL" > +{ > + rtx x = gen_reg_rtx (V2DImode); > + rtx y = gen_reg_rtx (V2DImode); > + rtx z = gen_reg_rtx (V2DImode); > + emit_move_insn (x, gen_rtx_VEC_CONCAT (V2DImode, operands[2], const0_rtx)); > + emit_move_insn (y, gen_rtx_VEC_CONCAT (V2DImode, operands[3], const0_rtx)); > + emit_insn (gen_pclmulqdq (z, x, y, const0_rtx)); > + rtvec tmp = rtvec_alloc (1); > + RTVEC_ELT (tmp, 0) = const0_rtx; > + rtx selector = gen_rtx_PARALLEL (VOIDmode, tmp); > + emit_move_insn (operands[0], gen_rtx_VEC_SELECT (DImode, z, selector)); > + tmp = rtvec_alloc (1); > + RTVEC_ELT (tmp, 0) = const1_rtx; > + selector = gen_rtx_PARALLEL (VOIDmode, tmp); > + emit_move_insn (operands[1], gen_rtx_VEC_SELECT (DImode, z, selector)); > + DONE; > +}) > + > (define_expand "avx_vzeroall" > [(match_par_dup 0 [(const_int 0)])] > "TARGET_AVX" > --- a/gcc/cp/parser.cc 2026-10-30 17:05:21.711552230 +0100 > +++ b/gcc/cp/parser.cc 2026-10-30 17:06:34.374614764 +0100 > @@ -8741,6 +8741,7 @@ cp_parser_postfix_expression (cp_parser > case RID_BUILTIN_OPERATOR_DELETE: > case RID_BUILTIN_BSWAPG: > case RID_BUILTIN_BITREVERSEG: > + case RID_BUILTIN_CLMULG: > { > vec *vec; > > @@ -8872,6 +8873,11 @@ cp_parser_postfix_expression (cp_parser > tf_warning_or_error); > break; > > + case RID_BUILTIN_CLMULG: > + postfix_expression > + = build_x_clmulg (loc, vec, tf_warning_or_error); > + break; > + > default: > gcc_unreachable (); > } > --- a/gcc/cp/typeck.cc 2026-10-30 17:05:21.721552101 +0100 > +++ b/gcc/cp/typeck.cc 2026-10-30 17:06:34.375957989 +0100 > @@ -7180,6 +7180,107 @@ build_x_bswapg_bitreverseg (location_t l > } > return exp; > } > + > +/* Build __builtin_clmulg (ARG1, ARG2) or > + __builtin_clmulg (ARG1, ARG2, ARG3). */ > +tree > +build_x_clmulg (location_t loc, vec *args, > + tsubst_flags_t complain) > +{ > + const char *name = "__builtin_clmulg"; > + if (args->length () < 2 || args->length () > 3) > + { > + if (complain & tf_error) > + error_at (loc, "wrong number of arguments to %qs", name); > + return error_mark_node; > + } > + tree arg1 = (*args)[0]; > + tree arg2 = (*args)[1]; > + tree arg3 = args->length () == 3 ? (*args)[2] : NULL_TREE; > + if (error_operand_p (arg1) > + || error_operand_p (arg2) > + || error_operand_p (arg3)) > + return error_mark_node; > + if (type_dependent_expression_p (arg1) > + || type_dependent_expression_p (arg2) > + || type_dependent_expression_p (arg3)) > + { > + tree exp = build_min_nt_call_vec (NULL, args); > + CALL_EXPR_IFN (exp) = IFN_CLMUL; > + return exp; > + } > + tree type = TYPE_MAIN_VARIANT (TREE_TYPE (arg1)); > + if (!INTEGRAL_TYPE_P (type)) > + { > + if (complain & tf_error) > + error_at (loc, "%qs operand not an integral type", name); > + return error_mark_node; > + } > + if (TREE_CODE (type) == ENUMERAL_TYPE) > + { > + if (complain & tf_error) > + error_at (loc, "argument %u in call to function " > + "%qs has enumerated type", 1, name); > + return error_mark_node; > + } > + if (TREE_CODE (type) == BOOLEAN_TYPE) > + { > + if (complain & tf_error) > + error_at (loc, "argument %u in call to function " > + "%qs has boolean type", 1, name); > + return error_mark_node; > + } > + if (!TYPE_UNSIGNED (type)) > + { > + if (complain & tf_error) > + error_at (loc, "argument 1 in call to function " > + "%qs has signed type", name); > + return error_mark_node; > + } > + if (!same_type_p (type, TYPE_MAIN_VARIANT (TREE_TYPE (arg2)))) > + { > + if (complain & tf_error) > + error_at (loc, "arguments 1 and 2 to function %qs " > + "have different types %qT and %qT", > + name, type, TYPE_MAIN_VARIANT (TREE_TYPE (arg2))); > + return error_mark_node; > + } > + if (arg3) > + { > + if (!POINTER_TYPE_P (TREE_TYPE (arg3))) > + { > + if (complain & tf_error) > + error_at (loc, "argument 3 to function %qs does not have " > + "pointer type", name); > + return error_mark_node; > + } > + tree htype = TREE_TYPE (TREE_TYPE (arg3)); > + if (!same_type_p (type, TYPE_MAIN_VARIANT (htype))) > + { > + if (complain & tf_error) > + error_at (loc, "arguments 1 and 3 to function %qs " > + "have incompatible types %qT and %qT", > + name, type, TREE_TYPE (arg3)); > + return error_mark_node; > + } > + if (TYPE_READONLY (htype)) > + { > + if (complain & tf_error) > + error_at (loc, "arguments 3 to function %qs " > + "have pointer to % type %qT", > + name, TREE_TYPE (arg3)); > + return error_mark_node; > + } > + } > + tree exp = build_call_expr_internal_loc (loc, IFN_CLMUL, type, > + arg3 ? 3 : 2, arg1, arg2, arg3); > + if (processing_template_decl) > + { > + exp = build_min_non_dep_call_vec (exp, NULL, args); > + CALL_EXPR_IFN (exp) = IFN_CLMUL; > + } > + return exp; > +} > > /* Return a tree for the sum or difference (RESULTCODE says which) > of pointer PTROP and integer INTOP. */ > --- a/gcc/cp/cp-tree.h 2026-10-30 17:05:21.679552643 +0100 > +++ b/gcc/cp/cp-tree.h 2026-10-30 17:06:34.376884133 +0100 > @@ -9065,6 +9065,9 @@ extern tree build_x_shufflevector > extern tree build_x_bswapg_bitreverseg (location_t, internal_fn, > vec *, > tsubst_flags_t); > +extern tree build_x_clmulg (location_t, > + vec *, > + tsubst_flags_t); > #define cxx_sizeof(T) cxx_sizeof_or_alignof_type (input_location, T, SIZEOF_EXPR, false, true) > extern tree build_simple_component_ref (tree, tree); > extern tree build_ptrmemfunc_access_expr (tree, tree); > --- a/gcc/cp/pt.cc 2026-10-30 17:05:21.714552191 +0100 > +++ b/gcc/cp/pt.cc 2026-10-30 17:06:34.378614712 +0100 > @@ -22732,6 +22732,14 @@ tsubst_expr (tree t, tree args, tsubst_f > break; > } > > + case IFN_CLMUL: > + { > + ret = build_x_clmulg (input_location, call_args, complain); > + if (ret != error_mark_node) > + RETURN (ret); > + break; > + } > + > case IFN_ASSUME: > gcc_assert (nargs == 1); > if (vec_safe_length (call_args) != 1) > --- a/gcc/cp/mangle.cc 2026-10-30 17:05:21.706552295 +0100 > +++ b/gcc/cp/mangle.cc 2026-10-30 17:06:34.380228121 +0100 > @@ -4110,16 +4110,19 @@ write_expression (tree expr) > else > switch (CALL_EXPR_IFN (expr)) > { > - /* Calls to __builtin_bswapg/__builtin_bitreverseg are parsed > - as IFN_BSWAP/IFN_BITREVERSE calls because we don't have > - those builtins but instead keywords. Pretend they are > - builtin function template. */ > + /* Calls to __builtin_bswapg/__builtin_bitreverseg/__builtin_clmulg > + are parsed as IFN_BSWAP/IFN_BITREVERSE/IFN_CLMUL calls because > + we don't have those builtins but instead keywords. Pretend > + they are builtin function template. */ > case IFN_BSWAP: > write_source_name (get_identifier ("__builtin_bswapg")); > break; > case IFN_BITREVERSE: > write_source_name (get_identifier ("__builtin_bitreverseg")); > break; > + case IFN_CLMUL: > + write_source_name (get_identifier ("__builtin_clmulg")); > + break; > default: > gcc_unreachable (); > } > --- a/gcc/cp/cp-objcp-common.cc 2026-10-27 14:32:12.576304097 +0100 > +++ b/gcc/cp/cp-objcp-common.cc 2026-10-30 17:06:34.380564383 +0100 > @@ -574,6 +574,7 @@ names_builtin_p (const char *name) > case RID_ADDRESSOF: > case RID_BUILTIN_BITREVERSEG: > case RID_BUILTIN_BSWAPG: > + case RID_BUILTIN_CLMULG: > case RID_BUILTIN_CONVERTVECTOR: > case RID_BUILTIN_HAS_ATTRIBUTE: > case RID_BUILTIN_SHUFFLE: > --- a/gcc/cp/cp-gimplify.cc 2026-10-27 14:32:12.576304097 +0100 > +++ b/gcc/cp/cp-gimplify.cc 2026-10-30 17:06:34.380801991 +0100 > @@ -898,6 +898,24 @@ cp_gimplify_expr (tree *expr_p, gimple_s > return ret; > } > break; > + case IFN_CLMUL: > + if (ret == GS_OK) > + { > + location_t loc = EXPR_LOCATION (*expr_p); > + tree arg1 = CALL_EXPR_ARG (*expr_p, 0); > + tree arg2 = CALL_EXPR_ARG (*expr_p, 1); > + tree arg3 = NULL_TREE; > + if (call_expr_nargs (*expr_p) == 3) > + arg3 = CALL_EXPR_ARG (*expr_p, 2); > + tree r = fold_build_builtin_clmulg (loc, arg1, arg2, arg3); > + if (TREE_CODE (r) == CALL_EXPR > + && !CALL_EXPR_FN (r) > + && CALL_EXPR_IFN (r) == IFN_CLMUL) > + break; > + *expr_p = r; > + return ret; > + } > + break; > default: > break; > } > --- a/gcc/cp/constexpr.cc 2026-10-30 17:05:21.678552656 +0100 > +++ b/gcc/cp/constexpr.cc 2026-10-30 17:22:07.439524272 +0100 > @@ -3738,6 +3738,49 @@ cxx_eval_internal_function (const conste > arg); > } > > + case IFN_CLMUL: > + { > + tree args[3] = {}; > + for (int i = 0; i < call_expr_nargs (t); ++i) > + { > + args[i] = cxx_eval_constant_expression (ctx, CALL_EXPR_ARG (t, i), > + vc_prvalue, non_constant_p, > + overflow_p, jump_target); > + if (*jump_target) > + return NULL_TREE; > + if (*non_constant_p) > + return t; > + } > + location_t loc = cp_expr_loc_or_input_loc (t); > + if (TREE_CODE (args[0]) != INTEGER_CST > + || TREE_CODE (args[1]) != INTEGER_CST) > + { > + if (!ctx->quiet) > + error_at (loc, "call to internal function %qE", t); > + *non_constant_p = true; > + return t; > + } > + unsigned int prec = TYPE_PRECISION (TREE_TYPE (args[0])); > + wide_int res = wi::clmul (wi::to_wide (args[0]), > + wi::to_wide (args[1]), > + prec * (args[2] ? 2 : 1)); > + if (args[2] == NULL_TREE) > + return wide_int_to_tree (TREE_TYPE (t), res); > + wide_int lo = wide_int::from (res, prec, UNSIGNED); > + wide_int hi = wide_int::from (wi::rshift (res, prec, UNSIGNED), > + prec, UNSIGNED); > + tree mod = build2_loc (loc, MODIFY_EXPR, void_type_node, > + build_fold_indirect_ref_loc (loc, args[2]), > + wide_int_to_tree (TREE_TYPE (t), hi)); > + cxx_eval_constant_expression (ctx, mod, vc_prvalue, non_constant_p, > + overflow_p, jump_target); > + if (*jump_target) > + return NULL_TREE; > + if (*non_constant_p) > + return t; > + return wide_int_to_tree (TREE_TYPE (t), lo); > + } > + > case IFN_VEC_CONVERT: > { > tree arg = cxx_eval_constant_expression (ctx, CALL_EXPR_ARG (t, 0), > @@ -12680,6 +12723,7 @@ potential_constant_expression_1 (tree t, > case IFN_VEC_CONVERT: > case IFN_BSWAP: > case IFN_BITREVERSE: > + case IFN_CLMUL: > bail = false; > break; > > --- a/gcc/doc/extend.texi 2026-10-27 14:32:19.717209439 +0100 > +++ b/gcc/doc/extend.texi 2026-10-30 17:32:38.085291853 +0100 > @@ -18096,6 +18096,29 @@ recognized in such contexts. > > @enddefbuiltin > > +@defbuiltin{@var{type} __builtin_clmulg (@var{type} @var{a}, @var{type} @var{b})} > +@defbuiltinx{@var{type} __builtin_clmulg (@var{type} @var{a}, @var{type} @var{b}, @var{type} *@var{c})} > + > +This type-generic built-in function returns carry-less product of the > +first two arguments. @var{type} may be any unsigned integral type. > +The function returns the lower half of the full result, which has > +twice the precision of @var{type}. If three arguments are specified, > +the higher half of the full result is stored into the object the argument > +points to. > + > +@smallexample > + unsigned int a = 0x10111111U, b = 0x22002222U; > + unsigned int c = __builtin_clmulg (a, b); > + unsigned int d, e = __builtin_clmulg (a, b, &d); > +@end smallexample > + > +If @code{int} is 32-bit, both @var{c} and @var{e} will be set to the least significant > +32 bits of the full 64-bit carry-less product result @code{0x222022020000202ULL}, > +i.e. @code{0x20000202U}, while @var{d} will be set to the most significant 32 bits > +of the full result, i.e. @code{0x2220220U}. > + > +@enddefbuiltin > + > @defbuiltin{@var{type} __builtin_speculation_safe_value (@var{type} @var{val}, @var{type} @var{failval})} > > This built-in function can be used to help mitigate against unsafe > --- a/gcc/testsuite/c-c++-common/builtin-clmulg-1.c 2026-10-30 17:06:34.386000667 +0100 > +++ b/gcc/testsuite/c-c++-common/builtin-clmulg-1.c 2026-10-30 17:06:34.386000667 +0100 > @@ -0,0 +1,524 @@ > +/* Test __builtin_clmulg. */ > +/* { dg-do run { target { c || c++11 } } } */ > +/* { dg-options "-O2" } */ > + > +#if !__has_builtin(__builtin_clmulg) > +#error __builtin_clmulg unsupported > +#endif > + > +#if __CHAR_BIT__ == 8 > +static_assert (__builtin_clmulg ((unsigned char) 0x7e, (unsigned char) 0x9c) == 0xe8, ""); > +#if __SIZEOF_SHORT__ == 2 > +static_assert (__builtin_clmulg ((unsigned short) 0xc8aa, (unsigned short) 0x7616) == 0xa55c, ""); > +#endif > +#if __SIZEOF_INT__ == 4 > +static_assert (__builtin_clmulg (0x9f330680U, 0x4e157eadU) == 0xb23fb880U, ""); > +static_assert (__builtin_clmulg (0x11111111U, 0x11111111U) == 0x1010101U, ""); > +static_assert (__builtin_clmulg (~0U, ~0U) == 0x55555555U, ""); > +#endif > +#if __SIZEOF_LONG__ == 4 > +static_assert (__builtin_clmulg (0xcd63e2c1UL, 0xab176a37UL) == 0x2f053277UL, ""); > +#elif __SIZEOF_LONG__ == 8 > +static_assert (__builtin_clmulg (0x43e13a77bec666afUL, 0x39c165e2ed3f98f7UL) == 0xe8465657c87e7a1dUL, ""); > +#endif > +#if __SIZEOF_LONG_LONG__ == 8 > +static_assert (__builtin_clmulg (0xe38ebed3ef3cc8deULL, 0x75224424100f8096ULL) == 0xfaf0ddab7a75024ULL, ""); > +static_assert (__builtin_clmulg (0x11111111ULL, 0x11111111ULL) == 0x101010101010101ULL, ""); > +static_assert (__builtin_clmulg (0x1111111111111111ULL, 0x1111111111111111ULL) == 0x101010101010101ULL, ""); > +static_assert (__builtin_clmulg (~0ULL, ~0ULL) == 0x5555555555555555ULL, ""); > +#endif > +#if __SIZEOF_INT128__ == 16 > +static_assert (__builtin_clmulg ((((unsigned __int128) 0x983a442a106b8a83ULL) << 64) > + | 0x1866ccfa2e2b382cULL, > + (((unsigned __int128) 0xe9abf4d856d535c3ULL) << 64) > + | 0x58708f117a52c14cULL) > + == ((((unsigned __int128) 0xd3ae65b0bac566b2ULL) << 64) > + | 0xdd6b33f9bb8606d0ULL), ""); > +#endif > +#endif > + > +#if __BITINT_MAXWIDTH__ >= 856 > +static_assert (__builtin_clmulg ((unsigned _BitInt(24)) 0xea754cuwb, > + (unsigned _BitInt(24)) 0x7cfcb9uwb) == 0xd946cuwb, ""); > +static_assert (__builtin_clmulg ((unsigned _BitInt(40)) 0xb35cea0986uwb, > + (unsigned _BitInt(40)) 0xec8cec0cffuwb) == 0xcf45a35282uwb, ""); > +static_assert (__builtin_clmulg ((unsigned _BitInt(128)) 0x40a6e26b30f2ff0e2b099e7a71429d54uwb, > + (unsigned _BitInt(128)) 0xddd32528056500d0b79218aa8b55046cuwb) > + == 0xa11e12e273ecbf7d7f0c6f8409db3070uwb, ""); > +static_assert (__builtin_clmulg ((unsigned _BitInt(129)) 0x01a057b67e5807da3e87d86e34ead6d446uwb, > + (unsigned _BitInt(129)) 0x00ebfe8616a19a74e093c39217b1f599c5uwb) > + == 0x7aa05ee8e53876da9b60fbe653da1deuwb, ""); > +static_assert (__builtin_clmulg ((unsigned _BitInt(136)) 0xe8654afad921062835d589e9de710c59e2uwb, > + (unsigned _BitInt(136)) 0xec973d421e8e06fda1fc1ec83be74e7ac5uwb) > + == 0xcaba6f2d4948b5e794137742285f7d83eauwb, ""); > +static_assert (__builtin_clmulg ((unsigned _BitInt(832)) 0x3bf0e6fcd0acb795c68d436f4038d14f1eeadd2447157b04d15ad94ec0638ffb5375f72321afb8e73cfb577d3328cc5213a9765abff15e904c37de0c9b6d08eee2ff1204aecaebebc64268f96b344b7edec2d89db3362dff6e0b0c097814f75a13095ec2d44aad9auwb, > + (unsigned _BitInt(832)) 0x527f6addf01c1827f833ac6222d6d1c2b114862834006297b3a44b8c445a2b97da9574cab18cf1a9c09d0be273dca424f12b4c252baebdde52086b9763962e3d2ba207dd2ef886ee9592d1086e752c5fa07885cc2742aa794a1510adab3eead7e0f1b40fe93afd7euwb) > + == 0xed1958f12923520d74fc66cea0973580825a5e563806308c9740731d7873df8d1842a1e78f7c2d957aa122477042739466df964d826d3ae2b77b0d153ba77375b4d53f85667ee9e99bc6e4f20e15ede19ea949c1c3783205003ac0dca600daa9cfc51777640ccfecuwb, ""); > +static_assert (__builtin_clmulg ((unsigned _BitInt(856)) 0x7118148ab2f165085830aa8b252e2d1600b3264181b7b611c72bce4e05cb0276e316019607669e609748ebbc7618d276ccf8b84db06e5f77992dc59ef8c715dcdd1672e57c1045135830d0ce49a245159bfd624b6bc1c204ef88a2e74fb7c32dcd35124a45575d9d872d6cuwb, > + (unsigned _BitInt(856)) 0x04c996a2400c474c71d73fb208c9f256676d0beebc3dd80e1dfce8d3cb7613d03faa7280b6b9cc27900bd998d4cbee3b38fa2af537020355feeb28ca613b9aa1e50c219bc5edc255f89bedcc67db079fd531940d33976232838afce4c59685aba2a646679309bc8ba4a957uwb) > + == 0xa969732632882314035c08bb15c392653af107f06b90b4e63580f503c7be7163bb379407420d9b72f0147d9a2c4008ed148b88a6c4304c923ec6e148484572893b3474829536e0a44a0400d10764cb7538ef2c24cd7d18374bbead68028cca6cc3433c6ce6f679de41c3c4uwb, ""); > +#endif > + > +[[gnu::noipa]] unsigned char > +clmul8 (unsigned char x, unsigned char y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned char > +clmul8w (unsigned char x, unsigned char y, unsigned char *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > + > +[[gnu::noipa]] unsigned char > +clmul8b (bool x, bool y) > +{ > + return __builtin_clmulg ((unsigned char) x, (unsigned char) y); > +} > + > +[[gnu::noipa]] unsigned char > +clmul8m (unsigned char x, unsigned char y) > +{ > + return __builtin_clmulg (x, (unsigned char) (y & 0x3f)); > +} > + > +[[gnu::noipa]] unsigned short > +clmul16 (unsigned short x, unsigned short y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned short > +clmul16w (unsigned short x, unsigned short y, unsigned short *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > + > +[[gnu::noipa]] unsigned int > +clmul32 (unsigned int x, unsigned int y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned int > +clmul32w (unsigned int x, unsigned int y, unsigned int *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > + > +[[gnu::noipa]] unsigned int > +clmul32m (unsigned int x, unsigned int y) > +{ > + return __builtin_clmulg (x & 0x1fffffU, y); > +} > + > +[[gnu::noipa]] unsigned int > +clmul32m2 (unsigned int x, unsigned int y) > +{ > + return __builtin_clmulg (x & 0x1fU, y & 0xf); > +} > + > +[[gnu::noipa]] unsigned int > +clmul32m3 (unsigned int x, unsigned int y) > +{ > + return __builtin_clmulg (x & 0x7fffU, y & 0x3ffU); > +} > + > +[[gnu::noipa]] unsigned long > +clmull (unsigned long x, unsigned long y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned long > +clmullw (unsigned long x, unsigned long y, unsigned long *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > + > +[[gnu::noipa]] unsigned long long > +clmul64 (unsigned long long x, unsigned long long y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned long long > +clmul64w (unsigned long long x, unsigned long long y, unsigned long long *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > + > +[[gnu::noipa]] unsigned long long > +clmul64wm (unsigned long long x, unsigned long long y, unsigned long long *z) > +{ > + return __builtin_clmulg (x & 0x3fffffffULL, y & 0x3fffffffULL, z); > +} > + > +#if __CHAR_BIT__ == 8 && __SIZEOF_INT128__ == 16 > +[[gnu::noipa]] unsigned __int128 > +clmul128 (unsigned __int128 x, unsigned __int128 y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned __int128 > +clmul128w (unsigned __int128 x, unsigned __int128 y, unsigned __int128 *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > +#endif > + > +#if __BITINT_MAXWIDTH__ >= 856 > +[[gnu::noipa]] unsigned _BitInt(1) > +clmul1 (unsigned _BitInt(1) x, unsigned _BitInt(1) y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned _BitInt(1) > +clmul1w (unsigned _BitInt(1) x, unsigned _BitInt(1) y, unsigned _BitInt(1) *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > + > +[[gnu::noipa]] unsigned _BitInt(24) > +clmul24 (unsigned _BitInt(24) x, unsigned _BitInt(24) y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned _BitInt(24) > +clmul24w (unsigned _BitInt(24) x, unsigned _BitInt(24) y, unsigned _BitInt(24) *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > + > +[[gnu::noipa]] unsigned _BitInt(40) > +clmul40 (unsigned _BitInt(40) x, unsigned _BitInt(40) y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned _BitInt(40) > +clmul40w (unsigned _BitInt(40) x, unsigned _BitInt(40) y, unsigned _BitInt(40) *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > + > +[[gnu::noipa]] unsigned _BitInt(128) > +clmul128b (unsigned _BitInt(128) x, unsigned _BitInt(128) y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned _BitInt(128) > +clmul128bw (unsigned _BitInt(128) x, unsigned _BitInt(128) y, unsigned _BitInt(128) *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > + > +[[gnu::noipa]] unsigned _BitInt(129) > +clmul129 (unsigned _BitInt(129) x, unsigned _BitInt(129) y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned _BitInt(129) > +clmul129w (unsigned _BitInt(129) x, unsigned _BitInt(129) y, unsigned _BitInt(129) *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > + > +[[gnu::noipa]] unsigned _BitInt(136) > +clmul136 (unsigned _BitInt(136) x, unsigned _BitInt(136) y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned _BitInt(136) > +clmul136w (unsigned _BitInt(136) x, unsigned _BitInt(136) y, unsigned _BitInt(136) *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > + > +[[gnu::noipa]] unsigned _BitInt(832) > +clmul832 (unsigned _BitInt(832) x, unsigned _BitInt(832) y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned _BitInt(832) > +clmul832w (unsigned _BitInt(832) x, unsigned _BitInt(832) y, unsigned _BitInt(832) *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > + > +[[gnu::noipa]] unsigned _BitInt(856) > +clmul856 (unsigned _BitInt(856) x, unsigned _BitInt(856) y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned _BitInt(856) > +clmul856w (unsigned _BitInt(856) x, unsigned _BitInt(856) y, unsigned _BitInt(856) *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > +#endif > + > +#if __BITINT_MAXWIDTH__ >= 65535 > +[[gnu::noipa]] unsigned _BitInt(65535) > +clmul65535 (unsigned _BitInt(65535) x, unsigned _BitInt(65535) y) > +{ > + return __builtin_clmulg (x, y); > +} > + > +[[gnu::noipa]] unsigned _BitInt(65535) > +clmul65535w (unsigned _BitInt(65535) x, unsigned _BitInt(65535) y, unsigned _BitInt(65535) *z) > +{ > + return __builtin_clmulg (x, y, z); > +} > +#endif > + > +int > +main () > +{ > +#if __CHAR_BIT__ == 8 > + if (clmul8 ((unsigned char) 0x7e, (unsigned char) 0x9c) != 0xe8) > + __builtin_abort (); > + if (clmul8b (false, false) != 0 > + || clmul8b (false, true) != 0 > + || clmul8b (true, false) != 0 > + || clmul8b (true, true) != 1) > + __builtin_abort (); > + if (clmul8m ((unsigned char) 0x7e, (unsigned char) 0x9c) > + != __builtin_clmulg ((unsigned char) 0x7e, (unsigned char) (0x9c & 0x3f))) > + __builtin_abort (); > + if (clmul8m ((unsigned char) 0xff, (unsigned char) 0xff) > + != __builtin_clmulg ((unsigned char) 0xff, (unsigned char) (0xff & 0x3f))) > + __builtin_abort (); > + { > + unsigned char hi; > + if (clmul8w ((unsigned char) 0x7e, (unsigned char) 0x9c, &hi) != 0xe8 > + || hi != 0x3a) > + __builtin_abort (); > + } > +#if __SIZEOF_SHORT__ == 2 > + if (clmul16 ((unsigned short) 0xc8aa, (unsigned short) 0x7616) != 0xa55c) > + __builtin_abort (); > + { > + unsigned short hi; > + if (clmul16w ((unsigned short) 0xc8aa, (unsigned short) 0x7616, &hi) != 0xa55c > + || hi != 0x2508) > + __builtin_abort (); > + } > +#endif > +#if __SIZEOF_INT__ == 4 > + if (clmul32 (0x9f330680U, 0x4e157eadU) != 0xb23fb880U) > + __builtin_abort (); > + if (clmul32 (0x11111111U, 0x11111111U) != 0x1010101U) > + __builtin_abort (); > + if (clmul32 (~0U, ~0U) != 0x55555555U) > + __builtin_abort (); > + if (clmul32m (0x9f330680U, 0x4e157eadU) > + != __builtin_clmulg (0x9f330680U & 0x1fffffU, 0x4e157eadU)) > + __builtin_abort (); > + if (clmul32m2 (0x9f330680U, 0x4e157eadU) > + != __builtin_clmulg (0x9f330680U & 0x1fU, 0x4e157eadU & 0xfU)) > + __builtin_abort (); > + if (clmul32m3 (0x9f330680U, 0x4e157eadU) > + != __builtin_clmulg (0x9f330680U & 0x7fffU, 0x4e157eadU & 0x3ffU)) > + __builtin_abort (); > + if (clmul32m (~0U, ~0U) != __builtin_clmulg (0x1fffffU, ~0U)) > + __builtin_abort (); > + if (clmul32m2 (~0U, ~0U) != __builtin_clmulg (0x1fU, 0xfU)) > + __builtin_abort (); > + if (clmul32m3 (~0U, ~0U) != __builtin_clmulg (0x7fffU, 0x3ffU)) > + __builtin_abort (); > + { > + unsigned int hi; > + if (clmul32w (0x9f330680U, 0x4e157eadU, &hi) != 0xb23fb880U > + || hi != 0x207cd974) > + __builtin_abort (); > + if (clmul32w (0x11111111U, 0x11111111U, &hi) != 0x1010101U > + || hi != 0x1010101U) > + __builtin_abort (); > + if (clmul32w (~0U, ~0U, &hi) != 0x55555555U > + || hi != 0x55555555U) > + __builtin_abort (); > + } > +#endif > +#if __SIZEOF_LONG__ == 4 > + if (clmull (0xcd63e2c1UL, 0xab176a37UL) != 0x2f053277UL) > + __builtin_abort (); > + { > + unsigned long hi; > + if (clmullw (0xcd63e2c1UL, 0xab176a37UL, &hi) != 0x2f053277UL > + || hi != 0x782faf0eUL) > + __builtin_abort (); > + } > +#elif __SIZEOF_LONG__ == 8 > + if (clmull (0x43e13a77bec666afUL, 0x39c165e2ed3f98f7UL) != 0xe8465657c87e7a1dUL) > + __builtin_abort (); > + { > + unsigned long hi; > + if (clmullw (0x43e13a77bec666afUL, 0x39c165e2ed3f98f7UL, &hi) != 0xe8465657c87e7a1dUL > + || hi != 0xe2f8ec31f25371bUL) > + __builtin_abort (); > + } > +#endif > +#if __SIZEOF_LONG_LONG__ == 8 > + if (clmul64 (0xe38ebed3ef3cc8deULL, 0x75224424100f8096ULL) != 0xfaf0ddab7a75024ULL) > + __builtin_abort (); > + if (clmul64 (0x11111111ULL, 0x11111111ULL) != 0x101010101010101ULL) > + __builtin_abort (); > + if (clmul64 (0x1111111111111111ULL, 0x1111111111111111ULL) != 0x101010101010101ULL) > + __builtin_abort (); > + if (clmul64 (~0ULL, ~0ULL) != 0x5555555555555555ULL) > + __builtin_abort (); > + { > + unsigned long long hi; > + if (clmul64w (0xe38ebed3ef3cc8deULL, 0x75224424100f8096ULL, &hi) != 0xfaf0ddab7a75024ULL > + || hi != 0x29daaa7ee7cd2860ULL) > + __builtin_abort (); > + if (clmul64w (0x11111111ULL, 0x11111111ULL, &hi) != 0x101010101010101ULL > + || hi != 0ULL) > + __builtin_abort (); > + if (clmul64w (0x1111111111111111ULL, 0x1111111111111111ULL, &hi) != 0x101010101010101ULL > + || hi != 0x101010101010101ULL) > + __builtin_abort (); > + if (clmul64w (~0ULL, ~0ULL, &hi) != 0x5555555555555555ULL > + || hi != 0x5555555555555555ULL) > + __builtin_abort (); > + if (clmul64wm (0xe38ebed3ef3cc8deULL, 0x75224424100f8096ULL, &hi) > + != __builtin_clmulg (0xe38ebed3ef3cc8deULL & 0x3fffffffULL, > + 0x75224424100f8096ULL & 0x3fffffffULL) > + || hi != 0ULL) > + __builtin_abort (); > + if (clmul64wm (~0ULL, ~0ULL, &hi) != __builtin_clmulg (0x3fffffffULL, 0x3fffffffULL) > + || hi != 0ULL) > + __builtin_abort (); > + } > +#endif > +#if __SIZEOF_INT128__ == 16 > + if (clmul128 ((((unsigned __int128) 0x983a442a106b8a83ULL) << 64) > + | 0x1866ccfa2e2b382cULL, > + (((unsigned __int128) 0xe9abf4d856d535c3ULL) << 64) > + | 0x58708f117a52c14cULL) > + != ((((unsigned __int128) 0xd3ae65b0bac566b2ULL) << 64) > + | 0xdd6b33f9bb8606d0ULL)) > + __builtin_abort (); > + { > + unsigned __int128 hi; > + if (clmul128w ((((unsigned __int128) 0x983a442a106b8a83ULL) << 64) > + | 0x1866ccfa2e2b382cULL, > + (((unsigned __int128) 0xe9abf4d856d535c3ULL) << 64) > + | 0x58708f117a52c14cULL, &hi) > + != ((((unsigned __int128) 0xd3ae65b0bac566b2ULL) << 64) > + | 0xdd6b33f9bb8606d0ULL) > + || hi != ((((unsigned __int128) 0x7d17129902648920ULL) << 64) > + | 0xfdb34e3b7c058047ULL)) > + __builtin_abort (); > + } > +#endif > +#endif > +#if __BITINT_MAXWIDTH__ >= 856 > + if (clmul1 (0, 0) != 0 > + || clmul1 (0, 1) != 0 > + || clmul1 (1, 0) != 0 > + || clmul1 (1, 1) != 1) > + __builtin_abort (); > + if (clmul24 (0xea754cuwb, 0x7cfcb9uwb) != 0xd946cuwb) > + __builtin_abort (); > + if (clmul40 (0xb35cea0986uwb, 0xec8cec0cffuwb) != 0xcf45a35282uwb) > + __builtin_abort (); > + if (clmul128b (0x40a6e26b30f2ff0e2b099e7a71429d54uwb, 0xddd32528056500d0b79218aa8b55046cuwb) > + != 0xa11e12e273ecbf7d7f0c6f8409db3070uwb) > + __builtin_abort (); > + if (clmul129 (0x01a057b67e5807da3e87d86e34ead6d446uwb, 0x00ebfe8616a19a74e093c39217b1f599c5uwb) > + != 0x7aa05ee8e53876da9b60fbe653da1deuwb) > + __builtin_abort (); > + if (clmul136 (0xe8654afad921062835d589e9de710c59e2uwb, 0xec973d421e8e06fda1fc1ec83be74e7ac5uwb) > + != 0xcaba6f2d4948b5e794137742285f7d83eauwb) > + __builtin_abort (); > + if (clmul832 (0x3bf0e6fcd0acb795c68d436f4038d14f1eeadd2447157b04d15ad94ec0638ffb5375f72321afb8e73cfb577d3328cc5213a9765abff15e904c37de0c9b6d08eee2ff1204aecaebebc64268f96b344b7edec2d89db3362dff6e0b0c097814f75a13095ec2d44aad9auwb, > + 0x527f6addf01c1827f833ac6222d6d1c2b114862834006297b3a44b8c445a2b97da9574cab18cf1a9c09d0be273dca424f12b4c252baebdde52086b9763962e3d2ba207dd2ef886ee9592d1086e752c5fa07885cc2742aa794a1510adab3eead7e0f1b40fe93afd7euwb) > + != 0xed1958f12923520d74fc66cea0973580825a5e563806308c9740731d7873df8d1842a1e78f7c2d957aa122477042739466df964d826d3ae2b77b0d153ba77375b4d53f85667ee9e99bc6e4f20e15ede19ea949c1c3783205003ac0dca600daa9cfc51777640ccfecuwb) > + __builtin_abort (); > + if (clmul856 (0x7118148ab2f165085830aa8b252e2d1600b3264181b7b611c72bce4e05cb0276e316019607669e609748ebbc7618d276ccf8b84db06e5f77992dc59ef8c715dcdd1672e57c1045135830d0ce49a245159bfd624b6bc1c204ef88a2e74fb7c32dcd35124a45575d9d872d6cuwb, > + 0x04c996a2400c474c71d73fb208c9f256676d0beebc3dd80e1dfce8d3cb7613d03faa7280b6b9cc27900bd998d4cbee3b38fa2af537020355feeb28ca613b9aa1e50c219bc5edc255f89bedcc67db079fd531940d33976232838afce4c59685aba2a646679309bc8ba4a957uwb) > + != 0xa969732632882314035c08bb15c392653af107f06b90b4e63580f503c7be7163bb379407420d9b72f0147d9a2c4008ed148b88a6c4304c923ec6e148484572893b3474829536e0a44a0400d10764cb7538ef2c24cd7d18374bbead68028cca6cc3433c6ce6f679de41c3c4uwb) > + __builtin_abort (); > +#endif > +#if __BITINT_MAXWIDTH__ >= 856 * 2 > + { > + unsigned _BitInt(1) hi; > + if (clmul1w (0, 0, &hi) != 0 > + || hi != 0 > + || clmul1w (0, 1, &hi) != 0 > + || hi != 0 > + || clmul1w (1, 0, &hi) != 0 > + || hi != 0 > + || clmul1w (1, 1, &hi) != 1 > + || hi != 0) > + __builtin_abort (); > + } > + { > + unsigned _BitInt(24) hi; > + if (clmul24w (0xea754cuwb, 0x7cfcb9uwb, &hi) != 0xd946cuwb > + || hi != __builtin_clmulg ((unsigned _BitInt(24 * 2)) 0xea754cuwb, > + (unsigned _BitInt(24 * 2)) 0x7cfcb9uwb) >> 24) > + __builtin_abort (); > + } > + { > + unsigned _BitInt(40) hi; > + if (clmul40w (0xb35cea0986uwb, 0xec8cec0cffuwb, &hi) != 0xcf45a35282uwb > + || hi != __builtin_clmulg ((unsigned _BitInt(40 * 2)) 0xb35cea0986uwb, > + (unsigned _BitInt(40 * 2)) 0xec8cec0cffuwb) >> 40) > + __builtin_abort (); > + } > + { > + unsigned _BitInt(128) hi; > + if (clmul128bw (0x40a6e26b30f2ff0e2b099e7a71429d54uwb, 0xddd32528056500d0b79218aa8b55046cuwb, &hi) > + != 0xa11e12e273ecbf7d7f0c6f8409db3070uwb > + || hi != __builtin_clmulg ((unsigned _BitInt(128 * 2)) 0x40a6e26b30f2ff0e2b099e7a71429d54uwb, > + (unsigned _BitInt(128 * 2)) 0xddd32528056500d0b79218aa8b55046cuwb) >> 128) > + __builtin_abort (); > + } > + { > + unsigned _BitInt(129) hi; > + if (clmul129w (0x01a057b67e5807da3e87d86e34ead6d446uwb, 0x00ebfe8616a19a74e093c39217b1f599c5uwb, &hi) > + != 0x7aa05ee8e53876da9b60fbe653da1deuwb > + || hi != __builtin_clmulg ((unsigned _BitInt(129 * 2)) 0x01a057b67e5807da3e87d86e34ead6d446uwb, > + (unsigned _BitInt(129 * 2)) 0x00ebfe8616a19a74e093c39217b1f599c5uwb) >> 129) > + __builtin_abort (); > + } > + { > + unsigned _BitInt(136) hi; > + if (clmul136w (0xe8654afad921062835d589e9de710c59e2uwb, 0xec973d421e8e06fda1fc1ec83be74e7ac5uwb, &hi) > + != 0xcaba6f2d4948b5e794137742285f7d83eauwb > + || hi != __builtin_clmulg ((unsigned _BitInt(136 * 2)) 0xe8654afad921062835d589e9de710c59e2uwb, > + (unsigned _BitInt(136 * 2)) 0xec973d421e8e06fda1fc1ec83be74e7ac5uwb) >> 136) > + __builtin_abort (); > + } > + { > + unsigned _BitInt(832) hi; > + if (clmul832w (0x3bf0e6fcd0acb795c68d436f4038d14f1eeadd2447157b04d15ad94ec0638ffb5375f72321afb8e73cfb577d3328cc5213a9765abff15e904c37de0c9b6d08eee2ff1204aecaebebc64268f96b344b7edec2d89db3362dff6e0b0c097814f75a13095ec2d44aad9auwb, > + 0x527f6addf01c1827f833ac6222d6d1c2b114862834006297b3a44b8c445a2b97da9574cab18cf1a9c09d0be273dca424f12b4c252baebdde52086b9763962e3d2ba207dd2ef886ee9592d1086e752c5fa07885cc2742aa794a1510adab3eead7e0f1b40fe93afd7euwb, &hi) > + != 0xed1958f12923520d74fc66cea0973580825a5e563806308c9740731d7873df8d1842a1e78f7c2d957aa122477042739466df964d826d3ae2b77b0d153ba77375b4d53f85667ee9e99bc6e4f20e15ede19ea949c1c3783205003ac0dca600daa9cfc51777640ccfecuwb > + || hi != __builtin_clmulg ((unsigned _BitInt(832 * 2)) 0x3bf0e6fcd0acb795c68d436f4038d14f1eeadd2447157b04d15ad94ec0638ffb5375f72321afb8e73cfb577d3328cc5213a9765abff15e904c37de0c9b6d08eee2ff1204aecaebebc64268f96b344b7edec2d89db3362dff6e0b0c097814f75a13095ec2d44aad9auwb, > + (unsigned _BitInt(832 * 2)) 0x527f6addf01c1827f833ac6222d6d1c2b114862834006297b3a44b8c445a2b97da9574cab18cf1a9c09d0be273dca424f12b4c252baebdde52086b9763962e3d2ba207dd2ef886ee9592d1086e752c5fa07885cc2742aa794a1510adab3eead7e0f1b40fe93afd7euwb) >> 832) > + __builtin_abort (); > + } > + { > + unsigned _BitInt(856) hi; > + if (clmul856w (0x7118148ab2f165085830aa8b252e2d1600b3264181b7b611c72bce4e05cb0276e316019607669e609748ebbc7618d276ccf8b84db06e5f77992dc59ef8c715dcdd1672e57c1045135830d0ce49a245159bfd624b6bc1c204ef88a2e74fb7c32dcd35124a45575d9d872d6cuwb, > + 0x04c996a2400c474c71d73fb208c9f256676d0beebc3dd80e1dfce8d3cb7613d03faa7280b6b9cc27900bd998d4cbee3b38fa2af537020355feeb28ca613b9aa1e50c219bc5edc255f89bedcc67db079fd531940d33976232838afce4c59685aba2a646679309bc8ba4a957uwb, &hi) > + != 0xa969732632882314035c08bb15c392653af107f06b90b4e63580f503c7be7163bb379407420d9b72f0147d9a2c4008ed148b88a6c4304c923ec6e148484572893b3474829536e0a44a0400d10764cb7538ef2c24cd7d18374bbead68028cca6cc3433c6ce6f679de41c3c4uwb > + || hi != __builtin_clmulg ((unsigned _BitInt(856 * 2)) 0x7118148ab2f165085830aa8b252e2d1600b3264181b7b611c72bce4e05cb0276e316019607669e609748ebbc7618d276ccf8b84db06e5f77992dc59ef8c715dcdd1672e57c1045135830d0ce49a245159bfd624b6bc1c204ef88a2e74fb7c32dcd35124a45575d9d872d6cuwb, > + (unsigned _BitInt(856 * 2)) 0x04c996a2400c474c71d73fb208c9f256676d0beebc3dd80e1dfce8d3cb7613d03faa7280b6b9cc27900bd998d4cbee3b38fa2af537020355feeb28ca613b9aa1e50c219bc5edc255f89bedcc67db079fd531940d33976232838afce4c59685aba2a646679309bc8ba4a957uwb) >> 856) > + __builtin_abort (); > + } > +#endif > +} > --- a/gcc/testsuite/c-c++-common/builtin-clmulg-2.c 2026-10-30 17:06:34.386133029 +0100 > +++ b/gcc/testsuite/c-c++-common/builtin-clmulg-2.c 2026-10-30 17:06:34.386133029 +0100 > @@ -0,0 +1,51 @@ > +/* Test __builtin_clmulg. */ > +/* { dg-do compile } */ > +/* { dg-options "" } */ > + > +int > +main () > +{ > + unsigned int a; > + __builtin_clmulg (); /* { dg-error "wrong number of arguments to '__builtin_clmulg'" } */ > + __builtin_clmulg (1U); /* { dg-error "wrong number of arguments to '__builtin_clmulg'" } */ > + __builtin_clmulg (1U, 1U, &a, 1U); /* { dg-error "wrong number of arguments to '__builtin_clmulg'" } */ > + __builtin_clmulg (1.0, 1.0); /* { dg-error "'__builtin_clmulg' operand not an integral type" } */ > + __builtin_clmulg (1.0f, 1.0f); /* { dg-error "'__builtin_clmulg' operand not an integral type" } */ > + __builtin_clmulg (1.0L, 1.0L); /* { dg-error "'__builtin_clmulg' operand not an integral type" } */ > + struct S { int a; }; > + __builtin_clmulg ((struct S) { 42 }, (struct S) { 43 }); /* { dg-error "'__builtin_clmulg' operand not an integral type" } */ > + enum E { E0, E1 } e; > + __builtin_clmulg (E1, E1); /* { dg-error "argument 1 in call to function '__builtin_clmulg' has signed type" "" { target c } } */ > + /* { dg-error "argument 1 in call to function '__builtin_clmulg' has enumerated type" "" { target c++ } .-1 } */ > + __builtin_clmulg (e, e); /* { dg-error "argument 1 in call to function '__builtin_clmulg' has enumerated type" } */ > + __builtin_clmulg ((enum E) 1, (enum E) 1); /* { dg-error "argument 1 in call to function '__builtin_clmulg' has enumerated type" } */ > +#if !defined(__cplusplus) || __cplusplus >= 201103L > + enum F : int { F0, F1 } f; > + __builtin_clmulg (F1, F1); /* { dg-error "argument 1 in call to function '__builtin_clmulg' has enumerated type" "" { target { c || c++11 } } } */ > + __builtin_clmulg (f, f); /* { dg-error "argument 1 in call to function '__builtin_clmulg' has enumerated type" "" { target { c || c++11 } } } */ > + __builtin_clmulg ((enum F) 1, (enum F) 1); /* { dg-error "argument 1 in call to function '__builtin_clmulg' has enumerated type" "" { target { c || c++11 } } } */ > +#endif > + __builtin_clmulg (false, true); /* { dg-error "argument 1 in call to function '__builtin_clmulg' has boolean type" } */ > + __builtin_clmulg (1, 1); /* { dg-error "argument 1 in call to function '__builtin_clmulg' has signed type" } */ > + __builtin_clmulg ((char) 1, (char) 1);/* { dg-error "argument 1 in call to function '__builtin_clmulg' has signed type" "" { target { ! unsigned_char } } } */ > + __builtin_clmulg (1UL, 1ULL); /* { dg-error "arguments 1 and 2 to function '__builtin_clmulg' have different types 'long unsigned int' and 'long long unsigned int'" } */ > + __builtin_clmulg (1U, 1.0); /* { dg-error "arguments 1 and 2 to function '__builtin_clmulg' have different types 'unsigned int' and 'double'" } */ > + __builtin_clmulg ((unsigned char) 1, (char) 1); /* { dg-error "arguments 1 and 2 to function '__builtin_clmulg' have different types 'unsigned char' and 'char'" } */ > + __builtin_clmulg ((unsigned char) 1, true); /* { dg-error "arguments 1 and 2 to function '__builtin_clmulg' have different types 'unsigned char' and 'bool'" } */ > + __builtin_clmulg (1UL, 1UL, 1UL); /* { dg-error "argument 3 to function '__builtin_clmulg' does not have pointer type" } */ > + __builtin_clmulg (1UL, 1UL, &a); /* { dg-error "arguments 1 and 3 to function '__builtin_clmulg' have incompatible types 'long unsigned int' and 'unsigned int ?\\\*'" } */ > + const unsigned int b = 42; > + __builtin_clmulg (1U, 1U, &b); /* { dg-error "arguments 3 to function '__builtin_clmulg' have pointer to 'const' type 'const unsigned int ?\\\*'" } */ > + bool c = false; > + int d = 1; > + char g = ' '; > + unsigned long h = 42; > + unsigned char i = 1; > + __builtin_clmulg (false, true, &c); /* { dg-error "argument 1 in call to function '__builtin_clmulg' has boolean type" } */ > + __builtin_clmulg (1, 1, &d); /* { dg-error "argument 1 in call to function '__builtin_clmulg' has signed type" } */ > + __builtin_clmulg ((char) 1, (char) 1, &g); /* { dg-error "argument 1 in call to function '__builtin_clmulg' has signed type" "" { target { ! unsigned_char } } } */ > + __builtin_clmulg (1UL, 1ULL, &h); /* { dg-error "arguments 1 and 2 to function '__builtin_clmulg' have different types 'long unsigned int' and 'long long unsigned int'" } */ > + __builtin_clmulg (1U, 1.0, &a); /* { dg-error "arguments 1 and 2 to function '__builtin_clmulg' have different types 'unsigned int' and 'double'" } */ > + __builtin_clmulg ((unsigned char) 1, (char) 1, &i); /* { dg-error "arguments 1 and 2 to function '__builtin_clmulg' have different types 'unsigned char' and 'char'" } */ > + __builtin_clmulg ((unsigned char) 1, true, &i); /* { dg-error "arguments 1 and 2 to function '__builtin_clmulg' have different types 'unsigned char' and 'bool'" } */ > +} > --- a/gcc/testsuite/g++.dg/ext/builtin-clmulg-1.C 2026-10-30 17:32:00.888781370 +0100 > +++ b/gcc/testsuite/g++.dg/ext/builtin-clmulg-1.C 2026-10-30 17:37:47.132224697 +0100 > @@ -0,0 +1,24 @@ > +// { dg-do compile { target c++14 } } > + > +constexpr unsigned long long > +foo (unsigned int x, unsigned int y) > +{ > + unsigned int a = 0; > + unsigned int b = __builtin_clmulg (x, y, &a); > + return (((unsigned long long) a) << ((__SIZEOF_LONG_LONG__ * __CHAR_BIT__) / 2)) | b; > +} > + > +constexpr unsigned long long > +bar (unsigned int x, unsigned int y) > +{ > + return __builtin_clmulg ((unsigned long long) x, (unsigned long long) y); > +} > + > +#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8 && __CHAR_BIT__ == 8 > +static_assert (foo (0x10111111U, 0x22002222U) == 0x222022020000202ULL, ""); > +static_assert (bar (0x10111111U, 0x22002222U) == 0x222022020000202ULL, ""); > +#endif > +static_assert (foo (0, 0) == 0, ""); > +static_assert (bar (0, 0) == 0, ""); > +static_assert (foo (6, 4) == 0x18, ""); > +static_assert (bar (6, 4) == 0x18, ""); > --- a/gcc/testsuite/gcc.target/i386/pclmul-builtin-clmulg-1.c 2026-10-30 17:16:34.003853028 +0100 > +++ b/gcc/testsuite/gcc.target/i386/pclmul-builtin-clmulg-1.c 2026-10-30 17:37:23.191539767 +0100 > @@ -0,0 +1,19 @@ > +/* { dg-do run } */ > +/* { dg-require-effective-target pclmul } */ > +/* { dg-options "-O2 -mpclmul" } */ > + > +#ifndef CHECK_H > +#define CHECK_H "pclmul-check.h" > +#endif > + > +#include CHECK_H > + > +#define main do_main > + > +#include "../../c-c++-common/builtin-clmulg-1.c" > + > +static void > +pclmul_test (void) > +{ > + do_main (); > +} > --- a/gcc/builtins.h 2026-10-27 14:32:12.566304229 +0100 > +++ b/gcc/builtins.h 2026-10-30 17:06:34.386300380 +0100 > @@ -142,6 +142,7 @@ extern tree fold_builtin_expect (locatio > extern tree fold_builtin_constant_p (tree); > extern tree fold_build_builtin_bswapg_bitreverseg (location_t, internal_fn, > tree); > +extern tree fold_build_builtin_clmulg (location_t, tree, tree, tree); > extern bool avoid_folding_inline_builtin (tree); > extern tree fold_call_expr (location_t, tree, bool); > extern tree fold_builtin_call_array (location_t, tree, tree, int, tree *); > --- a/gcc/fold-const-call.cc 2026-10-27 14:32:12.588303938 +0100 > +++ b/gcc/fold-const-call.cc 2026-10-30 17:06:34.386517905 +0100 > @@ -1804,6 +1804,10 @@ fold_const_call_sss (wide_int *result, c > return true; > } > > + case CFN_CLMUL: > + *result = wi::clmul (arg0, arg1, precision); > + return true; > + > default: > return false; > } > @@ -2092,6 +2096,20 @@ fold_const_call (combined_fn fn, tree ty > } > return NULL_TREE; > > + case CFN_CLMUL_WIDEN: > + if (integer_cst_p (arg0) && integer_cst_p (arg1)) > + { > + unsigned int prec = TYPE_PRECISION (TREE_TYPE (arg0)); > + wide_int res = wi::clmul (wi::to_wide (arg0), wi::to_wide (arg1), > + prec * 2); > + wide_int lo = wide_int::from (res, prec, UNSIGNED); > + wide_int hi = wide_int::from (wi::rshift (res, prec, UNSIGNED), > + prec, UNSIGNED); > + return build_complex (type, wide_int_to_tree (TREE_TYPE (type), lo), > + wide_int_to_tree (TREE_TYPE (type), hi)); > + } > + return NULL_TREE; > + > default: > return fold_const_call_1 (fn, type, arg0, arg1); > } > --- a/gcc/internal-fn.h 2026-10-27 14:32:12.591303898 +0100 > +++ b/gcc/internal-fn.h 2026-10-30 17:06:34.386744534 +0100 > @@ -288,6 +288,8 @@ extern void expand_PARITY (internal_fn, > extern void expand_POPCOUNT (internal_fn, gcall *); > extern void expand_BSWAP (internal_fn, gcall *); > extern void expand_BITREVERSE (internal_fn, gcall *); > +extern void expand_CLMUL (internal_fn, gcall *); > +extern void expand_CLMUL_WIDEN (internal_fn, gcall *); > > extern bool vectorized_internal_fn_supported_p (internal_fn, tree); > > --- a/gcc/fold-const.cc 2026-10-27 14:32:19.727209307 +0100 > +++ b/gcc/fold-const.cc 2026-10-30 17:06:34.387357028 +0100 > @@ -14920,6 +14920,7 @@ tree_call_nonnegative_p (tree type, comb > CASE_CFN_CLRSB: > CASE_CFN_BSWAP: > CASE_CFN_BITREVERSE: > + case CFN_CLMUL: > /* Always true. */ > return true; > > --- a/gcc/wide-int.cc 2026-10-27 14:32:12.593303871 +0100 > +++ b/gcc/wide-int.cc 2026-10-30 17:06:34.388248026 +0100 > @@ -2400,6 +2400,72 @@ wi::mod_inv (const wide_int &a, const wi > return x1; > } > > +/* Return as many repetition of X.get_precision () bits from X > + as fit into PREC. */ > +wide_int > +wi::bit_repeat (const wide_int_ref &x, unsigned int prec) > +{ > + unsigned int xprec = x.get_precision (); > + if (xprec >= prec) > + return wide_int::from (x, prec, UNSIGNED); > + if (xprec <= HOST_BITS_PER_WIDE_INT && (HOST_BITS_PER_WIDE_INT % xprec) == 0) > + { > + unsigned HOST_WIDE_INT val = x.to_uhwi (xprec); > + while (xprec < HOST_BITS_PER_WIDE_INT) > + { > + val |= val << xprec; > + xprec <<= 1; > + } > + wide_int ret = wide_int::create (prec); > + HOST_WIDE_INT *v = ret.write_val (0); > + unsigned int i = 0; > + for (unsigned int p = 0; p < prec; p += HOST_BITS_PER_WIDE_INT) > + v[i++] = val; > + ret.set_len (i, false); > + return ret; > + } > + wide_int ret = wide_int::from (x, prec, UNSIGNED), b; > + while (xprec < prec) > + { > + ret |= (ret << xprec); > + xprec <<= 1; > + } > + return ret; > +} > + > +/* Compute carry-less product of X and Y with precision PREC. */ > + > +wide_int > +wi::clmul (const wide_int_ref &x, const wide_int_ref &y, unsigned int prec) > +{ > + wide_int a; > + const wide_int_ref *b; > + if (wi::popcount (x) >= wi::popcount (y)) > + { > + a = wide_int::from (x, prec, UNSIGNED); > + b = &y; > + } > + else > + { > + a = wide_int::from (y, prec, UNSIGNED); > + b = &x; > + } > + unsigned int bprec = b->get_precision (); > + wide_int r = wi::zero (prec); > + unsigned int j = 0, k = 0; > + for (unsigned int i = 0; i < bprec; ++i) > + { > + if (((((unsigned HOST_WIDE_INT) b->elt (k)) >> j) & 1) != 0) > + r ^= a << i; > + if (++j == HOST_BITS_PER_WIDE_INT) > + { > + j = 0; > + ++k; > + } > + } > + return r; > +} > + > /* > * Private utilities. > */ > --- a/gcc/wide-int.h 2026-10-28 11:58:06.737131485 +0100 > +++ b/gcc/wide-int.h 2026-10-30 17:06:34.388570864 +0100 > @@ -3982,6 +3982,9 @@ namespace wi > bool, unsigned int); > unsigned int from_array (HOST_WIDE_INT *, const HOST_WIDE_INT *, > unsigned int, unsigned int, bool); > + > + wide_int bit_repeat (const wide_int_ref &, unsigned int); > + wide_int clmul (const wide_int_ref &, const wide_int_ref &, unsigned int); > } > > /* Return a PRECISION-bit integer in which the low WIDTH bits are set > --- a/gcc/builtins.cc 2026-10-29 10:04:45.898698728 +0100 > +++ b/gcc/builtins.cc 2026-10-30 17:06:34.389214260 +0100 > @@ -10732,6 +10732,52 @@ fold_builtin_addc_subc (location_t loc, > return build2_loc (loc, COMPOUND_EXPR, type, store, intres); > } > > +/* Fold __builtin_clmulg (arg1, arg2) or __builtin_clmulg (arg1, arg2, arg3) > + into IFN_CLMUL or IFN_CLMUL_WIDEN internal call. */ > + > +tree > +fold_build_builtin_clmulg (location_t loc, tree arg1, tree arg2, tree arg3) > +{ > + tree type = TYPE_MAIN_VARIANT (TREE_TYPE (arg1)); > + if (TREE_CODE (arg1) == INTEGER_CST > + && !TREE_OVERFLOW (arg1) > + && TREE_CODE (arg2) == INTEGER_CST > + && !TREE_OVERFLOW (arg2)) > + { > + unsigned prec = TYPE_PRECISION (type); > + wide_int res = wi::clmul (wi::to_wide (arg1), wi::to_wide (arg2), > + prec * (arg3 == NULL_TREE ? 1 : 2)); > + if (arg3 == NULL_TREE) > + return wide_int_to_tree (type, res); > + wide_int lo = wide_int::from (res, prec, UNSIGNED); > + wide_int hi = wide_int::from (wi::rshift (res, prec, UNSIGNED), > + prec, UNSIGNED); > + tree mem_arg3 = build_fold_indirect_ref_loc (loc, arg3); > + tree store > + = fold_build2_loc (loc, MODIFY_EXPR, void_type_node, mem_arg3, > + wide_int_to_tree (type, hi)); > + return build2_loc (loc, COMPOUND_EXPR, type, store, > + wide_int_to_tree (type, lo)); > + } > + if (arg3 == NULL_TREE) > + return build_call_expr_internal_loc (loc, IFN_CLMUL, type, 2, arg1, arg2); > + tree ctype = build_complex_type (type); > + tree call = build_call_expr_internal_loc (loc, IFN_CLMUL_WIDEN, ctype, 2, > + arg1, arg2); > + /* Force SAVE_EXPR even for calls which satisfy tree_invariant_p_1, > + as while the call itself is const, the REALPART_EXPR store is > + certainly not. And in any case, we want just one call, > + not multiple and trying to CSE them later. */ > + TREE_SIDE_EFFECTS (call) = 1; > + tree tgt = save_expr (call); > + tree intres = build1_loc (loc, REALPART_EXPR, type, tgt); > + tree ovfres = build1_loc (loc, IMAGPART_EXPR, type, tgt); > + tree mem_arg3 = build_fold_indirect_ref_loc (loc, arg3); > + tree store > + = fold_build2_loc (loc, MODIFY_EXPR, void_type_node, mem_arg3, ovfres); > + return build2_loc (loc, COMPOUND_EXPR, type, store, intres); > +} > + > /* Fold a call to __builtin_FILE to a constant string. */ > > static inline tree > --- a/gcc/internal-fn.def 2026-10-27 14:32:19.739209148 +0100 > +++ b/gcc/internal-fn.def 2026-10-30 17:06:34.389880678 +0100 > @@ -549,6 +549,8 @@ DEF_INTERNAL_FN (TSAN_FUNC_EXIT, ECF_NOV > DEF_INTERNAL_FN (VA_ARG, ECF_NOTHROW | ECF_LEAF, NULL) > DEF_INTERNAL_FN (VEC_CONVERT, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL) > DEF_INTERNAL_FN (RAWMEMCHR, ECF_PURE | ECF_LEAF | ECF_NOTHROW, NULL) > +DEF_INTERNAL_FN (CLMUL, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL) > +DEF_INTERNAL_FN (CLMUL_WIDEN, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL) > > /* An unduplicable, uncombinable function. Generally used to preserve > a CFG property in the face of jump threading, tail merging or > --- a/gcc/internal-fn.cc 2026-10-28 11:58:06.725131642 +0100 > +++ b/gcc/internal-fn.cc 2026-10-30 19:38:00.468830445 +0100 > @@ -4653,6 +4653,8 @@ commutative_binary_fn_p (internal_fn fn) > case IFN_UBSAN_CHECK_MUL: > case IFN_ADD_OVERFLOW: > case IFN_MUL_OVERFLOW: > + case IFN_CLMUL: > + case IFN_CLMUL_WIDEN: > case IFN_SAT_ADD: > case IFN_SAT_MUL: > case IFN_VEC_WIDEN_PLUS: > @@ -6020,3 +6022,330 @@ expand_BITREVERSE (internal_fn fn, gcall > if (expand_bitquery (fn, stmt)) > expand_unary_optab_fn (fn, stmt, bitreverse_optab); > } > + > +/* Expand CLMUL (OP0, OP1) where operands are in OP_MODE and have > + minimum unsigned precision PREC0 and PREC1. Compute result in MODE. */ > + > +static rtx > +expand_clmul (machine_mode mode, machine_mode op_mode, rtx op0, rtx op1, > + unsigned int prec0, unsigned int prec1) > +{ > + unsigned int op_prec = GET_MODE_PRECISION (as_a (op_mode)); > + unsigned int prec = GET_MODE_PRECISION (as_a (mode)); > + machine_mode cmode; > + optab_methods olw = OPTAB_LIB_WIDEN; > + if (MIN (prec0, prec1) == 1) > + { > + /* If one operand has [0, 1] range, we can do just > + multiplication and if both are [0, 1], this is equivalent to AND. */ > + rtx res = expand_binop (op_mode, prec0 == prec1 ? and_optab : smul_optab, > + op0, op1, NULL_RTX, 1, olw); > + return convert_modes (mode, op_mode, res, 1); > + } > + FOR_EACH_MODE_IN_CLASS (cmode, MODE_INT) > + { > + unsigned int this_prec > + = GET_MODE_PRECISION (as_a (cmode)); > + if (prec0 > this_prec || prec1 > this_prec) > + continue; > + if (optab_handler (clmul_optab, cmode) != CODE_FOR_nothing > + && (prec0 + prec1 - 1 <= this_prec || prec <= this_prec)) > + { > + rtx_insn *start = get_last_insn (); > + rtx op0c = convert_modes (cmode, op_mode, op0, 1); > + rtx op1c = convert_modes (cmode, op_mode, op1, 1); > + if (rtx res = expand_binop (cmode, clmul_optab, op0c, op1c, > + NULL_RTX, 1, OPTAB_DIRECT)) > + return convert_modes (mode, cmode, res, 1); > + delete_insns_since (start); > + } > + if (optab_handler (clmul_widen_optab, cmode) != CODE_FOR_nothing) > + { > + rtx_insn *start = get_last_insn (); > + rtx op0c = convert_modes (cmode, op_mode, op0, 1); > + rtx op1c = convert_modes (cmode, op_mode, op1, 1); > + rtx reslo = gen_reg_rtx (cmode); > + rtx reshi = gen_reg_rtx (cmode); > + class expand_operand ops[4]; > + create_output_operand (&ops[0], reslo, cmode); > + create_output_operand (&ops[1], reshi, cmode); > + create_input_operand (&ops[2], op0c, cmode); > + create_input_operand (&ops[3], op1c, cmode); > + if (maybe_expand_insn (optab_handler (clmul_widen_optab, cmode), > + 4, ops)) > + { > + if (prec0 + prec1 - 1 <= this_prec || prec <= this_prec) > + return convert_modes (mode, cmode, reslo, 1); > + machine_mode wmode; > + if (!GET_MODE_2XWIDER_MODE (cmode).exists (&wmode)) > + wmode = mode; > + reslo = convert_modes (wmode, cmode, reslo, 1); > + reshi = convert_modes (wmode, cmode, reshi, 1); > + reshi = expand_shift (LSHIFT_EXPR, wmode, reshi, this_prec, > + NULL_RTX, 1); > + rtx res = expand_binop (wmode, ior_optab, reslo, reshi, > + NULL_RTX, 1, olw); > + return convert_modes (mode, wmode, res, 1); > + } > + delete_insns_since (start); > + } > + } > + /* Fallback using Kronecker substitution. > + Depending on the number of active bits in the operand with smaller > + number of those and the result precision we choose smallest spacing > + S in [2, 13], such that MIN (prec0, prec1) <= S * ((1 << S) - 1), > + or prec <= S * (1 << S) or prec0 + prec1 - 1 <= S * (1 << S). > + The algorithm then uses S * S multiplications, 3 * S bitwise ANDs, > + S * (S - 1) XORs and S - 1 IORs. > + For e.g. S = 4 this is: > + uint64_t x0 = x & 0x1111111111111111ULL, y0 = y & 0x1111111111111111ULL; > + uint64_t x1 = x & 0x2222222222222222ULL, y1 = y & 0x2222222222222222ULL; > + uint64_t x2 = x & 0x4444444444444444ULL, y2 = y & 0x4444444444444444ULL; > + uint64_t x3 = x & 0x8888888888888888ULL, y3 = y & 0x8888888888888888ULL; > + uint64_t z0 = (x0 * y0) ^ (x1 * y3) ^ (x2 * y2) ^ (x3 * y1); > + uint64_t z1 = (x0 * y1) ^ (x1 * y0) ^ (x2 * y3) ^ (x3 * y2); > + uint64_t z2 = (x0 * y2) ^ (x1 * y1) ^ (x2 * y0) ^ (x3 * y3); > + uint64_t z3 = (x0 * y3) ^ (x1 * y2) ^ (x2 * y1) ^ (x3 * y0); > + z0 &= 0x1111111111111111ULL; > + z1 &= 0x2222222222222222ULL; > + z2 &= 0x4444444444444444ULL; > + z3 &= 0x8888888888888888ULL; > + return (z0 | z1) | (z2 | z3); */ > + unsigned int s; > + for (s = 2; s <= 13; ++s) > + if (MIN (prec0, prec1) <= s * ((1 << s) - 1) > + || MIN (prec, prec0 + prec1 - 1) <= s * (1 << s)) > + break; > + /* S = 13 should handle up to _BitInt maximum 65535 (106483 bits). */ > + gcc_assert (s <= 13); > + rtx mask[13], x[13], y[13], t[13], r; > + bool do_widen_mult = false; > + if (mode != op_mode > + && (convert_optab_handler (umul_widen_optab, mode, op_mode) > + != CODE_FOR_nothing)) > + do_widen_mult = true; > + for (unsigned int i = 0; i < s; ++i) > + { > + mask[i] > + = immed_wide_int_const (wi::bit_repeat (wide_int::from (1 << i, s, > + UNSIGNED), > + op_prec), op_mode); > + if (CONST_INT_P (op0) && CONST_INT_P (mask[i])) > + x[i] = gen_int_mode (INTVAL (op0) & INTVAL (mask[i]), op_mode); > + else > + x[i] = expand_binop (op_mode, and_optab, op0, mask[i], NULL_RTX, 1, > + olw); > + if (mode != op_mode && !do_widen_mult) > + x[i] = convert_modes (mode, op_mode, x[i], 1); > + if (CONST_INT_P (op1) && CONST_INT_P (mask[i])) > + y[i] = gen_int_mode (INTVAL (op1) & INTVAL (mask[i]), op_mode); > + else > + y[i] = expand_binop (op_mode, and_optab, op1, mask[i], NULL_RTX, 1, > + olw); > + if (mode != op_mode && !do_widen_mult) > + y[i] = convert_modes (mode, op_mode, y[i], 1); > + } > + for (unsigned int i = 0; i < s; ++i) > + { > + for (unsigned int j = 0; j < s; ++j) > + { > + unsigned int k = (i + s - j) % s; > + if (do_widen_mult) > + t[j] = expand_widening_mult (mode, x[j], y[k], NULL_RTX, 1, > + umul_widen_optab); > + else > + t[j] = expand_binop (mode, smul_optab, x[j], y[k], NULL_RTX, 1, > + olw); > + if ((j & 1) == 1) > + { > + t[j - 1] = expand_binop (mode, xor_optab, t[j - 1], t[j], > + NULL_RTX, 1, olw); > + t[j] = NULL_RTX; > + } > + if ((j & 3) == 3) > + { > + t[j - 3] = expand_binop (mode, xor_optab, t[j - 3], t[j - 1], > + NULL_RTX, 1, olw); > + t[j - 1] = NULL_RTX; > + } > + } > + for (unsigned int j = 1; j < s; ++j) > + if (t[j]) > + t[0] = expand_binop (mode, xor_optab, t[0], t[j], NULL_RTX, 1, olw); > + if (mode != op_mode) > + mask[i] > + = immed_wide_int_const (wi::bit_repeat (wide_int::from (1 << i, s, > + UNSIGNED), > + prec), mode); > + t[0] = expand_binop (mode, and_optab, t[0], mask[i], NULL_RTX, 1, olw); > + if (i == 0) > + r = t[0]; > + else > + r = expand_binop (mode, ior_optab, r, t[0], NULL_RTX, 1, olw); > + } > + return r; > +} > + > +void > +expand_CLMUL (internal_fn, gcall *stmt) > +{ > + tree lhs = gimple_call_lhs (stmt); > + tree arg0 = gimple_call_arg (stmt, 0); > + tree arg1 = gimple_call_arg (stmt, 1); > + scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg0)); > + unsigned int prec0 = get_min_precision (arg0, UNSIGNED); > + unsigned int prec1 = get_min_precision (arg1, UNSIGNED); > + rtx op0 = expand_normal (arg0); > + rtx op1 = expand_normal (arg1); > + rtx res = expand_clmul (mode, mode, op0, op1, prec0, prec1); > + if (TYPE_PRECISION (TREE_TYPE (arg0)) < GET_MODE_PRECISION (mode)) > + { > + rtx mask > + = immed_wide_int_const (wi::mask (TYPE_PRECISION (TREE_TYPE (arg0)), > + false, > + GET_MODE_PRECISION (mode)), mode); > + res = expand_and (mode, res, mask, NULL_RTX); > + } > + rtx target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE); > + emit_move_insn (target, res); > +} > + > +void > +expand_CLMUL_WIDEN (internal_fn, gcall *stmt) > +{ > + tree lhs = gimple_call_lhs (stmt); > + tree arg0 = gimple_call_arg (stmt, 0); > + tree arg1 = gimple_call_arg (stmt, 1); > + scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg0)); > + unsigned int prec0 = get_min_precision (arg0, UNSIGNED); > + unsigned int prec1 = get_min_precision (arg1, UNSIGNED); > + unsigned int prec = GET_MODE_PRECISION (mode); > + rtx op0 = expand_normal (arg0); > + rtx op1 = expand_normal (arg1); > + rtx target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE); > + rtx bitint_mask = NULL_RTX; > + if (TYPE_PRECISION (TREE_TYPE (arg0)) != prec) > + bitint_mask > + = immed_wide_int_const (wi::mask (TYPE_PRECISION (TREE_TYPE (arg0)), > + false, prec), mode); > + if (prec0 + prec1 - 1 <= prec) > + { > + rtx res = expand_clmul (mode, mode, op0, op1, prec0, prec1); > + if (bitint_mask) > + res = expand_and (mode, res, bitint_mask, NULL_RTX); > + write_complex_part (target, res, false, true); > + write_complex_part (target, const0_rtx, true, false); > + return; > + } > + if (optab_handler (clmul_widen_optab, mode) != CODE_FOR_nothing > + && TYPE_PRECISION (TREE_TYPE (arg0)) == prec) > + { > + rtx_insn *start = get_last_insn (); > + rtx reslo = gen_reg_rtx (mode); > + rtx reshi = gen_reg_rtx (mode); > + class expand_operand ops[4]; > + create_output_operand (&ops[0], reslo, mode); > + create_output_operand (&ops[1], reshi, mode); > + create_input_operand (&ops[2], op0, mode); > + create_input_operand (&ops[3], op1, mode); > + if (maybe_expand_insn (optab_handler (clmul_widen_optab, mode), > + 4, ops)) > + { > + write_complex_part (target, reslo, false, true); > + write_complex_part (target, reshi, true, false); > + return; > + } > + delete_insns_since (start); > + } > + scalar_int_mode wmode; > + if (GET_MODE_2XWIDER_MODE (mode).exists (&wmode) > + && targetm.scalar_mode_supported_p (wmode)) > + { > + rtx res = expand_clmul (wmode, mode, op0, op1, prec0, prec1); > + rtx reslo = convert_modes (mode, wmode, res, 1); > + if (bitint_mask) > + reslo = expand_and (mode, reslo, bitint_mask, NULL_RTX); > + write_complex_part (target, reslo, false, true); > + rtx reshi = expand_shift (RSHIFT_EXPR, wmode, res, > + TYPE_PRECISION (TREE_TYPE (arg0)), > + NULL_RTX, 1); > + reshi = convert_modes (mode, wmode, reshi, 1); > + write_complex_part (target, reshi, true, false); > + return; > + } > + /* If we have native bitreverse in mode, fallback using: > + uint64_t l = clmul (x, y); > + uint64_t h = clmul (__builtin_bitreverseg (x), > + __builtin_bitreverseg (y)); > + return { l, __builtin_bitreverseg (h) >> 1 }; */ > + if (optab_handler (bitreverse_optab, mode) != CODE_FOR_nothing > + || (prec == 2 * UNITS_PER_WORD > + && optab_handler (bitreverse_optab, word_mode) != CODE_FOR_nothing)) > + { > + rtx reslo = expand_clmul (mode, mode, op0, op1, prec0, prec1); > + if (bitint_mask) > + reslo = expand_and (mode, reslo, bitint_mask, NULL_RTX); > + write_complex_part (target, reslo, false, true); > + rtx revx = expand_unop (mode, bitreverse_optab, op0, NULL_RTX, 1); > + rtx revy = expand_unop (mode, bitreverse_optab, op1, NULL_RTX, 1); > + rtx reshi = expand_clmul (mode, mode, revx, revy, prec, prec); > + reshi = expand_unop (mode, bitreverse_optab, reshi, NULL_RTX, 1); > + if (bitint_mask) > + reshi = expand_and (mode, reshi, bitint_mask, NULL_RTX); > + reshi = expand_shift (RSHIFT_EXPR, mode, reshi, 1, NULL_RTX, 1); > + write_complex_part (target, reshi, true, false); > + return; > + } > + /* Fallback to modified Karatsuba multiplication step > + using 3x expand_clmul in mode. > + For 64x64 -> 128bit CLMUL this would be: > + uint64_t x0 = (uint32_t) x, x1 = (x >> 32); > + uint64_t y0 = (uint32_t) y, y1 = (y >> 32); > + uint64_t l = clmul (x0, y0); > + uint64_t m = clmul (x0 ^ x1, y0 ^ y1); > + uint64_t h = clmul (x1, y1); > + m ^= l ^ h; > + return { l ^ (m << 32), h ^ (m >> 32) }; */ > + unsigned int hprec = prec / 2; > + rtx mask = immed_wide_int_const (wi::mask (hprec, false, prec), mode); > + optab_methods olw = OPTAB_LIB_WIDEN; > + rtx x0 = expand_binop (mode, and_optab, op0, mask, NULL_RTX, 1, olw); > + rtx x1 = expand_shift (RSHIFT_EXPR, mode, op0, hprec, NULL_RTX, 1); > + rtx y0 = expand_binop (mode, and_optab, op1, mask, NULL_RTX, 1, olw); > + rtx y1 = expand_shift (RSHIFT_EXPR, mode, op1, hprec, NULL_RTX, 1); > + rtx l = expand_clmul (mode, mode, x0, y0, hprec, hprec); > + rtx t0 = expand_binop (mode, xor_optab, x0, x1, NULL_RTX, 1, olw); > + rtx t1 = expand_binop (mode, xor_optab, y0, y1, NULL_RTX, 1, olw); > + rtx m = expand_clmul (mode, mode, t0, t1, hprec, hprec); > + rtx h; > + if (prec0 <= hprec || prec1 <= hprec) > + h = const0_rtx; > + else > + h = expand_clmul (mode, mode, x1, y1, MIN (hprec, prec0 - hprec), > + MIN (hprec, prec1 - hprec)); > + t0 = expand_binop (mode, xor_optab, l, h, NULL_RTX, 1, olw); > + m = expand_binop (mode, xor_optab, m, t0, NULL_RTX, 1, olw); > + t0 = expand_shift (LSHIFT_EXPR, mode, m, hprec, NULL_RTX, 1); > + t1 = expand_shift (RSHIFT_EXPR, mode, m, hprec, NULL_RTX, 1); > + rtx reslo = expand_binop (mode, xor_optab, l, t0, NULL_RTX, 1, olw); > + if (bitint_mask) > + { > + rtx reslom = expand_and (mode, reslo, bitint_mask, NULL_RTX); > + write_complex_part (target, reslom, false, true); > + rtx reshi = expand_binop (mode, xor_optab, h, t1, NULL_RTX, 1, olw); > + reshi = expand_shift (LSHIFT_EXPR, mode, reshi, > + prec - TYPE_PRECISION (TREE_TYPE (arg0)), > + NULL_RTX, 1); > + reslo = expand_shift (RSHIFT_EXPR, mode, reslo, > + TYPE_PRECISION (TREE_TYPE (arg0)), NULL_RTX, 1); > + reshi = expand_binop (mode, ior_optab, reshi, reslo, NULL_RTX, 1, olw); > + reshi = expand_and (mode, reshi, bitint_mask, NULL_RTX); > + write_complex_part (target, reshi, true, false); > + } > + else > + { > + write_complex_part (target, reslo, false, true); > + rtx reshi = expand_binop (mode, xor_optab, h, t1, NULL_RTX, 1, olw); > + write_complex_part (target, reshi, true, false); > + } > +} > --- a/gcc/optabs.def 2026-10-27 14:32:19.745209068 +0100 > +++ b/gcc/optabs.def 2026-10-30 17:06:34.390945359 +0100 > @@ -577,3 +577,5 @@ OPTAB_D (mask_len_strided_store_optab, " > OPTAB_D (andn_optab, "andn$a3") > OPTAB_D (iorn_optab, "iorn$a3") > OPTAB_D (aop_optab, "aop$a3") > +OPTAB_D (clmul_optab, "clmul$a3") > +OPTAB_D (clmul_widen_optab, "clmul_widen$a3") > --- a/gcc/gimple-lower-bitint.cc 2026-10-27 14:32:12.590303911 +0100 > +++ b/gcc/gimple-lower-bitint.cc 2026-10-30 17:06:34.391314891 +0100 > @@ -478,6 +478,7 @@ struct bitint_large_huge > void lower_complexexpr_stmt (gimple *); > void lower_bit_query (gimple *); > void lower_bswap_bitreverse (tree, gimple *); > + void lower_clmul (tree, gimple *); > void lower_call (tree, gimple *); > void lower_asm (gimple *); > void lower_stmt (gimple *); > @@ -6305,6 +6306,236 @@ bitint_large_huge::lower_bswap_bitrevers > } > } > > +/* Lower a .CLMUL call with two large/huge _BitInt arguments. */ > + > +void > +bitint_large_huge::lower_clmul (tree obj, gimple *stmt) > +{ > + tree arg1 = gimple_call_arg (stmt, 0); > + tree arg2 = gimple_call_arg (stmt, 1); > + tree lhs = gimple_call_lhs (stmt); > + gimple *g; > + > + if (!lhs) > + { > + gimple_stmt_iterator gsi = gsi_for_stmt (stmt); > + gsi_remove (&gsi, true); > + return; > + } > + if (wi::popcount (get_nonzero_bits (arg1)) > + < wi::popcount (get_nonzero_bits (arg2))) > + std::swap (arg1, arg2); > + tree type = TREE_TYPE (arg1); > + gcc_assert (BITINT_TYPE_P (type)); > + bitint_prec_kind kind = bitint_precision_kind (type); > + gcc_assert (kind >= bitint_prec_large); > + if (!obj) > + { > + int part = var_to_partition (m_map, lhs); > + gcc_assert (m_vars[part] != NULL_TREE); > + obj = m_vars[part]; > + } > + /* For .CLMUL, we can use handle_operand with non-INTEGER_CST > + idx even to access the most significant partial limb. */ > + m_var_msb = true; > + unsigned prec = TYPE_PRECISION (type); > + /* Lower > + dst = .CLMUL (src1, src2); > + as > + size_t p = prec / limb_prec - (prec % limb_prec == 0); > + dst = {}; > + for (idx = 0; idx <= p; ++idx) > + { > + limb_type t = src2[idx]; > + size_t i = 0, j = 0; > + do > + { > + if (t & 1) > + { > + size_t idx3 = idx + j; > + size_t k = -i & (limb_prec - 1); > + r[idx] ^= (src1[0] << i); > + for (idx2 = idx + 1; idx2 <= p; ++idx2) > + r[idx2] ^= (src1[idx2 - idx] << i) > + | (src1[idx2 - idx3] >> k); > + } > + t >>= 1; > + ++i; > + j = 1; > + } > + while (t); > + } */ > + tree p = build_int_cst (sizetype, > + prec / limb_prec - (prec % limb_prec == 0)); > + tree zero = build_zero_cst (TREE_TYPE (obj)); > + g = gimple_build_assign (obj, zero); > + insert_before (g); > + tree idx_next; > + tree idx = create_loop (bitint_big_endian ? p : size_zero_node, &idx_next); > + m_data_cnt = 0; > + tree t_init = handle_operand (arg2, idx); > + m_first = false; > + tree i_next; > + tree i = create_loop (size_zero_node, &i_next); > + tree j = make_ssa_name (sizetype); > + gphi *phi = create_phi_node (j, m_bb); > + add_phi_arg (phi, size_zero_node, find_edge (m_preheader_bb, m_bb), > + UNKNOWN_LOCATION); > + add_phi_arg (phi, size_one_node, find_edge (m_bb, m_bb), UNKNOWN_LOCATION); > + tree t = make_ssa_name (m_limb_type); > + phi = create_phi_node (t, m_bb); > + add_phi_arg (phi, t_init, find_edge (m_preheader_bb, m_bb), > + UNKNOWN_LOCATION); > + tree t_next = make_ssa_name (m_limb_type); > + add_phi_arg (phi, t_next, find_edge (m_bb, m_bb), UNKNOWN_LOCATION); > + tree t1 = make_ssa_name (m_limb_type); > + g = gimple_build_assign (t1, BIT_AND_EXPR, t, build_one_cst (m_limb_type)); > + insert_before (g); > + g = gimple_build_cond (NE_EXPR, t1, build_zero_cst (m_limb_type), > + NULL_TREE, NULL_TREE); > + edge edge_true, edge_false; > + if_then (g, profile_probability::even (), edge_true, edge_false); > + tree idx3 = make_ssa_name (sizetype), idx4 = idx; > + g = gimple_build_assign (idx3, bitint_big_endian ? MINUS_EXPR : PLUS_EXPR, > + idx, j); > + insert_before (g); > + if (bitint_big_endian) > + { > + g = gimple_build_assign (make_ssa_name (sizetype), MINUS_EXPR, p, idx3); > + insert_before (g); > + idx3 = gimple_assign_lhs (g); > + idx4 = make_ssa_name (sizetype); > + g = gimple_build_assign (idx4, MINUS_EXPR, p, idx); > + insert_before (g); > + } > + g = gimple_build_assign (make_ssa_name (sizetype), NEGATE_EXPR, i); > + insert_before (g); > + tree k = make_ssa_name (sizetype); > + g = gimple_build_assign (k, BIT_AND_EXPR, gimple_assign_lhs (g), > + size_int (limb_prec - 1)); > + insert_before (g); > + unsigned data_cnt = m_data_cnt; > + m_first = true; > + tree s1 = handle_operand (arg1, bitint_big_endian ? p : size_zero_node); > + m_first = false; > + m_data_cnt = data_cnt; > + g = gimple_build_assign (make_ssa_name (m_limb_type), LSHIFT_EXPR, s1, i); > + insert_before (g); > + s1 = gimple_assign_lhs (g); > + tree r = limb_access (TREE_TYPE (lhs), obj, idx, false); > + g = gimple_build_assign (make_ssa_name (m_limb_type), r); > + insert_before (g); > + g = gimple_build_assign (make_ssa_name (m_limb_type), BIT_XOR_EXPR, > + gimple_assign_lhs (g), s1); > + insert_before (g); > + r = limb_access (TREE_TYPE (lhs), obj, idx, true); > + g = gimple_build_assign (r, gimple_assign_lhs (g)); > + insert_before (g); > + tree idxp1 = make_ssa_name (sizetype); > + g = gimple_build_assign (idxp1, PLUS_EXPR, idx, > + bitint_big_endian ? size_int (-1) : size_one_node); > + insert_before (g); > + if (bitint_big_endian) > + g = gimple_build_cond (NE_EXPR, idxp1, size_int (-1), > + NULL_TREE, NULL_TREE); > + else > + g = gimple_build_cond (LE_EXPR, idxp1, p, NULL_TREE, NULL_TREE); > + edge edge_true2, edge_false2; > + if_then (g, profile_probability::likely (), edge_true2, edge_false2); > + tree idx2_next; > + tree idx2 = create_loop (idxp1, &idx2_next); > + tree idx2midx = make_ssa_name (sizetype); > + g = gimple_build_assign (idx2midx, MINUS_EXPR, idx2, idx4); > + insert_before (g); > + tree idx2midx3 = make_ssa_name (sizetype); > + g = gimple_build_assign (idx2midx3, MINUS_EXPR, idx2, idx3); > + insert_before (g); > + m_data_cnt = data_cnt; > + tree s2 = handle_operand (arg1, idx2midx); > + g = gimple_build_assign (make_ssa_name (m_limb_type), LSHIFT_EXPR, > + s2, i); > + insert_before (g); > + s2 = gimple_assign_lhs (g); > + m_data_cnt = data_cnt; > + tree s3 = handle_operand (arg1, idx2midx3); > + g = gimple_build_assign (make_ssa_name (m_limb_type), RSHIFT_EXPR, > + s3, k); > + insert_before (g); > + g = gimple_build_assign (make_ssa_name (m_limb_type), BIT_IOR_EXPR, > + s2, gimple_assign_lhs (g)); > + insert_before (g); > + s2 = gimple_assign_lhs (g); > + r = limb_access (TREE_TYPE (lhs), obj, idx2, false); > + g = gimple_build_assign (make_ssa_name (m_limb_type), r); > + insert_before (g); > + g = gimple_build_assign (make_ssa_name (m_limb_type), BIT_XOR_EXPR, > + gimple_assign_lhs (g), s2); > + insert_before (g); > + r = limb_access (TREE_TYPE (lhs), obj, idx2, true); > + g = gimple_build_assign (r, gimple_assign_lhs (g)); > + insert_before (g); > + g = gimple_build_assign (idx2_next, PLUS_EXPR, idx2, > + bitint_big_endian ? size_int (-1) : size_one_node); > + insert_before (g); > + if (bitint_big_endian) > + g = gimple_build_cond (NE_EXPR, idx2_next, size_int (-1), > + NULL_TREE, NULL_TREE); > + else > + g = gimple_build_cond (LE_EXPR, idx2_next, p, NULL_TREE, NULL_TREE); > + insert_before (g); > + m_gsi = gsi_after_labels (edge_false->dest); > + g = gimple_build_assign (t_next, RSHIFT_EXPR, t, integer_one_node); > + insert_before (g); > + g = gimple_build_assign (i_next, PLUS_EXPR, i, size_one_node); > + insert_before (g); > + g = gimple_build_cond (NE_EXPR, t_next, build_zero_cst (m_limb_type), > + NULL_TREE, NULL_TREE); > + insert_before (g); > + if ((EDGE_SUCC (edge_false->dest, 0)->flags & EDGE_FALSE_VALUE) != 0) > + m_gsi = gsi_after_labels (EDGE_SUCC (edge_false->dest, 0)->dest); > + else > + m_gsi = gsi_after_labels (EDGE_SUCC (edge_false->dest, 1)->dest); > + g = gimple_build_assign (idx_next, PLUS_EXPR, idx, > + bitint_big_endian ? size_int (-1) : size_one_node); > + insert_before (g); > + if (bitint_big_endian) > + g = gimple_build_cond (NE_EXPR, idx_next, size_int (-1), > + NULL_TREE, NULL_TREE); > + else > + g = gimple_build_cond (LE_EXPR, idx_next, p, NULL_TREE, NULL_TREE); > + insert_before (g); > + m_gsi = gsi_for_stmt (stmt); > + if (bitint_extended && prec % limb_prec != 0) > + { > + /* The most significant limb has been updated either in the > + loop or in the if after it. To simplify the code, just > + read it back from memory and extend. */ > + idx = bitint_big_endian ? size_zero_node : p; > + tree l = limb_access (TREE_TYPE (lhs), obj, idx, true); > + tree type = limb_access_type (TREE_TYPE (lhs), idx); > + tree v = make_ssa_name (m_limb_type); > + g = gimple_build_assign (v, l); > + insert_before (g); > + v = add_cast (type, v); > + l = limb_access (TREE_TYPE (lhs), obj, idx, true); > + v = add_cast (m_limb_type, v); > + g = gimple_build_assign (l, v); > + insert_before (g); > + } > + if (bitint_extended == bitint_ext_full > + && abi_limb_prec > limb_prec > + && (CEIL (prec, abi_limb_prec) * abi_limb_prec > + > CEIL (prec, limb_prec) * limb_prec)) > + { > + tree p2 = build_int_cst (sizetype, > + CEIL (prec, abi_limb_prec) > + * abi_limb_prec / limb_prec - 1); > + tree l = limb_access (TREE_TYPE (lhs), obj, p2, true); > + g = gimple_build_assign (l, build_zero_cst (m_limb_type)); > + insert_before (g); > + } > +} > + > /* Lower a call statement with one or more large/huge _BitInt > arguments or large/huge _BitInt return value. */ > > @@ -6338,6 +6569,9 @@ bitint_large_huge::lower_call (tree obj, > case IFN_BITREVERSE: > lower_bswap_bitreverse (obj, stmt); > return; > + case IFN_CLMUL: > + lower_clmul (obj, stmt); > + return; > default: > break; > } > @@ -6654,6 +6888,7 @@ bitint_large_huge::lower_stmt (gimple *s > { > case IFN_BSWAP: > case IFN_BITREVERSE: > + case IFN_CLMUL: > lower_call (lhs, g); > goto handled; > default: > @@ -6820,10 +7055,11 @@ stmt_needs_operand_addr (gimple *stmt) > case IFN_MUL_OVERFLOW: > case IFN_UBSAN_CHECK_MUL: > return true; > - /* These two actually don't take address, but reshuffle > + /* These three actually don't take address, but reshuffle > all bytes or bits, so need similar treatment. */ > case IFN_BSWAP: > case IFN_BITREVERSE: > + case IFN_CLMUL: > return true; > default: > break; > @@ -7058,6 +7294,7 @@ build_bitint_stmt_ssa_conflicts (gimple > case IFN_UBSAN_CHECK_MUL: > case IFN_BSWAP: > case IFN_BITREVERSE: > + case IFN_CLMUL: > lhs = gimple_call_lhs (stmt); > if (lhs) > muldiv_p = true; > @@ -7598,6 +7835,55 @@ gimple_lower_bitint (void) > add_phi_arg (phi, rhs2, e3, UNKNOWN_LOCATION); > break; > } > + else if (gimple_call_internal_p (stmt, IFN_CLMUL_WIDEN)) > + { > + /* For now, lower this to two IFN_CLMUL and three > + IFN_BITREVERSE calls. Could be implemented in > + lower_clmul too, just needs special care on padding > + bits and split the shifting into up to two disjunct > + results, or treat result as 2*prec array and adjust > + afterwards. */ > + first_large_huge = 0; > + location_t loc = gimple_location (stmt); > + tree arg0 = gimple_call_arg (stmt, 0); > + tree arg1 = gimple_call_arg (stmt, 1); > + tree type = TREE_TYPE (arg0); > + gsi = gsi_for_stmt (stmt); > + gimple *g = gimple_build_call_internal (IFN_CLMUL, 2, > + arg0, arg1); > + tree real = make_ssa_name (type); > + gimple_call_set_lhs (g, real); > + gsi_insert_before (&gsi, g, GSI_SAME_STMT); > + gimple_set_location (g, loc); > + g = gimple_build_call_internal (IFN_BITREVERSE, 1, arg0); > + tree rarg0 = make_ssa_name (type); > + gimple_call_set_lhs (g, rarg0); > + gsi_insert_before (&gsi, g, GSI_SAME_STMT); > + gimple_set_location (g, loc); > + g = gimple_build_call_internal (IFN_BITREVERSE, 1, arg1); > + tree rarg1 = make_ssa_name (type); > + gimple_call_set_lhs (g, rarg1); > + gsi_insert_before (&gsi, g, GSI_SAME_STMT); > + gimple_set_location (g, loc); > + g = gimple_build_call_internal (IFN_CLMUL, 2, rarg0, rarg1); > + tree rimag = make_ssa_name (type); > + gimple_call_set_lhs (g, rimag); > + gsi_insert_before (&gsi, g, GSI_SAME_STMT); > + gimple_set_location (g, loc); > + g = gimple_build_call_internal (IFN_BITREVERSE, 1, rimag); > + tree imag = make_ssa_name (type); > + gimple_call_set_lhs (g, imag); > + gsi_insert_before (&gsi, g, GSI_SAME_STMT); > + gimple_set_location (g, loc); > + g = gimple_build_assign (make_ssa_name (type), RSHIFT_EXPR, imag, > + build_one_cst (unsigned_type_node)); > + gsi_insert_before (&gsi, g, GSI_SAME_STMT); > + gimple_set_location (g, loc); > + g = gimple_build_assign (gimple_call_lhs (stmt), COMPLEX_EXPR, > + real, gimple_assign_lhs (g)); > + gimple_set_location (g, loc); > + gsi_replace (&gsi, g, true); > + } > else if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (s) > && is_gimple_call (stmt) > && gimple_call_internal_p (stmt)) > @@ -7611,6 +7897,7 @@ gimple_lower_bitint (void) > case IFN_UBSAN_CHECK_MUL: > case IFN_BSWAP: > case IFN_BITREVERSE: > + case IFN_CLMUL: > for (unsigned i = 0; i < gimple_call_num_args (stmt); ++i) > { > location_t loc = gimple_location (stmt); > @@ -7948,6 +8235,7 @@ gimple_lower_bitint (void) > { > case IFN_BSWAP: > case IFN_BITREVERSE: > + case IFN_CLMUL: > if (gimple_store_p (use_stmt) > && is_gimple_assign (use_stmt) > && !gimple_has_volatile_ops (use_stmt) > @@ -8069,6 +8357,7 @@ gimple_lower_bitint (void) > case IFN_POPCOUNT: > case IFN_BSWAP: > case IFN_BITREVERSE: > + case IFN_CLMUL: > continue; > default: > break; > --- a/gcc/match.pd 2026-10-29 10:04:45.920698437 +0100 > +++ b/gcc/match.pd 2026-10-30 17:06:34.392806693 +0100 > @@ -13883,3 +13883,22 @@ and, > && wi::le_p (wi::to_wide (@1), bound, TYPE_SIGN (type)))) > @3))))) > #endif > + > +(simplify > + (IFN_CLMUL:c @0 zero_one_valued_p@1) > + (mult @0 @1)) > + > +#if GIMPLE > +(simplify > + (IFN_CLMUL_WIDEN @0 @1) > + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) && TYPE_UNSIGNED (TREE_TYPE (@0))) > + (with { unsigned int min_prec0 = TYPE_PRECISION (TREE_TYPE (@0)); > + unsigned int min_prec1 = min_prec0; > + int_range_max vr0, vr1; > + if (gimple_match_range_of_expr (vr0, @0) && !vr0.undefined_p ()) > + min_prec0 = wi::min_precision (vr0.upper_bound (), UNSIGNED); > + if (gimple_match_range_of_expr (vr1, @1) && !vr1.undefined_p ()) > + min_prec1 = wi::min_precision (vr1.upper_bound (), UNSIGNED); } > + (if (min_prec0 + min_prec1 - 1 <= TYPE_PRECISION (TREE_TYPE (@0))) > + (complex (IFN_CLMUL @0 @1) { build_zero_cst (TREE_TYPE (@0)); }))))) > +#endif > --- a/gcc/genmatch.cc 2026-10-27 14:32:12.590303911 +0100 > +++ b/gcc/genmatch.cc 2026-10-30 17:06:34.393746767 +0100 > @@ -1393,6 +1393,8 @@ commutative_op (id_base *id, bool compar > case CFN_FNMS: > case CFN_ADD_OVERFLOW: > case CFN_MUL_OVERFLOW: > + case CFN_CLMUL: > + case CFN_CLMUL_WIDEN: > case CFN_SAT_ADD: > return 0; > > > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From hr.jonas.hansen@gmail.com Mon Nov 2 08:41:39 2026 From: hr.jonas.hansen@gmail.com (Jonas Hansen) Date: Mon, 2 Nov 2026 09:41:39 +0100 Subject: [PATCH v3] middle-end: Track deferred initialization by declaration [PR124380] In-Reply-To: <0948f589-32d2-4d39-8e00-66c481e99780@redhat.com> References: <0948f589-32d2-4d39-8e00-66c481e99780@redhat.com> Message-ID: > On 30 Oct 2026, at 17.23, Jason Merrill wrote: > > On 10/30/26 7:50 AM, Jonas Hansen via Sourceware Forge wrote: >> From: Jonas Hansen >> The name recorded by .DEFERRED_INIT can stop identifying its destination >> after inlining or LTO renumbers anonymous declarations. This makes >> warn_uninit diagnose an artificial initialization store as an >> uninitialized read, notably with sanitizers and -ftrivial-auto-var-init. >> Use the initialized declaration's address as diagnostic metadata instead >> of a name string. Preserve its identity through declaration remapping >> and LTO streaming, and compare declarations in warn_uninit. Keep this >> operand unevaluated and avoid making the object addressable or preventing >> SSA promotion. Update scalar replacement, nested-function lowering, >> parallelization and offload handling accordingly. > > Is the ADDR_EXPR easier to handle than using the DECL directly as the operand? > > Jason > Hi Jason, I followed Richard?s earlier preference (https://www.mail-archive.com/gcc-patches%40gcc.gnu.org/msg423145.html) for IL hygiene. ADDR_EXPR has one useful property here: SSA operand scanning already treats &decl as identifying an object without reading its value. A bare register-type DECL would normally be treated as a value use and renamed into SSA. However, the address form still requires special handling to avoid making the object addressable and to preserve the metadata through transformations. A direct DECL would instead need explicit handling to prevent value-use processing. I haven?t implemented the direct-DECL alternative for comparison, so I can?t claim the address form is simpler overall. Jonas From Tamar.Christina@arm.com Mon Nov 2 08:44:43 2026 From: Tamar.Christina@arm.com (Tamar Christina) Date: Mon, 2 Nov 2026 08:44:43 +0000 Subject: [patch v3][gcc 1/5]middle-end: support multi-character output operand modifiers [PR122716] In-Reply-To: References: Message-ID: > -----Original Message----- > From: Richard Sandiford > Sent: 30 October 2026 08:30 > To: Tamar Christina > Cc: gcc-patches@gcc.gnu.org; nd ; rguenther@suse.de; > Richard Earnshaw ; > jeffrey.law@oss.qualcomm.com > Subject: Re: [patch v3][gcc 1/5]middle-end: support multi-character output > operand modifiers [PR122716] > > > Today output operand modifiers are limited to a single character, as in %w0 > or > > %c1. That works, but it makes the modifier namespace very small and > encourages > > target ports either to use cryptic letters or to fall back to C output blocks > > for cases that are really just target-specific printing. > > > > This patch adds a longer spelling for the same mechanism: > > > > %[name:0] > > > > The bracketed spelling is intentionally familiar rather than completely new: > > extended asm already uses %[Value] to refer to an operand with a symbolic > name, > > as in: > > > > asm ("add %[out], %[in], %[imm]" > > : [out] "=r" (out) > > : [in] "r" (in), [imm] "I" (1)); > > > > That existing form keeps its meaning. A bare %[Value] is still resolved by the > > front end as a symbolic operand reference. The new print-operand form > puts the > > modifier name before a colon and the operand number inside the brackets, > as in > > %[name:0]. The form %[0] also lets a template separate an operand number > from > > any literal digits that follow. > > > > The modifier syntax can also be combined with symbolic operand names. In > user > > asm, %[modifier:Value] means "print operand Value using the multi- > character > > modifier named modifier". The front end resolves Value to an operand > number, so > > final output sees the same thing it would have seen for %[modifier:N]. For > > example: > > > > asm ("mov %[w:out], %[w:in]" > > : [out] "=r" (out) > > : [in] "r" (in)); > > > > is resolved as if the template had used %[w:0] and %[w:1]. > > > > GCC parses the bracketed modifier name and asks the new > > TARGET_PRINT_OPERAND_MODIFIER hook for the integer code to pass to > > PRINT_OPERAND. The target owns the names and codes, which must be > outside the > > single-character range. Old-style modifiers keep their existing values, so > > existing target hooks continue to see 'w', 'c', etc. for those forms. > > > > For example, a machine description can now write something like: > > > > "extract\t%[lowpart:0], %1" > > > > and the target's PRINT_OPERAND hook can handle "lowpart" as a named > modifier. > > The parser also allows comma-separated nonempty components in the > brackets, but > > deliberately leaves the interpretation of those components to the target. > > > > A named modifier can also take several operands, as in %[name:0,1]. > > PRINT_OPERAND receives the first operand as usual, and can use > > output_operand_modifier_operand (code, i) to get the others. All operands > in > > the list are recorded as referenced, including those that the target prints > > through this helper. This requires the use of a temporary global variable. > > current_modifier_opnums which is my least favorite part of this but I don't > > see another way around it... > > > > The new hook also receives a flag saying whether the modifier came from > user asm > > or an internal machine-description output template. Targets can reject > > internal-only names in user-facing asm while still using the clearer names > > internally. The front end checks named modifiers too, so invalid user asm is > > rejected even if it would later be optimized away. > > > > This addresses Richard Earnshaw's suggestion by keeping the target hook > > interface as an int code and mapping the longer spelling onto values outside > the > > single-character range. The default hook rejects named modifiers, so targets > > that do not opt in keep the existing syntax. Existing hard-coded character > uses > > continue to work. > > > > It also addresses Richard Sandiford's feedback by giving the new %[...] syntax > > its own namespace rather than automatically exposing every single-letter > > modifier through the new spelling. The user-asm flag lets a target decide > which > > named modifiers are public and which are only for compiler-generated > templates. > > The comma-separated spelling is accepted as a target-defined modifier > string, so > > a port can later treat, say, %[gpr,zero:0] as a composition of target-specific > > printing choices without requiring more middle-end syntax. > > > > I also used a little bit of C++ to clean up the parsing code, the diff shows > > a lot of movements but the final code is simpler. > > > > I decided to support the multiple operands case now, as that allowed me to > clean > > up the CONST_INT cases and while doing so fixing the existing ambiguity > with > > %[foo]0 being able to resolve to %10. > > > > Bootstrapped Regtested on aarch64-none-linux-gnu, > > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > > -m32, -m64 and no issues. > > > > OK for master? > > > > Thanks, > > Tamar > > > > gcc/ChangeLog: > > > > PR target/122716 > > * doc/extend.texi: Document named asm operand modifiers. > > * doc/md.texi: Document bracketed operands and operand lists. > > * doc/tm.texi: Regenerate. > > * doc/tm.texi.in (PRINT_OPERAND): Document named modifier codes > and > > output_operand_modifier_operand. > > (TARGET_PRINT_OPERAND_MODIFIER): Add hook reference. > > * final.cc: Include selftest.h. > > (current_modifier_operands, current_modifier_opnums): New > variables. > > (output_operand_modifier_operand, output_bracketed_operand): New > > functions. > > (output_asm_insn): Handle bracketed operands. > > (selftest::test_parse_bracketed_operand): New test. > > (selftest::test_referenced_operands): Likewise. > > (selftest::test_output_operand_modifier_operand): Likewise. > > (selftest::final_cc_tests): Run them. > > * output.h (PRINT_OPERAND_MODIFIER_BASE): New constant. > > (output_operand_modifier_operand): Declare. > > * recog.cc (parse_bracketed_operand): New function. > > (get_referenced_operands): Handle bracketed operands and operand > lists. > > Handle %ccN and a trailing percent sign. > > * recog.h (bracketed_operand): New structure. > > (parse_bracketed_operand): Declare. > > * selftest-run-tests.cc (selftest::run_tests): Call final_cc_tests and > > stmt_cc_tests. > > * selftest.h (final_cc_tests, stmt_cc_tests): Declare. > > * stmt.cc: Include selftest.h when checking is enabled. > > (resolve_operand_name_1): Remove. > > (asm_operand_name_number, asm_obstack_grow_opnum): New > functions. > > (resolve_asm_operand_names): Resolve bracketed operand lists and > check > > named modifiers. Share bracket parsing and build strings from obstack > > lengths. > > (selftest::build_asm_operand, selftest::build_asm_label): New helpers. > > (selftest::test_asm_operand_modifier): Likewise. > > (selftest::test_resolve_asm_operand_names): New test. > > (selftest::stmt_cc_tests): Run it. > > * target.def (print_operand_modifier): New hook. > > * targhooks.cc (default_print_operand_modifier): New function. > > * targhooks.h (default_print_operand_modifier): Declare. > > This is looking really nice, thanks. I suppose my main question is: > given the multi-operand syntax, should the number of operands be passed > to the print_operand_modifier hook too, as part of the error checking? > We could allocate numbers below the base for specific errors (unrecognised > modifier, incorrect number of operands, etc.). > Thanks for the reviews! Yeah, that's a good shout, would allow the target to add some extra error handling. > Even if that sounds worthwhile, it could be a follow-on patch. > Thanks! Will do! > Some comments below. > > > [...] > > diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi > > index > 648c12f6e7b9a7e785857dc6e4e831071bd5165b..11b3f116da51c53f65ae > 2637763f56d01cf0800d 100644 > > --- a/gcc/doc/md.texi > > +++ b/gcc/doc/md.texi > > @@ -524,6 +524,46 @@ alternate fashion. Four letters have standard, > built-in meanings described > > below. The machine description macro @code{PRINT_OPERAND} can > define > > additional letters with nonstandard meanings. > > > > +@samp{%[@var{n}]} is another way of writing operand @var{n}. The > brackets > > +separate the operand number from any literal digits that follow it. > > + > > +@samp{%[@var{name}:@var{n}]} is the same idea as > > +@samp{%@var{letter}@var{n}}, but with a multi-character target-specific > > +modifier named @var{name}. GCC parses the bracketed name and passes > it to > > +@code{PRINT_OPERAND} as an opaque integer code supplied by the > target's > > +@code{TARGET_PRINT_OPERAND_MODIFIER} hook. This form is > > +useful when a single-letter modifier would be too cryptic, or when a target > > +has used most of its single-letter namespace. The modifier name can > include > > +text substituted by the machine description reader, such as mode > attributes. > > +It can also contain comma-separated nonempty components; GCC records > the > > +full text before the colon and leaves any further interpretation to the > > +target. > > + > > +The operand part can list more than one operand, as in > > +@samp{%[@var{name}:@var{n},@var{m}]}. @code{PRINT_OPERAND} > receives > > +@var{n}; the target can use @code{output_operand_modifier_operand} to > > +access either operand. Operands in a list must be numbered. > > + > > +In user @code{asm} statements, the same modifier can be used with a > symbolic > > +operand name by writing > @samp{%[@var{name}:@var{asmSymbolicName}]}. The > > +front end resolves the symbolic name to an operand number before final > > +output. The bracketed form @samp{%[@var{name}]} continues to name > an > > +@code{asm} operand if @var{name} is an operand name, even if the > closing > > +bracket is followed by a digit. > > I'm not sure that it's necessary to repeat the information in the last > paragraph, since the text is part of the internals manual, but keeping > it is ok with me too. Just a suggestion. Happy to drop it. > > > ]...] > > +/* Output OPERAND, which was parsed from a %[...] reference. */ > > + > > +static void > > +output_bracketed_operand (bracketed_operand &operand, rtx *operands, > > + int *oporder, char *opoutput, int &ops) > > +{ > > + if (this_is_asm_operands) > > + for (unsigned long opnum : operand.opnums) > > + if (opnum >= insn_noperands) > > + { > > + output_operand_lossage ("operand number out of range"); > > + return; > > + } > > + unsigned long opnum = operand.opnums[0]; > > + if (!operand.modifier.empty ()) > > + { > > + char *name = XALLOCAVEC (char, operand.modifier.size () + 1); > > + memcpy (name, operand.modifier.begin (), operand.modifier.size ()); > > + name[operand.modifier.size ()] = 0; > > + int code = targetm.asm_out.print_operand_modifier (name, > > + this_is_asm_operands != NULL); > > I think instead we should make print_operand_modifier take an array_slice > rather than a null-terminated string. That should mean that we only need > an allocation for diagnostics. > > It also means that the hooks can use == to check for specific strings. > > Maybe you tried that and something about the header layout made it > difficult, but I wasn't sure from the covering note. Nah, the first version I had used array_slice and I backed it out since that changed the hook to also take an array_slice, and I thought people might object to using a C++ abstraction here. But it was definitely cleaner.. So I'll put it back :) > > > [...] > > diff --git a/gcc/target.def b/gcc/target.def > > index > 4c4f91827b2cb2f4dd113989eda36432b8228093..5c09552cc34bc605b95b > 06a119cd8f02123b2660 100644 > > --- a/gcc/target.def > > +++ b/gcc/target.def > > @@ -895,6 +895,16 @@ DEFHOOK_UNDOC > > void, (FILE *file, rtx x, int code), > > default_print_operand) > > > > +/* Validate a multi-character operand modifier and return its target code. > */ > > +DEFHOOK > > +(print_operand_modifier, > > + "Return the code to pass to @code{TARGET_PRINT_OPERAND} for the > named\n\ > > +modifier @var{name}. @var{user_p} is true for a modifier in user\n\ > > s/modifier in/modifier in a/ > > Ok with those changes (not including the suggesting about passing the > number of operands to the hook). Thank you! Tamar > > Richard > > > +@code{asm}. Return zero if the modifier is unavailable in that context.\n\ > > +Valid codes must be at least @code{PRINT_OPERAND_MODIFIER_BASE}.", > > + int, (const char *name, bool user_p), > > + default_print_operand_modifier) > > + > > /* Emit a machine-specific memory address. */ > > /* ??? tm.texi only documents the old macro PRINT_OPERAND_ADDRESS, > > not this hook, and uses different argument names. */ > > [...] From Tamar.Christina@arm.com Mon Nov 2 08:46:50 2026 From: Tamar.Christina@arm.com (Tamar Christina) Date: Mon, 2 Nov 2026 08:46:50 +0000 Subject: [PATCH 2/2] sched: Return delta when the pressure is below the peak pressure In-Reply-To: References: Message-ID: > -----Original Message----- > From: xiezhiheng > Sent: 30 October 2026 03:48 > To: Tamar Christina ; gcc-patches@gcc.gnu.org > Cc: Kyrylo Tkachov ; jeffreyalaw@gmail.com > Subject: RE: [PATCH 2/2] sched: Return delta when the pressure is below the > peak pressure > > > -----Original Message----- > > From: Tamar Christina > > Sent: Thursday, October 29, 2026 10:09 PM > > To: xiezhiheng ; gcc-patches@gcc.gnu.org > > Cc: Kyrylo Tkachov ; jeffreyalaw@gmail.com > > Subject: RE: [PATCH 2/2] sched: Return delta when the pressure is below the > peak pressure > > > > > -----Original Message----- > > > From: xiezhiheng > > > Sent: 29 October 2026 03:40 > > > To: gcc-patches@gcc.gnu.org > > > Cc: Kyrylo Tkachov ; Tamar Christina > > > ; jeffreyalaw@gmail.com > > > Subject: [PATCH 2/2] sched: Return delta when the pressure is below the > peak > > > pressure > > > > > > After applying the hip12 scheduling model, 507.cactuBSSN_r shows a > ~12% > > > performance regression. The reason is the same as the issue described in > > > PR/114729, but that patch cannot fix this problem. > > > > > > I have enhanced this as follows: in model_excess_group_cost, originally > > > the pressure increase was returned only when the pressure exceeded the > > > peak pressure; now the delta is also returned when the pressure is below > > > the peak pressure, in order to reduce spills. The change is controlled by > > > the --param=cycle-accurate-model= option. > > > > > > As discussed in PR/114729, the "model" heuristic currently used by default > > > on AArch64 is pretty old. However, the cortex-a57 scheduling model used > > > by many AArch64 cores is also fairly old, so perhaps the default behavior > > > of the scheduling algorithm is well matched to cortex-a57. Therefore, > > > I only enable cycle-accurate-model=0 by default for the more modern > hip12 > > > scheduling model. > > > > > > On hip12, the actually executed instructions are as follows, (-O3 - > > > mcpu=native) > > > > > > Original: 1,207,015,685,661 instructions:u > > > Apply hip12 scheduling model: 1,522,907,774,690 instructions:u > > > Apply this patch: 1,278,756,677,944 instructions:u > > > > > > gcc/ChangeLog: > > > > > > * config/aarch64/aarch64.cc (aarch64_override_options_internal): > > > Set cycle-accurate-model to 0 for hip12. > > > * haifa-sched.cc (model_excess_group_cost): Return delta if > > > param_cycle_accurate_model is 0. > > > > > > Signed-off-by: Zhiheng Xie > > > --- > > > gcc/config/aarch64/aarch64.cc | 5 +++++ > > > gcc/haifa-sched.cc | 4 ++++ > > > 2 files changed, 9 insertions(+) > > > > > > diff --git a/gcc/config/aarch64/aarch64.cc > b/gcc/config/aarch64/aarch64.cc > > > index 9290677655a..561516a3c79 100644 > > > --- a/gcc/config/aarch64/aarch64.cc > > > +++ b/gcc/config/aarch64/aarch64.cc > > > @@ -20323,6 +20323,11 @@ aarch64_override_options_internal (struct > > > gcc_options *opts, > > > param_sched_pressure_algorithm, > > > SCHED_PRESSURE_MODEL); > > > > > > + if (tune->tune == &hip12_tunings) > > > + SET_OPTION_IF_UNSET (opts, opts_set, > > > + param_cycle_accurate_model, > > > + 0); > > > > Please make this a tune parameter and add it to the cost model instead. > > See aarch64-tuning-flags.def > > > > This would also better allow us to experiment in the other cost models. > > > > Here is the patch v2. Bootstrapped and tested on aarch64-linux-gnu. > > > After applying the hip12 scheduling model, 507.cactuBSSN_r shows a ~12% > performance regression. The reason is the same as the issue described in > PR/114729, but that patch cannot fix this problem. > > I have enhanced this as follows: in model_excess_group_cost, originally > the pressure increase was returned only when the pressure exceeded the > peak pressure; now the delta is also returned when the pressure is below > the peak pressure, in order to reduce spills. The change is controlled by > the --param=cycle-accurate-model= option. > > As discussed in PR/114729, the "model" heuristic currently used by default > on AArch64 is pretty old. However, the cortex-a57 scheduling model used > by many AArch64 cores is also fairly old, so perhaps the default behavior > of the scheduling algorithm is well matched to cortex-a57. Therefore, > I add an additional DISABLE_CYCLE_ACCURATE_MODEL tune parameter to > control > the behavior. > > On hip12, the actually executed instructions on 507.cactuBSSN_r are > as follows, (w/ option -O3 -mcpu=native) > > Original: 1,207,015,685,661 instructions:u > Apply hip12 scheduling model: 1,522,907,774,690 instructions:u > Apply this patch: 1,278,756,677,944 instructions:u > > gcc/ChangeLog: > > * config/aarch64/aarch64-tuning-flags.def > (AARCH64_EXTRA_TUNING_OPTION): > Add DISABLE_CYCLE_ACCURATE_MODEL tune parameter. > * config/aarch64/aarch64.cc (aarch64_override_options_internal): > Set param_cycle_accurate_model to 0. > * config/aarch64/tuning_models/hip12.h: Set tune parameter > DISABLE_CYCLE_ACCURATE_MODEL. > * haifa-sched.cc (model_excess_group_cost): Return delta if > param_cycle_accurate_model is 0. > > Signed-off-by: Zhiheng Xie > --- > gcc/config/aarch64/aarch64-tuning-flags.def | 3 +++ > gcc/config/aarch64/aarch64.cc | 6 ++++++ > gcc/config/aarch64/tuning_models/hip12.h | 3 ++- > gcc/haifa-sched.cc | 4 ++++ > 4 files changed, 15 insertions(+), 1 deletion(-) > > diff --git a/gcc/config/aarch64/aarch64-tuning-flags.def > b/gcc/config/aarch64/aarch64-tuning-flags.def > index 64a773be34c..f756cae4edd 100644 > --- a/gcc/config/aarch64/aarch64-tuning-flags.def > +++ b/gcc/config/aarch64/aarch64-tuning-flags.def > @@ -84,4 +84,7 @@ AARCH64_EXTRA_TUNING_OPTION > ("narrow_gp_writes", NARROW_GP_WRITES) > /* Enable when the target prefers SVE merging movimm over zeroing. */ > AARCH64_EXTRA_TUNING_OPTION ("avoid_zeroing_movimm", > AVOID_MOVIMM_Z) > > +/* Set param_cycle_accurate_model to 0 for the target. */ > +AARCH64_EXTRA_TUNING_OPTION ("disable-cycle-accurate-model", > DISABLE_CYCLE_ACCURATE_MODEL) > + Minor nit, can you make this DISABLE_CYCLE_ACCURATE_SCHED_MODEL? So it's not confused with the latency modelling in the vectorizer. Patch is OK with that change. But I can't approve the middle-end bit. Once middle-end maintainer does I can apply the updated patch for you. Thanks, Tamar > #undef AARCH64_EXTRA_TUNING_OPTION > diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc > index 9290677655a..b9f5df82f45 100644 > --- a/gcc/config/aarch64/aarch64.cc > +++ b/gcc/config/aarch64/aarch64.cc > @@ -20323,6 +20323,12 @@ aarch64_override_options_internal (struct > gcc_options *opts, > param_sched_pressure_algorithm, > SCHED_PRESSURE_MODEL); > > + if (aarch64_tune_params.extra_tuning_flags > + & AARCH64_EXTRA_TUNE_DISABLE_CYCLE_ACCURATE_MODEL) > + SET_OPTION_IF_UNSET (opts, opts_set, > + param_cycle_accurate_model, > + 0); > + > /* Validate the guard size. */ > int guard_size = param_stack_clash_protection_guard_size; > > diff --git a/gcc/config/aarch64/tuning_models/hip12.h > b/gcc/config/aarch64/tuning_models/hip12.h > index cfb204b2e53..39b5462926e 100644 > --- a/gcc/config/aarch64/tuning_models/hip12.h > +++ b/gcc/config/aarch64/tuning_models/hip12.h > @@ -217,7 +217,8 @@ static const struct tune_params hip12_tunings = > 0, /* max_case_values. */ > tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ > (AARCH64_EXTRA_TUNE_BASE > - | AARCH64_EXTRA_TUNE_MATCHED_VECTOR_THROUGHPUT), /* > tune_flags. */ > + | AARCH64_EXTRA_TUNE_MATCHED_VECTOR_THROUGHPUT > + | AARCH64_EXTRA_TUNE_DISABLE_CYCLE_ACCURATE_MODEL), /* > tune_flags. */ > &generic_armv8_a_prefetch_tune, > AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ > AARCH64_LDP_STP_POLICY_ALWAYS, /* stp_policy_model. */ > diff --git a/gcc/haifa-sched.cc b/gcc/haifa-sched.cc > index e0505e9db64..51b47764d25 100644 > --- a/gcc/haifa-sched.cc > +++ b/gcc/haifa-sched.cc > @@ -2428,6 +2428,10 @@ model_excess_group_cost (struct > model_pressure_group *group, > if (pressure > group->limits[pci].pressure) > return model_spill_cost (cl, group->limits[pci].orig_pressure, > pressure); > + /* If target prefers fewer spills, return the +ve delta indicating > + pressure increase. */ > + else if (!param_cycle_accurate_model) > + return delta; > } > > return 0; > -- > 2.43.0 > > > > Thanks, > > Tamar > > > > > + > > > /* Validate the guard size. */ > > > int guard_size = param_stack_clash_protection_guard_size; > > > > > > diff --git a/gcc/haifa-sched.cc b/gcc/haifa-sched.cc > > > index e0505e9db64..51b47764d25 100644 > > > --- a/gcc/haifa-sched.cc > > > +++ b/gcc/haifa-sched.cc > > > @@ -2428,6 +2428,10 @@ model_excess_group_cost (struct > > > model_pressure_group *group, > > > if (pressure > group->limits[pci].pressure) > > > return model_spill_cost (cl, group->limits[pci].orig_pressure, > > > pressure); > > > + /* If target prefers fewer spills, return the +ve delta indicating > > > + pressure increase. */ > > > + else if (!param_cycle_accurate_model) > > > + return delta; > > > } > > > > > > return 0; > > > -- > > > 2.43.0 > > From rguenther@suse.de Mon Nov 2 08:48:42 2026 From: rguenther@suse.de (Richard Biener) Date: Mon, 2 Nov 2026 09:48:42 +0100 (CET) Subject: [PATCH] tree-optimization/128133 - wrong vectorized _BitInt load In-Reply-To: <3d2c3616-678d-455e-a6eb-70ec5d721205@foss.st.com> References: <3d2c3616-678d-455e-a6eb-70ec5d721205@foss.st.com> Message-ID: On Sun, 1 Nov 2026, Torbjorn SVENSSON wrote: > Hi Richard, > > The new test case fails for > thumb/arch=armv7ve+simd/cpu=cortex-a7/float-abi=hard/fpu=auto (arm-none-eabi). > > Testing vect/vect-pr128133.c > doing compile > Executing on host: /build/r17-5743-ge33129b871c302/bin/arm-none-eabi-gcc > /build/gcc_src/gcc/testsuite/gcc.dg/vect/vect-pr128133.c -mthumb > -march=armv7ve+simd -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=auto -dumpbase "" > -fdiagnostics-plain-output -ffast-math -ftree-vectorize > -fno-tree-loop-distribute-patterns -fno-vect-cost-model -fno-common -O2 > -fdump-tree-vect-details --specs=rdimon.specs -Wl,--start-group -lc -lm > -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition > -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main > -Wl,-wrap,abort -Wl,gcc_tg.o -lm -T qemu.ld -o ./vect-pr128133.exe (timeout > = 800) > spawn -ignore SIGHUP /build/r17-5743-ge33129b871c302/bin/arm-none-eabi-gcc > /build/gcc_src/gcc/testsuite/gcc.dg/vect/vect-pr128133.c -mthumb > -march=armv7ve+simd -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=auto -dumpbase > -fdiagnostics-plain-output -ffast-math -ftree-vectorize > -fno-tree-loop-distribute-patterns -fno-vect-cost-model -fno-common -O2 > -fdump-tree-vect-details --specs=rdimon.specs -Wl,--start-group -lc -lm > -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition > -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main > -Wl,-wrap,abort -Wl,gcc_tg.o -lm -T qemu.ld -o ./vect-pr128133.exe > pid is 2769237 -2769237 > pid is -1 > output is status 0 > PASS: gcc.dg/vect/vect-pr128133.c (test for excess errors) > spawning command qemu-system-arm -nographic -machine virt -cpu cortex-a7 -m > 256 -semihosting -monitor /dev/null -kernel ./vect-pr128133.exe > spawn qemu-system-arm -nographic -machine virt -cpu cortex-a7 -m 256 > -semihosting -monitor /dev/null -kernel ./vect-pr128133.exe > > *** EXIT code 4242 > > *** EXIT code 1 > pid is -1 > Shell closed. > Output is > *** EXIT code 4242 > > *** EXIT code 1 > > FAIL: gcc.dg/vect/vect-pr128133.c execution test > > > Running gdb shows the following after the convert() call: > > (gdb) print src > {131071, 131071, 131071, 131071} > > (gdb) print dst > {4294967295, 4294967295, 4294967295, 4294967295} Hmm, I suppose depending on the _BitInt ABI the testcase puts an invalid _BitInt(17) representation into src[] and thus the result in dst[] is not as expected. I do not exactly know how to test this in the testsuite, nor do I know whether or what goes wrong on arm. I suggest to file a new bugreport. Richard. > > Kind regards, > Torbj?rn > > On 2026-10-26 13:01, Richard Biener wrote: > > The following plugs the only halfway supported vectorization of > > _BitInt at the load side where we currently fail to handle padding > > bits correctly. > > > > Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. > > > > PR tree-optimization/128133 > > * tree-vect-stmts.cc (vectorizable_load): Reject _BitInt > > loads of non-mode precision. > > > > * gcc.dg/vect/vect-pr128133.c: New testcase. > > --- > > gcc/testsuite/gcc.dg/vect/vect-pr128133.c | 24 +++++++++++++++++++++++ > > gcc/tree-vect-stmts.cc | 9 +++++++++ > > 2 files changed, 33 insertions(+) > > create mode 100644 gcc/testsuite/gcc.dg/vect/vect-pr128133.c > > > > diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr128133.c > > b/gcc/testsuite/gcc.dg/vect/vect-pr128133.c > > new file mode 100644 > > index 00000000000..933592384a4 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.dg/vect/vect-pr128133.c > > @@ -0,0 +1,24 @@ > > +/* { dg-require-effective-target bitint } */ > > + > > +#include "tree-vect.h" > > + > > +__attribute__((noipa)) > > +void convert(unsigned *dst, unsigned _BitInt(17) *src) > > +{ > > + for (int i = 0; i < 4; ++i) > > + dst[i] = src[i]; > > +} > > + > > +int main() > > +{ > > + unsigned _BitInt(17) src[4]; > > + unsigned dst[4]; > > + > > + check_vect (); > > + > > + __builtin_memset(src, 0xff, sizeof src); > > + convert(dst, src); > > + if (dst[0] != 131071) > > + __builtin_abort (); > > + return 0; > > +} > > diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc > > index 09d87739cea..85ca127244e 100644 > > --- a/gcc/tree-vect-stmts.cc > > +++ b/gcc/tree-vect-stmts.cc > > @@ -9938,6 +9938,15 @@ vectorizable_load (vec_info *vinfo, > > bool type_mode_padding_p > > = TYPE_PRECISION (scalar_type) < GET_MODE_PRECISION (GET_MODE_INNER > > (mode)); > > + if (TREE_CODE (scalar_type) == BITINT_TYPE > > + && !type_has_mode_precision_p (scalar_type)) > > + { > > + if (dump_enabled_p ()) > > + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, > > + "_BitInt loads are not fully supported.\n"); > > + return false; > > + } > > + > > if (slp_node->ldst_lanes > > && memory_access_type != VMAT_LOAD_STORE_LANES) > > { > > > > base-commit: cf43f83b4195dccbd61abeb4aeabbdd22fcbe828 > > prerequisite-patch-id: e52d299db98b0892f974152cd9fa5f6859fec5b7 > > prerequisite-patch-id: 39da6ec3264bae454fa504f127cd5b80a0662f04 > > prerequisite-patch-id: 6d6c263a964425334ad8c2edd4dd89dcbff44bfe > > prerequisite-patch-id: 9a12a1706cbdff1edf8959682cd3cf9d900cd8f1 > > prerequisite-patch-id: b24057443c46d6979436cce479836178b19355de > > prerequisite-patch-id: d61bf2c4249ecd3d9da5eeda002d332ed3a8b4fd > > prerequisite-patch-id: 59cbeca60f782f48f945bc532c2235a50de6f0e5 > > prerequisite-patch-id: 8eddd3172e2007d0fc591124a56b372dfe83e683 > > prerequisite-patch-id: 862842dd3742066d039f66ffe9528bc490308c50 > > prerequisite-patch-id: e413d39d9af45f25483eaf229cf883c771444fbb > > prerequisite-patch-id: 2faef186ad1d816bb104d89638bc4cec6d863a46 > > prerequisite-patch-id: b32cceb111f4f57798e4b1d58822281e7bbaf25e > > prerequisite-patch-id: 404fd84b023dbe3994be05f26d6a86e83486d405 > > prerequisite-patch-id: 08ff1c06921c5e253d911128be3a8ebb76137d3c > > prerequisite-patch-id: 38ac1ab5d13f963f497b2985ef5aa0004c0e0550 > > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From richard.guenther@gmail.com Mon Nov 2 08:57:02 2026 From: richard.guenther@gmail.com (Richard Biener) Date: Mon, 2 Nov 2026 09:57:02 +0100 Subject: [PATCH] dwarf2out: Allow for an empty cie_cfi_vec. In-Reply-To: <20261101152819.43397-1-iain@sandoe.co.uk> References: <20261101152819.43397-1-iain@sandoe.co.uk> Message-ID: On Sun, Nov 1, 2026 at 4:29?PM Iain Sandoe wrote: > > This shows up on aarch64-darwin but can be repeated with -fno-cfi-asm on > Linux, tested on x86_64, aarch64-linux, aarch64-darwin, OK for trunk? > thanks > Iain OK. > --- 8< --- > > The RTL front end can start at a pass later than the initialisation of > the cie/cfi vector and so we must cater for it being unset. > > This fires for RTL testcases on platform which do not use cfi instructions. > > gcc/ChangeLog: > > * dwarf2out.cc (output_call_frame_info): Check for unset cie/cfi > vector before iteration. > > Signed-off-by: Iain Sandoe > --- > gcc/dwarf2out.cc | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc > index e8a6019f72e..4e8a2ddfc75 100644 > --- a/gcc/dwarf2out.cc > +++ b/gcc/dwarf2out.cc > @@ -943,8 +943,12 @@ output_call_frame_info (int for_eh) > eh_data_format_name (fde_encoding)); > } > > - FOR_EACH_VEC_ELT (*cie_cfi_vec, i, cfi) > - output_cfi (cfi, NULL, for_eh); > + /* cie_cfi_vec is created lazily by the dwarf2 frame pass. > + The RTL front end allows for starting from a pass after that so that > + this can be absent. */ > + if (cie_cfi_vec) > + FOR_EACH_VEC_ELT (*cie_cfi_vec, i, cfi) > + output_cfi (cfi, NULL, for_eh); > > /* Pad the CIE out to an address sized boundary. */ > ASM_OUTPUT_ALIGN (asm_out_file, > -- > 2.50.1 (Apple Git-155) > From chenzhongyao.hit@gmail.com Mon Nov 2 09:02:43 2026 From: chenzhongyao.hit@gmail.com (Zhongyao Chen) Date: Mon, 2 Nov 2026 17:02:43 +0800 Subject: [PATCH] RISC-V: Scale vector permute costs quadratically with LMUL In-Reply-To: References: <20261029021451.2644-1-chen.zhongyao@zte.com.cn> Message-ID: > I'd say let's go ahead with an array for gather and compress as these > are usually the exceptions from the linear rule. Perhaps make quadratic > the default and use better values (e.g. Ascalon) also for generic-ooo. that would be a permute_cost[4] for now, because we only know kind == vec_perm and can't tell it will expand to vrgahter or vslide. -- Regards, Zhongyao From rdapp.gcc@gmail.com Mon Nov 2 09:04:24 2026 From: rdapp.gcc@gmail.com (Robin Dapp) Date: Mon, 02 Nov 2026 10:04:24 +0100 Subject: [PATCH] RISC-V: Scale vector permute costs quadratically with LMUL In-Reply-To: References: <20261029021451.2644-1-chen.zhongyao@zte.com.cn> Message-ID: >> I'd say let's go ahead with an array for gather and compress as these >> are usually the exceptions from the linear rule. Perhaps make quadratic >> the default and use better values (e.g. Ascalon) also for generic-ooo. > > that would be a permute_cost[4] for now, > because we only know kind == vec_perm and can't tell it will expand to > vrgahter or vslide. Yes, I'm working on that and hope to make stage 1 still. -- Regards Robin From chenzhongyao.hit@gmail.com Mon Nov 2 09:11:05 2026 From: chenzhongyao.hit@gmail.com (Zhongyao Chen) Date: Mon, 2 Nov 2026 17:11:05 +0800 Subject: [PATCH] RISC-V: Scale vector permute costs quadratically with LMUL In-Reply-To: References: <20261029021451.2644-1-chen.zhongyao@zte.com.cn> Message-ID: On Mon, Nov 2, 2026 at 5:04?PM Robin Dapp wrote: > > >> I'd say let's go ahead with an array for gather and compress as these > >> are usually the exceptions from the linear rule. Perhaps make quadratic > >> the default and use better values (e.g. Ascalon) also for generic-ooo. > > > > that would be a permute_cost[4] for now, > > because we only know kind == vec_perm and can't tell it will expand to > > vrgahter or vslide. > > Yes, I'm working on that and hope to make stage 1 still. > not much time left HAHA. I should wait for that, then post the v2 patch. -- Regards, Zhongyao From rdapp.gcc@gmail.com Mon Nov 2 09:14:24 2026 From: rdapp.gcc@gmail.com (Robin Dapp) Date: Mon, 02 Nov 2026 10:14:24 +0100 Subject: [PATCH] RISC-V: Scale vector permute costs quadratically with LMUL In-Reply-To: References: <20261029021451.2644-1-chen.zhongyao@zte.com.cn> Message-ID: > not much time left HAHA. Yes :) > I should wait for that, then post the v2 patch. I'd suggest to go ahead with just gather now and add more cases later. We have an agreement that target cost-model fixes can still go in after stage 1 and that would fall under it IMHO. -- Regards Robin From richard.guenther@gmail.com Mon Nov 2 09:26:40 2026 From: richard.guenther@gmail.com (Richard Biener) Date: Mon, 2 Nov 2026 10:26:40 +0100 Subject: [PATCH] tree-optimization/127211 - Reset SCEV after predcom without unrolling In-Reply-To: <20261102011355.13576-1-stevebezalel215@gmail.com> References: <20261102011355.13576-1-stevebezalel215@gmail.com> Message-ID: On Mon, Nov 2, 2026 at 2:14?AM Steve Bezalel wrote: > > On Thu, Oct 30, 2026, Richard Biener wrote: > > OK. > > Thanks for the review! I don't have write access, so could you or > someone else please push this for me? The patch still applies to > current trunk. Done. > Thanks, > Steve From richard.guenther@gmail.com Mon Nov 2 09:35:46 2026 From: richard.guenther@gmail.com (Richard Biener) Date: Mon, 2 Nov 2026 10:35:46 +0100 Subject: [PATCH] match.pd: Fold masked vector multiply to widening even/odd multiply [PR124271] In-Reply-To: <20261102024810.3533124-1-hongtao.liu@intel.com> References: <20261102024810.3533124-1-hongtao.liu@intel.com> Message-ID: On Mon, Nov 2, 2026 at 3:49?AM liuhongt wrote: > > (x & lowhalf_mask) * (y & lowhalf_mask) on an integer vector only > multiplies the zero-extended low halves of each element. That is > VEC_WIDEN_MULT_EVEN_EXPR of x and y viewed as vectors of half-width > unsigned elements (VEC_WIDEN_MULT_ODD_EXPR on big-endian, where the low > halves are the odd lanes). > > On x86 this replaces the V*DImode multiply emulation (3 pmuludq plus > shifts and adds) with a single pmuludq, and replaces vpmullq when > AVX512DQ is available. > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > Ok for trunk? This is OK. Thanks, Richard. > gcc/ChangeLog: > > PR target/124271 > * match.pd ((x & lowhalf_mask) * (y & lowhalf_mask)): New > simplification to VEC_WIDEN_MULT_{EVEN,ODD}_EXPR. > > gcc/testsuite/ChangeLog: > > PR target/124271 > * gcc.dg/torture/pr124271.c: New test. > * gcc.target/i386/pr124271-1.c: New test. > * gcc.target/i386/pr124271-2.c: New test. > --- > gcc/match.pd | 39 ++++++++++++++ > gcc/testsuite/gcc.dg/torture/pr124271.c | 63 ++++++++++++++++++++++ > gcc/testsuite/gcc.target/i386/pr124271-1.c | 32 +++++++++++ > gcc/testsuite/gcc.target/i386/pr124271-2.c | 40 ++++++++++++++ > 4 files changed, 174 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/torture/pr124271.c > create mode 100644 gcc/testsuite/gcc.target/i386/pr124271-1.c > create mode 100644 gcc/testsuite/gcc.target/i386/pr124271-2.c > > diff --git a/gcc/match.pd b/gcc/match.pd > index d1eeb283bcb..f25952c6fd8 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -474,6 +474,45 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > { zeros; }) > { ones; } { zeros; }))))))))) > > +#if GIMPLE > +/* (x & lowhalf_mask) * (y & lowhalf_mask) > + -> VEC_WIDEN_MULT_EVEN (VIEW_CONVERT (x), VIEW_CONVERT (y)), or > + VEC_WIDEN_MULT_ODD on big-endian targets where the low halves are the > + odd lanes. */ > +(simplify > + (mult (bit_and @0 VECTOR_CST@2) > + (bit_and @1 @2)) > + (if (uniform_vector_p (@2) > + /* Single-element results are excluded since targets disagree > + on the mode of a vector(1) widening multiply result (V2DI -> TI > + on s390 but V2DI -> V1TI on rs6000). */ > + && known_gt (TYPE_VECTOR_SUBPARTS (type), 1U)) > + (with > + { > + auto elem = wi::to_wide (uniform_vector_p (@2)); > + unsigned int outer_prec = TYPE_PRECISION (TREE_TYPE (type)); > + unsigned int inner_prec = outer_prec / 2; > + /* The half-width lanes are zero-extended, so the multiply is > + unsigned even for a signed TYPE. */ > + tree inner_scalar = build_nonstandard_integer_type (inner_prec, 1); > + tree inner_type > + = build_vector_type (inner_scalar, TYPE_VECTOR_SUBPARTS (type) * 2); > + optab op = (BYTES_BIG_ENDIAN > + ? vec_widen_umult_odd_optab : vec_widen_umult_even_optab); > + } > + (if (elem == wi::mask (inner_prec, false, outer_prec) > + /* Without a mode of exactly INNER_PREC bits (e.g. for QImode > + elements) the half-width vector would be wider than TYPE. */ > + && type_has_mode_precision_p (inner_scalar) > + && GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_VECTOR_INT > + && optab_handler (op, TYPE_MODE (inner_type)) != CODE_FOR_nothing) > + (if (BYTES_BIG_ENDIAN) > + (vec_widen_mult_odd (view_convert:inner_type @0) > + (view_convert:inner_type @1)) > + (vec_widen_mult_even (view_convert:inner_type @0) > + (view_convert:inner_type @1))))))) > +#endif > + > (for cmp (gt ge lt le) > outp (convert convert negate negate) > outn (negate negate convert convert) > diff --git a/gcc/testsuite/gcc.dg/torture/pr124271.c b/gcc/testsuite/gcc.dg/torture/pr124271.c > new file mode 100644 > index 00000000000..911a50f71ed > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/torture/pr124271.c > @@ -0,0 +1,63 @@ > +/* PR target/124271 */ > +/* { dg-do run } */ > + > +typedef unsigned long long v2du __attribute__ ((vector_size (16))); > +typedef unsigned long long v4du __attribute__ ((vector_size (32))); > +typedef long long v2di __attribute__ ((vector_size (16))); > +typedef unsigned int v4su __attribute__ ((vector_size (16))); > +typedef unsigned short v8hu __attribute__ ((vector_size (16))); > +typedef unsigned char v8qu __attribute__ ((vector_size (8))); > + > +#define TEST(NAME, VT, ET, UT, M) \ > + __attribute__ ((noipa)) void \ > + NAME (VT *r, VT *a, VT *b) \ > + { \ > + *r = (*a & (ET) M) * (*b & (ET) M); \ > + } \ > + \ > + void \ > + check_##NAME (void) \ > + { \ > + VT a, b, r; \ > + for (unsigned i = 0; i < sizeof (VT) / sizeof (ET); i++) \ > + { \ > + a[i] = (ET) (0x9e3779b97f4a7c15ULL * (i + 1)); \ > + b[i] = (ET) (0xc2b2ae3d27d4eb4fULL * (i + 3)); \ > + /* Keep the signed product from overflowing. */ \ > + if ((ET) -1 < 0) \ > + { \ > + a[i] &= (ET) ((UT) M >> 1) | ~(ET) M; \ > + b[i] &= (ET) ((UT) M >> 1) | ~(ET) M; \ > + } \ > + } \ > + NAME (&r, &a, &b); \ > + for (unsigned i = 0; i < sizeof (VT) / sizeof (ET); i++) \ > + if ((UT) r[i] != (UT) ((UT) (a[i] & (ET) M) \ > + * (UT) (b[i] & (ET) M))) \ > + __builtin_abort (); \ > + } > + > +TEST (f1, v2du, unsigned long long, unsigned long long, 0xffffffffULL) > +TEST (f2, v4du, unsigned long long, unsigned long long, 0xffffffffULL) > +TEST (f3, v2di, long long, unsigned long long, 0xffffffffULL) > +TEST (f4, v4su, unsigned int, unsigned int, 0xffffU) > +TEST (f5, v8hu, unsigned short, unsigned short, 0xffU) > +/* Not a low-half mask. */ > +TEST (f6, v2du, unsigned long long, unsigned long long, 0x1ffffffffULL) > +TEST (f7, v2du, unsigned long long, unsigned long long, 0x7fffffffULL) > +/* No integer mode for the half-width element. */ > +TEST (f8, v8qu, unsigned char, unsigned char, 0xfU) > + > +int > +main () > +{ > + check_f1 (); > + check_f2 (); > + check_f3 (); > + check_f4 (); > + check_f5 (); > + check_f6 (); > + check_f7 (); > + check_f8 (); > + return 0; > +} > diff --git a/gcc/testsuite/gcc.target/i386/pr124271-1.c b/gcc/testsuite/gcc.target/i386/pr124271-1.c > new file mode 100644 > index 00000000000..00fcb561989 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/pr124271-1.c > @@ -0,0 +1,32 @@ > +/* PR target/124271 */ > +/* { dg-do compile } */ > +/* { dg-options "-O3 -mavx2 -mno-avx512f -fdump-tree-optimized" } */ > + > +typedef __UINT64_TYPE__ uint64_t; > +typedef __UINT32_TYPE__ uint32_t; > + > +static inline uint64_t > +mul32 (uint64_t a, uint64_t b) > +{ > + return (uint64_t) (uint32_t) a * (uint64_t) (uint32_t) b; > +} > + > +void > +foo (uint64_t *__restrict a, const uint64_t *__restrict b) > +{ > + for (int i = 0; i < 1024; i++) > + a[i] = mul32 (a[i], b[i]); > +} > + > +void > +bar (long long *__restrict a, const long long *__restrict b) > +{ > + for (int i = 0; i < 1024; i++) > + a[i] = (a[i] & 0xffffffff) * (b[i] & 0xffffffff); > +} > + > +/* { dg-final { scan-tree-dump-times "WIDEN_MULT_EVEN_EXPR" 2 "optimized" } } */ > +/* { dg-final { scan-assembler-times "vpmuludq\[ \\t\]+\[^\n\]*%ymm" 2 } } */ > +/* { dg-final { scan-assembler-not "vpsrlq" } } */ > +/* { dg-final { scan-assembler-not "vpsllq" } } */ > +/* { dg-final { scan-assembler-not "vpand" } } */ > diff --git a/gcc/testsuite/gcc.target/i386/pr124271-2.c b/gcc/testsuite/gcc.target/i386/pr124271-2.c > new file mode 100644 > index 00000000000..fd9ed7ac699 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/pr124271-2.c > @@ -0,0 +1,40 @@ > +/* PR target/124271 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -mavx512f -mno-avx512dq" } */ > + > +typedef unsigned long long v2du __attribute__ ((vector_size (16))); > +typedef unsigned long long v4du __attribute__ ((vector_size (32))); > +typedef unsigned long long v8du __attribute__ ((vector_size (64))); > +typedef long long v2di __attribute__ ((vector_size (16))); > + > +#define M 0xffffffffULL > + > +v2du > +f1 (v2du x, v2du y) > +{ > + return (x & M) * (y & M); > +} > + > +v4du > +f2 (v4du x, v4du y) > +{ > + return (x & M) * (y & M); > +} > + > +v8du > +f3 (v8du x, v8du y) > +{ > + return (x & M) * (y & M); > +} > + > +v2di > +f4 (v2di x, v2di y) > +{ > + return (x & (long long) M) * (y & (long long) M); > +} > + > +/* { dg-final { scan-assembler-times "vpmuludq\[ \\t\]+\[^\n\]*%xmm" 2 } } */ > +/* { dg-final { scan-assembler-times "vpmuludq\[ \\t\]+\[^\n\]*%ymm" 1 } } */ > +/* { dg-final { scan-assembler-times "vpmuludq\[ \\t\]+\[^\n\]*%zmm" 1 } } */ > +/* { dg-final { scan-assembler-not "vpsrlq" } } */ > +/* { dg-final { scan-assembler-not "vpsllq" } } */ > -- > 2.34.1 > From ro@CeBiTec.Uni-Bielefeld.DE Mon Nov 2 09:38:04 2026 From: ro@CeBiTec.Uni-Bielefeld.DE (Rainer Orth) Date: Mon, 02 Nov 2026 10:38:04 +0100 Subject: [pushed: r17-5669] analyzer: add analyzer-graphs=yes|no option to SARIF output In-Reply-To: <5b109a8298ec57c47a18752ce5942b7a99d5a81a.camel@redhat.com> (David Malcolm's message of "Fri, 30 Oct 2026 13:45:41 -0400") References: <20261028150205.3705520-1-dmalcolm@redhat.com> <5b109a8298ec57c47a18752ce5942b7a99d5a81a.camel@redhat.com> Message-ID: Hi David, > On Thu, 2026-10-29 at 09:43 +0100, Andreas Schwab wrote: >> g++ -std=c++14 -c?? -g -O2 -DIN_GCC??? -fno-exceptions -fno-rtti - >> fasynchronous-unwind-tables -W -Wall -Wno-error=narrowing -Wwrite- >> strings -Wcast-qual -Wno-format -Wmissing-format-attribute - >> Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long- >> long -Wno-variadic-macros -Wno-overlength-strings? -DHAVE_CONFIG_H? - >> DGENERATOR_FILE -I. -Ibuild -I../../gcc -I../../gcc/build - >> I../../gcc/../include? -I../../gcc/../libcpp/include? \ >> ??????? -o build/print-rtl.o ../../gcc/print-rtl.cc >> In file included from ../../gcc/print-rtl.cc:57: >> ../../gcc/json.h:226:57: error: ?std::string? has not been declared >> ? 226 |?? const json::string *set_string (const char *key, >> std::string utf8_value); >> ????? |???????????????????????????????????????????????????????? >> ^~~~~~ >> ../../gcc/json.h:25:1: note: ?std::string? is defined in header >> ??; this is probably fixable by adding ?#include ? >> ?? 24 | #include "label-text.h" >> ? +++ |+#include >> ?? 25 | >> make[3]: *** [Makefile:3297: build/print-rtl.o] Error 1 > > [adding the list this time] > > Sorry about the breakage. Does the attached patch fix things for you? worked for me to unbreak amd64-pc-openbsd8.0 bootstrap. Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University From richard.guenther@gmail.com Mon Nov 2 09:44:07 2026 From: richard.guenther@gmail.com (Richard Biener) Date: Mon, 2 Nov 2026 10:44:07 +0100 Subject: [RFC PATCH v2] match: Expose constant factors through signed widening conversions In-Reply-To: <20261102082104.3745544-1-vov.dm.an@gmail.com> References: <20261029103645.3266839-1-vov.dm.an@gmail.com> <20261102082104.3745544-1-vov.dm.an@gmail.com> Message-ID: On Mon, Nov 2, 2026 at 9:21?AM Dmitrii Vovdenko wrote: > > A signed widening conversion can hide a constant factor from the existing > multiplication reassociation and constant division rules. For example, > (long long) (a * 30) * b / 6 retains the narrow multiplication and division > instead of becoming ((long long) a * b) * 5. > > Expose the inner multiplication in a multiply/multiply or multiply/divide > chain when both types are signed integral types with undefined overflow > and the conversion does not narrow. Exclude overflow instrumentation and > use the existing single-use restrictions to avoid duplicating producers. > > For division, require a nonzero divisor that divides the inner constant. > For multiplication, require the product of the constants to fit the > destination type. > Let the existing simplifications reassociate and combine the constants. https://gcc.sashiko.dev/#/patchset/20261102082104.3745544-1-vov.dm.an%40gmail.com explains why I'd like to see the result expression simplified rather than leaving that to recursive simplification. Richard. > gcc/ChangeLog: > > * match.pd: Expose constant multiplication through signed > non-narrowing conversions in multiplication and division chains. > > gcc/testsuite/ChangeLog: > > * gcc.dg/tree-ssa/widen-mult-const-1.c: New test. > * gcc.dg/tree-ssa/widen-mult-const-2.c: Likewise. > * gcc.dg/tree-ssa/widen-mult-const-3.c: Likewise. > * gcc.dg/tree-ssa/widen-mult-const-4.c: Likewise. > * gcc.dg/tree-ssa/widen-mult-const-5.c: Likewise. > * gcc.dg/tree-ssa/widen-mult-const-6.c: Likewise. > * gcc.dg/tree-ssa/widen-mult-const-7.c: Likewise. > > Signed-off-by: Dmitrii Vovdenko > --- > Hello, > > Changes since v1: > > Added widen-mult-const-7.c using the GIMPLE frontend and explicit __EXACT_DIV operations, as suggested in review. It covers full cancellation and partial cancellation, checking the optimized statements and the remaining factor of 5. The other six tests are unchanged. > > Removed the exclusions for zero and minus one inner factors, and retained the nonzero outer constant check only for division, following the review comments. Also corrected the explanatory expression to show the conversion of C1 explicitly. > > I would appreciate feedback on the correctness conditions and approach > of this match.pd optimization before completing full validation. > > My motivation example have appeared in fixed point arithmetic library. After inlining, an > example looks like this: > > int foo (int a, int b) > { > return (static_cast(a * (1 << 16)) * b) / (1 << 16); > } > > On defined executions, it can be simplified to: > > int foo (int a, int b) > { > return static_cast(a) * b; > } > > The conversion prevents the existing patterns from exposing and > cancelling the constant factor in the original expression. The patch > below addresses this with a guarded GIMPLE pattern, as described above. > The pattern is restricted to GIMPLE because it relies on single-use > checks to avoid duplicating shared multiplications, and the motivating > code only appears after inlining. > > Seven regression tests cover complete and partial cancellation, including > explicit exact division through the GIMPLE frontend, constant > multiplication, negative and commuted operands, wrapping and trapping > arithmetic, shared intermediate values, unsigned sources, and constant > product overflow. Runtime checks exercise signed integer boundaries. > The positive compile tests disable tree reassociation to exercise the > folding patterns independently of that pass. > > This implementation is deliberately narrow. A more general approach > could construct a temporary candidate expression after exposing the > constant, simplify it using the existing machinery, and evaluate its > profitability before committing the transformation. That would add > considerable complexity, and I would appreciate advice on whether it is > warranted. > > Testing status: > > Tested on x86_64-pc-linux-gnu with a non-bootstrapped build (C and C++), > comparing against an unpatched build at the same revision. There are no > new failures in the gcc, g++, libstdc++, libatomic, libitm, and libgomp > testsuites, and the new tests pass. A full bootstrap and regression > test is pending. > > The patch is based on d5b9d3a458a58766d03445441e3952d43824c402. There > is no associated Bugzilla PR for this submission. > > Is exposing the factor through this guarded match.pd pattern an > appropriate approach? Are there additional correctness or profitability > restrictions that should be considered? > > Thank you, > Dmitrii Vovdenko > > gcc/match.pd | 24 +++++++ > .../gcc.dg/tree-ssa/widen-mult-const-1.c | 35 +++++++++ > .../gcc.dg/tree-ssa/widen-mult-const-2.c | 29 ++++++++ > .../gcc.dg/tree-ssa/widen-mult-const-3.c | 18 +++++ > .../gcc.dg/tree-ssa/widen-mult-const-4.c | 8 ++ > .../gcc.dg/tree-ssa/widen-mult-const-5.c | 35 +++++++++ > .../gcc.dg/tree-ssa/widen-mult-const-6.c | 73 +++++++++++++++++++ > .../gcc.dg/tree-ssa/widen-mult-const-7.c | 40 +++++++++++ > 8 files changed, 262 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-1.c > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-2.c > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-3.c > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-4.c > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-5.c > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-6.c > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-7.c > > diff --git a/gcc/match.pd b/gcc/match.pd > index f3d9e55f139..7b32940d1a1 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -1125,6 +1125,30 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > wi::exact_log2 (wi::to_wide (@1))); })))) > #endif > > +#if GIMPLE > +/* Simplify (T)(X * C1) * Y op C2 -> ((T)X * (T)C1) * Y op C2, where op is a > + multiplication or a division, to expose C1 to the reassociation and > + constant folding patterns. This is valid when T and the type of X are > + signed with undefined overflow and T is not narrower, since X * C1 then > + cannot overflow. Only do this when C1 and C2 can be combined. */ > +(for op (mult trunc_div exact_div) > + (simplify > + (op (mult:cs (convert:s (mult:s @0 INTEGER_CST@1)) @2) INTEGER_CST@3) > + (if (INTEGRAL_TYPE_P (type) > + && INTEGRAL_TYPE_P (TREE_TYPE (@0)) > + && TYPE_PRECISION (type) >= TYPE_PRECISION (TREE_TYPE (@0)) > + && TYPE_OVERFLOW_UNDEFINED (type) > + && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)) > + && !TYPE_OVERFLOW_SANITIZED (type) > + && !TYPE_OVERFLOW_SANITIZED (TREE_TYPE (@0)) > + && (op == MULT_EXPR > + ? wi::fits_to_tree_p (wi::to_widest (@1) * wi::to_widest (@3), type) > + : (!integer_zerop (@3) > + && wi::multiple_of_p (wi::to_widest (@1), wi::to_widest (@3), > + SIGNED)))) > + (op (mult (mult (convert @0) (convert @1)) @2) @3)))) > +#endif > + > (for div (trunc_div ceil_div floor_div round_div exact_div) > /* Simplify (t * u) / u -> t. */ > (simplify > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-1.c b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-1.c > new file mode 100644 > index 00000000000..cd24da3dc69 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-1.c > @@ -0,0 +1,35 @@ > +/* { dg-do compile } */ > +/* { dg-require-effective-target int32 } */ > +/* { dg-require-effective-target longlong64 } */ > +/* { dg-options "-O2 -fno-tree-reassoc -fdump-tree-optimized-raw" } */ > + > +__attribute__((noipa)) long long > +cancel (int a, long long b) > +{ > + return (long long) (a * 65536) * b / 65536; > +} > + > +__attribute__((noipa)) long long > +partial (int a, long long b) > +{ > + return (long long) (a * 30) * b / 6; > +} > + > +__attribute__((noipa)) long long > +negative (int a, long long b) > +{ > + return (long long) (a * -30) * b / 6; > +} > + > +__attribute__((noipa)) long long > +commuted (int a, long long b) > +{ > + return b * (long long) (-30 * a) / -30; > +} > + > +/* { dg-final { scan-tree-dump-times { +/* { dg-final { scan-tree-dump-times { +/* { dg-final { scan-tree-dump-times {gimple_return <} 4 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times {gimple_[a-z_]+} 14 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times { +/* { dg-final { scan-tree-dump-times { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-2.c b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-2.c > new file mode 100644 > index 00000000000..fd5db2d5ea8 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-2.c > @@ -0,0 +1,29 @@ > +/* { dg-do compile } */ > +/* { dg-require-effective-target int32 } */ > +/* { dg-require-effective-target longlong64 } */ > +/* { dg-options "-O2 -fno-tree-reassoc -fdump-tree-optimized-raw" } */ > + > +__attribute__((noipa)) long long > +multiply (int a, long long b) > +{ > + return (long long) (a * 30) * b * 7; > +} > + > +__attribute__((noipa)) long long > +negative (int a, long long b) > +{ > + return (long long) (a * -30) * b * 7; > +} > + > +__attribute__((noipa)) long long > +commuted (int a, long long b) > +{ > + return -7 * (b * (long long) (-30 * a)); > +} > + > +/* { dg-final { scan-tree-dump-times { +/* { dg-final { scan-tree-dump-times { +/* { dg-final { scan-tree-dump-times {gimple_return <} 3 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times {gimple_[a-z_]+} 12 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times { +/* { dg-final { scan-tree-dump-times { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-3.c b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-3.c > new file mode 100644 > index 00000000000..28df037b516 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-3.c > @@ -0,0 +1,18 @@ > +/* { dg-do compile } */ > +/* { dg-require-effective-target int32 } */ > +/* { dg-require-effective-target longlong64 } */ > +/* { dg-options "-O2 -fwrapv -fdump-tree-optimized-raw" } */ > + > +long long > +divide (int a, long long b) > +{ > + return (long long) (a * 30) * b / 6; > +} > + > +long long > +multiply (int a, long long b) > +{ > + return (long long) (a * 30) * b * 7; > +} > + > +/* { dg-final { scan-tree-dump-times { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-4.c b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-4.c > new file mode 100644 > index 00000000000..f9167e6831c > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-4.c > @@ -0,0 +1,8 @@ > +/* { dg-do compile } */ > +/* { dg-require-effective-target int32 } */ > +/* { dg-require-effective-target longlong64 } */ > +/* { dg-options "-O2 -ftrapv -fdump-tree-optimized-raw" } */ > + > +#include "widen-mult-const-3.c" > + > +/* { dg-final { scan-tree-dump-times { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-5.c b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-5.c > new file mode 100644 > index 00000000000..d2c274c547a > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-5.c > @@ -0,0 +1,35 @@ > +/* { dg-do compile } */ > +/* { dg-require-effective-target int32 } */ > +/* { dg-require-effective-target longlong64 } */ > +/* { dg-options "-O2 -fdump-tree-optimized-raw" } */ > + > +volatile long long sink; > + > +long long > +mismatch (int a, long long b) > +{ > + return (long long) (a * 30) * b / 7; > +} > + > +long long > +shared (int a, long long b) > +{ > + long long x = (long long) (a * 30); > + sink = x; > + return x * b / 6; > +} > + > +long long > +unsigned_source (unsigned int a, long long b) > +{ > + return (long long) (a * 30U) * b / 6; > +} > + > +long long > +constant_overflow (int a, long long b) > +{ > + return (long long) (a * 2) * b * 4611686018427387904LL; > +} > + > +/* { dg-final { scan-tree-dump-times { +/* { dg-final { scan-tree-dump-times { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-6.c b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-6.c > new file mode 100644 > index 00000000000..2e0de2ef62e > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-6.c > @@ -0,0 +1,73 @@ > +/* { dg-do run } */ > +/* { dg-require-effective-target int32 } */ > +/* { dg-require-effective-target longlong64 } */ > +/* { dg-options "-O2" } */ > + > +__attribute__((noipa)) long long > +cancel (int a, long long b) > +{ > + return (long long) (a * 65536) * b / 65536; > +} > + > +__attribute__((noipa)) long long > +partial (int a, long long b) > +{ > + return (long long) (a * 30) * b / 6; > +} > + > +__attribute__((noipa)) long long > +multiply (int a, long long b) > +{ > + return (long long) (a * 30) * b * 7; > +} > + > +__attribute__((noipa)) long long > +negative (int a, long long b) > +{ > + return (long long) (a * -30) * b / 6; > +} > + > +__attribute__((noipa)) long long > +constant_overflow (int a, long long b) > +{ > + return (long long) (a * 2) * b * 4611686018427387904LL; > +} > + > +__attribute__((noipa)) long long > +constant_min (int a, long long b) > +{ > + return (long long) (a * -2) * b * 4611686018427387904LL; > +} > + > +int > +main (void) > +{ > + const int inputs[] = {-32768, -32767, -1, 0, 1, 32767}; > + for (unsigned int i = 0; i < sizeof (inputs) / sizeof (inputs[0]); ++i) > + for (unsigned int j = 0; j < sizeof (inputs) / sizeof (inputs[0]); ++j) > + { > + int a = inputs[i]; > + long long b = inputs[j]; > + long long product = (long long) a * b; > + if (cancel (a, b) != product > + || partial (a, b) != product * 5 > + || multiply (a, b) != product * 210 > + || negative (a, b) != product * -5) > + __builtin_abort (); > + } > + > + long long min = -__LONG_LONG_MAX__ - 1; > + if (cancel (-32768, 4294967296LL) != min / 65536 > + || partial (1, __LONG_LONG_MAX__ / 30) > + != (__LONG_LONG_MAX__ / 30) * 5 > + || multiply (1, __LONG_LONG_MAX__ / 210) > + != (__LONG_LONG_MAX__ / 210) * 210 > + || constant_overflow (-1, 1) != min > + || constant_overflow (1, -1) != min > + || constant_overflow (1, 0) != 0 > + || constant_min (1, 1) != min > + || constant_min (-1, -1) != min) > + __builtin_abort (); > + > + return 0; > +} > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-7.c b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-7.c > new file mode 100644 > index 00000000000..0356ff4d441 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/widen-mult-const-7.c > @@ -0,0 +1,40 @@ > +/* { dg-do compile } */ > +/* { dg-require-effective-target int32 } */ > +/* { dg-require-effective-target longlong64 } */ > +/* { dg-options "-O2 -fgimple -fno-tree-reassoc -fdump-tree-optimized-raw" } */ > + > +long long __GIMPLE > +cancel_exact (int a, long long b) > +{ > + int narrow; > + long long wide; > + long long product; > + long long result; > + > + narrow = a * 65536; > + wide = (long long) narrow; > + product = wide * b; > + result = product __EXACT_DIV 65536LL; > + return result; > +} > + > +long long __GIMPLE > +partial_exact (int a, long long b) > +{ > + int narrow; > + long long wide; > + long long product; > + long long result; > + > + narrow = a * 30; > + wide = (long long) narrow; > + product = wide * b; > + result = product __EXACT_DIV 6LL; > + return result; > +} > + > +/* { dg-final { scan-tree-dump-times { +/* { dg-final { scan-tree-dump-times { +/* { dg-final { scan-tree-dump-times {gimple_return <} 2 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times {gimple_[a-z_]+} 7 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times { -- > 2.43.0 > From jeevitha@linux.ibm.com Mon Nov 2 09:58:50 2026 From: jeevitha@linux.ibm.com (jeevitha) Date: Mon, 2 Nov 2026 15:28:50 +0530 Subject: [PATCH] testsuite: Skip Wtrampolines-3.c for powerpc64 big endian target [PR125061] In-Reply-To: <052b1b24-8e22-4bd3-b882-212b7d264b39@linux.ibm.com> References: <052b1b24-8e22-4bd3-b882-212b7d264b39@linux.ibm.com> Message-ID: <99257b7d-dd42-4fce-b91a-bcb12f99e367@linux.ibm.com> Hi, Just a minor formatting nit. On 29/10/26 10:59 pm, Surya Kumari Jangala wrote: > testsuite: Skip Wtrampolines-3.c for powerpc64 big endian target [PR125061] > > The test Wtrampolines-3.c checks if trampolines are generated where > required. However, in PowerPC64 BE ABI, there is no need for trampolines > as function pointers are fat pointers. Hence, skip this test for > PowerPC64 big endian target. Note that PowerPC 64-bit in little endian > mode and PowerPC 32bit do not have fat pointers and hence trampolines > are generated. > > 2026-10-29 Surya Kumari Jangala > > gcc/testsuite/ > PR target/125061 > * gcc.dg/Wtrampolines-3.c: Skip powerpc64 big endian. > --- > gcc/testsuite/gcc.dg/Wtrampolines-3.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/gcc/testsuite/gcc.dg/Wtrampolines-3.c b/gcc/testsuite/gcc.dg/Wtrampolines-3.c > index 43d6bcefcf8..abc8f5ea4d8 100644 > --- a/gcc/testsuite/gcc.dg/Wtrampolines-3.c > +++ b/gcc/testsuite/gcc.dg/Wtrampolines-3.c > @@ -2,6 +2,7 @@ > /* { dg-require-effective-target trampolines } */ > /* { dg-options "-Wtrampolines" } */ > /* { dg-skip-if "" { *-*-darwin2* } } */ > +/* { dg-skip-if "trampolines not needed on ppc64" { powerpc64-*-* && lp64} } */ The dg-skip-if directive is missing a space before the closing brace after lp64. It should be: /* { dg-skip-if "trampolines not needed on ppc64" { powerpc64-*-* && lp64 } } */ Thanks, Jeevitha P. > > > // Test that we do generate trampolines where this is required. > -- 2.52.0 > From ktkachov@nvidia.com Mon Nov 2 10:11:25 2026 From: ktkachov@nvidia.com (Kyrylo Tkachov) Date: Mon, 2 Nov 2026 10:11:25 +0000 Subject: [PATCH v4 8/8] common: Enable -fduplicate-switch-dispatch at -O2 [PR middle-end/126236] In-Reply-To: <663434ae-9f90-4ebb-b78f-4d95271554d5@oss.qualcomm.com> References: <20261016162959.98351-1-ktkachov@nvidia.com> <20261016162959.98351-8-ktkachov@nvidia.com> <663434ae-9f90-4ebb-b78f-4d95271554d5@oss.qualcomm.com> Message-ID: <04DAC358-7CC2-4DD2-828A-DABD24A036A1@nvidia.com> Hi Jeff, > On 24 Oct 2026, at 05:47, Jeff Law wrote: > > > > On 10/16/26 10:29 AM, ktkachov@nvidia.com wrote: >> From: Kyrylo Tkachov >> >> The switch-dispatch transformation trades code size for dispatch speed. At >> -O2 on an AArch64 Olympus system it improves mawk by 5.7% and QuickJS-ng by >> 25.2%. Their text changes are 3.73% and 0.90%, respectively. At -Ofast it >> improves 714.cpython_r by 7.7% with a 0.20% text change. >> >> Enable the option at -O2 for speed builds, where the existing computed-goto >> unfactoring also runs. Keep it disabled for -Os, -Oz, and size-optimized >> functions. It applies to every target that does not refuse to share jump >> tables through TARGET_CAN_SHARE_JUMP_TABLE_P. >> >> Jeff Law approved v3 of this patch (4/7), provided that the patches it >> depends on are approved: >> https://inbox.sourceware.org/gcc-patches/6beb9fd7-5e52-49d1-988e-1ed36582d1ea@oss.qualcomm.com/ >> >> gcc/ChangeLog: >> >> PR middle-end/126236 >> * opts.cc (default_options_table): Enable >> -fduplicate-switch-dispatch at -O2 for speed builds. >> * doc/invoke.texi: Document it. List it among the options that >> -Os does not enable. >> >> gcc/testsuite/ChangeLog: >> >> PR middle-end/126236 >> * gcc.dg/switch-dispatch-5.c: New test. >> * gcc.target/aarch64/switch-dispatch-1.c: Test default enablement at >> -O2. >> >> Signed-off-by: Kyrylo Tkachov >> --- >> Changes since v3: >> - In v3, this patch changed code only on AArch64. With 3/8 and 4/8, >> the same opts.cc entry changes code on every target that does not opt >> out through TARGET_CAN_SHARE_JUMP_TABLE_P, such as x86_64 and RISC-V. >> - The patch moves from 4/7 to 8/8, after the port opt-outs (4/8), the >> verifier (6/8) and the RISC-V vsetvl fix (7/8). Without 7/8, the >> option can cause an ICE in rtl_split_edge on RISC-V vector code. >> - A new test, gcc.dg/switch-dispatch-5.c, checks the -O2 default. It >> runs on all targets. On shared_jump_tables targets, it also checks >> that the compgotos dump shows two shared tables. >> - doc/invoke.texi now lists -fduplicate-switch-dispatch among the -O2 >> options that -Os does not enable. This matches the opts.cc entry. >> - Commit message: it no longer says that targets without >> TARGET_ASM_JUMP_TABLE_BASE have unchanged code. It says that the >> option applies to every target that does not opt out. The subject now >> ends with [PR middle-end/126236]. > And still OK. > > While I'd hoped to run my tester on the series to catch any weird targets issues that were missed, we'll just picked it up post-commit. > Just returning back from vacation. I think all patches are now approved. I?ve rebased, bootstrapped and ran testing on the series on aarch64 and x86_64. Pushing now to trunk so they can get wider testing. Thank you very much for the reviews! Kyrill > jeff From ibuclaw@gdcproject.org Mon Nov 2 10:14:42 2026 From: ibuclaw@gdcproject.org (Iain Buclaw) Date: Mon, 02 Nov 2026 11:14:42 +0100 Subject: [PATCH] D: Correct vector compares for targets with mask types different from data size. In-Reply-To: <20261101172719.59602-1-iain@sandoe.co.uk> References: <20261101172719.59602-1-iain@sandoe.co.uk> Message-ID: <1793614450.3t5mh7ric7.astroid@pulse.none> Excerpts from Iain Sandoe's message of November 1, 2026 6:26 pm: > This shows, for example, on cascadelake. > Tested on x86_64-linux (cfarm151) and darwin both with cascadelake CPUs. > OK for trunk? > thanks > Iain > > --- 8< --- > > build_boolop types the VEC_COND_EXPR result with the comparison's mask type > instead of a same-width integral vector. Where the target has AVX512 mask registers > (avx512vl) that type is 32x narrower than the operands, and D's same-size rule then > rejects the reinterpretation. > > The solution is to copy the approach used in the C/C++ frontends, where a separate > return type is computed, the patch here essentially duplicates those actions. > > gcc/d/ChangeLog: > > * d-codegen.cc (build_vec_cmp): New. > (build_boolop): Where required compute a separate return type for vector > boolean ops. > > gcc/testsuite/ChangeLog: > > * gdc.dg/pr108945.d: Actully test for the absence of the floating > point constant, instead of using VEC_COND_EXPR; the latter is now > validly emitted. > > Signed-off-by: Iain Sandoe > --- > gcc/d/d-codegen.cc | 46 +++++++++++++++++++++++---------- > gcc/testsuite/gdc.dg/pr108945.d | 2 +- > 2 files changed, 34 insertions(+), 14 deletions(-) > OK. Thanks Iain! From forge-bot+ams@forge-stage.sourceware.org Mon Nov 2 10:46:13 2026 From: forge-bot+ams@forge-stage.sourceware.org (ams via Sourceware Forge) Date: Mon, 02 Nov 2026 10:46:13 +0000 Subject: [PATCH v1] combine, amdgcn: Fix ICE truncating wide vectors; allow packed accesses [PR122583] In-Reply-To: Message-ID: Patch approved and committed. -- https://forge.sourceware.org/gcc/gcc/pulls/263#issuecomment-8087 From forge-bot+ams@forge-stage.sourceware.org Mon Nov 2 10:46:28 2026 From: forge-bot+ams@forge-stage.sourceware.org (ams via Sourceware Forge) Date: Mon, 02 Nov 2026 10:46:28 +0000 (UTC) Subject: [SUMMARY] Re: [PATCH v1] combine, amdgcn: Fix ICE truncating wide vectors; allow packed accesses [PR122583] In-Reply-To: Message-ID: This is a summary of discussions relative to the merge request created by (ams) titled combine, amdgcn: Fix ICE truncating wide vectors; allow packed accesses [PR122583] since its creation. Description: The patch has been tested on both x86_64 and amdgcn with no regressions, but I didn't check that it never affects code generation. However, the intention is that it only triggers in a case where the compiler was heading for an ICE. OK for mainline? Thanks Andrew The full and up to date discussion can be found at https://forge.sourceware.org/gcc/gcc/pulls/263 The merge request has been closed without being merged directly on the forge repository. On 2026-11-02 10:46:13+00:00, (ams) wrote: Patch approved and committed. From jchrist@linux.ibm.com Mon Nov 2 11:00:30 2026 From: jchrist@linux.ibm.com (Juergen Christ) Date: Mon, 2 Nov 2026 12:00:30 +0100 Subject: [PATCH] Avoid parenthesis when printing differences involving labels. Message-ID: <20261102110029.84606-2-jchrist@linux.ibm.com> When printing differences to assembler, only SYMBOL_REF was excluded from the parenthesis branch. This lead to output like .L1-(.L2) when differences of code labels were used. Align the printing code with the printing of SYMBOL_REF, LABEL_REF, and CODE_LABEL. gcc/ChangeLog: * final.cc (output_addr_const): Adjust printing in MINUS case. Signed-off-by: Juergen Christ Bootstrapped and regtested on s390x. Okay for trunk? --- gcc/final.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/final.cc b/gcc/final.cc index ab7fba831760..2aab0674ef2a 100644 --- a/gcc/final.cc +++ b/gcc/final.cc @@ -3779,7 +3779,9 @@ output_addr_const (FILE *file, rtx x) fprintf (file, "-"); if ((CONST_INT_P (XEXP (x, 1)) && INTVAL (XEXP (x, 1)) >= 0) || GET_CODE (XEXP (x, 1)) == PC - || GET_CODE (XEXP (x, 1)) == SYMBOL_REF) + || GET_CODE (XEXP (x, 1)) == SYMBOL_REF + || GET_CODE (XEXP (x, 1)) == LABEL_REF + || GET_CODE (XEXP (x, 1)) == CODE_LABEL) output_addr_const (file, XEXP (x, 1)); else { -- 2.43.7 From ktkachov@nvidia.com Mon Nov 2 11:05:45 2026 From: ktkachov@nvidia.com (Kyrylo Tkachov) Date: Mon, 2 Nov 2026 11:05:45 +0000 Subject: [PATCH v4] phiopt: Support more than moving 1 statement for match In-Reply-To: <20261024045603.467459-1-andrew.pinski@oss.qualcomm.com> References: <20261024045603.467459-1-andrew.pinski@oss.qualcomm.com> Message-ID: <7F0379EA-B38D-4A59-815E-EC16EBC8329C@nvidia.com> > On 24 Oct 2026, at 06:56, Andrea Pinski wrote: > > This adds support to match_simplify_replacement to allowing of the > middle-bbs to have more than 1 statement in a few cases. If we are > replacing the both middle bbs with a fully independent sequence we > can handle that. If we are replacing with a sequence that depends > on the first statement of either (or both) blocks, this allows that. > If the result is defined by part or fully of one of the middle bbs. > Then make the whole bb unconditional. > > Note the middle bbs still need to have statements that can't trap nor have > side effects. And each of the statements need to feed into the next > instruction and including into the phi. And there is a limited number of > stmts is allowed. Also have an allow list of expressions type to be used > after the first few stmts. > > This allows removal of the manual matching done in > cond_removal_in_builtin_zero_pattern as those have been > moved to match patterns back in r14-362-gc53237cefbad0c > and r14-414-g078339fc04f5de. > > Changes since v1: > * v2: Add allow list to feeding_bb_info and add a limit to > the number of stmts to consider. Adds 2 testcases based on 2 pre-existing > match patterns to show what can be done. > * v3: Use walk_gimple_op instead of gimple_op walk. Add check for some > possible undefined code when becoming unconditional (shifts, rotates, > clz/ctz); add testcases for that too. Fix allow expressions detection > and calls to be better. > * v4: Fix up shift undefined behavior slightly more. > > Note Sashiko LLM analysis is not clean because the cases it is complaining > about will be rejected later on or won't show up (e.g. CLZ with a one bit > argument is folded aways or a shift for one bit will also be simplified away). > The code left behind in one of the middle bb is dead; the patch which was > posted earlier today will fix up those dead stmts; the ICE it mentions also > will never show up because simple_dce will not delete stmts that are in use > still and the phi will have been changed to reference only the ones from the > condition (and dominating bb) and the dominator is not updated until > cfgcleanup even so messes up that analysis too. > > Bootstrapped and tested on x86_64-linux-gnu. > With this version, the PR126035 testcase itself (lo ? __builtin_ctz (lo) : 32 + __builtin_ctz (hi)) is no longer combined. feeding_bb_info rejects the else arm because of had_undefined_stmt, before the match. The replacement there is an independent .CTZ (x), and the arm statements are not executed. Could the undefined-count restriction apply only when the arm statements are moved before the condition, that is when the result uses them? With that check removed, the double-word clz/ctz patterns in my series match again. Thanks, Kyrill > gcc/ChangeLog: > > * tree-ssa-phiopt.cc (gsi_next_nondebug_nonnop_non_predict): New function. > (enum bbfeeding_info): New enum. > (empty_bb_or_one_feeding_into_p): Rename to ... > (feeding_bb_info): This and support few different other cases. > (auto_flow_sensitive): Increase the vect base size to 4. > (auto_flow_sensitive::auto_flow_sensitive(gimple*)): Split out into ... > (auto_flow_sensitive::save_stmt): This. > (auto_flow_sensitive::auto_flow_sensitive(basic_block)): New constructor. > (match_simplify_replacement): Support More than one statement in > the middle BB. > * params.opt (-param=phiopt-max-feeding-stmts=): New option. > * doc/params.texi (phiopt-max-feeding-stmts): Document. > > PR tree-optimization/127166 > > gcc/testsuite/ChangeLog: > > * gcc.dg/tree-ssa/ssa-dom-thread-16.c: Disable phiopt. > * gcc.dg/tree-ssa/clamp-1.c: New test. > * gcc.dg/tree-ssa/umax-sub-1.c: New test. > * gcc.dg/tree-ssa/and-ctz-1.c: New test. > * gcc.dg/tree-ssa/and-shift-1.c: New test. > > Signed-off-by: Andrea Pinski > --- > gcc/doc/params.texi | 5 + > gcc/params.opt | 4 + > gcc/testsuite/gcc.dg/tree-ssa/and-ctz-1.c | 21 + > gcc/testsuite/gcc.dg/tree-ssa/and-shift-1.c | 14 + > gcc/testsuite/gcc.dg/tree-ssa/clamp-1.c | 25 ++ > .../gcc.dg/tree-ssa/ssa-dom-thread-16.c | 2 +- > gcc/testsuite/gcc.dg/tree-ssa/umax-sub-1.c | 14 + > gcc/tree-ssa-phiopt.cc | 421 ++++++++++++++---- > 8 files changed, 415 insertions(+), 91 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/and-ctz-1.c > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/and-shift-1.c > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/clamp-1.c > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/umax-sub-1.c > > diff --git a/gcc/doc/params.texi b/gcc/doc/params.texi > index 090af64a7e7..b26513a7ea1 100644 > --- a/gcc/doc/params.texi > +++ b/gcc/doc/params.texi > @@ -57,6 +57,11 @@ When factoring statements out of if/then/else, this is the maximum number > of statements > after the defining statement to be allowed to extend the lifetime of a name. > > +@paindex phiopt-max-feeding-stmts > +@item phiopt-max-feeding-stmts > +When deciding if a basic block is too big to phiopt, this decides the maximum > +number of statements that feed into one another is too many. This excludes converts. > + > @paindex predictable-branch-outcome > @item predictable-branch-outcome > When branch is predicted to be taken with probability lower than this threshold > diff --git a/gcc/params.opt b/gcc/params.opt > index 29a5c7018a8..f0702f97625 100644 > --- a/gcc/params.opt > +++ b/gcc/params.opt > @@ -958,6 +958,10 @@ Maximum probability of the entry BB of split region (as a percentage relative to > Common Joined UInteger Var(param_phiopt_factor_max_stmts_live) Init(5) Optimization IntegerRange(0, 100) Param > Maximum number of statements allowed between a defining statement and the end of the basic block before extending the live range is considered profitable. > > +-param=phiopt-max-feeding-stmts= > +Common Joined UInteger Var(param_phiopt_max_feeding_stmts) Init(4) Optimization IntegerRange(1, 100) Param > +Maximum number of statements can considered for each basic block excluding converts. > + > -param=predictable-branch-outcome= > Common Joined UInteger Var(param_predictable_branch_outcome) Init(2) IntegerRange(0, 50) Param Optimization > Maximal estimated outcome of branch considered predictable. > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/and-ctz-1.c b/gcc/testsuite/gcc.dg/tree-ssa/and-ctz-1.c > new file mode 100644 > index 00000000000..4408addfe3a > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/and-ctz-1.c > @@ -0,0 +1,21 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fdump-tree-phiopt2-details -fdump-tree-optimized" } */ > + > +int f(int a, int b) > +{ > + if (a == 0) > + return 0; > + return a & __builtin_ctz(b); > +} > + > +int f1(int a, int b) > +{ > + if (a == 0) > + return 0; > + return a & __builtin_clz(b); > +} > + > +/* Here we can't make the call to ctz/clz unconditional without undefined behavior. */ > + > +/* { dg-final { scan-tree-dump-not "converted to straightline code" "phiopt2" } } */ > +/* { dg-final { scan-tree-dump-times "if " 2 "optimized" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/and-shift-1.c b/gcc/testsuite/gcc.dg/tree-ssa/and-shift-1.c > new file mode 100644 > index 00000000000..f0e96e0b0d6 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/and-shift-1.c > @@ -0,0 +1,14 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fdump-tree-phiopt2-details -fdump-tree-optimized" } */ > + > +int f(int a, int b, int c) > +{ > + if (a == 0) > + return 0; > + return a & (b >> c); > +} > + > +/* Here we can't make the shift unconditional without undefined behavior. */ > + > +/* { dg-final { scan-tree-dump-not "converted to straightline code" "phiopt2" } } */ > +/* { dg-final { scan-tree-dump "if " "optimized" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/clamp-1.c b/gcc/testsuite/gcc.dg/tree-ssa/clamp-1.c > new file mode 100644 > index 00000000000..43239772ca0 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/clamp-1.c > @@ -0,0 +1,25 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fdump-tree-phiopt2-details -fdump-tree-optimized" } */ > + > +/* PR tree-optimization/127166 */ > + > +unsigned char clip(int x) > +{ > + unsigned u; > + unsigned char r; > + u = x; > + r = x; > + if (u > 255) > + { > + int n = -x; > + int s = n >> (sizeof(int)*8 - 1); > + r = s; > + } > + return r; > +} > + > + > +/* { dg-final { scan-tree-dump "converted to straightline code" "phiopt2" } } */ > +/* { dg-final { scan-tree-dump "MAX_EXPR" "phiopt2" } } */ > +/* { dg-final { scan-tree-dump "MIN_EXPR" "phiopt2" } } */ > +/* { dg-final { scan-tree-dump-not "if " "optimized" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-16.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-16.c > index e8555f2d963..51b686b1de8 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-16.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-16.c > @@ -1,5 +1,5 @@ > /* { dg-do compile } */ > -/* { dg-options "-O2 -fdump-tree-dom2-details -w --param logical-op-non-short-circuit=1 -fdisable-tree-threadfull1" } */ > +/* { dg-options "-O2 -fdump-tree-dom2-details -w --param logical-op-non-short-circuit=1 -fdisable-tree-threadfull1 -fno-ssa-phiopt" } */ > unsigned char > validate_subreg (unsigned int offset, unsigned int isize, unsigned int osize, int zz, int qq) > { > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/umax-sub-1.c b/gcc/testsuite/gcc.dg/tree-ssa/umax-sub-1.c > new file mode 100644 > index 00000000000..c07eb4154d6 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/umax-sub-1.c > @@ -0,0 +1,14 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fdump-tree-phiopt2-details -fdump-tree-optimized" } */ > + > +signed f1 (signed x) > +{ > + if (x == 0) return 0; > + unsigned y = x; > + y -= 1; > + x = y; > + return x; > +} > + > +/* { dg-final { scan-tree-dump "converted to straightline code" "phiopt2" } } */ > +/* { dg-final { scan-tree-dump-not "if " "optimized" } } */ > diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc > index 53256d1f787..08b40897a60 100644 > --- a/gcc/tree-ssa-phiopt.cc > +++ b/gcc/tree-ssa-phiopt.cc > @@ -56,6 +56,7 @@ along with GCC; see the file COPYING3. If not see > #include "gimple-predict.h" > #include "alias.h" > #include "tree-ssa-threadedge.h" > +#include "gimple-walk.h" > > /* Return the singleton PHI in the SEQ of PHIs for edges E0 and E1. */ > > @@ -832,6 +833,19 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt, > return NULL; > } > > +/* Like gsi_next_nondebug but also skips over NOPs and predicats. */ > +static void > +gsi_next_nondebug_nonnop_nonpredict (gimple_stmt_iterator *i) > +{ > + do > + { > + gsi_next_nondebug (i); > + } > + while (!gsi_end_p (*i) > + && (gimple_code (**i) == GIMPLE_PREDICT > + || gimple_code (**i) == GIMPLE_NOP)); > +} > + > /* one_feeding_comparison_into_p returns true if BB has one comparison > statement and it sets STMT to that statement. Note the comparison can > be trapping too. */ > @@ -896,110 +910,191 @@ one_feeding_comparison_into_p (basic_block bb, > return true; > } > > -/* empty_bb_or_one_feeding_into_p returns true if bb was empty basic block > - or it has one cheap preparation statement that feeds into the PHI > - statement and it sets STMT to that statement. */ > -static bool > -empty_bb_or_one_feeding_into_p (basic_block bb, > - gimple *phi, > - gimple *&stmt) > + > +enum bbfeeding_info > +{ > + invalid_bb, > + empty_bb, > + one_stmt_bb, > + feeding_bb > +}; > + > +/* This returns empty_bb if bb was empty basic block. > + or returns one_stmt_bb if it has one cheap preparation > + statement that feeds into the PHI statement and it sets > + STMT to that statement. Returns feeding_bb if the > + basic block is not empty but has a sequence of statements > + feeding into the phi that has no side effects. */ > +static bbfeeding_info > +feeding_bb_info (basic_block bb, gimple *phi, gimple *&stmt) > { > stmt = nullptr; > gimple *stmt_to_move = nullptr; > tree lhs; > > if (empty_block_p (bb)) > - return true; > + return empty_bb; > > if (!single_pred_p (bb)) > - return false; > + return invalid_bb; > > /* The middle bb cannot have phi nodes as we don't > move those assignments yet. */ > if (!gimple_seq_empty_p (phi_nodes (bb))) > - return false; > + return invalid_bb; > > gimple_stmt_iterator gsi; > > gsi = gsi_start_nondebug_after_labels_bb (bb); > + int stmts = 0; > + int stmts_minus_convert = 0; > + bool non_allowed_stmt = false; > + bool had_undefined_stmt = false; > + bool has_call = false; > while (!gsi_end_p (gsi)) > { > - gimple *s = gsi_stmt (gsi); > - gsi_next_nondebug (&gsi); > - /* Skip over Predict and nop statements. */ > + gimple *s = *gsi; > + gsi_next_nondebug_nonnop_nonpredict (&gsi); > + // Skip over predict and nop statements which could happen > + // if they are at the beginging. > if (gimple_code (s) == GIMPLE_PREDICT > || gimple_code (s) == GIMPLE_NOP) > continue; > - /* If there is more one statement return false. */ > - if (stmt_to_move) > - return false; > - stmt_to_move = s; > - } > - > - /* The only statement here was a Predict or a nop statement > - so return true. */ > - if (!stmt_to_move) > - return true; > - > - if (gimple_vuse (stmt_to_move)) > - return false; > - > - if (gimple_could_trap_p (stmt_to_move) > - || gimple_has_side_effects (stmt_to_move)) > - return false; > - > - ssa_op_iter it; > - tree use; > - FOR_EACH_SSA_TREE_OPERAND (use, stmt_to_move, it, SSA_OP_USE) > - if (ssa_name_maybe_undef_p (use)) > - return false; > - > - /* Allow assignments but allow some builtin/internal calls. > - As const calls don't match any of the above, yet they could > - still have some side-effects - they could contain > - gimple_could_trap_p statements, like floating point > - exceptions or integer division by zero. See PR70586. > - FIXME: perhaps gimple_has_side_effects or gimple_could_trap_p > - should handle this. > - Allow some known builtin/internal calls that are known not to > - trap: logical functions (e.g. bswap and bit counting). */ > - if (!is_gimple_assign (stmt_to_move)) > - { > - if (!is_gimple_call (stmt_to_move)) > - return false; > - combined_fn cfn = gimple_call_combined_fn (stmt_to_move); > - switch (cfn) > + stmts++; > + stmts_minus_convert++; > + if (stmts_minus_convert > param_phiopt_max_feeding_stmts) > + return invalid_bb; > + if (gimple_vuse (s)) > + return invalid_bb; > + if (gimple_could_trap_p (s) > + || gimple_has_side_effects (s)) > + return invalid_bb; > + ssa_op_iter it; > + tree use; > + FOR_EACH_SSA_TREE_OPERAND (use, s, it, SSA_OP_USE) > + if (ssa_name_maybe_undef_p (use)) > + return invalid_bb; > + > + /* Allow some assignments but allow some builtin/internal calls. > + As const calls don't match any of the above, yet they could > + still have some side-effects - they could contain > + gimple_could_trap_p statements, like floating point > + exceptions or integer division by zero. See PR70586. > + FIXME: perhaps gimple_has_side_effects or gimple_could_trap_p > + should handle this. > + Allow some known builtin/internal calls that are known not to > + trap: logical functions (e.g. bswap and bit counting). */ > + if (!is_gimple_assign (s)) > { > - default: > - return false; > - CASE_CFN_BSWAP: > - CASE_CFN_BITREVERSE: > - CASE_CFN_FFS: > - CASE_CFN_PARITY: > - CASE_CFN_POPCOUNT: > - CASE_CFN_CLZ: > - CASE_CFN_CTZ: > - case CFN_BUILT_IN_CLRSB: > - case CFN_BUILT_IN_CLRSBL: > - case CFN_BUILT_IN_CLRSBLL: > - lhs = gimple_call_lhs (stmt_to_move); > - break; > + if (!is_gimple_call (s)) > + return invalid_bb; > + combined_fn cfn = gimple_call_combined_fn (s); > + switch (cfn) > + { > + default: > + return invalid_bb; > + CASE_CFN_CLZ: > + CASE_CFN_CTZ: > + if (gimple_call_num_args (s) != 2) > + had_undefined_stmt = true; > + // FALLTHRU > + case CFN_BUILT_IN_CLRSB: > + case CFN_BUILT_IN_CLRSBL: > + case CFN_BUILT_IN_CLRSBLL: > + CASE_CFN_BSWAP: > + CASE_CFN_BITREVERSE: > + CASE_CFN_FFS: > + CASE_CFN_PARITY: > + CASE_CFN_POPCOUNT: > + lhs = gimple_call_lhs (s); > + // A call can after some stmts but not with a non allowed one > + // or another call. > + if (non_allowed_stmt || has_call) > + return invalid_bb; > + has_call = true; > + break; > + } > } > + else > + { > + lhs = gimple_assign_lhs (s); > + // Only allow a few different for the feeding list. > + switch (gimple_assign_rhs_code (s)) > + { > + // Always allow a convert. > + CASE_CONVERT: > + stmts_minus_convert --; > + break; > + case PLUS_EXPR: > + case MINUS_EXPR: > + case ABS_EXPR: > + case ABSU_EXPR: > + case BIT_IOR_EXPR: > + case BIT_XOR_EXPR: > + case BIT_AND_EXPR: > + case MIN_EXPR: > + case MAX_EXPR: > + case NEGATE_EXPR: > + break; > + // Shifts with a (positive) constant shifter are on the allow list. > + // Shifters which are above the precision are not well defined, so > + // that is undefined stmt. > + case LSHIFT_EXPR: > + case RSHIFT_EXPR: > + if (TREE_CODE (gimple_assign_rhs2 (s)) == INTEGER_CST > + && wi::ltu_p (wi::to_wide (gimple_assign_rhs2 (s)), > + element_precision (TREE_TYPE (lhs)))) > + break; > + // Don't allow non-const shifters as they will cause > + // undefined behavior > + had_undefined_stmt = true; > + break; > + case LROTATE_EXPR: > + case RROTATE_EXPR: > + had_undefined_stmt = true; > + // FALLTHRU > + default: > + // Allow all kind of expressions after the first > + // convert but not with other stmts before hand. > + if (stmts_minus_convert > 1 && non_allowed_stmt) > + return invalid_bb; > + if (has_call) > + return invalid_bb; > + non_allowed_stmt = true; > + break; > + } > + } > + > + gimple *use_stmt; > + use_operand_p use_p; > + > + /* Allow only a statement which feeds into the next stmt > + or the phi (when last statement). */ > + if (!lhs || TREE_CODE (lhs) != SSA_NAME > + || !single_imm_use (lhs, &use_p, &use_stmt) > + || use_stmt != (gsi_end_p (gsi) ? phi : *gsi )) > + return invalid_bb; > + if (!stmt_to_move) > + stmt_to_move = s; > } > - else > - lhs = gimple_assign_lhs (stmt_to_move); > > - gimple *use_stmt; > - use_operand_p use_p; > + // CLZ/CTZ is undefined at 0 (or a shift with a non constant) > + // so if other stmts besides converts moving it will cause > + // undefined behavior. > + if (had_undefined_stmt && stmts_minus_convert != 1) > + return invalid_bb; > > - /* Allow only a statement which feeds into the other stmt. */ > - if (!lhs || TREE_CODE (lhs) != SSA_NAME > - || !single_imm_use (lhs, &use_p, &use_stmt) > - || use_stmt != phi) > - return false; > + // If there are any questionable stmts, make sure there are only > + // that one (and possible converts). > + if (stmts_minus_convert != 1 && non_allowed_stmt) > + return invalid_bb; > > + /* The only statement here was a Predict or a nop statement > + so return 1. */ > + if (stmts == 0) > + return empty_bb; > stmt = stmt_to_move; > - return true; > + return stmts > 1 ? feeding_bb : one_stmt_bb; > } > > /* Move STMT to before GSI and insert its defining > @@ -1031,14 +1126,17 @@ move_stmt (gimple *stmt, gimple_stmt_iterator *gsi, auto_bitmap &inserted_exprs) > } > > /* RAII style class to temporarily remove flow sensitive > - from ssa names defined by a gimple statement. */ > + from ssa names defined by a gimple statement or > + a whole Basic block. */ > class auto_flow_sensitive > { > public: > auto_flow_sensitive (gimple *s); > + auto_flow_sensitive (basic_block bb); > ~auto_flow_sensitive (); > private: > - auto_vec, 2> stack; > + auto_vec, 4> stack; > + void save_stmt (gimple *s); > }; > > /* Constructor for auto_flow_sensitive. Saves > @@ -1050,6 +1148,15 @@ auto_flow_sensitive::auto_flow_sensitive (gimple *s) > { > if (!s) > return; > + save_stmt (s); > +} > + > +/* Saves off the ssa names' flow sensitive information > + that was defined by gimple statement S and > + resets it to be non-flow based ones. */ > +void > +auto_flow_sensitive::save_stmt (gimple *s) > +{ > ssa_op_iter it; > tree def; > FOR_EACH_SSA_TREE_OPERAND (def, s, it, SSA_OP_DEF) > @@ -1060,6 +1167,21 @@ auto_flow_sensitive::auto_flow_sensitive (gimple *s) > } > } > > +/* Constructor for auto_flow_sensitive. Saves > + off the ssa names' flow sensitive information > + that was defined in the BB and > + resets it to be non-flow based ones. */ > + > +auto_flow_sensitive::auto_flow_sensitive (basic_block bb) > +{ > + if (!bb) > + return; > + gimple_stmt_iterator gsi; > + gsi = gsi_start_nondebug_after_labels_bb (bb); > + for (; !gsi_end_p (gsi); gsi_next_nondebug (&gsi)) > + save_stmt (*gsi); > +} > + > /* Deconstructor, restores the flow sensitive information > for the SSA names that had been saved off. */ > > @@ -1118,14 +1240,20 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, > > /* If the basic block only has a cheap preparation statement, > allow it and move it once the transformation is done. */ > - if (!empty_bb_or_one_feeding_into_p (middle_bb, phi, stmt_to_move)) > + bbfeeding_info middle_bb_info = feeding_bb_info (middle_bb, > + phi, stmt_to_move); > + if (middle_bb_info == invalid_bb) > return false; > > + bbfeeding_info middle_bb_alt_info = invalid_bb; > if (threeway_p > - && middle_bb != middle_bb_alt > - && !empty_bb_or_one_feeding_into_p (middle_bb_alt, phi, > - stmt_to_move_alt)) > - return false; > + && middle_bb != middle_bb_alt) > + { > + middle_bb_alt_info = feeding_bb_info (middle_bb_alt, phi, > + stmt_to_move_alt); > + if (middle_bb_alt_info == invalid_bb) > + return false; > + } > > /* Do not make conditional undefs unconditional. */ > if ((TREE_CODE (arg0) == SSA_NAME > @@ -1175,12 +1303,15 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, > > tree type = TREE_TYPE (gimple_phi_result (phi)); > { > - auto_flow_sensitive s1(stmt_to_move); > - auto_flow_sensitive s_alt(stmt_to_move_alt); > + auto_flow_sensitive s1(middle_bb); > + basic_block other_bb = nullptr; > + if (middle_bb_alt_info >= one_stmt_bb) > + other_bb = middle_bb_alt; > + auto_flow_sensitive s_alt(other_bb); > > result = gimple_simplify_phiopt (early_p, type, stmt, > arg_true, arg_false, > - &seq); > + &seq); > } > > /* For early phiopt, we don't want to lose user generated predictors > @@ -1220,7 +1351,8 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, > semantics (that's not IEEE max semantics). */ > if (!HONOR_NANS (type) && !HONOR_SIGNED_ZEROS (type)) > return false; > - if (stmt_to_move || stmt_to_move_alt) > + if (middle_bb_info >= one_stmt_bb > + || middle_bb_alt_info >= one_stmt_bb) > return false; > tree_code cmp = gimple_cond_code (stmt); > if (cmp != LT_EXPR && cmp != LE_EXPR > @@ -1242,11 +1374,120 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, > statistics_counter_event (cfun, "Non-IEEE FP MIN/MAX PHI replacement", > 1); > } > - if (dump_file && (dump_flags & TDF_FOLDING)) > - fprintf (dump_file, "accepted the phiopt match-simplify.\n"); > > auto_bitmap exprs_maybe_dce; > > + /* One of the middle BBs had more than one statements. */ > + if (middle_bb_info == feeding_bb > + || middle_bb_alt_info == feeding_bb) > + { > + gimple_stmt_iterator gsi = gsi_start (seq); > + bool ok = true; > + walk_stmt_info wi = {}; > + struct op_info { > + gimple *stmt_to_move; > + gimple *stmt_to_move_alt; > + basic_block middle_bb; > + basic_block middle_bb_alt; > + bbfeeding_info middle_bb_info; > + bbfeeding_info middle_bb_alt_info; > + } info = { stmt_to_move, stmt_to_move_alt, > + middle_bb, middle_bb_alt, > + middle_bb_info, middle_bb_alt_info }; > + wi.info = &info; > + /* Check to see if any of the new sequence uses the definitions > + from the middle bbs. */ > + for (gsi = gsi_start (seq); !gsi_end_p (gsi); gsi_next (&gsi)) > + { > + tree use; > + use = walk_gimple_op (*gsi, > + [](tree *tp, int *, void *data) -> tree > + { > + walk_stmt_info *wi = (walk_stmt_info*)data; > + op_info *info = (op_info *)wi->info; > + tree use = *tp; > + if (!use || TREE_CODE (use) != SSA_NAME) > + return NULL_TREE; > + gimple *us = SSA_NAME_DEF_STMT (use); > + if (!us) > + return NULL_TREE; > + if (us == info->stmt_to_move > + || us == info->stmt_to_move_alt) > + return NULL_TREE; > + basic_block use_bb = gimple_bb (us); > + // If an operand is defined from the middle bb > + // where there was more one statement, reject it. > + if ((info->middle_bb_info == feeding_bb > + && use_bb == info->middle_bb) > + || (info->middle_bb_alt_info == feeding_bb > + && use_bb == info->middle_bb_alt)) > + return use; > + return NULL_TREE; > + }, &wi); > + if (use) > + { > + ok = false; > + break; > + } > + } > + if (!ok) > + { > + gimple_seq_discard (seq); > + if (dump_file && (dump_flags & TDF_FOLDING)) > + fprintf (dump_file, "rejected the phiopt match-simplify for having more stmts.\n"); > + return false; > + } > + statistics_counter_event (cfun, "unconditionalized one middle bb phiopt", > + 1); > + // If the result is the one of the arguments or a partial > + // defined in the middle bb, then make those statements unconditional. > + if (TREE_CODE (result) == SSA_NAME > + && (middle_bb_info == feeding_bb > + || middle_bb_alt_info == feeding_bb)) > + { > + gimple *us = SSA_NAME_DEF_STMT (result); > + if (us && ((middle_bb_info == feeding_bb > + && gimple_bb (us) == middle_bb) > + || (middle_bb_alt_info == feeding_bb > + && gimple_bb (us) == middle_bb_alt))) > + { > + gimple_stmt_iterator middle_gsi; > + basic_block use_bb = gimple_bb (us); > + middle_gsi = gsi_start_nondebug_after_labels_bb (use_bb); > + > + // Move the statements one at a time until reach the last > + // statement or the statement that is referenced from the result. > + while (!gsi_end_p (middle_gsi)) > + { > + // Skip over nop or predicates > + // Also don't move debug statements > + if (gimple_code (*middle_gsi) == GIMPLE_NOP > + || gimple_code (*middle_gsi) == GIMPLE_PREDICT) > + { > + gsi_next_nondebug_nonnop_nonpredict (&middle_gsi); > + continue; > + } > + gsi = gsi_last_bb (cond_bb); > + gimple *s = *middle_gsi; > + move_stmt (s, &gsi, exprs_maybe_dce); > + > + // Reached the last statement that is refenced, > + // all the rest would be DCEd anyways. > + if (s == us) > + break; > + middle_gsi = gsi_start_nondebug_after_labels_bb (use_bb); > + } > + stmt_to_move = nullptr; > + stmt_to_move_alt = nullptr; > + statistics_counter_event (cfun, "unconditionalized partial middle bb phiopt", > + 1); > + } > + } > + } > + > + if (dump_file && (dump_flags & TDF_FOLDING)) > + fprintf (dump_file, "accepted the phiopt match-simplify.\n"); > + > /* Mark the cond statements' lhs/rhs as maybe dce. */ > if (TREE_CODE (gimple_cond_lhs (stmt)) == SSA_NAME > && !SSA_NAME_IS_DEFAULT_DEF (gimple_cond_lhs (stmt))) > @@ -1272,7 +1513,7 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, > gsi_insert_seq_before (&gsi, seq, GSI_CONTINUE_LINKING); > } > > - /* If there was a statement to move, move it to right before > + /* If there was one statement to move, move it to right before > the original conditional. */ > move_stmt (stmt_to_move, &gsi, exprs_maybe_dce); > move_stmt (stmt_to_move_alt, &gsi, exprs_maybe_dce); > -- > 2.43.0 > From jeevitha@linux.ibm.com Mon Nov 2 11:06:59 2026 From: jeevitha@linux.ibm.com (jeevitha) Date: Mon, 2 Nov 2026 16:36:59 +0530 Subject: [PATCH] rs6000: Fix _mm_movemask intrinsics on Power10BE [PR127274] In-Reply-To: References: <37110534-9d82-419a-851a-311579d1b227@linux.ibm.com> Message-ID: <8c9b617c-d13a-439c-b115-e3e11f3efe4c@linux.ibm.com> On 28/10/26 4:49 pm, Surya Kumari Jangala wrote: > LGTM. Ok to upstream. > > -Surya Hi, This patch has been committed to trunk. Can I backport it to all open branches? Thanks, Jeevitha P. > On 28/09/26 5:43 PM, jeevitha wrote: >> Hi All, >> >> The following patch has been bootstrapped and regtested on powerpc64le-linux >> and powerpc64-linux. >> >> The Power10 implementation of the SSE movemask intrinsics uses >> vec_extractm(). On big-endian PowerPC, the vector element order >> causes vec_extractm() to produce the mask bits in a different >> order than required by the SSE movemask intrinsics. >> >> Reverse the vector element order with vec_reve() on big-endian Power10 >> before calling vec_extractm(). This ensures that _mm_movemask_pd(), >> _mm_movemask_ps(), and _mm_movemask_epi8() produce the same results on >> both big and little endian targets. >> >> 2026-09-28 Jeevitha Palanisamy >> >> gcc/ >> PR target/127274 >> * config/rs6000/emmintrin.h (_mm_movemask_pd): Reverse vector >> element order on big-endian Power10 before calling vec_extractm(). >> (_mm_movemask_epi8): Likewise. >> * config/rs6000/xmmintrin.h (_mm_movemask_ps): Likewise. >> >> diff --git a/gcc/config/rs6000/emmintrin.h b/gcc/config/rs6000/emmintrin.h >> index 4d442d2e965..551be83617d 100644 >> --- a/gcc/config/rs6000/emmintrin.h >> +++ b/gcc/config/rs6000/emmintrin.h >> @@ -1234,6 +1234,9 @@ extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artifici >> _mm_movemask_pd (__m128d __A) >> { >> #ifdef _ARCH_PWR10 >> +#ifdef __BIG_ENDIAN__ >> + __A = vec_reve (__A); >> +#endif >> return vec_extractm ((__v2du) __A); >> #else >> __vector unsigned long long __result; >> @@ -2031,6 +2034,9 @@ extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artifici >> _mm_movemask_epi8 (__m128i __A) >> { >> #ifdef _ARCH_PWR10 >> +#ifdef __BIG_ENDIAN__ >> + __A = (__m128i) vec_reve ((__v16qu) __A); >> +#endif >> return vec_extractm ((__v16qu) __A); >> #else >> __vector unsigned long long __result; >> diff --git a/gcc/config/rs6000/xmmintrin.h b/gcc/config/rs6000/xmmintrin.h >> index bd5be193b44..d98d4b3570c 100644 >> --- a/gcc/config/rs6000/xmmintrin.h >> +++ b/gcc/config/rs6000/xmmintrin.h >> @@ -1353,6 +1353,9 @@ extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artifici >> _mm_movemask_ps (__m128 __A) >> { >> #ifdef _ARCH_PWR10 >> +#ifdef __BIG_ENDIAN__ >> + __A = vec_reve (__A); >> +#endif >> return vec_extractm ((__vector unsigned int) __A); >> #else >> __vector unsigned long long __result; > From gerris.rs@gmail.com Mon Nov 2 11:16:53 2026 From: gerris.rs@gmail.com (gerris.rs@gmail.com) Date: Mon, 2 Nov 2026 11:16:53 +0000 Subject: [gccrs COMMIT] Remove the function_defer_statement helper. Message-ID: <20261102111654.3049-1-gerris.rs@gmail.com> From: Sriram Raghunathan This patch removes the function_defer_statement, this is a feature available in go and rust doesn't support this. gcc/rust/ChangeLog: * rust-backend.h (function_defer_statement): Remove. * rust-gcc.cc (function_defer_statement): Remove. Signed-off-by: Sriram Raghunathan --- This change was merged into the gccrs repository and is posted here for upstream visibility and potential drive-by review, as requested by GCC release managers. Each commit email contains a link to its details on github from where you can find the Pull-Request and associated discussions. Commit on github: https://github.com/Rust-GCC/gccrs/commit/ea402b0a668d490c6b73ba63715a82fd2629e1dd The commit has NOT been mentioned in any issue. The commit has been mentioned in the following pull-request(s): - https://github.com/Rust-GCC/gccrs/pull/5029 gcc/rust/rust-backend.h | 7 ------- gcc/rust/rust-gcc.cc | 35 ----------------------------------- 2 files changed, 42 deletions(-) diff --git a/gcc/rust/rust-backend.h b/gcc/rust/rust-backend.h index ecd868362..e3013cbb3 100644 --- a/gcc/rust/rust-backend.h +++ b/gcc/rust/rust-backend.h @@ -431,13 +431,6 @@ static const unsigned int function_in_unique_section = 1 << 3; tree function (tree fntype, GGC::Ident name, tl::optional asm_name, unsigned int flags, location_t); -// Create a statement that runs all deferred calls for FUNCTION. This should -// be a statement that looks like this in C++: -// finish: -// try { DEFER_RETURN; } catch { CHECK_DEFER; goto finish; } -tree function_defer_statement (tree function, tree undefer, tree check_defer, - location_t); - // Record PARAM_VARS as the variables to use for the parameters of FUNCTION. // This will only be called for a function definition. Returns true on // success, false on failure. diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index b3e5a5cdd..00df8b3b9 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -2388,41 +2388,6 @@ function (tree functype, GGC::Ident name, tl::optional asm_name, return decl; } -// Create a statement that runs all deferred calls for FUNCTION. This should -// be a statement that looks like this in C++: -// finish: -// try { UNDEFER; } catch { CHECK_DEFER; goto finish; } - -tree -function_defer_statement (tree function, tree undefer_tree, tree defer_tree, - location_t location) -{ - if (error_operand_p (undefer_tree) || error_operand_p (defer_tree) - || error_operand_p (function)) - return error_mark_node; - - if (DECL_STRUCT_FUNCTION (function) == NULL) - push_struct_function (function); - else - push_cfun (DECL_STRUCT_FUNCTION (function)); - - tree stmt_list = NULL; - tree label = Backend::label (function, tl::nullopt, location); - tree label_def = label_definition_statement (label); - append_to_statement_list (label_def, &stmt_list); - - tree jump_stmt = goto_statement (label, location); - tree catch_body - = build2 (COMPOUND_EXPR, void_type_node, defer_tree, jump_stmt); - catch_body = build2 (CATCH_EXPR, void_type_node, NULL, catch_body); - tree try_catch - = build2 (TRY_CATCH_EXPR, void_type_node, undefer_tree, catch_body); - append_to_statement_list (try_catch, &stmt_list); - pop_cfun (); - - return stmt_list; -} - // Record PARAM_VARS as the variables to use for the parameters of FUNCTION. // This will only be called for a function definition. base-commit: 1bef66052c5ad9ecea86a540bd3766083c5b0e71 -- 2.56.0 From jwakely@redhat.com Mon Nov 2 11:21:21 2026 From: jwakely@redhat.com (Jonathan Wakely) Date: Mon, 2 Nov 2026 11:21:21 +0000 Subject: [PATCH v3] libstdc++: improve string construction from streambuf [PR112925] In-Reply-To: <20261028150018.162867-1-ncm@cantrip.org> References: <20261028150018.162867-1-ncm@cantrip.org> Message-ID: On Wed, 28 Oct 2026 at 10:59 -0400, Nathan Myers wrote: >Changes in v3: > - Remove check for __is_constant_evaluated. > - Gate the shortcut on string's _Traits matching the default, > like the streambuf iterator's traits. > >Changes in v2: > - When constructing from a streambuf iterator range, ensure its > sentinel is another streambuf iterator, or default_sentinel. > - Add #pragma diagnostic push for "if constexpr" in c++11. > - Add c++11 test for construction from raw iterators. > - Add test with a sentinel in place of default-ctor'd iterator. > - Add test with range pipeline. > - Remove spurious 'constexpr' in test. > >Constructing a string from a streambuf iterator pair or range has >been found to be 3x faster using the streambuf member `sgetn`. >This is the minimal implementation as outlined in [PR112925]. >Future improvements might include doing the same optimization >when appending, and preallocating when the final size can be >known. > >libstdc++-v3/ChangeLog: > PR libstdc++/112925 > * include/bits/basic_string.h: (basic_string range ctor) The colon should be after the closing paren not the filename. > Special-case ranges of streambuf iterators. > * include/bits/basic_string.tcc: (_M_construct) Special-case Same here (the 'git gcc-verify' alias should catch these). > streambuf iterators. These always consume the whole stream. > * testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc: > New test, construction from two istreambuf_iterators. > * testsuite/21_strings/basic_string/cons/from_range2.cc: > New tests, construction from ranges. >--- > libstdc++-v3/include/bits/basic_string.h | 11 +++- > libstdc++-v3/include/bits/basic_string.tcc | 18 +++++++ > .../basic_string/cons/char/from_sbufiter.cc | 24 +++++++++ > .../basic_string/cons/from_range2.cc | 50 +++++++++++++++++++ > 4 files changed, 102 insertions(+), 1 deletion(-) > create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc > create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc > >diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h >index fd9419220a4..6886c7b2632 100644 >--- a/libstdc++-v3/include/bits/basic_string.h >+++ b/libstdc++-v3/include/bits/basic_string.h >@@ -826,7 +826,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 > basic_string(from_range_t, _Rg&& __rg, const _Alloc& __a = _Alloc()) > : basic_string(__a) > { >- if constexpr (ranges::forward_range<_Rg> || ranges::sized_range<_Rg>) >+ using _SbufIter = istreambuf_iterator<_CharT, char_traits<_CharT>>; >+ if constexpr (requires { >+ requires is_same_v, _SbufIter>; >+ requires is_same_v, _SbufIter> || >+ is_same_v, default_sentinel_t>; }) Is the requires-expression used to short-circuit? Is that worth it? We need to evaluate ranges::end(__rg) anyway, so the sentinel_t alias is cheap to evaluate, and is_same_v is cheap. So I think it is simpler to read without the requires requires, i.e. if constexpr (is_same_v, _SbufIter> && (is_same_v, _SbufIter> || is_same_v, default_sentinel_t>)) Do we also need to gate on is_same_v> here, so that we don't take the _M_construct path unless it's going to use the optimization? It probably doesn't matter, because if we have an istreambuf_iterator and default sentinel then I think the performance will be the same whether we use the loop in this function or the loop in _M_construct for input iterators. >+ { >+ _M_construct(__rg.begin(), _SbufIter(), input_iterator_tag{}); This needs to be ranges::begin(__rg) because an arbitary range that has istreambuf iterators might not have a .begin() member function. >+ } >+ else if constexpr ( >+ ranges::forward_range<_Rg> || ranges::sized_range<_Rg>) line break before the || rather than before the first condition please: else if constexpr (ranges::forward_range<_Rg> || ranges::sized_range<_Rg>) > { > const auto __n = static_cast(ranges::distance(__rg)); > reserve(__n); >diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc >index de82e997888..5bfc26740c3 100644 >--- a/libstdc++-v3/include/bits/basic_string.tcc >+++ b/libstdc++-v3/include/bits/basic_string.tcc >@@ -199,6 +199,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > _M_init_local_buf(); > >+ // NB: size() (i.e. _M_length) is initialized only at the end. > while (__beg != __end && __len < __capacity) > { > _M_local_buf[__len++] = *__beg; >@@ -228,6 +229,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > _M_data(__another.__ptr); > _M_capacity(__capacity); > } >+ >+#if __cplusplus >= 201103L >+# pragma GCC diagnostic push >+# pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr >+ >+ using _SbufIter = istreambuf_iterator<_CharT, char_traits<_CharT>>; This can just be istreambuf_iterator<_CharT> using the default template argument, although maybe it's better to be more explicit that we are intentionally using std::char_traits<_CharT>. So no change needed. >+ if constexpr (is_same<_InIterator, _SbufIter>::value && >+ is_same<_Traits, char_traits<_CharT>>::value) >+ { >+ auto __r = std::__copy_n_a( >+ __beg, __capacity - __len, _M_data() + __len, false); Line break after one of the commans, not after the opening paren. It didn't occur to me before but this makes a copy of __beg and then reads from that, then operates on the original __beg again. That's not valid for input iterators in general, but I think it's OK for our istreambuf_iterator ... right? Although the copy of __beg is the one that gets _M_sbuf == nullptr, when we do `__beg == __end` on the original object that will still be true because it will use _M_sbuf->sgetc() which will return eof. So I think it works by design not just by accident. >+ __len = __r - data(); >+ continue; >+ } >+ >+# pragma GCC diagnostic pop >+#endif > traits_type::assign(_M_data()[__len++], > static_cast<_CharT>(*__beg)); > ++__beg; >diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc >new file mode 100644 >index 00000000000..338dcbcdd27 >--- /dev/null >+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc >@@ -0,0 +1,24 @@ >+// { dg-do run { target c++11 } } >+ >+#include >+#include >+#include >+#include >+#include >+ >+std::string abcs{"abcdefghijklmnopqrstuvwxyz"}; >+std::string twice{abcs + " " + abcs}; >+ >+void >+test_iters() >+{ >+ std::istringstream stream{twice}; >+ std::istreambuf_iterator iter{stream}, end; >+ std::string str{iter, end}; >+ VERIFY(str == twice); >+} >+ >+int main() >+{ >+ test_iters(); >+} >diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc >new file mode 100644 >index 00000000000..7dd98b5c29b >--- /dev/null >+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc >@@ -0,0 +1,50 @@ >+// { dg-do run { target c++23 } } >+ >+#include >+#include >+#include >+#include >+#include >+#include >+ >+std::string abcs{"abcdefghijklmnopqrstuvwxyz"}; >+std::string twice{abcs + " " + abcs}; >+ >+void >+test_range() >+{ >+ std::istringstream stream{twice}; >+ std::istreambuf_iterator it{stream}, end; >+ std::ranges::subrange range{it, end}; >+ std::basic_string str{std::from_range, range}; >+ VERIFY(str == twice); >+} >+ >+void >+test_sentinel() >+{ >+ std::istringstream stream{twice}; >+ std::istreambuf_iterator it{stream}, end; >+ std::ranges::subrange range{it, std::default_sentinel}; >+ std::basic_string str{std::from_range, range}; >+ VERIFY(str == twice); >+} >+ >+void >+test_take() >+{ >+ std::istringstream stream{twice}; >+ std::istreambuf_iterator it{stream}, end; >+ std::ranges::subrange range{it, std::default_sentinel}; >+ std::basic_string str{std::from_range, >+ range | std::views::take_while([](char c){ return c != ' '; }) }; >+ VERIFY(str == abcs); >+} >+ >+ >+int main() >+{ >+ test_range(); >+ test_sentinel(); >+ test_take(); >+} >-- >2.56.0 > > From xiezhiheng@huawei.com Mon Nov 2 11:24:24 2026 From: xiezhiheng@huawei.com (xiezhiheng) Date: Mon, 2 Nov 2026 11:24:24 +0000 Subject: [PATCH 2/2] sched: Return delta when the pressure is below the peak pressure In-Reply-To: References: Message-ID: <4ecfe298f05b4b1aa87ac2718e560a4d@huawei.com> > > diff --git a/gcc/config/aarch64/aarch64-tuning-flags.def > > b/gcc/config/aarch64/aarch64-tuning-flags.def > > index 64a773be34c..f756cae4edd 100644 > > --- a/gcc/config/aarch64/aarch64-tuning-flags.def > > +++ b/gcc/config/aarch64/aarch64-tuning-flags.def > > @@ -84,4 +84,7 @@ AARCH64_EXTRA_TUNING_OPTION > > ("narrow_gp_writes", NARROW_GP_WRITES) > > /* Enable when the target prefers SVE merging movimm over zeroing. */ > > AARCH64_EXTRA_TUNING_OPTION ("avoid_zeroing_movimm", > > AVOID_MOVIMM_Z) > > > > +/* Set param_cycle_accurate_model to 0 for the target. */ > > +AARCH64_EXTRA_TUNING_OPTION ("disable-cycle-accurate-model", > > DISABLE_CYCLE_ACCURATE_MODEL) > > + > > Minor nit, can you make this DISABLE_CYCLE_ACCURATE_SCHED_MODEL? > So it's not confused with the latency modelling in the vectorizer. > > Patch is OK with that change. But I can't approve the middle-end bit. > > Once middle-end maintainer does I can apply the updated patch for you. > > Thanks, > Tamar > Thanks, this is the v3 patch. I've also sent it to the scheduler maintainers. Hi Jeff and Vladimir, could you please review the patch? Thanks, Zhiheng After applying the hip12 scheduling model, 507.cactuBSSN_r shows a ~12% performance regression. The reason is the same as the issue described in PR/114729, but that patch cannot fix this problem. I have enhanced this as follows: in model_excess_group_cost, originally the pressure increase was returned only when the pressure exceeded the peak pressure; now the delta is also returned when the pressure is below the peak pressure, in order to reduce spills. The change is controlled by the --param=cycle-accurate-model= option. As discussed in PR/114729, the "model" heuristic currently used by default on AArch64 is pretty old. However, the cortex-a57 scheduling model used by many AArch64 cores is also fairly old, so perhaps the default behavior of the scheduling algorithm is well matched to cortex-a57. Therefore, I add an additional DISABLE_CYCLE_ACCURATE_SCHED_MODEL tune parameter to control the behavior. On hip12, the actually executed instructions on 507.cactuBSSN_r are as follows, (w/ option -O3 -mcpu=native) Original: 1,207,015,685,661 instructions:u Apply hip12 scheduling model: 1,522,907,774,690 instructions:u Apply this patch: 1,278,756,677,944 instructions:u gcc/ChangeLog: * config/aarch64/aarch64-tuning-flags.def (AARCH64_EXTRA_TUNING_OPTION): Add DISABLE_CYCLE_ACCURATE_SCHED_MODEL tune parameter. * config/aarch64/aarch64.cc (aarch64_override_options_internal): Set param_cycle_accurate_model to 0. * config/aarch64/tuning_models/hip12.h: Set tune parameter DISABLE_CYCLE_ACCURATE_SCHED_MODEL. * haifa-sched.cc (model_excess_group_cost): Return delta if param_cycle_accurate_model is 0. Signed-off-by: Zhiheng Xie --- gcc/config/aarch64/aarch64-tuning-flags.def | 3 +++ gcc/config/aarch64/aarch64.cc | 6 ++++++ gcc/config/aarch64/tuning_models/hip12.h | 3 ++- gcc/haifa-sched.cc | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/config/aarch64/aarch64-tuning-flags.def b/gcc/config/aarch64/aarch64-tuning-flags.def index 64a773be34c..dd52b1e8db6 100644 --- a/gcc/config/aarch64/aarch64-tuning-flags.def +++ b/gcc/config/aarch64/aarch64-tuning-flags.def @@ -84,4 +84,7 @@ AARCH64_EXTRA_TUNING_OPTION ("narrow_gp_writes", NARROW_GP_WRITES) /* Enable when the target prefers SVE merging movimm over zeroing. */ AARCH64_EXTRA_TUNING_OPTION ("avoid_zeroing_movimm", AVOID_MOVIMM_Z) +/* Set param_cycle_accurate_model to 0 for the target. */ +AARCH64_EXTRA_TUNING_OPTION ("disable_cycle_accurate_sched_model", DISABLE_CYCLE_ACCURATE_SCHED_MODEL) + #undef AARCH64_EXTRA_TUNING_OPTION diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 9290677655a..6556691c5e9 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -20323,6 +20323,12 @@ aarch64_override_options_internal (struct gcc_options *opts, param_sched_pressure_algorithm, SCHED_PRESSURE_MODEL); + if (aarch64_tune_params.extra_tuning_flags + & AARCH64_EXTRA_TUNE_DISABLE_CYCLE_ACCURATE_SCHED_MODEL) + SET_OPTION_IF_UNSET (opts, opts_set, + param_cycle_accurate_model, + 0); + /* Validate the guard size. */ int guard_size = param_stack_clash_protection_guard_size; diff --git a/gcc/config/aarch64/tuning_models/hip12.h b/gcc/config/aarch64/tuning_models/hip12.h index cfb204b2e53..e464f6a7c20 100644 --- a/gcc/config/aarch64/tuning_models/hip12.h +++ b/gcc/config/aarch64/tuning_models/hip12.h @@ -217,7 +217,8 @@ static const struct tune_params hip12_tunings = 0, /* max_case_values. */ tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_BASE - | AARCH64_EXTRA_TUNE_MATCHED_VECTOR_THROUGHPUT), /* tune_flags. */ + | AARCH64_EXTRA_TUNE_MATCHED_VECTOR_THROUGHPUT + | AARCH64_EXTRA_TUNE_DISABLE_CYCLE_ACCURATE_SCHED_MODEL), /* tune_flags. */ &generic_armv8_a_prefetch_tune, AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ AARCH64_LDP_STP_POLICY_ALWAYS, /* stp_policy_model. */ diff --git a/gcc/haifa-sched.cc b/gcc/haifa-sched.cc index e0505e9db64..51b47764d25 100644 --- a/gcc/haifa-sched.cc +++ b/gcc/haifa-sched.cc @@ -2428,6 +2428,10 @@ model_excess_group_cost (struct model_pressure_group *group, if (pressure > group->limits[pci].pressure) return model_spill_cost (cl, group->limits[pci].orig_pressure, pressure); + /* If target prefers fewer spills, return the +ve delta indicating + pressure increase. */ + else if (!param_cycle_accurate_model) + return delta; } return 0; -- 2.43.0 From tkaminsk@redhat.com Mon Nov 2 11:40:55 2026 From: tkaminsk@redhat.com (Tomasz Kaminski) Date: Mon, 2 Nov 2026 12:40:55 +0100 Subject: [PATCH v3] libstdc++: improve string construction from streambuf [PR112925] In-Reply-To: References: <20261028150018.162867-1-ncm@cantrip.org> Message-ID: On Mon, Nov 2, 2026 at 12:22?PM Jonathan Wakely wrote: > On Wed, 28 Oct 2026 at 10:59 -0400, Nathan Myers wrote: > >Changes in v3: > > - Remove check for __is_constant_evaluated. > > - Gate the shortcut on string's _Traits matching the default, > > like the streambuf iterator's traits. > > > >Changes in v2: > > - When constructing from a streambuf iterator range, ensure its > > sentinel is another streambuf iterator, or default_sentinel. > > - Add #pragma diagnostic push for "if constexpr" in c++11. > > - Add c++11 test for construction from raw iterators. > > - Add test with a sentinel in place of default-ctor'd iterator. > > - Add test with range pipeline. > > - Remove spurious 'constexpr' in test. > > > >Constructing a string from a streambuf iterator pair or range has > >been found to be 3x faster using the streambuf member `sgetn`. > >This is the minimal implementation as outlined in [PR112925]. > >Future improvements might include doing the same optimization > >when appending, and preallocating when the final size can be > >known. > > > >libstdc++-v3/ChangeLog: > > PR libstdc++/112925 > > * include/bits/basic_string.h: (basic_string range ctor) > > The colon should be after the closing paren not the filename. > > > Special-case ranges of streambuf iterators. > > * include/bits/basic_string.tcc: (_M_construct) Special-case > > Same here > (the 'git gcc-verify' alias should catch these). > > > streambuf iterators. These always consume the whole stream. > > * testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc: > > New test, construction from two istreambuf_iterators. > > * testsuite/21_strings/basic_string/cons/from_range2.cc: > > New tests, construction from ranges. > >--- > > libstdc++-v3/include/bits/basic_string.h | 11 +++- > > libstdc++-v3/include/bits/basic_string.tcc | 18 +++++++ > > .../basic_string/cons/char/from_sbufiter.cc | 24 +++++++++ > > .../basic_string/cons/from_range2.cc | 50 +++++++++++++++++++ > > 4 files changed, 102 insertions(+), 1 deletion(-) > > create mode 100644 > libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc > > create mode 100644 > libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc > > > >diff --git a/libstdc++-v3/include/bits/basic_string.h > b/libstdc++-v3/include/bits/basic_string.h > >index fd9419220a4..6886c7b2632 100644 > >--- a/libstdc++-v3/include/bits/basic_string.h > >+++ b/libstdc++-v3/include/bits/basic_string.h > >@@ -826,7 +826,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 > > basic_string(from_range_t, _Rg&& __rg, const _Alloc& __a = > _Alloc()) > > : basic_string(__a) > > { > >- if constexpr (ranges::forward_range<_Rg> || > ranges::sized_range<_Rg>) > >+ using _SbufIter = istreambuf_iterator<_CharT, > char_traits<_CharT>>; > >+ if constexpr (requires { > >+ requires is_same_v, _SbufIter>; > >+ requires is_same_v, _SbufIter> || > >+ is_same_v, > default_sentinel_t>; }) > > Is the requires-expression used to short-circuit? > That was my suggestion, and yes the intent was to short-circuit. > > Is that worth it? We need to evaluate ranges::end(__rg) anyway, so the > sentinel_t alias is cheap to evaluate, and is_same_v is cheap. > Agreed, that does not buy us much in this case. > > So I think it is simpler to read without the requires requires, i.e. > > if constexpr (is_same_v, _SbufIter> > && (is_same_v, _SbufIter> > || is_same_v, > default_sentinel_t>)) > I subjectively find the syntax resulting from the repeated use of "requires" decently readable: if constexpr (requires { requires A; requires B || C; }) But not strongly enough to oppose changing it, to your preference. > > Do we also need to gate on is_same_v> > here, so that we don't take the _M_construct path unless it's going to > use the optimization? It probably doesn't matter, because if we have > an istreambuf_iterator and default sentinel then I think the > performance will be the same whether we use the loop in this function > or the loop in _M_construct for input iterators. > > >+ { > >+ _M_construct(__rg.begin(), _SbufIter(), > input_iterator_tag{}); > > This needs to be ranges::begin(__rg) because an arbitary range that > has istreambuf iterators might not have a .begin() member function. > > >+ } > >+ else if constexpr ( > >+ ranges::forward_range<_Rg> || ranges::sized_range<_Rg>) > > line break before the || rather than before the first condition > please: > > else if constexpr (ranges::forward_range<_Rg> > || ranges::sized_range<_Rg>) > > > { > > const auto __n = > static_cast(ranges::distance(__rg)); > > reserve(__n); > >diff --git a/libstdc++-v3/include/bits/basic_string.tcc > b/libstdc++-v3/include/bits/basic_string.tcc > >index de82e997888..5bfc26740c3 100644 > >--- a/libstdc++-v3/include/bits/basic_string.tcc > >+++ b/libstdc++-v3/include/bits/basic_string.tcc > >@@ -199,6 +199,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > > > _M_init_local_buf(); > > > >+ // NB: size() (i.e. _M_length) is initialized only at the end. > > while (__beg != __end && __len < __capacity) > > { > > _M_local_buf[__len++] = *__beg; > >@@ -228,6 +229,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > _M_data(__another.__ptr); > > _M_capacity(__capacity); > > } > >+ > >+#if __cplusplus >= 201103L > >+# pragma GCC diagnostic push > >+# pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr > >+ > >+ using _SbufIter = istreambuf_iterator<_CharT, > char_traits<_CharT>>; > > This can just be istreambuf_iterator<_CharT> using the default > template argument, although maybe it's better to be more explicit that > we are intentionally using std::char_traits<_CharT>. So no change > needed. > > >+ if constexpr (is_same<_InIterator, _SbufIter>::value && > >+ is_same<_Traits, char_traits<_CharT>>::value) > >+ { > >+ auto __r = std::__copy_n_a( > >+ __beg, __capacity - __len, _M_data() + __len, false); > > Line break after one of the commans, not after the opening paren. > > It didn't occur to me before but this makes a copy of __beg and then > reads from that, then operates on the original __beg again. That's not > valid for input iterators in general, but I think it's OK for our > istreambuf_iterator ... right? > > Although the copy of __beg is the one that gets _M_sbuf == nullptr, > when we do `__beg == __end` on the original object that will still be > true because it will use _M_sbuf->sgetc() which will return eof. > > So I think it works by design not just by accident. > That is also my understanding, that r17-376-ga068d1b7c9da60 preserved. > > >+ __len = __r - data(); > >+ continue; > >+ } > >+ > >+# pragma GCC diagnostic pop > >+#endif > > traits_type::assign(_M_data()[__len++], > > static_cast<_CharT>(*__beg)); > > ++__beg; > >diff --git > a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc > b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc > >new file mode 100644 > >index 00000000000..338dcbcdd27 > >--- /dev/null > >+++ > b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc > >@@ -0,0 +1,24 @@ > >+// { dg-do run { target c++11 } } > >+ > >+#include > >+#include > >+#include > >+#include > >+#include > >+ > >+std::string abcs{"abcdefghijklmnopqrstuvwxyz"}; > >+std::string twice{abcs + " " + abcs}; > >+ > >+void > >+test_iters() > >+{ > >+ std::istringstream stream{twice}; > >+ std::istreambuf_iterator iter{stream}, end; > >+ std::string str{iter, end}; > >+ VERIFY(str == twice); > >+} > >+ > >+int main() > >+{ > >+ test_iters(); > >+} > >diff --git > a/libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc > b/libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc > >new file mode 100644 > >index 00000000000..7dd98b5c29b > >--- /dev/null > >+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc > >@@ -0,0 +1,50 @@ > >+// { dg-do run { target c++23 } } > >+ > >+#include > >+#include > >+#include > >+#include > >+#include > >+#include > >+ > >+std::string abcs{"abcdefghijklmnopqrstuvwxyz"}; > >+std::string twice{abcs + " " + abcs}; > >+ > >+void > >+test_range() > >+{ > >+ std::istringstream stream{twice}; > >+ std::istreambuf_iterator it{stream}, end; > >+ std::ranges::subrange range{it, end}; > >+ std::basic_string str{std::from_range, range}; > >+ VERIFY(str == twice); > >+} > >+ > >+void > >+test_sentinel() > >+{ > >+ std::istringstream stream{twice}; > >+ std::istreambuf_iterator it{stream}, end; > >+ std::ranges::subrange range{it, std::default_sentinel}; > >+ std::basic_string str{std::from_range, range}; > >+ VERIFY(str == twice); > >+} > >+ > >+void > >+test_take() > >+{ > >+ std::istringstream stream{twice}; > >+ std::istreambuf_iterator it{stream}, end; > >+ std::ranges::subrange range{it, std::default_sentinel}; > >+ std::basic_string str{std::from_range, > >+ range | std::views::take_while([](char c){ return c != ' '; }) }; > >+ VERIFY(str == abcs); > >+} > >+ > >+ > >+int main() > >+{ > >+ test_range(); > >+ test_sentinel(); > >+ test_take(); > >+} > >-- > >2.56.0 > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jwakely@redhat.com Mon Nov 2 11:48:59 2026 From: jwakely@redhat.com (Jonathan Wakely) Date: Mon, 2 Nov 2026 11:48:59 +0000 Subject: [PATCH v3] libstdc++: improve string construction from streambuf [PR112925] In-Reply-To: References: <20261028150018.162867-1-ncm@cantrip.org> Message-ID: On Mon, 2 Nov 2026 at 11:41, Tomasz Kaminski wrote: > > > > On Mon, Nov 2, 2026 at 12:22?PM Jonathan Wakely wrote: >> >> On Wed, 28 Oct 2026 at 10:59 -0400, Nathan Myers wrote: >> >Changes in v3: >> > - Remove check for __is_constant_evaluated. >> > - Gate the shortcut on string's _Traits matching the default, >> > like the streambuf iterator's traits. >> > >> >Changes in v2: >> > - When constructing from a streambuf iterator range, ensure its >> > sentinel is another streambuf iterator, or default_sentinel. >> > - Add #pragma diagnostic push for "if constexpr" in c++11. >> > - Add c++11 test for construction from raw iterators. >> > - Add test with a sentinel in place of default-ctor'd iterator. >> > - Add test with range pipeline. >> > - Remove spurious 'constexpr' in test. >> > >> >Constructing a string from a streambuf iterator pair or range has >> >been found to be 3x faster using the streambuf member `sgetn`. >> >This is the minimal implementation as outlined in [PR112925]. >> >Future improvements might include doing the same optimization >> >when appending, and preallocating when the final size can be >> >known. >> > >> >libstdc++-v3/ChangeLog: >> > PR libstdc++/112925 >> > * include/bits/basic_string.h: (basic_string range ctor) >> >> The colon should be after the closing paren not the filename. >> >> > Special-case ranges of streambuf iterators. >> > * include/bits/basic_string.tcc: (_M_construct) Special-case >> >> Same here >> (the 'git gcc-verify' alias should catch these). >> >> > streambuf iterators. These always consume the whole stream. >> > * testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc: >> > New test, construction from two istreambuf_iterators. >> > * testsuite/21_strings/basic_string/cons/from_range2.cc: >> > New tests, construction from ranges. >> >--- >> > libstdc++-v3/include/bits/basic_string.h | 11 +++- >> > libstdc++-v3/include/bits/basic_string.tcc | 18 +++++++ >> > .../basic_string/cons/char/from_sbufiter.cc | 24 +++++++++ >> > .../basic_string/cons/from_range2.cc | 50 +++++++++++++++++++ >> > 4 files changed, 102 insertions(+), 1 deletion(-) >> > create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc >> > create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc >> > >> >diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h >> >index fd9419220a4..6886c7b2632 100644 >> >--- a/libstdc++-v3/include/bits/basic_string.h >> >+++ b/libstdc++-v3/include/bits/basic_string.h >> >@@ -826,7 +826,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 >> > basic_string(from_range_t, _Rg&& __rg, const _Alloc& __a = _Alloc()) >> > : basic_string(__a) >> > { >> >- if constexpr (ranges::forward_range<_Rg> || ranges::sized_range<_Rg>) >> >+ using _SbufIter = istreambuf_iterator<_CharT, char_traits<_CharT>>; >> >+ if constexpr (requires { >> >+ requires is_same_v, _SbufIter>; >> >+ requires is_same_v, _SbufIter> || >> >+ is_same_v, default_sentinel_t>; }) >> >> Is the requires-expression used to short-circuit? > > That was my suggestion, and yes the intent was to short-circuit. >> >> >> Is that worth it? We need to evaluate ranges::end(__rg) anyway, so the >> sentinel_t alias is cheap to evaluate, and is_same_v is cheap. > > Agreed, that does not buy us much in this case. >> >> >> So I think it is simpler to read without the requires requires, i.e. >> >> if constexpr (is_same_v, _SbufIter> >> && (is_same_v, _SbufIter> >> || is_same_v, default_sentinel_t>)) > > I subjectively find the syntax resulting from the repeated use of "requires" decently readable: > if constexpr (requires { > requires A; > requires B || C; > }) > But not strongly enough to oppose changing it, to your preference. If you both like that form I'll withdraw the comment. >> >> >> Do we also need to gate on is_same_v> >> here, so that we don't take the _M_construct path unless it's going to >> use the optimization? It probably doesn't matter, because if we have >> an istreambuf_iterator and default sentinel then I think the >> performance will be the same whether we use the loop in this function >> or the loop in _M_construct for input iterators. >> >> >+ { >> >+ _M_construct(__rg.begin(), _SbufIter(), input_iterator_tag{}); >> >> This needs to be ranges::begin(__rg) because an arbitary range that >> has istreambuf iterators might not have a .begin() member function. >> >> >+ } >> >+ else if constexpr ( >> >+ ranges::forward_range<_Rg> || ranges::sized_range<_Rg>) >> >> line break before the || rather than before the first condition >> please: >> >> else if constexpr (ranges::forward_range<_Rg> >> || ranges::sized_range<_Rg>) >> >> > { >> > const auto __n = static_cast(ranges::distance(__rg)); >> > reserve(__n); >> >diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc >> >index de82e997888..5bfc26740c3 100644 >> >--- a/libstdc++-v3/include/bits/basic_string.tcc >> >+++ b/libstdc++-v3/include/bits/basic_string.tcc >> >@@ -199,6 +199,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >> > >> > _M_init_local_buf(); >> > >> >+ // NB: size() (i.e. _M_length) is initialized only at the end. >> > while (__beg != __end && __len < __capacity) >> > { >> > _M_local_buf[__len++] = *__beg; >> >@@ -228,6 +229,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >> > _M_data(__another.__ptr); >> > _M_capacity(__capacity); >> > } >> >+ >> >+#if __cplusplus >= 201103L >> >+# pragma GCC diagnostic push >> >+# pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr >> >+ >> >+ using _SbufIter = istreambuf_iterator<_CharT, char_traits<_CharT>>; >> >> This can just be istreambuf_iterator<_CharT> using the default >> template argument, although maybe it's better to be more explicit that >> we are intentionally using std::char_traits<_CharT>. So no change >> needed. >> >> >+ if constexpr (is_same<_InIterator, _SbufIter>::value && >> >+ is_same<_Traits, char_traits<_CharT>>::value) >> >+ { >> >+ auto __r = std::__copy_n_a( >> >+ __beg, __capacity - __len, _M_data() + __len, false); >> >> Line break after one of the commans, not after the opening paren. >> >> It didn't occur to me before but this makes a copy of __beg and then >> reads from that, then operates on the original __beg again. That's not >> valid for input iterators in general, but I think it's OK for our >> istreambuf_iterator ... right? >> >> >> Although the copy of __beg is the one that gets _M_sbuf == nullptr, >> when we do `__beg == __end` on the original object that will still be >> true because it will use _M_sbuf->sgetc() which will return eof. >> >> So I think it works by design not just by accident. > > That is also my understanding, that r17-376-ga068d1b7c9da60 preserved. Ack, thanks. >> >> >> >+ __len = __r - data(); >> >+ continue; >> >+ } >> >+ >> >+# pragma GCC diagnostic pop >> >+#endif >> > traits_type::assign(_M_data()[__len++], >> > static_cast<_CharT>(*__beg)); >> > ++__beg; >> >diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc >> >new file mode 100644 >> >index 00000000000..338dcbcdd27 >> >--- /dev/null >> >+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc >> >@@ -0,0 +1,24 @@ >> >+// { dg-do run { target c++11 } } >> >+ >> >+#include >> >+#include >> >+#include >> >+#include >> >+#include >> >+ >> >+std::string abcs{"abcdefghijklmnopqrstuvwxyz"}; >> >+std::string twice{abcs + " " + abcs}; >> >+ >> >+void >> >+test_iters() >> >+{ >> >+ std::istringstream stream{twice}; >> >+ std::istreambuf_iterator iter{stream}, end; >> >+ std::string str{iter, end}; >> >+ VERIFY(str == twice); >> >+} >> >+ >> >+int main() >> >+{ >> >+ test_iters(); >> >+} >> >diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc >> >new file mode 100644 >> >index 00000000000..7dd98b5c29b >> >--- /dev/null >> >+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc >> >@@ -0,0 +1,50 @@ >> >+// { dg-do run { target c++23 } } >> >+ >> >+#include >> >+#include >> >+#include >> >+#include >> >+#include >> >+#include >> >+ >> >+std::string abcs{"abcdefghijklmnopqrstuvwxyz"}; >> >+std::string twice{abcs + " " + abcs}; >> >+ >> >+void >> >+test_range() >> >+{ >> >+ std::istringstream stream{twice}; >> >+ std::istreambuf_iterator it{stream}, end; >> >+ std::ranges::subrange range{it, end}; >> >+ std::basic_string str{std::from_range, range}; >> >+ VERIFY(str == twice); >> >+} >> >+ >> >+void >> >+test_sentinel() >> >+{ >> >+ std::istringstream stream{twice}; >> >+ std::istreambuf_iterator it{stream}, end; >> >+ std::ranges::subrange range{it, std::default_sentinel}; >> >+ std::basic_string str{std::from_range, range}; >> >+ VERIFY(str == twice); >> >+} >> >+ >> >+void >> >+test_take() >> >+{ >> >+ std::istringstream stream{twice}; >> >+ std::istreambuf_iterator it{stream}, end; >> >+ std::ranges::subrange range{it, std::default_sentinel}; >> >+ std::basic_string str{std::from_range, >> >+ range | std::views::take_while([](char c){ return c != ' '; }) }; >> >+ VERIFY(str == abcs); >> >+} >> >+ >> >+ >> >+int main() >> >+{ >> >+ test_range(); >> >+ test_sentinel(); >> >+ test_take(); >> >+} >> >-- >> >2.56.0 >> > >> > >> From gerris.rs@gmail.com Mon Nov 2 12:04:33 2026 From: gerris.rs@gmail.com (gerris.rs@gmail.com) Date: Mon, 2 Nov 2026 12:04:33 +0000 Subject: [gccrs COMMIT 1/2] gccrs: Fix fnv128 calculation Message-ID: <20261102120434.2877-1-gerris.rs@gmail.com> From: Owen Avery The function we use to calculate fnv128 had a precedence bug when applying prime128Shift and didn't take advantage of prime128Lower fitting into a uint32_t. gcc/rust/ChangeLog: * util/fnv-hash.h (FNV::write): Tweak calculation. Signed-off-by: Owen Avery --- This change was merged into the gccrs repository and is posted here for upstream visibility and potential drive-by review, as requested by GCC release managers. Each commit email contains a link to its details on github from where you can find the Pull-Request and associated discussions. Commit on github: https://github.com/Rust-GCC/gccrs/commit/a42f4cb297d332e87f2239d6b0bb121ede233a66 The commit has NOT been mentioned in any issue. The commit has been mentioned in the following pull-request(s): - https://github.com/Rust-GCC/gccrs/pull/5031 gcc/rust/util/fnv-hash.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/gcc/rust/util/fnv-hash.h b/gcc/rust/util/fnv-hash.h index 4d8a24373..1ef5eb617 100644 --- a/gcc/rust/util/fnv-hash.h +++ b/gcc/rust/util/fnv-hash.h @@ -47,31 +47,25 @@ public: unsigned char c = in[i]; // https://stackoverflow.com/questions/28868367/getting-the-high-part-of-64-bit-integer-multiplication + // modified since a is sub-32-bit uint64_t a = prime128Lower; uint64_t b = buf[1]; - uint64_t a_lo = (uint32_t) a; - uint64_t a_hi = a >> 32; uint64_t b_lo = (uint32_t) b; uint64_t b_hi = b >> 32; - uint64_t a_x_b_hi = a_hi * b_hi; - uint64_t a_x_b_mid = a_hi * b_lo; - uint64_t b_x_a_mid = b_hi * a_lo; - uint64_t a_x_b_lo = a_lo * b_lo; + uint64_t a_x_b_mid = a * b_hi; + uint64_t a_x_b_lo = a * b_lo; uint64_t carry_bit - = ((uint64_t) (uint32_t) a_x_b_mid + (uint64_t) (uint32_t) b_x_a_mid - + (a_x_b_lo >> 32)) - >> 32; + = ((uint64_t) (uint32_t) a_x_b_mid + (a_x_b_lo >> 32)) >> 32; - uint64_t multhi - = a_x_b_hi + (a_x_b_mid >> 32) + (b_x_a_mid >> 32) + carry_bit; + uint64_t multhi = (a_x_b_mid >> 32) + carry_bit; uint64_t s0 = multhi; // high uint64_t s1 = prime128Lower * buf[1]; // low - s0 += buf[1] << (prime128Shift + prime128Lower * buf[0]); + s0 += (buf[1] << prime128Shift) + prime128Lower * buf[0]; // Update the values buf[1] = s1; base-commit: ea402b0a668d490c6b73ba63715a82fd2629e1dd -- 2.56.0 From gerris.rs@gmail.com Mon Nov 2 12:04:34 2026 From: gerris.rs@gmail.com (gerris.rs@gmail.com) Date: Mon, 2 Nov 2026 12:04:34 +0000 Subject: [gccrs COMMIT 2/2] gccrs: Intrinsically compile slice index referencing In-Reply-To: <20261102120434.2877-1-gerris.rs@gmail.com> References: <20261102120434.2877-1-gerris.rs@gmail.com> Message-ID: <20261102120434.2877-2-gerris.rs@gmail.com> From: Yap Zhi Heng Generated GIMPLE for new issue-1133.rs testcase: ... b = issue_1133::::index> (D.5562, D.5561); _1 = b.data; c = MEM[(i32 *)_1 + 4B]; ... gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (visit(HIR::ArrayIndexExpr)): Implement type check support for slice types as well. * backend/rust-compile-expr.cc (visit(HIR::ArrayIndexExpr)): Implement intrinsic codegen support for slice indexing. gcc/testsuite/ChangeLog: * rust/execute/torture/issue-1133.rs: Update index impl for SliceIndex for usize. * rust/execute/torture/issue-1232.rs: Likewise. Signed-off-by: Yap Zhi Heng --- This change was merged into the gccrs repository and is posted here for upstream visibility and potential drive-by review, as requested by GCC release managers. Each commit email contains a link to its details on github from where you can find the Pull-Request and associated discussions. Commit on github: https://github.com/Rust-GCC/gccrs/commit/096c89030e1c006f433023574bcf61137a72d82a The commit has NOT been mentioned in any issue. The commit has been mentioned in the following pull-request(s): - https://github.com/Rust-GCC/gccrs/pull/5045 gcc/rust/backend/rust-compile-expr.cc | 57 +++++++++++++------ .../typecheck/rust-hir-type-check-expr.cc | 26 +++++++-- .../rust/execute/torture/issue-1133.rs | 5 +- .../rust/execute/torture/issue-1232.rs | 3 +- 4 files changed, 64 insertions(+), 27 deletions(-) diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 8c8268bc3..9798a9b30 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -2993,7 +2993,7 @@ CompileExpr::visit (HIR::RangeFullExpr &expr) void CompileExpr::visit (HIR::ArrayIndexExpr &expr) { - tree array_reference = CompileExpr::Compile (expr.get_array_expr (), ctx); + tree reference = CompileExpr::Compile (expr.get_array_expr (), ctx); tree index = CompileExpr::Compile (expr.get_index_expr (), ctx); // this might be an core::ops::index lang item situation @@ -3004,8 +3004,8 @@ CompileExpr::visit (HIR::ArrayIndexExpr &expr) { auto lang_item_type = LangItem::Kind::INDEX; tree operator_overload_call - = resolve_operator_overload (lang_item_type, expr, array_reference, - index, expr.get_array_expr (), + = resolve_operator_overload (lang_item_type, expr, reference, index, + expr.get_array_expr (), expr.get_index_expr ()); tree actual_type = TREE_TYPE (operator_overload_call); @@ -3024,29 +3024,52 @@ CompileExpr::visit (HIR::ArrayIndexExpr &expr) return; } - // lets check if the array is a reference type then we can add an + // lets check if the array/slice is a reference type then we can add an // indirection if required - TyTy::BaseType *array_expr_ty = nullptr; + TyTy::BaseType *base_ty = nullptr; bool ok = ctx->get_tyctx ()->lookup_type ( - expr.get_array_expr ().get_mappings ().get_hirid (), &array_expr_ty); + expr.get_array_expr ().get_mappings ().get_hirid (), &base_ty); rust_assert (ok); - // do we need to add an indirect reference - if (array_expr_ty->get_kind () == TyTy::TypeKind::REF) + if (base_ty->get_kind () == TyTy::TypeKind::REF) { - array_reference - = indirect_expression (array_reference, expr.get_locus ()); + auto ref = static_cast (base_ty); + base_ty = ref->get_base (); + + if (base_ty->get_kind () == TyTy::TypeKind::ARRAY) + { + // only array box is further deferenced to the underlying array + // slice always uses fat ptr, which is handled in + // slice_index_expression + reference = indirect_expression (reference, expr.get_locus ()); + } } - else if (TyTy::try_get_box_inner_type (array_expr_ty)) + else if (auto inner = TyTy::try_get_box_inner_type (base_ty)) { - array_reference - = build_box_inner_ptr (array_reference, expr.get_locus ()); - array_reference - = indirect_expression (array_reference, expr.get_locus ()); + base_ty = *inner; + reference = build_box_inner_ptr (reference, expr.get_locus ()); + + if (base_ty->get_kind () == TyTy::TypeKind::ARRAY) + { + // only array box is further deferenced to the underlying array + // slice always uses fat ptr, which is handled in + // slice_index_expression + reference = indirect_expression (reference, expr.get_locus ()); + } } - translated = Backend::array_index_expression (array_reference, index, - expr.get_locus ()); + if (base_ty->get_kind () == TyTy::TypeKind::ARRAY) + { + translated + = Backend::array_index_expression (reference, index, expr.get_locus ()); + } + else + { + // it must be a slice here + rust_assert (base_ty->get_kind () == TyTy::TypeKind::SLICE); + translated + = Backend::slice_index_expression (reference, index, expr.get_locus ()); + } } void diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc index 44487f532..b7acb787f 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc @@ -1097,7 +1097,8 @@ TypeCheckExpr::visit (HIR::ArrayIndexExpr &expr) // lets try and deref it since rust allows this auto ref = static_cast (direct_array_expr_ty); auto base = ref->get_base (); - if (base->get_kind () == TyTy::TypeKind::ARRAY) + if (base->get_kind () == TyTy::TypeKind::ARRAY + || base->get_kind () == TyTy::TypeKind::SLICE) direct_array_expr_ty = base; } // Box autoderef @@ -1114,8 +1115,11 @@ TypeCheckExpr::visit (HIR::ArrayIndexExpr &expr) = types_compatable (TyTy::TyWithLocation (index_expr_ty), TyTy::TyWithLocation (size_ty), expr.get_locus (), false); + + auto base_kind = direct_array_expr_ty->get_kind (); if (maybe_simple_array_access - && direct_array_expr_ty->get_kind () == TyTy::TypeKind::ARRAY) + && (base_kind == TyTy::TypeKind::ARRAY + || base_kind == TyTy::TypeKind::SLICE)) { unify_site (expr.get_index_expr ().get_mappings ().get_hirid (), TyTy::TyWithLocation (size_ty), @@ -1123,9 +1127,21 @@ TypeCheckExpr::visit (HIR::ArrayIndexExpr &expr) expr.get_index_expr ().get_locus ()), expr.get_locus ()); - TyTy::ArrayType *array_type - = static_cast (direct_array_expr_ty); - infered = array_type->get_element_type ()->clone (); + if (base_kind == TyTy::TypeKind::ARRAY) + { + TyTy::ArrayType *array_type + = static_cast (direct_array_expr_ty); + infered = array_type->get_element_type ()->clone (); + } + else + { + // is slice type instead + rust_assert (base_kind == TyTy::TypeKind::SLICE); + TyTy::SliceType *slice_type + = static_cast (direct_array_expr_ty); + infered = slice_type->get_element_type ()->clone (); + } + return; } diff --git a/gcc/testsuite/rust/execute/torture/issue-1133.rs b/gcc/testsuite/rust/execute/torture/issue-1133.rs index 5363e1c86..fc744d127 100644 --- a/gcc/testsuite/rust/execute/torture/issue-1133.rs +++ b/gcc/testsuite/rust/execute/torture/issue-1133.rs @@ -102,8 +102,7 @@ unsafe impl SliceIndex<[T]> for usize { fn index(self, slice: &[T]) -> &T { // N.B., use intrinsic indexing - // &(*slice)[self] - unsafe { &*self.get_unchecked(slice) } + &(*slice)[self] } } @@ -149,5 +148,5 @@ fn main() -> i32 { let b = &a[1..3]; let c = b[1]; - 0 + c - 3 } diff --git a/gcc/testsuite/rust/execute/torture/issue-1232.rs b/gcc/testsuite/rust/execute/torture/issue-1232.rs index 5bb867972..fb0e6fd43 100644 --- a/gcc/testsuite/rust/execute/torture/issue-1232.rs +++ b/gcc/testsuite/rust/execute/torture/issue-1232.rs @@ -107,8 +107,7 @@ unsafe impl SliceIndex<[T]> for usize { fn index(self, slice: &[T]) -> &T { // N.B., use intrinsic indexing - // &(*slice)[self] - unsafe { &*self.get_unchecked(slice) } + &(*slice)[self] } } -- 2.56.0 From tkaminsk@redhat.com Mon Nov 2 12:12:23 2026 From: tkaminsk@redhat.com (Tomasz Kaminski) Date: Mon, 2 Nov 2026 13:12:23 +0100 Subject: [PATCH 1/3] libstdc++: Fix buffer overflow in basic_filebuf::overflow [PR118099] In-Reply-To: References: <20261023174023.845748-1-jwakely@redhat.com> Message-ID: On Fri, Oct 23, 2026 at 8:09?PM Jonathan Wakely wrote: > On Fri, 23 Oct 2026 at 18:44, Jonathan Wakely wrote: > > > > On Fri, 23 Oct 2026 at 18:40, Jonathan Wakely > wrote: > > > > > > From: Peter Edwards > > > > > > If we fail to write the content of the buffer after inserting the > > > overflow character into the end of it, then remove that overflow > > > character before propagating the error back to the caller. Without > this, > > > the caller is left with pptr set past epptr, and successive calls to > > > overflow will write further past the end of the managed buffer with > each > > > failure. > > > > > > libstdc++-v3/ChangeLog: > > > > > > PR libstdc++/118099 > > > * include/bits/fstream.tcc (basic_filebuf::overflow): Rewind > the > > > put position if outputting the put area fails. > > > * testsuite/27_io/basic_filebuf/overflow/char/118099.cc: New > > > test. > > > * testsuite/27_io/basic_filebuf/overflow/wchar_t/118099.cc: > > > New test. > > > > > > Co-authored-by: Jonathan Wakely > > > --- > > > > > > Tested x86_64-linux. > > > > I forgot to say: > > [PATCH 1/3] should be backported to active branches. > > [PATCH 2/3] is doesn't need to be backported since it only fixes a > > hypothetical problem. > > [PATCH 3/3] is not suitable for backporting, but the bug can be fixed > > with a try-catch around the call to _M_convert_to_external. > > Or we could do this for the branches, which would fix the > non-hypothetical problems (and tests) fixed by PATCH 1/3 and 3/3: > I would use solution below for all branches (including trunk), so the backports are cherry-picked. With that and one small suggestion for test LGTM > > --- a/libstdc++-v3/include/bits/fstream.tcc > +++ b/libstdc++-v3/include/bits/fstream.tcc > @@ -561,11 +561,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > } > if (this->pbase() < this->pptr()) > { > + struct _Guard { > + ~_Guard() { if (_M_p) _M_p->pbump(-1); } > + basic_filebuf* _M_p; > + }; > + _Guard __g = { }; > + > // If appropriate, append the overflow char. > if (!__testeof) > { > *this->pptr() = traits_type::to_char_type(__c); > this->pbump(1); > + __g._M_p = this; > } > > // Convert pending sequence to external representation, > @@ -573,6 +580,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > if (_M_convert_to_external(this->pbase(), > this->pptr() - this->pbase())) > { > + __g._M_p = 0; > _M_set_buffer(0); > __ret = traits_type::not_eof(__c); > } > > > For trunk I would still like to do the larger refactoring so that we > avoid advancing then conditionally rewinding the next pointer, and the > changes to _M_convert_to_external make it simpler IMHO. > Agreed, the PATCH 3/3 can then remove _Guard, but will need to have message adjusted, to say it is refactoring/simplification. In the new test, I would prefer that instead of : + bool got_eof = false; + for (int i = 0; i < N; ++i) + if (fb.sputc(val) == std::char_traits::eof()) + got_eof = true; + VERIFY( got_eof ); // the error path was actually taken We will do the following for (int i = 0; i < N/2; ++i) VERIFY( fb.sputc(val) != std::char_traits::eof()) for (int i = N/2; i < N; ++i) VERIFY( fb.sputc(val) == std::char_traits::eof()) -------------- next part -------------- An HTML attachment was scrubbed... URL: From rguenther@suse.de Mon Nov 2 12:14:50 2026 From: rguenther@suse.de (Richard Biener) Date: Mon, 2 Nov 2026 13:14:50 +0100 (CET) Subject: [patch v2 7/14]middle-end: add conditional vector compare IFNs In-Reply-To: References: Message-ID: <16oqp27p-p634-ro1r-o82n-26p3r3qps354@fhfr.qr> On Thu, 22 Oct 2026, Tamar Christina wrote: > This patch adds the middle-end representation for conditional vector > comparisons. > > It introduces IFN_COND_VEC_CMP and IFN_COND_LEN_VEC_CMP, together with the > cond_vec_cmp and cond_len_vec_cmp optabs. The IFNs take a comparison code, a > governing vector predicate, and the two vector operands being compared. The LEN > form also carries the usual vector length and bias operands used by > length-masked internal functions. > > The support queries now validate the operands that the final expander needs: the > destination predicate, mask, comparison RTX, and the LEN/BIAS operands for the > length form. The generic documentation now describes the new IFNs and their > operands. > > For example, this source: > > void f (int *a, int *b, int *c, int *d) > { > for (int i = 0; i < 1024; ++i) > if (c[i] != 0 && a[i] < b[i]) > d[i] = a[i]; > } > > The old GIMPLE/code generation carried this as separate compare and mask > operations, so the target had to rediscover that the second compare was governed > by the first mask: > > mask0 = vect_c != 0; > mask1 = vect_a < vect_b; > mask2 = mask0 & mask1; > > With this patch, e.g. SVE receives the governing predicate directly and emits > the second compare under that predicate: > > cmpne p7.s, p7/z, z29.s, #0 > ld1w z31.s, p7/z, [x0, x4, lsl 2] > ld1w z30.s, p7/z, [x1, x4, lsl 2] > cmplt p7.s, p7/z, z31.s, z30.s > st1w z31.s, p7, [x3, x4, lsl 2] > > The change is mostly plumbing, but it keeps predicate-producing compares visible > long enough for the conditional compare IFN and AArch64 lowering patches to > select the intended target instructions. > > This change is done late in isel rather than in the vectorizer because various > passes still understand VLA compares and we'd lose all optimizations here if we > picked a different representation too early. > > However we need to do this in expand, so we can have CSE eliminate duplicate > compares. Without this we could only do it after combine after which we have no > more CSE. Additional side-effect is that we can now simplify many of the SVE > comparisons. > > Bootstrapped Regtested on aarch64-none-linux-gnu, > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > -m32, -m64 and no issues. > > -O3, profiled, profiled -O3 and -O3 -LTO bootstrap tested and no issues. > > Also SPECCPU 2017 and SPECCPU 2026 tested. > > OK for master? OK. As Robin probably means having the compare tree code as integer makes integration into match patterns difficult, but .VEC_COND has this as well, so I'm OK with it rather than adding 20 different .COND_VEC_{EQ,NE,...,UNEQ} variants. Richard. > gcc/ChangeLog: > > * doc/generic.texi (Vector Expressions): Document IFN_COND_VEC_CMP > and IFN_COND_LEN_VEC_CMP. > * internal-fn.cc (internal_fn_mask_index): Handle IFN_COND_VEC_CMP > and IFN_COND_LEN_VEC_CMP. > (expand_cond_vec_cmp_1_p): New function. Check target support for > the result, predicate and comparison, and length and bias if present. > (expand_cond_vec_cmp_p): New function. > (expand_COND_VEC_CMP): Likewise. > (expand_cond_len_vec_cmp_p): Likewise. > (expand_COND_LEN_VEC_CMP): Likewise. > * internal-fn.def (COND_VEC_CMP): New internal function. > (COND_LEN_VEC_CMP): Likewise. > * internal-fn.h (expand_COND_VEC_CMP): Declare. > (expand_COND_LEN_VEC_CMP): Likewise. > (expand_cond_vec_cmp_p): Likewise. > (expand_cond_len_vec_cmp_p): Likewise. > * optabs.def (cond_vec_cmp_optab): New optab. > (cond_len_vec_cmp_optab): Likewise. > > --- > diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi > index e61b151cd863f3eb843c0e9d11253ef7b5c9614e..dbf63074c4b39415936547734392e0e98f355b79 100644 > --- a/gcc/doc/generic.texi > +++ b/gcc/doc/generic.texi > @@ -1839,6 +1839,8 @@ a value from @code{enum annot_expr_kind}, the third is an @code{INTEGER_CST}. > @tindex IFN_VEC_WIDEN_MINUS_EVEN > @tindex IFN_VEC_WIDEN_MINUS_ODD > @tindex IFN_VEC_TRUNC_ADD_HIGH > +@tindex IFN_COND_VEC_CMP > +@tindex IFN_COND_LEN_VEC_CMP > @tindex VEC_UNPACK_HI_EXPR > @tindex VEC_UNPACK_LO_EXPR > @tindex VEC_UNPACK_FLOAT_HI_EXPR > @@ -1979,6 +1981,19 @@ type. > This operation currently only used for early break result compression when the > result of a vector boolean can be represented as 0 or -1. > > +@item IFN_COND_VEC_CMP > +@itemx IFN_COND_LEN_VEC_CMP > +These internal functions represent predicated vector comparisons. The first > +argument is an integer constant whose value is a @code{tree_code} comparison > +code. The next argument is the mask, followed by the two vector operands > +being compared. The result has the same vector boolean type as the mask; > +inactive elements are false. > + > +@code{IFN_COND_LEN_VEC_CMP} has two extra arguments, the vector length and > +bias, with the same meaning as for other length-masked internal functions. > +The functions are expanded through the @code{cond_vec_cmp} and > +@code{cond_len_vec_cmp} optabs. > + > @item VEC_UNPACK_HI_EXPR > @itemx VEC_UNPACK_LO_EXPR > These nodes represent unpacking of the high and low parts of the input vector, > diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc > index 7d2f887e8c72aedad28161da75d9a580dfc05609..99821efb9e9cdc9285b3af6bb681baf9dc97033e 100644 > --- a/gcc/internal-fn.cc > +++ b/gcc/internal-fn.cc > @@ -5362,6 +5362,10 @@ internal_fn_mask_index (internal_fn fn) > case IFN_COND_LEN_INDEX_FIRST_ACTIVE: > return 0; > > + case IFN_COND_VEC_CMP: > + case IFN_COND_LEN_VEC_CMP: > + return 1; > + > default: > return (conditional_internal_fn_code (fn) != ERROR_MARK > || get_unconditional_internal_fn (fn) != IFN_LAST ? 0 : -1); > @@ -5955,3 +5959,150 @@ expand_BITREVERSE (internal_fn fn, gcall *stmt) > if (expand_bitquery (fn, stmt)) > expand_unary_optab_fn (fn, stmt, bitreverse_optab); > } > + > +static bool > +expand_cond_vec_cmp_1_p (optab optab, tree_code tcode, tree mask, tree op0, > + tree len = NULL_TREE, tree bias = NULL_TREE) > +{ > + tree lhs_type = TREE_TYPE (mask); > + tree op_type = TREE_TYPE (op0); > + machine_mode mask_mode = TYPE_MODE (lhs_type); > + machine_mode op_mode = TYPE_MODE (op_type); > + > + gcc_assert (TREE_CODE_CLASS (tcode) == tcc_comparison); > + > + insn_code icode = convert_optab_handler (optab, op_mode, mask_mode); > + if (icode == CODE_FOR_nothing) > + return false; > + > + enum rtx_code rcode = get_rtx_code_1 (tcode, TYPE_UNSIGNED (op_type)); > + if (rcode == UNKNOWN) > + return false; > + > + rtx target = alloca_raw_REG (mask_mode, LAST_VIRTUAL_REGISTER); > + if (!insn_operand_matches (icode, 0, target)) > + return false; > + > + rtx pred = alloca_raw_REG (mask_mode, LAST_VIRTUAL_REGISTER + 1); > + if (!insn_operand_matches (icode, 2, pred)) > + return false; > + > + rtx reg1 = alloca_raw_REG (op_mode, LAST_VIRTUAL_REGISTER + 2); > + rtx reg2 = alloca_raw_REG (op_mode, LAST_VIRTUAL_REGISTER + 3); > + rtx test = alloca_rtx_fmt_ee (rcode, mask_mode, reg1, reg2); > + if (!insn_operand_matches (icode, 1, test)) > + return false; > + > + if (len) > + { > + gcc_assert (bias); > + machine_mode len_mode = insn_data[(int) icode].operand[5].mode; > + > + if (len_mode == VOIDmode) > + len_mode = TYPE_MODE (TREE_TYPE (len)); > + rtx len_rtx = alloca_raw_REG (len_mode, LAST_VIRTUAL_REGISTER + 4); > + if (!insn_operand_matches (icode, 5, len_rtx)) > + return false; > + > + if (!tree_fits_shwi_p (bias) > + || !insn_operand_matches (icode, 6, GEN_INT (tree_to_shwi (bias)))) > + return false; > + } > + > + return true; > +} > + > +bool > +expand_cond_vec_cmp_p (tree_code tcode, tree mask, tree op0, tree /* op1 */) > +{ > + return expand_cond_vec_cmp_1_p (cond_vec_cmp_optab, tcode, mask, op0); > +} > + > +void > +expand_COND_VEC_CMP (internal_fn fn, gcall *stmt) > +{ > + gcc_assert (fn == IFN_COND_VEC_CMP); > + > + tree lhs = gimple_call_lhs (stmt); > + tree lhs_type = TREE_TYPE (lhs); > + tree_code tcode = (tree_code) tree_to_uhwi (gimple_call_arg (stmt, 0)); > + tree mask = gimple_call_arg (stmt, 1); > + tree op0 = gimple_call_arg (stmt, 2); > + tree op1 = gimple_call_arg (stmt, 3); > + tree op_type = TREE_TYPE (op0); > + machine_mode mask_mode = TYPE_MODE (lhs_type); > + machine_mode op_mode = TYPE_MODE (op_type); > + bool unsignedp = TYPE_UNSIGNED (op_type); > + > + gcc_assert (TREE_CODE_CLASS (tcode) == tcc_comparison); > + > + insn_code icode = convert_optab_handler (cond_vec_cmp_optab, op_mode, > + mask_mode); > + gcc_assert (icode != CODE_FOR_nothing); > + > + rtx lhs_rtx = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE); > + rtx mask_rtx = expand_normal (mask); > + rtx comparison = vector_compare_rtx (mask_mode, tcode, op0, op1, > + unsignedp, icode, 3); > + > + class expand_operand ops[5]; > + create_call_lhs_operand (&ops[0], lhs_rtx, mask_mode); > + create_fixed_operand (&ops[1], comparison); > + create_input_operand (&ops[2], mask_rtx, TYPE_MODE (TREE_TYPE (mask))); > + create_fixed_operand (&ops[3], XEXP (comparison, 0)); > + create_fixed_operand (&ops[4], XEXP (comparison, 1)); > + expand_insn (icode, 5, ops); > + assign_call_lhs (lhs, lhs_rtx, &ops[0]); > +} > + > +bool > +expand_cond_len_vec_cmp_p (tree_code tcode, tree mask, tree op0, tree /* op1 */, > + tree len, tree bias) > +{ > + return expand_cond_vec_cmp_1_p (cond_len_vec_cmp_optab, tcode, mask, op0, > + len, bias); > +} > + > +void > +expand_COND_LEN_VEC_CMP (internal_fn fn, gcall *stmt) > +{ > + gcc_assert (fn == IFN_COND_LEN_VEC_CMP); > + > + tree lhs = gimple_call_lhs (stmt); > + tree lhs_type = TREE_TYPE (lhs); > + tree_code tcode = (tree_code) tree_to_uhwi (gimple_call_arg (stmt, 0)); > + tree mask = gimple_call_arg (stmt, 1); > + tree op0 = gimple_call_arg (stmt, 2); > + tree op1 = gimple_call_arg (stmt, 3); > + tree len = gimple_call_arg (stmt, 4); > + tree bias = gimple_call_arg (stmt, 5); > + tree op_type = TREE_TYPE (op0); > + machine_mode mask_mode = TYPE_MODE (lhs_type); > + machine_mode op_mode = TYPE_MODE (op_type); > + bool unsignedp = TYPE_UNSIGNED (op_type); > + > + gcc_assert (TREE_CODE_CLASS (tcode) == tcc_comparison); > + > + insn_code icode = convert_optab_handler (cond_len_vec_cmp_optab, op_mode, > + mask_mode); > + gcc_assert (icode != CODE_FOR_nothing); > + > + rtx lhs_rtx = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE); > + rtx mask_rtx = expand_normal (mask); > + rtx len_rtx = expand_normal (len); > + rtx bias_rtx = expand_normal (bias); > + rtx comparison = vector_compare_rtx (mask_mode, tcode, op0, op1, > + unsignedp, icode, 3); > + > + class expand_operand ops[7]; > + create_call_lhs_operand (&ops[0], lhs_rtx, mask_mode); > + create_fixed_operand (&ops[1], comparison); > + create_input_operand (&ops[2], mask_rtx, TYPE_MODE (TREE_TYPE (mask))); > + create_fixed_operand (&ops[3], XEXP (comparison, 0)); > + create_fixed_operand (&ops[4], XEXP (comparison, 1)); > + create_convert_operand_from (&ops[5], len_rtx, TYPE_MODE (TREE_TYPE (len)), > + TYPE_UNSIGNED (TREE_TYPE (len))); > + create_input_operand (&ops[6], bias_rtx, QImode); > + expand_insn (icode, 7, ops); > + assign_call_lhs (lhs, lhs_rtx, &ops[0]); > +} > diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def > index daf716f1ba143012e7036020dc9e5d126916df30..de03f8a382e06cdb7614e562aaf0f3c18dbc9207 100644 > --- a/gcc/internal-fn.def > +++ b/gcc/internal-fn.def > @@ -578,6 +578,10 @@ DEF_INTERNAL_FN (VA_ARG, ECF_NOTHROW | ECF_LEAF, NULL) > DEF_INTERNAL_FN (VEC_CONVERT, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL) > DEF_INTERNAL_FN (RAWMEMCHR, ECF_PURE | ECF_LEAF | ECF_NOTHROW, NULL) > > +/* Conditional vector comparisons. These use custom expansions. */ > +DEF_INTERNAL_FN (COND_VEC_CMP, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL) > +DEF_INTERNAL_FN (COND_LEN_VEC_CMP, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL) > + > /* An unduplicable, uncombinable function. Generally used to preserve > a CFG property in the face of jump threading, tail merging or > other such optimizations. The first argument distinguishes > diff --git a/gcc/internal-fn.h b/gcc/internal-fn.h > index 30930f388b069ca98167f0911c62681143979327..ac3a35eef62663267dd7ed8c749d02154208486b 100644 > --- a/gcc/internal-fn.h > +++ b/gcc/internal-fn.h > @@ -288,6 +288,11 @@ extern void expand_PARITY (internal_fn, gcall *); > extern void expand_POPCOUNT (internal_fn, gcall *); > extern void expand_BSWAP (internal_fn, gcall *); > extern void expand_BITREVERSE (internal_fn, gcall *); > +extern void expand_COND_VEC_CMP (internal_fn, gcall *); > +extern void expand_COND_LEN_VEC_CMP (internal_fn, gcall *); > + > +extern bool expand_cond_vec_cmp_p (tree_code, tree, tree, tree); > +extern bool expand_cond_len_vec_cmp_p (tree_code, tree, tree, tree, tree, tree); > > extern bool vectorized_internal_fn_supported_p (internal_fn, tree); > > diff --git a/gcc/optabs.def b/gcc/optabs.def > index 79751e28d9531620c01bb85f7bdb4a01c7e138a3..26748cd4fbbf2a6aa9fc23ba896dd4e368f6bca1 100644 > --- a/gcc/optabs.def > +++ b/gcc/optabs.def > @@ -99,6 +99,8 @@ OPTAB_CD(vcond_mask_optab, "vcond_mask_$a$b") > OPTAB_CD(vec_cmp_optab, "vec_cmp$a$b") > OPTAB_CD(vec_cmpu_optab, "vec_cmpu$a$b") > OPTAB_CD(vec_cmpeq_optab, "vec_cmpeq$a$b") > +OPTAB_CD(cond_vec_cmp_optab, "cond_vec_cmp$a$b") > +OPTAB_CD(cond_len_vec_cmp_optab, "cond_len_vec_cmp$a$b") > OPTAB_CD(maskload_optab, "maskload$a$b") > OPTAB_CD(maskstore_optab, "maskstore$a$b") > OPTAB_CD(mask_len_load_optab, "mask_len_load$a$b") > > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From schwab@suse.de Mon Nov 2 12:19:14 2026 From: schwab@suse.de (Andreas Schwab) Date: Mon, 02 Nov 2026 13:19:14 +0100 Subject: [pushed: r17-5669] analyzer: add analyzer-graphs=yes|no option to SARIF output In-Reply-To: <5b109a8298ec57c47a18752ce5942b7a99d5a81a.camel@redhat.com> References: <20261028150205.3705520-1-dmalcolm@redhat.com> <5b109a8298ec57c47a18752ce5942b7a99d5a81a.camel@redhat.com> Message-ID: On Okt 30 2026, David Malcolm wrote: > Sorry about the breakage. Does the attached patch fix things for you? Yes, it does. -- Andreas Schwab, SUSE Labs, schwab@suse.de From rguenther@suse.de Mon Nov 2 12:24:44 2026 From: rguenther@suse.de (Richard Biener) Date: Mon, 2 Nov 2026 13:24:44 +0100 (CET) Subject: [patch v2 8/14]middle-end: allow vector branches to consume conditional compare IFNs In-Reply-To: References: Message-ID: <60p29q24-n579-17s9-8805-1qq80767n685@fhfr.qr> On Thu, 22 Oct 2026, Tamar Christina wrote: > This patch lets vector branches consume the conditional compare IFNs added > earlier in the series. > > The IFNs need to survive long enough for branch expansion to see them, so the > patch marks the selected internal calls as TER-replaceable. It then teaches > emit_cmp_and_jump_insns to look through IFN_COND_VEC_CMP and > IFN_COND_LEN_VEC_CMP definitions when expanding vector conditions. > > For example, this source: > > int any_gt (int *a, int *b, int n) > { > for (int i = 0; i < n; ++i) > if (a[i] > b[i]) > return i; > return 0; > } > > Before this patch the tree-outof-ssa changes would fail as the new IFNs aren't > TER-able, mainly due to them not being standard optabs. Normally > direct_internal_fn_p is enough to consider an optab available, but for > comparisons we have to perform more checks and so direct_internal_fn_p is not > enough. > > That means the IFNs fail the check in ssa_is_replaceable_p. This adds a promise > essentially that if you see the IFN in the IL then the producer has checked it > and it's TER safe. > > This then updates the vec_cbranch_* code to support the new COND_* IFNs. > Without this we regress codegen to > > cmpgt p1.s, p0/z, z0.s, z1.s > ptest p0, p1.b > b.ne .Lhit > > and after this patch, branch expansion can see the compare IFN directly and pass > the original compare through the normal target compare-and-branch machinery: > > cmpgt p1.s, p0/z, z0.s, z1.s > b.any .Lhit > > For the length-controlled form, branch expansion preserves both the governing > mask and the length and bias. The existing vec_cbranch tests cover this path. > > Bootstrapped Regtested on aarch64-none-linux-gnu, > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > -m32, -m64 and no issues. > > -O3, profiled, profiled -O3 and -O3 -LTO bootstrap tested and no issues. > > Also SPECCPU 2017 and SPECCPU 2026 tested. > > OK for master? > gcc/ChangeLog: > > * internal-fn.cc (ter_replaceable_internal_fn_p): New function. > * internal-fn.h (ter_replaceable_internal_fn_p): Declare. > * optabs.cc (emit_cmp_and_jump_insns): Handle IFN_COND_VEC_CMP and > IFN_COND_LEN_VEC_CMP definitions. Preserve both the mask and length > when selecting length-controlled vector branches. Remove redundant > unsigned-condition conversion. > * tree-outof-ssa.cc (ssa_is_replaceable_p): Allow selected internal > calls that are not direct internal functions. > * tree-ssa-ter.cc: Include internal-fn.h. > (find_replaceable_in_bb): Do not count TER-replaceable internal > functions as calls. > > --- > diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc > index 99821efb9e9cdc9285b3af6bb681baf9dc97033e..e48fe4a497cbf0bfe3100946214c2a42db579d4b 100644 > --- a/gcc/internal-fn.cc > +++ b/gcc/internal-fn.cc > @@ -5693,6 +5693,28 @@ vectorized_internal_fn_supported_p (internal_fn ifn, tree type) > return false; > } > > +/* Return true if STMT is an internal function that has no side effects, does > + not clobber registers and will be expanded to a non-library call. */ > + > +bool ter_replaceable_internal_fn_p (gimple *stmt) > +{ > + if (!is_gimple_call (stmt) > + || !gimple_call_internal_p (stmt)) > + return false; > + > + switch (gimple_call_internal_fn (stmt)) > + { > + case IFN_COND_VEC_CMP: > + case IFN_COND_LEN_VEC_CMP: > + return true; > + > + default: > + return false; > + } > + > + return false; > +} > + > void > expand_SHUFFLEVECTOR (internal_fn, gcall *) > { > diff --git a/gcc/internal-fn.h b/gcc/internal-fn.h > index ac3a35eef62663267dd7ed8c749d02154208486b..8253f515b0fc46ccbf7486274791c4ea9bf38b9c 100644 > --- a/gcc/internal-fn.h > +++ b/gcc/internal-fn.h > @@ -295,6 +295,7 @@ extern bool expand_cond_vec_cmp_p (tree_code, tree, tree, tree); > extern bool expand_cond_len_vec_cmp_p (tree_code, tree, tree, tree, tree, tree); > > extern bool vectorized_internal_fn_supported_p (internal_fn, tree); > +extern bool ter_replaceable_internal_fn_p (gimple *); > > enum { > ATOMIC_OP_FETCH_CMP_0_EQ = 0, > diff --git a/gcc/optabs.cc b/gcc/optabs.cc > index a7988e0c26c992419871b97a157504e2d96ab434..5b34938e5e9896667c00cc77de0d1948a3fb19cd 100644 > --- a/gcc/optabs.cc > +++ b/gcc/optabs.cc > @@ -5041,61 +5041,83 @@ emit_cmp_and_jump_insns (rtx x, rtx y, enum rtx_code comparison, rtx size, > > enum insn_code icode; > if (def_stmt > - && is_gimple_assign (def_stmt) > - && TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)) > - == tcc_comparison) > + && ((is_gimple_assign (def_stmt) > + && TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)) > + == tcc_comparison) > + || gimple_call_internal_p (def_stmt, IFN_COND_VEC_CMP) > + || gimple_call_internal_p (def_stmt, IFN_COND_LEN_VEC_CMP))) > { > class expand_operand ops[5]; > rtx_insn *tmp = NULL; > start_sequence (); > - tree t_op0 = gimple_assign_rhs1 (def_stmt); > - tree t_op1 = gimple_assign_rhs2 (def_stmt); > + tree t_op0, t_op1; > + tree_code inner_code; > + if (is_gimple_call (def_stmt)) > + { > + t_op0 = gimple_call_arg (def_stmt, 2); > + t_op1 = gimple_call_arg (def_stmt, 3); > + tree code_arg = gimple_call_arg (def_stmt, 0); > + inner_code = (tree_code) tree_to_uhwi (code_arg); > + } > + else > + { > + t_op0 = gimple_assign_rhs1 (def_stmt); > + t_op1 = gimple_assign_rhs2 (def_stmt); > + inner_code = gimple_assign_rhs_code (def_stmt); > + } > rtx op0c = expand_normal (t_op0); > rtx op1c = expand_normal (t_op1); > machine_mode mode2 = GET_MODE (op0c); > > - int nops = masked_op ? 3 : (len_op ? 5 : 2); > + int nops = len_op ? 5 : (masked_op ? 3 : 2); > int offset = masked_op || len_op ? 1 : 0; > create_input_operand (&ops[offset + 0], op0c, mode2); > create_input_operand (&ops[offset + 1], op1c, mode2); > - if (masked_op) > - { > - auto mask_mode = TYPE_MODE (TREE_TYPE (masked_op)); > - rtx mask_op = expand_normal (masked_op); > - create_input_operand (&ops[0], mask_op, mask_mode); > - } > - else if (len_op) > + if (len_op) > { > + machine_mode mask_mode; > + rtx mask_op; > rtx len_rtx = expand_normal (len_op); > rtx len_bias_rtx = expand_normal (len_bias); > - tree lhs = gimple_get_lhs (def_stmt); > - auto mask_mode = TYPE_MODE (TREE_TYPE (lhs)); > + if (masked_op) > + { > + mask_mode = TYPE_MODE (TREE_TYPE (masked_op)); > + mask_op = expand_normal (masked_op); > + } > + else > + { > + tree lhs = gimple_get_lhs (def_stmt); > + mask_mode = TYPE_MODE (TREE_TYPE (lhs)); > + mask_op = CONSTM1_RTX (mask_mode); > + } > /* ??? We could use something like internal_fn's > add_mask_else_and_len_args here. Currently it > only supports a fixed, consecutive order of > mask and len, though. */ > - create_input_operand (&ops[0], CONSTM1_RTX (mask_mode), > - mask_mode); > + create_input_operand (&ops[0], mask_op, mask_mode); > create_convert_operand_from > (&ops[3], len_rtx, TYPE_MODE (TREE_TYPE (len_op)), > TYPE_UNSIGNED (TREE_TYPE (len_op))); > create_input_operand (&ops[4], len_bias_rtx, QImode); > } > + else if (masked_op) > + { > + auto mask_mode = TYPE_MODE (TREE_TYPE (masked_op)); > + rtx mask_op = expand_normal (masked_op); > + create_input_operand (&ops[0], mask_op, mask_mode); > + } > > int unsignedp2 = TYPE_UNSIGNED (TREE_TYPE (t_op0)); > - auto inner_code = gimple_assign_rhs_code (def_stmt); > rtx test2 = NULL_RTX; > > enum rtx_code comparison2 = get_rtx_code (inner_code, unsignedp2); > - if (unsignedp2) > - comparison2 = unsigned_condition (comparison2); > if (comparison == NE) > - optab = masked_op ? cond_vec_cbranch_any_optab > - : len_op ? cond_len_vec_cbranch_any_optab > + optab = len_op ? cond_len_vec_cbranch_any_optab > + : masked_op ? cond_vec_cbranch_any_optab > : vec_cbranch_any_optab; > else > - optab = masked_op ? cond_vec_cbranch_all_optab > - : len_op ? cond_len_vec_cbranch_all_optab > + optab = len_op ? cond_len_vec_cbranch_all_optab > + : masked_op ? cond_vec_cbranch_all_optab > : vec_cbranch_all_optab; > > if ((icode = optab_handler (optab, mode2)) > diff --git a/gcc/tree-outof-ssa.cc b/gcc/tree-outof-ssa.cc > index c59c080383195d6ad96d9cc09090ad0ce6245703..80176fc9d35ea766997055d59fe081d3f6dbaf0a 100644 > --- a/gcc/tree-outof-ssa.cc > +++ b/gcc/tree-outof-ssa.cc > @@ -72,7 +72,8 @@ ssa_is_replaceable_p (gimple *stmt) > && (!(call = dyn_cast (stmt)) > || gimple_call_tail_p (call) > || !gimple_call_internal_p (call) > - || !direct_internal_fn_p (gimple_call_internal_fn (call)))) > + || (!direct_internal_fn_p (gimple_call_internal_fn (call)) > + && !ter_replaceable_internal_fn_p (call)))) this does seem to be at the wrong abstraction level somehow given ... > return false; > > /* If the statement may throw an exception, it cannot be replaced. */ > diff --git a/gcc/tree-ssa-ter.cc b/gcc/tree-ssa-ter.cc > index 8dc26aa1907cbf25ee00b6cad524a0963a2b8839..5d6ccbb589e427f47d0392672bf1b3c41925671f 100644 > --- a/gcc/tree-ssa-ter.cc > +++ b/gcc/tree-ssa-ter.cc > @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see > #include "tree-ssa-ter.h" > #include "tree-outof-ssa.h" > #include "gimple-walk.h" > +#include "internal-fn.h" > > > /* Temporary Expression Replacement (TER) > @@ -686,6 +687,7 @@ find_replaceable_in_bb (temp_expr_table *tab, basic_block bb) > replacement over BUILT_IN calls since many will expand to inline > insns instead of a true call. */ > if (is_gimple_call (stmt) > + && !ter_replaceable_internal_fn_p (stmt) ... we don't check this in ter_is_replaceable_p, wo I'm not sure what you do is enough. It also seems this place should check direct_internal_fn_p as well (a pre-existing issue). Just adding && !ter_replaceable_internal_fn_p makes this feel inconsistent. Richard. > && !((fndecl = gimple_call_fndecl (stmt)) > && fndecl_built_in_p (fndecl))) > cur_call_cnt++; > > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From rguenther@suse.de Mon Nov 2 12:37:41 2026 From: rguenther@suse.de (Richard Biener) Date: Mon, 2 Nov 2026 13:37:41 +0100 (CET) Subject: [patch v2 9/14][isel]: form conditional vector compare IFNs In-Reply-To: References: Message-ID: On Thu, 22 Oct 2026, Tamar Christina wrote: > This patch forms conditional vector compare IFNs during gimple isel. > > The match.pd rules recognize integer vector compare idioms where a compare is > guarded by another vector predicate. gimple isel then lowers those idioms to > IFN_COND_VEC_CMP or IFN_COND_LEN_VEC_CMP when the target reports support for the > corresponding optab. If the original compare was only used by the converted > statement, the patch removes that now-dead definition. > > The tests for this lowering are kept with the later AArch64 SVE expander patch, > since they require the SVE cond_vec_cmp target support added there. > > Bootstrapped Regtested on aarch64-none-linux-gnu, > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > -m32, -m64 and no issues. > > -O3, profiled, profiled -O3 and -O3 -LTO bootstrap tested and no issues. > > Also SPECCPU 2017 and SPECCPU 2026 tested. > > OK for master? If you are here, can you expand the IFN_VCOND_MASK[_LEN] docs in doc/ifn.texi? Also ... > gcc/ChangeLog: > > * gimple-isel.cc (gimple_convert_conditional_compare): Declare. > (gimple_convert_conditional_len_compare): Likewise. > (maybe_duplicate_comparison): Fix comment. > (gimple_expand_conditional_compare): New function. Form conditional > vector compare IFNs when supported and identify a dead original > comparison for removal. > (pass_gimple_isel::execute): Use it and remove the original comparison > when it has no remaining uses. > * match.pd (convert_conditional_compare): New match for masked > non-floating-point vector comparisons. > (convert_conditional_len_compare): New match for length-masked > non-floating-point vector comparisons. > > --- > diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc > index 1d346ee124ffdfdccf658ea79cc72cbf80240f81..9bd523cd81be541383ea9c962a9180565cea9f0d 100644 > --- a/gcc/gimple-isel.cc > +++ b/gcc/gimple-isel.cc > @@ -327,8 +327,8 @@ maybe_duplicate_comparison (gassign *stmt, basic_block bb) > tree lhs = gimple_assign_lhs (stmt); > unsigned cnt = 0; > > - /* This is should not be used for -O0 nor it is not useful > - when ter is turned off. */ > + /* This should not be used for -O0 and is not useful when TER is turned > + off. */ > if (!optimize || !flag_tree_ter) > return; > > @@ -376,6 +376,9 @@ maybe_duplicate_comparison (gassign *stmt, basic_block bb) > extern bool gimple_nop_atomic_bit_test_and_p (tree, tree *, > tree (*) (tree)); > extern bool gimple_nop_convert (tree, tree*, tree (*) (tree)); > +extern bool gimple_convert_conditional_compare (tree, tree *, tree (*) (tree)); > +extern bool gimple_convert_conditional_len_compare (tree, tree *, > + tree (*) (tree)); > > namespace { > > @@ -488,6 +491,74 @@ convert_atomic_bit_not (enum internal_fn fn, gimple *use_stmt, > return use_stmt; > } > > +/* Try to replace STMT with a conditional vector comparison internal function. > + The generated matchers recognize the source patterns and capture the mask, > + operands and original comparison SSA name. If the original comparison is > + used only by STMT, store its defining statement in *DEAD_CMP_DEF so that the > + caller can remove it after replacing STMT. */ > + > +static gimple * > +gimple_expand_conditional_compare (gimple_stmt_iterator *gsi, > + gassign **dead_cmp_def) > +{ > + gimple *stmt = gsi_stmt (*gsi); > + *dead_cmp_def = nullptr; > + tree lhs = gimple_get_lhs (stmt); > + > + if (!lhs || TREE_CODE (lhs) != SSA_NAME) > + return nullptr; > + > + tree ops[6] = {}; > + location_t loc = gimple_location (stmt); > + bool len_p = false; > + if (!gimple_convert_conditional_compare (lhs, ops, nullptr) > + && !gimple_convert_conditional_len_compare (lhs, ops, nullptr)) > + return nullptr; > + len_p = ops[4] != NULL_TREE; > + > + unsigned int cmp_opno = len_p ? 5 : 3; > + tree cmp_name = ops[cmp_opno]; > + if (TREE_CODE (cmp_name) != SSA_NAME) > + return nullptr; > + > + gassign *cmp_def = dyn_cast (SSA_NAME_DEF_STMT (cmp_name)); > + if (!cmp_def) > + return nullptr; > + > + tree_code code = gimple_assign_rhs_code (cmp_def); > + if (TREE_CODE_CLASS (code) != tcc_comparison) > + return nullptr; > + > + internal_fn ifn = len_p ? IFN_COND_LEN_VEC_CMP : IFN_COND_VEC_CMP; > + bool supported_p > + = (len_p > + ? expand_cond_len_vec_cmp_p (code, ops[0], ops[1], ops[2], > + ops[3], ops[4]) > + : expand_cond_vec_cmp_p (code, ops[0], ops[1], ops[2])); > + if (!supported_p) > + return nullptr; > + > + auto_vec args; > + args.quick_push (build_int_cst (integer_type_node, code)); > + args.quick_push (ops[0]); > + args.quick_push (ops[1]); > + args.quick_push (ops[2]); > + if (len_p) > + { > + args.quick_push (ops[3]); > + args.quick_push (ops[4]); > + } > + > + gcall *call = gimple_build_call_internal_vec (ifn, args); > + gimple_call_set_lhs (call, lhs); > + gimple_set_location (call, loc); > + use_operand_p use_p; > + gimple *use_stmt; > + if (single_imm_use (cmp_name, &use_p, &use_stmt) && use_stmt == stmt) > + *dead_cmp_def = cmp_def; > + return call; > +} > + > /* Optimize > mask_2 = 1 << cnt_1; > _4 = __atomic_fetch_or_* (ptr_6, mask_2, _3); > @@ -1369,6 +1440,20 @@ pass_gimple_isel::execute (struct function *fun) > /* Give the target first try at replacing the instruction. */ > cfg_changed |= targetm.instruction_selection (fun, &gsi); > > + gimple *isel_stmt = NULL; > + gassign *dead_cmp_def = NULL; > + if (!gsi_end_p (gsi)) > + isel_stmt = gimple_expand_conditional_compare (&gsi, &dead_cmp_def); > + if (isel_stmt) > + { > + gsi_replace (&gsi, isel_stmt, true); > + if (dead_cmp_def) > + { > + gimple_stmt_iterator cmp_gsi = gsi_for_stmt (dead_cmp_def); > + gsi_remove (&cmp_gsi, true); > + } > + } > + You are adding this before we generate .VCOND_MASK? Please wrap the thing into a function wrapping gimple_expand_conditional_compare. I'm not exactly happy with the "driver" of ISEL and the uncommon interface to how workers leave 'gsi' ... > /* Pre-expand VEC_COND_EXPRs to .VCOND* internal function > calls mapping to supported optabs. */ > gimple *g = gimple_expand_vec_cond_expr (&gsi); > @@ -1411,4 +1496,3 @@ make_pass_gimple_isel (gcc::context *ctxt) > { > return new pass_gimple_isel (ctxt); > } > - > diff --git a/gcc/match.pd b/gcc/match.pd > index f3d9e55f1390ab4185b3dff1f59d60e10b138cb4..4557dccad60c02fe821b390752bfefa14209bceb 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -13782,4 +13782,17 @@ and, > || (minmax == MAX_EXPR > && wi::le_p (wi::to_wide (@1), bound, TYPE_SIGN (type)))) > @3))))) > + > +(match (convert_conditional_compare @0 @1 @2 @3) > + (bit_and:c @0 (tcc_comparison@3 @1 @2)) > + (if (VECTOR_BOOLEAN_TYPE_P (type) > + && !FLOAT_TYPE_P (TREE_TYPE (@1))))) this isn't equal to .VCOND_CMP as it will mask IEEE exceptions from masked compares, so it would need -fno-trapping-math, correct? > + > +/* Transform .VCOND_MASK_LEN (a `cmp` b, {-1, ...}, {0, ...}, len, bias) > + into cond_len_vec_cmp (cmp, {-1, ...}, a, b, len, bias). */ Same here? Why not .VCOND_MASK as well? > +(match (convert_conditional_len_compare @0 @1 @2 @3 @4 @5) > + (IFN_VCOND_MASK_LEN (tcc_comparison@5 @1 @2) > + integer_minus_onep@0 integer_zerop @3 @4) > + (if (VECTOR_BOOLEAN_TYPE_P (type) > + && !FLOAT_TYPE_P (TREE_TYPE (@1))))) > #endif > > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From josef.melcr@suse.com Mon Nov 2 12:39:21 2026 From: josef.melcr@suse.com (Josef Melcr) Date: Mon, 2 Nov 2026 13:39:21 +0100 Subject: [PATCH] ipa: Add callback edges without carrying edges to call_site_hash [PR128226] Message-ID: <20261102123921.60621-1-josef.melcr@suse.com> Hi, this patch fixes an ICE reported as PR128226. If a function has many calls, but not enough to cross the call_site_hash creation threshold and was brought over this threshold with callback edges, the previously created callback edges wouldn't be added to call_site_hash. This was intentional up until the addition of internal callback edges, as we want to hash their carrying edge instead. However, in the case of internal callbacks, the callback edge is the only one (and hence the right one) to hash. Because of the early return, the slot would be empty, leading to an ICE during ipa-fnsummary. This patch changes the check to only act on callbacks with carrying edges. The testcase in the PR is really convoluted and doesn't showcase the issue in my opinion, so I came up with the testcase in the patch. It's the best I could come up with, even though it's a bit unusual. Bootstrapped and regtested on x86_64-linux with no new regressions. OK for master? Best regards, Josef -- >8 -- This patch fixes the early return in cgraph_add_edge_to_call_site_hash for internal callback edges. Callback edges are created much later than other callgraph edges. If the function doesn't have its call_site_hash yet, the creation of callback edges can bring it over the threshold and trigger the call_site_hash's construction. However, callback edges created prior to crossing the threshold (i.e. callback edges constructed in the first 100 edges) won't be added to the call_site_hash due to the early return. This is actually the desired behavior for regular callback edges, as we want to hash their carrying edges instead. The trouble arises for the recently added internal callback edges, as they don't have a carrying edge, leaving the slot empty. In their case, the callback edge is actually the correct one to hash. This can lead to segfaults when fetching the edge after call_site_hash's construction, as is the case for PR128226. This patch fixes the early return to only apply to callback edges with carrying edges. The original testcase is long, complicated and doesn't demonstrate the problem well, so I've created this one instead. PR ipa/128226 gcc/ChangeLog: * cgraph.cc (cgraph_add_edge_to_call_site_hash): Only skip callback edges with carrying edges. gcc/testsuite/ChangeLog: * g++.dg/ipa/pr128226.C: New test. Signed-off-by: Josef Melcr Assisted-by: Claude Opus 5.5 --- gcc/cgraph.cc | 8 ++++---- gcc/testsuite/g++.dg/ipa/pr128226.C | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ipa/pr128226.C diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc index 3448bc37714..748fe579a22 100644 --- a/gcc/cgraph.cc +++ b/gcc/cgraph.cc @@ -870,10 +870,10 @@ cgraph_add_edge_to_call_site_hash (cgraph_edge *e) one indirect); always hash the direct one. */ if (e->speculative && e->indirect_unknown_callee) return; - /* We always want to hash the carrying edge of a callback, not the edges - pointing to the callbacks themselves, as their call statement doesn't - exist. */ - if (e->callback) + /* Callback edges share the call statement of the carrying edge, so hash + the carrying edge instead. Internal callback edges have no carrying + edge, so hash the callback edge directly. */ + if (e->callback_with_carrying_edge_p ()) return; cgraph_edge **slot = e->caller->call_site_hash->find_slot_with_hash (e->call_stmt, cgraph_edge_hasher::hash (e->call_stmt), INSERT); diff --git a/gcc/testsuite/g++.dg/ipa/pr128226.C b/gcc/testsuite/g++.dg/ipa/pr128226.C new file mode 100644 index 00000000000..ec5f437500f --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr128226.C @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +/* The 100 calls alone do not cross the call_site_hash construction threshold + in cgraph_node::get_edge, but together with the internal callback edges + created for the assumes, they do. We are testing whether the internal + callback edges are added to call_site_hash. */ + +#define CALL(x) (x) () +#define CALL5(x) CALL (x), CALL (x), CALL (x), CALL (x), CALL (x) +#define CALL25(x) CALL5 (x), CALL5 (x), CALL5 (x), CALL5 (x), CALL5 (x) +#define CALL100(x) CALL25 (x), CALL25 (x), CALL25 (x), CALL25 (x) + +bool foo (); + +void +bar () +{ + __attribute__ ((assume (foo ()))); + __attribute__ ((assume (foo ()))); + CALL100 (foo); +} -- 2.56.0 From jwakely@redhat.com Mon Nov 2 12:41:08 2026 From: jwakely@redhat.com (Jonathan Wakely) Date: Mon, 2 Nov 2026 12:41:08 +0000 Subject: [PATCH 1/3] libstdc++: Fix buffer overflow in basic_filebuf::overflow [PR118099] In-Reply-To: References: <20261023174023.845748-1-jwakely@redhat.com> Message-ID: On Mon, 2 Nov 2026 at 12:12, Tomasz Kaminski wrote: > > > > On Fri, Oct 23, 2026 at 8:09?PM Jonathan Wakely wrote: >> >> On Fri, 23 Oct 2026 at 18:44, Jonathan Wakely wrote: >> > >> > On Fri, 23 Oct 2026 at 18:40, Jonathan Wakely wrote: >> > > >> > > From: Peter Edwards >> > > >> > > If we fail to write the content of the buffer after inserting the >> > > overflow character into the end of it, then remove that overflow >> > > character before propagating the error back to the caller. Without this, >> > > the caller is left with pptr set past epptr, and successive calls to >> > > overflow will write further past the end of the managed buffer with each >> > > failure. >> > > >> > > libstdc++-v3/ChangeLog: >> > > >> > > PR libstdc++/118099 >> > > * include/bits/fstream.tcc (basic_filebuf::overflow): Rewind the >> > > put position if outputting the put area fails. >> > > * testsuite/27_io/basic_filebuf/overflow/char/118099.cc: New >> > > test. >> > > * testsuite/27_io/basic_filebuf/overflow/wchar_t/118099.cc: >> > > New test. >> > > >> > > Co-authored-by: Jonathan Wakely >> > > --- >> > > >> > > Tested x86_64-linux. >> > >> > I forgot to say: >> > [PATCH 1/3] should be backported to active branches. >> > [PATCH 2/3] is doesn't need to be backported since it only fixes a >> > hypothetical problem. >> > [PATCH 3/3] is not suitable for backporting, but the bug can be fixed >> > with a try-catch around the call to _M_convert_to_external. >> >> Or we could do this for the branches, which would fix the >> non-hypothetical problems (and tests) fixed by PATCH 1/3 and 3/3: > > I would use solution below for all branches (including trunk), so the backports > are cherry-picked. > > With that and one small suggestion for test LGTM >> >> >> --- a/libstdc++-v3/include/bits/fstream.tcc >> +++ b/libstdc++-v3/include/bits/fstream.tcc >> @@ -561,11 +561,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >> } >> if (this->pbase() < this->pptr()) >> { >> + struct _Guard { >> + ~_Guard() { if (_M_p) _M_p->pbump(-1); } >> + basic_filebuf* _M_p; >> + }; >> + _Guard __g = { }; >> + >> // If appropriate, append the overflow char. >> if (!__testeof) >> { >> *this->pptr() = traits_type::to_char_type(__c); >> this->pbump(1); >> + __g._M_p = this; >> } >> >> // Convert pending sequence to external representation, >> @@ -573,6 +580,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >> if (_M_convert_to_external(this->pbase(), >> this->pptr() - this->pbase())) >> { >> + __g._M_p = 0; >> _M_set_buffer(0); >> __ret = traits_type::not_eof(__c); >> } >> >> >> For trunk I would still like to do the larger refactoring so that we >> avoid advancing then conditionally rewinding the next pointer, and the >> changes to _M_convert_to_external make it simpler IMHO. > > Agreed, the PATCH 3/3 can then remove _Guard, but will need to have message > adjusted, to say it is refactoring/simplification. So add the _Guard as patch 0, so there are four patches on trunk, and then only backport the patch 0 to the branches. That makes sense. > In the new test, I would prefer that instead of : > + bool got_eof = false; > + for (int i = 0; i < N; ++i) > + if (fb.sputc(val) == std::char_traits::eof()) > + got_eof = true; > + VERIFY( got_eof ); // the error path was actually taken > We will do the following > for (int i = 0; i < N/2; ++i) > VERIFY( fb.sputc(val) != std::char_traits::eof()) > for (int i = N/2; i < N; ++i) > VERIFY( fb.sputc(val) == std::char_traits::eof()) Yes, that's better. From Tamar.Christina@arm.com Mon Nov 2 12:41:04 2026 From: Tamar.Christina@arm.com (Tamar Christina) Date: Mon, 2 Nov 2026 12:41:04 +0000 Subject: [patch v2 8/14]middle-end: allow vector branches to consume conditional compare IFNs In-Reply-To: <60p29q24-n579-17s9-8805-1qq80767n685@fhfr.qr> References: <60p29q24-n579-17s9-8805-1qq80767n685@fhfr.qr> Message-ID: > -----Original Message----- > From: Richard Biener > Sent: 02 November 2026 12:25 > To: Tamar Christina > Cc: gcc-patches@gcc.gnu.org; nd > Subject: Re: [patch v2 8/14]middle-end: allow vector branches to consume > conditional compare IFNs > > On Thu, 22 Oct 2026, Tamar Christina wrote: > > > This patch lets vector branches consume the conditional compare IFNs > added > > earlier in the series. > > > > The IFNs need to survive long enough for branch expansion to see them, so > the > > patch marks the selected internal calls as TER-replaceable. It then teaches > > emit_cmp_and_jump_insns to look through IFN_COND_VEC_CMP and > > IFN_COND_LEN_VEC_CMP definitions when expanding vector conditions. > > > > For example, this source: > > > > int any_gt (int *a, int *b, int n) > > { > > for (int i = 0; i < n; ++i) > > if (a[i] > b[i]) > > return i; > > return 0; > > } > > > > Before this patch the tree-outof-ssa changes would fail as the new IFNs > aren't > > TER-able, mainly due to them not being standard optabs. Normally > > direct_internal_fn_p is enough to consider an optab available, but for > > comparisons we have to perform more checks and so direct_internal_fn_p is > not > > enough. > > > > That means the IFNs fail the check in ssa_is_replaceable_p. This adds a > promise > > essentially that if you see the IFN in the IL then the producer has checked it > > and it's TER safe. > > > > This then updates the vec_cbranch_* code to support the new COND_* > IFNs. > > Without this we regress codegen to > > > > cmpgt p1.s, p0/z, z0.s, z1.s > > ptest p0, p1.b > > b.ne .Lhit > > > > and after this patch, branch expansion can see the compare IFN directly and > pass > > the original compare through the normal target compare-and-branch > machinery: > > > > cmpgt p1.s, p0/z, z0.s, z1.s > > b.any .Lhit > > > > For the length-controlled form, branch expansion preserves both the > governing > > mask and the length and bias. The existing vec_cbranch tests cover this > path. > > > > Bootstrapped Regtested on aarch64-none-linux-gnu, > > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > > -m32, -m64 and no issues. > > > > -O3, profiled, profiled -O3 and -O3 -LTO bootstrap tested and no issues. > > > > Also SPECCPU 2017 and SPECCPU 2026 tested. > > > > OK for master? > > > > > gcc/ChangeLog: > > > > * internal-fn.cc (ter_replaceable_internal_fn_p): New function. > > * internal-fn.h (ter_replaceable_internal_fn_p): Declare. > > * optabs.cc (emit_cmp_and_jump_insns): Handle > IFN_COND_VEC_CMP and > > IFN_COND_LEN_VEC_CMP definitions. Preserve both the mask and > length > > when selecting length-controlled vector branches. Remove redundant > > unsigned-condition conversion. > > * tree-outof-ssa.cc (ssa_is_replaceable_p): Allow selected internal > > calls that are not direct internal functions. > > * tree-ssa-ter.cc: Include internal-fn.h. > > (find_replaceable_in_bb): Do not count TER-replaceable internal > > functions as calls. > > > > --- > > diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc > > index > 99821efb9e9cdc9285b3af6bb681baf9dc97033e..e48fe4a497cbf0bfe31009 > 46214c2a42db579d4b 100644 > > --- a/gcc/internal-fn.cc > > +++ b/gcc/internal-fn.cc > > @@ -5693,6 +5693,28 @@ vectorized_internal_fn_supported_p > (internal_fn ifn, tree type) > > return false; > > } > > > > +/* Return true if STMT is an internal function that has no side effects, does > > + not clobber registers and will be expanded to a non-library call. */ > > + > > +bool ter_replaceable_internal_fn_p (gimple *stmt) > > +{ > > + if (!is_gimple_call (stmt) > > + || !gimple_call_internal_p (stmt)) > > + return false; > > + > > + switch (gimple_call_internal_fn (stmt)) > > + { > > + case IFN_COND_VEC_CMP: > > + case IFN_COND_LEN_VEC_CMP: > > + return true; > > + > > + default: > > + return false; > > + } > > + > > + return false; > > +} > > + > > void > > expand_SHUFFLEVECTOR (internal_fn, gcall *) > > { > > diff --git a/gcc/internal-fn.h b/gcc/internal-fn.h > > index > ac3a35eef62663267dd7ed8c749d02154208486b..8253f515b0fc46ccbf748 > 6274791c4ea9bf38b9c 100644 > > --- a/gcc/internal-fn.h > > +++ b/gcc/internal-fn.h > > @@ -295,6 +295,7 @@ extern bool expand_cond_vec_cmp_p (tree_code, > tree, tree, tree); > > extern bool expand_cond_len_vec_cmp_p (tree_code, tree, tree, tree, tree, > tree); > > > > extern bool vectorized_internal_fn_supported_p (internal_fn, tree); > > +extern bool ter_replaceable_internal_fn_p (gimple *); > > > > enum { > > ATOMIC_OP_FETCH_CMP_0_EQ = 0, > > diff --git a/gcc/optabs.cc b/gcc/optabs.cc > > index > a7988e0c26c992419871b97a157504e2d96ab434..5b34938e5e9896667c0 > 0cc77de0d1948a3fb19cd 100644 > > --- a/gcc/optabs.cc > > +++ b/gcc/optabs.cc > > @@ -5041,61 +5041,83 @@ emit_cmp_and_jump_insns (rtx x, rtx y, enum > rtx_code comparison, rtx size, > > > > enum insn_code icode; > > if (def_stmt > > - && is_gimple_assign (def_stmt) > > - && TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)) > > - == tcc_comparison) > > + && ((is_gimple_assign (def_stmt) > > + && TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)) > > + == tcc_comparison) > > + || gimple_call_internal_p (def_stmt, IFN_COND_VEC_CMP) > > + || gimple_call_internal_p (def_stmt, > IFN_COND_LEN_VEC_CMP))) > > { > > class expand_operand ops[5]; > > rtx_insn *tmp = NULL; > > start_sequence (); > > - tree t_op0 = gimple_assign_rhs1 (def_stmt); > > - tree t_op1 = gimple_assign_rhs2 (def_stmt); > > + tree t_op0, t_op1; > > + tree_code inner_code; > > + if (is_gimple_call (def_stmt)) > > + { > > + t_op0 = gimple_call_arg (def_stmt, 2); > > + t_op1 = gimple_call_arg (def_stmt, 3); > > + tree code_arg = gimple_call_arg (def_stmt, 0); > > + inner_code = (tree_code) tree_to_uhwi (code_arg); > > + } > > + else > > + { > > + t_op0 = gimple_assign_rhs1 (def_stmt); > > + t_op1 = gimple_assign_rhs2 (def_stmt); > > + inner_code = gimple_assign_rhs_code (def_stmt); > > + } > > rtx op0c = expand_normal (t_op0); > > rtx op1c = expand_normal (t_op1); > > machine_mode mode2 = GET_MODE (op0c); > > > > - int nops = masked_op ? 3 : (len_op ? 5 : 2); > > + int nops = len_op ? 5 : (masked_op ? 3 : 2); > > int offset = masked_op || len_op ? 1 : 0; > > create_input_operand (&ops[offset + 0], op0c, mode2); > > create_input_operand (&ops[offset + 1], op1c, mode2); > > - if (masked_op) > > - { > > - auto mask_mode = TYPE_MODE (TREE_TYPE (masked_op)); > > - rtx mask_op = expand_normal (masked_op); > > - create_input_operand (&ops[0], mask_op, mask_mode); > > - } > > - else if (len_op) > > + if (len_op) > > { > > + machine_mode mask_mode; > > + rtx mask_op; > > rtx len_rtx = expand_normal (len_op); > > rtx len_bias_rtx = expand_normal (len_bias); > > - tree lhs = gimple_get_lhs (def_stmt); > > - auto mask_mode = TYPE_MODE (TREE_TYPE (lhs)); > > + if (masked_op) > > + { > > + mask_mode = TYPE_MODE (TREE_TYPE (masked_op)); > > + mask_op = expand_normal (masked_op); > > + } > > + else > > + { > > + tree lhs = gimple_get_lhs (def_stmt); > > + mask_mode = TYPE_MODE (TREE_TYPE (lhs)); > > + mask_op = CONSTM1_RTX (mask_mode); > > + } > > /* ??? We could use something like internal_fn's > > add_mask_else_and_len_args here. Currently it > > only supports a fixed, consecutive order of > > mask and len, though. */ > > - create_input_operand (&ops[0], CONSTM1_RTX > (mask_mode), > > - mask_mode); > > + create_input_operand (&ops[0], mask_op, mask_mode); > > create_convert_operand_from > > (&ops[3], len_rtx, TYPE_MODE (TREE_TYPE (len_op)), > > TYPE_UNSIGNED (TREE_TYPE (len_op))); > > create_input_operand (&ops[4], len_bias_rtx, QImode); > > } > > + else if (masked_op) > > + { > > + auto mask_mode = TYPE_MODE (TREE_TYPE (masked_op)); > > + rtx mask_op = expand_normal (masked_op); > > + create_input_operand (&ops[0], mask_op, mask_mode); > > + } > > > > int unsignedp2 = TYPE_UNSIGNED (TREE_TYPE (t_op0)); > > - auto inner_code = gimple_assign_rhs_code (def_stmt); > > rtx test2 = NULL_RTX; > > > > enum rtx_code comparison2 = get_rtx_code (inner_code, > unsignedp2); > > - if (unsignedp2) > > - comparison2 = unsigned_condition (comparison2); > > if (comparison == NE) > > - optab = masked_op ? cond_vec_cbranch_any_optab > > - : len_op ? cond_len_vec_cbranch_any_optab > > + optab = len_op ? cond_len_vec_cbranch_any_optab > > + : masked_op ? cond_vec_cbranch_any_optab > > : vec_cbranch_any_optab; > > else > > - optab = masked_op ? cond_vec_cbranch_all_optab > > - : len_op ? cond_len_vec_cbranch_all_optab > > + optab = len_op ? cond_len_vec_cbranch_all_optab > > + : masked_op ? cond_vec_cbranch_all_optab > > : vec_cbranch_all_optab; > > > > if ((icode = optab_handler (optab, mode2)) > > diff --git a/gcc/tree-outof-ssa.cc b/gcc/tree-outof-ssa.cc > > index > c59c080383195d6ad96d9cc09090ad0ce6245703..80176fc9d35ea7669970 > 55d59fe081d3f6dbaf0a 100644 > > --- a/gcc/tree-outof-ssa.cc > > +++ b/gcc/tree-outof-ssa.cc > > @@ -72,7 +72,8 @@ ssa_is_replaceable_p (gimple *stmt) > > && (!(call = dyn_cast (stmt)) > > || gimple_call_tail_p (call) > > || !gimple_call_internal_p (call) > > - || !direct_internal_fn_p (gimple_call_internal_fn (call)))) > > + || (!direct_internal_fn_p (gimple_call_internal_fn (call)) > > + && !ter_replaceable_internal_fn_p (call)))) > > this does seem to be at the wrong abstraction level somehow given ... > > > return false; > > > > /* If the statement may throw an exception, it cannot be replaced. */ > > diff --git a/gcc/tree-ssa-ter.cc b/gcc/tree-ssa-ter.cc > > index > 8dc26aa1907cbf25ee00b6cad524a0963a2b8839..5d6ccbb589e427f47d03 > 92672bf1b3c41925671f 100644 > > --- a/gcc/tree-ssa-ter.cc > > +++ b/gcc/tree-ssa-ter.cc > > @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see > > #include "tree-ssa-ter.h" > > #include "tree-outof-ssa.h" > > #include "gimple-walk.h" > > +#include "internal-fn.h" > > > > > > /* Temporary Expression Replacement (TER) > > @@ -686,6 +687,7 @@ find_replaceable_in_bb (temp_expr_table *tab, > basic_block bb) > > replacement over BUILT_IN calls since many will expand to inline > > insns instead of a true call. */ > > if (is_gimple_call (stmt) > > + && !ter_replaceable_internal_fn_p (stmt) > > ... we don't check this in ter_is_replaceable_p, wo I'm not sure > what you do is enough. > > It also seems this place should check direct_internal_fn_p as well > (a pre-existing issue). Just adding && !ter_replaceable_internal_fn_p > makes this feel inconsistent. I couldn't figure out why ssa_is_replaceable_p checks for direct_internal_fn_p If I'm honest, because the conditions it requires are not property of the way of expanding the IFN but rather properties of the definition of the IFN. i.e. not trapping, no VOPS etc. That's why the expansion code doesn't actually care because it calls expand_internal_call. Initially I was going to just remove it from ssa_is_replaceable_p, but wasn't sure. Do you know why it checks this? Thanks, Tamar > > Richard. > > > && !((fndecl = gimple_call_fndecl (stmt)) > > && fndecl_built_in_p (fndecl))) > > cur_call_cnt++; > > > > > > > > -- > Richard Biener > SUSE Software Solutions Germany GmbH, > Frankenstrasse 146, 90461 Nuernberg, Germany; > GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From rguenther@suse.de Mon Nov 2 12:44:57 2026 From: rguenther@suse.de (Richard Biener) Date: Mon, 2 Nov 2026 13:44:57 +0100 (CET) Subject: [patch v2 13/14]middle-end: fold vector extract across lane-preserving converts In-Reply-To: References: Message-ID: <42p601sp-r83r-504o-n5o3-9r8spp7875sq@fhfr.qr> On Thu, 22 Oct 2026, Tamar Christina wrote: > This patch adds a GIMPLE simplification for extracting the first or last active > element from a converted vector. If the conversion preserves the number of > lanes, the selected logical element is the same before and after the conversion, > so the middle end can extract from the original vector and convert the scalar > result instead. The fold also checks that the target supports extraction from > the source vector type. > > For example: > > float last_s32_to_f32 (int *restrict a, int *restrict b, > int *restrict c, int n) > { > float last = 0.0f; > for (int i = 0; i < n; ++i) > { > int x = a[i] + b[i]; > c[i] = x; > last = (float) x; > } > return last; > } > > Before this patch we generate with -O3 -march=armv8-a+sve: > > vect_last = (vector float) vect_x; > last = .EXTRACT_LAST_ACTIVE (loop_mask, vect_last); > > After this patch the extraction happens before the scalar conversion: > > tmp = .EXTRACT_LAST_ACTIVE (loop_mask, vect_x); > last = (float) tmp; > > With -O3 -march=armv8-a+sve this gives the expected SVE scalar extraction and > conversion sequence: > > add z30.s, z30.s, z31.s > st1w z30.s, p7, [x2, x4, lsl 2] > lastb s30, p6, z30.s > scvtf s0, s30 > > The idea is that usually a scalar convert is cheaper than vector converts and in > some cases, e.g. zero extensions not needed at all (on AArch64). > > Bootstrapped Regtested on aarch64-none-linux-gnu, > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > -m32, -m64 and no issues. > > -O3, profiled, profiled -O3 and -O3 -LTO bootstrap tested and no issues. > > Also SPECCPU 2017 and SPECCPU 2026 tested. > > OK for master? > > Thanks, > Tamar > > gcc/ChangeLog: > > * match.pd (IFN_EXTRACT_FIRST_ACTIVE, IFN_EXTRACT_LAST_ACTIVE): Move > lane-preserving conversions after scalar extraction when the target > supports extraction from the source vector type. > > gcc/testsuite/ChangeLog: > > * gcc.target/aarch64/sve/extract_last_convert_1.c: New test. > > --- > diff --git a/gcc/match.pd b/gcc/match.pd > index 4557dccad60c02fe821b390752bfefa14209bceb..156fb8024d0783b4d569116ced4750d0dea4c3a0 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -13443,6 +13443,26 @@ and, > && !TYPE_OVERFLOW_SANITIZED (TREE_TYPE (@0))) > (convert @0))) > > +#if GIMPLE > +/* When extracting the first or last active element from a converted vector, > + extract from the source vector instead and convert the scalar result. > + This is valid if the conversion preserves the number of lanes, so that the > + mask selects the same logical element in both vectors, and if the target > + supports the extract operation on the source vector type. */ > +(for extract (IFN_EXTRACT_FIRST_ACTIVE IFN_EXTRACT_LAST_ACTIVE) > +(simplify > + (extract @0 (convert@1 @2)) For FP <-> FP conversions this might drop IEEE flags. Same for when adding FP <-> int conversions (float, fix_trunc). > + (if (!VECTOR_TYPE_P (type) > + && VECTOR_TYPE_P (TREE_TYPE (@1)) > + && VECTOR_TYPE_P (TREE_TYPE (@2)) > + && known_eq (TYPE_VECTOR_SUBPARTS (TREE_TYPE (@1)), > + TYPE_VECTOR_SUBPARTS (TREE_TYPE (@2))) I think (convert ...) is only well-defined for same number of elements? > + && direct_internal_fn_supported_p (as_internal_fn (extract), > + TREE_TYPE (@2), OPTIMIZE_FOR_BOTH)) > + (with { tree element_type = TREE_TYPE (TREE_TYPE (@2)); } > + (convert (extract:element_type @0 @2)))))) > +#endif > + > /* Optimize > c1 = VEC_PERM_EXPR (a, a, mask) > c2 = VEC_PERM_EXPR (b, b, mask) > diff --git a/gcc/testsuite/gcc.target/aarch64/sve/extract_last_convert_1.c b/gcc/testsuite/gcc.target/aarch64/sve/extract_last_convert_1.c > new file mode 100644 > index 0000000000000000000000000000000000000000..ac624ec6408f6f7fd0771fb9fd6fdb7c74d7c759 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/sve/extract_last_convert_1.c > @@ -0,0 +1,33 @@ > +/* { dg-do compile { target aarch64_asm_sve_ok } } */ > +/* { dg-options "-O3 -march=armv8-a+sve -mautovec-preference=sve-only --param vect-epilogues-nomask=0 -fdump-tree-optimized" } */ > + > +float > +last_s32_to_f32 (int *restrict a, int *restrict b, > + int *restrict c, int n) > +{ > + float last = 0.0f; > + for (int i = 0; i < n; ++i) > + { > + int x = a[i] + b[i]; > + c[i] = x; > + last = (float) x; > + } > + return last; > +} > + > +int > +last_f32_to_s32 (float *restrict a, float *restrict b, > + float *restrict c, int n) > +{ > + int last = 0; > + for (int i = 0; i < n; ++i) > + { > + float x = a[i] + b[i]; > + c[i] = x; > + last = (int) x; > + } > + return last; > +} > + > +/* { dg-final { scan-tree-dump-times {_[0-9]+ = \.EXTRACT_LAST_ACTIVE \(loop_mask_[0-9]+, vect_x_[0-9]+\.[0-9]+_[0-9]+\);\n last_[0-9]+ = \(float\) _[0-9]+;} 1 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times {_[0-9]+ = \.EXTRACT_LAST_ACTIVE \(loop_mask_[0-9]+, vect_x_[0-9]+\.[0-9]+_[0-9]+\);\n last_[0-9]+ = \(int\) _[0-9]+;} 1 "optimized" } } */ > > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From rguenther@suse.de Mon Nov 2 12:53:18 2026 From: rguenther@suse.de (Richard Biener) Date: Mon, 2 Nov 2026 13:53:18 +0100 (CET) Subject: [patch v2 14/14][vect]: allow degenerate SLP permutations for early loads In-Reply-To: References: Message-ID: On Thu, 22 Oct 2026, Tamar Christina wrote: > This patch relaxes one speculative-load check used by early-break vectorization. > The vectorizer correctly rejects SLP load permutations for speculative loads > because an arbitrary permutation can invalidate the load layout assumptions. > However, an all-zero permutation is fine when the group has no gaps, including > permutations such as { 0, 0, 0, 0 } for multi-element groups. It only replicates > the first element of each scalar iteration's group and does not change the > alignment or footprint of the input loads. The existing checks still require > alignment for the whole group and check the speculative read amount against the > page size. > > A simplified C example is: > > void **find_ptr (void **first, void **last, void *needle) > { > while (first != last && *first != needle) > ++first; > return first; > } > > Before this patch the vectorizer could reject the speculative load because it > saw an SLP load permutation and treated it like a real permute: > > missed: loads with load permutations not supported for speculative loads > > After this patch, all-zero load permutations are accepted for groups without > gaps, and the loop can continue down the early-break vectorization path. > > Bootstrapped Regtested on aarch64-none-linux-gnu, > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > -m32, -m64 and no issues. > > -O3, profiled, profiled -O3 and -O3 -LTO bootstrap tested and no issues. > > Also SPECCPU 2017 and SPECCPU 2026 tested. > > Any feedback? Would that, by extension, not be the same for any uniform load permutation? So even for { 1, 1, 1 ... } for a multi-element group? The reasoning is that the first iteration is executed, so any further iteration does not change whether that element load trapped, right? I'll note that this isn't universally true but only when all scalar elements of one vector iterations load the same element which depends on a) VF, b) the group size, so I think you are lacking some multiple-of checks here. Richard. > Thanks, > Tamar > > gcc/ChangeLog: > > * tree-vect-stmts.cc (get_load_store_type): Allow all-zero SLP load > permutations for speculative loads from groups without gaps, including > multi-element groups. Update the diagnostic. > > gcc/testsuite/ChangeLog: > > * g++.dg/vect/vect-early-break-pr-spec-find.cc: New test. > > --- > diff --git a/gcc/testsuite/g++.dg/vect/vect-early-break-pr-spec-find.cc b/gcc/testsuite/g++.dg/vect/vect-early-break-pr-spec-find.cc > new file mode 100644 > index 0000000000000000000000000000000000000000..05e82345f0214d70da355a07053e10a9a069ab73 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/vect/vect-early-break-pr-spec-find.cc > @@ -0,0 +1,96 @@ > +/* { dg-do compile } */ > +/* { dg-add-options vect_early_break } */ > +/* { dg-require-effective-target vect_early_break } */ > +/* { dg-require-effective-target vect_long_long } */ > +/* { dg-additional-options "-O3 -fno-tree-loop-distribute-patterns" } */ > + > +struct X; > + > +template > +struct iter_equals_val > +{ > + Value& value; > + > + explicit > + iter_equals_val (Value& val) > + : value (val) > + {} > + > + template > + bool > + operator() (Iter it) > + { return *it == value; } > +}; > + > +template > +inline Iter > +find_if (Iter first, Iter last, Pred pred) > +{ > +#pragma GCC unroll 4 > + while (first != last && !pred (first)) > + ++first; > + return first; > +} > + > +__attribute__((noipa, noinline)) > +X ** > +find_ptr (X **first, X **last, X *needle) > +{ > + iter_equals_val pred (needle); > + return find_if (first, last, pred); > +} > + > +struct object_pool > +{ > + X **first; > + X **last; > + > + __attribute__((noipa, noinline)) > + bool > + return_object (X *needle, bool reset) > + { > + iter_equals_val pred (needle); > + X **pos = find_if (first, last, pred); > + if (pos == last) > + return false; > + > + if (!reset) > + { > + for (X **it = pos; it + 1 != last; ++it) > + *it = *(it + 1); > + --last; > + } > + > + return true; > + } > +}; > + > +__attribute__((noipa, noinline)) > +bool > +return_to_pool (object_pool *pool, X *needle, bool reset) > +{ > + return pool->return_object (needle, reset); > +} > + > +__attribute__((noipa, noinline)) > +bool > +dom_string_equals (const unsigned short *lhs, unsigned long lhs_length, > + const unsigned short *rhs, unsigned long rhs_length) > +{ > + if (lhs_length != rhs_length) > + return false; > + if (lhs_length == 0) > + return true; > + > + const unsigned short *end = lhs + lhs_length; > + while (*lhs == *rhs) > + { > + ++lhs; > + if (lhs == end) > + return true; > + ++rhs; > + } > + return false; > +} > + > +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ > diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc > index 3bb10d4b9a9eee94cc6bce565ba78afc5fb243ab..72a44b278d298019d48324aa739aa58544f89645 100644 > --- a/gcc/tree-vect-stmts.cc > +++ b/gcc/tree-vect-stmts.cc > @@ -2644,13 +2644,25 @@ get_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, > the blend. This is what the x86_64 backend does for instance. As > such only the first load in the group is aligned, the rest are not. > Because of this the permutes may break the alignment requirements that > - have been set, and as such we should for now, reject them. */ > - if (SLP_TREE_LOAD_PERMUTATION (slp_node).exists ()) > + have been set, and as such we should for now, reject them. However, > + an all-zero permutation of a group without gaps only replicates the > + first element of each scalar iteration's group. It does not change > + the alignment or the footprint of the input loads, which the checks > + above account for using the whole group size. */ > + load_permutation_t perm = SLP_TREE_LOAD_PERMUTATION (slp_node); > + bool all_zero_p = true; > + for (unsigned int index : perm) > + if (index != 0) > + { > + all_zero_p = false; > + break; > + } > + if (perm.exists () && (gap != 0 || !all_zero_p)) > { > if (dump_enabled_p ()) > dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, > "loads with load permutations not supported for " > - "speculative early break loads for %G", > + "speculative loads for %G", > STMT_VINFO_STMT (stmt_info)); > return false; > } > > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From stefansf@linux.ibm.com Mon Nov 2 12:56:04 2026 From: stefansf@linux.ibm.com (Stefan Schulze Frielinghaus) Date: Mon, 2 Nov 2026 13:56:04 +0100 Subject: [COMMITTED, PATCH] s390: For halfwords a byte-swap is a rotate by 8 bits [PR100867] Message-ID: <20261102125604.1381479-1-stefansf@linux.ibm.com> From: Stefan Schulze Frielinghaus Instead of a vperm, which needs a permutation vector loaded from the constant pool, rotate each halfword by 8 bits, which is equivalent. This also applies to constant permutations dealt with via TARGET_VECTORIZE_VEC_PERM_CONST where we previously bailed out early without VXE2. However, the halfword case is folded to a rotate which does not require VXE2, therefore, don't bail out early. The implementation is more invasive than expected. A new named insn bswapv8hi_vxe2 is needed that must not carry a permutation vector, unlike the existing *bswap split pattern. If the existing insn were reused, during RA the reg-reg alternative would still push the constant into the constant pool. This would make r13 the pool pointer, which may result in spills, and a vector register is allocated to load the constant into although it is unused and removed in the end. To circumvent this, *vec_splats_bswap_vec, *vec_insert_and_zero_bswap, and *vec_set_bswap_vec are duplicated for V8HI, the only difference being that the permutation vector is left out. For V4SI we could basically do the same by emitting two rotates instead of a load+vperm. However, a priori it is not clear whether this is really worthwhile. In the best case the load of the constant is hoisted out of the hot path which means only a cheap vperm remains. Only in case the load cannot be hoisted and the cache line for the load is evicted, two rotates are beneficial. PR target/100867 gcc/ChangeLog: * config/s390/s390.cc (expand_perm_as_a_vlbr_vstbr_candidate): Handle the halfword byte-swap permutation also without VXE2. * config/s390/vector.md (VT_HW_SDT): New mode iterator. (V_HW_SD): Ditto. (bswap): Deal with V8HI directly. (bswapv8hi_vxe2): New insn. (*bswap): Remove V8HI mode handling which is done in bswap, now. (*vec_splats_bswap_vecv8hi): New insn for V8HI and VXE2 which doesn't make use of a permutation vector. (*vstbr): Use mode iterator VI_HW_SDT instead of VI_HW_HSDT. * config/s390/vx-builtins.md (*vec_insert_and_zero_bswapv8hi): New insn for V8HI and VXE2 which doesn't make use of a permutation vector. (*vec_set_bswap_vecv8hi): Ditto. gcc/testsuite/ChangeLog: * gcc.target/s390/vector/vec-perm-halfword-swap-1.c: New test. * gcc.target/s390/zvector/vec-revb-halfword-1.c: New test. --- gcc/config/s390/s390.cc | 7 +- gcc/config/s390/vector.md | 78 ++++++++++++++----- gcc/config/s390/vx-builtins.md | 48 +++++++++--- .../s390/vector/vec-perm-halfword-swap-1.c | 45 +++++++++++ .../s390/zvector/vec-revb-halfword-1.c | 77 ++++++++++++++++++ 5 files changed, 224 insertions(+), 31 deletions(-) create mode 100644 gcc/testsuite/gcc.target/s390/vector/vec-perm-halfword-swap-1.c create mode 100644 gcc/testsuite/gcc.target/s390/zvector/vec-revb-halfword-1.c diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 61ca55161f9..577b0d0c8a2 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -18167,9 +18167,11 @@ expand_perm_as_a_vlbr_vstbr_candidate (const struct expand_vec_perm_d &d) { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 }, { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 } }; - if (!TARGET_VXE2 || d.vmode != V16QImode || d.op0 != d.op1) + if (d.vmode != V16QImode || d.op0 != d.op1) return false; + /* For halfwords a byte-swap is a rotate by 8 bits (verllh), which does not + require VXE2. */ if (memcmp (d.perm, perm[0], MAX_VECT_LEN) == 0) { if (!d.testing_p) @@ -18181,6 +18183,9 @@ expand_perm_as_a_vlbr_vstbr_candidate (const struct expand_vec_perm_d &d) return true; } + if (!TARGET_VXE2) + return false; + if (memcmp (d.perm, perm[1], MAX_VECT_LEN) == 0) { if (!d.testing_p) diff --git a/gcc/config/s390/vector.md b/gcc/config/s390/vector.md index 3f5abca1e6e..500cb0b5961 100644 --- a/gcc/config/s390/vector.md +++ b/gcc/config/s390/vector.md @@ -41,7 +41,9 @@ (define_mode_iterator V_HW3 [V16QI V8HI V4SI V2DI V1TI TI V4SF V2DF V1TF TF]) (define_mode_iterator VT_HW_HSDT [V8HI V4SI V4SF V2DI V2DF V1TI V1TF TI TF]) +(define_mode_iterator VT_HW_SDT [V4SI V4SF V2DI V2DF V1TI V1TF TI TF]) (define_mode_iterator V_HW_HSD [V8HI V4SI (V4SF "TARGET_VXE") V2DI V2DF]) +(define_mode_iterator V_HW_SD [V4SI (V4SF "TARGET_VXE") V2DI V2DF]) ; Including TI for instructions that support it (va, vn, ...) (define_mode_iterator VT_HW [V16QI V8HI V4SI V2DI V2DF V1TI TI (V4SF "TARGET_VXE") (V1TF "TARGET_VXE")]) @@ -815,16 +817,27 @@ #" [(set_attr "op_type" "VRX,VRI,VRI,*")]) -; vlbrreph, vlbrrepf, vlbrrepg +; vlbrrepf, vlbrrepg (define_insn "*vec_splats_bswap_vec" - [(set (match_operand:V_HW_HSD 0 "register_operand" "=v") - (bswap:V_HW_HSD - (vec_duplicate:V_HW_HSD (match_operand: 1 "memory_operand" "R")))) - (use (match_operand:V16QI 2 "permute_pattern_operand" "X"))] + [(set (match_operand:V_HW_SD 0 "register_operand" "=v") + (bswap:V_HW_SD + (vec_duplicate:V_HW_SD (match_operand: 1 "memory_operand" "R")))) + (use (match_operand:V16QI 2 "permute_pattern_operand" "X"))] "TARGET_VXE2" "vlbrrep\t%v0,%1" [(set_attr "op_type" "VRX")]) +; bswapv8hi does not emit a permutation vector, so this variant has +; no (use ...) operand. +; vlbrreph +(define_insn "*vec_splats_bswap_vecv8hi" + [(set (match_operand:V8HI 0 "register_operand" "=v") + (bswap:V8HI + (vec_duplicate:V8HI (match_operand:HI 1 "memory_operand" "R"))))] + "TARGET_VXE2" + "vlbrreph\t%v0,%1" + [(set_attr "op_type" "VRX")]) + ; Why do we need both? Shouldn't there be a canonical form? ; vlbrreph, vlbrrepf, vlbrrepg (define_insn "*vec_splats_bswap_elem" @@ -3514,9 +3527,25 @@ (use (match_dup 2))])] "TARGET_VX" { - static const char p[4][16] = - { { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }, /* H */ - { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 }, /* S */ + /* For halfwords a byte-swap is a rotate by 8 bits. */ + if (mode == V8HImode) + { + /* With VXE2, the memory instructions vlbrh and vstbrh are available + (the reg-reg case uses verllh). */ + if (TARGET_VXE2) + emit_insn (gen_bswapv8hi_vxe2 (operands[0], operands[1])); + else + { + rtx in = force_reg (V8HImode, operands[1]); + rtx out = gen_reg_rtx (V8HImode); + emit_insn (gen_rotlv8hi3 (out, in, GEN_INT (8))); + emit_move_insn (operands[0], out); + } + DONE; + } + + static const char p[3][16] = + { { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 }, /* S */ { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 }, /* D */ { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 } }; /* T */ const char *perm; @@ -3524,10 +3553,9 @@ switch (GET_MODE_SIZE (GET_MODE_INNER (mode))) { - case 2: perm = p[0]; break; - case 4: perm = p[1]; break; - case 8: perm = p[2]; break; - case 16: perm = p[3]; break; + case 4: perm = p[0]; break; + case 8: perm = p[1]; break; + case 16: perm = p[2]; break; default: gcc_unreachable (); } for (int i = 0; i < 16; i++) @@ -3551,6 +3579,17 @@ } }) +; verllh, vlbrh, vstbrh +(define_insn "bswapv8hi_vxe2" + [(set (match_operand:V8HI 0 "nonimmediate_operand" "=v,v,R") + (bswap:V8HI (match_operand:V8HI 1 "nonimmediate_operand" "v,R,v")))] + "TARGET_VXE2" + "@ + verllh\t%v0,%v1,8 + vlbrh\t%v0,%1 + vstbrh\t%v1,%0" + [(set_attr "op_type" "VRS,VRX,VRX")]) + ; Switching late to the reg-reg variant requires the vector permute ; pattern to be pushed into literal pool and allocating a vector ; register to load it into. We rely on both being provided by LRA @@ -3563,11 +3602,11 @@ ; ^R: Prevent these alternatives from being chosen if it would require ; pushing the operand into memory first -; vlbrh, vlbrf, vlbrg, vlbrq, vstbrh, vstbrf, vstbrg, vstbrq +; vlbrf, vlbrg, vlbrq, vstbrf, vstbrg, vstbrq (define_insn_and_split "*bswap" - [(set (match_operand:VT_HW_HSDT 0 "nonimmediate_operand" "=v, v,^R") - (bswap:VT_HW_HSDT (match_operand:VT_HW_HSDT 1 "nonimmediate_operand" "v,^R, v"))) - (use (match_operand:V16QI 2 "permute_pattern_operand" "v, X, X"))] + [(set (match_operand:VT_HW_SDT 0 "nonimmediate_operand" "=v, v,^R") + (bswap:VT_HW_SDT (match_operand:VT_HW_SDT 1 "nonimmediate_operand" "v,^R, v"))) + (use (match_operand:V16QI 2 "permute_pattern_operand" "v, X, X"))] "TARGET_VXE2" "@ # @@ -3577,7 +3616,7 @@ && !memory_operand (operands[0], mode) && !memory_operand (operands[1], mode)" [(set (match_dup 0) - (subreg:VT_HW_HSDT + (subreg:VT_HW_SDT (unspec:V16QI [(subreg:V16QI (match_dup 1) 0) (subreg:V16QI (match_dup 1) 0) (match_dup 2)] @@ -3585,9 +3624,10 @@ "" [(set_attr "op_type" "*,VRX,VRX")]) +; The halfword variant is handled by bswapv8hi_vxe2. (define_insn "*vstbr" - [(set (match_operand:VI_HW_HSDT 0 "memory_operand" "=R") - (bswap:VI_HW_HSDT (match_operand:VI_HW_HSDT 1 "register_operand" "v")))] + [(set (match_operand:VI_HW_SDT 0 "memory_operand" "=R") + (bswap:VI_HW_SDT (match_operand:VI_HW_SDT 1 "register_operand" "v")))] "TARGET_VXE2" "vstbr\t%v1,%0" [(set_attr "op_type" "VRX")]) diff --git a/gcc/config/s390/vx-builtins.md b/gcc/config/s390/vx-builtins.md index 6d06f1a7915..4837290af01 100644 --- a/gcc/config/s390/vx-builtins.md +++ b/gcc/config/s390/vx-builtins.md @@ -181,10 +181,10 @@ [(set_attr "op_type" "VRX")]) ; vec_revb (vec_insert_and_zero(x)) bswap-and-replicate-1.c -; vllebrzh, vllebrzf, vllebrzg +; vllebrzf, vllebrzg (define_insn "*vec_insert_and_zero_bswap" - [(set (match_operand:V_HW_HSD 0 "register_operand" "=v") - (bswap:V_HW_HSD (unspec:V_HW_HSD + [(set (match_operand:V_HW_SD 0 "register_operand" "=v") + (bswap:V_HW_SD (unspec:V_HW_SD [(match_operand: 1 "memory_operand" "R")] UNSPEC_VEC_INSERT_AND_ZERO))) (use (match_operand:V16QI 2 "permute_pattern_operand" "X"))] @@ -192,6 +192,18 @@ "vllebrz\t%v0,%1" [(set_attr "op_type" "VRX")]) +; bswapv8hi does not emit a permutation vector, so this variant has +; no (use ...) operand. +; vllebrzh +(define_insn "*vec_insert_and_zero_bswapv8hi" + [(set (match_operand:V8HI 0 "register_operand" "=v") + (bswap:V8HI (unspec:V8HI + [(match_operand:HI 1 "memory_operand" "R")] + UNSPEC_VEC_INSERT_AND_ZERO)))] + "TARGET_VXE2" + "vllebrzh\t%v0,%1" + [(set_attr "op_type" "VRX")]) + (define_insn "vlbb" [(set (match_operand:V16QI 0 "register_operand" "=v") @@ -2122,19 +2134,33 @@ [(set_attr "op_type" "VRX")]) ; vec_revb (vec_insert (*a, vec_revb (b), 1)) set-element-bswap-1.c -; vlebrh, vlebrf, vlebrg +; vlebrf, vlebrg (define_insn "*vec_set_bswap_vec" - [(set (match_operand:V_HW_HSD 0 "register_operand" "=v") - (bswap:V_HW_HSD - (unspec:V_HW_HSD [(match_operand: 1 "memory_operand" "R") - (match_operand:SI 2 "const_int_operand" "C") - (bswap:V_HW_HSD (match_operand:V_HW_HSD 3 "register_operand" "0"))] + [(set (match_operand:V_HW_SD 0 "register_operand" "=v") + (bswap:V_HW_SD + (unspec:V_HW_SD [(match_operand: 1 "memory_operand" "R") + (match_operand:SI 2 "const_int_operand" "C") + (bswap:V_HW_SD (match_operand:V_HW_SD 3 "register_operand" "0"))] UNSPEC_VEC_SET))) - (use (match_operand:V16QI 4 "permute_pattern_operand" "X"))] - "TARGET_VXE2 && UINTVAL (operands[2]) < GET_MODE_NUNITS (mode)" + (use (match_operand:V16QI 4 "permute_pattern_operand" "X"))] + "TARGET_VXE2 && UINTVAL (operands[2]) < GET_MODE_NUNITS (mode)" "vlebr\t%v0,%1,%2" [(set_attr "op_type" "VRX")]) +; bswapv8hi does not emit a permutation vector, so this variant has +; no (use ...) operand. +; vlebrh +(define_insn "*vec_set_bswap_vecv8hi" + [(set (match_operand:V8HI 0 "register_operand" "=v") + (bswap:V8HI + (unspec:V8HI [(match_operand:HI 1 "memory_operand" "R") + (match_operand:SI 2 "const_int_operand" "C") + (bswap:V8HI (match_operand:V8HI 3 "register_operand" "0"))] + UNSPEC_VEC_SET)))] + "TARGET_VXE2 && UINTVAL (operands[2]) < 8" + "vlebrh\t%v0,%1,%2" + [(set_attr "op_type" "VRX")]) + ; *a = vec_extract (vec_revb (b), 1); get-element-bswap-3.c ; *a = vec_revb (b)[1]; get-element-bswap-4.c ; vstebrh, vstebrf, vstebrg diff --git a/gcc/testsuite/gcc.target/s390/vector/vec-perm-halfword-swap-1.c b/gcc/testsuite/gcc.target/s390/vector/vec-perm-halfword-swap-1.c new file mode 100644 index 00000000000..54f8d3bf1e7 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/vector/vec-perm-halfword-swap-1.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=z13" } */ +/* { dg-final { check-function-bodies "**" "" "" } } */ + +/* For halfwords a byte-swap is a rotate by 8. */ + +typedef unsigned char v16qi __attribute__ ((vector_size (16))); + +/* +** test_reg_reg: +** verllh %v24,%v24,8 +** br %r14 +*/ +v16qi +test_reg_reg (v16qi x) +{ + return __builtin_shuffle (x, (v16qi) { 1, 0, 3, 2, 5, 4, 7, 6, + 9, 8, 11, 10, 13, 12, 15, 14 }); +} + +/* +** test_reg_mem: +** vl %v24,0\(%r2\),3 +** verllh %v24,%v24,8 +** br %r14 +*/ +v16qi +test_reg_mem (v16qi *x) +{ + return __builtin_shuffle (*x, (v16qi) { 1, 0, 3, 2, 5, 4, 7, 6, + 9, 8, 11, 10, 13, 12, 15, 14 }); +} + +/* +** test_mem_reg: +** verllh %v24,%v24,8 +** vst %v24,0\(%r2\),3 +** br %r14 +*/ +void +test_mem_reg (v16qi *x, v16qi y) +{ + *x = __builtin_shuffle (y, (v16qi) { 1, 0, 3, 2, 5, 4, 7, 6, + 9, 8, 11, 10, 13, 12, 15, 14 }); +} diff --git a/gcc/testsuite/gcc.target/s390/zvector/vec-revb-halfword-1.c b/gcc/testsuite/gcc.target/s390/zvector/vec-revb-halfword-1.c new file mode 100644 index 00000000000..c0931ac51f6 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/zvector/vec-revb-halfword-1.c @@ -0,0 +1,77 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=z13 -mzvector" } */ +/* { dg-final { check-function-bodies "**" "" "" } } */ +/* { dg-final { scan-assembler-not {\tvperm\t} } } */ + +#include + +/* +** test_z13_rr: +** verllh %v24,%v24,8 +** br %r14 +*/ +vector unsigned short +test_z13_rr (vector unsigned short a) +{ + return vec_revb (a); +} + +/* +** test_z15_rr: +** verllh %v24,%v24,8 +** br %r14 +*/ +__attribute__ ((target ("arch=z15"))) +vector unsigned short +test_z15_rr (vector unsigned short a) +{ + return vec_revb (a); +} + +/* +** test_z13_rm: +** vl %v24,0\(%r2\),3 +** verllh %v24,%v24,8 +** br %r14 +*/ +vector unsigned short +test_z13_rm (vector unsigned short *a) +{ + return vec_revb (*a); +} + +/* +** test_z15_rm: +** vlbrh %v24,0\(%r2\) +** br %r14 +*/ +__attribute__ ((target ("arch=z15"))) +vector unsigned short +test_z15_rm (vector unsigned short *a) +{ + return vec_revb (*a); +} + +/* +** test_z13_mr: +** verllh %v24,%v24,8 +** vst %v24,0\(%r2\),3 +** br %r14 +*/ +void +test_z13_mr (vector unsigned short *dst, vector unsigned short a) +{ + *dst = vec_revb (a); +} + +/* +** test_z15_mr: +** vstbrh %v24,0\(%r2\) +** br %r14 +*/ +__attribute__ ((target ("arch=z15"))) +void +test_z15_mr (vector unsigned short *dst, vector unsigned short a) +{ + *dst = vec_revb (a); +} -- 2.55.0 From Tamar.Christina@arm.com Mon Nov 2 12:56:55 2026 From: Tamar.Christina@arm.com (Tamar Christina) Date: Mon, 2 Nov 2026 12:56:55 +0000 Subject: [patch v2 9/14][isel]: form conditional vector compare IFNs In-Reply-To: References: Message-ID: > -----Original Message----- > From: Richard Biener > Sent: 02 November 2026 12:38 > To: Tamar Christina > Cc: gcc-patches@gcc.gnu.org; nd ; > jeffrey.law@oss.qualcomm.com > Subject: Re: [patch v2 9/14][isel]: form conditional vector compare IFNs > > On Thu, 22 Oct 2026, Tamar Christina wrote: > > > This patch forms conditional vector compare IFNs during gimple isel. > > > > The match.pd rules recognize integer vector compare idioms where a > compare is > > guarded by another vector predicate. gimple isel then lowers those idioms > to > > IFN_COND_VEC_CMP or IFN_COND_LEN_VEC_CMP when the target reports > support for the > > corresponding optab. If the original compare was only used by the > converted > > statement, the patch removes that now-dead definition. > > > > The tests for this lowering are kept with the later AArch64 SVE expander > patch, > > since they require the SVE cond_vec_cmp target support added there. > > > > Bootstrapped Regtested on aarch64-none-linux-gnu, > > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > > -m32, -m64 and no issues. > > > > -O3, profiled, profiled -O3 and -O3 -LTO bootstrap tested and no issues. > > > > Also SPECCPU 2017 and SPECCPU 2026 tested. > > > > OK for master? > > If you are here, can you expand the IFN_VCOND_MASK[_LEN] docs in > doc/ifn.texi? > > Also ... > > > gcc/ChangeLog: > > > > * gimple-isel.cc (gimple_convert_conditional_compare): Declare. > > (gimple_convert_conditional_len_compare): Likewise. > > (maybe_duplicate_comparison): Fix comment. > > (gimple_expand_conditional_compare): New function. Form > conditional > > vector compare IFNs when supported and identify a dead original > > comparison for removal. > > (pass_gimple_isel::execute): Use it and remove the original > comparison > > when it has no remaining uses. > > * match.pd (convert_conditional_compare): New match for masked > > non-floating-point vector comparisons. > > (convert_conditional_len_compare): New match for length-masked > > non-floating-point vector comparisons. > > > > --- > > diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc > > index > 1d346ee124ffdfdccf658ea79cc72cbf80240f81..9bd523cd81be541383ea9c9 > 62a9180565cea9f0d 100644 > > --- a/gcc/gimple-isel.cc > > +++ b/gcc/gimple-isel.cc > > @@ -327,8 +327,8 @@ maybe_duplicate_comparison (gassign *stmt, > basic_block bb) > > tree lhs = gimple_assign_lhs (stmt); > > unsigned cnt = 0; > > > > - /* This is should not be used for -O0 nor it is not useful > > - when ter is turned off. */ > > + /* This should not be used for -O0 and is not useful when TER is turned > > + off. */ > > if (!optimize || !flag_tree_ter) > > return; > > > > @@ -376,6 +376,9 @@ maybe_duplicate_comparison (gassign *stmt, > basic_block bb) > > extern bool gimple_nop_atomic_bit_test_and_p (tree, tree *, > > tree (*) (tree)); > > extern bool gimple_nop_convert (tree, tree*, tree (*) (tree)); > > +extern bool gimple_convert_conditional_compare (tree, tree *, tree (*) > (tree)); > > +extern bool gimple_convert_conditional_len_compare (tree, tree *, > > + tree (*) (tree)); > > > > namespace { > > > > @@ -488,6 +491,74 @@ convert_atomic_bit_not (enum internal_fn fn, > gimple *use_stmt, > > return use_stmt; > > } > > > > +/* Try to replace STMT with a conditional vector comparison internal > function. > > + The generated matchers recognize the source patterns and capture the > mask, > > + operands and original comparison SSA name. If the original comparison is > > + used only by STMT, store its defining statement in *DEAD_CMP_DEF so > that the > > + caller can remove it after replacing STMT. */ > > + > > +static gimple * > > +gimple_expand_conditional_compare (gimple_stmt_iterator *gsi, > > + gassign **dead_cmp_def) > > +{ > > + gimple *stmt = gsi_stmt (*gsi); > > + *dead_cmp_def = nullptr; > > + tree lhs = gimple_get_lhs (stmt); > > + > > + if (!lhs || TREE_CODE (lhs) != SSA_NAME) > > + return nullptr; > > + > > + tree ops[6] = {}; > > + location_t loc = gimple_location (stmt); > > + bool len_p = false; > > + if (!gimple_convert_conditional_compare (lhs, ops, nullptr) > > + && !gimple_convert_conditional_len_compare (lhs, ops, nullptr)) > > + return nullptr; > > + len_p = ops[4] != NULL_TREE; > > + > > + unsigned int cmp_opno = len_p ? 5 : 3; > > + tree cmp_name = ops[cmp_opno]; > > + if (TREE_CODE (cmp_name) != SSA_NAME) > > + return nullptr; > > + > > + gassign *cmp_def = dyn_cast (SSA_NAME_DEF_STMT > (cmp_name)); > > + if (!cmp_def) > > + return nullptr; > > + > > + tree_code code = gimple_assign_rhs_code (cmp_def); > > + if (TREE_CODE_CLASS (code) != tcc_comparison) > > + return nullptr; > > + > > + internal_fn ifn = len_p ? IFN_COND_LEN_VEC_CMP : > IFN_COND_VEC_CMP; > > + bool supported_p > > + = (len_p > > + ? expand_cond_len_vec_cmp_p (code, ops[0], ops[1], ops[2], > > + ops[3], ops[4]) > > + : expand_cond_vec_cmp_p (code, ops[0], ops[1], ops[2])); > > + if (!supported_p) > > + return nullptr; > > + > > + auto_vec args; > > + args.quick_push (build_int_cst (integer_type_node, code)); > > + args.quick_push (ops[0]); > > + args.quick_push (ops[1]); > > + args.quick_push (ops[2]); > > + if (len_p) > > + { > > + args.quick_push (ops[3]); > > + args.quick_push (ops[4]); > > + } > > + > > + gcall *call = gimple_build_call_internal_vec (ifn, args); > > + gimple_call_set_lhs (call, lhs); > > + gimple_set_location (call, loc); > > + use_operand_p use_p; > > + gimple *use_stmt; > > + if (single_imm_use (cmp_name, &use_p, &use_stmt) && use_stmt == > stmt) > > + *dead_cmp_def = cmp_def; > > + return call; > > +} > > + > > /* Optimize > > mask_2 = 1 << cnt_1; > > _4 = __atomic_fetch_or_* (ptr_6, mask_2, _3); > > @@ -1369,6 +1440,20 @@ pass_gimple_isel::execute (struct function *fun) > > /* Give the target first try at replacing the instruction. */ > > cfg_changed |= targetm.instruction_selection (fun, &gsi); > > > > + gimple *isel_stmt = NULL; > > + gassign *dead_cmp_def = NULL; > > + if (!gsi_end_p (gsi)) > > + isel_stmt = gimple_expand_conditional_compare (&gsi, > &dead_cmp_def); > > + if (isel_stmt) > > + { > > + gsi_replace (&gsi, isel_stmt, true); > > + if (dead_cmp_def) > > + { > > + gimple_stmt_iterator cmp_gsi = gsi_for_stmt > (dead_cmp_def); > > + gsi_remove (&cmp_gsi, true); > > + } > > + } > > + > > You are adding this before we generate .VCOND_MASK? Please wrap > the thing into a function wrapping gimple_expand_conditional_compare. > I'm not exactly happy with the "driver" of ISEL and the uncommon > interface to how workers leave 'gsi' ... > > > /* Pre-expand VEC_COND_EXPRs to .VCOND* internal function > > calls mapping to supported optabs. */ > > gimple *g = gimple_expand_vec_cond_expr (&gsi); > > @@ -1411,4 +1496,3 @@ make_pass_gimple_isel (gcc::context *ctxt) > > { > > return new pass_gimple_isel (ctxt); > > } > > - > > diff --git a/gcc/match.pd b/gcc/match.pd > > index > f3d9e55f1390ab4185b3dff1f59d60e10b138cb4..4557dccad60c02fe821b3 > 90752bfefa14209bceb 100644 > > --- a/gcc/match.pd > > +++ b/gcc/match.pd > > @@ -13782,4 +13782,17 @@ and, > > || (minmax == MAX_EXPR > > && wi::le_p (wi::to_wide (@1), bound, TYPE_SIGN (type)))) > > @3))))) > > + > > +(match (convert_conditional_compare @0 @1 @2 @3) > > + (bit_and:c @0 (tcc_comparison@3 @1 @2)) > > + (if (VECTOR_BOOLEAN_TYPE_P (type) > > + && !FLOAT_TYPE_P (TREE_TYPE (@1))))) > > this isn't equal to .VCOND_CMP as it will mask IEEE exceptions from > masked compares, so it would need -fno-trapping-math, correct? > Yeah, the GIMPLE semantics here were a bit confusing to me. because technically speaking on a = b `fcmp` c a' = a & mask, the flags get thrown on a, and a' just silences them. So in GIMPLE the trapping behaviour is a bit.. iffy and so I didn't change them. Technically speaking using the masked compares here would be more correct, but would also trigger for i.e. gcc vector extensions. That said, the backend would have applied the masking anyway. So I dunno, maybe it should just work for floats always, but yes adding a check on trapping math at the very least makes sense. Thanks, Tamar > > + > > +/* Transform .VCOND_MASK_LEN (a `cmp` b, {-1, ...}, {0, ...}, len, bias) > > + into cond_len_vec_cmp (cmp, {-1, ...}, a, b, len, bias). */ > > Same here? Why not .VCOND_MASK as well? > > > +(match (convert_conditional_len_compare @0 @1 @2 @3 @4 @5) > > + (IFN_VCOND_MASK_LEN (tcc_comparison@5 @1 @2) > > + integer_minus_onep@0 integer_zerop @3 @4) > > + (if (VECTOR_BOOLEAN_TYPE_P (type) > > + && !FLOAT_TYPE_P (TREE_TYPE (@1))))) > > #endif > > > > > > > > -- > Richard Biener > SUSE Software Solutions Germany GmbH, > Frankenstrasse 146, 90461 Nuernberg, Germany; > GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From rguenther@suse.de Mon Nov 2 13:00:51 2026 From: rguenther@suse.de (Richard Biener) Date: Mon, 2 Nov 2026 14:00:51 +0100 (CET) Subject: [PATCH] vect: Admit exact in-place aliasing in address-based alias checks In-Reply-To: <20261023064455.3443954-1-konstantinos.eleftheriou@vrull.eu> References: <20261023064455.3443954-1-konstantinos.eleftheriou@vrull.eu> Message-ID: <9194054s-9q23-4s54-8q06-2ns8ps612onp@fhfr.qr> On Thu, 22 Oct 2026, Konstantinos Eleftheriou wrote: > A loop that reads and writes through two pointers that may alias is > versioned on a runtime alias check. The IFN and WAR/WAW checks accept > equal pointers, but many pairs get the address-based overlap test > instead: a pair with a reordered member, a merged pair whose members > access the two pointers in opposite orders, or a RAW pair that the > target's IFN pattern cannot handle. The overlap test fails when the > pointers are equal, so a loop called with its output equal to its input > runs the scalar version. This affects SPEC2026's 736.ocio_r benchmark, > whose renderers process a single buffer in place. > > This patch makes the overlap test accept equal pointers for the pairs > where that is safe. A pair qualifies when its two accesses have the same > size and lie on a common grid of that size, meaning that their common > stride and the distance between them are multiples of the size. They > must also either never coincide, or coincide only in the same iteration > and stay in scalar order when vectorized. Other pairs, such as a read > one element ahead of a store or accesses of different sizes, can overlap > across iterations or partially, so they keep the original test. > > The check is done per member pair in vect_prune_runtime_alias_test_list, > before the group leaders are substituted and the pairs are merged, and > its result is carried in a new inplace_safe field. A merged pair > qualifies only if all its members do. For a qualifying pair, > create_intersect_range_checks ORs a base-address equality into the > overlap test. > > This speeds up 736.ocio_r by 4.3% on AArch64. > > Tested on aarch64-linux-gnu and x86_64-linux-gnu. Sashiko points out https://gcc.sashiko.dev/#/patchset/20261023064455.3443954-1-konstantinos.eleftheriou%40vrull.eu and I wonder why you add a bool when 'flags' has loads of bits left. Richard. > gcc/ChangeLog: > > * tree-data-ref.cc (merge_alias_pair_into): New function. > (prune_runtime_alias_test_list): Use it at both merge sites. > (relax_cond_for_inplace_aliasing): New function. > (create_intersect_range_checks): Use it on the address-based > overlap path only. > * tree-data-ref.h (dr_with_seg_len_pair_t): Add inplace_safe. > * tree-vect-data-refs.cc (vect_inplace_alias_result): New function. > (vect_inplace_alias_safe_p): Likewise. > (vect_prune_runtime_alias_test_list): Call it on each member > pair before substituting the group leaders. > > gcc/testsuite/ChangeLog: > > * gcc.dg/vect/vect-alias-check-inplace-run.c: New test. > * gcc.target/aarch64/vect-alias-check-inplace.c: New test. > > Co-authored-by: Philipp Tomsich > --- > .../vect/vect-alias-check-inplace-run.c | 309 ++++++++++++++++++ > .../aarch64/vect-alias-check-inplace.c | 30 ++ > gcc/tree-data-ref.cc | 44 ++- > gcc/tree-data-ref.h | 6 +- > gcc/tree-vect-data-refs.cc | 88 +++++ > 5 files changed, 474 insertions(+), 3 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/vect/vect-alias-check-inplace-run.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/vect-alias-check-inplace.c > > diff --git a/gcc/testsuite/gcc.dg/vect/vect-alias-check-inplace-run.c b/gcc/testsuite/gcc.dg/vect/vect-alias-check-inplace-run.c > new file mode 100644 > index 000000000000..2b9b235da230 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/vect/vect-alias-check-inplace-run.c > @@ -0,0 +1,309 @@ > +/* Each kernel is called with the output aliasing the input and compared > + against a scalar reference. */ > + > +#include "tree-vect.h" > + > +#define N 64 > + > +__attribute__ ((noipa)) float > +read_ahead (float *x, float *y, int n) > +{ > + float s = 0.0f; > + for (int i = 0; i < n; i++) > + { > + x[i] = (float) i; > + s += y[i] + y[i + 1]; > + } > + return s; > +} > + > +__attribute__ ((noipa)) float > +store_after_load (float *x, float *y, int n) > +{ > + float s = 0.0f; > + for (int i = 0; i < n; i++) > + { > + x[2 * i] = (float) i; > + s += y[2 * i] + y[2 * i + 1]; > + x[2 * i + 1] = 2.0f; > + } > + return s; > +} > + > +__attribute__ ((noipa)) float > +read_ahead_ref (float *x, float *y, int n) > +{ > + float s = 0.0f; > +#pragma GCC novector > + for (int i = 0; i < n; i++) > + { > + x[i] = (float) i; > + s += y[i] + y[i + 1]; > + } > + return s; > +} > + > +__attribute__ ((noipa)) float > +store_after_load_ref (float *x, float *y, int n) > +{ > + float s = 0.0f; > +#pragma GCC novector > + for (int i = 0; i < n; i++) > + { > + x[2 * i] = (float) i; > + s += y[2 * i] + y[2 * i + 1]; > + x[2 * i + 1] = 2.0f; > + } > + return s; > +} > + > +/* Offsets two bytes apart are off the four-byte grid, so each load > + partially overlaps the store of its own iteration and of the next one. */ > + > +__attribute__ ((noipa)) unsigned > +off_grid_cross (unsigned char *x, unsigned char *y, int n) > +{ > + unsigned s = 0; > + for (int i = 0; i < n; i++) > + { > + unsigned v = i * 0x01010101u; > + __builtin_memcpy (x + 4 * i + 2, &v, 4); > + unsigned t; > + __builtin_memcpy (&t, y + 4 * i + 4, 4); > + s += t; > + } > + return s; > +} > + > +/* Accesses of different sizes, the smaller first, so that only the size > + check refuses the pair. The next iteration's short store overlaps this > + iteration's int load. */ > + > +__attribute__ ((noipa)) unsigned > +mixed_size_cross (unsigned char *x, unsigned char *y, int n) > +{ > + unsigned s = 0; > + for (int i = 0; i < n; i++) > + { > + unsigned short v = i * 3u; > + __builtin_memcpy (x + 8 * i + 6, &v, 2); > + unsigned t; > + __builtin_memcpy (&t, y + 8 * i + 12, 4); > + s += t; > + } > + return s; > +} > + > +__attribute__ ((noipa)) unsigned > +off_grid_cross_ref (unsigned char *x, unsigned char *y, int n) > +{ > + unsigned s = 0; > +#pragma GCC novector > + for (int i = 0; i < n; i++) > + { > + unsigned v = i * 0x01010101u; > + __builtin_memcpy (x + 4 * i + 2, &v, 4); > + unsigned t; > + __builtin_memcpy (&t, y + 4 * i + 4, 4); > + s += t; > + } > + return s; > +} > + > +__attribute__ ((noipa)) unsigned > +mixed_size_cross_ref (unsigned char *x, unsigned char *y, int n) > +{ > + unsigned s = 0; > +#pragma GCC novector > + for (int i = 0; i < n; i++) > + { > + unsigned short v = i * 3u; > + __builtin_memcpy (x + 8 * i + 6, &v, 2); > + unsigned t; > + __builtin_memcpy (&t, y + 8 * i + 12, 4); > + s += t; > + } > + return s; > +} > + > +/* Relaxed for an exact in-place call. A partial overlap must still take > + the scalar version. */ > + > +__attribute__ ((noipa)) void > +scale4 (float *out, const float *in, int n) > +{ > + for (int i = 0; i < n; i++, out += 4, in += 4) > + { > + out[0] = in[0] * 2.0f; > + out[1] = in[1] * 3.0f; > + out[2] = in[2] * 4.0f; > + out[3] = in[3] * 5.0f; > + } > +} > + > +__attribute__ ((noipa)) void > +scale4_ref (float *out, const float *in, int n) > +{ > +#pragma GCC novector > + for (int i = 0; i < n; i++, out += 4, in += 4) > + { > + out[0] = in[0] * 2.0f; > + out[1] = in[1] * 3.0f; > + out[2] = in[2] * 4.0f; > + out[3] = in[3] * 5.0f; > + } > +} > + > +/* The same kernel walked backwards, for a negative step. */ > + > +__attribute__ ((noipa)) void > +scale4_down (float *out, const float *in, int n) > +{ > + out += 4 * (n - 1); > + in += 4 * (n - 1); > + for (int i = 0; i < n; i++, out -= 4, in -= 4) > + { > + out[0] = in[0] * 2.0f; > + out[1] = in[1] * 3.0f; > + out[2] = in[2] * 4.0f; > + out[3] = in[3] * 5.0f; > + } > +} > + > +__attribute__ ((noipa)) void > +scale4_down_ref (float *out, const float *in, int n) > +{ > + out += 4 * (n - 1); > + in += 4 * (n - 1); > +#pragma GCC novector > + for (int i = 0; i < n; i++, out -= 4, in -= 4) > + { > + out[0] = in[0] * 2.0f; > + out[1] = in[1] * 3.0f; > + out[2] = in[2] * 4.0f; > + out[3] = in[3] * 5.0f; > + } > +} > + > +/* Byte channels fit several iterations into one vector, which the float > + kernels above do not on most targets. */ > + > +__attribute__ ((noipa)) void > +add4 (unsigned char *out, const unsigned char *in, int n) > +{ > + for (int i = 0; i < n; i++, out += 4, in += 4) > + { > + out[0] = in[0] + 1; > + out[1] = in[1] + 2; > + out[2] = in[2] + 3; > + out[3] = in[3] + 4; > + } > +} > + > +__attribute__ ((noipa)) void > +add4_ref (unsigned char *out, const unsigned char *in, int n) > +{ > +#pragma GCC novector > + for (int i = 0; i < n; i++, out += 4, in += 4) > + { > + out[0] = in[0] + 1; > + out[1] = in[1] + 2; > + out[2] = in[2] + 3; > + out[3] = in[3] + 4; > + } > +} > + > +static float f[4 * N + 2], fref[4 * N + 2]; > +static unsigned char c[8 * N + 16], cref[8 * N + 16]; > + > +/* Give each buffer and its reference copy the same contents. */ > + > +static void > +reset (void) > +{ > + for (int i = 0; i < 4 * N + 2; i++) > + f[i] = fref[i] = 1.0f + i; > + for (int i = 0; i < 8 * N + 16; i++) > + c[i] = cref[i] = i; > +} > + > +/* Abort unless each buffer matches its reference copy. */ > + > +static void > +check (void) > +{ > + if (__builtin_memcmp (f, fref, sizeof f) != 0 > + || __builtin_memcmp (c, cref, sizeof c) != 0) > + __builtin_abort (); > +} > + > +int > +main (void) > +{ > + check_vect (); > + > + reset (); > + if (read_ahead (f, f, N) != read_ahead_ref (fref, fref, N)) > + __builtin_abort (); > + check (); > + > + reset (); > + if (store_after_load (f, f, N) != store_after_load_ref (fref, fref, N)) > + __builtin_abort (); > + check (); > + > + /* Exactly in place. The relaxation applies, and the result must match > + the reference. */ > + reset (); > + scale4 (f, f, N); > + scale4_ref (fref, fref, N); > + check (); > + > + /* Partial overlap off the grid, across iterations. */ > + reset (); > + if (off_grid_cross (c, c, N) != off_grid_cross_ref (cref, cref, N)) > + __builtin_abort (); > + check (); > + > + /* The same with mismatched access sizes. */ > + reset (); > + if (mixed_size_cross (c, c, N) != mixed_size_cross_ref (cref, cref, N)) > + __builtin_abort (); > + check (); > + > + /* Negative step, exactly in place. */ > + reset (); > + scale4_down (f, f, N); > + scale4_down_ref (fref, fref, N); > + check (); > + > + /* Output one element ahead of the input. The equality term is false, > + so the scalar version must run. */ > + reset (); > + scale4 (f + 1, f, N - 1); > + scale4_ref (fref + 1, fref, N - 1); > + check (); > + > + /* The byte kernel, exactly in place. */ > + reset (); > + add4 (c, c, N); > + add4_ref (cref, cref, N); > + check (); > + > + /* The byte kernel with the output one byte ahead of the input. */ > + reset (); > + add4 (c + 1, c, N); > + add4_ref (cref + 1, cref, N); > + check (); > + > + return 0; > +} > + > +/* scale4, scale4_down and add4 are relaxed, and every other kernel is > + refused. The memcpy kernels reach the check only where the memcpy folds > + to a MEM_REF, hence non_strict_align. */ > +/* { dg-final { scan-tree-dump-times "relaxed to permit exact in-place aliasing" 3 "vect" { target { vect_float && vect_int } } } } */ > +/* { dg-final { scan-tree-dump "dependence across iterations" "vect" { target vect_float } } } */ > +/* { dg-final { scan-tree-dump "dependence distance 0, reordered" "vect" { target vect_float } } } */ > +/* { dg-final { scan-tree-dump "unsigned int> \[^\n\]* and MEM \[^\n\]*may overlap partially" "vect" { target { vect_int && non_strict_align } } } } */ > +/* { dg-final { scan-tree-dump "unsigned short> \[^\n\]*may overlap partially" "vect" { target { vect_int && non_strict_align } } } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/vect-alias-check-inplace.c b/gcc/testsuite/gcc.target/aarch64/vect-alias-check-inplace.c > new file mode 100644 > index 000000000000..1bd1e8d44663 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/vect-alias-check-inplace.c > @@ -0,0 +1,30 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -ftree-vectorize -march=armv8-a -fdump-tree-vect-details" } */ > + > +/* A RAW pair on plain Advanced SIMD reaches the address-based overlap > + test, which is false for x == y and so needs the relaxation. */ > + > +float > +fn (float *x, float *y, int n) > +{ > + float s = 0.0f; > + for (int i = 0; i < n; i++) > + { > + x[i] = (float) i; > + s += y[i]; > + } > + return s; > +} > + > +/* A WAR pair gets an ordering test, which admits distance zero already. > + The count below asserts it does not pick up the equality term. */ > + > +void > +fn_war (float *x, const float *y, int n) > +{ > + for (int i = 0; i < n; i++) > + x[i] = y[i] * 2.0f; > +} > + > +/* { dg-final { scan-tree-dump "using an address-based WAR/WAW test" "vect" } } */ > +/* { dg-final { scan-tree-dump-times "relaxed to permit exact in-place aliasing" 1 "vect" } } */ > diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc > index 400a405792bb..b22e17a1a302 100644 > --- a/gcc/tree-data-ref.cc > +++ b/gcc/tree-data-ref.cc > @@ -1831,6 +1831,20 @@ dump_alias_pair (dr_with_seg_len_pair_t *alias_pair, const char *indent) > if (alias_pair->flags == 0) > dump_printf (MSG_NOTE, " "); > dump_printf (MSG_NOTE, "\n"); > + if (alias_pair->inplace_safe) > + dump_printf (MSG_NOTE, "%sin-place: safe\n", indent); > +} > + > +/* Fold the pair SRC into DST as part of a merge: the dependence and > + ordering flags accumulate, and DST stays safe for in-place aliasing only > + if both pairs were. */ > + > +static void > +merge_alias_pair_into (dr_with_seg_len_pair_t *dst, > + const dr_with_seg_len_pair_t *src) > +{ > + dst->flags |= src->flags; > + dst->inplace_safe &= src->inplace_safe; > } > > /* Merge alias checks recorded in ALIAS_PAIRS and remove redundant ones. > @@ -1919,7 +1933,7 @@ prune_runtime_alias_test_list (vec *alias_pairs, > dump_printf (MSG_NOTE, "found equal ranges %T, %T and %T, %T\n", > DR_REF (dr_a1->dr), DR_REF (dr_b1->dr), > DR_REF (dr_a2->dr), DR_REF (dr_b2->dr)); > - alias_pair1->flags |= alias_pair2->flags; > + merge_alias_pair_into (alias_pair1, alias_pair2); > continue; > } > > @@ -2035,7 +2049,7 @@ prune_runtime_alias_test_list (vec *alias_pairs, > dump_printf (MSG_NOTE, "merging ranges for %T, %T and %T, %T\n", > DR_REF (dr_a1->dr), DR_REF (dr_b1->dr), > DR_REF (dr_a2->dr), DR_REF (dr_b2->dr)); > - alias_pair1->flags |= alias_pair2->flags; > + merge_alias_pair_into (alias_pair1, alias_pair2); > last -= 1; > } > } > @@ -2135,6 +2149,31 @@ create_ifn_alias_checks (tree *cond_expr, > return true; > } > > +/* Extend *COND_EXPR, the overlap test for ALIAS_PAIR, to also accept equal > + base addresses, so that an in-place call takes the vector version. The > + IFN and WAR/WAW checks already accept equal addresses, and on SVE2 an > + equality term would stop the whilerw result from feeding the branch > + directly. */ > + > +static void > +relax_cond_for_inplace_aliasing (tree *cond_expr, > + const dr_with_seg_len_pair_t &alias_pair) > +{ > + if (*cond_expr == boolean_true_node || !alias_pair.inplace_safe) > + return; > + > + tree ba = DR_BASE_ADDRESS (alias_pair.first.dr); > + tree bb = DR_BASE_ADDRESS (alias_pair.second.dr); > + /* Compare as pointers, like the overlap test itself, which builds its > + bounds from these same two bases. */ > + tree base_eq = fold_build2 (EQ_EXPR, boolean_type_node, ba, > + fold_convert (TREE_TYPE (ba), bb)); > + *cond_expr = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, > + base_eq, *cond_expr); > + if (dump_enabled_p ()) > + dump_printf (MSG_NOTE, "relaxed to permit exact in-place aliasing\n"); > +} > + > /* Try to generate a runtime condition that is true if ALIAS_PAIR is > free of aliases, using a condition based on index values instead > of a condition based on addresses. Return true on success, > @@ -2720,6 +2759,7 @@ create_intersect_range_checks (class loop *loop, tree *cond_expr, > fold_build2 (cmp_code, boolean_type_node, seg_b_max, seg_a_min)); > if (dump_enabled_p ()) > dump_printf (MSG_NOTE, "using an address-based overlap test\n"); > + relax_cond_for_inplace_aliasing (cond_expr, alias_pair); > } > > /* Create a conditional expression that represents the run-time checks for > diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h > index ba901a5f6cee..af09d13d3960 100644 > --- a/gcc/tree-data-ref.h > +++ b/gcc/tree-data-ref.h > @@ -321,12 +321,16 @@ public: > dr_with_seg_len first; > dr_with_seg_len second; > unsigned int flags; > + /* True if the new code stays correct for every access pair being checked > + when the two base addresses are equal, so that an overlap test can > + accept that case too. */ > + bool inplace_safe; > }; > > inline dr_with_seg_len_pair_t:: > dr_with_seg_len_pair_t (const dr_with_seg_len &d1, const dr_with_seg_len &d2, > sequencing seq) > - : first (d1), second (d2), flags (0) > + : first (d1), second (d2), flags (0), inplace_safe (false) > { > if (DR_IS_READ (d1.dr) && DR_IS_WRITE (d2.dr)) > flags |= DR_ALIAS_WAR; > diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc > index 22fce2c927b3..46455e6102f9 100644 > --- a/gcc/tree-vect-data-refs.cc > +++ b/gcc/tree-vect-data-refs.cc > @@ -4076,6 +4076,87 @@ vectorizable_with_step_bound_p (dr_vec_info *dr_info_a, dr_vec_info *dr_info_b, > return true; > } > > +/* Dump whether the in-place check found DR_INFO_A and DR_INFO_B safe, and > + REASON, then return SAFE. */ > + > +static bool > +vect_inplace_alias_result (dr_vec_info *dr_info_a, dr_vec_info *dr_info_b, > + bool safe, const char *reason) > +{ > + if (dump_enabled_p ()) > + dump_printf_loc (MSG_NOTE, vect_location, > + "in-place aliasing %s for %T and %T (%s)\n", > + safe ? "safe" : "unsafe", DR_REF (dr_info_a->dr), > + DR_REF (dr_info_b->dr), reason); > + > + return safe; > +} > + > +/* Return true if accesses DR_INFO_A and DR_INFO_B, which need a runtime > + alias check, stay correct when their base addresses are equal. > + PRESERVES_SCALAR_ORDER_P says whether vectorization keeps the two in > + scalar order. > + > + The two must have the same size and lie on a common grid of that size. > + That is, the step and the distance between them are multiples of the > + size, so that any two of their accesses cover the same bytes or none. > + Other pairs could overlap partially and are refused. Pairs on a common > + grid are safe if they never access the same element, or access it in > + the same iteration and stay in scalar order. */ > + > +static bool > +vect_inplace_alias_safe_p (dr_vec_info *dr_info_a, dr_vec_info *dr_info_b, > + bool preserves_scalar_order_p) > +{ > + data_reference *dr_a = dr_info_a->dr; > + data_reference *dr_b = dr_info_b->dr; > + if (!tree_fits_shwi_p (DR_STEP (dr_a)) > + || !tree_fits_shwi_p (DR_STEP (dr_b)) > + || !tree_fits_shwi_p (DR_INIT (dr_a)) > + || !tree_fits_shwi_p (DR_INIT (dr_b))) > + return vect_inplace_alias_result (dr_info_a, dr_info_b, false, > + "non-constant step or init"); > + > + HOST_WIDE_INT step = tree_to_shwi (DR_STEP (dr_a)); > + if (step != tree_to_shwi (DR_STEP (dr_b)) || step == 0) > + return vect_inplace_alias_result (dr_info_a, dr_info_b, false, > + "different or zero steps"); > + > + if (!operand_equal_p (DR_OFFSET (dr_a), DR_OFFSET (dr_b), 0)) > + return vect_inplace_alias_result (dr_info_a, dr_info_b, false, > + "different offsets"); > + > + tree size_a = TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr_a))); > + tree size_b = TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr_b))); > + /* The difference of the two inits can overflow a HOST_WIDE_INT. */ > + offset_int init_distance > + = wi::to_offset (DR_INIT (dr_a)) - wi::to_offset (DR_INIT (dr_b)); > + if (!tree_fits_shwi_p (size_a) > + || !tree_int_cst_equal (size_a, size_b) > + || tree_to_shwi (size_a) == 0 > + || step % tree_to_shwi (size_a) != 0 > + || init_distance % tree_to_shwi (size_a) != 0) > + return vect_inplace_alias_result (dr_info_a, dr_info_b, false, > + "accesses may overlap partially"); > + > + if (init_distance == 0) > + { > + if (!preserves_scalar_order_p) > + return vect_inplace_alias_result (dr_info_a, dr_info_b, false, > + "dependence distance 0, reordered"); > + > + return vect_inplace_alias_result (dr_info_a, dr_info_b, true, > + "dependence distance 0, order kept"); > + } > + > + if (init_distance % step == 0) > + return vect_inplace_alias_result (dr_info_a, dr_info_b, false, > + "dependence across iterations"); > + > + return vect_inplace_alias_result (dr_info_a, dr_info_b, true, > + "no dependence"); > +} > + > /* Function vect_prune_runtime_alias_test_list. > > Prune a list of ddrs to be tested at run-time by versioning for alias. > @@ -4217,6 +4298,12 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo) > continue; > } > > + /* The in-place check needs the individual accesses, so do it before > + DR_INFO_A and DR_INFO_B are replaced by their group leaders. */ > + bool inplace_safe > + = vect_inplace_alias_safe_p (dr_info_a, dr_info_b, > + preserves_scalar_order_p); > + > stmt_vec_info dr_group_first_a = DR_GROUP_FIRST_ELEMENT (stmt_info_a); > if (dr_group_first_a) > { > @@ -4316,6 +4403,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo) > (dr_a, dr_b, (preserves_scalar_order_p > ? dr_with_seg_len_pair_t::WELL_ORDERED > : dr_with_seg_len_pair_t::REORDERED)); > + dr_with_seg_len_pair.inplace_safe = inplace_safe; > > comp_alias_ddrs.safe_push (dr_with_seg_len_pair); > } > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From tkaminsk@redhat.com Mon Nov 2 13:14:03 2026 From: tkaminsk@redhat.com (Tomasz Kaminski) Date: Mon, 2 Nov 2026 14:14:03 +0100 Subject: [PATCH 1/3] libstdc++: Fix buffer overflow in basic_filebuf::overflow [PR118099] In-Reply-To: References: <20261023174023.845748-1-jwakely@redhat.com> Message-ID: On Mon, Nov 2, 2026 at 1:41?PM Jonathan Wakely wrote: > On Mon, 2 Nov 2026 at 12:12, Tomasz Kaminski wrote: > > > > > > > > On Fri, Oct 23, 2026 at 8:09?PM Jonathan Wakely > wrote: > >> > >> On Fri, 23 Oct 2026 at 18:44, Jonathan Wakely > wrote: > >> > > >> > On Fri, 23 Oct 2026 at 18:40, Jonathan Wakely > wrote: > >> > > > >> > > From: Peter Edwards > >> > > > >> > > If we fail to write the content of the buffer after inserting the > >> > > overflow character into the end of it, then remove that overflow > >> > > character before propagating the error back to the caller. Without > this, > >> > > the caller is left with pptr set past epptr, and successive calls to > >> > > overflow will write further past the end of the managed buffer with > each > >> > > failure. > >> > > > >> > > libstdc++-v3/ChangeLog: > >> > > > >> > > PR libstdc++/118099 > >> > > * include/bits/fstream.tcc (basic_filebuf::overflow): > Rewind the > >> > > put position if outputting the put area fails. > >> > > * testsuite/27_io/basic_filebuf/overflow/char/118099.cc: New > >> > > test. > >> > > * testsuite/27_io/basic_filebuf/overflow/wchar_t/118099.cc: > >> > > New test. > >> > > > >> > > Co-authored-by: Jonathan Wakely > >> > > --- > >> > > > >> > > Tested x86_64-linux. > >> > > >> > I forgot to say: > >> > [PATCH 1/3] should be backported to active branches. > >> > [PATCH 2/3] is doesn't need to be backported since it only fixes a > >> > hypothetical problem. > >> > [PATCH 3/3] is not suitable for backporting, but the bug can be fixed > >> > with a try-catch around the call to _M_convert_to_external. > >> > >> Or we could do this for the branches, which would fix the > >> non-hypothetical problems (and tests) fixed by PATCH 1/3 and 3/3: > > > > I would use solution below for all branches (including trunk), so the > backports > > are cherry-picked. > > > > With that and one small suggestion for test LGTM > >> > >> > >> --- a/libstdc++-v3/include/bits/fstream.tcc > >> +++ b/libstdc++-v3/include/bits/fstream.tcc > >> @@ -561,11 +561,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > >> } > >> if (this->pbase() < this->pptr()) > >> { > >> + struct _Guard { > >> + ~_Guard() { if (_M_p) _M_p->pbump(-1); } > >> + basic_filebuf* _M_p; > >> + }; > >> + _Guard __g = { }; > >> + > >> // If appropriate, append the overflow char. > >> if (!__testeof) > >> { > >> *this->pptr() = traits_type::to_char_type(__c); > >> this->pbump(1); > >> + __g._M_p = this; > >> } > >> > >> // Convert pending sequence to external representation, > >> @@ -573,6 +580,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > >> if (_M_convert_to_external(this->pbase(), > >> this->pptr() - this->pbase())) > >> { > >> + __g._M_p = 0; > >> _M_set_buffer(0); > >> __ret = traits_type::not_eof(__c); > >> } > >> > >> > >> For trunk I would still like to do the larger refactoring so that we > >> avoid advancing then conditionally rewinding the next pointer, and the > >> changes to _M_convert_to_external make it simpler IMHO. > > > > Agreed, the PATCH 3/3 can then remove _Guard, but will need to have > message > > adjusted, to say it is refactoring/simplification. > > So add the _Guard as patch 0, so there are four patches on trunk, and > then only backport the patch 0 to the branches. That makes sense. > The _Guard can replace patch 1, we do not need to have patch adding else in that case. So we have: * New patch 1 with guard * Patch 2 unchanged * Modified patch 3, that removes _Guard, and adjust commit message, as it will be only simplification > > > In the new test, I would prefer that instead of : > > + bool got_eof = false; > > + for (int i = 0; i < N; ++i) > > + if (fb.sputc(val) == std::char_traits::eof()) > > + got_eof = true; > > + VERIFY( got_eof ); // the error path was actually taken > > We will do the following > > for (int i = 0; i < N/2; ++i) > > VERIFY( fb.sputc(val) != std::char_traits::eof()) > > for (int i = N/2; i < N; ++i) > > VERIFY( fb.sputc(val) == std::char_traits::eof()) > > Yes, that's better. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Tamar.Christina@arm.com Mon Nov 2 13:12:40 2026 From: Tamar.Christina@arm.com (Tamar Christina) Date: Mon, 2 Nov 2026 13:12:40 +0000 Subject: [patch v2 14/14][vect]: allow degenerate SLP permutations for early loads In-Reply-To: References: Message-ID: > -----Original Message----- > From: Richard Biener > Sent: 02 November 2026 12:53 > To: Tamar Christina > Cc: gcc-patches@gcc.gnu.org; nd ; rdapp.gcc@gmail.com > Subject: Re: [patch v2 14/14][vect]: allow degenerate SLP permutations for > early loads > > On Thu, 22 Oct 2026, Tamar Christina wrote: > > > This patch relaxes one speculative-load check used by early-break > vectorization. > > The vectorizer correctly rejects SLP load permutations for speculative loads > > because an arbitrary permutation can invalidate the load layout > assumptions. > > However, an all-zero permutation is fine when the group has no gaps, > including > > permutations such as { 0, 0, 0, 0 } for multi-element groups. It only replicates > > the first element of each scalar iteration's group and does not change the > > alignment or footprint of the input loads. The existing checks still require > > alignment for the whole group and check the speculative read amount > against the > > page size. > > > > A simplified C example is: > > > > void **find_ptr (void **first, void **last, void *needle) > > { > > while (first != last && *first != needle) > > ++first; > > return first; > > } > > > > Before this patch the vectorizer could reject the speculative load because it > > saw an SLP load permutation and treated it like a real permute: > > > > missed: loads with load permutations not supported for speculative loads > > > > After this patch, all-zero load permutations are accepted for groups without > > gaps, and the loop can continue down the early-break vectorization path. > > > > Bootstrapped Regtested on aarch64-none-linux-gnu, > > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > > -m32, -m64 and no issues. > > > > -O3, profiled, profiled -O3 and -O3 -LTO bootstrap tested and no issues. > > > > Also SPECCPU 2017 and SPECCPU 2026 tested. > > > > Any feedback? > > Would that, by extension, not be the same for any uniform load > permutation? So even for { 1, 1, 1 ... } for a multi-element group? > The reasoning is that the first iteration is executed, so any further > iteration does not change whether that element load trapped, right? > If the group access isn't change indeed. I was conservative here because I wasn't sure if this scenario could happen. Consider [0 1 . .][0 1 . .] I was concerned that instead we could optimize this by changing base to be base + 1, and loading [1 0 . 1] instead. I suppose we'd block this later but [0 0 0 ..] was easier to reason about. But Maybe I'm too conservative. > I'll note that this isn't universally true but only when all > scalar elements of one vector iterations load the same element > which depends on a) VF, b) the group size, so I think you are > lacking some multiple-of checks here. > Hmm will check. Don't immediately follow this one. Thanks for the reviews!, Tamar > Richard. > > > Thanks, > > Tamar > > > > gcc/ChangeLog: > > > > * tree-vect-stmts.cc (get_load_store_type): Allow all-zero SLP load > > permutations for speculative loads from groups without gaps, > including > > multi-element groups. Update the diagnostic. > > > > gcc/testsuite/ChangeLog: > > > > * g++.dg/vect/vect-early-break-pr-spec-find.cc: New test. > > > > --- > > diff --git a/gcc/testsuite/g++.dg/vect/vect-early-break-pr-spec-find.cc > b/gcc/testsuite/g++.dg/vect/vect-early-break-pr-spec-find.cc > > new file mode 100644 > > index > 0000000000000000000000000000000000000000..05e82345f0214d70da > 355a07053e10a9a069ab73 > > --- /dev/null > > +++ b/gcc/testsuite/g++.dg/vect/vect-early-break-pr-spec-find.cc > > @@ -0,0 +1,96 @@ > > +/* { dg-do compile } */ > > +/* { dg-add-options vect_early_break } */ > > +/* { dg-require-effective-target vect_early_break } */ > > +/* { dg-require-effective-target vect_long_long } */ > > +/* { dg-additional-options "-O3 -fno-tree-loop-distribute-patterns" } */ > > + > > +struct X; > > + > > +template > > +struct iter_equals_val > > +{ > > + Value& value; > > + > > + explicit > > + iter_equals_val (Value& val) > > + : value (val) > > + {} > > + > > + template > > + bool > > + operator() (Iter it) > > + { return *it == value; } > > +}; > > + > > +template > > +inline Iter > > +find_if (Iter first, Iter last, Pred pred) > > +{ > > +#pragma GCC unroll 4 > > + while (first != last && !pred (first)) > > + ++first; > > + return first; > > +} > > + > > +__attribute__((noipa, noinline)) > > +X ** > > +find_ptr (X **first, X **last, X *needle) > > +{ > > + iter_equals_val pred (needle); > > + return find_if (first, last, pred); > > +} > > + > > +struct object_pool > > +{ > > + X **first; > > + X **last; > > + > > + __attribute__((noipa, noinline)) > > + bool > > + return_object (X *needle, bool reset) > > + { > > + iter_equals_val pred (needle); > > + X **pos = find_if (first, last, pred); > > + if (pos == last) > > + return false; > > + > > + if (!reset) > > + { > > + for (X **it = pos; it + 1 != last; ++it) > > + *it = *(it + 1); > > + --last; > > + } > > + > > + return true; > > + } > > +}; > > + > > +__attribute__((noipa, noinline)) > > +bool > > +return_to_pool (object_pool *pool, X *needle, bool reset) > > +{ > > + return pool->return_object (needle, reset); > > +} > > + > > +__attribute__((noipa, noinline)) > > +bool > > +dom_string_equals (const unsigned short *lhs, unsigned long lhs_length, > > + const unsigned short *rhs, unsigned long rhs_length) > > +{ > > + if (lhs_length != rhs_length) > > + return false; > > + if (lhs_length == 0) > > + return true; > > + > > + const unsigned short *end = lhs + lhs_length; > > + while (*lhs == *rhs) > > + { > > + ++lhs; > > + if (lhs == end) > > + return true; > > + ++rhs; > > + } > > + return false; > > +} > > + > > +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ > > diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc > > index > 3bb10d4b9a9eee94cc6bce565ba78afc5fb243ab..72a44b278d298019d483 > 24aa739aa58544f89645 100644 > > --- a/gcc/tree-vect-stmts.cc > > +++ b/gcc/tree-vect-stmts.cc > > @@ -2644,13 +2644,25 @@ get_load_store_type (vec_info *vinfo, > stmt_vec_info stmt_info, > > the blend. This is what the x86_64 backend does for instance. As > > such only the first load in the group is aligned, the rest are not. > > Because of this the permutes may break the alignment requirements > that > > - have been set, and as such we should for now, reject them. */ > > - if (SLP_TREE_LOAD_PERMUTATION (slp_node).exists ()) > > + have been set, and as such we should for now, reject them. However, > > + an all-zero permutation of a group without gaps only replicates the > > + first element of each scalar iteration's group. It does not change > > + the alignment or the footprint of the input loads, which the checks > > + above account for using the whole group size. */ > > + load_permutation_t perm = SLP_TREE_LOAD_PERMUTATION > (slp_node); > > + bool all_zero_p = true; > > + for (unsigned int index : perm) > > + if (index != 0) > > + { > > + all_zero_p = false; > > + break; > > + } > > + if (perm.exists () && (gap != 0 || !all_zero_p)) > > { > > if (dump_enabled_p ()) > > dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, > > "loads with load permutations not supported for " > > - "speculative early break loads for %G", > > + "speculative loads for %G", > > STMT_VINFO_STMT (stmt_info)); > > return false; > > } > > > > > > > > -- > Richard Biener > SUSE Software Solutions Germany GmbH, > Frankenstrasse 146, 90461 Nuernberg, Germany; > GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From mattst88@gmail.com Mon Nov 2 13:27:47 2026 From: mattst88@gmail.com (Matt Turner) Date: Mon, 2 Nov 2026 08:27:47 -0500 Subject: [PATCH v3 0/4] include: Let longlong.h build with clang, keeping GCC's output casts In-Reply-To: <1d9912bb-3e6a-44c3-95b5-6c01149602a8@oss.qualcomm.com> References: <20260921-longlong-fixes-v2-v3-0-ee2a8182508b@gmail.com> <1d9912bb-3e6a-44c3-95b5-6c01149602a8@oss.qualcomm.com> Message-ID: On Thu, Oct 22, 2026 at 8:41?PM Jeff Law wrote: > > > > On 10/8/26 3:31 PM, Matt Turner wrote: > > On Mon, Sep 21, 2026 at 8:12?PM Matt Turner wrote: > >> Several blocks of longlong.h do not build with clang, because clang > >> rejects casts on asm output operands. This affects libgcrypt, which > >> imports longlong.h, and wide-int.cc in GCC itself. > >> > >> 1. Remove the Z8000 block, as Richard suggested. Unchanged from v2. > >> > >> 2. Update the header comment, which still says the file is part of > >> the GNU C Library. glibc removed its copy of longlong.h in 2.43. > >> > >> 3. Wrap each output cast in a macro, as Jakub suggested: > >> > >> : "=r" __ll_check_output (USItype, sh), > >> > >> 4. Let wide-int.cc include longlong.h under clang again, so a GCC > >> built by clang without bootstrapping uses umul_ppmm. > >> > >> With GCC, patch 3 expands to the same casts as before. With clang, the > >> i386 block, the x86_64 and sparc64 blocks for W_TYPE_SIZE 64, and the > >> arm blocks as C now build. The arm blocks still fail as C++, because > >> the arm umul_ppmm declares a register variable, which C++17 does not > >> allow; that is a separate problem. > >> > >> Tested by building x86_64-pc-linux-gnu with clang 22 as the host > >> compiler (--disable-bootstrap). wi::mul_internal now uses mulq, the > >> selftests pass and the target libraries build. > >> > >> Changes in v3: > >> - Replace the sizeof check with __ll_check_output, which keeps the cast > >> for GCC and drops it for clang (Jakub). GCC's cast check rejects > >> any conversion that is not a no-op, while the size check accepted > >> outputs of a different type with the same size. > >> - Drop v2 patches 3 and 4 (__ll_out and the libquadmath register > >> change). They are no longer needed since GCC keeps the cast. > >> - New patch 2: say longlong.h is part of GCC, not the GNU C Library, > >> and update the stale comment on attribute_hidden. > >> - New patch 4: include longlong.h in wide-int.cc with clang. > >> - Link to v2: https://inbox.sourceware.org/gcc-patches/20260921-longlong-fixes-v2-v2-0-83a48fd515cf@gmail.com/ > >> > >> Changes in v2: > >> - Keep the output size check instead of dropping it (patch 2). > >> - Remove the Z8000 block instead of editing it (patch 1). > >> - New, optional: patches 3 and 4. > >> - v1 patch 2/2 (sdiv_qrnnd parentheses) is already committed. > >> - Link to v1: https://inbox.sourceware.org/gcc-patches/20260906025840.1275711-1-mattst88@gmail.com/ > >> > >> --- > >> Matt Turner (4): > >> include: Remove Z8000 support from longlong.h > >> include: Say longlong.h is part of GCC, not the GNU C Library > >> include: Wrap the casts on asm output operands in longlong.h in a macro > >> wide-int.cc: Include longlong.h when built with clang [PR61146] > >> > >> gcc/wide-int.cc | 3 +- > >> include/longlong.h | 241 ++++++++++++++++++++++++----------------------------- > >> 2 files changed, 110 insertions(+), 134 deletions(-) > >> --- > >> base-commit: e47eccbe6d118023e4fe83bde14075729c40e030 > >> change-id: 20260921-longlong-fixes-v2-d8f7bb2376cc > >> > >> Best regards, > >> -- > >> Matt Turner > > Any further comments or can someone push this for me? > Richi, Jakub, Andrea, any further concerns here? Bueller, bueller? From uttamsinghbhadoriya23@gmail.com Mon Nov 2 13:35:44 2026 From: uttamsinghbhadoriya23@gmail.com (Uttam Bhadauriya) Date: Mon, 2 Nov 2026 19:05:44 +0530 Subject: [PATCH v4] match.pd: Recognize X == MIN ? MIN : X - 1 as signed sat add [PR127985] Message-ID: >From 139d4ed702eb90377eab29e832a03683d37be20e Mon Sep 17 00:00:00 2001 From: Uttam Singh Bhadauriya Date: Wed, 21 Oct 2026 09:05:10 +0530 Subject: [PATCH v4] match.pd: Recognize X == MIN ? MIN : X - 1 as signed sat add [PR127985] Commit ff133b4cd22 (PR126627) simplified (X & -X) < 0 into X == INT_MIN and (X & -X) >= 0 into X != INT_MIN. However, the signed saturating addition pattern for IMM = -1 in match-sat-alu.pd only looked for the unsimplified (X & -X) < 0 condition. As a result, a saturating decrement is no longer recognized as .SAT_ADD when (X & -X) < 0 is folded, causing regressions in gcc.target/riscv/sat/sat_s_add_imm-*.c. Keep the existing (X & -X) < 0 pattern (for cases such as -fwrapv where PR126627 does not apply) and add match patterns for the canonical X == MIN ? MIN : X - 1 and X != MIN ? X - 1 : MIN forms. This restores .SAT_ADD discovery on RISC-V and also captures saturating decrements written directly with MIN comparisons. PR tree-optimization/127985 gcc/ChangeLog: * match-sat-alu.pd (signed_integer_sat_add): Add patterns for X == MIN ? MIN : X - 1 and X != MIN ? X - 1 : MIN. gcc/testsuite/ChangeLog: * gcc.dg/torture/pr127985.c: New test. * gcc.target/riscv/sat/pr127985.c: New test. Signed-off-by: Uttam Singh Bhadauriya --- Hello, Based on the feedback provided for v3 by Jeff, I am presenting v4 of this patch with the following changes: 1. Retained the existing (X & -X) < 0 pattern: Kept the original (X & -X) < 0 pattern intact for cases where PR126627 does not fire (such as with -fwrapv / -ftrapv), and added the two new canonical patterns (X == MIN ? MIN : X - 1 and X != MIN ? X - 1 : MIN) alongside it. 2. Test Verification Summary: - x86_64: gcc.dg/torture/pr127985.c passes runtime execution across all optimization levels (-O0, -O1, -O2, -O3, -Os). - RISC-V (rv64gc-lp64d): Verified on cc1 that sat_s_add_imm-1-i16.c restores the regression (2 .SAT_ADD instances found). - RISC-V (rv64gc-lp64d): Verified pr127985.c finds all 8 .SAT_ADD instances and produces branchless assembly (0 branch labels). - Style & Apply: contrib/check_GNU_style.sh reports 0 errors and 0 warnings; git apply --check applies cleanly to latest trunk. Thanks, Uttam gcc/match-sat-alu.pd | 40 ++++++ gcc/testsuite/gcc.dg/torture/pr127985.c | 122 ++++++++++++++++++ gcc/testsuite/gcc.target/riscv/sat/pr127985.c | 56 ++++++++ 3 files changed, 218 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr127985.c create mode 100644 gcc/testsuite/gcc.target/riscv/sat/pr127985.c diff --git a/gcc/match-sat-alu.pd b/gcc/match-sat-alu.pd index 236d6fb2e19..20f3ebaecc8 100644 --- a/gcc/match-sat-alu.pd +++ b/gcc/match-sat-alu.pd @@ -503,6 +503,46 @@ along with GCC; see the file COPYING3. If not see (if (types_match (type, @0) && wi::eq_p (sum, wi::max_value (precision, SIGNED)))))) +(match (signed_integer_sat_add @0 @1) + /* T SUM = (T)((UT)X + (UT)-1); + SAT_S_ADD = X == MIN ? MIN : SUM. */ + (convert? (cond^ (eq (nop_convert1? @0) INTEGER_CST@3) + INTEGER_CST@2 + (plus (nop_convert2? @0) integer_all_onesp@1))) + (with + { + unsigned precision = TYPE_PRECISION (type); + wide_int c1 = wi::to_wide (@1); + wide_int c2 = wi::to_wide (@2); + wide_int c3 = wi::to_wide (@3); + wide_int sum = wi::add (c1, c2); + } + /* The outer conversion must not change the type of X. */ + (if (types_match (type, @0) + && TYPE_PRECISION (TREE_TYPE (@3)) == precision + && wi::eq_p (sum, wi::max_value (precision, SIGNED)) + && wi::eq_p (c3, wi::min_value (precision, SIGNED)))))) + +(match (signed_integer_sat_add @0 @1) + /* T SUM = (T)((UT)X + (UT)-1); + SAT_S_ADD = X != MIN ? SUM : MIN. */ + (convert? (cond^ (ne (nop_convert1? @0) INTEGER_CST@3) + (plus (nop_convert2? @0) integer_all_onesp@1) + INTEGER_CST@2)) + (with + { + unsigned precision = TYPE_PRECISION (type); + wide_int c1 = wi::to_wide (@1); + wide_int c2 = wi::to_wide (@2); + wide_int c3 = wi::to_wide (@3); + wide_int sum = wi::add (c1, c2); + } + /* The outer conversion must not change the type of X. */ + (if (types_match (type, @0) + && TYPE_PRECISION (TREE_TYPE (@3)) == precision + && wi::eq_p (sum, wi::max_value (precision, SIGNED)) + && wi::eq_p (c3, wi::min_value (precision, SIGNED)))))) + (match (signed_integer_sat_add @0 @1) /* T SUM = (T)((UT)X + (UT)IMM) SAT_S_ADD = (X ^ SUM) < 0 && (X ^ IMM) >= 0 ? (-(T)(X < 0) ^ MAX) : SUM */ diff --git a/gcc/testsuite/gcc.dg/torture/pr127985.c b/gcc/testsuite/gcc.dg/torture/pr127985.c new file mode 100644 index 00000000000..0ebdc47b2b4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr127985.c @@ -0,0 +1,122 @@ +/* PR tree-optimization/127985 */ +/* { dg-do run } */ + +#include + +__attribute__((noipa)) int8_t +dec_i8 (int8_t x) +{ + return x == INT8_MIN ? INT8_MIN : x - 1; +} + +__attribute__((noipa)) int16_t +dec_i16 (int16_t x) +{ + return x == INT16_MIN ? INT16_MIN : x - 1; +} + +__attribute__((noipa)) int32_t +dec_i32 (int32_t x) +{ + return x == INT32_MIN ? INT32_MIN : x - 1; +} + +__attribute__((noipa)) int64_t +dec_i64 (int64_t x) +{ + return x == INT64_MIN ? INT64_MIN : x - 1; +} + +__attribute__((noipa)) int8_t +dec_ne_i8 (int8_t x) +{ + return x != INT8_MIN ? x - 1 : INT8_MIN; +} + +__attribute__((noipa)) int16_t +dec_ne_i16 (int16_t x) +{ + return x != INT16_MIN ? x - 1 : INT16_MIN; +} + +__attribute__((noipa)) int32_t +dec_ne_i32 (int32_t x) +{ + return x != INT32_MIN ? x - 1 : INT32_MIN; +} + +__attribute__((noipa)) int64_t +dec_ne_i64 (int64_t x) +{ + return x != INT64_MIN ? x - 1 : INT64_MIN; +} + +int +main (void) +{ + if (dec_i8 (INT8_MIN) != INT8_MIN + || dec_i8 (INT8_MIN + 1) != INT8_MIN + || dec_i8 (-1) != -2 + || dec_i8 (0) != -1 + || dec_i8 (10) != 9 + || dec_i8 (INT8_MAX) != INT8_MAX - 1) + __builtin_abort (); + + if (dec_i16 (INT16_MIN) != INT16_MIN + || dec_i16 (INT16_MIN + 1) != INT16_MIN + || dec_i16 (-1) != -2 + || dec_i16 (0) != -1 + || dec_i16 (10) != 9 + || dec_i16 (INT16_MAX) != INT16_MAX - 1) + __builtin_abort (); + + if (dec_i32 (INT32_MIN) != INT32_MIN + || dec_i32 (INT32_MIN + 1) != INT32_MIN + || dec_i32 (-1) != -2 + || dec_i32 (0) != -1 + || dec_i32 (10) != 9 + || dec_i32 (INT32_MAX) != INT32_MAX - 1) + __builtin_abort (); + + if (dec_i64 (INT64_MIN) != INT64_MIN + || dec_i64 (INT64_MIN + 1) != INT64_MIN + || dec_i64 (-1) != -2 + || dec_i64 (0) != -1 + || dec_i64 (10) != 9 + || dec_i64 (INT64_MAX) != INT64_MAX - 1) + __builtin_abort (); + + if (dec_ne_i8 (INT8_MIN) != INT8_MIN + || dec_ne_i8 (INT8_MIN + 1) != INT8_MIN + || dec_ne_i8 (-1) != -2 + || dec_ne_i8 (0) != -1 + || dec_ne_i8 (10) != 9 + || dec_ne_i8 (INT8_MAX) != INT8_MAX - 1) + __builtin_abort (); + + if (dec_ne_i16 (INT16_MIN) != INT16_MIN + || dec_ne_i16 (INT16_MIN + 1) != INT16_MIN + || dec_ne_i16 (-1) != -2 + || dec_ne_i16 (0) != -1 + || dec_ne_i16 (10) != 9 + || dec_ne_i16 (INT16_MAX) != INT16_MAX - 1) + __builtin_abort (); + + if (dec_ne_i32 (INT32_MIN) != INT32_MIN + || dec_ne_i32 (INT32_MIN + 1) != INT32_MIN + || dec_ne_i32 (-1) != -2 + || dec_ne_i32 (0) != -1 + || dec_ne_i32 (10) != 9 + || dec_ne_i32 (INT32_MAX) != INT32_MAX - 1) + __builtin_abort (); + + if (dec_ne_i64 (INT64_MIN) != INT64_MIN + || dec_ne_i64 (INT64_MIN + 1) != INT64_MIN + || dec_ne_i64 (-1) != -2 + || dec_ne_i64 (0) != -1 + || dec_ne_i64 (10) != 9 + || dec_ne_i64 (INT64_MAX) != INT64_MAX - 1) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/sat/pr127985.c b/gcc/testsuite/gcc.target/riscv/sat/pr127985.c new file mode 100644 index 00000000000..b7faef1eadc --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat/pr127985.c @@ -0,0 +1,56 @@ +/* PR tree-optimization/127985 */ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-tree-optimized" } */ + +#include + +int8_t +dec_i8 (int8_t x) +{ + return x == INT8_MIN ? INT8_MIN : x - 1; +} + +int16_t +dec_i16 (int16_t x) +{ + return x == INT16_MIN ? INT16_MIN : x - 1; +} + +int32_t +dec_i32 (int32_t x) +{ + return x == INT32_MIN ? INT32_MIN : x - 1; +} + +int64_t +dec_i64 (int64_t x) +{ + return x == INT64_MIN ? INT64_MIN : x - 1; +} + +int8_t +dec_ne_i8 (int8_t x) +{ + return x != INT8_MIN ? x - 1 : INT8_MIN; +} + +int16_t +dec_ne_i16 (int16_t x) +{ + return x != INT16_MIN ? x - 1 : INT16_MIN; +} + +int32_t +dec_ne_i32 (int32_t x) +{ + return x != INT32_MIN ? x - 1 : INT32_MIN; +} + +int64_t +dec_ne_i64 (int64_t x) +{ + return x != INT64_MIN ? x - 1 : INT64_MIN; +} + +/* { dg-final { scan-tree-dump-times ".SAT_ADD " 8 "optimized" } } */ +/* { dg-final { scan-assembler-not "\\.L\[0-9\]+" } } */ -- 2.34.1 -------------- next part -------------- A non-text attachment was scrubbed... Name: PR127985.patch Type: application/octet-stream Size: 9076 bytes Desc: not available URL: From uttamsinghbhadoriya23@gmail.com Mon Nov 2 13:38:58 2026 From: uttamsinghbhadoriya23@gmail.com (Uttam Bhadauriya) Date: Mon, 2 Nov 2026 19:08:58 +0530 Subject: [PATCH v3] match.pd: Recognize X == MIN ? MIN : X - 1 as signed sat add [PR127985] In-Reply-To: <214caea7-9678-4c46-aa20-90250edcc300@oss.qualcomm.com> References: <214caea7-9678-4c46-aa20-90250edcc300@oss.qualcomm.com> Message-ID: Hello Jeff, Thank you for the review and providing your valuable feedback. I have sent a v4 of the patch, as requested. Kind regards, Uttam On Mon, Nov 2, 2026 at 9:27?AM Jeff Law wrote: > > > > On 10/21/26 6:15 AM, Uttam Bhadauriya wrote: > > From fb6b4d83d08d8d30b31a450d6aa410d95d1b2e89 Mon Sep 17 00:00:00 2001 > > From: Uttam Singh Bhadauriya > > Date: Wed, 21 Oct 2026 17:45:13 +0530 > > Subject: [PATCH v3] match.pd: Recognize X == MIN ? MIN : X - 1 as signed sat add > > [PR127985] > > > > Commit ff133b4cd22 (PR126627) simplified (X & -X) < 0 into X == INT_MIN > > and (X & -X) >= 0 into X != INT_MIN. However, the signed saturating > > addition pattern for IMM = -1 in match-sat-alu.pd looked for the > > unsimplified (X & -X) < 0 condition. As a result, a saturating decrement > > is no longer recognized as .SAT_ADD, which causes regressions in > > gcc.target/riscv/sat/sat_s_add_imm-*.c. > > > > Because the old (X & -X) < 0 pattern can no longer match outside > > -ftrapv, this patch replaces it with match patterns for the canonical > > X == MIN ? MIN : X - 1 and X != MIN ? X - 1 : MIN forms. This restores > > .SAT_ADD discovery on RISC-V and also captures saturating decrements > > written directly with MIN comparisons. > > > > PR tree-optimization/127985 > > > > gcc/ChangeLog: > > > > * match-sat-alu.pd (signed_integer_sat_add): Replace obsolete > > (X & -X) < 0 pattern with patterns for X == MIN ? MIN : X - 1 > > and X != MIN ? X - 1 : MIN. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.dg/torture/pr127985.c: New test. > > * gcc.target/riscv/sat/pr127985.c: New test. > > > > Signed-off-by: Uttam Singh Bhadauriya > > --- > > Hello, > > > > I am presenting the v3 patch, I was able to build the cross-compiler > > and test it locally( had some issues with my hardware apparently so > > had to do some tweaking), the changes made are as follows: > > > > 1. Replaced the old obsolete pattern: > > Verified that (X & -X) < 0 cannot fire after commit ff133b4cd22 (PR126627) > > outside -ftrapv. The obsolete pattern has been completely replaced with > > canonical matchers for both: > > - X == MIN ? MIN : X - 1 > > - X != MIN ? X - 1 : MIN > Essentially your pattern for 126627 will not fire with -fwrapv is > active, so we're still rely on the pattern you removed in this patch to > optimize that case, or am I misunderstanding something? It seems the > simple solution is to just keep the old pattern and add your new one. > > > 5. Test Verification Summary: > > - x86_64: gcc.dg/torture/pr127985.c passes runtime execution across > > all optimization levels (-O0, -O1, -O2, -O3, -Os). > > - RISC-V (rv64gc-lp64d): Verified on cc1 that sat_s_add_imm-1-i16.c > > restores the regression (2 .SAT_ADD instances found). > > - RISC-V (rv64gc-lp64d): Verified pr127985.c finds all 8 .SAT_ADD > > instances and produces branchless assembly (0 branch labels). > Since we're changing a generic file a full bootstrap and regression test > is required on one of the major targets (x86_64 and aarch64 are the most > common). > > Your patch fails to apply to the trunk. I would hazard a guess there's > a context difference because of other changes in this space. Given this > patch is meant to fix a regression, let's focus on getting this patch > under control first. > > If you can repost a version that works with the trunk it'd be hugely > appreciated. Sashiko ought to pick it up and I can do some regression > testing on it. > > Thanks! > > jeff > > From rguenther@suse.de Mon Nov 2 13:41:56 2026 From: rguenther@suse.de (Richard Biener) Date: Mon, 2 Nov 2026 14:41:56 +0100 (CET) Subject: [patch v2 8/14]middle-end: allow vector branches to consume conditional compare IFNs In-Reply-To: References: <60p29q24-n579-17s9-8805-1qq80767n685@fhfr.qr> Message-ID: On Mon, 2 Nov 2026, Tamar Christina wrote: > > -----Original Message----- > > From: Richard Biener > > Sent: 02 November 2026 12:25 > > To: Tamar Christina > > Cc: gcc-patches@gcc.gnu.org; nd > > Subject: Re: [patch v2 8/14]middle-end: allow vector branches to consume > > conditional compare IFNs > > > > On Thu, 22 Oct 2026, Tamar Christina wrote: > > > > > This patch lets vector branches consume the conditional compare IFNs > > added > > > earlier in the series. > > > > > > The IFNs need to survive long enough for branch expansion to see them, so > > the > > > patch marks the selected internal calls as TER-replaceable. It then teaches > > > emit_cmp_and_jump_insns to look through IFN_COND_VEC_CMP and > > > IFN_COND_LEN_VEC_CMP definitions when expanding vector conditions. > > > > > > For example, this source: > > > > > > int any_gt (int *a, int *b, int n) > > > { > > > for (int i = 0; i < n; ++i) > > > if (a[i] > b[i]) > > > return i; > > > return 0; > > > } > > > > > > Before this patch the tree-outof-ssa changes would fail as the new IFNs > > aren't > > > TER-able, mainly due to them not being standard optabs. Normally > > > direct_internal_fn_p is enough to consider an optab available, but for > > > comparisons we have to perform more checks and so direct_internal_fn_p is > > not > > > enough. > > > > > > That means the IFNs fail the check in ssa_is_replaceable_p. This adds a > > promise > > > essentially that if you see the IFN in the IL then the producer has checked it > > > and it's TER safe. > > > > > > This then updates the vec_cbranch_* code to support the new COND_* > > IFNs. > > > Without this we regress codegen to > > > > > > cmpgt p1.s, p0/z, z0.s, z1.s > > > ptest p0, p1.b > > > b.ne .Lhit > > > > > > and after this patch, branch expansion can see the compare IFN directly and > > pass > > > the original compare through the normal target compare-and-branch > > machinery: > > > > > > cmpgt p1.s, p0/z, z0.s, z1.s > > > b.any .Lhit > > > > > > For the length-controlled form, branch expansion preserves both the > > governing > > > mask and the length and bias. The existing vec_cbranch tests cover this > > path. > > > > > > Bootstrapped Regtested on aarch64-none-linux-gnu, > > > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > > > -m32, -m64 and no issues. > > > > > > -O3, profiled, profiled -O3 and -O3 -LTO bootstrap tested and no issues. > > > > > > Also SPECCPU 2017 and SPECCPU 2026 tested. > > > > > > OK for master? > > > > > > > > > gcc/ChangeLog: > > > > > > * internal-fn.cc (ter_replaceable_internal_fn_p): New function. > > > * internal-fn.h (ter_replaceable_internal_fn_p): Declare. > > > * optabs.cc (emit_cmp_and_jump_insns): Handle > > IFN_COND_VEC_CMP and > > > IFN_COND_LEN_VEC_CMP definitions. Preserve both the mask and > > length > > > when selecting length-controlled vector branches. Remove redundant > > > unsigned-condition conversion. > > > * tree-outof-ssa.cc (ssa_is_replaceable_p): Allow selected internal > > > calls that are not direct internal functions. > > > * tree-ssa-ter.cc: Include internal-fn.h. > > > (find_replaceable_in_bb): Do not count TER-replaceable internal > > > functions as calls. > > > > > > --- > > > diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc > > > index > > 99821efb9e9cdc9285b3af6bb681baf9dc97033e..e48fe4a497cbf0bfe31009 > > 46214c2a42db579d4b 100644 > > > --- a/gcc/internal-fn.cc > > > +++ b/gcc/internal-fn.cc > > > @@ -5693,6 +5693,28 @@ vectorized_internal_fn_supported_p > > (internal_fn ifn, tree type) > > > return false; > > > } > > > > > > +/* Return true if STMT is an internal function that has no side effects, does > > > + not clobber registers and will be expanded to a non-library call. */ > > > + > > > +bool ter_replaceable_internal_fn_p (gimple *stmt) > > > +{ > > > + if (!is_gimple_call (stmt) > > > + || !gimple_call_internal_p (stmt)) > > > + return false; > > > + > > > + switch (gimple_call_internal_fn (stmt)) > > > + { > > > + case IFN_COND_VEC_CMP: > > > + case IFN_COND_LEN_VEC_CMP: > > > + return true; > > > + > > > + default: > > > + return false; > > > + } > > > + > > > + return false; > > > +} > > > + > > > void > > > expand_SHUFFLEVECTOR (internal_fn, gcall *) > > > { > > > diff --git a/gcc/internal-fn.h b/gcc/internal-fn.h > > > index > > ac3a35eef62663267dd7ed8c749d02154208486b..8253f515b0fc46ccbf748 > > 6274791c4ea9bf38b9c 100644 > > > --- a/gcc/internal-fn.h > > > +++ b/gcc/internal-fn.h > > > @@ -295,6 +295,7 @@ extern bool expand_cond_vec_cmp_p (tree_code, > > tree, tree, tree); > > > extern bool expand_cond_len_vec_cmp_p (tree_code, tree, tree, tree, tree, > > tree); > > > > > > extern bool vectorized_internal_fn_supported_p (internal_fn, tree); > > > +extern bool ter_replaceable_internal_fn_p (gimple *); > > > > > > enum { > > > ATOMIC_OP_FETCH_CMP_0_EQ = 0, > > > diff --git a/gcc/optabs.cc b/gcc/optabs.cc > > > index > > a7988e0c26c992419871b97a157504e2d96ab434..5b34938e5e9896667c0 > > 0cc77de0d1948a3fb19cd 100644 > > > --- a/gcc/optabs.cc > > > +++ b/gcc/optabs.cc > > > @@ -5041,61 +5041,83 @@ emit_cmp_and_jump_insns (rtx x, rtx y, enum > > rtx_code comparison, rtx size, > > > > > > enum insn_code icode; > > > if (def_stmt > > > - && is_gimple_assign (def_stmt) > > > - && TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)) > > > - == tcc_comparison) > > > + && ((is_gimple_assign (def_stmt) > > > + && TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)) > > > + == tcc_comparison) > > > + || gimple_call_internal_p (def_stmt, IFN_COND_VEC_CMP) > > > + || gimple_call_internal_p (def_stmt, > > IFN_COND_LEN_VEC_CMP))) > > > { > > > class expand_operand ops[5]; > > > rtx_insn *tmp = NULL; > > > start_sequence (); > > > - tree t_op0 = gimple_assign_rhs1 (def_stmt); > > > - tree t_op1 = gimple_assign_rhs2 (def_stmt); > > > + tree t_op0, t_op1; > > > + tree_code inner_code; > > > + if (is_gimple_call (def_stmt)) > > > + { > > > + t_op0 = gimple_call_arg (def_stmt, 2); > > > + t_op1 = gimple_call_arg (def_stmt, 3); > > > + tree code_arg = gimple_call_arg (def_stmt, 0); > > > + inner_code = (tree_code) tree_to_uhwi (code_arg); > > > + } > > > + else > > > + { > > > + t_op0 = gimple_assign_rhs1 (def_stmt); > > > + t_op1 = gimple_assign_rhs2 (def_stmt); > > > + inner_code = gimple_assign_rhs_code (def_stmt); > > > + } > > > rtx op0c = expand_normal (t_op0); > > > rtx op1c = expand_normal (t_op1); > > > machine_mode mode2 = GET_MODE (op0c); > > > > > > - int nops = masked_op ? 3 : (len_op ? 5 : 2); > > > + int nops = len_op ? 5 : (masked_op ? 3 : 2); > > > int offset = masked_op || len_op ? 1 : 0; > > > create_input_operand (&ops[offset + 0], op0c, mode2); > > > create_input_operand (&ops[offset + 1], op1c, mode2); > > > - if (masked_op) > > > - { > > > - auto mask_mode = TYPE_MODE (TREE_TYPE (masked_op)); > > > - rtx mask_op = expand_normal (masked_op); > > > - create_input_operand (&ops[0], mask_op, mask_mode); > > > - } > > > - else if (len_op) > > > + if (len_op) > > > { > > > + machine_mode mask_mode; > > > + rtx mask_op; > > > rtx len_rtx = expand_normal (len_op); > > > rtx len_bias_rtx = expand_normal (len_bias); > > > - tree lhs = gimple_get_lhs (def_stmt); > > > - auto mask_mode = TYPE_MODE (TREE_TYPE (lhs)); > > > + if (masked_op) > > > + { > > > + mask_mode = TYPE_MODE (TREE_TYPE (masked_op)); > > > + mask_op = expand_normal (masked_op); > > > + } > > > + else > > > + { > > > + tree lhs = gimple_get_lhs (def_stmt); > > > + mask_mode = TYPE_MODE (TREE_TYPE (lhs)); > > > + mask_op = CONSTM1_RTX (mask_mode); > > > + } > > > /* ??? We could use something like internal_fn's > > > add_mask_else_and_len_args here. Currently it > > > only supports a fixed, consecutive order of > > > mask and len, though. */ > > > - create_input_operand (&ops[0], CONSTM1_RTX > > (mask_mode), > > > - mask_mode); > > > + create_input_operand (&ops[0], mask_op, mask_mode); > > > create_convert_operand_from > > > (&ops[3], len_rtx, TYPE_MODE (TREE_TYPE (len_op)), > > > TYPE_UNSIGNED (TREE_TYPE (len_op))); > > > create_input_operand (&ops[4], len_bias_rtx, QImode); > > > } > > > + else if (masked_op) > > > + { > > > + auto mask_mode = TYPE_MODE (TREE_TYPE (masked_op)); > > > + rtx mask_op = expand_normal (masked_op); > > > + create_input_operand (&ops[0], mask_op, mask_mode); > > > + } > > > > > > int unsignedp2 = TYPE_UNSIGNED (TREE_TYPE (t_op0)); > > > - auto inner_code = gimple_assign_rhs_code (def_stmt); > > > rtx test2 = NULL_RTX; > > > > > > enum rtx_code comparison2 = get_rtx_code (inner_code, > > unsignedp2); > > > - if (unsignedp2) > > > - comparison2 = unsigned_condition (comparison2); > > > if (comparison == NE) > > > - optab = masked_op ? cond_vec_cbranch_any_optab > > > - : len_op ? cond_len_vec_cbranch_any_optab > > > + optab = len_op ? cond_len_vec_cbranch_any_optab > > > + : masked_op ? cond_vec_cbranch_any_optab > > > : vec_cbranch_any_optab; > > > else > > > - optab = masked_op ? cond_vec_cbranch_all_optab > > > - : len_op ? cond_len_vec_cbranch_all_optab > > > + optab = len_op ? cond_len_vec_cbranch_all_optab > > > + : masked_op ? cond_vec_cbranch_all_optab > > > : vec_cbranch_all_optab; > > > > > > if ((icode = optab_handler (optab, mode2)) > > > diff --git a/gcc/tree-outof-ssa.cc b/gcc/tree-outof-ssa.cc > > > index > > c59c080383195d6ad96d9cc09090ad0ce6245703..80176fc9d35ea7669970 > > 55d59fe081d3f6dbaf0a 100644 > > > --- a/gcc/tree-outof-ssa.cc > > > +++ b/gcc/tree-outof-ssa.cc > > > @@ -72,7 +72,8 @@ ssa_is_replaceable_p (gimple *stmt) > > > && (!(call = dyn_cast (stmt)) > > > || gimple_call_tail_p (call) > > > || !gimple_call_internal_p (call) > > > - || !direct_internal_fn_p (gimple_call_internal_fn (call)))) > > > + || (!direct_internal_fn_p (gimple_call_internal_fn (call)) > > > + && !ter_replaceable_internal_fn_p (call)))) > > > > this does seem to be at the wrong abstraction level somehow given ... > > > > > return false; > > > > > > /* If the statement may throw an exception, it cannot be replaced. */ > > > diff --git a/gcc/tree-ssa-ter.cc b/gcc/tree-ssa-ter.cc > > > index > > 8dc26aa1907cbf25ee00b6cad524a0963a2b8839..5d6ccbb589e427f47d03 > > 92672bf1b3c41925671f 100644 > > > --- a/gcc/tree-ssa-ter.cc > > > +++ b/gcc/tree-ssa-ter.cc > > > @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see > > > #include "tree-ssa-ter.h" > > > #include "tree-outof-ssa.h" > > > #include "gimple-walk.h" > > > +#include "internal-fn.h" > > > > > > > > > /* Temporary Expression Replacement (TER) > > > @@ -686,6 +687,7 @@ find_replaceable_in_bb (temp_expr_table *tab, > > basic_block bb) > > > replacement over BUILT_IN calls since many will expand to inline > > > insns instead of a true call. */ > > > if (is_gimple_call (stmt) > > > + && !ter_replaceable_internal_fn_p (stmt) > > > > ... we don't check this in ter_is_replaceable_p, wo I'm not sure > > what you do is enough. > > > > It also seems this place should check direct_internal_fn_p as well > > (a pre-existing issue). Just adding && !ter_replaceable_internal_fn_p > > makes this feel inconsistent. > > I couldn't figure out why ssa_is_replaceable_p checks for direct_internal_fn_p > If I'm honest, because the conditions it requires are not property of the way of > expanding the IFN but rather properties of the definition of the IFN. i.e. not > trapping, no VOPS etc. > > That's why the expansion code doesn't actually care because it calls expand_internal_call. > > Initially I was going to just remove it from ssa_is_replaceable_p, but wasn't sure. > > Do you know why it checks this? ISTR this is done to avoid scheduling side-effects (including aliasing) across invalid points and also to avoid breaking how we expand calls (so only ever have ssa_is_replaceable_p true when we're sure to not go through expand_call). TER is fincky, one more reason to get rid of it (and not extend it ...). ISTR I added direct_internal_fn_p because we got so many of those that not TER-ing them regressed things. The find_replaceable_in_bb code should possibly just re-use the is_replaceable computation we already do, but I'm sure you're going to hit corner-cases (the call counting is to avoid TER-ing other stuff across calls IIRC). Richard. > > Thanks, > Tamar > > > > > Richard. > > > > > && !((fndecl = gimple_call_fndecl (stmt)) > > > && fndecl_built_in_p (fndecl))) > > > cur_call_cnt++; > > > > > > > > > > > > > -- > > Richard Biener > > SUSE Software Solutions Germany GmbH, > > Frankenstrasse 146, 90461 Nuernberg, Germany; > > GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From rguenther@suse.de Mon Nov 2 13:43:24 2026 From: rguenther@suse.de (Richard Biener) Date: Mon, 2 Nov 2026 14:43:24 +0100 (CET) Subject: [patch v2 9/14][isel]: form conditional vector compare IFNs In-Reply-To: References: Message-ID: <4pq2nq1q-oonr-77s9-opnn-r264opn09s7o@fhfr.qr> On Mon, 2 Nov 2026, Tamar Christina wrote: > > -----Original Message----- > > From: Richard Biener > > Sent: 02 November 2026 12:38 > > To: Tamar Christina > > Cc: gcc-patches@gcc.gnu.org; nd ; > > jeffrey.law@oss.qualcomm.com > > Subject: Re: [patch v2 9/14][isel]: form conditional vector compare IFNs > > > > On Thu, 22 Oct 2026, Tamar Christina wrote: > > > > > This patch forms conditional vector compare IFNs during gimple isel. > > > > > > The match.pd rules recognize integer vector compare idioms where a > > compare is > > > guarded by another vector predicate. gimple isel then lowers those idioms > > to > > > IFN_COND_VEC_CMP or IFN_COND_LEN_VEC_CMP when the target reports > > support for the > > > corresponding optab. If the original compare was only used by the > > converted > > > statement, the patch removes that now-dead definition. > > > > > > The tests for this lowering are kept with the later AArch64 SVE expander > > patch, > > > since they require the SVE cond_vec_cmp target support added there. > > > > > > Bootstrapped Regtested on aarch64-none-linux-gnu, > > > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > > > -m32, -m64 and no issues. > > > > > > -O3, profiled, profiled -O3 and -O3 -LTO bootstrap tested and no issues. > > > > > > Also SPECCPU 2017 and SPECCPU 2026 tested. > > > > > > OK for master? > > > > If you are here, can you expand the IFN_VCOND_MASK[_LEN] docs in > > doc/ifn.texi? > > > > Also ... > > > > > gcc/ChangeLog: > > > > > > * gimple-isel.cc (gimple_convert_conditional_compare): Declare. > > > (gimple_convert_conditional_len_compare): Likewise. > > > (maybe_duplicate_comparison): Fix comment. > > > (gimple_expand_conditional_compare): New function. Form > > conditional > > > vector compare IFNs when supported and identify a dead original > > > comparison for removal. > > > (pass_gimple_isel::execute): Use it and remove the original > > comparison > > > when it has no remaining uses. > > > * match.pd (convert_conditional_compare): New match for masked > > > non-floating-point vector comparisons. > > > (convert_conditional_len_compare): New match for length-masked > > > non-floating-point vector comparisons. > > > > > > --- > > > diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc > > > index > > 1d346ee124ffdfdccf658ea79cc72cbf80240f81..9bd523cd81be541383ea9c9 > > 62a9180565cea9f0d 100644 > > > --- a/gcc/gimple-isel.cc > > > +++ b/gcc/gimple-isel.cc > > > @@ -327,8 +327,8 @@ maybe_duplicate_comparison (gassign *stmt, > > basic_block bb) > > > tree lhs = gimple_assign_lhs (stmt); > > > unsigned cnt = 0; > > > > > > - /* This is should not be used for -O0 nor it is not useful > > > - when ter is turned off. */ > > > + /* This should not be used for -O0 and is not useful when TER is turned > > > + off. */ > > > if (!optimize || !flag_tree_ter) > > > return; > > > > > > @@ -376,6 +376,9 @@ maybe_duplicate_comparison (gassign *stmt, > > basic_block bb) > > > extern bool gimple_nop_atomic_bit_test_and_p (tree, tree *, > > > tree (*) (tree)); > > > extern bool gimple_nop_convert (tree, tree*, tree (*) (tree)); > > > +extern bool gimple_convert_conditional_compare (tree, tree *, tree (*) > > (tree)); > > > +extern bool gimple_convert_conditional_len_compare (tree, tree *, > > > + tree (*) (tree)); > > > > > > namespace { > > > > > > @@ -488,6 +491,74 @@ convert_atomic_bit_not (enum internal_fn fn, > > gimple *use_stmt, > > > return use_stmt; > > > } > > > > > > +/* Try to replace STMT with a conditional vector comparison internal > > function. > > > + The generated matchers recognize the source patterns and capture the > > mask, > > > + operands and original comparison SSA name. If the original comparison is > > > + used only by STMT, store its defining statement in *DEAD_CMP_DEF so > > that the > > > + caller can remove it after replacing STMT. */ > > > + > > > +static gimple * > > > +gimple_expand_conditional_compare (gimple_stmt_iterator *gsi, > > > + gassign **dead_cmp_def) > > > +{ > > > + gimple *stmt = gsi_stmt (*gsi); > > > + *dead_cmp_def = nullptr; > > > + tree lhs = gimple_get_lhs (stmt); > > > + > > > + if (!lhs || TREE_CODE (lhs) != SSA_NAME) > > > + return nullptr; > > > + > > > + tree ops[6] = {}; > > > + location_t loc = gimple_location (stmt); > > > + bool len_p = false; > > > + if (!gimple_convert_conditional_compare (lhs, ops, nullptr) > > > + && !gimple_convert_conditional_len_compare (lhs, ops, nullptr)) > > > + return nullptr; > > > + len_p = ops[4] != NULL_TREE; > > > + > > > + unsigned int cmp_opno = len_p ? 5 : 3; > > > + tree cmp_name = ops[cmp_opno]; > > > + if (TREE_CODE (cmp_name) != SSA_NAME) > > > + return nullptr; > > > + > > > + gassign *cmp_def = dyn_cast (SSA_NAME_DEF_STMT > > (cmp_name)); > > > + if (!cmp_def) > > > + return nullptr; > > > + > > > + tree_code code = gimple_assign_rhs_code (cmp_def); > > > + if (TREE_CODE_CLASS (code) != tcc_comparison) > > > + return nullptr; > > > + > > > + internal_fn ifn = len_p ? IFN_COND_LEN_VEC_CMP : > > IFN_COND_VEC_CMP; > > > + bool supported_p > > > + = (len_p > > > + ? expand_cond_len_vec_cmp_p (code, ops[0], ops[1], ops[2], > > > + ops[3], ops[4]) > > > + : expand_cond_vec_cmp_p (code, ops[0], ops[1], ops[2])); > > > + if (!supported_p) > > > + return nullptr; > > > + > > > + auto_vec args; > > > + args.quick_push (build_int_cst (integer_type_node, code)); > > > + args.quick_push (ops[0]); > > > + args.quick_push (ops[1]); > > > + args.quick_push (ops[2]); > > > + if (len_p) > > > + { > > > + args.quick_push (ops[3]); > > > + args.quick_push (ops[4]); > > > + } > > > + > > > + gcall *call = gimple_build_call_internal_vec (ifn, args); > > > + gimple_call_set_lhs (call, lhs); > > > + gimple_set_location (call, loc); > > > + use_operand_p use_p; > > > + gimple *use_stmt; > > > + if (single_imm_use (cmp_name, &use_p, &use_stmt) && use_stmt == > > stmt) > > > + *dead_cmp_def = cmp_def; > > > + return call; > > > +} > > > + > > > /* Optimize > > > mask_2 = 1 << cnt_1; > > > _4 = __atomic_fetch_or_* (ptr_6, mask_2, _3); > > > @@ -1369,6 +1440,20 @@ pass_gimple_isel::execute (struct function *fun) > > > /* Give the target first try at replacing the instruction. */ > > > cfg_changed |= targetm.instruction_selection (fun, &gsi); > > > > > > + gimple *isel_stmt = NULL; > > > + gassign *dead_cmp_def = NULL; > > > + if (!gsi_end_p (gsi)) > > > + isel_stmt = gimple_expand_conditional_compare (&gsi, > > &dead_cmp_def); > > > + if (isel_stmt) > > > + { > > > + gsi_replace (&gsi, isel_stmt, true); > > > + if (dead_cmp_def) > > > + { > > > + gimple_stmt_iterator cmp_gsi = gsi_for_stmt > > (dead_cmp_def); > > > + gsi_remove (&cmp_gsi, true); > > > + } > > > + } > > > + > > > > You are adding this before we generate .VCOND_MASK? Please wrap > > the thing into a function wrapping gimple_expand_conditional_compare. > > I'm not exactly happy with the "driver" of ISEL and the uncommon > > interface to how workers leave 'gsi' ... > > > > > /* Pre-expand VEC_COND_EXPRs to .VCOND* internal function > > > calls mapping to supported optabs. */ > > > gimple *g = gimple_expand_vec_cond_expr (&gsi); > > > @@ -1411,4 +1496,3 @@ make_pass_gimple_isel (gcc::context *ctxt) > > > { > > > return new pass_gimple_isel (ctxt); > > > } > > > - > > > diff --git a/gcc/match.pd b/gcc/match.pd > > > index > > f3d9e55f1390ab4185b3dff1f59d60e10b138cb4..4557dccad60c02fe821b3 > > 90752bfefa14209bceb 100644 > > > --- a/gcc/match.pd > > > +++ b/gcc/match.pd > > > @@ -13782,4 +13782,17 @@ and, > > > || (minmax == MAX_EXPR > > > && wi::le_p (wi::to_wide (@1), bound, TYPE_SIGN (type)))) > > > @3))))) > > > + > > > +(match (convert_conditional_compare @0 @1 @2 @3) > > > + (bit_and:c @0 (tcc_comparison@3 @1 @2)) > > > + (if (VECTOR_BOOLEAN_TYPE_P (type) > > > + && !FLOAT_TYPE_P (TREE_TYPE (@1))))) > > > > this isn't equal to .VCOND_CMP as it will mask IEEE exceptions from > > masked compares, so it would need -fno-trapping-math, correct? > > > > Yeah, the GIMPLE semantics here were a bit confusing to me. > because technically speaking on > > a = b `fcmp` c > a' = a & mask, > > the flags get thrown on a, and a' just silences them. So in GIMPLE > the trapping behaviour is a bit.. iffy and so I didn't change them. > > Technically speaking using the masked compares here would be > more correct, but would also trigger for i.e. gcc vector extensions. > > That said, the backend would have applied the masking anyway. > > So I dunno, maybe it should just work for floats always, but yes > adding a check on trapping math at the very least makes sense. Iff the source has originally non-trapping (masked) compares the vectorizer would already see .COND_CMP from ifcvt, so yes, a check on trapping math is required for correctness IMO. > Thanks, > Tamar > > > > + > > > +/* Transform .VCOND_MASK_LEN (a `cmp` b, {-1, ...}, {0, ...}, len, bias) > > > + into cond_len_vec_cmp (cmp, {-1, ...}, a, b, len, bias). */ > > > > Same here? Why not .VCOND_MASK as well? > > > > > +(match (convert_conditional_len_compare @0 @1 @2 @3 @4 @5) > > > + (IFN_VCOND_MASK_LEN (tcc_comparison@5 @1 @2) > > > + integer_minus_onep@0 integer_zerop @3 @4) > > > + (if (VECTOR_BOOLEAN_TYPE_P (type) > > > + && !FLOAT_TYPE_P (TREE_TYPE (@1))))) > > > #endif > > > > > > > > > > > > > -- > > Richard Biener > > SUSE Software Solutions Germany GmbH, > > Frankenstrasse 146, 90461 Nuernberg, Germany; > > GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From rguenther@suse.de Mon Nov 2 13:45:37 2026 From: rguenther@suse.de (Richard Biener) Date: Mon, 2 Nov 2026 14:45:37 +0100 (CET) Subject: [patch v2 14/14][vect]: allow degenerate SLP permutations for early loads In-Reply-To: References: Message-ID: <7r437qr2-ss1q-827n-o21n-106876s5n44r@fhfr.qr> On Mon, 2 Nov 2026, Tamar Christina wrote: > > -----Original Message----- > > From: Richard Biener > > Sent: 02 November 2026 12:53 > > To: Tamar Christina > > Cc: gcc-patches@gcc.gnu.org; nd ; rdapp.gcc@gmail.com > > Subject: Re: [patch v2 14/14][vect]: allow degenerate SLP permutations for > > early loads > > > > On Thu, 22 Oct 2026, Tamar Christina wrote: > > > > > This patch relaxes one speculative-load check used by early-break > > vectorization. > > > The vectorizer correctly rejects SLP load permutations for speculative loads > > > because an arbitrary permutation can invalidate the load layout > > assumptions. > > > However, an all-zero permutation is fine when the group has no gaps, > > including > > > permutations such as { 0, 0, 0, 0 } for multi-element groups. It only replicates > > > the first element of each scalar iteration's group and does not change the > > > alignment or footprint of the input loads. The existing checks still require > > > alignment for the whole group and check the speculative read amount > > against the > > > page size. > > > > > > A simplified C example is: > > > > > > void **find_ptr (void **first, void **last, void *needle) > > > { > > > while (first != last && *first != needle) > > > ++first; > > > return first; > > > } > > > > > > Before this patch the vectorizer could reject the speculative load because it > > > saw an SLP load permutation and treated it like a real permute: > > > > > > missed: loads with load permutations not supported for speculative loads > > > > > > After this patch, all-zero load permutations are accepted for groups without > > > gaps, and the loop can continue down the early-break vectorization path. > > > > > > Bootstrapped Regtested on aarch64-none-linux-gnu, > > > arm-none-linux-gnueabihf, x86_64-pc-linux-gnu > > > -m32, -m64 and no issues. > > > > > > -O3, profiled, profiled -O3 and -O3 -LTO bootstrap tested and no issues. > > > > > > Also SPECCPU 2017 and SPECCPU 2026 tested. > > > > > > Any feedback? > > > > Would that, by extension, not be the same for any uniform load > > permutation? So even for { 1, 1, 1 ... } for a multi-element group? > > The reasoning is that the first iteration is executed, so any further > > iteration does not change whether that element load trapped, right? > > > > If the group access isn't change indeed. I was conservative here because > I wasn't sure if this scenario could happen. Consider > > [0 1 . .][0 1 . .] > > I was concerned that instead we could optimize this by changing base to > be base + 1, and loading [1 0 . 1] instead. I suppose we'd block this later > but [0 0 0 ..] was easier to reason about. But Maybe I'm too conservative. > > > I'll note that this isn't universally true but only when all > > scalar elements of one vector iterations load the same element > > which depends on a) VF, b) the group size, so I think you are > > lacking some multiple-of checks here. > > > > Hmm will check. Don't immediately follow this one. If you have a { 0, 0 } load permutation of a group size of two with zero gap and the VF is so that we'll have two 4 element vectors you really load { 0, 0, 2, 2 }, { 4, 4, 6, 6 } in the first vector iteration and your argument breaks down. Richard. > Thanks for the reviews!, > Tamar > > > Richard. > > > > > Thanks, > > > Tamar > > > > > > gcc/ChangeLog: > > > > > > * tree-vect-stmts.cc (get_load_store_type): Allow all-zero SLP load > > > permutations for speculative loads from groups without gaps, > > including > > > multi-element groups. Update the diagnostic. > > > > > > gcc/testsuite/ChangeLog: > > > > > > * g++.dg/vect/vect-early-break-pr-spec-find.cc: New test. > > > > > > --- > > > diff --git a/gcc/testsuite/g++.dg/vect/vect-early-break-pr-spec-find.cc > > b/gcc/testsuite/g++.dg/vect/vect-early-break-pr-spec-find.cc > > > new file mode 100644 > > > index > > 0000000000000000000000000000000000000000..05e82345f0214d70da > > 355a07053e10a9a069ab73 > > > --- /dev/null > > > +++ b/gcc/testsuite/g++.dg/vect/vect-early-break-pr-spec-find.cc > > > @@ -0,0 +1,96 @@ > > > +/* { dg-do compile } */ > > > +/* { dg-add-options vect_early_break } */ > > > +/* { dg-require-effective-target vect_early_break } */ > > > +/* { dg-require-effective-target vect_long_long } */ > > > +/* { dg-additional-options "-O3 -fno-tree-loop-distribute-patterns" } */ > > > + > > > +struct X; > > > + > > > +template > > > +struct iter_equals_val > > > +{ > > > + Value& value; > > > + > > > + explicit > > > + iter_equals_val (Value& val) > > > + : value (val) > > > + {} > > > + > > > + template > > > + bool > > > + operator() (Iter it) > > > + { return *it == value; } > > > +}; > > > + > > > +template > > > +inline Iter > > > +find_if (Iter first, Iter last, Pred pred) > > > +{ > > > +#pragma GCC unroll 4 > > > + while (first != last && !pred (first)) > > > + ++first; > > > + return first; > > > +} > > > + > > > +__attribute__((noipa, noinline)) > > > +X ** > > > +find_ptr (X **first, X **last, X *needle) > > > +{ > > > + iter_equals_val pred (needle); > > > + return find_if (first, last, pred); > > > +} > > > + > > > +struct object_pool > > > +{ > > > + X **first; > > > + X **last; > > > + > > > + __attribute__((noipa, noinline)) > > > + bool > > > + return_object (X *needle, bool reset) > > > + { > > > + iter_equals_val pred (needle); > > > + X **pos = find_if (first, last, pred); > > > + if (pos == last) > > > + return false; > > > + > > > + if (!reset) > > > + { > > > + for (X **it = pos; it + 1 != last; ++it) > > > + *it = *(it + 1); > > > + --last; > > > + } > > > + > > > + return true; > > > + } > > > +}; > > > + > > > +__attribute__((noipa, noinline)) > > > +bool > > > +return_to_pool (object_pool *pool, X *needle, bool reset) > > > +{ > > > + return pool->return_object (needle, reset); > > > +} > > > + > > > +__attribute__((noipa, noinline)) > > > +bool > > > +dom_string_equals (const unsigned short *lhs, unsigned long lhs_length, > > > + const unsigned short *rhs, unsigned long rhs_length) > > > +{ > > > + if (lhs_length != rhs_length) > > > + return false; > > > + if (lhs_length == 0) > > > + return true; > > > + > > > + const unsigned short *end = lhs + lhs_length; > > > + while (*lhs == *rhs) > > > + { > > > + ++lhs; > > > + if (lhs == end) > > > + return true; > > > + ++rhs; > > > + } > > > + return false; > > > +} > > > + > > > +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ > > > diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc > > > index > > 3bb10d4b9a9eee94cc6bce565ba78afc5fb243ab..72a44b278d298019d483 > > 24aa739aa58544f89645 100644 > > > --- a/gcc/tree-vect-stmts.cc > > > +++ b/gcc/tree-vect-stmts.cc > > > @@ -2644,13 +2644,25 @@ get_load_store_type (vec_info *vinfo, > > stmt_vec_info stmt_info, > > > the blend. This is what the x86_64 backend does for instance. As > > > such only the first load in the group is aligned, the rest are not. > > > Because of this the permutes may break the alignment requirements > > that > > > - have been set, and as such we should for now, reject them. */ > > > - if (SLP_TREE_LOAD_PERMUTATION (slp_node).exists ()) > > > + have been set, and as such we should for now, reject them. However, > > > + an all-zero permutation of a group without gaps only replicates the > > > + first element of each scalar iteration's group. It does not change > > > + the alignment or the footprint of the input loads, which the checks > > > + above account for using the whole group size. */ > > > + load_permutation_t perm = SLP_TREE_LOAD_PERMUTATION > > (slp_node); > > > + bool all_zero_p = true; > > > + for (unsigned int index : perm) > > > + if (index != 0) > > > + { > > > + all_zero_p = false; > > > + break; > > > + } > > > + if (perm.exists () && (gap != 0 || !all_zero_p)) > > > { > > > if (dump_enabled_p ()) > > > dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, > > > "loads with load permutations not supported for " > > > - "speculative early break loads for %G", > > > + "speculative loads for %G", > > > STMT_VINFO_STMT (stmt_info)); > > > return false; > > > } > > > > > > > > > > > > > -- > > Richard Biener > > SUSE Software Solutions Germany GmbH, > > Frankenstrasse 146, 90461 Nuernberg, Germany; > > GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From ktkachov@nvidia.com Mon Nov 2 14:19:18 2026 From: ktkachov@nvidia.com (ktkachov@nvidia.com) Date: Mon, 2 Nov 2026 15:19:18 +0100 Subject: [PATCH 1/4] ifcvt, aarch64: Make the outside-loop profitability rule work Message-ID: <20261102141921.88485-1-ktkachov@nvidia.com> From: Kyrylo Tkachov The AArch64 if-conversion hook intends to accept candidates outside loops without applying its CSEL cost limit, because the branch predictor has little history to train on there. The check has never fired. In ce1 the loop tree is still there, but a block outside every loop belongs to the root loop, whose header is the entry block, so testing for a null header does not find it. In ce2 and ce3 if_convert frees the loop tree before it examines candidates, so current_loops is null. Record natural-loop membership before the loop tree is freed and pass it to the target in noce_if_info. Use it in the AArch64 hook, and apply the rule only when optimizing for speed, since it is about branch prediction. find_if_case_1 gives the jump block it creates the index of the THEN block it deletes, so assert that this block has one successor and therefore can never be the test block of a later conversion. Add tests for the same dependent sequence inside and outside a loop, for outside-loop acceptance with explicit low cost limits, and for -Os keeping the branch. Bootstrapped and tested on aarch64-none-linux-gnu. Ok for trunk? Thanks, Kyrill gcc/ChangeLog: * ifcvt.h (noce_if_info): Add in_loop. * ifcvt.cc (bbs_in_loops): New bitmap. (noce_find_if_block): Set in_loop. (find_if_case_1): Assert that the replacement block has one successor. (if_convert): Record loop membership before finalizing loops. Release the bitmap at the end of the pass. * config/aarch64/aarch64.cc (aarch64_noce_conversion_profitable_p): Use in_loop, and only when optimizing for speed. gcc/testsuite/ChangeLog: * gcc.target/aarch64/if_conv_outside_loop_1.c: New test. * gcc.target/aarch64/if_conv_outside_loop_2.c: Likewise. * gcc.target/aarch64/if_conv_outside_loop_3.c: Likewise. Signed-off-by: Kyrylo Tkachov --- gcc/config/aarch64/aarch64.cc | 11 ++--- gcc/ifcvt.cc | 13 +++++ gcc/ifcvt.h | 3 ++ .../aarch64/if_conv_outside_loop_1.c | 47 +++++++++++++++++++ .../aarch64/if_conv_outside_loop_2.c | 33 +++++++++++++ .../aarch64/if_conv_outside_loop_3.c | 29 ++++++++++++ 6 files changed, 129 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/if_conv_outside_loop_1.c create mode 100644 gcc/testsuite/gcc.target/aarch64/if_conv_outside_loop_2.c create mode 100644 gcc/testsuite/gcc.target/aarch64/if_conv_outside_loop_3.c diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 948967982dd..7a73a441f98 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -2405,13 +2405,10 @@ static bool aarch64_noce_conversion_profitable_p (rtx_insn *seq, struct noce_if_info *if_info) { - /* If not in a loop, just accept all if-conversion as the branch predictor - won't have anything to train on. So assume sequences are essentially - unpredictable. ce1 is in CFG mode still while ce2 is outside. For ce2 - accept limited if-conversion based on the shape of the instruction. */ - if (current_loops - && (!if_info->test_bb->loop_father - || !if_info->test_bb->loop_father->header)) + /* Outside loops the branch predictor has little history to train on, so + treat the branch as unpredictable and accept the sequence when + optimizing for speed. */ + if (if_info->speed_p && !if_info->in_loop) return true; /* For now we only care about csel speciifcally. */ diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc index fad341ead6c..8cc8ab1c369 100644 --- a/gcc/ifcvt.cc +++ b/gcc/ifcvt.cc @@ -92,6 +92,9 @@ static int num_true_changes; successful conversion sets it, not only the conditional-execution one. */ static bool ifcvt_changed_p; +/* Blocks that are inside a loop at the start of this pass. */ +static bitmap_head bbs_in_loops; + /* Forward references. */ static bool noce_operand_ok (const_rtx); static void merge_if_block (ce_if_block *); @@ -5514,6 +5517,7 @@ noce_find_if_block (basic_block test_bb, edge then_edge, edge else_edge, if_info.jump = jump; if_info.then_else_reversed = then_else_reversed; if_info.speed_p = speed_p; + if_info.in_loop = bitmap_bit_p (&bbs_in_loops, test_bb->index); if_info.max_seq_cost = targetm.max_noce_ifcvt_seq_cost (then_edge); /* We'll add in the cost of THEN_BB and ELSE_BB later, when we check @@ -6377,6 +6381,9 @@ find_if_case_1 (basic_block test_bb, edge then_edge, edge else_edge) block we removed. */ if (new_bb) { + /* NEW_BB takes the index, and so the bbs_in_loops bit, of THEN_BB. + That bit is only read for a block that ends in a conditional jump. */ + gcc_checking_assert (single_succ_p (new_bb)); df_bb_replace (then_bb_index, new_bb); /* This should have been done above via force_nonfallthru_and_redirect (possibly called from redirect_edge_and_branch_force). */ @@ -6810,6 +6817,10 @@ if_convert (ifcvt_phase phase) loop_optimizer_init (AVOID_CFG_MODIFICATIONS); mark_loop_exit_edges (); + bitmap_initialize (&bbs_in_loops, &bitmap_default_obstack); + FOR_EACH_BB_FN (bb, cfun) + if (bb_loop_depth (bb) != 0) + bitmap_set_bit (&bbs_in_loops, bb->index); loop_optimizer_finalize (); free_dominance_info (CDI_DOMINATORS); @@ -6851,6 +6862,8 @@ if_convert (ifcvt_phase phase) free_dominance_info (CDI_POST_DOMINATORS); + bitmap_release (&bbs_in_loops); + if (dump_file) fflush (dump_file); diff --git a/gcc/ifcvt.h b/gcc/ifcvt.h index 806ad47158e..8347e0e8bc8 100644 --- a/gcc/ifcvt.h +++ b/gcc/ifcvt.h @@ -120,6 +120,9 @@ struct noce_if_info we're optimizing for size. */ bool speed_p; + /* True if TEST_BB was inside a loop at the start of this pass. */ + bool in_loop; + /* An estimate of the cost of the original, un-converted if-region. It covers COND and JUMP plus the arms: both arms when optimizing for size, and their branch-probability-weighted average when optimizing for speed, diff --git a/gcc/testsuite/gcc.target/aarch64/if_conv_outside_loop_1.c b/gcc/testsuite/gcc.target/aarch64/if_conv_outside_loop_1.c new file mode 100644 index 00000000000..c9bb3960aa6 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/if_conv_outside_loop_1.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* The target accepts if-conversion outside loops without a cost limit. */ + +int +outside_loop (int v, int threshold) +{ + int t = v; + if (v > threshold) + { + t = v * 3; + t += 7; + t ^= 0x55; + t *= 0x55; + t -= 5; + t &= 0xFE; + t ^= 0x55; + } + return t; +} + +/* The same sequence inside a loop exceeds the cost limit. */ + +int +inside_loop (int n, const int *a, int threshold) +{ + int s = 0; + for (int i = 0; i < n; i++) + { + int v = a[i], t = v; + if (v > threshold) + { + t = v * 3; + t += 7; + t ^= 0x55; + t *= 0x55; + t -= 5; + t &= 0xFE; + t ^= 0x55; + } + s += t; + } + return s; +} + +/* { dg-final { scan-assembler-times "\\tcsel\\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/if_conv_outside_loop_2.c b/gcc/testsuite/gcc.target/aarch64/if_conv_outside_loop_2.c new file mode 100644 index 00000000000..732d23ec6fb --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/if_conv_outside_loop_2.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mcpu=olympus --param=max-rtl-if-conversion-unpredictable-cost=1 --param=max-rtl-if-conversion-predictable-cost=1 -fdump-rtl-ce1" } */ + +/* Outside loops, the target accepts the sequence before checking its cost. */ + +volatile unsigned long output[2]; + +void +select_values (unsigned long c, unsigned long x, unsigned long y) +{ + unsigned long a, b; + if (c > 7) + { + a = x + 9; + a ^= y; + a >>= 2; + a += 5; + a ^= y; + a >>= 3; + a += 13; + a ^= y; + b = 2; + } + else + { + a = x + 9; + b = 3; + } + output[0] = a; + output[1] = b; +} + +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through noce_convert_multiple_sets" 1 "ce1" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/if_conv_outside_loop_3.c b/gcc/testsuite/gcc.target/aarch64/if_conv_outside_loop_3.c new file mode 100644 index 00000000000..0350c80eb34 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/if_conv_outside_loop_3.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ + +/* Outside loops the target skips its cost check only when optimizing for + speed. When optimizing for size the three selects are larger than the + branch they replace. */ + +void sink3 (long, long, long); + +void +f (long c) +{ + long a, b, d; + if (c == 3) + { + a = 5; + b = 7; + d = 13; + } + else + { + a = 9; + b = 11; + d = 17; + } + sink3 (a, b, d); +} + +/* { dg-final { scan-assembler-not "\\tcsel\\t" } } */ -- 2.54.0 (Apple Git-157) From ktkachov@nvidia.com Mon Nov 2 14:19:21 2026 From: ktkachov@nvidia.com (ktkachov@nvidia.com) Date: Mon, 2 Nov 2026 15:19:21 +0100 Subject: [PATCH 4/4] AArch64: Limit the CINC exception in the if-conversion cost check In-Reply-To: <20261102141921.88485-1-ktkachov@nvidia.com> References: <20261102141921.88485-1-ktkachov@nvidia.com> Message-ID: <20261102141921.88485-4-ktkachov@nvidia.com> From: Kyrylo Tkachov aarch64_noce_conversion_profitable_p skips its cost check when any instruction of the sequence adds or subtracts one from a register, because the select is then likely a CSINC. It looks at every instruction, so a long sequence that happens to contain an increment is accepted however long it is. In for (int i = 0; i < n; i++) if (a[i] > lim) { cnt++; s += a[i] * 3; t ^= a[i] * 5; } the counter makes the whole multiple-set sequence pass, and the loop then computes all three updates on every iteration, even when the arm is rarely taken. Skip the cost check only when, apart from comparisons, the sequence is one increment and one conditional select that uses it, which is the shape that becomes a single CSINC. Other sequences go through the cost check. This relies on the parallel cost estimate of the previous patch. Under the serial cost, the multiple-set conversions that ifcvt_multiple_sets_arithm.c and ifcvt_multiple_sets_diamond_{2,5}.c expect fail the cost check and pass only through this exception. This patch gives another 0.5% on top of the previous patches on Snappy compress performance on NVIDIA Vera (taking the total gain from the series to about 5%) Bootstrapped and tested on aarch64-none-linux-gnu. Ok for trunk? Thanks, Kyrill Cc: Tamar Christina gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_noce_conversion_profitable_p): Skip the cost check for an increment only if the sequence is that increment and one conditional select that uses it. gcc/testsuite/ChangeLog: * gcc.target/aarch64/pr123017_8.c: New test. Signed-off-by: Kyrylo Tkachov --- gcc/config/aarch64/aarch64.cc | 66 +++++++++++-------- gcc/testsuite/gcc.target/aarch64/pr123017_8.c | 59 +++++++++++++++++ 2 files changed, 98 insertions(+), 27 deletions(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/pr123017_8.c diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 282be9a9b1c..7cc741074a8 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -2426,34 +2426,46 @@ aarch64_noce_conversion_profitable_p (rtx_insn *seq, && !SUBREG_P (if_info->b)) is_csel_p = false; - for (rtx_insn *insn = seq; is_csel_p && insn; insn = NEXT_INSN (insn)) - { - rtx set = single_set (insn); - if (!set) - continue; - - rtx src = SET_SRC (set); - rtx dst = SET_DEST (set); - machine_mode mode = GET_MODE (src); - if (GET_MODE_CLASS (mode) != MODE_INT) - continue; + /* A CSINC selects between a register and another register plus or minus + one, so an increment that feeds a select costs no extra instruction. + Treat such a sequence like the cases above, but only if the increment + and the select are all it computes apart from comparisons. An + increment elsewhere in a longer sequence says nothing about the rest of + it. */ + if (is_csel_p) + { + rtx inc = NULL_RTX, sel = NULL_RTX; + unsigned int nsets = 0; + for (rtx_insn *insn = seq; insn; insn = NEXT_INSN (insn)) + { + if (!NONDEBUG_INSN_P (insn)) + continue; + rtx set = single_set (insn); + if (set && GET_MODE_CLASS (GET_MODE (SET_DEST (set))) == MODE_CC) + continue; + nsets++; + if (!set) + continue; - switch (GET_CODE (src)) - { - case PLUS: - case MINUS: - { - /* Likely a CINC. */ - if (REG_P (dst) - && (REG_P (XEXP (src, 0)) || SUBREG_P (XEXP (src, 0))) - && (XEXP (src, 1) == CONST1_RTX (mode) - || XEXP (src, 1) == CONSTM1_RTX (mode))) - is_csel_p = false; - break; - } - default: - break; - } + rtx src = SET_SRC (set); + machine_mode mode = GET_MODE (src); + if (GET_CODE (src) == IF_THEN_ELSE) + sel = src; + else if ((GET_CODE (src) == PLUS || GET_CODE (src) == MINUS) + && GET_MODE_CLASS (mode) == MODE_INT + && REG_P (SET_DEST (set)) + && (REG_P (XEXP (src, 0)) || SUBREG_P (XEXP (src, 0))) + && (XEXP (src, 1) == CONST1_RTX (mode) + || XEXP (src, 1) == CONSTM1_RTX (mode))) + inc = SET_DEST (set); + } + + if (nsets == 2 + && inc + && sel + && (rtx_equal_p (XEXP (sel, 1), inc) + || rtx_equal_p (XEXP (sel, 2), inc))) + is_csel_p = false; } /* For now accept every variant but csel unconditionally because CSEL usually diff --git a/gcc/testsuite/gcc.target/aarch64/pr123017_8.c b/gcc/testsuite/gcc.target/aarch64/pr123017_8.c new file mode 100644 index 00000000000..da7596946c8 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr123017_8.c @@ -0,0 +1,59 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* An increment inside a longer arm does not make the select a CSINC, so + the cost limit still applies. */ + +void +chain (const int *restrict in, int *restrict out, int n, int threshold) +{ + for (int i = 0; i < n; ++i) + { + int v = in[i]; + if (v > threshold) + { + int t = v * 3; + t += 1; + t ^= 0x55; + t *= 0x55; + t -= 0x5; + t &= 0xFE; + t ^= 0x55; + out[i] = t; + } + else + out[i] = v; + } +} + +int +multi (const int *a, int n, int lim) +{ + int cnt = 0, s = 0, t = 0; + for (int i = 0; i < n; i++) + { + int v = a[i]; + if (v > lim) + { + cnt++; + s += v * 3; + t ^= v * 5; + } + } + return cnt + s + t; +} + +/* A lone conditional increment is still converted. */ + +int +count (const int *a, int n, int lim) +{ + int cnt = 0; + for (int i = 0; i < n; i++) + if (a[i] > lim) + cnt++; + return cnt; +} + +/* { dg-final { scan-assembler-not "csel\t" } } */ +/* { dg-final { scan-assembler-times "cinc\t" 1 } } */ -- 2.54.0 (Apple Git-157) From ktkachov@nvidia.com Mon Nov 2 14:19:20 2026 From: ktkachov@nvidia.com (ktkachov@nvidia.com) Date: Mon, 2 Nov 2026 15:19:20 +0100 Subject: [PATCH 3/4] ifcvt, aarch64: Use parallel costs for if-conversion In-Reply-To: <20261102141921.88485-1-ktkachov@nvidia.com> References: <20261102141921.88485-1-ktkachov@nvidia.com> Message-ID: <20261102141921.88485-3-ktkachov@nvidia.com> From: Kyrylo Tkachov The AArch64 speed profitability check adds serial instruction costs for conditional-select sequences inside loops. It can reject short independent register computations that fit within the target's issue rate and cost limit, so a block that computes two values that do not depend on each other and selects between them keeps its branch. Export noce_parallel_seq_cost and use it in the AArch64 speed check. Sequences it cannot model keep the serial cost. Keep the target cost limit, the instruction-shape checks and the in-loop size policy. Add a loop test where two independent outputs now convert, guard tests where a long dependent chain and low explicit cost limits keep the branch and where -Os and -Oz still convert. This improves Snappy compress performance by 4.7% on NVIDIA Vera. Bootstrapped and tested on aarch64-none-linux-gnu. Ok for trunk? Thanks, Kyrill Cc: Tamar Christina gcc/ChangeLog: * ifcvt.cc (noce_parallel_seq_cost): Remove static. * ifcvt.h (noce_parallel_seq_cost): Declare. * config/aarch64/aarch64.cc (aarch64_noce_conversion_profitable_p): Use noce_parallel_seq_cost. gcc/testsuite/ChangeLog: * gcc.target/aarch64/noce-parallel-cost-1.c: New test. * gcc.target/aarch64/noce-parallel-cost-2.c: Likewise. * gcc.target/aarch64/noce-parallel-cost-3.c: Likewise. * gcc.target/aarch64/noce-parallel-cost-4.c: Likewise. * gcc.target/aarch64/noce-parallel-cost-5.c: Likewise. Signed-off-by: Kyrylo Tkachov --- gcc/config/aarch64/aarch64.cc | 2 +- gcc/ifcvt.cc | 2 +- gcc/ifcvt.h | 2 ++ .../gcc.target/aarch64/noce-parallel-cost-1.c | 27 +++++++++++++++ .../gcc.target/aarch64/noce-parallel-cost-2.c | 34 +++++++++++++++++++ .../gcc.target/aarch64/noce-parallel-cost-3.c | 6 ++++ .../gcc.target/aarch64/noce-parallel-cost-4.c | 6 ++++ .../gcc.target/aarch64/noce-parallel-cost-5.c | 6 ++++ 8 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-1.c create mode 100644 gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-2.c create mode 100644 gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-3.c create mode 100644 gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-4.c create mode 100644 gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-5.c diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 7a73a441f98..282be9a9b1c 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -2466,7 +2466,7 @@ aarch64_noce_conversion_profitable_p (rtx_insn *seq, most cases. */ if (if_info->speed_p) { - unsigned cost = seq_cost (seq, true); + unsigned cost = noce_parallel_seq_cost (seq, true); return cost <= if_info->max_seq_cost; } diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc index cd205ffdb9a..6c37b6bd359 100644 --- a/gcc/ifcvt.cc +++ b/gcc/ifcvt.cc @@ -891,7 +891,7 @@ noce_dependency_level (noce_ready_map &ready, 0.2 < ratio <= 0.4 0.91 percent 0.0 < ratio <= 0.2 0.00 percent. */ -static unsigned int +unsigned int noce_parallel_seq_cost (rtx_insn *seq, bool speed_p) { unsigned int serial_cost = seq_cost (seq, speed_p); diff --git a/gcc/ifcvt.h b/gcc/ifcvt.h index 8347e0e8bc8..1ffd5bbb797 100644 --- a/gcc/ifcvt.h +++ b/gcc/ifcvt.h @@ -138,4 +138,6 @@ struct noce_if_info const char *transform_name; }; +extern unsigned int noce_parallel_seq_cost (rtx_insn *, bool); + #endif /* GCC_IFCVT_H */ diff --git a/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-1.c b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-1.c new file mode 100644 index 00000000000..74f6677fa29 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-1.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mcpu=olympus -fdump-rtl-ce1" } */ + +void +select_values (unsigned int n, const volatile unsigned long input[][3], + volatile unsigned long output[][2]) +{ + for (unsigned int i = 0; i < n; ++i) + { + unsigned long c = input[i][0], x = input[i][1], y = input[i][2]; + unsigned long a, b; + if (c > 7) + { + a = x * 3 + y; + b = 2; + } + else + { + a = x + 9; + b = 3; + } + output[i][0] = a; + output[i][1] = b; + } +} + +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through noce_convert_multiple_sets" 1 "ce1" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-2.c b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-2.c new file mode 100644 index 00000000000..be414b109d7 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-2.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mcpu=olympus -fdump-rtl-ce1" } */ + +void +select_values (unsigned int n, const volatile unsigned long input[][3], + volatile unsigned long output[][2]) +{ + for (unsigned int i = 0; i < n; ++i) + { + unsigned long c = input[i][0], x = input[i][1], y = input[i][2]; + unsigned long a, b; + if (c > 7) + { + a = x + 9; + a ^= y; + a >>= 2; + a += 5; + a ^= y; + a >>= 3; + a += 13; + a ^= y; + b = 2; + } + else + { + a = x + 9; + b = 3; + } + output[i][0] = a; + output[i][1] = b; + } +} + +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded" "ce1" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-3.c b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-3.c new file mode 100644 index 00000000000..d861b108e75 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-3.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mcpu=olympus --param=max-rtl-if-conversion-unpredictable-cost=1 --param=max-rtl-if-conversion-predictable-cost=1 -fdump-rtl-ce1" } */ + +#include "noce-parallel-cost-1.c" + +/* { dg-final { scan-rtl-dump-not "if-conversion succeeded" "ce1" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-4.c b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-4.c new file mode 100644 index 00000000000..fac1f2eee3a --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-4.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -mcpu=olympus -fdump-rtl-ce1" } */ + +#include "noce-parallel-cost-1.c" + +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through noce_convert_multiple_sets" 1 "ce1" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-5.c b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-5.c new file mode 100644 index 00000000000..d2213a522f9 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/noce-parallel-cost-5.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-Oz -mcpu=olympus -fdump-rtl-ce1" } */ + +#include "noce-parallel-cost-1.c" + +/* { dg-final { scan-rtl-dump-times "if-conversion succeeded through noce_convert_multiple_sets" 1 "ce1" } } */ -- 2.54.0 (Apple Git-157) From ktkachov@nvidia.com Mon Nov 2 14:19:19 2026 From: ktkachov@nvidia.com (ktkachov@nvidia.com) Date: Mon, 2 Nov 2026 15:19:19 +0100 Subject: [PATCH 2/4] ifcvt: Track register availability in the parallel cost estimate In-Reply-To: <20261102141921.88485-1-ktkachov@nvidia.com> References: <20261102141921.88485-1-ktkachov@nvidia.com> Message-ID: <20261102141921.88485-2-ktkachov@nvidia.com> From: Kyrylo Tkachov The parallel cost estimate scans all earlier definitions for each input. This keeps dependencies on overwritten register values and misses inputs outside SET_SRC, such as USEs in a PARALLEL. Use vec_rtx_properties to collect register references and a register map to track availability. Read the inputs before recording the definitions, and let a definition replace the availability of each register number it writes. For example: r100 = 0 r100 = r100 + 1 r100 = 0 r101 = r100 The final assignment has dependency level one, independent of the earlier value of r100. Previously it inherited level two. Check the whole pattern for memory, side effects and traps, and reject additional SETs and asms. Keep the existing sum of per-level instruction counts divided by the target issue rate, rounded up, and the serial-cost cap. aarch64 reaches the estimate only through the default hook when optimizing for size, where it is the serial cost. The next patch uses it in the AArch64 speed check. Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux-gnu. Ok for trunk? Thanks, Kyrill gcc/ChangeLog: * ifcvt.cc: Include rtlanal.h and selftest.h. (noce_parallel_cost_node): Remove. (noce_parallel_costed_insn_p): Check the complete pattern and reject multiple SETs. Remove the SET output parameter. (noce_ready_map): New typedef. (noce_dependency_level): Use register properties and an availability map. (noce_parallel_seq_cost): Collect complete instruction references. Reject asms. (selftest::test_noce_level): New function. (selftest::test_noce_pseudo_dependencies): New test. (selftest::test_noce_parallel_references): Likewise. (selftest::test_noce_hard_register_dependencies): Likewise. (selftest::test_noce_parallel_cost_gates): Likewise. (selftest::ifcvt_cc_tests): New function. * selftest.h (ifcvt_cc_tests): Declare. * selftest-run-tests.cc (selftest::run_tests): Call it. Signed-off-by: Kyrylo Tkachov --- gcc/ifcvt.cc | 246 ++++++++++++++++++++++++++++++++------ gcc/selftest-run-tests.cc | 1 + gcc/selftest.h | 1 + 3 files changed, 211 insertions(+), 37 deletions(-) diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc index 8cc8ab1c369..cd205ffdb9a 100644 --- a/gcc/ifcvt.cc +++ b/gcc/ifcvt.cc @@ -45,7 +45,9 @@ #include "dbgcnt.h" #include "shrink-wrap.h" #include "rtl-iter.h" +#include "rtlanal.h" #include "ifcvt.h" +#include "selftest.h" /* The number of instructions this pass may make run unconditionally in place of a branch. The conditional-execution path uses it as the number of insns @@ -815,47 +817,62 @@ noce_reversed_cond_code (noce_if_info *if_info) return code; } -/* A register definition and its dependency level. */ - -struct noce_parallel_cost_node -{ - rtx dest; - unsigned int level; -}; - /* Return true if INSN is a unit-cost register SET supported by the parallel - cost model. Store the SET in *SET. */ + cost model when optimizing for SPEED_P. */ static bool -noce_parallel_costed_insn_p (rtx_insn *insn, bool speed_p, rtx *set) +noce_parallel_costed_insn_p (rtx_insn *insn, bool speed_p) { - *set = single_set (insn); - if (!*set) + rtx set = single_set (insn); + if (!set || multiple_sets (insn)) return false; - rtx dest = SET_DEST (*set); - rtx src = SET_SRC (*set); + rtx dest = SET_DEST (set); + rtx pat = PATTERN (insn); return (REG_P (dest) - && !contains_mem_rtx_p (src) - && !side_effects_p (src) - && !may_trap_p (src) - && set_rtx_cost (*set, speed_p) == COSTS_N_INSNS (1)); + && !contains_mem_rtx_p (pat) + && !side_effects_p (pat) + && !may_trap_p (pat) + && set_rtx_cost (set, speed_p) == COSTS_N_INSNS (1)); } -/* Return the dependency level for an instruction reading SRC. A use of a - register defined at level N requires level N + 1. */ +/* Map from a register number to the dependency level at which the current + value of the register is available. */ -static unsigned int -noce_dependency_level (const vec &defs, rtx src) -{ - unsigned int level = 0; +typedef hash_map, unsigned int> noce_ready_map; - for (unsigned int i = 0; i < defs.length (); ++i) - if (reg_overlap_mentioned_p (defs[i].dest, src)) - level = MAX (level, defs[i].level + 1); +/* Store in *LEVEL the dependency level of the instruction that PROPERTIES + describes, using the register availability in READY, then update READY + for its definitions. Return false, leaving READY unchanged, if PROPERTIES + has a non-register reference, otherwise return true. The caller must + check that every register the instruction sets is set as a whole. */ - return level; +static bool +noce_dependency_level (noce_ready_map &ready, + const vec_rtx_properties &properties, + unsigned int *level) +{ + *level = 0; + for (auto ref : properties.refs ()) + { + if (!ref.is_reg ()) + return false; + if (ref.is_read ()) + if (unsigned int *time = ready.get (ref.regno)) + *level = MAX (*level, *time); + } + + /* Read all inputs before recording the definitions. A SET of a register + defines every register number it covers, and a clobber produces no + value. */ + for (auto ref : properties.refs ()) + if (ref.is_write () && !ref.is_clobber ()) + { + gcc_checking_assert (!ref.in_subreg ()); + ready.put (ref.regno, *level + 1); + } + return true; } /* Estimate the cost of SEQ using the target issue rate. Unit-cost register @@ -884,28 +901,29 @@ noce_parallel_seq_cost (rtx_insn *seq, bool speed_p) unsigned int issue_rate = MAX (targetm.sched.issue_rate (), 1); - /* Track prior definitions and instruction counts per dependency level. */ - auto_vec defs; + /* Track register availability and instruction counts per level. */ + noce_ready_map ready; auto_vec insns_per_level; for (rtx_insn *insn = seq; insn; insn = NEXT_INSN (insn)) { - rtx set; - if (!NONDEBUG_INSN_P (insn)) continue; - if (!noce_parallel_costed_insn_p (insn, speed_p, &set)) + if (!noce_parallel_costed_insn_p (insn, speed_p)) return serial_cost; - unsigned int level = noce_dependency_level (defs, SET_SRC (set)); + vec_rtx_properties properties; + properties.add_insn (insn, false); + if (properties.has_asm) + return serial_cost; + unsigned int level; + if (!noce_dependency_level (ready, properties, &level)) + return serial_cost; if (insns_per_level.length () <= level) insns_per_level.safe_grow_cleared (level + 1, true); ++insns_per_level[level]; - - noce_parallel_cost_node node = { SET_DEST (set), level }; - defs.safe_push (node); } unsigned int parallel_cost = 0; @@ -7028,3 +7046,157 @@ make_pass_if_after_reload (gcc::context *ctxt) return new pass_rtl_ifcvt (ctxt, pass_data_if_after_reload, IFCVT_AFTER_RELOAD); } + +#if CHECKING_P + +namespace selftest { + +/* Return the dependency level of PAT and update READY. */ + +static unsigned int +test_noce_level (noce_ready_map &ready, rtx pat) +{ + vec_rtx_properties properties; + properties.add_pattern (pat); + unsigned int level; + ASSERT_TRUE (noce_dependency_level (ready, properties, &level)); + return level; +} + +/* Check read-before-write handling and replacement of complete definitions. */ + +static void +test_noce_pseudo_dependencies () +{ + noce_ready_map ready; + rtx a = gen_raw_REG (SImode, LAST_VIRTUAL_REGISTER + 1); + rtx b = gen_raw_REG (SImode, LAST_VIRTUAL_REGISTER + 2); + rtx increment = gen_rtx_SET (a, gen_rtx_PLUS (SImode, a, const1_rtx)); + + ASSERT_EQ (0U, test_noce_level (ready, gen_rtx_SET (a, const0_rtx))); + ASSERT_EQ (1U, test_noce_level (ready, increment)); + ASSERT_EQ (2U, test_noce_level (ready, increment)); + ASSERT_EQ (0U, test_noce_level (ready, gen_rtx_SET (a, const0_rtx))); + ASSERT_EQ (1U, test_noce_level (ready, gen_rtx_SET (b, a))); +} + +/* Check references outside the SET and rejection before updating READY. */ + +static void +test_noce_parallel_references () +{ + noce_ready_map ready; + rtx a = gen_raw_REG (SImode, LAST_VIRTUAL_REGISTER + 1); + rtx b = gen_raw_REG (SImode, LAST_VIRTUAL_REGISTER + 2); + rtx c = gen_raw_REG (SImode, LAST_VIRTUAL_REGISTER + 3); + ready.put (REGNO (a), 4); + ready.put (REGNO (c), 7); + rtx pat = gen_rtx_PARALLEL (VOIDmode, + gen_rtvec (3, gen_rtx_SET (b, const0_rtx), + gen_rtx_USE (VOIDmode, a), + gen_rtx_CLOBBER (VOIDmode, c))); + ASSERT_EQ (4U, test_noce_level (ready, pat)); + ASSERT_EQ (5U, *ready.get (REGNO (b))); + ASSERT_EQ (7U, *ready.get (REGNO (c))); + + rtx addr = gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 4); + vec_rtx_properties properties; + properties.add_pattern (gen_rtx_SET (b, gen_rtx_MEM (SImode, addr))); + unsigned int level; + ASSERT_FALSE (noce_dependency_level (ready, properties, &level)); + ASSERT_EQ (5U, *ready.get (REGNO (b))); +} + +/* Check that each register number of a hard register that spans several is + tracked on its own. */ + +static void +test_noce_hard_register_dependencies () +{ + for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; ++regno) + { + if (!targetm.hard_regno_mode_ok (regno, TImode) + || !targetm.hard_regno_mode_ok (regno, QImode)) + continue; + rtx wide = gen_raw_REG (TImode, regno); + unsigned int end = END_REGNO (wide); + if (end > FIRST_PSEUDO_REGISTER || end <= regno + 1 + || (regno <= STACK_POINTER_REGNUM && STACK_POINTER_REGNUM < end)) + continue; + + noce_ready_map ready; + ready.put (end - 1, 4); + ASSERT_EQ (0U, test_noce_level (ready, gen_rtx_SET (wide, const0_rtx))); + for (unsigned int i = regno; i < end; ++i) + ASSERT_EQ (1U, *ready.get (i)); + rtx dest = gen_raw_REG (TImode, LAST_VIRTUAL_REGISTER + 1); + ASSERT_EQ (1U, test_noce_level (ready, gen_rtx_SET (dest, wide))); + + ready.put (end - 1, 6); + rtx narrow = gen_raw_REG (QImode, regno); + ASSERT_EQ (0U, test_noce_level (ready, gen_rtx_SET (narrow, const0_rtx))); + ASSERT_EQ (6U, test_noce_level (ready, gen_rtx_SET (dest, wide))); + return; + } +} + +/* Check full-pattern rejection before target costing. */ + +static void +test_noce_parallel_cost_gates () +{ + rtx a = gen_raw_REG (SImode, LAST_VIRTUAL_REGISTER + 1); + rtx b = gen_raw_REG (SImode, LAST_VIRTUAL_REGISTER + 2); + rtx set = gen_rtx_SET (a, const0_rtx); + ASSERT_FALSE (side_effects_p (set)); + rtx pat = gen_rtx_PARALLEL (VOIDmode, + gen_rtvec (2, set, gen_rtx_USE (VOIDmode, b))); + if (set_rtx_cost (set, true) == COSTS_N_INSNS (1)) + { + ASSERT_TRUE (noce_parallel_costed_insn_p (make_insn_raw (set), true)); + ASSERT_TRUE (noce_parallel_costed_insn_p (make_insn_raw (pat), true)); + } + + /* A partial write is not a unit-cost set. The lowpart of a narrower mode + does not sit at offset zero on a big-endian target, and a target need not + accept the subreg at all, so ask before building it. */ + poly_uint64 byte = subreg_lowpart_offset (QImode, SImode); + if (validate_subreg (QImode, SImode, a, byte)) + { + rtx partial = gen_rtx_SUBREG (QImode, a, byte); + rtx_insn *part_insn = make_insn_raw (gen_rtx_SET (partial, const0_rtx)); + ASSERT_FALSE (noce_parallel_costed_insn_p (part_insn, true)); + } + + pat = gen_rtx_PARALLEL (VOIDmode, + gen_rtvec (2, set, gen_rtx_SET (b, const0_rtx))); + rtx_insn *insn = make_insn_raw (pat); + add_reg_note (insn, REG_UNUSED, b); + ASSERT_TRUE (multiple_sets (insn)); + ASSERT_FALSE (noce_parallel_costed_insn_p (insn, true)); + + rtx addr = gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 3); + rtx mem_use = gen_rtx_USE (VOIDmode, gen_rtx_MEM (SImode, addr)); + pat = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, set, mem_use)); + ASSERT_FALSE (noce_parallel_costed_insn_p (make_insn_raw (pat), true)); + + rtx vol = gen_rtx_UNSPEC_VOLATILE (SImode, gen_rtvec (1, b), 0); + pat = gen_rtx_PARALLEL (VOIDmode, + gen_rtvec (2, set, gen_rtx_USE (VOIDmode, vol))); + ASSERT_FALSE (noce_parallel_costed_insn_p (make_insn_raw (pat), true)); +} + +/* Run the selftests in this file. */ + +void +ifcvt_cc_tests () +{ + test_noce_pseudo_dependencies (); + test_noce_parallel_references (); + test_noce_hard_register_dependencies (); + test_noce_parallel_cost_gates (); +} + +} // namespace selftest + +#endif /* CHECKING_P. */ diff --git a/gcc/selftest-run-tests.cc b/gcc/selftest-run-tests.cc index 07eb984e918..89fd05da893 100644 --- a/gcc/selftest-run-tests.cc +++ b/gcc/selftest-run-tests.cc @@ -95,6 +95,7 @@ selftest::run_tests () convert_cc_tests (); gimple_cc_tests (); rtl_tests_cc_tests (); + ifcvt_cc_tests (); read_rtl_function_cc_tests (); digraph_cc_tests (); tristate_cc_tests (); diff --git a/gcc/selftest.h b/gcc/selftest.h index acfc4a46e49..6740c3d2a52 100644 --- a/gcc/selftest.h +++ b/gcc/selftest.h @@ -235,6 +235,7 @@ extern void gimple_range_tests (); extern void graphviz_cc_tests (); extern void hash_map_tests_cc_tests (); extern void hash_set_tests_cc_tests (); +extern void ifcvt_cc_tests (); extern void input_cc_tests (); extern void ipa_modref_tree_cc_tests (); extern void json_cc_tests (); -- 2.54.0 (Apple Git-157) From christophe.lyon@arm.com Mon Nov 2 14:26:33 2026 From: christophe.lyon@arm.com (Christophe Lyon) Date: Mon, 2 Nov 2026 15:26:33 +0100 Subject: [PATCH] testsuite: Reset module_do for each ungrouped modules test In-Reply-To: References: <20261023131632.292024-1-christophe.lyon@arm.com> <6c4f664e-2d45-4234-9707-50b0d1c56a55@redhat.com> Message-ID: <9d61eef7-e89c-43c5-baf5-e400f3d23ecd@arm.com> Hi, On 10/24/26 12:14, Jakub Jelinek wrote: > On Fri, Oct 23, 2026 at 04:09:59PM -0400, Jason Merrill wrote: >> On 10/23/26 9:16 AM, Christophe Lyon wrote: >>> The ungrouped modules test loop does not reset module_do between >>> tests. If a previous test calls unsupported, module_do can remain >>> set to {"compile" "N"}, causing the CMI checks for subsequent >>> tests to be skipped. >>> >>> Reset module_do at the beginning of each iteration, as is already >>> done for grouped modules tests. >> >> OK. >> >>> gcc/testsuite/ChangeLog: >>> >>> * g++.dg/modules/modules.exp: > > Except description in ChangeLog needs to be provided. Thanks for catching this. Interestingly 'git gcc-verify' did not report the problem :-( Now fixed and pushed to trunk. OK to backport to gcc-14, gcc-15 and gcc-16 (applies cleanly) Thanks, Christophe > > Jakub > From gaiusmod2@gmail.com Mon Nov 2 14:46:18 2026 From: gaiusmod2@gmail.com (Gaius Mulley) Date: Mon, 2 Nov 2026 14:46:18 +0000 Subject: [pushed]PR modula2/128293: Document plugin/m2rte.so dynamically linked to stdc++ Message-ID: <20261102144618.3224672-1-gaiusmod2@gmail.com> This patch for doc/install.texi documents that m2rte.so is dependent upon stdc++. gcc/ChangeLog: PR modula2/128293 * doc/install.texi (GM2-prerequisite): Add paragraph explaining m2rte.so is dependent upon stdc++. Signed-off-by: Gaius Mulley --- gcc/doc/install.texi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 2be38423c79..840e6553db6 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -347,6 +347,12 @@ documentation including the target @code{SYSTEM} definition module. If Python3 is unavailable Modula-2 documentation will include a target independent version of the SYSTEM modules. +If plugins are enabled a compile time call flow analysis shared +library @file{m2rte.so} is built. This plugin performs a limited +amount of compile time static analysis in an attempt to detect runtime +Modula-2 exceptions at compile time. The plugin @file{m2rte.so} +depends upon @file{-lstdc++}. + @item @anchor{gccrs-prerequisite}gccrs The official Rust compiler and Rust build system (cargo) are required for -- 2.47.3 From tkaminsk@redhat.com Mon Nov 2 15:07:49 2026 From: tkaminsk@redhat.com (Tomasz Kaminski) Date: Mon, 2 Nov 2026 16:07:49 +0100 Subject: [PATCH 2/3] libstdc++: Avoid possible null pointer arithmetic in basic_filebuf::overflow [PR118099] In-Reply-To: <20261023174023.845748-2-jwakely@redhat.com> References: <20261023174023.845748-1-jwakely@redhat.com> <20261023174023.845748-2-jwakely@redhat.com> Message-ID: On Fri, Oct 23, 2026 at 7:43?PM Jonathan Wakely wrote: > The unbuffered path in basic_filebuf::overflow calls > _M_convert_to_external(&__conv, 1) to output a single character. But if > a partial codecvt conversion happens in _M_convert_to_external then it > calculates the number of unconverted characters in the filebuf's put > area by calling pptr(). In the unbuffered case pptr() returns a null > pointer and so the arithmetic on it is undefined. > > Although GCC doesn't diagnose this, Clang's UBSan does: > .../include/c++/16/bits/fstream.tcc:655:19: runtime error: applying > non-zero offset to non-null pointer 0x7ffd0d20eca7 produced null pointer > > _M_convert_to_external should only read from the buffer passed to it, > not assume that the streambuf's put area exists or is equivalent to the > buffer that was passed. > > This probably isn't a problem in real code, because the null pptr() in > _M_convert_to_external was only reachable for a non-conforming codecvt > facet that lies about max_length() or for some reason performs a partial > conversion on a single character even when sufficient output space is > available (as in the new testcases). But it is more robust to not > access pptr() directly when we are called with a pointer to the sequence > that should be converted. This also enables a further correctness fix to > basic_filebuf::overflow in a subsequent commit. > > The retry code can be further simplified because not only is using > pptr() unsafe, but we can just use [__iend, __ibuf + __ilen) as the > input range, instead of [__iend, __iend + (pptr() - __iend)). That was > just unnecessarily complicated. > > The retry_forcing_codecvt in the new test was generated by an LLM, > although greatly simplified by me so that the bug is detected with a > simple VERIFY rather than examining the characters output by the facet. > > Assisted-by: LLM > > libstdc++-v3/ChangeLog: > > PR libstdc++/118099 > * include/bits/fstream.tcc > (basic_filebuf::_M_convert_to_external): Use __ibuf + __ilen > instead of this->pptr(). > * testsuite/27_io/basic_filebuf/overflow/char/118099-unbuffered.cc: > New test. > * > testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-unbuffered.cc: > New test. > --- > > Tested x86_64-linux. > LGTM, only small stylistic comments. > > libstdc++-v3/include/bits/fstream.tcc | 9 +-- > .../overflow/char/118099-unbuffered.cc | 72 +++++++++++++++++++ > .../overflow/wchar_t/118099-unbuffered.cc | 72 +++++++++++++++++++ > 3 files changed, 147 insertions(+), 6 deletions(-) > create mode 100644 > libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-unbuffered.cc > create mode 100644 > libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-unbuffered.cc > > diff --git a/libstdc++-v3/include/bits/fstream.tcc > b/libstdc++-v3/include/bits/fstream.tcc > index 2a1257c3e341..5d13633b6841 100644 > --- a/libstdc++-v3/include/bits/fstream.tcc > +++ b/libstdc++-v3/include/bits/fstream.tcc > @@ -651,14 +651,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > // Try once more for partial conversions. > if (__r == codecvt_base::partial && __elen == __plen) > { > - const char_type* __iresume = __iend; > - streamsize __rlen = this->pptr() - __iend; > - __r = _M_codecvt->out(_M_state_cur, __iresume, > - __iresume + __rlen, __iend, __buf, > - __buf + __blen, __bend); > + __r = _M_codecvt->out(_M_state_cur, __iend, __ibuf + __ilen, > + __iend, __buf, __buf + __blen, __bend); > Could you change the formatting of this invocation of out (and the one above) to something like, so parameters related to one buffer are together: __r = _M_codecvt->out(_M_state_cur, __iend, __ibuf + __ilen, __iend, __buf, __buf + __blen, __bend); > if (__r != codecvt_base::error) > { > - __rlen = __bend - __buf; > + const streamsize __rlen = __bend - __buf; > __elen = _M_file.xsputn(__buf, __rlen); > __plen = __rlen; > } > diff --git > a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-unbuffered.cc > b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-unbuffered.cc > new file mode 100644 > index 000000000000..a77a635feb73 > --- /dev/null > +++ > b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-unbuffered.cc > @@ -0,0 +1,72 @@ > +// { dg-do run } > +// { dg-require-fileio "" } > + > +// PR libstdc++/118099 > +// basic_filebuf::overflow leaves streambuf in inconsistent state on I/O > error > +// > +// Companion test of 118099.cc testing the unbuffered put path, which > calls > +// _M_convert_to_external(&__conv, 1). When a codecvt forces the > +// "partial conversion" retry, that retry must compute the amount of input > +// left to convert from the buffer it was handed (__ibuf + __ilen), not > from > +// pptr(). In unbuffered mode pptr() is null, so the old code called > +// codecvt::out with from_end == __iresume + (pptr() - __iend) == pptr(), > +// i.e. a null `from_end` for a non-null `from`. > + > +#include > +#include > +#include > + > +typedef char C; > + > +// Emits one external char per do_out() call without consuming input, and > +// under-reports max_length(), so that _M_convert_to_external is forced to > +// take its partial-conversion retry branch. The retry is where the bogus > +// (null) from_end is passed. > +// This is probably not a conforming codecvt facet and is intended only to > +// test the libstdc++ basic_filebuf::_M_convert_to_external behaviour. > +struct retry_forcing_codecvt : std::codecvt > +{ > +protected: > + result > + do_out(state_type&, const intern_type* from, const intern_type* > from_end, > + const intern_type*& from_next, extern_type* to, extern_type* > to_end, > + extern_type*& to_next) const > + { > + // The _M_convert_to_external bug passed non-null from and null > from_end. > + if (from != 0) > + VERIFY( from_end != 0 ); > + > + from_next = from; > + to_next = to; > I would find it more readable if we do: if (from == from_end) return ok; if (to != to_end) to_next++ = *from; // emit a character; do not advance from_next return partial; > + if (from < from_end && to < to_end) > + { > + *to_next++ = *from; // emit a character; do not advance from_next > + return partial; > + } > + return from == from_end ? ok : partial; > + } > + > + bool do_always_noconv() const throw() { return false; } > + int do_max_length() const throw() { return 1; } > +}; > + > +static void > +test_pr118099_unbuffered() > +{ > + std::basic_filebuf fb; > + fb.pubimbue(std::locale(std::locale::classic(), new > retry_forcing_codecvt)); > + fb.pubsetbuf(0, 0); // unbuffered: pptr() == epptr() == null > + fb.open("tmp_118099_unbuffered", std::ios_base::out | > std::ios_base::trunc); > + VERIFY( fb.is_open() ); > + > + // Each put goes straight to _M_convert_to_external(&__conv, 1); the > codecvt > + // above asserts it is never called with the bogus null from_end. > + fb.sputc('a'); > + fb.sputc('b'); > + fb.sputc('c'); > +} > + > +int main() > +{ > + test_pr118099_unbuffered(); > +} > diff --git > a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-unbuffered.cc > b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-unbuffered.cc > new file mode 100644 > index 000000000000..b2c8ae3ec8c0 > --- /dev/null > +++ > b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-unbuffered.cc > @@ -0,0 +1,72 @@ > +// { dg-do run } > +// { dg-require-fileio "" } > + > +// PR libstdc++/118099 > +// basic_filebuf::overflow leaves streambuf in inconsistent state on I/O > error > +// > +// Companion test of 118099.cc testing the unbuffered put path, which > calls > +// _M_convert_to_external(&__conv, 1). When a codecvt forces the > +// "partial conversion" retry, that retry must compute the amount of input > +// left to convert from the buffer it was handed (__ibuf + __ilen), not > from > +// pptr(). In unbuffered mode pptr() is null, so the old code called > +// codecvt::out with from_end == __iresume + (pptr() - __iend) == pptr(), > +// i.e. a null `from_end` for a non-null `from`. > + > +#include > +#include > +#include > + > +typedef wchar_t C; > + > +// Emits one external char per do_out() call without consuming input, and > +// under-reports max_length(), so that _M_convert_to_external is forced to > +// take its partial-conversion retry branch. The retry is where the bogus > +// (null) from_end is passed. > +// This is probably not a conforming codecvt facet and is intended only to > +// test the libstdc++ basic_filebuf::_M_convert_to_external behaviour. > +struct retry_forcing_codecvt : std::codecvt > +{ > +protected: > + result > + do_out(state_type&, const intern_type* from, const intern_type* > from_end, > + const intern_type*& from_next, extern_type* to, extern_type* > to_end, > + extern_type*& to_next) const > + { > + // The _M_convert_to_external bug passed non-null from and null > from_end. > + if (from != 0) > + VERIFY( from_end != 0 ); > + > + from_next = from; > + to_next = to; > + if (from < from_end && to < to_end) > + { > + *to_next++ = *from; // emit a character; do not advance from_next > + return partial; > + } > + return from == from_end ? ok : partial; > + } > + > + bool do_always_noconv() const throw() { return false; } > + int do_max_length() const throw() { return 1; } > +}; > + > +static void > +test_pr118099_unbuffered() > +{ > + std::basic_filebuf fb; > + fb.pubimbue(std::locale(std::locale::classic(), new > retry_forcing_codecvt)); > + fb.pubsetbuf(0, 0); // unbuffered: pptr() == epptr() == null > + fb.open("tmp_118099_unbuffered", std::ios_base::out | > std::ios_base::trunc); > + VERIFY( fb.is_open() ); > + > + // Each put goes straight to _M_convert_to_external(&__conv, 1); the > codecvt > + // above asserts it is never called with the bogus null from_end. > + fb.sputc(L'a'); > + fb.sputc(L'b'); > + fb.sputc(L'c'); > +} > + > +int main() > +{ > + test_pr118099_unbuffered(); > +} > -- > 2.56.0 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jakub@redhat.com Mon Nov 2 15:20:36 2026 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 2 Nov 2026 16:20:36 +0100 Subject: [RFC PATCH] c++: Implement the core part of P3666R5 - Bit-precise integers Message-ID: Hi! The following patch implements the core part of the P3666R5 - Bit-precise integers paper. Unlike the paper, it assumes bit-precise initializers of enumerators are valid even when the underlying enumeration type is not fixed, as long as their values fit in some non-bit-precise standard/extended type, https://github.com/eisenwave/cpp-proposals/issues/276 , handles _BitInt(N) and unsigned _BitInt(N) where N is value-dependent as type-dependent types https://github.com/eisenwave/cpp-proposals/issues/275 Still something unresolved here is how should ++ and -- behave on bit-precise types https://github.com/eisenwave/cpp-proposals/issues/278 especially on signed _BitInt(1) where even C2Y is unclear. I know the paper hasn't been voted in yet and who knows how much time will there be for it in Buzios, but I think it is still useful to have a second independent implementation. And if it is not voted in but likely to pass later on whether we want to add it for GCC 17 as an extension or not. Open questions are: 1) what to do with literals with wb/uwb suffixes for earlier C++ versions; we have the warning that non-_ prefixed udlits are reserved for implementation, unsure if that is good enough, or if e.g. the code should try to look up user defined literals before C++29 for it and if it finds a match, handle it as user defined literal and only otherwise as _BitInt suffix with pedwarn; what the patch does right now is emit just a pedwarn (not guarded on pedantic) 2) whether (__extension__ 0wb) should disable that pedwarn; for C it does, for C++ it currently disables pedantic, but not e.g. -Wc++29-extensions (or any other -Wc++NN-extensions) For _BitInt keyword it is right now pedwarn guarded on pedantic, so __extension__ disables it and it doesn't diagnose unless -pedantic/-pedantic-errors. I think some difference for _BitInt vs. wb suffixes is desirable, because the former requires use of an reserved name, while the latter doesn't. This patch doesn't include the library side at all, wonder if it is useful if I try to implement that part as well. And, presumably some compiler changes will need to be done afterwards on the reflect.cc side to match the library changes (e.g. for make_signed/make_unsigned, or some traits which ought to accept _BitInt now). So far tested using GXX_TESTSUITE_STDS=98,11,14,17,20,23,26,29 make check-g++ RUNTESTFLAGS=dg.exp=bitint* plus manually tried to compile/run all gcc.dg/torture/bitint*.c tests and with a few exceptions (some narrowing conversions or stuff valid only in C and not C++) it worked fine there too. 2026-11-02 Jakub Jelinek P3666R5 gcc/c-family/ * c-lex.cc (interpret_integer): Handle 0wb as _BitInt(1) 0 for C++. * c-common.cc (c_common_reswords): Change C_ONLY to 0 for _BitInt. * c-cppbuiltin.cc (c_cpp_builtins): Predefine __BITINT_MAXWIDTH__ also for C++ when supported. For C++29 also predefine __cpp_bit_int in that case as well. gcc/cp/ * parser.cc: Implement P3666R5 - Bit-precise integers. (cp_keyword_starts_decl_specifier_p): Handle RID_BITINT. (cp_parser_simple_type_specifier): Likewise. (set_and_check_decl_spec_loc): Add "_BitInt" name. * cp-tree.h (INTEGRAL_CODE_P): Handle BITINT_TYPE. (CP_INTEGRAL_TYPE_P): Likewise. (BITINT_PREC): Define. (enum cp_decl_spec): Add ds_bitint. (finish_bitint): Declare. * typeck.cc (cp_common_type): Emit sorry when trying to create common type for _Complex and _BitInt. Handle the case where at least one type is bit-precise and they have the same precision. (structural_comptypes): Handle BITINT_TYPE. (cp_perform_integral_promotions): Likewise. (cp_build_array_ref): Likewise. (warn_for_null_address): Likewise. (cp_build_binary_op): Likewise. (cp_build_c_cast): Likewise. (ptr_reasonably_similar): Likewise. (finish_bitint): New function. * decl.cc (reshape_init_array_1): Handle BITINT_TYPE. (grokdeclarator): Likewise. * pt.cc (find_parameter_packs_r): Likewise. (tsubst): Likewise. (uses_deducible_template_parms): Likewise. (array_deduction_r): Likewise. (unify): Likewise. (dependent_type_p_r): Likewise. * error.cc (dump_type): Likewise. (dump_type_prefix): Likewise. (dump_type_suffix): Likewise. (dump_expr): Likewise. * cxx-pretty-print.cc: Likewise. * tree.cc: Include target.h. (type_has_unique_obj_representations): Handle BITINT_TYPE. (cp_walk_subtrees): Likewise. * semantics.cc (handle_omp_for_class_iterator): Likewise. * call.cc (null_ptr_cst_p): Likewise. (build_list_conv): Likewise. (standard_conversion): Likewise. (build_conditional_expr): Likewise. (convert_like_internal): Likewise. (joust): Likewise. * constexpr.cc (cxx_eval_bit_field_ref): Likewise. (cxx_eval_outermost_constant_expr): Likewise. * cvt.cc (build_expr_type_conversion): Likewise. * init.cc (build_vec_init): Likewise. * mangle.cc (write_type): Likewise. (write_builtin_type): Likewise. * class.cc (layout_class_type): Likewise. gcc/testsuite/ * g++.dg/ext/bitint1.C: Remove. * g++.dg/ext/bitint2.C: Remove. * g++.dg/ext/bitint3.C: Remove. * g++.dg/ext/bitint4.C: Remove. * g++.dg/cpp29/bitint1.C: New test. * g++.dg/cpp29/bitint2.C: New test. * g++.dg/cpp29/bitint3.C: New test. * g++.dg/cpp29/bitint4.C: New test. * g++.dg/cpp29/bitint5.C: New test. * g++.dg/cpp29/bitint6.C: New test. * g++.dg/cpp29/bitint7.C: New test. * g++.dg/cpp29/bitint8.C: New test. * g++.dg/cpp29/bitint9.C: New test. * g++.dg/cpp29/bitint10.C: New test. * g++.dg/cpp29/bitint11.C: New test. * g++.dg/cpp29/bitint12.C: New test. * g++.dg/cpp29/bitint13.C: New test. * g++.dg/cpp29/bitint14.C: New test. * g++.dg/cpp29/bitint15.C: New test. * g++.dg/cpp29/bitint16.C: New test. * g++.dg/cpp29/bitint17.C: New test. * g++.dg/cpp29/bitint18.C: New test. * g++.dg/cpp29/bitint19.C: New test. * g++.dg/cpp29/bitint20.C: New test. * g++.dg/cpp29/bitint21.C: New test. * g++.dg/cpp29/bitint22.C: New test. * g++.dg/cpp29/bitint23.C: New test. * g++.dg/cpp29/bitint24.C: New test. * g++.dg/cpp29/bitint25.C: New test. * g++.dg/cpp29/bitint26.C: New test. * g++.dg/cpp29/bitint27.C: New test. * lib/target-supports.exp (check_effective_target_bitint, check_effective_target_bitint128, check_effective_target_bitint575, check_effective_target_bitint65535): For C++ use -std=c++29 rather than -std=c23. libcpp/ * expr.cc (interpret_int_suffix): Don't return 0 for wb for C++. (cpp_classify_number): Emit a pedwarn for C++ < 29 uses of wb. --- a/gcc/c-family/c-lex.cc 2026-10-30 17:05:21.669552772 +0100 +++ b/gcc/c-family/c-lex.cc 2026-10-30 21:48:13.121945586 +0100 @@ -1094,7 +1094,8 @@ interpret_integer (const cpp_token *toke } prec = wi::min_precision (wval, UNSIGNED); - if (prec == 0 && ((flags & CPP_N_UNSIGNED) != 0 || !flag_isoc2y)) + if (prec == 0 && ((flags & CPP_N_UNSIGNED) != 0 + || (!flag_isoc2y && !c_dialect_cxx ()))) prec = 1; if ((flags & CPP_N_UNSIGNED) == 0) ++prec; --- a/gcc/c-family/c-common.cc 2026-10-30 21:46:23.531810585 +0100 +++ b/gcc/c-family/c-common.cc 2026-10-30 21:48:13.122774164 +0100 @@ -400,7 +400,7 @@ const struct c_common_resword c_common_r { "_Maxof", RID_MAXOF, D_CONLY }, { "_Minof", RID_MINOF, D_CONLY }, { "_Atomic", RID_ATOMIC, D_CONLY }, - { "_BitInt", RID_BITINT, D_CONLY }, + { "_BitInt", RID_BITINT, 0 }, { "_Bool", RID_BOOL, D_CONLY }, { "_Complex", RID_COMPLEX, 0 }, { "_Imaginary", RID_IMAGINARY, D_CONLY }, --- a/gcc/c-family/c-cppbuiltin.cc 2026-10-30 17:05:21.669552772 +0100 +++ b/gcc/c-family/c-cppbuiltin.cc 2026-10-30 21:48:13.123571959 +0100 @@ -1261,28 +1261,28 @@ c_cpp_builtins (cpp_reader *pfile) builtin_define_type_width ("__PTRDIFF_WIDTH__", ptrdiff_type_node, NULL_TREE); builtin_define_type_width ("__SIZE_WIDTH__", size_type_node, NULL_TREE); - if (!c_dialect_cxx ()) + struct bitint_info info; + /* For now, restrict __BITINT_MAXWIDTH__ to what can be represented in + wide_int and widest_int. */ + if (targetm.c.bitint_type_info (WIDE_INT_MAX_PRECISION - 1, &info)) { - struct bitint_info info; - /* For now, restrict __BITINT_MAXWIDTH__ to what can be represented in - wide_int and widest_int. */ - if (targetm.c.bitint_type_info (WIDE_INT_MAX_PRECISION - 1, &info)) + cpp_define_formatted (pfile, "__BITINT_MAXWIDTH__=%d", + (int) WIDE_INT_MAX_PRECISION - 1); + if (c_dialect_cxx () && cxx_dialect >= cxx29) + cpp_define_warn (pfile, "__cpp_bit_int=202611L"); + if (flag_building_libgcc) { - cpp_define_formatted (pfile, "__BITINT_MAXWIDTH__=%d", - (int) WIDE_INT_MAX_PRECISION - 1); - if (flag_building_libgcc) - { - scalar_int_mode limb_mode - = as_a (info.limb_mode); - cpp_define_formatted (pfile, "__LIBGCC_BITINT_LIMB_WIDTH__=%d", - (int) GET_MODE_PRECISION (limb_mode)); - cpp_define_formatted (pfile, "__LIBGCC_BITINT_ORDER__=%s", - info.big_endian - ? "__ORDER_BIG_ENDIAN__" - : "__ORDER_LITTLE_ENDIAN__"); - } + scalar_int_mode limb_mode = as_a (info.limb_mode); + cpp_define_formatted (pfile, "__LIBGCC_BITINT_LIMB_WIDTH__=%d", + (int) GET_MODE_PRECISION (limb_mode)); + cpp_define_formatted (pfile, "__LIBGCC_BITINT_ORDER__=%s", + info.big_endian + ? "__ORDER_BIG_ENDIAN__" + : "__ORDER_LITTLE_ENDIAN__"); } } + else if (c_dialect_cxx () && cxx_dialect >= cxx29) + cpp_warn (pfile, "__cpp_bit_int"); if (c_dialect_cxx ()) for (i = 0; i < NUM_INT_N_ENTS; i ++) --- a/gcc/cp/parser.cc 2026-10-30 21:46:23.580809940 +0100 +++ b/gcc/cp/parser.cc 2026-11-02 11:43:29.245478936 +0100 @@ -1342,6 +1342,7 @@ cp_keyword_starts_decl_specifier_p (enum case RID_DOUBLE: CASE_RID_FLOATN_NX: case RID_VOID: + case RID_BITINT: /* CV qualifiers. */ case RID_CONST: case RID_VOLATILE: @@ -22710,6 +22711,14 @@ cp_parser_type_specifier (cp_parser* par nested-name-specifier(opt) template-name + C++29 extension: + + simple-type-specifier: + bit-precise-int-type-specifier + + bit-precise-int-type-specifier: + _BitInt ( constant-expression ) + computed-type-specifier: decltype-specifier pack-index-specifier @@ -22828,6 +22837,36 @@ cp_parser_simple_type_specifier (cp_pars case RID_VOID: type = void_type_node; break; + case RID_BITINT: + { + location_t loc = token->location; + if (cxx_dialect < cxx29 && pedantic) + pedwarn (loc, OPT_Wc__29_extensions, + "%<_BitInt%> only available with " + "%<-std=c++2d%> or %<-std=gnu++2d%>"); + /* Consume the `_BitInt' token. */ + cp_lexer_consume_token (parser->lexer); + matching_parens parens; + if (!parens.require_open (parser)) + return error_mark_node; + tree prec + = cp_parser_constant_expression (parser, + /*allow_non_constant_p=*/false, + /*non_constant_p=*/nullptr, + /*strict_p=*/true); + if (!parens.require_close (parser)) + cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, + /*or_comma=*/false, + /*consume_paren=*/true); + if (check_for_bare_parameter_packs (prec)) + prec = error_mark_node; + type = finish_bitint (loc, prec, false, tf_warning_or_error); + set_and_check_decl_spec_loc (decl_specs, ds_bitint, token); + if (decl_specs) + cp_parser_set_decl_spec_type (decl_specs, type, token, + /*type_definition_p=*/false); + return type; + } case RID_AUTO: maybe_warn_cpp0x (CPP0X_AUTO); @@ -38037,6 +38076,7 @@ set_and_check_decl_spec_loc (cp_decl_spe "__complex", "constinit", "consteval", + "_BitInt", "this" }; gcc_rich_location richloc (location); --- a/gcc/cp/cp-tree.h 2026-10-30 21:46:23.574810019 +0100 +++ b/gcc/cp/cp-tree.h 2026-11-02 11:43:08.237756471 +0100 @@ -609,7 +609,8 @@ extern GTY(()) tree cp_global_trees[CPTI For a FUNCTION_TYPE or METHOD_TYPE, this is TYPE_RAISES_EXCEPTIONS. For a POINTER_TYPE (to a METHOD_TYPE), this is TYPE_PTRMEMFUNC_TYPE. For an ENUMERAL_TYPE, BOUND_TEMPLATE_TEMPLATE_PARM_TYPE, - RECORD_TYPE or UNION_TYPE this is TYPE_TEMPLATE_INFO, + RECORD_TYPE or UNION_TYPE this is TYPE_TEMPLATE_INFO. + For a BITINT_TYPE, this is BITINT_PREC. BINFO_VIRTUALS For a binfo, this is a TREE_LIST. There is an entry for each @@ -4913,7 +4914,8 @@ get_vec_init_expr (tree t) #define INTEGRAL_CODE_P(CODE) \ ((CODE) == ENUMERAL_TYPE \ || (CODE) == BOOLEAN_TYPE \ - || (CODE) == INTEGER_TYPE) + || (CODE) == INTEGER_TYPE \ + || (CODE) == BITINT_TYPE) /* [basic.fundamental] @@ -4925,7 +4927,8 @@ get_vec_init_expr (tree t) ascending code order. */ #define CP_INTEGRAL_TYPE_P(TYPE) \ (TREE_CODE (TYPE) == BOOLEAN_TYPE \ - || TREE_CODE (TYPE) == INTEGER_TYPE) + || TREE_CODE (TYPE) == INTEGER_TYPE \ + || TREE_CODE (TYPE) == BITINT_TYPE) /* Returns true if TYPE is an integral or enumeration name. Keep these checks in ascending code order. */ @@ -5212,6 +5215,10 @@ get_vec_init_expr (tree t) #define INDIRECT_TYPE_P(NODE) \ (TYPE_PTR_P (NODE) || TYPE_REF_P (NODE)) +/* Precision of BITINT_TYPE when dependent. */ +#define BITINT_PREC(NODE) \ + TYPE_LANG_SLOT_1 (BITINT_TYPE_CHECK (NODE)) + /* Returns true if NODE is an object type: [basic.types] @@ -6961,6 +6968,7 @@ enum cp_decl_spec { ds_complex, ds_constinit, ds_consteval, + ds_bitint, ds_this, /* Index of last element of decl_spec_names. */ ds_thread, ds_type_spec, @@ -9092,6 +9100,8 @@ extern tree finish_binary_fold_expr extern tree treat_lvalue_as_rvalue_p (tree, bool); extern bool decl_in_std_namespace_p (tree); extern void maybe_warn_pessimizing_move (tree, tree, bool); +extern tree finish_bitint (location_t, tree, bool, + tsubst_flags_t); /* in typeck2.cc */ extern void require_complete_eh_spec_types (tree, tree); --- a/gcc/cp/typeck.cc 2026-10-30 21:46:23.584809888 +0100 +++ b/gcc/cp/typeck.cc 2026-11-02 12:52:46.411580583 +0100 @@ -473,6 +473,12 @@ cp_common_type (tree t1, tree t2) if (subtype == error_mark_node) return subtype; + if (TREE_CODE (subtype) == BITINT_TYPE) + { + sorry ("%<_Complex _BitInt(%d)%> unsupported", + TYPE_PRECISION (subtype)); + subtype = code1 == COMPLEX_TYPE ? subtype1 : subtype2; + } if (code1 == COMPLEX_TYPE && TREE_TYPE (t1) == subtype) return build_type_attribute_variant (t1, attributes); else if (code2 == COMPLEX_TYPE && TREE_TYPE (t2) == subtype) @@ -584,6 +590,23 @@ cp_common_type (tree t1, tree t2) } } + if ((code1 == BITINT_TYPE || code2 == BITINT_TYPE) && code1 != code2) + { + /* Prefer any other integral types over bit-precise integer + types. */ + if (TYPE_UNSIGNED (t1) == TYPE_UNSIGNED (t2)) + return build_type_attribute_variant (code1 == BITINT_TYPE + ? t2 : t1, attributes); + /* If BITINT_TYPE is unsigned and the other type is signed + non-BITINT_TYPE with the same precision, the latter has higher + rank. */ + if (TYPE_UNSIGNED (code1 == BITINT_TYPE ? t1 : t2)) + { + tree t = c_common_unsigned_type (code1 == BITINT_TYPE ? t2 : t1); + return build_type_attribute_variant (t, attributes); + } + } + /* Otherwise prefer the unsigned one. */ if (TYPE_UNSIGNED (t1)) return build_type_attribute_variant (t1, attributes); @@ -1524,6 +1547,19 @@ structural_comptypes (tree t1, tree t2, /* We don't need or want the attribute comparison. */ goto check_alias; + case BITINT_TYPE: + /* Similar to INTEGER_TYPE, just have to compare BITINT_PREC for + dependent bit-precise integers. */ + if (TYPE_CANONICAL (t1) != TYPE_CANONICAL (t2)) + return false; + if (TYPE_PRECISION (t1) != TYPE_PRECISION (t2)) + return false; + if (TYPE_PRECISION (t1) == 0 + && (TYPE_UNSIGNED (t1) != TYPE_UNSIGNED (t2) + || !cp_tree_equal (BITINT_PREC (t1), BITINT_PREC (t2)))) + return false; + goto check_alias; + case TEMPLATE_TEMPLATE_PARM: case BOUND_TEMPLATE_TEMPLATE_PARM: if (!comp_template_parms_position (t1, t2)) @@ -2782,6 +2818,7 @@ cp_perform_integral_promotions (tree exp tree bitfield_type = is_bitfield_expr_with_lowered_type (expr); if (bitfield_type && (TREE_CODE (bitfield_type) == ENUMERAL_TYPE + || TREE_CODE (bitfield_type) == BITINT_TYPE || TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node))) type = bitfield_type; @@ -4347,7 +4384,8 @@ cp_build_array_ref (location_t loc, tree ar = first = save_expr (ar); /* Put the integer in IND to simplify error checking. */ - if (TREE_CODE (TREE_TYPE (ar)) == INTEGER_TYPE) + if (TREE_CODE (TREE_TYPE (ar)) == INTEGER_TYPE + || TREE_CODE (TREE_TYPE (ar)) == BITINT_TYPE) std::swap (ar, ind); if (ar == error_mark_node || ind == error_mark_node) @@ -4359,7 +4397,8 @@ cp_build_array_ref (location_t loc, tree error_at (loc, "subscripted value is neither array nor pointer"); return error_mark_node; } - if (TREE_CODE (TREE_TYPE (ind)) != INTEGER_TYPE) + if (TREE_CODE (TREE_TYPE (ind)) != INTEGER_TYPE + && TREE_CODE (TREE_TYPE (ind)) != BITINT_TYPE) { if (complain & tf_error) error_at (loc, "array subscript is not an integer"); @@ -5235,7 +5274,8 @@ warn_for_null_address (location_t locati { /* Allow casts to intptr_t to suppress the warning. */ tree type = TREE_TYPE (cop); - if (TREE_CODE (type) == INTEGER_TYPE) + if (TREE_CODE (type) == INTEGER_TYPE + || TREE_CODE (type) == BITINT_TYPE) return; STRIP_NOPS (cop); @@ -5765,7 +5805,8 @@ cp_build_binary_op (const op_location_t } /* In all other cases except pointer - int, the usual arithmetic rules apply. */ - else if (!(code0 == POINTER_TYPE && code1 == INTEGER_TYPE)) + else if (!(code0 == POINTER_TYPE + && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))) { common = 1; break; @@ -5775,12 +5816,14 @@ cp_build_binary_op (const op_location_t gcc_fallthrough (); case PLUS_EXPR: if ((code0 == POINTER_TYPE || code1 == POINTER_TYPE) - && (code0 == INTEGER_TYPE || code1 == INTEGER_TYPE)) + && (code0 == INTEGER_TYPE || code0 == BITINT_TYPE + || code1 == INTEGER_TYPE || code1 == BITINT_TYPE)) { tree ptr_operand; tree int_operand; ptr_operand = ((code0 == POINTER_TYPE) ? op0 : op1); - int_operand = ((code0 == INTEGER_TYPE) ? op0 : op1); + int_operand = ((code0 == INTEGER_TYPE + || code0 == BITINT_TYPE) ? op0 : op1); if (processing_template_decl) { result_type = TREE_TYPE (ptr_operand); @@ -5844,9 +5887,11 @@ cp_build_binary_op (const op_location_t } if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE - || code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE) + || code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE + || code0 == BITINT_TYPE) && (code1 == INTEGER_TYPE || code1 == REAL_TYPE - || code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)) + || code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE + || code1 == BITINT_TYPE)) { enum tree_code tcode0 = code0, tcode1 = code1; doing_div_or_mod = true; @@ -5857,9 +5902,9 @@ cp_build_binary_op (const op_location_t if (tcode1 == COMPLEX_TYPE || tcode1 == VECTOR_TYPE) tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1))); - if (!((tcode0 == INTEGER_TYPE + if (!(((tcode0 == INTEGER_TYPE || tcode0 == BITINT_TYPE) || (tcode0 == ENUMERAL_TYPE && code0 == VECTOR_TYPE)) - && (tcode1 == INTEGER_TYPE + && ((tcode1 == INTEGER_TYPE || tcode1 == BITINT_TYPE) || (tcode1 == ENUMERAL_TYPE && code1 == VECTOR_TYPE)))) resultcode = RDIV_EXPR; else @@ -5880,7 +5925,8 @@ cp_build_binary_op (const op_location_t case BIT_AND_EXPR: case BIT_IOR_EXPR: case BIT_XOR_EXPR: - if ((code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) + if (((code0 == INTEGER_TYPE || code0 == BITINT_TYPE) + && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE)) || (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE && !VECTOR_FLOAT_TYPE_P (type0) && !VECTOR_FLOAT_TYPE_P (type1))) @@ -5896,7 +5942,8 @@ cp_build_binary_op (const op_location_t && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE) common = 1; - else if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) + else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE) + && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE)) { /* Although it would be tempting to shorten always here, that loses on some targets, since the modulo instruction is undefined if the @@ -5958,8 +6005,10 @@ cp_build_binary_op (const op_location_t if (warn_constant_logical_operand && (complain & tf_warning) - && (code0 == INTEGER_TYPE || code0 == ENUMERAL_TYPE) - && (code1 == INTEGER_TYPE || code1 == ENUMERAL_TYPE)) + && (code0 == INTEGER_TYPE || code0 == BITINT_TYPE + || code0 == ENUMERAL_TYPE) + && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE + || code1 == ENUMERAL_TYPE)) { tree cop0 = fold_for_warn (op0), cop1 = fold_for_warn (op1); const char *name @@ -6003,7 +6052,7 @@ cp_build_binary_op (const op_location_t case RSHIFT_EXPR: if (gnu_vector_type_p (type0) - && code1 == INTEGER_TYPE + && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE) && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE) { result_type = type0; @@ -6019,7 +6068,8 @@ cp_build_binary_op (const op_location_t result_type = type0; converted = 1; } - else if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) + else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE) + && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE)) { tree const_op1 = fold_for_warn (op1); if (TREE_CODE (const_op1) != INTEGER_CST) @@ -6054,7 +6104,7 @@ cp_build_binary_op (const op_location_t case LSHIFT_EXPR: if (gnu_vector_type_p (type0) - && code1 == INTEGER_TYPE + && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE) && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE) { result_type = type0; @@ -6070,7 +6120,8 @@ cp_build_binary_op (const op_location_t result_type = type0; converted = 1; } - else if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) + else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE) + && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE)) { tree const_op0 = fold_for_warn (op0); if (TREE_CODE (const_op0) != INTEGER_CST) @@ -6148,9 +6199,11 @@ cp_build_binary_op (const op_location_t build_type = boolean_type_node; if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE - || code0 == COMPLEX_TYPE || code0 == ENUMERAL_TYPE) + || code0 == COMPLEX_TYPE || code0 == ENUMERAL_TYPE + || code0 == BITINT_TYPE) && (code1 == INTEGER_TYPE || code1 == REAL_TYPE - || code1 == COMPLEX_TYPE || code1 == ENUMERAL_TYPE)) + || code1 == COMPLEX_TYPE || code1 == ENUMERAL_TYPE + || code1 == BITINT_TYPE)) short_compare = 1; else if (((code0 == POINTER_TYPE || TYPE_PTRDATAMEM_P (type0)) && null_ptr_cst_p (orig_op1)) @@ -6208,7 +6261,8 @@ cp_build_binary_op (const op_location_t else if (null_ptr_cst_p (orig_op0) && null_ptr_cst_p (orig_op1)) /* One of the operands must be of nullptr_t type. */ result_type = TREE_TYPE (nullptr_node); - else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) + else if (code0 == POINTER_TYPE + && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE)) { result_type = type0; if (complain & tf_error) @@ -6217,7 +6271,8 @@ cp_build_binary_op (const op_location_t else return error_mark_node; } - else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE) + else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE) + && code1 == POINTER_TYPE) { result_type = type1; if (complain & tf_error) @@ -6405,8 +6460,10 @@ cp_build_binary_op (const op_location_t case MAX_EXPR: case MIN_EXPR: - if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE) - && (code1 == INTEGER_TYPE || code1 == REAL_TYPE)) + if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE + || code0 == REAL_TYPE) + && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE + || code1 == REAL_TYPE)) shorten = 1; else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE) result_type = composite_pointer_type (location, @@ -6515,9 +6572,9 @@ cp_build_binary_op (const op_location_t } build_type = boolean_type_node; if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE - || code0 == ENUMERAL_TYPE) + || code0 == ENUMERAL_TYPE || code0 == BITINT_TYPE) && (code1 == INTEGER_TYPE || code1 == REAL_TYPE - || code1 == ENUMERAL_TYPE)) + || code1 == ENUMERAL_TYPE || code1 == BITINT_TYPE)) short_compare = 1; else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE) result_type = composite_pointer_type (location, @@ -6533,7 +6590,8 @@ cp_build_binary_op (const op_location_t "integer zero (%qT and %qT)", type0, type1); return error_mark_node; } - else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) + else if (code0 == POINTER_TYPE + && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE)) { result_type = type0; if (complain & tf_error) @@ -6542,7 +6600,8 @@ cp_build_binary_op (const op_location_t else return error_mark_node; } - else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE) + else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE) + && code1 == POINTER_TYPE) { result_type = type1; if (complain & tf_error) @@ -6587,9 +6646,10 @@ cp_build_binary_op (const op_location_t } if (((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE - || code0 == ENUMERAL_TYPE) + || code0 == ENUMERAL_TYPE || code0 == BITINT_TYPE) && (code1 == INTEGER_TYPE || code1 == REAL_TYPE - || code1 == COMPLEX_TYPE || code1 == ENUMERAL_TYPE))) + || code1 == COMPLEX_TYPE || code1 == ENUMERAL_TYPE + || code1 == BITINT_TYPE))) arithmetic_types_p = 1; else { @@ -9751,7 +9811,8 @@ cp_build_c_cast (location_t loc, tree ty } if (TYPE_PTR_P (type) - && TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE + && (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE + || TREE_CODE (TREE_TYPE (value)) == BITINT_TYPE) /* Casting to an integer of smaller size is an error detected elsewhere. */ && TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (value)) /* Don't warn about converting any constant. */ @@ -12067,7 +12128,7 @@ ptr_reasonably_similar (const_tree to, c && vector_types_convertible_p (to, from, false)) return true; - if (TREE_CODE (to) == INTEGER_TYPE + if ((TREE_CODE (to) == INTEGER_TYPE || TREE_CODE (to) == BITINT_TYPE) && TYPE_PRECISION (to) == TYPE_PRECISION (from)) return true; @@ -12522,6 +12583,59 @@ check_literal_operator_args (const_tree } } +/* Finish a BITINT_TYPE with precision PREC. */ + +tree +finish_bitint (location_t loc, tree prec, bool unsignedp, + tsubst_flags_t complain) +{ + if (!type_dependent_expression_p (prec)) + prec = build_converted_constant_expr (size_type_node, prec, complain); + prec = fold_non_dependent_expr (prec, complain, true); + if (error_operand_p (prec)) + return error_mark_node; + if (TREE_CODE (prec) == INTEGER_CST) + { + if (integer_zerop (prec)) + { + if (complain & tf_error) + error_at (loc, "%<_BitInt%> argument %qE is not a positive " + "integer constant expression", prec); + return error_mark_node; + } + else if (wi::to_widest (prec) > WIDE_INT_MAX_PRECISION - 1) + { + if (complain & tf_error) + error_at (loc, "%<_BitInt%> argument %qE is larger than " + "% %qd", + prec, (int) WIDE_INT_MAX_PRECISION - 1); + return error_mark_node; + } + unsigned int p = tree_to_uhwi (prec); + struct bitint_info info; + if (!targetm.c.bitint_type_info (p, &info)) + { + if (complain & tf_error) + sorry_at (loc, "%<_BitInt(%d)%> is not supported on this " + "target", p); + return error_mark_node; + } + return build_bitint_type (p, unsignedp); + } + else if (!value_dependent_expression_p (prec)) + { + if (complain & tf_error) + error_at (loc, "%<_BitInt%> argument is not an integer " + "constant expression"); + return error_mark_node; + } + tree ret = make_node (BITINT_TYPE); + TYPE_PRECISION (ret) = 0; + TYPE_UNSIGNED (ret) = unsignedp; + BITINT_PREC (ret) = prec; + return ret; +} + /* Always returns false since unlike C90, C++ has no concept of implicit function declarations. */ --- a/gcc/cp/decl.cc 2026-10-30 17:05:21.696552424 +0100 +++ b/gcc/cp/decl.cc 2026-10-30 21:48:13.132151918 +0100 @@ -7712,6 +7712,7 @@ reshape_init_array_1 (tree elt_type, tre check_array_designated_initializer (d->cur, index); if (TREE_CODE (d->cur->value) == RAW_DATA_CST && (TREE_CODE (elt_type) == INTEGER_TYPE + || TREE_CODE (elt_type) == BITINT_TYPE || is_byte_access_type (elt_type)) && TYPE_PRECISION (elt_type) == CHAR_BIT && (!sized_array_p || index < max_index_cst) @@ -14256,6 +14257,7 @@ grokdeclarator (const cp_declarator *dec bool constexpr_p = decl_spec_seq_has_spec_p (declspecs, ds_constexpr); bool constinit_p = decl_spec_seq_has_spec_p (declspecs, ds_constinit); bool consteval_p = decl_spec_seq_has_spec_p (declspecs, ds_consteval); + bool bitint_p = decl_spec_seq_has_spec_p (declspecs, ds_bitint); bool late_return_type_p = false; bool array_parameter_p = false; tree reqs = NULL_TREE; @@ -14777,15 +14779,19 @@ grokdeclarator (const cp_declarator *dec complain_about_incompatible_declspecs ("long", declspecs->locations[ds_long], "short", declspecs->locations[ds_short]); - else if (TREE_CODE (type) != INTEGER_TYPE + else if ((TREE_CODE (type) != INTEGER_TYPE + && TREE_CODE (type) != BITINT_TYPE) || type == char8_type_node || type == char16_type_node || type == char32_type_node || ((long_p || short_p) - && (explicit_char || explicit_intN))) + && (explicit_char + || explicit_intN + || TREE_CODE (type) == BITINT_TYPE))) error_at (loc, "%qs specified with %qT", key, type); else if (!explicit_int && !defaulted_int - && !explicit_char && !explicit_intN) + && !explicit_char && !explicit_intN + && !bitint_p) { if (typedef_decl) { @@ -14848,6 +14854,16 @@ grokdeclarator (const cp_declarator *dec type = short_unsigned_type_node; else if (type == char_type_node) type = unsigned_char_type_node; + else if (TREE_CODE (type) == BITINT_TYPE) + { + if (TYPE_PRECISION (type)) + type = c_common_unsigned_type (type); + else + { + type = build_distinct_type_copy (type); + TYPE_UNSIGNED (type) = 1; + } + } else if (typedef_decl) type = c_common_unsigned_type (type); else --- a/gcc/cp/pt.cc 2026-10-30 21:46:23.583809901 +0100 +++ b/gcc/cp/pt.cc 2026-11-02 11:44:06.936980981 +0100 @@ -4248,6 +4248,15 @@ find_parameter_packs_r (tree *tp, int *w *walk_subtrees = 0; return NULL_TREE; + case BITINT_TYPE: + if (TYPE_PRECISION (t) == 0) + { + cp_walk_tree (&BITINT_PREC (t), &find_parameter_packs_r, + ppd, ppd->visited); + } + *walk_subtrees = 0; + return NULL_TREE; + case IDENTIFIER_NODE: cp_walk_tree (&TREE_TYPE (t), &find_parameter_packs_r, ppd, ppd->visited); @@ -17428,6 +17437,16 @@ tsubst (tree t, tree args, tsubst_flags_ return compute_array_index_type (NULL_TREE, max, complain); } + case BITINT_TYPE: + if (TYPE_PRECISION (t)) + return t; + else + { + tree prec = tsubst_expr (BITINT_PREC (t), args, complain, in_decl); + return finish_bitint (input_location, prec, TYPE_UNSIGNED (t), + complain); + } + case TEMPLATE_TYPE_PARM: if (TEMPLATE_TYPE_LEVEL (t) == 0) { @@ -24961,6 +24980,11 @@ uses_deducible_template_parms (tree type return (uses_deducible_template_parms (TREE_TYPE (type)) || deducible_array_bound (TYPE_DOMAIN (type))); + /* _BitInt(i) */ + if (TREE_CODE (type) == BITINT_TYPE + && TYPE_PRECISION (type) == 0) + return deducible_expression (BITINT_PREC (type)); + /* T type ::* type T::* T T::* @@ -25132,6 +25156,12 @@ array_deduction_r (tree t, void *data) UNIFY_ALLOW_NONE, /*explain*/false); } + if (TREE_CODE (t) == BITINT_TYPE + && TYPE_PRECISION (t) == 0 + && TREE_CODE (BITINT_PREC (t)) == TEMPLATE_PARM_INDEX) + unify (tparms, targs, TREE_TYPE (BITINT_PREC (t)), size_type_node, + UNIFY_ALLOW_NONE, /*explain*/false); + /* Keep walking. */ return 0; } @@ -25139,7 +25169,7 @@ array_deduction_r (tree t, void *data) /* Try to deduce any not-yet-deduced template type arguments from the type of an array bound. This is handled separately from unify because 14.8.2.5 says "The type of a type parameter is only deduced from an array bound if it is - not otherwise deduced." */ + not otherwise deduced." Also handles _BitInt width deduction. */ static void try_array_deduction (tree tparms, tree targs, tree parm) @@ -26915,6 +26945,28 @@ unify (tree tparms, tree targs, tree par will invalidate it if necessary. */ return unify_success (explain_p); + case BITINT_TYPE: + if (TREE_CODE (arg) != BITINT_TYPE + || TYPE_UNSIGNED (arg) != TYPE_UNSIGNED (parm)) + return unify_type_mismatch (explain_p, parm, arg); + if (TYPE_PRECISION (arg) == 0 || TYPE_PRECISION (parm) == 0) + { + tree arg_prec, parm_prec; + if (TYPE_PRECISION (arg) == 0) + arg_prec = BITINT_PREC (arg); + else + arg_prec = size_int (TYPE_PRECISION (arg)); + if (TYPE_PRECISION (parm) == 0) + parm_prec = BITINT_PREC (parm); + else + parm_prec = size_int (TYPE_PRECISION (parm)); + return unify (tparms, targs, parm_prec, arg_prec, + UNIFY_ALLOW_INTEGER, explain_p); + } + if (!same_type_ignoring_top_level_qualifiers_p (arg, parm)) + return unify_type_mismatch (explain_p, parm, arg); + return unify_success (explain_p); + /* Types INTEGER_CST and MINUS_EXPR can come from array bounds. */ /* Type INTEGER_CST can come from ordinary constant template args. */ case INTEGER_CST: @@ -29877,6 +29929,12 @@ dependent_type_p_r (tree type) || TREE_CODE (type) == TRAIT_TYPE) return true; + /* Bit-precise integer types with value-dependent width are dependent. */ + if (TREE_CODE (type) == BITINT_TYPE + && TYPE_PRECISION (type) == 0 + && BITINT_PREC (type)) + return true; + /* A template argument pack is dependent if any of its packed arguments are. */ if (TREE_CODE (type) == TYPE_ARGUMENT_PACK) --- a/gcc/cp/error.cc 2026-10-30 17:05:21.703552333 +0100 +++ b/gcc/cp/error.cc 2026-10-30 21:48:13.136261303 +0100 @@ -766,6 +766,7 @@ dump_type (cxx_pretty_printer *pp, tree case COMPLEX_TYPE: case VECTOR_TYPE: case FIXED_POINT_TYPE: + case BITINT_TYPE: pp_type_specifier_seq (pp, t); break; @@ -1148,6 +1149,7 @@ dump_type_prefix (cxx_pretty_printer *pp case NULLPTR_TYPE: case PACK_INDEX_TYPE: case SPLICE_SCOPE: + case BITINT_TYPE: dump_type (pp, t, flags); pp->set_padding (pp_before); break; @@ -1282,6 +1284,7 @@ dump_type_suffix (cxx_pretty_printer *pp case NULLPTR_TYPE: case PACK_INDEX_TYPE: case SPLICE_SCOPE: + case BITINT_TYPE: break; default: @@ -3173,6 +3176,7 @@ dump_expr (cxx_pretty_printer *pp, tree case COMPLEX_TYPE: case VECTOR_TYPE: case DECLTYPE_TYPE: + case BITINT_TYPE: pp_type_specifier_seq (pp, t); break; --- a/gcc/cp/cxx-pretty-print.cc 2026-10-30 17:05:21.692552475 +0100 +++ b/gcc/cp/cxx-pretty-print.cc 2026-10-30 21:48:13.136692492 +0100 @@ -1442,6 +1442,21 @@ cxx_pretty_printer::simple_type_specifie pp_cxx_trait (this, t); break; + case BITINT_TYPE: + if (TYPE_NAME (t) == NULL_TREE + && TYPE_PRECISION (t) == 0 + && BITINT_PREC (t)) + { + if (TYPE_UNSIGNED (t)) + pp_c_ws_string (this, "unsigned"); + pp_c_ws_string (this, "_BitInt(");; + expression (BITINT_PREC (t)); + pp_right_paren (this); + break; + } + c_pretty_printer::simple_type_specifier (t); + break; + case OPAQUE_TYPE: if (REFLECTION_TYPE_P (t)) { --- a/gcc/cp/tree.cc 2026-10-30 17:05:21.720552114 +0100 +++ b/gcc/cp/tree.cc 2026-10-30 21:48:13.137097966 +0100 @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. #include "attribs.h" #include "flags.h" #include "selftest.h" +#include "target.h" static tree bot_manip (tree *, int *, void *); static tree bot_replace (tree *, int *, void *); @@ -5114,6 +5115,39 @@ type_has_unique_obj_representations (con inform (loc, "%qT is a fixed-point type", t); return false; + case BITINT_TYPE: + { + struct bitint_info info; + bool ok = targetm.c.bitint_type_info (TYPE_PRECISION (t), &info); + gcc_assert (ok); + if (info.extended == bitint_ext_full) + return true; + scalar_int_mode abi_limb_mode + = as_a (info.abi_limb_mode); + if (TYPE_PRECISION (t) < GET_MODE_PRECISION (abi_limb_mode)) + { + if (info.extended == bitint_ext_partial) + return true; + } + else if (TYPE_PRECISION (t) == GET_MODE_PRECISION (abi_limb_mode)) + return true; + else if ((((unsigned) TYPE_PRECISION (t)) + % GET_MODE_PRECISION (abi_limb_mode)) == 0) + return true; + else if (info.extended == bitint_ext_partial) + { + scalar_int_mode limb_mode + = as_a (info.limb_mode); + if ((ROUND_UP ((unsigned) TYPE_PRECISION (t), + (unsigned) GET_MODE_PRECISION (limb_mode)) + % GET_MODE_PRECISION (abi_limb_mode)) == 0) + return true; + } + if (explain) + inform (loc, "%qT has padding bits", t); + return false; + } + case OFFSET_TYPE: return true; @@ -6606,6 +6640,11 @@ cp_walk_subtrees (tree *tp, int *walk_su WALK_SUBTREE (TYPE_MAX_VALUE (t)); break; + case BITINT_TYPE: + if (TYPE_PRECISION (t) == 0) + WALK_SUBTREE (BITINT_PREC (t)); + break; + case SPLICE_SCOPE: WALK_SUBTREE (SPLICE_SCOPE_EXPR (t)); *walk_subtrees_p = 0; --- a/gcc/cp/semantics.cc 2026-10-30 17:05:21.715552179 +0100 +++ b/gcc/cp/semantics.cc 2026-10-30 21:48:13.137949020 +0100 @@ -11869,7 +11869,8 @@ handle_omp_for_class_iterator (int i, lo diff = cp_fully_fold (diff); if (error_operand_p (diff)) return true; - if (TREE_CODE (TREE_TYPE (diff)) != INTEGER_TYPE) + if (TREE_CODE (TREE_TYPE (diff)) != INTEGER_TYPE + && TREE_CODE (TREE_TYPE (diff)) != BITINT_TYPE) { error_at (elocus, "difference between %qE and %qD does not have integer type", TREE_OPERAND (cond, 1), iter); @@ -11912,7 +11913,9 @@ handle_omp_for_class_iterator (int i, lo if (TREE_OPERAND (rhs, 0) == iter) { if (TREE_CODE (TREE_TYPE (TREE_OPERAND (rhs, 1))) - != INTEGER_TYPE) + != INTEGER_TYPE + && (TREE_CODE (TREE_TYPE (TREE_OPERAND (rhs, 1))) + != BITINT_TYPE)) incr = error_mark_node; else { @@ -11940,7 +11943,10 @@ handle_omp_for_class_iterator (int i, lo } else if (TREE_OPERAND (rhs, 1) == iter) { - if (TREE_CODE (TREE_TYPE (TREE_OPERAND (rhs, 0))) != INTEGER_TYPE + if ((TREE_CODE (TREE_TYPE (TREE_OPERAND (rhs, 0))) + != INTEGER_TYPE + && (TREE_CODE (TREE_TYPE (TREE_OPERAND (rhs, 0))) + != BITINT_TYPE)) || TREE_CODE (rhs) != PLUS_EXPR) incr = error_mark_node; else --- a/gcc/cp/call.cc 2026-10-30 17:05:21.676552682 +0100 +++ b/gcc/cp/call.cc 2026-10-30 21:48:13.139153037 +0100 @@ -564,7 +564,8 @@ null_ptr_cst_p (tree t) /* Core issue 903 says only literal 0 is a null pointer constant. */ if (TREE_CODE (t) == INTEGER_CST && !TREE_OVERFLOW (t) - && TREE_CODE (type) == INTEGER_TYPE + && (TREE_CODE (type) == INTEGER_TYPE + || TREE_CODE (type) == BITINT_TYPE) && integer_zerop (t) && !char_type_p (type)) return true; @@ -888,6 +889,7 @@ build_list_conv (tree type, tree ctor, i if (sub->kind == ck_std && sub->type && (TREE_CODE (sub->type) == INTEGER_TYPE + || TREE_CODE (sub->type) == BITINT_TYPE || is_byte_access_type (sub->type)) && TYPE_PRECISION (sub->type) == CHAR_BIT && (next = next_conversion (sub)) @@ -1400,15 +1402,18 @@ standard_conversion (tree to, tree from, && ((expr && null_ptr_cst_p (expr)) || NULLPTR_TYPE_P (from))) conv = build_conv (ck_std, to, conv); - else if ((tcode == INTEGER_TYPE && fcode == POINTER_TYPE) - || (tcode == POINTER_TYPE && fcode == INTEGER_TYPE)) + else if (((tcode == INTEGER_TYPE || tcode == BITINT_TYPE) + && fcode == POINTER_TYPE) + || (tcode == POINTER_TYPE + && (fcode == INTEGER_TYPE || fcode == BITINT_TYPE))) { /* For backwards brain damage compatibility, allow interconversion of pointers and integers with a pedwarn. */ conv = build_conv (ck_std, to, conv); conv->bad_p = true; } - else if (UNSCOPED_ENUM_P (to) && fcode == INTEGER_TYPE) + else if (UNSCOPED_ENUM_P (to) + && (fcode == INTEGER_TYPE || fcode == BITINT_TYPE)) { /* For backwards brain damage compatibility, allow interconversion of enums and integers with a pedwarn. */ @@ -6073,9 +6078,11 @@ build_conditional_expr (const op_locatio if ((TREE_CODE (arg2) == EXCESS_PRECISION_EXPR || TREE_CODE (arg3) == EXCESS_PRECISION_EXPR) && (TREE_CODE (arg2_type) == INTEGER_TYPE + || TREE_CODE (arg2_type) == BITINT_TYPE || SCALAR_FLOAT_TYPE_P (arg2_type) || TREE_CODE (arg2_type) == COMPLEX_TYPE) && (TREE_CODE (arg3_type) == INTEGER_TYPE + || TREE_CODE (arg3_type) == BITINT_TYPE || SCALAR_FLOAT_TYPE_P (arg3_type) || TREE_CODE (arg3_type) == COMPLEX_TYPE)) { @@ -9085,6 +9092,7 @@ convert_like_internal (conversion *convs conversion *next = next_conversion (convs->u.list[ix]); gcc_assert (et && (TREE_CODE (et) == INTEGER_TYPE + || TREE_CODE (et) == BITINT_TYPE || is_byte_access_type (et)) && TYPE_PRECISION (et) == CHAR_BIT && next @@ -13483,8 +13491,10 @@ joust (struct z_candidate *cand1, struct == cr_std + cr_promotion) && t1->kind == ck_std && t2->kind == ck_std - && TREE_CODE (t1->type) == INTEGER_TYPE - && TREE_CODE (t2->type) == INTEGER_TYPE + && (TREE_CODE (t1->type) == INTEGER_TYPE + || TREE_CODE (t1->type) == BITINT_TYPE) + && (TREE_CODE (t2->type) == INTEGER_TYPE + || TREE_CODE (t2->type) == BITINT_TYPE) && (TYPE_PRECISION (t1->type) == TYPE_PRECISION (t2->type)) && (TYPE_UNSIGNED (next_conversion (t1)->type) --- a/gcc/cp/constexpr.cc 2026-10-30 21:46:23.573810032 +0100 +++ b/gcc/cp/constexpr.cc 2026-10-30 21:48:13.140376583 +0100 @@ -6839,7 +6839,8 @@ cxx_eval_bit_field_ref (const constexpr_ STRIP_ANY_LOCATION_WRAPPER (value); if (bitpos == start && DECL_SIZE (field) == TREE_OPERAND (t, 1)) return value; - if (TREE_CODE (TREE_TYPE (field)) == INTEGER_TYPE + if ((TREE_CODE (TREE_TYPE (field)) == INTEGER_TYPE + || TREE_CODE (TREE_TYPE (field)) == BITINT_TYPE) && TREE_CODE (value) == INTEGER_CST && tree_fits_shwi_p (bitpos) && tree_fits_shwi_p (DECL_SIZE (field))) @@ -11598,7 +11599,9 @@ cxx_eval_outermost_constant_expr (tree t we don't shortcut all vector constructors. */ if (fndecl && DECL_CONSTRUCTOR_P (fndecl) && allow_non_constant && is_std_class (type, "vector") && call_expr_nargs (x) > 1 - && TREE_CODE (TREE_TYPE (get_nth_callarg (x, 1))) == INTEGER_TYPE) + && (TREE_CODE (TREE_TYPE (get_nth_callarg (x, 1))) == INTEGER_TYPE + || (TREE_CODE (TREE_TYPE (get_nth_callarg (x, 1))) + == BITINT_TYPE))) return t; } if (AGGREGATE_TYPE_P (type) || VECTOR_TYPE_P (type)) --- a/gcc/cp/cvt.cc 2026-10-30 17:05:21.685552566 +0100 +++ b/gcc/cp/cvt.cc 2026-10-30 21:48:13.141175664 +0100 @@ -1868,6 +1868,7 @@ build_expr_type_conversion (int desires, switch (TREE_CODE (basetype)) { case INTEGER_TYPE: + case BITINT_TYPE: if ((desires & WANT_NULL) && null_ptr_cst_p (expr)) return expr; /* fall through. */ @@ -1897,6 +1898,7 @@ build_expr_type_conversion (int desires, switch (TREE_CODE (TREE_TYPE (basetype))) { case INTEGER_TYPE: + case BITINT_TYPE: case BOOLEAN_TYPE: return (desires & WANT_INT) ? expr : NULL_TREE; case ENUMERAL_TYPE: @@ -1937,6 +1939,7 @@ build_expr_type_conversion (int desires, { case BOOLEAN_TYPE: case INTEGER_TYPE: + case BITINT_TYPE: win = (desires & WANT_INT); break; case ENUMERAL_TYPE: win = (desires & WANT_ENUM); break; --- a/gcc/cp/init.cc 2026-10-30 17:05:21.703552333 +0100 +++ b/gcc/cp/init.cc 2026-10-30 21:48:13.141552991 +0100 @@ -4930,6 +4930,7 @@ build_vec_init (tree base, tree maxindex { if (digested && (TREE_CODE (type) == INTEGER_TYPE + || TREE_CODE (type) == BITINT_TYPE || is_byte_access_type (type)) && TYPE_PRECISION (type) == CHAR_BIT) { --- a/gcc/cp/mangle.cc 2026-10-30 21:46:23.575810006 +0100 +++ b/gcc/cp/mangle.cc 2026-10-30 21:48:13.142046633 +0100 @@ -2554,7 +2554,8 @@ write_type (tree type) if (!VOID_TYPE_P (type) && TREE_CODE (type) != INTEGER_TYPE && TREE_CODE (type) != REAL_TYPE - && TREE_CODE (type) != BOOLEAN_TYPE) + && TREE_CODE (type) != BOOLEAN_TYPE + && TREE_CODE (type) != BITINT_TYPE) add_substitution (type); return; } @@ -2566,6 +2567,7 @@ write_type (tree type) case INTEGER_TYPE: /* Includes wchar_t. */ case REAL_TYPE: case FIXED_POINT_TYPE: + case BITINT_TYPE: { /* If this is a typedef, TYPE may not be one of the standard builtin type nodes, but an alias of one. Use @@ -2935,7 +2937,16 @@ write_CV_qualifiers_for_type (const tree ::= f # float ::= d # double ::= e # long double, __float80 - ::= g # __float128 [not supported] + ::= g # __float128 + ::= Di # char32_t + ::= Ds # char16_t + ::= Du # char8_t + ::= DB _ # C++29 signed _BitInt(N) + ::= DB _ + # C++29 signed _BitInt(N) + ::= DU _ # C++29 unsigned _BitInt(N) + ::= DU _ + # C++29 unsigned _BitInt(N) ::= u # vendor extended type */ static void @@ -3051,6 +3062,18 @@ write_builtin_type (tree type) gcc_unreachable (); break; + case BITINT_TYPE: + if (TYPE_UNSIGNED (type)) + write_string ("DU"); + else + write_string ("DB"); + if (TYPE_PRECISION (type) != 0) + write_number (TYPE_PRECISION (type), /*unsigned_p=*/1, 10); + else + write_expression (BITINT_PREC (type)); + write_char ('_'); + break; + default: gcc_unreachable (); } --- a/gcc/cp/class.cc 2026-10-16 12:19:50.930077747 +0200 +++ b/gcc/cp/class.cc 2026-11-02 12:08:49.088392583 +0100 @@ -7316,9 +7316,13 @@ layout_class_type (tree t, tree *virtual width = tree_to_uhwi (DECL_SIZE (field)); if (width != TYPE_PRECISION (ftype)) { - TREE_TYPE (field) - = c_build_bitfield_integer_type (width, - TYPE_UNSIGNED (ftype)); + if (BITINT_TYPE_P (ftype) && width >= 1) + TREE_TYPE (field) + = build_bitint_type (width, TYPE_UNSIGNED (ftype)); + else + TREE_TYPE (field) + = c_build_bitfield_integer_type (width, + TYPE_UNSIGNED (ftype)); TREE_TYPE (field) = cp_build_qualified_type (TREE_TYPE (field), cp_type_quals (ftype)); @@ -7374,7 +7378,8 @@ layout_class_type (tree t, tree *virtual to that width. */ && (DECL_SIZE (field) == NULL_TREE || integer_zerop (DECL_SIZE (field))) - && TREE_TYPE (field) != error_mark_node) + && TREE_TYPE (field) != error_mark_node + && DECL_BIT_FIELD (field)) SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD (field, 1); check_non_pod_aggregate (field); } --- a/gcc/testsuite/g++.dg/ext/bitint1.C 2026-10-30 17:05:21.730551985 +0100 +++ b/gcc/testsuite/g++.dg/ext/bitint1.C 2026-10-30 21:48:13.142282573 +0100 @@ -1,9 +0,0 @@ -// PR c/102989 -// { dg-do compile } - -_BitInt(63) a; // { dg-error "expected" } -unsigned _BitInt(31) b; // { dg-error "expected" } -int c = 21wb; // { dg-error "invalid suffix 'wb' on integer constant" "" { target c++98_only } } - // { dg-error "unable to find numeric literal operator 'operator\"\"wb'" "" { target c++11 } .-1 } -long long d = 60594869054uwb; // { dg-error "invalid suffix 'uwb' on integer constant" "" { target c++98_only } } - // { dg-error "unable to find numeric literal operator 'operator\"\"uwb'" "" { target c++11 } .-1 } --- a/gcc/testsuite/g++.dg/ext/bitint2.C 2026-10-30 17:05:21.730551985 +0100 +++ b/gcc/testsuite/g++.dg/ext/bitint2.C 2026-10-30 21:48:13.142479834 +0100 @@ -1,10 +0,0 @@ -// PR c/102989 -// { dg-do compile } -// { dg-options "" } - -_BitInt(63) a; // { dg-error "expected" } -unsigned _BitInt(31) b; // { dg-error "expected" } -int c = 21wb; // { dg-error "invalid suffix 'wb' on integer constant" "" { target c++98_only } } - // { dg-error "unable to find numeric literal operator 'operator\"\"wb'" "" { target c++11 } .-1 } -long long d = 60594869054uwb; // { dg-error "invalid suffix 'uwb' on integer constant" "" { target c++98_only } } - // { dg-error "unable to find numeric literal operator 'operator\"\"uwb'" "" { target c++11 } .-1 } --- a/gcc/testsuite/g++.dg/ext/bitint3.C 2026-10-30 17:05:21.730551985 +0100 +++ b/gcc/testsuite/g++.dg/ext/bitint3.C 2026-10-30 21:48:13.142621374 +0100 @@ -1,8 +0,0 @@ -// PR c/102989 -// { dg-do compile { target c++11 } } - -constexpr int operator""wb (unsigned long long) { return 0; } // { dg-warning "reserved for future standardization" } -constexpr int operator""uwb (unsigned long long) { return 1; } // { dg-warning "reserved for future standardization" } - -static_assert (-42wb == 0, ""); -static_assert (81uwb == 1, ""); --- a/gcc/testsuite/g++.dg/ext/bitint4.C 2026-10-30 17:05:21.730551985 +0100 +++ b/gcc/testsuite/g++.dg/ext/bitint4.C 2026-10-30 21:48:13.142728072 +0100 @@ -1,9 +0,0 @@ -// PR c/102989 -// { dg-do compile { target c++11 } } -// { dg-options "" } - -constexpr int operator""wb (unsigned long long) { return 0; } // { dg-warning "reserved for future standardization" } -constexpr int operator""uwb (unsigned long long) { return 1; } // { dg-warning "reserved for future standardization" } - -static_assert (-42wb == 0, ""); -static_assert (81uwb == 1, ""); --- a/gcc/testsuite/g++.dg/cpp29/bitint1.C 2026-10-30 21:48:13.142944973 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint1.C 2026-10-30 21:48:13.142944973 +0100 @@ -0,0 +1,27 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +void +foo (int x) +{ + _BitInt (1) a; + signed _BitInt (1) b; + _BitInt (0) c; // { dg-error "'_BitInt' argument '0' is not a positive integer constant expression" } + unsigned _BitInt (0) d; // { dg-error "'_BitInt' argument '0' is not a positive integer constant expression" } + _BitInt (-42) e; // { dg-error "narrowing conversion of '-42' from 'int' to '\[^'\n\r]*'" } + _BitInt (-5) unsigned f; // { dg-error "narrowing conversion of '-5' from 'int' to '\[^'\n\r]*'" } + _BitInt (4294967295ULL) g; // { dg-error "'_BitInt' argument '4294967295' is larger than 'BITINT_MAXWIDTH' '\[0-9]+'" } + long _BitInt (42) h; // { dg-error "'long' specified with '_BitInt\\\(42\\\)'" } + long long _BitInt (42) i; // { dg-error "'long long' specified with '_BitInt\\\(42\\\)'" } + _BitInt (42) long j; // { dg-error "'long' specified with '_BitInt\\\(42\\\)'" } + _BitInt (42) long long k; // { dg-error "'long long' specified with '_BitInt\\\(42\\\)'" } + short _BitInt (42) l; // { dg-error "'short' specified with '_BitInt\\\(42\\\)'" } + _BitInt (42) short m; // { dg-error "'short' specified with '_BitInt\\\(42\\\)'" } + _Complex _BitInt (42) n; // { dg-error "complex invalid for 'n'" } + _BitInt (42) _Complex o; // { dg-error "complex invalid for 'o'" } + int _BitInt (42) p; // { dg-error "two or more data types in declaration of 'p'" } + _BitInt (42) int q; // { dg-error "two or more data types in declaration of 'q'" } + _BitInt (x) r; // { dg-error "'x' is not a constant expression" } +} // { dg-error "'_BitInt' argument is not an integer constant expression" "" { target *-*-* } .-1 } --- a/gcc/testsuite/g++.dg/cpp29/bitint2.C 2026-10-30 21:48:13.143033178 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint2.C 2026-10-30 21:48:13.143033178 +0100 @@ -0,0 +1,9 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-require-effective-target bitint } + +auto a = 123wb; // { dg-error "'wb' literal suffixes before C\\\+\\\+29 are a GCC extension" "" { target c++26_down } } +auto b = 234uwb; // { dg-error "'wb' literal suffixes before C\\\+\\\+29 are a GCC extension" "" { target c++26_down } } +_BitInt(1) c; // { dg-error "'_BitInt' only available with" "" { target c++26_down } } +unsigned _BitInt(1) d; // { dg-error "'_BitInt' only available with" "" { target c++26_down } } +_BitInt(1) signed e; // { dg-error "'_BitInt' only available with" "" { target c++26_down } } --- a/gcc/testsuite/g++.dg/cpp29/bitint3.C 2026-10-30 21:48:13.143137166 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint3.C 2026-10-30 21:48:13.143137166 +0100 @@ -0,0 +1,10 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile } +// { dg-options "" } +// { dg-require-effective-target bitint } + +int a = 123wb; // { dg-warning "'wb' literal suffixes before C\\\+\\\+29 are a GCC extension" "" { target c++26_down } } +unsigned b = 234uwb; // { dg-warning "'wb' literal suffixes before C\\\+\\\+29 are a GCC extension" "" { target c++26_down } } +_BitInt(1) c; +unsigned _BitInt(1) d; +_BitInt(1) signed e; --- a/gcc/testsuite/g++.dg/cpp29/bitint4.C 2026-10-30 21:48:13.143233528 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint4.C 2026-10-30 21:48:13.143233528 +0100 @@ -0,0 +1,10 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-options "-pedantic" } +// { dg-require-effective-target bitint } + +auto a = 123wb; // { dg-warning "'wb' literal suffixes before C\\\+\\\+29 are a GCC extension" "" { target c++26_down } } +auto b = 234uwb; // { dg-warning "'wb' literal suffixes before C\\\+\\\+29 are a GCC extension" "" { target c++26_down } } +_BitInt(1) c; // { dg-warning "'_BitInt' only available with" "" { target c++26_down } } +unsigned _BitInt(1) d; // { dg-warning "'_BitInt' only available with" "" { target c++26_down } } +_BitInt(1) signed e; // { dg-warning "'_BitInt' only available with" "" { target c++26_down } } --- a/gcc/testsuite/g++.dg/cpp29/bitint5.C 2026-10-30 21:48:13.143331022 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint5.C 2026-10-30 21:48:13.143331022 +0100 @@ -0,0 +1,128 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +template +struct same_type { static constexpr bool value = false; }; +template +struct same_type { static constexpr bool value = true; }; + +#define expr_has_type(e, t) same_type ::value + +#ifdef __BITINT_MAXWIDTH__ +void +foo (void) +{ + _BitInt(42) a = (_BitInt(42)) 1; + _BitInt(42) unsigned b = (unsigned _BitInt(42)) 2; + _BitInt(5) c = (_BitInt(5)) 3; + _BitInt(5) unsigned d = (unsigned _BitInt(5)) 4; + _BitInt(32) e = (_BitInt(32)) 5; + _BitInt(32) unsigned f = (unsigned _BitInt(32)) 6; + constexpr int g = 43; + enum E { F = 44 }; + _BitInt(g) h; + unsigned _BitInt(F) i; + static_assert (expr_has_type (a, signed _BitInt(42)), ""); + static_assert (expr_has_type (a, _BitInt(42)), ""); + static_assert (!expr_has_type (a, unsigned _BitInt(42)), ""); + static_assert (!expr_has_type (b, signed _BitInt(42)), ""); + static_assert (!expr_has_type (b, _BitInt(42)), ""); + static_assert (expr_has_type (b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (a + b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (a * b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (a - b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (a * a, _BitInt(42)), ""); + static_assert (expr_has_type (a / b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (c, signed _BitInt(5)), ""); + static_assert (expr_has_type (c, _BitInt(5)), ""); + static_assert (!expr_has_type (c, unsigned _BitInt(5)), ""); + static_assert (!expr_has_type (d, signed _BitInt(5)), ""); + static_assert (!expr_has_type (d, _BitInt(5)), ""); + static_assert (expr_has_type (d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (c + d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (c * d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (c - d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (c * c, _BitInt(5)), ""); + static_assert (expr_has_type (c / d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (e, signed _BitInt(32)), ""); + static_assert (expr_has_type (e, _BitInt(32)), ""); + static_assert (!expr_has_type (e, unsigned _BitInt(32)), ""); + static_assert (!expr_has_type (f, signed _BitInt(32)), ""); + static_assert (!expr_has_type (f, _BitInt(32)), ""); + static_assert (expr_has_type (f, unsigned _BitInt(32)), ""); + static_assert (expr_has_type (e + f, unsigned _BitInt(32)), ""); + static_assert (expr_has_type (e * f, unsigned _BitInt(32)), ""); + static_assert (expr_has_type (e - f, unsigned _BitInt(32)), ""); + static_assert (expr_has_type (e * e, _BitInt(32)), ""); + static_assert (expr_has_type (e / f, unsigned _BitInt(32)), ""); +#if __CHAR_BIT__ * __SIZEOF_INT__ == 32 + static_assert (expr_has_type (e + 1, int), ""); + static_assert (expr_has_type (f + 1, unsigned int), ""); + static_assert (expr_has_type (e + 1U, unsigned int), ""); + static_assert (expr_has_type (f + 1U, unsigned int), ""); + static_assert (expr_has_type (1 - e, int), ""); + static_assert (expr_has_type (1 - f, unsigned int), ""); + static_assert (expr_has_type (1U * e, unsigned int), ""); + static_assert (expr_has_type (1U / f, unsigned int), ""); +#endif + static_assert (expr_has_type (0wb, _BitInt(1)), ""); + static_assert (expr_has_type (-1WB, _BitInt(2)), ""); + static_assert (expr_has_type (-1wb - 1wb, _BitInt(2)), ""); + static_assert (expr_has_type (1wb, _BitInt(2)), ""); + static_assert (expr_has_type (2wb, _BitInt(3)), ""); + static_assert (expr_has_type (0wbu, unsigned _BitInt(1)), ""); + static_assert (expr_has_type (-1UWB, unsigned _BitInt(1)), ""); + static_assert (expr_has_type (1uWB, unsigned _BitInt(1)), ""); + static_assert (expr_has_type (2Uwb, unsigned _BitInt(2)), ""); + static_assert (expr_has_type (h, signed _BitInt(43)), ""); + static_assert (expr_has_type (i, unsigned _BitInt(44)), ""); + static_assert (0wb == 0, ""); + static_assert (-1wb == -1, ""); + static_assert (0xffffffffwb == 4294967295wb, ""); + static_assert (0xffffffffwb == 000000000000000000000000000037777777777wb, ""); + static_assert (0x0000000000000000000000000ffffffffwb == 0b00011111111111111111111111111111111wb, ""); +#if __BITINT_MAXWIDTH__ >= 128 + static_assert (expr_has_type (0xffffffffffffffffffffffffffffffffuwb, unsigned _BitInt(128)), ""); + static_assert (0xffffffffffffffffffffffffffffffffuwb == 340282366920938463463374607431768211455uwb, ""); + static_assert (200000000000000000000000000000000000000wb == 0x96769950b50d88f41314448000000000WB, ""); + static_assert (02263551452055206610750114242110000000000000wb == 200000000000000000000000000000000000000wb, ""); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static_assert (expr_has_type (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567UWB, unsigned _BitInt(575)), ""); + static_assert (expr_has_type (0x00000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwbu, unsigned _BitInt(575)), ""); + static_assert (expr_has_type (0377777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777uwb, unsigned _BitInt(575)), ""); + static_assert (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb == 0x00000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwbu, ""); + static_assert (0377777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777WBU == 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffuWB, ""); + static_assert (100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb == 0X678159610903F7974A7CB3F22F01FA5D9A2CD6039DE4A7A60F713676CE7D7113FF1A499D9BFD0FDCD2999652EB4C7F398DE2A0000000000000000000000000000000000000000000UWB, ""); + static_assert (expr_has_type (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, _BitInt(575)), ""); + static_assert (expr_has_type (0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwb, signed _BitInt(575)), ""); + static_assert (expr_has_type (0177777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777wb, _BitInt(575)), ""); + static_assert (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783WB == -0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwb, ""); + static_assert (0177777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777wb / 2wb * 2wb + 1wb == 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwb, ""); +#endif +#if (0wb != 0) || (0wbU != 0U) || (1wb != 1) || (1uWB != 1u) \ + || (-1wb >= 0) || (-1UWB < 0) || (4294967295uwb != 4294967295U) \ + || 18446744073709551615wbu != 18446744073709551615ULL +#error "" +#endif +} + +void +bar (void) +{ + _BitInt(2) a = (_BitInt(2)) 1; + unsigned _BitInt(1) b = 1uwb; + _BitInt(4) c; + c = 7; + _BitInt(2) d = 1; + _BitInt(5) e = 2wb; + unsigned _BitInt(6) f = 3uwb; +} +#endif + +int +main () +{ +} --- a/gcc/testsuite/g++.dg/cpp29/bitint6.C 2026-10-30 21:48:13.143489071 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint6.C 2026-11-02 10:41:42.326486728 +0100 @@ -0,0 +1,110 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +using size_t = decltype (sizeof 0); +template +struct same_type { static constexpr bool value = false; }; +template +struct same_type { static constexpr bool value = true; }; +template +struct is_bitint { static constexpr bool value = false; }; +template +struct is_bitint <_BitInt (N)> { static constexpr bool value = true; }; +template +struct is_bitint { static constexpr bool value = true; }; + +template +constexpr int foo (_BitInt (N)) { return N; } +template +constexpr int bar (unsigned _BitInt (N)) { return N; } +template +constexpr int baz (_BitInt (N)) { return -int (N); } +template +constexpr int baz (unsigned _BitInt (N)) { return N; } +#if __cplusplus >= 201703L +template +constexpr T qux (_BitInt (N)) { return N; } +#endif +#if __cpp_concepts >= 202002L +template +static constexpr bool is_bitintc_v = requires { baz (T ()); }; +#endif + +static_assert (foo (0wb) == 1, ""); +static_assert (foo (1wb) == 2, ""); +static_assert (foo (78262296091114787wb) == 58, ""); +static_assert (bar (0uwb) == 1, ""); +static_assert (bar (1uwb) == 1, ""); +static_assert (bar (2uwb) == 2, ""); +static_assert (bar (78262296091114787uwb) == 57, ""); +static_assert (baz (0wb) == -1, ""); +static_assert (baz (1wb) == -2, ""); +static_assert (baz (78262296091114787wb) == -58, ""); +static_assert (baz (0uwb) == 1, ""); +static_assert (baz (1uwb) == 1, ""); +static_assert (baz (2uwb) == 2, ""); +static_assert (baz (78262296091114787uwb) == 57, ""); +#if __cplusplus >= 201703L +static_assert (same_type ::value, ""); +static_assert (qux (68796wb) == 18, ""); +#endif +static_assert (foo <42> (0) == 42, ""); +static_assert (bar <42> (0) == 42, ""); +template +struct S { using T = unsigned _BitInt(N); }; +static_assert (same_type ::T, unsigned _BitInt (42)>::value, ""); +char *p; +static_assert (is_bitint ::value, ""); +static_assert (is_bitint ::value, ""); +static_assert (is_bitint ::value, ""); +static_assert (is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (is_bitint <_BitInt (5)>::value, ""); +static_assert (is_bitint <_BitInt (5) unsigned>::value, ""); +static_assert (is_bitint <_BitInt (__BITINT_MAXWIDTH__) signed>::value, ""); +static_assert (is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +#if __cpp_concepts >= 202002L +static_assert (is_bitintc_v ); +static_assert (is_bitintc_v ); +static_assert (is_bitintc_v ); +static_assert (is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (is_bitintc_v <_BitInt (5)>); +static_assert (is_bitintc_v <_BitInt (5) unsigned>); +static_assert (is_bitintc_v <_BitInt (__BITINT_MAXWIDTH__) signed>); +static_assert (is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +static_assert (!is_bitintc_v ); +#endif --- a/gcc/testsuite/g++.dg/cpp29/bitint7.C 2026-10-30 21:48:13.143585697 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint7.C 2026-10-30 21:48:13.143585697 +0100 @@ -0,0 +1,24 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +using size_t = decltype (sizeof 0); + +template +void foo (_BitInt (N)); // { dg-error "'_BitInt' argument '0' is not a positive integer constant expression" } + // { dg-error "'_BitInt' argument '\[0-9]*' is larger than 'BITINT_MAXWIDTH' '\[0-9]*'" "" { target *-*-* } .-1 } +template +void bar (_BitInt (N + 1)); + +void +baz () +{ + foo <0> (0); // { dg-error "no matching function for call to 'foo<0>\\\(int\\\)'" } + foo <1> (0); + foo <__BITINT_MAXWIDTH__> (0); + foo <__BITINT_MAXWIDTH__ + 1> (0); // { dg-error "no matching function for call to 'foo<\\\(\[0-9]* \\\+ 1\\\)>\\\(int\\\)'" } + bar <26> (0); + bar (123456789wb); // { dg-error "no matching function for call to 'bar\\\(_BitInt\\\(28\\\)\\\)'" } + bar <27> (123456789wb); +} --- a/gcc/testsuite/g++.dg/cpp29/bitint8.C 2026-10-30 21:48:13.143672778 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint8.C 2026-11-02 10:41:53.176343205 +0100 @@ -0,0 +1,54 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +using size_t = decltype (sizeof 0); +template +struct same_type { static constexpr bool value = false; }; +template +struct same_type { static constexpr bool value = true; }; +template +struct is_bitint { static constexpr bool value = false; }; +template +struct is_bitint <_BitInt (N)> { static constexpr bool value = true; }; +template +struct is_bitint { static constexpr bool value = true; }; + +enum A { A0 = 0wb, A1 = 1wb, A2 = same_type ::value + 2wb - 1wb, + A3 = 3wb, A4, A5 = (5wb + same_type ::value + + same_type ::value + + is_bitint ::value + + same_type ::value), + A6 = 6wb, A7, A8 = 8wb - 1 + same_type ::value } a; +constexpr int intprec = __SIZEOF_INT__ * __CHAR_BIT__; +constexpr int longprec = __SIZEOF_LONG__ * __CHAR_BIT__; +enum B { B0 = 0, B1 = _BitInt (intprec + 1) (1) << (intprec - 1) } b; +enum C { C0 = -1wb, C1 = _BitInt (intprec + 1) (1) << (intprec - 1) } c; +enum D { D0 = 0, D1 = _BitInt (longprec + 1) (1) << (longprec - 1) } d; +enum E : _BitInt(5) { E0 = 0wb, E1 = 15wb, E2 = _BitInt (46) (2), + E3 = same_type ::value, + E4 = -15wb - 1 } e; +enum F { F0 = E0, F1 = same_type ::value }; +static_assert (same_type ::value, ""); +static_assert (same_type ::value, ""); +static_assert (!same_type ::value, ""); +static_assert (!same_type ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (!is_bitint ::value, ""); +static_assert (A2 == 2, ""); +static_assert (A5 == 5, ""); +static_assert (A8 == 8, ""); +static_assert (same_type ::value, ""); +#if __SIZEOF_INT__ == __SIZEOF_LONG__ +static_assert (same_type ::value, ""); +static_assert (same_type ::value, ""); +#else +static_assert (same_type ::value, ""); +static_assert (same_type ::value, ""); +#endif +static_assert (same_type ::value, ""); +static_assert (E3 == 1, ""); +#if 0 // FIXME - CWG1765 unimplemented +static_assert (F1 == 1, ""); +#endif --- a/gcc/testsuite/g++.dg/cpp29/bitint9.C 2026-10-31 14:16:14.077352607 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint9.C 2026-10-31 14:16:10.419400530 +0100 @@ -0,0 +1,6 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +#include "../../gcc.dg/bitint-3.c" --- a/gcc/testsuite/g++.dg/cpp29/bitint10.C 2026-10-31 14:16:36.430059749 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint10.C 2026-10-31 14:16:50.534874952 +0100 @@ -0,0 +1,5 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++29 } } +// { dg-require-effective-target bitint } + +#include "../../gcc.dg/bitint-4.c" --- a/gcc/testsuite/g++.dg/cpp29/bitint11.C 2026-10-31 14:17:28.437378370 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint11.C 2026-10-31 14:17:52.782059414 +0100 @@ -0,0 +1,6 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +#include "../../gcc.dg/bitint-5.c" --- a/gcc/testsuite/g++.dg/cpp29/bitint12.C 2026-10-31 14:18:07.639864756 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint12.C 2026-10-31 14:18:17.796731683 +0100 @@ -0,0 +1,5 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++29 } } +// { dg-require-effective-target bitint } + +#include "../../gcc.dg/bitint-6.c" --- a/gcc/testsuite/g++.dg/cpp29/bitint13.C 2026-10-31 14:19:38.873669447 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint13.C 2026-11-02 12:27:23.921660405 +0100 @@ -0,0 +1,6 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-c++29-extensions -w" } +// { dg-require-effective-target bitint } + +#include "../../gcc.dg/bitint-12.c" --- a/gcc/testsuite/g++.dg/cpp29/bitint14.C 2026-10-31 14:20:28.312021724 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint14.C 2026-10-31 14:24:03.748199160 +0100 @@ -0,0 +1,11 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target { c++29 && bitint575 } } } +// { dg-options "-pedantic-errors" } + +enum A : _BitInt(15) { A0 = 0, A1 = 1 }; +enum B : unsigned _BitInt(575) { B0 = 0, B1 = 1 }; +enum C { C0 = 459875743wb, C1 = 3298437354uwb }; +enum D { D0 = 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, D1 }; +// { dg-error "no integral type can represent all of the enumerator values for 'D'" "" { target *-*-* } .-1 } */ +// { dg-error "overflow in enumeration values" "" { target *-*-* } .-2 } */ +// { dg-warning "unsigned conversion from '_BitInt\\\(575\\\)' to '\[^'\n\r]*' changes value from" "" { target *-*-* } .-3 } */ --- a/gcc/testsuite/g++.dg/cpp29/bitint15.C 2026-10-31 14:25:01.029448067 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint15.C 2026-10-31 14:26:18.517431011 +0100 @@ -0,0 +1,53 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +template +struct same_type { static constexpr bool value = false; }; +template +struct same_type { static constexpr bool value = true; }; + +#define expr_has_type(e, t) same_type ::value + +struct S1 { char x; char : 0; char y; }; +struct S2 { char x; int : 0; char y; }; +#if __BITINT_MAXWIDTH__ >= 575 +struct S3 { char x; _BitInt(575) : 0; char y; }; +#endif +#if __BITINT_MAXWIDTH__ >= 389 +struct S4 { char x; _BitInt(195) a : 63; _BitInt(282) b : 280; _BitInt(389) c : 23; _BitInt(2) d : 1; char y; }; +#endif +#if __BITINT_MAXWIDTH__ >= 192 +struct S5 { char x; _BitInt(192) a : 191; unsigned _BitInt(192) b : 190; _BitInt(192) c : 189; char y; }; +#endif +struct S6 { _BitInt(2) a : 1; }; +#if __BITINT_MAXWIDTH__ >= 389 +struct S4 s4; +static_assert (expr_has_type (s4.a + 1uwb, _BitInt(195))); +static_assert (expr_has_type (s4.b + 1uwb, _BitInt(282))); +static_assert (expr_has_type (s4.c + 1uwb, _BitInt(389))); +static_assert (expr_has_type (s4.d * 0wb, _BitInt(2))); +#endif +#if __BITINT_MAXWIDTH__ >= 192 +struct S5 s5; +static_assert (expr_has_type (s5.a + 1uwb, _BitInt(192))); +static_assert (expr_has_type (s5.b + 1wb, unsigned _BitInt(192))); +static_assert (expr_has_type (s5.c + 1uwb, _BitInt(192))); +#endif +struct S6 s6; +static_assert (expr_has_type (s6.a + 0wb, _BitInt(2))); +#if defined(__x86_64__) && __LP64__ && __BITINT_MAXWIDTH__ >= 575 +static_assert (sizeof (struct S1) == 2); +static_assert (sizeof (struct S2) == 5); +static_assert (sizeof (struct S3) == 9); +static_assert (sizeof (struct S4) == 48); +static_assert (sizeof (struct S5) == 88); +static_assert (sizeof (struct S6) == 1); +static_assert (alignof (struct S1) == 1); +static_assert (alignof (struct S2) == 1); +static_assert (alignof (struct S3) == 1); +static_assert (alignof (struct S4) == 8); +static_assert (alignof (struct S5) == 8); +static_assert (alignof (struct S6) == 1); +#endif --- a/gcc/testsuite/g++.dg/cpp29/bitint16.C 2026-11-02 12:30:47.623970870 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint16.C 2026-11-02 12:34:56.157689419 +0100 @@ -0,0 +1,22 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +template +struct same_type { static constexpr bool value = false; }; +template +struct same_type { static constexpr bool value = true; }; + +#define expr_has_type(e, t) same_type ::value + +void +foo (_Complex int ci, _Complex long long cl) +{ + _BitInt(__SIZEOF_INT__ * __CHAR_BIT__ - 1) bi = 0wb; + _BitInt(__SIZEOF_LONG_LONG__ * __CHAR_BIT__ - 1) bl = 0wb; + static_assert (expr_has_type (ci + bi, _Complex int), ""); + static_assert (expr_has_type (cl + bl, _Complex long long), ""); + static_assert (expr_has_type (bi + ci, _Complex int), ""); + static_assert (expr_has_type (bl + cl, _Complex long long), ""); +} --- a/gcc/testsuite/g++.dg/cpp29/bitint17.C 2026-11-02 12:31:52.574113319 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint17.C 2026-11-02 12:32:11.340865537 +0100 @@ -0,0 +1,17 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +void +foo (_Complex int ci, _Complex long long cl) +{ + _BitInt(__SIZEOF_INT__ * __CHAR_BIT__ + 1) bi = 0wb; + ci + bi; /* { dg-message "unsupported" } */ + bi + ci; /* { dg-message "unsupported" } */ +#if __BITINT_MAXWIDTH__ >= 575 + _BitInt(575) bw = 0wb; + cl + bw; /* { dg-message "unsupported" "" { target bitint575 } } */ + bw + cl; /* { dg-message "unsupported" "" { target bitint575 } } */ +#endif +} --- a/gcc/testsuite/g++.dg/cpp29/bitint18.C 2026-11-02 12:32:25.894673382 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint18.C 2026-11-02 12:32:40.742477339 +0100 @@ -0,0 +1,12 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +#define IB __SIZEOF_INT__ * __CHAR_BIT__ +typedef _BitInt(IB) V1 __attribute__((vector_size (sizeof (_BitInt(IB))))); /* { dg-error "invalid vector type for attribute 'vector_size'" } */ +typedef _BitInt(IB) V2 __attribute__((vector_size (8 * sizeof (_BitInt(IB))))); /* { dg-error "invalid vector type for attribute 'vector_size'" } */ +#if __BITINT_MAXWIDTH__ >= 575 +typedef _BitInt(575) V3 __attribute__((vector_size (sizeof (_BitInt(575))))); /* { dg-error "invalid vector type for attribute 'vector_size'" "" { target bitint575 } } */ +typedef _BitInt(575) V3 __attribute__((vector_size (16 * sizeof (_BitInt(575))))); /* { dg-error "invalid vector type for attribute 'vector_size'" "" { target bitint575 } } */ +#endif --- a/gcc/testsuite/g++.dg/cpp29/bitint19.C 2026-11-02 12:33:21.111944331 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint19.C 2026-11-02 12:46:21.151655241 +0100 @@ -0,0 +1,18 @@ +// P3666R5 - Bit-precise integers +// { dg-do compile { target c++11 } } +// { dg-require-effective-target bitint } + +_BitInt(63) a; // { dg-error "'_BitInt' only available with" "" { target c++26_down } } +signed _BitInt(15) b; // { dg-error "'_BitInt' only available with" "" { target c++26_down } } +unsigned _BitInt(31) c; // { dg-error "'_BitInt' only available with" "" { target c++26_down } } +int d = 21wb; // { dg-error "'wb' literal suffixes before C\\\+\\\+29 are a GCC extension" "" { target c++26_down } } +long long e = 60594869054uwb; // { dg-error "'wb' literal suffixes before C\\\+\\\+29 are a GCC extension" "" { target c++26_down } } +__extension__ _BitInt(63) f; +__extension__ _BitInt(15) g; +__extension__ unsigned _BitInt(31) h; +int i = __extension__ 21wb; // { dg-error "'wb' literal suffixes before C\\\+\\\+29 are a GCC extension" "" { target c++26_down } } +long long j = __extension__ 60594869054uwb; // { dg-error "'wb' literal suffixes before C\\\+\\\+29 are a GCC extension" "" { target c++26_down } } +#if 0wb == 0 // { dg-error "'wb' literal suffixes before C\\\+\\\+29 are a GCC extension" "" { target c++26_down } } +#endif +#if 0uwb == 0 // { dg-error "'wb' literal suffixes before C\\\+\\\+29 are a GCC extension" "" { target c++26_down } } +#endif --- a/gcc/testsuite/g++.dg/cpp29/bitint20.C 2026-11-02 13:06:43.670538523 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint20.C 2026-11-02 13:07:05.713247584 +0100 @@ -0,0 +1,8 @@ +// P3666R5 - Bit-precise integers +// { dg-do run { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } +/* { dg-require-effective-target fenv_exceptions } */ +/* { dg-add-options ieee } */ + +#include "../../gcc.dg/bitint-28.c" --- a/gcc/testsuite/g++.dg/cpp29/bitint21.C 2026-11-02 13:07:19.566064739 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint21.C 2026-11-02 13:07:26.372974897 +0100 @@ -0,0 +1,8 @@ +// P3666R5 - Bit-precise integers +// { dg-do run { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } +/* { dg-require-effective-target fenv_exceptions } */ +/* { dg-add-options ieee } */ + +#include "../../gcc.dg/bitint-29.c" --- a/gcc/testsuite/g++.dg/cpp29/bitint22.C 2026-11-02 13:07:52.671627778 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint22.C 2026-11-02 13:07:58.189554949 +0100 @@ -0,0 +1,8 @@ +// P3666R5 - Bit-precise integers +// { dg-do run { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } +/* { dg-require-effective-target fenv_exceptions } */ +/* { dg-add-options ieee } */ + +#include "../../gcc.dg/bitint-30.c" --- a/gcc/testsuite/g++.dg/cpp29/bitint23.C 2026-11-02 13:08:05.311460950 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint23.C 2026-11-02 13:08:08.869413989 +0100 @@ -0,0 +1,8 @@ +// P3666R5 - Bit-precise integers +// { dg-do run { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } +/* { dg-require-effective-target fenv_exceptions } */ +/* { dg-add-options ieee } */ + +#include "../../gcc.dg/bitint-31.c" --- a/gcc/testsuite/g++.dg/cpp29/bitint24.C 2026-11-02 13:09:01.998712733 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint24.C 2026-11-02 13:18:46.442001200 +0100 @@ -0,0 +1,6 @@ +// P3666R5 - Bit-precise integers +// { dg-do run { target c++11 } } +// { dg-options "-Wno-c++29-extensions -funsigned-bitfields -Wno-overflow" } +// { dg-require-effective-target bitint } + +#include "../../gcc.dg/bitint-34.c" --- a/gcc/testsuite/g++.dg/cpp29/bitint25.C 2026-11-02 14:06:04.290539796 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint25.C 2026-11-02 14:07:10.689662462 +0100 @@ -0,0 +1,102 @@ +// P3666R5 - Bit-precise integers +// { dg-do run { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +#if __BITINT_MAXWIDTH__ >= 156 +struct S156 { unsigned _BitInt(156) a : 135; _BitInt(156) b : 2; }; +struct S156 s1 = { 18071796389618321960417503813958783219759uwb, 0 }; +struct S156 s2 = { 18071796389618321960417503813958783219759uwb, -1 }; +struct T156 { _BitInt(156) a : 2; unsigned _BitInt(156) b : 135; _BitInt(156) c : 2; }; +struct T156 s3 = { -1, 10623570996611319062233232245276988766900uwb, -1 }; +struct T156 s4 = { 0, 10623570996611319062233232245276988766900uwb, 0 }; +#endif +#if __BITINT_MAXWIDTH__ >= 230 +struct U230 { _BitInt(230) a : 140, b : 140, c : 168; unsigned _BitInt(230) d : 135; _BitInt(230) e : 2; }; +struct U230 s5 = { -1, -1, -167793869854583920719725244652254633450201662238868wb, (unsigned _BitInt(135)) -1, -1 }; +struct U230 s6 = { 0, 0, -167793869854583920719725244652254633450201662238868wb, 0, 0 }; +#endif +#if __BITINT_MAXWIDTH__ >= 412 +struct S412 { unsigned _BitInt(412) a : 391; _BitInt(412) b : 2; }; +struct S412 s7 = { 3345867579074605921998363891622879168820794533140203757607077179689806177940265164723139484043689737118576518770430659uwb, 0 }; +struct S412 s8 = { 3345867579074605921998363891622879168820794533140203757607077179689806177940265164723139484043689737118576518770430659uwb, -1 }; +struct T412 { _BitInt(412) a : 2; unsigned _BitInt(412) b : 391; _BitInt(412) c : 2; }; +struct T412 s9 = { -1, 4349534826165161048611343533362431993802129027379695873644854753645283352804798649538744513979417539155427766538864041uwb, -1 }; +struct T412 s10 = { 0, 4349534826165161048611343533362431993802129027379695873644854753645283352804798649538744513979417539155427766538864041uwb, 0 }; +#endif +#if __BITINT_MAXWIDTH__ >= 486 +struct U486 { _BitInt(486) a : 396, b : 396, c : 424; unsigned _BitInt(486) d : 391; _BitInt(486) e : 2; }; +struct U486 s11 = { -1, -1, -13261086392773587186244717277670203234755842300010780483040284280064790949739084884446379147987979627678541509279207301027482398wb, (unsigned _BitInt(391)) -1, -1 }; +struct U486 s12 = { 0, 0, 13261086392773587186244717277670203234755842300010780483040284280064790949739084884446379147987979627678541509279207301027482398wb, 0, 0 }; +#endif + +#if __BITINT_MAXWIDTH__ >= 156 +__attribute__((noipa)) _BitInt(156) +f1 (struct S156 *p) +{ + return p->a; +} + +__attribute__((noipa)) _BitInt(156) +f2 (struct T156 *q) +{ + return q->b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 230 +__attribute__((noipa)) _BitInt(230) +f3 (struct U230 *q) +{ + return q->c; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 412 +__attribute__((noipa)) _BitInt(412) +f4 (struct S412 *p) +{ + return p->a; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 486 +__attribute__((noipa)) _BitInt(412) +f5 (struct T412 *q) +{ + return q->b; +} + +__attribute__((noipa)) _BitInt(486) +f6 (struct U486 *q) +{ + return q->c; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 156 + if (f1 (&s1) != 18071796389618321960417503813958783219759wb + || f1 (&s2) != 18071796389618321960417503813958783219759wb + || f2 (&s3) != 10623570996611319062233232245276988766900wb + || f2 (&s4) != 10623570996611319062233232245276988766900wb +#if __BITINT_MAXWIDTH__ >= 230 + || f3 (&s5) != -167793869854583920719725244652254633450201662238868wb + || f3 (&s6) != -167793869854583920719725244652254633450201662238868wb +#if __BITINT_MAXWIDTH__ >= 412 + || f4 (&s7) != 3345867579074605921998363891622879168820794533140203757607077179689806177940265164723139484043689737118576518770430659uwb + || f4 (&s8) != 3345867579074605921998363891622879168820794533140203757607077179689806177940265164723139484043689737118576518770430659uwb + || f5 (&s9) != 4349534826165161048611343533362431993802129027379695873644854753645283352804798649538744513979417539155427766538864041uwb + || f5 (&s10) != 4349534826165161048611343533362431993802129027379695873644854753645283352804798649538744513979417539155427766538864041uwb +#if __BITINT_MAXWIDTH__ >= 486 + || f6 (&s11) != -13261086392773587186244717277670203234755842300010780483040284280064790949739084884446379147987979627678541509279207301027482398wb + || f6 (&s12) != 13261086392773587186244717277670203234755842300010780483040284280064790949739084884446379147987979627678541509279207301027482398wb +#endif +#endif +#endif + || 0) + __builtin_abort (); +#endif +} --- a/gcc/testsuite/g++.dg/cpp29/bitint26.C 2026-11-02 14:07:48.289165627 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint26.C 2026-11-02 14:20:51.430817374 +0100 @@ -0,0 +1,174 @@ +// P3666R5 - Bit-precise integers +// { dg-do run { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +#if __BITINT_MAXWIDTH__ >= 2048 +struct S { unsigned _BitInt(2048) a : 2048, b : 2048, c : 17, d : 1984, e : 47; }; + +__attribute__((noipa)) void +foo (struct S *p, unsigned _BitInt(1024) x, unsigned _BitInt(1024) y) +{ + p->d = x + y; +} + +__attribute__((noipa)) void +bar (struct S *p, _BitInt(1024) x, _BitInt(1024) y) +{ + p->d = x + y; +} + +__attribute__((noipa)) void +baz (struct S *p, unsigned _BitInt(1920) x, unsigned _BitInt(1920) y) +{ + p->d = x + y; +} + +__attribute__((noipa)) void +qux (struct S *p, _BitInt(1920) x, _BitInt(1920) y) +{ + p->d = x + y; +} + +__attribute__((noipa)) void +corge (struct S *p, unsigned _BitInt(1900) x, unsigned _BitInt(1900) y) +{ + p->d = x + y; +} + +__attribute__((noipa)) void +garply (struct S *p, _BitInt(1900) x, _BitInt(1900) y) +{ + p->d = x + y; +} + +__attribute__((noipa)) void +freddy (struct S *p, unsigned _BitInt(1856) x, unsigned _BitInt(1856) y) +{ + p->d = x + y; +} + +__attribute__((noipa)) void +waldo (struct S *p, _BitInt(1856) x, _BitInt(1856) y) +{ + p->d = x + y; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 2048 + static struct S a = { + (unsigned _BitInt(2048)) -1, (unsigned _BitInt(2048)) -1, 0, + 463917970028583783130221282302564969130016367896792751313667391101541961539304534496983866855440713410002431069759936351630526612549721249569957606098639059197777177066032356317311377246348044640151413769734055367388430457406812743413172658955449268511488689032363320539418931719008983635641503449973939023326362877468919468283037515857633928783609142892025498615118950347461620276675520332352617645525539262850089419854851129987768363578088495582892780293031963532530279743528517338149433293940566560543044220727331056862486476880117725416278405160480429664896200335164399009026428547582688918275uwb, + 0 }; + a.c = (unsigned _BitInt(17)) -1; a.e = (unsigned _BitInt(47)) -1; + foo (&a, 104931473307998568376284944455816272419276290777426540227909077072607565781305910683656824567560123753706639375583615231475830225655977968417978331508801616912246729932071770026909197561252489929164753507156163716727743848177523298403504040861948797263925263359073704810875557925737265337616304489108966376158uwb, + 59920243355458337710161417863366293718453205838526168844643867766614610356796955200643446741760592218738700475637131838188996966576023003439875232851999584726009865342375796439481941924864368246882381830388251975603959739534065212652254710711469239923127731536814696621712112440700123429434845131596418309393uwb); + if (a.c != (unsigned _BitInt(17)) -1 + || a.d != (unsigned _BitInt(1024)) (104931473307998568376284944455816272419276290777426540227909077072607565781305910683656824567560123753706639375583615231475830225655977968417978331508801616912246729932071770026909197561252489929164753507156163716727743848177523298403504040861948797263925263359073704810875557925737265337616304489108966376158uwb + + 59920243355458337710161417863366293718453205838526168844643867766614610356796955200643446741760592218738700475637131838188996966576023003439875232851999584726009865342375796439481941924864368246882381830388251975603959739534065212652254710711469239923127731536814696621712112440700123429434845131596418309393uwb) + || a.e != (unsigned _BitInt(47)) -1) + __builtin_abort (); + a.c = 0; a.e = 0; + a.d = 463917970028583783130221282302564969130016367896792751313667391101541961539304534496983866855440713410002431069759936351630526612549721249569957606098639059197777177066032356317311377246348044640151413769734055367388430457406812743413172658955449268511488689032363320539418931719008983635641503449973939023326362877468919468283037515857633928783609142892025498615118950347461620276675520332352617645525539262850089419854851129987768363578088495582892780293031963532530279743528517338149433293940566560543044220727331056862486476880117725416278405160480429664896200335164399009026428547582688918275uwb; + bar (&a, 57696900052508731507403549405758598034300143658103207319023779669222605350088754701899236130746881446668609696540074847952256437939432895408791375123523927312623997545422223335393957708478037810305856074599089747771505132758755976367296302409566647338223622914274236998855494169815473992397952258483243021302wb, + -72842517138334828284807942772540307802590837121353434029836391595120471219334627505967145432766876195584374614127318095866715782180696170716375533225237916165551049842450106822314457638403968810895466326295894575989547864175819099455892706907142084137837126096115084189997686278911334555694779991889737914097wb); + if (a.c != 0 + || a.d != (unsigned _BitInt(1984)) (57696900052508731507403549405758598034300143658103207319023779669222605350088754701899236130746881446668609696540074847952256437939432895408791375123523927312623997545422223335393957708478037810305856074599089747771505132758755976367296302409566647338223622914274236998855494169815473992397952258483243021302wb + - 72842517138334828284807942772540307802590837121353434029836391595120471219334627505967145432766876195584374614127318095866715782180696170716375533225237916165551049842450106822314457638403968810895466326295894575989547864175819099455892706907142084137837126096115084189997686278911334555694779991889737914097wb) + || a.e != 0) + __builtin_abort (); + a.c = (unsigned _BitInt(17)) -1; a.e = (unsigned _BitInt(47)) -1; + a.d = 463917970028583783130221282302564969130016367896792751313667391101541961539304534496983866855440713410002431069759936351630526612549721249569957606098639059197777177066032356317311377246348044640151413769734055367388430457406812743413172658955449268511488689032363320539418931719008983635641503449973939023326362877468919468283037515857633928783609142892025498615118950347461620276675520332352617645525539262850089419854851129987768363578088495582892780293031963532530279743528517338149433293940566560543044220727331056862486476880117725416278405160480429664896200335164399009026428547582688918275uwb; + bar (&a, -57696900052508731507403549405758598034300143658103207319023779669222605350088754701899236130746881446668609696540074847952256437939432895408791375123523927312623997545422223335393957708478037810305856074599089747771505132758755976367296302409566647338223622914274236998855494169815473992397952258483243021302wb, + 72842517138334828284807942772540307802590837121353434029836391595120471219334627505967145432766876195584374614127318095866715782180696170716375533225237916165551049842450106822314457638403968810895466326295894575989547864175819099455892706907142084137837126096115084189997686278911334555694779991889737914097wb); + if (a.c != (unsigned _BitInt(17)) -1 + || a.d != (unsigned _BitInt(1984)) (-57696900052508731507403549405758598034300143658103207319023779669222605350088754701899236130746881446668609696540074847952256437939432895408791375123523927312623997545422223335393957708478037810305856074599089747771505132758755976367296302409566647338223622914274236998855494169815473992397952258483243021302wb + + 72842517138334828284807942772540307802590837121353434029836391595120471219334627505967145432766876195584374614127318095866715782180696170716375533225237916165551049842450106822314457638403968810895466326295894575989547864175819099455892706907142084137837126096115084189997686278911334555694779991889737914097wb) + || a.e != (unsigned _BitInt(47)) -1) + __builtin_abort (); + a.c = (unsigned _BitInt(17)) -1; a.e = (unsigned _BitInt(47)) -1; + a.d = 463917970028583783130221282302564969130016367896792751313667391101541961539304534496983866855440713410002431069759936351630526612549721249569957606098639059197777177066032356317311377246348044640151413769734055367388430457406812743413172658955449268511488689032363320539418931719008983635641503449973939023326362877468919468283037515857633928783609142892025498615118950347461620276675520332352617645525539262850089419854851129987768363578088495582892780293031963532530279743528517338149433293940566560543044220727331056862486476880117725416278405160480429664896200335164399009026428547582688918275uwb; + baz (&a, 10046674427769604624104256297198144686571499244626667928387309298929376098027029576279399593953275611749179759608292175423884771453122373428446900092238297028886595955833507301142748242755116804512085361142982476735378897659094772516348752033708523603210976749488948779512595019051543682808058468854071972247830133684340816736701518783450117953852153823310129790997309466493287853621568286299778852505115809372004493209067461371542082762075506285274124778581566591915544298148128752861519967454244034597718098760883258950102015993032472578845214796865351706334956028690073732824uwb, + 30612973315144170166058778463435127763223804285434461900113576569307167284342964585999954156672087142162949891238018140546663093988389394093653346239026903138243323723125156926788354976614671206441524235029939884520999076249737807760807371468017378301855151655697275608111727393644387426955142126548487675753916845926686394733479586127697929204917657250622879488360082650822591661695896650131839942739510727482535722456341390110272939230980001298487239399637003898555616301235680415285050104075063794523896618439667653475267312346144285918918555551560640876816454019806981149346uwb); + if (a.c != (unsigned _BitInt(17)) -1 + || a.d != (unsigned _BitInt(1920)) (10046674427769604624104256297198144686571499244626667928387309298929376098027029576279399593953275611749179759608292175423884771453122373428446900092238297028886595955833507301142748242755116804512085361142982476735378897659094772516348752033708523603210976749488948779512595019051543682808058468854071972247830133684340816736701518783450117953852153823310129790997309466493287853621568286299778852505115809372004493209067461371542082762075506285274124778581566591915544298148128752861519967454244034597718098760883258950102015993032472578845214796865351706334956028690073732824uwb + + 30612973315144170166058778463435127763223804285434461900113576569307167284342964585999954156672087142162949891238018140546663093988389394093653346239026903138243323723125156926788354976614671206441524235029939884520999076249737807760807371468017378301855151655697275608111727393644387426955142126548487675753916845926686394733479586127697929204917657250622879488360082650822591661695896650131839942739510727482535722456341390110272939230980001298487239399637003898555616301235680415285050104075063794523896618439667653475267312346144285918918555551560640876816454019806981149346uwb) + || a.e != (unsigned _BitInt(47)) -1) + __builtin_abort (); + a.c = 0; a.e = 0; + a.d = 463917970028583783130221282302564969130016367896792751313667391101541961539304534496983866855440713410002431069759936351630526612549721249569957606098639059197777177066032356317311377246348044640151413769734055367388430457406812743413172658955449268511488689032363320539418931719008983635641503449973939023326362877468919468283037515857633928783609142892025498615118950347461620276675520332352617645525539262850089419854851129987768363578088495582892780293031963532530279743528517338149433293940566560543044220727331056862486476880117725416278405160480429664896200335164399009026428547582688918275uwb; + qux (&a, 13016013079173103291099614189980806323842381205278317530930273134000041840366629398775140035115843810473709567772778302693082141789947769432915075175055773162235275161483274294215337459035077170772792870300959580270341613989326562524225424508425190735941052267862958598262374659588227320019762607908610630268016655402141784434304726674259917365365145444188910006023308330624708207712990521956652004155313903306577312390098183139445953080974727140041686581923442658014291404592915933601121276930660194063673671653456001711834226809501680465040298012239797363611423758621282776913wb, + -28446813692377976500941113458061042520266991028095510595278491516213231833343127954947958697833886839482306777092401391414122947073667300047514166155274861575977000665767593771951017640475352507402509527609607984675986413277164234921816991523476344394719439798762757430434241059844235758595109405173122010749636425151730743690113153472777458440898097338588818905573968955113497483813484624809156428527476374283821364764837699711517717561791530220504756111060769224676146577608338385717008304034083639716040512354106392262091939683382939797913585450175899702396573011461697333034wb); + if (a.c != 0 + || a.d != (unsigned _BitInt(1984)) (13016013079173103291099614189980806323842381205278317530930273134000041840366629398775140035115843810473709567772778302693082141789947769432915075175055773162235275161483274294215337459035077170772792870300959580270341613989326562524225424508425190735941052267862958598262374659588227320019762607908610630268016655402141784434304726674259917365365145444188910006023308330624708207712990521956652004155313903306577312390098183139445953080974727140041686581923442658014291404592915933601121276930660194063673671653456001711834226809501680465040298012239797363611423758621282776913wb + - 28446813692377976500941113458061042520266991028095510595278491516213231833343127954947958697833886839482306777092401391414122947073667300047514166155274861575977000665767593771951017640475352507402509527609607984675986413277164234921816991523476344394719439798762757430434241059844235758595109405173122010749636425151730743690113153472777458440898097338588818905573968955113497483813484624809156428527476374283821364764837699711517717561791530220504756111060769224676146577608338385717008304034083639716040512354106392262091939683382939797913585450175899702396573011461697333034wb) + || a.e != 0) + __builtin_abort (); + a.c = (unsigned _BitInt(17)) -1; a.e = (unsigned _BitInt(47)) -1; + a.d = 463917970028583783130221282302564969130016367896792751313667391101541961539304534496983866855440713410002431069759936351630526612549721249569957606098639059197777177066032356317311377246348044640151413769734055367388430457406812743413172658955449268511488689032363320539418931719008983635641503449973939023326362877468919468283037515857633928783609142892025498615118950347461620276675520332352617645525539262850089419854851129987768363578088495582892780293031963532530279743528517338149433293940566560543044220727331056862486476880117725416278405160480429664896200335164399009026428547582688918275uwb; + qux (&a, -13016013079173103291099614189980806323842381205278317530930273134000041840366629398775140035115843810473709567772778302693082141789947769432915075175055773162235275161483274294215337459035077170772792870300959580270341613989326562524225424508425190735941052267862958598262374659588227320019762607908610630268016655402141784434304726674259917365365145444188910006023308330624708207712990521956652004155313903306577312390098183139445953080974727140041686581923442658014291404592915933601121276930660194063673671653456001711834226809501680465040298012239797363611423758621282776913wb, + 28446813692377976500941113458061042520266991028095510595278491516213231833343127954947958697833886839482306777092401391414122947073667300047514166155274861575977000665767593771951017640475352507402509527609607984675986413277164234921816991523476344394719439798762757430434241059844235758595109405173122010749636425151730743690113153472777458440898097338588818905573968955113497483813484624809156428527476374283821364764837699711517717561791530220504756111060769224676146577608338385717008304034083639716040512354106392262091939683382939797913585450175899702396573011461697333034wb); + if (a.c != (unsigned _BitInt(17)) -1 + || a.d != (unsigned _BitInt(1984)) (-13016013079173103291099614189980806323842381205278317530930273134000041840366629398775140035115843810473709567772778302693082141789947769432915075175055773162235275161483274294215337459035077170772792870300959580270341613989326562524225424508425190735941052267862958598262374659588227320019762607908610630268016655402141784434304726674259917365365145444188910006023308330624708207712990521956652004155313903306577312390098183139445953080974727140041686581923442658014291404592915933601121276930660194063673671653456001711834226809501680465040298012239797363611423758621282776913wb + + 28446813692377976500941113458061042520266991028095510595278491516213231833343127954947958697833886839482306777092401391414122947073667300047514166155274861575977000665767593771951017640475352507402509527609607984675986413277164234921816991523476344394719439798762757430434241059844235758595109405173122010749636425151730743690113153472777458440898097338588818905573968955113497483813484624809156428527476374283821364764837699711517717561791530220504756111060769224676146577608338385717008304034083639716040512354106392262091939683382939797913585450175899702396573011461697333034wb) + || a.e != (unsigned _BitInt(47)) -1) + __builtin_abort (); + a.c = (unsigned _BitInt(17)) -1; a.e = (unsigned _BitInt(47)) -1; + a.d = 463917970028583783130221282302564969130016367896792751313667391101541961539304534496983866855440713410002431069759936351630526612549721249569957606098639059197777177066032356317311377246348044640151413769734055367388430457406812743413172658955449268511488689032363320539418931719008983635641503449973939023326362877468919468283037515857633928783609142892025498615118950347461620276675520332352617645525539262850089419854851129987768363578088495582892780293031963532530279743528517338149433293940566560543044220727331056862486476880117725416278405160480429664896200335164399009026428547582688918275uwb; + corge (&a, 64171754625068989919140837000994640111727112880534508544592426680368730902810558177004927067680584241787685314155807083650755609249723856651964519183899537071234738837290542998681042547778311707239561819724556440611184192044964070498288365795284868545819938858772217225078359446215623326392822749370924397592547178151227397770818626413099911326742674650698762654686406157275035696691347162817031065585247142657560604671730554635740625725423122837711895800895711658181231623745755808749163225238686251279789200140461667130974133295022126714627199940806900473151584805415195uwb, + 10507418314822331271773044775475398971761862686484059883353388622395900044257992245406697831431608445492518374055670273513238951235394317339987011165612885709605626614512380143227176716397144020233730021138060515517588833982427087228530305874044854732163307726421040484981309646463788817170356084893284995027973314236302612849097075836350102359164874937708745757469764621885202447442513857862352391464614086255770773793956362777147243363233935961477956934790795000772957425970578395645388729306937175617548119494347932433902865451670299375626936811709188316328877711066266uwb); + if (a.c != (unsigned _BitInt(17)) -1 + || a.d != (unsigned _BitInt(1900)) (64171754625068989919140837000994640111727112880534508544592426680368730902810558177004927067680584241787685314155807083650755609249723856651964519183899537071234738837290542998681042547778311707239561819724556440611184192044964070498288365795284868545819938858772217225078359446215623326392822749370924397592547178151227397770818626413099911326742674650698762654686406157275035696691347162817031065585247142657560604671730554635740625725423122837711895800895711658181231623745755808749163225238686251279789200140461667130974133295022126714627199940806900473151584805415195uwb + + 10507418314822331271773044775475398971761862686484059883353388622395900044257992245406697831431608445492518374055670273513238951235394317339987011165612885709605626614512380143227176716397144020233730021138060515517588833982427087228530305874044854732163307726421040484981309646463788817170356084893284995027973314236302612849097075836350102359164874937708745757469764621885202447442513857862352391464614086255770773793956362777147243363233935961477956934790795000772957425970578395645388729306937175617548119494347932433902865451670299375626936811709188316328877711066266uwb) + || a.e != (unsigned _BitInt(47)) -1) + __builtin_abort (); + a.c = 0; a.e = 0; + a.d = 463917970028583783130221282302564969130016367896792751313667391101541961539304534496983866855440713410002431069759936351630526612549721249569957606098639059197777177066032356317311377246348044640151413769734055367388430457406812743413172658955449268511488689032363320539418931719008983635641503449973939023326362877468919468283037515857633928783609142892025498615118950347461620276675520332352617645525539262850089419854851129987768363578088495582892780293031963532530279743528517338149433293940566560543044220727331056862486476880117725416278405160480429664896200335164399009026428547582688918275uwb; + garply (&a, 5868498364266506524577605439874476245426686973426700959109780040518579902459120222835694740563157202759355683256866704897404738166990697509006899291520655587106188792963812978958796524525114633868734394698171505881029257971723149816101834255875674028498733002531852425394712442344661593840806267795078353686464213122490607069539130187483435521707186417019607510065332996787510980236995794693748424754247983911372699143281367405983607540070016093272958998509389591623580441329207441967951990849359776649279644251163115935521494220792988120247084691082546041345346792010242wb, + -11347197387388289958753680375659873990863802565165926783885510745013060725984194141674849668356803935504502347397858539486502925095461636911844100666788607295568532884580882894109301976999229938210427880195738078809053637249087573583682429867587279531387832617988923148433372488547498087660777174110005800619288934623468273334771375199931835359341800380427942391213375221877238129575165007900737487381149085076124736500637930425093008055570334609463897282935446073021835731133748226290709813024590427968994174853094349555317945926316079817123209552512780636562105208387802wb); + if (a.c != 0 + || a.d != (unsigned _BitInt(1984)) (5868498364266506524577605439874476245426686973426700959109780040518579902459120222835694740563157202759355683256866704897404738166990697509006899291520655587106188792963812978958796524525114633868734394698171505881029257971723149816101834255875674028498733002531852425394712442344661593840806267795078353686464213122490607069539130187483435521707186417019607510065332996787510980236995794693748424754247983911372699143281367405983607540070016093272958998509389591623580441329207441967951990849359776649279644251163115935521494220792988120247084691082546041345346792010242wb + - 11347197387388289958753680375659873990863802565165926783885510745013060725984194141674849668356803935504502347397858539486502925095461636911844100666788607295568532884580882894109301976999229938210427880195738078809053637249087573583682429867587279531387832617988923148433372488547498087660777174110005800619288934623468273334771375199931835359341800380427942391213375221877238129575165007900737487381149085076124736500637930425093008055570334609463897282935446073021835731133748226290709813024590427968994174853094349555317945926316079817123209552512780636562105208387802wb) + || a.e != 0) + __builtin_abort (); + a.c = (unsigned _BitInt(17)) -1; a.e = (unsigned _BitInt(47)) -1; + a.d = 463917970028583783130221282302564969130016367896792751313667391101541961539304534496983866855440713410002431069759936351630526612549721249569957606098639059197777177066032356317311377246348044640151413769734055367388430457406812743413172658955449268511488689032363320539418931719008983635641503449973939023326362877468919468283037515857633928783609142892025498615118950347461620276675520332352617645525539262850089419854851129987768363578088495582892780293031963532530279743528517338149433293940566560543044220727331056862486476880117725416278405160480429664896200335164399009026428547582688918275uwb; + garply (&a, -5868498364266506524577605439874476245426686973426700959109780040518579902459120222835694740563157202759355683256866704897404738166990697509006899291520655587106188792963812978958796524525114633868734394698171505881029257971723149816101834255875674028498733002531852425394712442344661593840806267795078353686464213122490607069539130187483435521707186417019607510065332996787510980236995794693748424754247983911372699143281367405983607540070016093272958998509389591623580441329207441967951990849359776649279644251163115935521494220792988120247084691082546041345346792010242wb, + 11347197387388289958753680375659873990863802565165926783885510745013060725984194141674849668356803935504502347397858539486502925095461636911844100666788607295568532884580882894109301976999229938210427880195738078809053637249087573583682429867587279531387832617988923148433372488547498087660777174110005800619288934623468273334771375199931835359341800380427942391213375221877238129575165007900737487381149085076124736500637930425093008055570334609463897282935446073021835731133748226290709813024590427968994174853094349555317945926316079817123209552512780636562105208387802wb); + if (a.c != (unsigned _BitInt(17)) -1 + || a.d != (unsigned _BitInt(1984)) (-5868498364266506524577605439874476245426686973426700959109780040518579902459120222835694740563157202759355683256866704897404738166990697509006899291520655587106188792963812978958796524525114633868734394698171505881029257971723149816101834255875674028498733002531852425394712442344661593840806267795078353686464213122490607069539130187483435521707186417019607510065332996787510980236995794693748424754247983911372699143281367405983607540070016093272958998509389591623580441329207441967951990849359776649279644251163115935521494220792988120247084691082546041345346792010242wb + + 11347197387388289958753680375659873990863802565165926783885510745013060725984194141674849668356803935504502347397858539486502925095461636911844100666788607295568532884580882894109301976999229938210427880195738078809053637249087573583682429867587279531387832617988923148433372488547498087660777174110005800619288934623468273334771375199931835359341800380427942391213375221877238129575165007900737487381149085076124736500637930425093008055570334609463897282935446073021835731133748226290709813024590427968994174853094349555317945926316079817123209552512780636562105208387802wb) + || a.e != (unsigned _BitInt(47)) -1) + __builtin_abort (); + a.c = (unsigned _BitInt(17)) -1; a.e = (unsigned _BitInt(47)) -1; + a.d = 463917970028583783130221282302564969130016367896792751313667391101541961539304534496983866855440713410002431069759936351630526612549721249569957606098639059197777177066032356317311377246348044640151413769734055367388430457406812743413172658955449268511488689032363320539418931719008983635641503449973939023326362877468919468283037515857633928783609142892025498615118950347461620276675520332352617645525539262850089419854851129987768363578088495582892780293031963532530279743528517338149433293940566560543044220727331056862486476880117725416278405160480429664896200335164399009026428547582688918275uwb; + freddy (&a, 469252210556625900395321429768118373804271568886989705934619437372829749132450328525095591418777876663202724364753274041797120201435942727547992144282707964490547818365755687730365454828375134854279482853064804665151021915981446605629215712706942096964289300397645214217794960755102650152979365923262599694610536124094997394321315947501858977257060703103733108840085012396782596975471783978125423726167181925777731261440167038194119207611413091278559852866397229440000783332669637577092646062124696818736270717467013532501981408774198349957822434112647379005uwb, + 94070362846521859801705045906377514499678063439381376804210675777018147620560698746550277910632595473262065531986582027530889487288929548537551849350646108895807918918852446632833846575499156686904909401606895792588697611268444788607535104014712049735819470354574164068246431532229132503353457795214808974265484177085433521985873683760061889599206572475727862420333264989214721uwb); + if (a.c != (unsigned _BitInt(17)) -1 + || a.d != (unsigned _BitInt(1856)) (469252210556625900395321429768118373804271568886989705934619437372829749132450328525095591418777876663202724364753274041797120201435942727547992144282707964490547818365755687730365454828375134854279482853064804665151021915981446605629215712706942096964289300397645214217794960755102650152979365923262599694610536124094997394321315947501858977257060703103733108840085012396782596975471783978125423726167181925777731261440167038194119207611413091278559852866397229440000783332669637577092646062124696818736270717467013532501981408774198349957822434112647379005uwb + + 94070362846521859801705045906377514499678063439381376804210675777018147620560698746550277910632595473262065531986582027530889487288929548537551849350646108895807918918852446632833846575499156686904909401606895792588697611268444788607535104014712049735819470354574164068246431532229132503353457795214808974265484177085433521985873683760061889599206572475727862420333264989214721uwb) + || a.e != (unsigned _BitInt(47)) -1) + __builtin_abort (); + a.c = 0; a.e = 0; + a.d = 463917970028583783130221282302564969130016367896792751313667391101541961539304534496983866855440713410002431069759936351630526612549721249569957606098639059197777177066032356317311377246348044640151413769734055367388430457406812743413172658955449268511488689032363320539418931719008983635641503449973939023326362877468919468283037515857633928783609142892025498615118950347461620276675520332352617645525539262850089419854851129987768363578088495582892780293031963532530279743528517338149433293940566560543044220727331056862486476880117725416278405160480429664896200335164399009026428547582688918275uwb; + waldo (&a, 1077348803036394846628052386931031477092268876025321812336873307109206087913752615224874421161444982772998789879219858386748806555972198085260006113906211122468615028890545260489793232067037450746579377138953792376873515309768581358563731155642172915978701005830989320122620476563103717896150506580888344726125553209010077521592754225575655834325745455132336873236702283266289571810538207635029653566169955010183651423213982024692540900019767542204779117227674016120820660909981982885062591878726323250427606511922288639386683242905759109753373254316490315520wb, + -1985135610193680083664291948423326826338570203155603158942205167041487273165308445801199835862136626921357451386015509681859914819637185970790210070511326605854081763286684508027882510126294034064385106397322907046379158342618996640895074355907730050734884021065120984859890403437402777612953035357875244537844302334232817294878831239344832373356172440988052876809100011735694217824097948414358681171509506376373643145643902181072431032225879081947415698025494088413669737484685311564937312541325716542256136502054579138572508697290597615704140203423671499131wb); + if (a.c != 0 + || a.d != (unsigned _BitInt(1984)) (1077348803036394846628052386931031477092268876025321812336873307109206087913752615224874421161444982772998789879219858386748806555972198085260006113906211122468615028890545260489793232067037450746579377138953792376873515309768581358563731155642172915978701005830989320122620476563103717896150506580888344726125553209010077521592754225575655834325745455132336873236702283266289571810538207635029653566169955010183651423213982024692540900019767542204779117227674016120820660909981982885062591878726323250427606511922288639386683242905759109753373254316490315520wb + - 1985135610193680083664291948423326826338570203155603158942205167041487273165308445801199835862136626921357451386015509681859914819637185970790210070511326605854081763286684508027882510126294034064385106397322907046379158342618996640895074355907730050734884021065120984859890403437402777612953035357875244537844302334232817294878831239344832373356172440988052876809100011735694217824097948414358681171509506376373643145643902181072431032225879081947415698025494088413669737484685311564937312541325716542256136502054579138572508697290597615704140203423671499131wb) + || a.e != 0) + __builtin_abort (); + a.c = (unsigned _BitInt(17)) -1; a.e = (unsigned _BitInt(47)) -1; + a.d = 463917970028583783130221282302564969130016367896792751313667391101541961539304534496983866855440713410002431069759936351630526612549721249569957606098639059197777177066032356317311377246348044640151413769734055367388430457406812743413172658955449268511488689032363320539418931719008983635641503449973939023326362877468919468283037515857633928783609142892025498615118950347461620276675520332352617645525539262850089419854851129987768363578088495582892780293031963532530279743528517338149433293940566560543044220727331056862486476880117725416278405160480429664896200335164399009026428547582688918275uwb; + waldo (&a, -1077348803036394846628052386931031477092268876025321812336873307109206087913752615224874421161444982772998789879219858386748806555972198085260006113906211122468615028890545260489793232067037450746579377138953792376873515309768581358563731155642172915978701005830989320122620476563103717896150506580888344726125553209010077521592754225575655834325745455132336873236702283266289571810538207635029653566169955010183651423213982024692540900019767542204779117227674016120820660909981982885062591878726323250427606511922288639386683242905759109753373254316490315520wb, + 1985135610193680083664291948423326826338570203155603158942205167041487273165308445801199835862136626921357451386015509681859914819637185970790210070511326605854081763286684508027882510126294034064385106397322907046379158342618996640895074355907730050734884021065120984859890403437402777612953035357875244537844302334232817294878831239344832373356172440988052876809100011735694217824097948414358681171509506376373643145643902181072431032225879081947415698025494088413669737484685311564937312541325716542256136502054579138572508697290597615704140203423671499131wb); + if (a.c != (unsigned _BitInt(17)) -1 + || a.d != (unsigned _BitInt(1984)) (-1077348803036394846628052386931031477092268876025321812336873307109206087913752615224874421161444982772998789879219858386748806555972198085260006113906211122468615028890545260489793232067037450746579377138953792376873515309768581358563731155642172915978701005830989320122620476563103717896150506580888344726125553209010077521592754225575655834325745455132336873236702283266289571810538207635029653566169955010183651423213982024692540900019767542204779117227674016120820660909981982885062591878726323250427606511922288639386683242905759109753373254316490315520wb + + 1985135610193680083664291948423326826338570203155603158942205167041487273165308445801199835862136626921357451386015509681859914819637185970790210070511326605854081763286684508027882510126294034064385106397322907046379158342618996640895074355907730050734884021065120984859890403437402777612953035357875244537844302334232817294878831239344832373356172440988052876809100011735694217824097948414358681171509506376373643145643902181072431032225879081947415698025494088413669737484685311564937312541325716542256136502054579138572508697290597615704140203423671499131wb) + || a.e != (unsigned _BitInt(47)) -1) + __builtin_abort (); +#endif +} --- a/gcc/testsuite/g++.dg/cpp29/bitint27.C 2026-11-02 14:12:33.197400920 +0100 +++ b/gcc/testsuite/g++.dg/cpp29/bitint27.C 2026-11-02 14:58:53.024677595 +0100 @@ -0,0 +1,179 @@ +// P3666R5 - Bit-precise integers +// { dg-do run { target c++11 } } +// { dg-options "-Wno-c++29-extensions" } +// { dg-require-effective-target bitint } + +template +struct same_type { static constexpr bool value = false; }; +template +struct same_type { static constexpr bool value = true; }; + +#define expr_has_type(e, t) same_type ::value + +void +foo () +{ + _BitInt(1) a = (_BitInt(1)) -1; + static_assert (expr_has_type (a, signed _BitInt(1)), ""); + static_assert (expr_has_type (0wb, _BitInt(1)), ""); + static_assert (expr_has_type (~0wb, _BitInt(1)), ""); + static_assert (expr_has_type (1wb, _BitInt(2)), ""); + static_assert (expr_has_type (-1wb, _BitInt(2)), ""); + static_assert (expr_has_type (2wb, _BitInt(3)), ""); + static_assert (expr_has_type (0wb + 0wb, signed _BitInt(1)), ""); + static_assert (expr_has_type (0wb + 0uwb, unsigned _BitInt(1)), ""); + static_assert (expr_has_type (0wb + 1wb, _BitInt(2)), ""); + static_assert (expr_has_type (0uwb + 0wb, unsigned _BitInt(1)), ""); + static_assert (expr_has_type (1wb + 0wb, _BitInt(2)), ""); + static_assert (0wb == 0, ""); + static_assert (~0wb == -1, ""); + static_assert (~~0wb == 0, ""); + static_assert (-1wb == -1, ""); +} + +_BitInt(1) b = 0wb; +_BitInt(1) c = ~0wb; +_BitInt(1) d = 0wb; + +[[gnu::noipa]] void +bar (_BitInt(1) a[21], signed _BitInt(1) b[21], const _BitInt(1) c[21]) +{ + a[0] = b[0] + c[0]; + a[1] = b[1] + c[1]; + a[2] = b[2] + c[2]; + a[3] = b[3] - c[3]; + a[4] = b[4] - c[4]; + a[5] = b[5] - c[5]; + a[6] = b[6] * c[6]; + a[7] = b[7] * c[7]; + a[8] = b[8] * c[8]; + a[9] = b[9] / c[9]; + a[10] = b[10] % c[10]; + a[11] = b[10] % c[11]; + a[12] = b[12] & c[12]; + a[13] = b[13] & c[13]; + a[14] = b[14] & c[14]; + a[15] = b[15] | c[15]; + a[16] = b[16] | c[16]; + a[17] = b[17] | c[17]; + a[18] = b[18] ^ c[18]; + a[19] = b[19] ^ c[19]; + a[20] = b[20] ^ c[20]; +} + +#if __BITINT_MAXWIDTH__ >= 256 +[[gnu::noipa]] _BitInt(256) +baz (_BitInt(256) x, _BitInt(1) y) +{ + return x * y; +} +#endif + +[[gnu::noipa]] void +qux (_BitInt(1) p[3], float q, double r, long double s) +{ + p[0] = q; + p[1] = r; + p[2] = s; +} + +[[gnu::noipa]] void +corge (_BitInt(1) p[2], float q[2], double r[2], long double s[2]) +{ + q[0] = p[0]; + q[1] = p[1]; + r[0] = p[0]; + r[1] = p[1]; + s[0] = p[0]; + s[1] = p[1]; +} + +int +main () +{ + if (b != 0 || c != -1) + __builtin_abort (); + if (0) + { + --b; + ++c; + } + else + { + b += _BitInt(1)(-1wb); + c -= _BitInt(1)(-1wb); + } + if (b != -1 || c != 0) + __builtin_abort (); + b = ~b; + c = ~c; + if (b != 0 || c != -1) + __builtin_abort (); + c *= d; + if (d != 0) + __builtin_abort (); + _BitInt(1) e[21]; + _BitInt(1) f[21] = { + 0, -1, 0, + 0, -1, -1, + 0, -1, 0, + 0, + 0, -1, + 0, -1, -1, + 0, 0, -1, + 0, -1, -1 + }; + signed _BitInt(1) g[21] = { + 0, 0, -1, + 0, 0, -1, + 0, 0, -1, + -1, + -1, -1, + 0, 0, -1, + 0, -1, -1, + 0, 0, -1 + }; + bar (e, f, g); + _BitInt(1) h[21] = { + 0, -1, -1, + 0, -1, 0, + 0, 0, 0, + 0, + 0, 0, + 0, 0, -1, + 0, -1, -1, + 0, -1, 0 + }; + for (int i = 0; i < 21; ++i) + if (e[i] != h[i]) + __builtin_abort (); +#if __BITINT_MAXWIDTH__ >= 256 + if (baz (24807048826655379640613156875228202584070386120119745959437529938064756141700wb, ~0wb) + != -24807048826655379640613156875228202584070386120119745959437529938064756141700wb) + __builtin_abort (); + if (baz (24807048826655379640613156875228202584070386120119745959437529938064756141700wb, 0wb) != 0wb) + __builtin_abort (); + if (baz (-24807048826655379640613156875228202584070386120119745959437529938064756141700wb, 0wb) != 0wb) + __builtin_abort (); + if (baz (0wb, ~0wb) != 0wb) + __builtin_abort (); +#endif + qux (e, 0.5f, 0.25, 0.75L); + qux (e + 3, -0.5f, -0.25, -0.75L); + qux (e + 6, 0.f, 0., 0.L); + qux (e + 9, -1.f, -1., -1.L); + qux (e + 12, -1.5f, -1.25, -1.75L); + for (int i = 0; i < 15; ++i) + if (e[i] != (i < 9 ? 0 : -1)) + __builtin_abort (); + e[0] = 0wb; + e[1] = ~0wb; + float j[2]; + double k[2]; + long double l[2]; + corge (e, j, k, l); + if (j[0] != 0.0f || j[1] != -1.0f + || k[0] != 0.0 || k[1] != -1.0 + || l[0] != 0.0L || l[1] != -1.0L) + __builtin_abort (); +} --- a/gcc/testsuite/lib/target-supports.exp 2026-10-30 21:46:29.410733259 +0100 +++ b/gcc/testsuite/lib/target-supports.exp 2026-10-30 21:48:13.144228230 +0100 @@ -4649,37 +4649,57 @@ proc check_effective_target_fixed_point # Return 1 if the target supports _BitInt(N), 0 otherwise. proc check_effective_target_bitint { } { + if [check_effective_target_c++] { + set opts "-std=c++29" + } else { + set opts =-std=c23" + } return [check_no_compiler_messages bitint object { _BitInt (2) a = 1wb; unsigned _BitInt (__BITINT_MAXWIDTH__) b = 0uwb; - } "-std=c23"] + } $opts] } # Return 1 if the target supports _BitInt(128), 0 otherwise. proc check_effective_target_bitint128 { } { + if [check_effective_target_c++] { + set opts "-std=c++29" + } else { + set opts =-std=c23" + } return [check_no_compiler_messages bitint128 object { _BitInt (2) a = 1wb; unsigned _BitInt (128) b = 0uwb; - } "-std=c23"] + } $opts] } # Return 1 if the target supports _BitInt(575), 0 otherwise. proc check_effective_target_bitint575 { } { + if [check_effective_target_c++] { + set opts "-std=c++29" + } else { + set opts =-std=c23" + } return [check_no_compiler_messages bitint575 object { _BitInt (2) a = 1wb; unsigned _BitInt (575) b = 0uwb; - } "-std=c23"] + } $opts] } # Return 1 if the target supports _BitInt(65535), 0 otherwise. proc check_effective_target_bitint65535 { } { + if [check_effective_target_c++] { + set opts "-std=c++29" + } else { + set opts =-std=c23" + } return [check_no_compiler_messages bitint65535 object { _BitInt (2) a = 1wb; unsigned _BitInt (65535) b = 0uwb; - } "-std=c23"] + } $opts] } # Return 1 if the target supports compiling decimal floating point, --- a/libcpp/expr.cc 2026-10-30 17:05:21.741551843 +0100 +++ b/libcpp/expr.cc 2026-10-30 21:48:13.145071392 +0100 @@ -386,8 +386,6 @@ interpret_int_suffix (cpp_reader *pfile, if (wb) { - if (CPP_OPTION (pfile, cplusplus)) - return 0; if (l > 0 || i > 0 || z > 0) return 0; } @@ -897,26 +895,36 @@ cpp_classify_number (cpp_reader *pfile, virtual_location, 0, message); } - if ((result & CPP_N_BITINT) != 0 - && CPP_OPTION (pfile, cpp_warn_c11_c23_compat) != 0) + if ((result & CPP_N_BITINT) != 0) { - if (CPP_OPTION (pfile, cpp_warn_c11_c23_compat) > 0) - { - const char *message = N_("ISO C does not support literal " - "% suffixes before C23"); - if (CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, true_false)) - cpp_pedwarning_with_line (pfile, CPP_W_C11_C23_COMPAT, - virtual_location, 0, message); - else - cpp_warning_with_line (pfile, CPP_W_C11_C23_COMPAT, - virtual_location, 0, message); - } - else if (!CPP_OPTION (pfile, true_false)) + if (CPP_OPTION (pfile, cplusplus)) { - const char *message = N_("ISO C does not support literal " - "% suffixes before C23"); - cpp_pedwarning_with_line (pfile, CPP_W_PEDANTIC, - virtual_location, 0, message); + if (CPP_OPTION (pfile, lang) < CLK_GNUCXX29) + cpp_pedwarning_with_line (pfile, CPP_W_CXX29_EXTENSIONS, + virtual_location, 0, + "% literal suffixes before " + "C++29 are a GCC extension"); + } + else if (CPP_OPTION (pfile, cpp_warn_c11_c23_compat) != 0) + { + if (CPP_OPTION (pfile, cpp_warn_c11_c23_compat) > 0) + { + const char *message = N_("ISO C does not support literal " + "% suffixes before C23"); + if (CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, true_false)) + cpp_pedwarning_with_line (pfile, CPP_W_C11_C23_COMPAT, + virtual_location, 0, message); + else + cpp_warning_with_line (pfile, CPP_W_C11_C23_COMPAT, + virtual_location, 0, message); + } + else if (!CPP_OPTION (pfile, true_false)) + { + const char *message = N_("ISO C does not support literal " + "% suffixes before C23"); + cpp_pedwarning_with_line (pfile, CPP_W_PEDANTIC, + virtual_location, 0, message); + } } } Jakub From tkaminsk@redhat.com Mon Nov 2 15:29:52 2026 From: tkaminsk@redhat.com (Tomasz Kaminski) Date: Mon, 2 Nov 2026 16:29:52 +0100 Subject: [PATCH 3/3] libstdc++: Fix another buffer overflow in basic_filebuf::overflow [PR118099] In-Reply-To: <20261023174023.845748-3-jwakely@redhat.com> References: <20261023174023.845748-1-jwakely@redhat.com> <20261023174023.845748-3-jwakely@redhat.com> Message-ID: On Fri, Oct 23, 2026 at 7:43?PM Jonathan Wakely wrote: > The initial fix for PR 118099 handled the case where writing the pending > output sequence to the external file failed and _M_convert_to_external > returned false. But _M_convert_to_external can also fail by throwing an > exception in which case the same bug exists: the put area's next pointer > (i.e. pptr) has already been advanced and is not rewound when > basic_filebuf::overflow exits via an exception. As in the PR 118099 > testcase, the caller is left with pptr set past epptr, and successive > calls to overflow will write further past the end of the managed buffer > with each failure. > This should go to _Guard 1/3 commit, as it will be also fixed. > > This commit fixes it by not advancing the put area's next pointer at > all, instead we just increment the size passed to _M_convert_to_external > to account for the extra character in the put area. This relies on the > previous commit which changed _M_convert_to_external to no longer use > pptr() internally (when retrying after a partial codecvt conversion). > If _M_convert_to_external was still looking at pptr() directly and > expecting it to have been bumped then we could not change overflow to no > longer bump it. > > Because this change depends on that fix in _M_convert_to_external there > is a potential ABI issue that needs care. If the new bump-less version > of basic_filebuf::overflow gets inlined into a translation unit but the > linker resolves its call to _M_convert_to_external to an old definition > that still calls pptr(), we would not transfer the overflow character to > the external file when retrying after a partial conversion. Although > this scenario seems unlikely because std::filebuf and std::wfilebuf are > both explicitly instantiated in libstdc++.so (and the explicit > instantiations use the new definition of _M_convert_to_external) it > would be safer to ensure the problem cannot occur. > > This commit adds an _M_convert_to_external(const _CharT*, streamsize) > overload which takes a const pointer, and changes overflow to use that > instead. This ensures that the new bump-less overflow uses a new symbol > with the new behaviour, and will never bind to an old definition that > inspects pptr(). The old overload taking a non-const pointer needs to be > preserved for ABI compatibility, but can be defined to simply forward > its arguments (after a const_cast) to the new overload. With this > change, instantiations of the old version of overflow can safely bind to > either the old definition of _M_convert_to_external (which calls pptr()) > or the new definition (which doesn't) because both definitions are > compatible with the old overflow. Instantiations of the new version of > overflow will only ever bind to the new overload because it has a > different mangled name. > > The failing_codecvt in the new test was generated by an LLM because I > was too lazy to remember how to write codecvt facets. > > Assisted-by: LLM > > libstdc++-v3/ChangeLog: > > PR libstdc++/118099 > * config/abi/pre/gnu.ver: Tighten old patterns for basic_filebuf > and export new symbols. > * include/bits/fstream.tcc (basic_filebuf::overflow): Do not > bump the next pointer for the overflow character. Pass const > pointers to _M_convert_to_external. > (_M_convert_to_external(_CharT*, streamsize)): Forward to new > overload. > (_M_convert_to_external(const _CharT*, streamsize)): Define new > overload. > * include/std/fstream (_M_convert_to_external): Define new > overload and suppress old overload for _GLIBCXX_INLINE_VERSION. > * testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc: > New test. > * testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc: > New test. > --- > > Tested x86_64-linux. > Some minor comments, looks good to me with them fixed. > > libstdc++-v3/config/abi/pre/gnu.ver | 7 +- > libstdc++-v3/include/bits/fstream.tcc | 120 +++++++++--------- > libstdc++-v3/include/std/fstream | 7 +- > .../overflow/char/118099-codecvt.cc | 76 +++++++++++ > .../overflow/wchar_t/118099-codecvt.cc | 76 +++++++++++ > 5 files changed, 224 insertions(+), 62 deletions(-) > create mode 100644 > libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc > create mode 100644 > libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc > > diff --git a/libstdc++-v3/config/abi/pre/gnu.ver > b/libstdc++-v3/config/abi/pre/gnu.ver > index 4fbb87acee3f..d846ce6d3e36 100644 > --- a/libstdc++-v3/config/abi/pre/gnu.ver > +++ b/libstdc++-v3/config/abi/pre/gnu.ver > @@ -434,7 +434,9 @@ GLIBCXX_3.4 { > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE15*; > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE16*; > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE19*; > - _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE2*; > + > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE22_M_convert_to_externalEP[cw][ilx]; > + > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE26_M_destroy_internal_buffer*; > + > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE27_M_allocate_internal_buffer*; > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE3*; > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE4openEPKc*; > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE4sync*; > @@ -2641,6 +2643,9 @@ GLIBCXX_3.4.37 { > > _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE*_S_allocate_*; > > _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE*_M_create_*; > > + # basic_filebuf::_M_convert_to_external(const C*, streamsize) > + > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE22_M_convert_to_externalEPK[cw][ilx]; > + > } GLIBCXX_3.4.36; > > # Symbols in the support library (libsupc++) have their own tag. > diff --git a/libstdc++-v3/include/bits/fstream.tcc > b/libstdc++-v3/include/bits/fstream.tcc > index 5d13633b6841..427e7b3a0c43 100644 > --- a/libstdc++-v3/include/bits/fstream.tcc > +++ b/libstdc++-v3/include/bits/fstream.tcc > @@ -561,23 +561,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > } > if (this->pbase() < this->pptr()) > { > + streamsize __n = this->pptr() - this->pbase(); > + > // If appropriate, append the overflow char. > if (!__testeof) > { > *this->pptr() = traits_type::to_char_type(__c); > - this->pbump(1); > + ++__n; > } > > + // This must be const _CharT* to call the right overload. > + const _CharT* __p = this->pbase(); > The overload based on cost is sneaky here, but I do not have much better idea. > + > // Convert pending sequence to external representation, > - // and output. > - if (_M_convert_to_external(this->pbase(), > - this->pptr() - this->pbase())) > + // and output. Include the overflow char if appropriate. > + if (_M_convert_to_external(__p, __n)) > { > _M_set_buffer(0); > __ret = traits_type::not_eof(__c); > } > - else if (!__testeof) > - this->pbump(-1); > } > else if (_M_buf_size > 1) > { > @@ -596,7 +598,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > else > { > // Unbuffered. > - char_type __conv = traits_type::to_char_type(__c); > + const char_type __conv = traits_type::to_char_type(__c); > Could you add a comment here, about selecting overloads? > if (__testeof || _M_convert_to_external(&__conv, 1)) > { > _M_writing = true; > @@ -607,65 +609,63 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > return __ret; > } > > + template > + bool > + basic_filebuf<_CharT, _Traits>:: > + _M_convert_to_external(const _CharT* __ibuf, streamsize __ilen) > + { > + if (__check_facet(_M_codecvt).always_noconv()) > + return _M_file.xsputn(reinterpret_cast(__ibuf), > __ilen) > + == __ilen; > + > + // Worst-case number of external bytes needed. > + // XXX Not done encoding() == -1. > + const streamsize __maxlen = __ilen * _M_codecvt->max_length(); > + char* const __buf = static_cast(__builtin_alloca(__maxlen)); > + streamsize __blen = __maxlen; > + > + char* __bend; > + const char_type* __iend; > + codecvt_base::result __r; > + __r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen, > + __iend, __buf, __buf + __blen, __bend); > + __blen = __bend - __buf; > + > + if (__r == codecvt_base::ok) > + return _M_file.xsputn(__buf, __blen) == __blen; > + else if (__r == codecvt_base::noconv) > + return _M_file.xsputn(reinterpret_cast(__ibuf), > __ilen) > + == __ilen; > + else if (__r == codecvt_base::error) > + __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " > + "conversion error")); > + > + // Conversion was partial, some output is in __buf. > + if (_M_file.xsputn(__buf, __blen) != __blen) > + return false; > + > + // Try once more for partial conversions. > + __r = _M_codecvt->out(_M_state_cur, __iend, __ibuf + __ilen, > + __iend, __buf, __buf + __maxlen, __bend); > + > + if (__r == codecvt_base::error) > + __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " > + "conversion error")); > + > + __blen = __bend - __buf; > + return _M_file.xsputn(__buf, __blen) == __blen; > + } > + > +#if ! _GLIBCXX_INLINE_VERSION > + // Prior to GCC 17 basic_filebuf::overflow called this overload. > template > bool > basic_filebuf<_CharT, _Traits>:: > _M_convert_to_external(_CharT* __ibuf, streamsize __ilen) > { > - // Sizes of external and pending output. > - streamsize __elen; > - streamsize __plen; > - if (__check_facet(_M_codecvt).always_noconv()) > - { > - __elen = _M_file.xsputn(reinterpret_cast(__ibuf), __ilen); > - __plen = __ilen; > - } > - else > - { > - // Worst-case number of external bytes needed. > - // XXX Not done encoding() == -1. > - streamsize __blen = __ilen * _M_codecvt->max_length(); > - char* __buf = static_cast(__builtin_alloca(__blen)); > - > - char* __bend; > - const char_type* __iend; > - codecvt_base::result __r; > - __r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen, > - __iend, __buf, __buf + __blen, __bend); > - > - if (__r == codecvt_base::ok || __r == codecvt_base::partial) > - __blen = __bend - __buf; > - else if (__r == codecvt_base::noconv) > - { > - // Same as the always_noconv case above. > - __buf = reinterpret_cast(__ibuf); > - __blen = __ilen; > - } > - else > - __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external > " > - "conversion error")); > - > - __elen = _M_file.xsputn(__buf, __blen); > - __plen = __blen; > - > - // Try once more for partial conversions. > - if (__r == codecvt_base::partial && __elen == __plen) > - { > - __r = _M_codecvt->out(_M_state_cur, __iend, __ibuf + __ilen, > - __iend, __buf, __buf + __blen, __bend); > - if (__r != codecvt_base::error) > - { > - const streamsize __rlen = __bend - __buf; > - __elen = _M_file.xsputn(__buf, __rlen); > - __plen = __rlen; > - } > - else > - > __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " > - "conversion error")); > - } > - } > - return __elen == __plen; > + return _M_convert_to_external(const_cast(__ibuf), > __ilen); > I do not think that const_cast is needed here, we are only adding const. Since we are only adding const, single return, I would define this function inline in the fstream class body. That should not affect if the symbol is emitted from the extern template specialization, and we are never calling it, so it should not be emmitted. > } > +#endif > > template > streamsize > diff --git a/libstdc++-v3/include/std/fstream > b/libstdc++-v3/include/std/fstream > index 653d417c6288..9549638205ad 100644 > --- a/libstdc++-v3/include/std/fstream > +++ b/libstdc++-v3/include/std/fstream > @@ -436,10 +436,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > virtual int_type > overflow(int_type __c = _Traits::eof()); > > - // Convert internal byte sequence to external, char-based > + // Convert internal _CharT sequence to external, char-based > // sequence via codecvt. > + bool > + _M_convert_to_external(const char_type*, streamsize); > + > +#if ! _GLIBCXX_INLINE_VERSION // ABI compat > bool > _M_convert_to_external(char_type*, streamsize); > +#endif > > /** > * @brief Manipulates the buffer. > diff --git > a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc > b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc > new file mode 100644 > index 000000000000..99645e810975 > --- /dev/null > +++ > b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc > This test should be also moved to first _Guard commit. > @@ -0,0 +1,76 @@ > +// { dg-do run } > +// { dg-require-fileio "" } > + > +// PR libstdc++/118099 > +// basic_filebuf::overflow leaves streambuf in inconsistent state on I/O > error > +// > +// Companion test of 118099.cc testing the throwing failure path in > overflow: > +// a codecvt whose do_out always returns error makes > _M_convert_to_external > +// throw after the overflow character has been written to the end of put > area. > +// If the put pointer is advanced before the throw (and only rewound on > the > +// non-throwing error path), a caller that catches the exception and keeps > +// writing will cause overflow(c) to write past the end of the managed > buffer, > +// just like the original PR libstdc++/118099 testcase. > + > +#include > +#include > +#include > + > +typedef char C; > + > +struct failing_codecvt : std::codecvt > +{ > +protected: > + result > + do_out(state_type&, const intern_type* from, const intern_type*, > + const intern_type*& from_next, > + extern_type* to, extern_type*, extern_type*& to_next) const > + { > + from_next = from; > + to_next = to; > + return error; > + } > + > + bool do_always_noconv() const throw() { return false; } > +}; > + > +static void > +test_pr118099_codecvt() > +{ > + const C val = C('x'); > + const C canary = ~val; > + const int N = 16; > + C buf[N]; > + for (int i = 0; i < N; ++i) > + buf[i] = canary; > + > + std::basic_filebuf fb; > + fb.pubimbue(std::locale(std::locale::classic(), new failing_codecvt)); > + fb.pubsetbuf(buf, N/2); // filebuf can use buf[0..7] > + fb.open("tmp_118099_codecvt", std::ios_base::out | > std::ios_base::trunc); > + VERIFY( fb.is_open() ); > + > + // Libstdc++ filebuf throws ios::failure for the codecvt error, > + // but the standard allows overflow to return eof instead. > + // To make this test portable, we check for either kind of error. > + bool got_error = false; > + for (int i = 0; i < N; ++i) > I would again split this into two separate loops: one up to N/2, if we do not get eof. And a second loop counting errors, and verifying there are N/2 of them. > + try { > + std::char_traits::int_type r = fb.sputc(val); > + if (std::char_traits::eq_int_type(r, std::char_traits::eof())) > + got_error = true; > + } catch (const std::exception&) { > + got_error = true; > + } > + VERIFY( got_error ); // a codecvt error actually happened > + > + for (int i = 0; i < N/2; ++i) > + VERIFY( buf[i] == val ); > + for (int i = N/2; i < N; ++i) > + VERIFY( buf[i] == canary ); // nothing was written past buf[0..7] > +} > + > +int main() > +{ > + test_pr118099_codecvt(); > +} > diff --git > a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc > b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc > new file mode 100644 > index 000000000000..27420006fada > --- /dev/null > +++ > b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc > @@ -0,0 +1,76 @@ > +// { dg-do run } > +// { dg-require-fileio "" } > + > +// PR libstdc++/118099 > +// basic_filebuf::overflow leaves streambuf in inconsistent state on I/O > error > +// > +// Companion test of 118099.cc testing the throwing failure path in > overflow: > +// a codecvt whose do_out always returns error makes > _M_convert_to_external > +// throw after the overflow character has been written to the end of put > area. > +// If the put pointer is advanced before the throw (and only rewound on > the > +// non-throwing error path), a caller that catches the exception and keeps > +// writing will cause overflow(c) to write past the end of the managed > buffer, > +// just like the original PR libstdc++/118099 testcase. > + > +#include > +#include > +#include > + > +typedef wchar_t C; > + > +struct failing_codecvt : std::codecvt > +{ > +protected: > + result > + do_out(state_type&, const intern_type* from, const intern_type*, > + const intern_type*& from_next, > + extern_type* to, extern_type*, extern_type*& to_next) const > + { > + from_next = from; > + to_next = to; > + return error; > + } > + > + bool do_always_noconv() const throw() { return false; } > +}; > + > +static void > +test_pr118099_codecvt() > +{ > + const C val = C('x'); > + const C canary = ~val; > + const int N = 16; > + C buf[N]; > + for (int i = 0; i < N; ++i) > + buf[i] = canary; > + > + std::basic_filebuf fb; > + fb.pubimbue(std::locale(std::locale::classic(), new failing_codecvt)); > + fb.pubsetbuf(buf, N/2); // filebuf can use buf[0..7] > + fb.open("tmp_118099_codecvt", std::ios_base::out | > std::ios_base::trunc); > + VERIFY( fb.is_open() ); > + > + // Libstdc++ filebuf throws ios::failure for the codecvt error, > + // but the standard allows overflow to return eof instead. > + // To make this test portable, we check for either kind of error. > + bool got_error = false; > + for (int i = 0; i < N; ++i) > + try { > + std::char_traits::int_type r = fb.sputc(val); > + if (std::char_traits::eq_int_type(r, std::char_traits::eof())) > + got_error = true; > + } catch (const std::exception&) { > + got_error = true; > + } > + VERIFY( got_error ); // a codecvt error actually happened > + > + for (int i = 0; i < N/2; ++i) > + VERIFY( buf[i] == val ); > + for (int i = N/2; i < N; ++i) > + VERIFY( buf[i] == canary ); // nothing was written past buf[0..7] > +} > + > +int main() > +{ > + test_pr118099_codecvt(); > +} > -- > 2.56.0 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From yansendao@126.com Mon Nov 2 15:33:11 2026 From: yansendao@126.com (Sendao Yan) Date: Mon, 2 Nov 2026 23:33:11 +0800 Subject: [PATCH] tree-optimization/128365 - fix leak in predicate::simplify_2 Message-ID: <20261102153311.1047076-1-yansendao@126.com> predicate::simplify_2 removes b_chain from m_preds via ordered_remove without first releasing its heap-allocated storage, leaking it on each successful simplification. Bootstrapped and regression tested on x86_64-pc-linux-gnu. gcc/ChangeLog: * gimple-predicate-analysis.cc (predicate::simplify_2): Release b_chain before removing it from m_preds. --- gcc/gimple-predicate-analysis.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index 6ecb1bc0387..2ef62f9cf22 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -1394,6 +1394,7 @@ predicate::simplify_2 () if (neg_idx != -1U) { a_chain.ordered_remove (neg_idx); + b_chain.release (); m_preds.ordered_remove (j); simplified = true; if (a_chain.is_empty ()) From jakub@redhat.com Mon Nov 2 15:46:27 2026 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 2 Nov 2026 16:46:27 +0100 Subject: [PATCH] testsuite: Change 4 bitint tests to dg-do run Message-ID: Hi! When working on the C++ _BitInt support (just posted), I've noticed that 4 recentish bitint tests are just dg-do compile instead of dg-do run as I've meant. 3 of those work without any changes, the 4th runs into some problems. Three of them are problems in the testcase, for signed _BitInt(1) -1 * -1 and -1 % -1 invoke UB and the check for return value of large negative bit-precise int times 0, and there is a question what -- and ++ operators should do on signed _BitInt(1), because they are defined as E-=1 or E+=1 where 1 is of the appropriate type, but signed _BitInt(1) doesn't have value 1, so we need E+=-1 and E-=-1 instead. Given int main () { signed _BitInt(3) a; a = 3wb; ++a; a = -3wb - 1; --a; signed char b; b = __SCHAR_MAX__; ++b; b = -__SCHAR_MAX__ - 1; --b; } with -fsanitize=undefined, I think we already implement the signed _BitInt --/++ as C23/C2Y says so right now, i.e. for bit-precise integers it uses 1 of the appropriate type, for other types too, but given E+=1 and E-=1 promotion rules for signed char/char/signed short or extended signed integer types with precision smaller than int do promote. So it is just the weird signed _BitInt(1) case. For C++ with the patch I've posted it behaves similarly despite the current wording of the proposal, which I hope will be changed. Anyway, is this patch ok for trunk? 2026-11-02 Jakub Jelinek * gcc.dg/torture/bitint-96.c: Change dg-do compile to dg-do run. (bar): Avoid signed _BitInt(1) -1 * -1 and -1 % -1 as that is UB. Don't do predecrement and postincrement for now at runtime. (main): Fix expected result of -large * 0 multiplication. * gcc.dg/torture/bitint-97.c: Change dg-do compile to dg-do run. * gcc.dg/torture/bitint-98.c: Likewise. * gcc.dg/torture/bitint-99.c: Likewise. --- a/gcc/testsuite/gcc.dg/torture/bitint-96.c 2026-04-28 08:54:25.379972942 +0200 +++ b/gcc/testsuite/gcc.dg/torture/bitint-96.c 2026-11-02 14:57:32.415742429 +0100 @@ -1,5 +1,5 @@ /* C2Y N3747 - Integer Sets, v5 */ -/* { dg-do compile { target bitint } } */ +/* { dg-do run { target bitint } } */ /* { dg-options "-std=c2y -pedantic-errors" } */ #define expr_has_type(e, t) _Generic (e, default : 0, t : 1) @@ -39,11 +39,11 @@ bar (_BitInt(1) a[21], signed _BitInt(1) a[4] = b[4] - c[4]; a[5] = b[5] - c[5]; a[6] = b[6] * c[6]; - a[7] = b[7] * c[8]; + a[7] = b[7] * c[7]; a[8] = b[8] * c[8]; a[9] = b[9] / c[9]; a[10] = b[10] % c[10]; - a[11] = b[11] % c[11]; + a[11] = b[10] % c[11]; a[12] = b[12] & c[12]; a[13] = b[13] & c[13]; a[14] = b[14] & c[14]; @@ -87,8 +87,16 @@ main () { if (b != 0 || c != -1) __builtin_abort (); - --b; - ++c; + if (0) + { + --b; + ++c; + } + else + { + b += (_BitInt(1)) -1wb; + c -= (_BitInt(1)) -1wb; + } if (b != -1 || c != 0) __builtin_abort (); b = ~b; @@ -118,7 +126,7 @@ main () 0, 0, -1, 0, -1, -1, 0, 0, -1 - }; + }; bar (e, f, g); _BitInt(1) h[21] = { 0, -1, -1, @@ -139,8 +147,7 @@ main () __builtin_abort (); if (baz (24807048826655379640613156875228202584070386120119745959437529938064756141700wb, 0wb) != 0wb) __builtin_abort (); - if (baz (-24807048826655379640613156875228202584070386120119745959437529938064756141700wb, 0wb) - != 24807048826655379640613156875228202584070386120119745959437529938064756141700wb) + if (baz (-24807048826655379640613156875228202584070386120119745959437529938064756141700wb, 0wb) != 0wb) __builtin_abort (); if (baz (0wb, ~0wb) != 0wb) __builtin_abort (); --- a/gcc/testsuite/gcc.dg/torture/bitint-97.c 2026-04-28 08:54:25.380071489 +0200 +++ b/gcc/testsuite/gcc.dg/torture/bitint-97.c 2026-11-02 14:15:53.120759171 +0100 @@ -1,5 +1,5 @@ /* C2Y N3747 - Integer Sets, v5 */ -/* { dg-do compile { target bitint } } */ +/* { dg-do run { target bitint } } */ /* { dg-options "-std=c2y -pedantic-errors -fwrapv" } */ [[gnu::noipa]] void @@ -24,7 +24,7 @@ main () }; signed _BitInt(1) g[8] = { -1, -1, -1, -1, -1, 0, 0, -1, - }; + }; bar (e, f, g); _BitInt(1) h[8] = { 0, -1, -1, -1, 0, 0, -1, -1 --- a/gcc/testsuite/gcc.dg/torture/bitint-98.c 2026-04-28 08:54:25.380165117 +0200 +++ b/gcc/testsuite/gcc.dg/torture/bitint-98.c 2026-11-02 14:16:08.734552857 +0100 @@ -1,5 +1,5 @@ /* C2Y N3747 - Integer Sets, v5 */ -/* { dg-do compile { target bitint } } */ +/* { dg-do run { target bitint } } */ /* { dg-options "-std=c2y -pedantic-errors" } */ /* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ /* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ @@ -22,7 +22,6 @@ baz (_BitInt(256) x, _BitInt(256) y, _Bi { return __builtin_mul_overflow (x, y, z); } - #endif int --- a/gcc/testsuite/gcc.dg/torture/bitint-99.c 2026-05-30 09:46:04.466953334 +0200 +++ b/gcc/testsuite/gcc.dg/torture/bitint-99.c 2026-11-02 14:16:14.882471619 +0100 @@ -1,5 +1,5 @@ /* C2Y N3705: bit-precise enum. */ -/* { dg-do compile { target bitint } } */ +/* { dg-do run { target bitint } } */ /* { dg-options "-std=c2y -pedantic-errors" } */ /* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ /* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ Jakub From abhishek.kaushik@arm.com Mon Nov 2 15:46:18 2026 From: abhishek.kaushik@arm.com (Abhishek Kaushik) Date: Mon, 2 Nov 2026 15:46:18 +0000 Subject: [PATCH] aarch64: Port Neon table lookup intrinsics to new framework Message-ID: <20261102154618.134988-1-abhishek.kaushik@arm.com> This patch ports the Neon table lookup intrinsics to the new pragma-based framework. Bootstrapped and regression tested on aarch64-linux-gnu. gcc/ChangeLog: * config/aarch64/aarch64-acle-builtins.cc (DEF_NEON_FUNCTION_GS): Define. (DEF_NEON_FUNCTION): Use DEF_NEON_FUNCTION_GS. * config/aarch64/aarch64-acle-builtins.h (TYPES_neon_tbl_s8): Define. (TYPES_neon_tbl_other): Likewise. (TYPES_neon_luti2_b): Likewise. (TYPES_neon_luti2_h): Likewise. (types_neon_tbl_s8): Likewise. (types_neon_tbl_other): Likewise. * config/aarch64/aarch64-neon-builtins-base.cc: Include emit-rtl.h. (gimple_exact_insn::fold): Expand definition. (gimple_table_lookup): New class. (gimple_table_lookup::expand): Build multi-register table results directly and perform legacy TBX lookup before generating masks. (gimple_luti): Likewise. (vtbl1): Define. (vtbl2): Likewise. (vtbl3): Likewise. (vtbl4): Likewise. (vqtbl1): Likewise. (vqtbl2): Likewise. (vqtbl3): Likewise. (vqtbl4): Likewise. (vqtbl1q): Likewise. (vqtbl2q): Likewise. (vqtbl3q): Likewise. (vqtbl4q): Likewise. (vtbx1): Likewise. (vtbx2): Likewise. (vtbx3): Likewise. (vtbx4): Likewise. (vqtbx1): Likewise. (vqtbx2): Likewise. (vqtbx3): Likewise. (vqtbx4): Likewise. (vqtbx1q): Likewise. (vqtbx2q): Likewise. (vqtbx3q): Likewise. (vqtbx4q): Likewise. (vluti2_lane): Likewise. (vluti2_laneq): Likewise. (vluti2q_lane): Likewise. (vluti2q_laneq): Likewise. (vluti4q_lane): Likewise. (vluti4q_laneq): Likewise. * config/aarch64/aarch64-neon-builtins-base.def: Add table lookup intrinsic definitions. * config/aarch64/aarch64-neon-builtins.def (DEF_NEON_FUNCTION_GS): Define. * config/aarch64/aarch64-simd-pragma-builtins.def: Remove table lookup intrinsic definitions. * config/aarch64/arm_neon.h: Remove inline definitions of table lookup intrinsics. gcc/testsuite/ChangeLog: * gcc.target/aarch64/neon/vluti2.c: New test. * gcc.target/aarch64/neon/vluti4.c: New test. * gcc.target/aarch64/neon/vqtbl.c: New test. * gcc.target/aarch64/neon/vqtblq.c: New test. * gcc.target/aarch64/neon/vqtbx.c: New test. * gcc.target/aarch64/neon/vqtbxq.c: New test. * gcc.target/aarch64/neon/vtbl.c: New test. * gcc.target/aarch64/neon/vtbx.c: New test. * gcc.target/aarch64/simd/mf8_data_1.c: Update table lookup expectations. --- gcc/config/aarch64/aarch64-acle-builtins.cc | 15 +- gcc/config/aarch64/aarch64-acle-builtins.h | 18 + .../aarch64/aarch64-neon-builtins-base.cc | 216 ++++++- .../aarch64/aarch64-neon-builtins-base.def | 74 +++ gcc/config/aarch64/aarch64-neon-builtins.def | 7 + .../aarch64/aarch64-simd-pragma-builtins.def | 78 --- gcc/config/aarch64/arm_neon.h | 588 ------------------ .../gcc.target/aarch64/neon/vluti2.c | 263 ++++++++ .../gcc.target/aarch64/neon/vluti4.c | 138 ++++ gcc/testsuite/gcc.target/aarch64/neon/vqtbl.c | 117 ++++ .../gcc.target/aarch64/neon/vqtblq.c | 117 ++++ gcc/testsuite/gcc.target/aarch64/neon/vqtbx.c | 120 ++++ .../gcc.target/aarch64/neon/vqtbxq.c | 116 ++++ gcc/testsuite/gcc.target/aarch64/neon/vtbl.c | 153 +++++ gcc/testsuite/gcc.target/aarch64/neon/vtbx.c | 178 ++++++ .../gcc.target/aarch64/simd/mf8_data_1.c | 12 +- 16 files changed, 1535 insertions(+), 675 deletions(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vluti2.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vluti4.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vqtbl.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vqtblq.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vqtbx.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vqtbxq.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vtbl.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vtbx.c diff --git a/gcc/config/aarch64/aarch64-acle-builtins.cc b/gcc/config/aarch64/aarch64-acle-builtins.cc index 2d52443a68ca..2f51be1ff92f 100644 --- a/gcc/config/aarch64/aarch64-acle-builtins.cc +++ b/gcc/config/aarch64/aarch64-acle-builtins.cc @@ -187,18 +187,23 @@ constexpr group_suffix_info group_suffixes[] = { { "", 0, 1 } }; -constexpr const aarch64_acle::function_group_info neon_function_groups[] = { -#define DEF_NEON_FUNCTION(NAME, TYPES, SHAPE_ARGS) \ +constexpr const aarch64_acle::function_group_info +neon_function_groups[] = { +#define DEF_NEON_FUNCTION_GS(NAME, TYPES, GROUPS, SHAPE_ARGS) \ { \ /* .base_name = */ #NAME, \ - /* .base = */ &aarch64_acle::functions::NAME, \ + /* .base = */ &aarch64_acle::functions::NAME, \ /* .shape = */ &aarch64_acle::shapes::SHAPE_NAME (NAME, TYPES),\ /* .types = */ aarch64_acle::types_##TYPES, \ - /* .groups = */ aarch64_acle::groups_none, \ + /* .groups = */ aarch64_acle::groups_##GROUPS, \ /* .preds = */ aarch64_acle::preds_none, \ /* .extensions = */ aarch64_required_extensions::REQUIRED_EXTENSIONS,\ /* .fpm_mode = */ aarch64_acle::FPM_unused, \ }, + +#define DEF_NEON_FUNCTION(NAME, TYPES, SHAPE_ARGS) \ + DEF_NEON_FUNCTION_GS (NAME, TYPES, none, SHAPE_ARGS) + #include "aarch64-neon-builtins.def" }; @@ -3916,7 +3921,7 @@ function_expander::expand () if (fpm_mode == FPM_set) { /* The last element of these functions is always an fpm_t that must be - written to FPMR before the call to the instruction itself. */ + written to FPMR before the call to the instruction itself. */ rtx fpm = args.last (); gcc_assert (CONST_INT_P (fpm) || GET_MODE (fpm) == DImode); emit_move_insn (gen_rtx_REG (DImode, FPM_REGNUM), fpm); diff --git a/gcc/config/aarch64/aarch64-acle-builtins.h b/gcc/config/aarch64/aarch64-acle-builtins.h index 1572594872b9..b625e6a0a463 100644 --- a/gcc/config/aarch64/aarch64-acle-builtins.h +++ b/gcc/config/aarch64/aarch64-acle-builtins.h @@ -2056,6 +2056,20 @@ function_expander::result_mode () const TYPES_neon_reinterpretq1 (D, p64), \ TYPES_neon_reinterpretq1 (D, p128) +/* _s8. */ +#define TYPES_neon_tbl_s8(S, D, T) \ + S (s8) + +/* _u8, _p8 and _mf8. */ +#define TYPES_neon_tbl_other(S, D, T) \ + S (u8), S (p8), S (mf8) + +#define TYPES_neon_luti2_b(S, D, T) \ + S (u8), S (s8), S (p8), S (mf8) + +#define TYPES_neon_luti2_h(S, D, T) \ + S (u16), S (s16), S (f16), S (bf16), S (p16) + /* Describe a tuple of type suffixes in which only the first is used. */ #define DEF_VECTOR_TYPE(X) \ { TYPE_SUFFIX_ ## X, NUM_TYPE_SUFFIXES, NUM_TYPE_SUFFIXES } @@ -2228,6 +2242,10 @@ DEF_SVE_TYPES_ARRAY (neon_rev32); DEF_SVE_TYPES_ARRAY (neon_rev64); DEF_SVE_TYPES_ARRAY (neon_reinterpret); DEF_SVE_TYPES_ARRAY (neon_reinterpretq); +DEF_SVE_TYPES_ARRAY (neon_tbl_s8); +DEF_SVE_TYPES_ARRAY (neon_tbl_other); +DEF_SVE_TYPES_ARRAY (neon_luti2_b); +DEF_SVE_TYPES_ARRAY (neon_luti2_h); static const group_suffix_index groups_none[] = { GROUP_none, NUM_GROUP_SUFFIXES diff --git a/gcc/config/aarch64/aarch64-neon-builtins-base.cc b/gcc/config/aarch64/aarch64-neon-builtins-base.cc index b00aed7c7d77..53ac7dac7700 100644 --- a/gcc/config/aarch64/aarch64-neon-builtins-base.cc +++ b/gcc/config/aarch64/aarch64-neon-builtins-base.cc @@ -43,6 +43,7 @@ #include "aarch64-neon-builtins-base.h" #include "aarch64-neon-builtins-functions.h" #include "gimple-fold.h" +#include "emit-rtl.h" namespace aarch64_acle { /* Build a cast expression, `(TYPE)EXPR`, if necessary to make an expression @@ -168,7 +169,10 @@ class gimple_function_base : public function_base template struct gimple_exact_insn : gimple_function_base { - gimple *fold (gimple_folder &) const override { return nullptr; } + gimple *fold (gimple_folder &) const override + { + return nullptr; + } rtx expand (function_expander &e) const override { return e.use_exact_insn (insn); @@ -623,6 +627,180 @@ public: } }; +/* Expand legacy NEON vtbl1-4 and vtbx1-4. + N is the number of 64-bit vectors in the lookup table. */ +template +class gimple_table_lookup : public gimple_function_base +{ + bool m_is_tbx; + insn_code m_code; + unsigned int m_table_arg; + +public: + constexpr gimple_table_lookup (bool tbx = false) + : m_is_tbx (tbx), + m_code (tbx && (N == 2 || N == 4) + ? (N == 2 ? CODE_FOR_aarch64_qtbx1v8qi + : CODE_FOR_aarch64_qtbx2v8qi) + : (N <= 2 ? CODE_FOR_aarch64_qtbl1v8qi + : CODE_FOR_aarch64_qtbl2v8qi)), + m_table_arg (tbx ? 1 : 0) + { + static_assert (N >= 1 && N <= 4, + "Invalid number of table vectors"); + } + + gimple *fold (gimple_folder &) const override + { + return nullptr; + } + + rtx expand (function_expander &e) const override + { + rtx parts[N]; + + /* vtbl1 and vtbx1 take a single V8QI vector. The remaining + intrinsics take a tuple of N V8QI vectors. */ + if (N == 1) + parts[0] = e.args[m_table_arg]; + else + { + machine_mode mode = GET_MODE (e.args[m_table_arg]); + + gcc_assert ((N == 2 && mode == V2x8QImode) + || (N == 3 && mode == V3x8QImode) + || (N == 4 && mode == V4x8QImode)); + + rtx tuple = force_reg (mode, e.args[m_table_arg]); + + /* Extract the individual 64-bit table vectors. */ + for (unsigned int i = 0; i < N; ++i) + parts[i] = simplify_gen_subreg (V8QImode, tuple, + mode, i * 8); + } + + /* Construct the full hardware table. N == 1 or 2 requires + one 128-bit register; N == 3 or 4 requires two. */ + rtx table = N > 2 ? gen_reg_rtx (V2x16QImode) + : gen_reg_rtx (V16QImode); + + /* Construct the first 128-bit table register. + For N == 1, zero the unused upper eight bytes. */ + rtx first = N > 2 ? simplify_gen_subreg (V16QImode, table, + V2x16QImode, 0) + : table; + + rtx upper = N >= 2 ? parts[1] + : CONST0_RTX (V8QImode); + + emit_insn (gen_aarch64_combinev8qi (first, + parts[0], upper)); + + if (N > 2) + { + rtx second = simplify_gen_subreg (V16QImode, table, + V2x16QImode, 16); + + upper = N == 4 ? parts[3] + : CONST0_RTX (V8QImode); + + emit_insn (gen_aarch64_combinev8qi (second, + parts[2], upper)); + } + + /* Legacy vtbx1 and vtbx3 have tables of 8 and 24 bytes, + respectively. Hardware TBX accepts tables whose sizes + are multiples of 16 bytes, so the padded bytes must + not overwrite the original destination. */ + if (m_is_tbx && (N == 1 || N == 3)) + { + rtx indices = force_reg (V8QImode, e.args[2]); + + /* Perform the table lookup. */ + rtx lookup = gen_reg_rtx (V8QImode); + + if (N == 1) + emit_insn (gen_aarch64_qtbl1v8qi (lookup, table, + indices)); + else + emit_insn (gen_aarch64_qtbl2v8qi (lookup, table, + indices)); + + /* Generate a mask for indices within the logical table. + The maximum valid index is 7 for vtbx1 and 23 for vtbx3. */ + rtx limit = gen_const_vec_duplicate (V8QImode, + GEN_INT (8 * N - 1)); + limit = force_reg (V8QImode, limit); + + rtx mask = gen_reg_rtx (V8QImode); + + /* mask[i] = 0xff if indices[i] <= 8 * N - 1. */ + emit_insn (gen_aarch64_cmgeuv8qi (mask, limit, indices)); + + /* Select lookup for valid indices, otherwise preserve the + original destination. */ + rtx result = gen_reg_rtx (V8QImode); + + rtx fallback = force_reg (V8QImode, e.args[0]); + + emit_insn (gen_aarch64_simd_bslv8qi (result, mask, + lookup, fallback)); + return result; + } + + /* All vtbl variants, and vtbx2/vtbx4, map directly onto + the corresponding TBL or TBX instruction after packing. */ + e.args[m_table_arg] = table; + return e.use_exact_insn (m_code); + } +}; + +/* Expand NEON LUTI2 and LUTI4 intrinsics. + BITS_PER_INDEX is the number of bits per lookup index. */ +template +class gimple_luti : public gimple_function_base +{ +public: + gimple *fold (gimple_folder &) const override + { + return nullptr; + } + + rtx expand (function_expander &e) const override + { + static_assert (BITS_PER_INDEX == 2 || BITS_PER_INDEX == 4); + + rtx table = e.args[0]; + + /* LUTI2 uses only the low 64 bits of the table. + The 128-bit table forms are provided for convenience. */ + if (BITS_PER_INDEX == 2 + && known_eq (GET_MODE_BITSIZE (GET_MODE (table)), 128u)) + { + machine_mode mode + = aarch64_v64_mode (GET_MODE_INNER (GET_MODE (table))) + .require (); + + table = gen_lowpart (mode, table); + } + + /* Select the instruction based on the table and index modes. */ + insn_code icode + = code_for_aarch64_lut (GET_MODE (table), + GET_MODE (e.args[1])); + + gcc_assert (icode != CODE_FOR_nothing); + + e.add_output_operand (icode); + e.add_input_operand (icode, table); + e.add_input_operand (icode, e.args[1]); + e.add_input_operand (icode, e.args[2]); + e.add_integer_operand (BITS_PER_INDEX); + + return e.generate_insn (icode); + } +}; + tree ext_mask (gimple_folder &f) { @@ -860,6 +1038,42 @@ NEON_FUNCTION (vzip1, vzip1q, gimple_permute, (zip_mask)) NEON_FUNCTION (vzip2, vzip2q, gimple_permute, (zip_mask)) NEON_FUNCTION (vzip, vzipq, gimple_permute_pair, (zip_mask, zip_mask)) +// Table lookup +NEON_FUNCTION (vtbl1, gimple_table_lookup<1>,) +NEON_FUNCTION (vtbl2, gimple_table_lookup<2>,) +NEON_FUNCTION (vtbl3, gimple_table_lookup<3>,) +NEON_FUNCTION (vtbl4, gimple_table_lookup<4>,) +NEON_FUNCTION (vqtbl1, gimple_exact_insn,) +NEON_FUNCTION (vqtbl2, gimple_exact_insn,) +NEON_FUNCTION (vqtbl3, gimple_exact_insn,) +NEON_FUNCTION (vqtbl4, gimple_exact_insn,) +NEON_FUNCTION (vqtbl1q, gimple_exact_insn,) +NEON_FUNCTION (vqtbl2q, gimple_exact_insn,) +NEON_FUNCTION (vqtbl3q, gimple_exact_insn,) +NEON_FUNCTION (vqtbl4q, gimple_exact_insn,) +NEON_FUNCTION (vtbx1, gimple_table_lookup<1>, (true)) +NEON_FUNCTION (vtbx2, gimple_table_lookup<2>, (true)) +NEON_FUNCTION (vtbx3, gimple_table_lookup<3>, (true)) +NEON_FUNCTION (vtbx4, gimple_table_lookup<4>, (true)) +NEON_FUNCTION (vqtbx1, gimple_exact_insn,) +NEON_FUNCTION (vqtbx2, gimple_exact_insn,) +NEON_FUNCTION (vqtbx3, gimple_exact_insn,) +NEON_FUNCTION (vqtbx4, gimple_exact_insn,) +NEON_FUNCTION (vqtbx1q, gimple_exact_insn,) +NEON_FUNCTION (vqtbx2q, gimple_exact_insn,) +NEON_FUNCTION (vqtbx3q, gimple_exact_insn,) +NEON_FUNCTION (vqtbx4q, gimple_exact_insn,) + +// Table lookup with 2-bit indices +NEON_FUNCTION (vluti2_lane, gimple_luti<2>,) +NEON_FUNCTION (vluti2_laneq, gimple_luti<2>,) +NEON_FUNCTION (vluti2q_lane, gimple_luti<2>,) +NEON_FUNCTION (vluti2q_laneq, gimple_luti<2>,) + +// Table lookup with 4-bit indices +NEON_FUNCTION (vluti4q_lane, gimple_luti<4>,) +NEON_FUNCTION (vluti4q_laneq, gimple_luti<4>,) + // AES NEON_FUNCTION (vaeseq, gimple_exact_insn,) NEON_FUNCTION (vaesdq, gimple_exact_insn,) diff --git a/gcc/config/aarch64/aarch64-neon-builtins-base.def b/gcc/config/aarch64/aarch64-neon-builtins-base.def index df33c37c34fc..a723a5cc5584 100644 --- a/gcc/config/aarch64/aarch64-neon-builtins-base.def +++ b/gcc/config/aarch64/aarch64-neon-builtins-base.def @@ -261,6 +261,80 @@ DEF_NEON_FUNCTION (vzip2q, bhsd_neon, ("Q0,Q0,Q0")) DEF_NEON_FUNCTION (vzipq, bhs_neon, ("Q0x2,Q0,Q0")) #undef REQUIRED_EXTENSIONS +// Table lookup +#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD) +DEF_NEON_FUNCTION (vtbl1, neon_tbl_s8, ("D0,D0,D0")) +DEF_NEON_FUNCTION (vtbl1, neon_tbl_other, ("D0,D0,Du0")) +DEF_NEON_FUNCTION (vtbl2, neon_tbl_s8, ("D0,D0x2,D0")) +DEF_NEON_FUNCTION (vtbl2, neon_tbl_other, ("D0,D0x2,Du0")) +DEF_NEON_FUNCTION (vtbl3, neon_tbl_s8, ("D0,D0x3,D0")) +DEF_NEON_FUNCTION (vtbl3, neon_tbl_other, ("D0,D0x3,Du0")) +DEF_NEON_FUNCTION (vtbl4, neon_tbl_s8, ("D0,D0x4,D0")) +DEF_NEON_FUNCTION (vtbl4, neon_tbl_other, ("D0,D0x4,Du0")) +DEF_NEON_FUNCTION (vqtbl1, neon_rev16, ("D0,Q0,Du0")) +DEF_NEON_FUNCTION (vqtbl2, neon_rev16, ("D0,Q0x2,Du0")) +DEF_NEON_FUNCTION (vqtbl3, neon_rev16, ("D0,Q0x3,Du0")) +DEF_NEON_FUNCTION (vqtbl4, neon_rev16, ("D0,Q0x4,Du0")) +DEF_NEON_FUNCTION (vqtbl1q, neon_rev16, ("Q0,Q0,Qu0")) +DEF_NEON_FUNCTION (vqtbl2q, neon_rev16, ("Q0,Q0x2,Qu0")) +DEF_NEON_FUNCTION (vqtbl3q, neon_rev16, ("Q0,Q0x3,Qu0")) +DEF_NEON_FUNCTION (vqtbl4q, neon_rev16, ("Q0,Q0x4,Qu0")) +DEF_NEON_FUNCTION (vtbx1, neon_tbl_s8, ("D0,D0,D0,D0")) +DEF_NEON_FUNCTION (vtbx1, neon_tbl_other, ("D0,D0,D0,Du0")) +DEF_NEON_FUNCTION (vtbx2, neon_tbl_s8, ("D0,D0,D0x2,D0")) +DEF_NEON_FUNCTION (vtbx2, neon_tbl_other, ("D0,D0,D0x2,Du0")) +DEF_NEON_FUNCTION (vtbx3, neon_tbl_s8, ("D0,D0,D0x3,D0")) +DEF_NEON_FUNCTION (vtbx3, neon_tbl_other, ("D0,D0,D0x3,Du0")) +DEF_NEON_FUNCTION (vtbx4, neon_tbl_s8, ("D0,D0,D0x4,D0")) +DEF_NEON_FUNCTION (vtbx4, neon_tbl_other, ("D0,D0,D0x4,Du0")) +DEF_NEON_FUNCTION (vqtbx1, neon_rev16, ("D0,D0,Q0,Du0")) +DEF_NEON_FUNCTION (vqtbx2, neon_rev16, ("D0,D0,Q0x2,Du0")) +DEF_NEON_FUNCTION (vqtbx3, neon_rev16, ("D0,D0,Q0x3,Du0")) +DEF_NEON_FUNCTION (vqtbx4, neon_rev16, ("D0,D0,Q0x4,Du0")) +DEF_NEON_FUNCTION (vqtbx1q, neon_rev16, ("Q0,Q0,Q0,Qu0")) +DEF_NEON_FUNCTION (vqtbx2q, neon_rev16, ("Q0,Q0,Q0x2,Qu0")) +DEF_NEON_FUNCTION (vqtbx3q, neon_rev16, ("Q0,Q0,Q0x3,Qu0")) +DEF_NEON_FUNCTION (vqtbx4q, neon_rev16, ("Q0,Q0,Q0x4,Qu0")) +#undef REQUIRED_EXTENSIONS + +/* Lookup table read with packed 2-bit indices. */ +#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_LUT) + +/* 8-bit result elements. */ +DEF_NEON_FUNCTION (vluti2_lane, neon_luti2_b, + ("Q0,D0,Du8,ss32", range<2, 0, 1>)) +DEF_NEON_FUNCTION (vluti2_laneq, neon_luti2_b, + ("Q0,D0,Qu8,ss32", range<2, 0, 3>)) +DEF_NEON_FUNCTION (vluti2q_lane, neon_luti2_b, + ("Q0,Q0,Du8,ss32", range<2, 0, 1>)) +DEF_NEON_FUNCTION (vluti2q_laneq, neon_luti2_b, + ("Q0,Q0,Qu8,ss32", range<2, 0, 3>)) + +/* 16-bit result elements. */ +DEF_NEON_FUNCTION (vluti2_lane, neon_luti2_h, + ("Q0,D0,Du8,ss32", range<2, 0, 3>)) +DEF_NEON_FUNCTION (vluti2_laneq, neon_luti2_h, + ("Q0,D0,Qu8,ss32", range<2, 0, 7>)) +DEF_NEON_FUNCTION (vluti2q_lane, neon_luti2_h, + ("Q0,Q0,Du8,ss32", range<2, 0, 3>)) +DEF_NEON_FUNCTION (vluti2q_laneq, neon_luti2_h, + ("Q0,Q0,Qu8,ss32", range<2, 0, 7>)) + +/* 8-bit forms: no group suffix. */ +DEF_NEON_FUNCTION (vluti4q_lane, neon_luti2_b, + ("Q0,Q0,Du8,ss32", range<2, 0, 0>)) + +DEF_NEON_FUNCTION (vluti4q_laneq, neon_luti2_b, + ("Q0,Q0,Qu8,ss32", range<2, 0, 1>)) + +/* 16-bit forms: the name ends with _x2. */ +DEF_NEON_FUNCTION_GS (vluti4q_lane, neon_luti2_h, x2, + ("Q0,Q0x2,Du8,ss32", range<2, 0, 1>)) + +DEF_NEON_FUNCTION_GS (vluti4q_laneq, neon_luti2_h, x2, + ("Q0,Q0x2,Qu8,ss32", range<2, 0, 3>)) +#undef REQUIRED_EXTENSIONS + // AES #define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD | AARCH64_FL_AES) DEF_NEON_FUNCTION (vaeseq, b_unsigned, ("Q0,Q0,Q0")) diff --git a/gcc/config/aarch64/aarch64-neon-builtins.def b/gcc/config/aarch64/aarch64-neon-builtins.def index 58630eebe489..02bb5591b8ce 100644 --- a/gcc/config/aarch64/aarch64-neon-builtins.def +++ b/gcc/config/aarch64/aarch64-neon-builtins.def @@ -25,6 +25,12 @@ #define DEF_NEON_FUNCTION(NAME, TYPES, SHAPE_ARGS) #endif +/* Define a NEON function with an explicit group suffix. */ +#ifndef DEF_NEON_FUNCTION_GS +#define DEF_NEON_FUNCTION_GS(NAME, TYPES, GROUPS, SHAPE_ARGS) \ + DEF_NEON_FUNCTION (NAME, TYPES, SHAPE_ARGS) +#endif + /* Helper for generating the name of the function_group's corresponding neon_shape instance. */ #define OBJ_NAME(NAME, TYPES) NAME ## _ ## TYPES ## _obj @@ -36,5 +42,6 @@ #include "aarch64-neon-builtins-base.def" #undef DEF_NEON_FUNCTION +#undef DEF_NEON_FUNCTION_GS #undef OBJ_NAME #undef SHAPE_NAME diff --git a/gcc/config/aarch64/aarch64-simd-pragma-builtins.def b/gcc/config/aarch64/aarch64-simd-pragma-builtins.def index 92ae493800ea..6bd4e8e89714 100644 --- a/gcc/config/aarch64/aarch64-simd-pragma-builtins.def +++ b/gcc/config/aarch64/aarch64-simd-pragma-builtins.def @@ -78,36 +78,6 @@ ENTRY_BINARY (NAME##q_f32, f32q, f32q, s32q, UNSPEC, FLAGS) \ ENTRY_BINARY (NAME##q_f64, f64q, f64q, s64q, UNSPEC, FLAGS) -#undef ENTRY_TERNARY_VLUT8 -#define ENTRY_TERNARY_VLUT8(T) \ - ENTRY_BINARY_LANE (vluti2_lane_##T##8, T##8q, T##8, u8, \ - UNSPEC_LUTI2, QUIET) \ - ENTRY_BINARY_LANE (vluti2_laneq_##T##8, T##8q, T##8, u8q, \ - UNSPEC_LUTI2, QUIET) \ - ENTRY_BINARY_LANE (vluti2q_lane_##T##8, T##8q, T##8q, u8, \ - UNSPEC_LUTI2, QUIET) \ - ENTRY_BINARY_LANE (vluti2q_laneq_##T##8, T##8q, T##8q, u8q, \ - UNSPEC_LUTI2, QUIET) \ - ENTRY_BINARY_LANE (vluti4q_lane_##T##8, T##8q, T##8q, u8, \ - UNSPEC_LUTI4, QUIET) \ - ENTRY_BINARY_LANE (vluti4q_laneq_##T##8, T##8q, T##8q, u8q, \ - UNSPEC_LUTI4, QUIET) - -#undef ENTRY_TERNARY_VLUT16 -#define ENTRY_TERNARY_VLUT16(T) \ - ENTRY_BINARY_LANE (vluti2_lane_##T##16, T##16q, T##16, u8, \ - UNSPEC_LUTI2, QUIET) \ - ENTRY_BINARY_LANE (vluti2_laneq_##T##16, T##16q, T##16, u8q, \ - UNSPEC_LUTI2, QUIET) \ - ENTRY_BINARY_LANE (vluti2q_lane_##T##16, T##16q, T##16q, u8, \ - UNSPEC_LUTI2, QUIET) \ - ENTRY_BINARY_LANE (vluti2q_laneq_##T##16, T##16q, T##16q, u8q, \ - UNSPEC_LUTI2, QUIET) \ - ENTRY_BINARY_LANE (vluti4q_lane_##T##16_x2, T##16q, T##16qx2, u8, \ - UNSPEC_LUTI4, QUIET) \ - ENTRY_BINARY_LANE (vluti4q_laneq_##T##16_x2, T##16q, T##16qx2, u8q, \ - UNSPEC_LUTI4, QUIET) - #undef ENTRY_UNARY_VQ_BHF #define ENTRY_UNARY_VQ_BHF(N, T1, UNSPEC, FLAGS) \ ENTRY_UNARY (N##_bf16_mf8_fpm, bf16q, T1, UNSPEC, FLAGS) \ @@ -140,20 +110,6 @@ ENTRY_BINARY_VHSDF (vamax, UNSPEC_FAMAX, FP) ENTRY_BINARY_VHSDF (vamin, UNSPEC_FAMIN, FP) #undef REQUIRED_EXTENSIONS -// lut -#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_LUT) -ENTRY_TERNARY_VLUT8 (p) -ENTRY_TERNARY_VLUT8 (s) -ENTRY_TERNARY_VLUT8 (u) -ENTRY_TERNARY_VLUT8 (mf) - -ENTRY_TERNARY_VLUT16 (bf) -ENTRY_TERNARY_VLUT16 (f) -ENTRY_TERNARY_VLUT16 (p) -ENTRY_TERNARY_VLUT16 (s) -ENTRY_TERNARY_VLUT16 (u) -#undef REQUIRED_EXTENSIONS - // fpm conversion #define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_FP8) ENTRY_UNARY_VQ_BHF (vcvt1, mf8, UNSPEC_F1CVTL_FP8, FP8) @@ -287,37 +243,3 @@ ENTRY_STORE (vst1q_mf8_x4, mf8_scalar_ptr, mf8qx4, UNSPEC_ST1x4) ENTRY_STORE_LANE (vst4_lane_mf8, mf8_scalar_ptr, mf8x4, UNSPEC_ST4_LANE) ENTRY_STORE_LANE (vst4q_lane_mf8, mf8_scalar_ptr, mf8qx4, UNSPEC_ST4_LANE) #undef REQUIRED_EXTENSIONS - -// tbl -#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD) -ENTRY_BINARY (vtbl1_mf8, mf8, mf8, u8, UNSPEC_TBL, QUIET) -ENTRY_BINARY (vtbl2_mf8, mf8, mf8x2, u8, UNSPEC_TBL, QUIET) -ENTRY_BINARY (vtbl3_mf8, mf8, mf8x3, u8, UNSPEC_TBL, QUIET) -ENTRY_BINARY (vtbl4_mf8, mf8, mf8x4, u8, UNSPEC_TBL, QUIET) - -ENTRY_BINARY (vqtbl1_mf8, mf8, mf8q, u8, UNSPEC_TBL, QUIET) -ENTRY_BINARY (vqtbl1q_mf8, mf8q, mf8q, u8q, UNSPEC_TBL, QUIET) -ENTRY_BINARY (vqtbl2_mf8, mf8, mf8qx2, u8, UNSPEC_TBL, QUIET) -ENTRY_BINARY (vqtbl2q_mf8, mf8q, mf8qx2, u8q, UNSPEC_TBL, QUIET) -ENTRY_BINARY (vqtbl3_mf8, mf8, mf8qx3, u8, UNSPEC_TBL, QUIET) -ENTRY_BINARY (vqtbl3q_mf8, mf8q, mf8qx3, u8q, UNSPEC_TBL, QUIET) -ENTRY_BINARY (vqtbl4_mf8, mf8, mf8qx4, u8, UNSPEC_TBL, QUIET) -ENTRY_BINARY (vqtbl4q_mf8, mf8q, mf8qx4, u8q, UNSPEC_TBL, QUIET) -#undef REQUIRED_EXTENSIONS - -// tbx -#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD) -ENTRY_TERNARY (vtbx1_mf8, mf8, mf8, mf8, u8, UNSPEC_TBX, QUIET) -ENTRY_TERNARY (vtbx2_mf8, mf8, mf8, mf8x2, u8, UNSPEC_TBX, QUIET) -ENTRY_TERNARY (vtbx3_mf8, mf8, mf8, mf8x3, u8, UNSPEC_TBX, QUIET) -ENTRY_TERNARY (vtbx4_mf8, mf8, mf8, mf8x4, u8, UNSPEC_TBX, QUIET) - -ENTRY_TERNARY (vqtbx1_mf8, mf8, mf8, mf8q, u8, UNSPEC_TBX, QUIET) -ENTRY_TERNARY (vqtbx1q_mf8, mf8q, mf8q, mf8q, u8q, UNSPEC_TBX, QUIET) -ENTRY_TERNARY (vqtbx2_mf8, mf8, mf8, mf8qx2, u8, UNSPEC_TBX, QUIET) -ENTRY_TERNARY (vqtbx2q_mf8, mf8q, mf8q, mf8qx2, u8q, UNSPEC_TBX, QUIET) -ENTRY_TERNARY (vqtbx3_mf8, mf8, mf8, mf8qx3, u8, UNSPEC_TBX, QUIET) -ENTRY_TERNARY (vqtbx3q_mf8, mf8q, mf8q, mf8qx3, u8q, UNSPEC_TBX, QUIET) -ENTRY_TERNARY (vqtbx4_mf8, mf8, mf8, mf8qx4, u8, UNSPEC_TBX, QUIET) -ENTRY_TERNARY (vqtbx4q_mf8, mf8q, mf8q, mf8qx4, u8q, UNSPEC_TBX, QUIET) -#undef REQUIRED_EXTENSIONS diff --git a/gcc/config/aarch64/arm_neon.h b/gcc/config/aarch64/arm_neon.h index 7b5926ca21b2..e991ae806f8f 100644 --- a/gcc/config/aarch64/arm_neon.h +++ b/gcc/config/aarch64/arm_neon.h @@ -4514,232 +4514,6 @@ vqrdmulhq_laneq_s32 (int32x4_t __a, int32x4_t __b, const int __c) return __builtin_aarch64_sqrdmulh_laneqv4si (__a, __b, __c); } -/* Table intrinsics. */ - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl1_p8 (poly8x16_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbl1v8qi_ppu (__tab, __idx); -} - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl1_s8 (int8x16_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbl1v8qi_ssu (__tab, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl1_u8 (uint8x16_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbl1v8qi_uuu (__tab, __idx); -} - -__extension__ extern __inline poly8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl1q_p8 (poly8x16_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbl1v16qi_ppu (__tab, __idx); -} - -__extension__ extern __inline int8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl1q_s8 (int8x16_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbl1v16qi_ssu (__tab, __idx); -} - -__extension__ extern __inline uint8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl1q_u8 (uint8x16_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbl1v16qi_uuu (__tab, __idx); -} - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx1_s8 (int8x8_t __r, int8x16_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbx1v8qi_sssu (__r, __tab, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx1_u8 (uint8x8_t __r, uint8x16_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbx1v8qi_uuuu (__r, __tab, __idx); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx1_p8 (poly8x8_t __r, poly8x16_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbx1v8qi_pppu (__r, __tab, __idx); -} - -__extension__ extern __inline int8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx1q_s8 (int8x16_t __r, int8x16_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbx1v16qi_sssu (__r, __tab, __idx); -} - -__extension__ extern __inline uint8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx1q_u8 (uint8x16_t __r, uint8x16_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbx1v16qi_uuuu (__r, __tab, __idx); -} - -__extension__ extern __inline poly8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx1q_p8 (poly8x16_t __r, poly8x16_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbx1v16qi_pppu (__r, __tab, __idx); -} - -/* V7 legacy table intrinsics. */ - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbl1_s8 (int8x8_t __tab, int8x8_t __idx) -{ - int8x16_t __temp = vcombine_s8 (__tab, - vcreate_s8 (__AARCH64_UINT64_C (0x0))); - return __builtin_aarch64_qtbl1v8qi (__temp, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbl1_u8 (uint8x8_t __tab, uint8x8_t __idx) -{ - uint8x16_t __temp = vcombine_u8 (__tab, - vcreate_u8 (__AARCH64_UINT64_C (0x0))); - return __builtin_aarch64_qtbl1v8qi_uuu (__temp, __idx); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbl1_p8 (poly8x8_t __tab, uint8x8_t __idx) -{ - poly8x16_t __temp = vcombine_p8 (__tab, - vcreate_p8 (__AARCH64_UINT64_C (0x0))); - return __builtin_aarch64_qtbl1v8qi_ppu (__temp, __idx); -} - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbl2_s8 (int8x8x2_t __tab, int8x8_t __idx) -{ - int8x16_t __temp = vcombine_s8 (__tab.val[0], __tab.val[1]); - return __builtin_aarch64_qtbl1v8qi (__temp, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbl2_u8 (uint8x8x2_t __tab, uint8x8_t __idx) -{ - uint8x16_t __temp = vcombine_u8 (__tab.val[0], __tab.val[1]); - return __builtin_aarch64_qtbl1v8qi_uuu (__temp, __idx); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbl2_p8 (poly8x8x2_t __tab, uint8x8_t __idx) -{ - poly8x16_t __temp = vcombine_p8 (__tab.val[0], __tab.val[1]); - return __builtin_aarch64_qtbl1v8qi_ppu (__temp, __idx); -} - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbl3_s8 (int8x8x3_t __tab, int8x8_t __idx) -{ - int8x16x2_t __temp; - __temp.val[0] = vcombine_s8 (__tab.val[0], __tab.val[1]); - __temp.val[1] = vcombine_s8 (__tab.val[2], - vcreate_s8 (__AARCH64_UINT64_C (0x0))); - return __builtin_aarch64_qtbl2v8qi (__temp, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbl3_u8 (uint8x8x3_t __tab, uint8x8_t __idx) -{ - uint8x16x2_t __temp; - __temp.val[0] = vcombine_u8 (__tab.val[0], __tab.val[1]); - __temp.val[1] = vcombine_u8 (__tab.val[2], - vcreate_u8 (__AARCH64_UINT64_C (0x0))); - return __builtin_aarch64_qtbl2v8qi_uuu (__temp, __idx); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbl3_p8 (poly8x8x3_t __tab, uint8x8_t __idx) -{ - poly8x16x2_t __temp; - __temp.val[0] = vcombine_p8 (__tab.val[0], __tab.val[1]); - __temp.val[1] = vcombine_p8 (__tab.val[2], - vcreate_p8 (__AARCH64_UINT64_C (0x0))); - return __builtin_aarch64_qtbl2v8qi_ppu (__temp, __idx); -} - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbl4_s8 (int8x8x4_t __tab, int8x8_t __idx) -{ - int8x16x2_t __temp; - __temp.val[0] = vcombine_s8 (__tab.val[0], __tab.val[1]); - __temp.val[1] = vcombine_s8 (__tab.val[2], __tab.val[3]); - return __builtin_aarch64_qtbl2v8qi (__temp, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbl4_u8 (uint8x8x4_t __tab, uint8x8_t __idx) -{ - uint8x16x2_t __temp; - __temp.val[0] = vcombine_u8 (__tab.val[0], __tab.val[1]); - __temp.val[1] = vcombine_u8 (__tab.val[2], __tab.val[3]); - return __builtin_aarch64_qtbl2v8qi_uuu (__temp, __idx); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbl4_p8 (poly8x8x4_t __tab, uint8x8_t __idx) -{ - poly8x16x2_t __temp; - __temp.val[0] = vcombine_p8 (__tab.val[0], __tab.val[1]); - __temp.val[1] = vcombine_p8 (__tab.val[2], __tab.val[3]); - return __builtin_aarch64_qtbl2v8qi_ppu (__temp, __idx); -} - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbx2_s8 (int8x8_t __r, int8x8x2_t __tab, int8x8_t __idx) -{ - int8x16_t __temp = vcombine_s8 (__tab.val[0], __tab.val[1]); - return __builtin_aarch64_qtbx1v8qi (__r, __temp, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbx2_u8 (uint8x8_t __r, uint8x8x2_t __tab, uint8x8_t __idx) -{ - uint8x16_t __temp = vcombine_u8 (__tab.val[0], __tab.val[1]); - return __builtin_aarch64_qtbx1v8qi_uuuu (__r, __temp, __idx); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbx2_p8 (poly8x8_t __r, poly8x8x2_t __tab, uint8x8_t __idx) -{ - poly8x16_t __temp = vcombine_p8 (__tab.val[0], __tab.val[1]); - return __builtin_aarch64_qtbx1v8qi_pppu (__r, __temp, __idx); -} - /* End of temporary inline asm. */ /* Start of optimal implementations in approved order. */ @@ -14564,270 +14338,6 @@ vqshrund_n_s64 (int64_t __a, const int __b) return (int32_t) __builtin_aarch64_sqshrun_ndi (__a, __b); } -/* vqtbl2 */ - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl2_s8 (int8x16x2_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbl2v8qi_ssu (__tab, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl2_u8 (uint8x16x2_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbl2v8qi_uuu (__tab, __idx); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl2_p8 (poly8x16x2_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbl2v8qi_ppu (__tab, __idx); -} - -__extension__ extern __inline int8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl2q_s8 (int8x16x2_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbl2v16qi_ssu (__tab, __idx); -} - -__extension__ extern __inline uint8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl2q_u8 (uint8x16x2_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbl2v16qi_uuu (__tab, __idx); -} - -__extension__ extern __inline poly8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl2q_p8 (poly8x16x2_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbl2v16qi_ppu (__tab, __idx); -} - -/* vqtbl3 */ - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl3_s8 (int8x16x3_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbl3v8qi_ssu (__tab, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl3_u8 (uint8x16x3_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbl3v8qi_uuu (__tab, __idx); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl3_p8 (poly8x16x3_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbl3v8qi_ppu (__tab, __idx); -} - -__extension__ extern __inline int8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl3q_s8 (int8x16x3_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbl3v16qi_ssu (__tab, __idx); -} - -__extension__ extern __inline uint8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl3q_u8 (uint8x16x3_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbl3v16qi_uuu (__tab, __idx); -} - -__extension__ extern __inline poly8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl3q_p8 (poly8x16x3_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbl3v16qi_ppu (__tab, __idx); -} - -/* vqtbl4 */ - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl4_s8 (int8x16x4_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbl4v8qi_ssu (__tab, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl4_u8 (uint8x16x4_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbl4v8qi_uuu (__tab, __idx); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl4_p8 (poly8x16x4_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbl4v8qi_ppu (__tab, __idx); -} - -__extension__ extern __inline int8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl4q_s8 (int8x16x4_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbl4v16qi_ssu (__tab, __idx); -} - -__extension__ extern __inline uint8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl4q_u8 (uint8x16x4_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbl4v16qi_uuu (__tab, __idx); -} - -__extension__ extern __inline poly8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbl4q_p8 (poly8x16x4_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbl4v16qi_ppu (__tab, __idx); -} - -/* vqtbx2 */ - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx2_s8 (int8x8_t __r, int8x16x2_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbx2v8qi_sssu (__r, __tab, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx2_u8 (uint8x8_t __r, uint8x16x2_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbx2v8qi_uuuu (__r, __tab, __idx); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx2_p8 (poly8x8_t __r, poly8x16x2_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbx2v8qi_pppu (__r, __tab, __idx); -} - -__extension__ extern __inline int8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx2q_s8 (int8x16_t __r, int8x16x2_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbx2v16qi_sssu (__r, __tab, __idx); -} - -__extension__ extern __inline uint8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx2q_u8 (uint8x16_t __r, uint8x16x2_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbx2v16qi_uuuu (__r, __tab, __idx); -} - -__extension__ extern __inline poly8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx2q_p8 (poly8x16_t __r, poly8x16x2_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbx2v16qi_pppu (__r, __tab, __idx); -} - -/* vqtbx3 */ - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx3_s8 (int8x8_t __r, int8x16x3_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbx3v8qi_sssu (__r, __tab, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx3_u8 (uint8x8_t __r, uint8x16x3_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbx3v8qi_uuuu (__r, __tab, __idx); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx3_p8 (poly8x8_t __r, poly8x16x3_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbx3v8qi_pppu (__r, __tab, __idx); -} - -__extension__ extern __inline int8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx3q_s8 (int8x16_t __r, int8x16x3_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbx3v16qi_sssu (__r, __tab, __idx); -} - -__extension__ extern __inline uint8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx3q_u8 (uint8x16_t __r, uint8x16x3_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbx3v16qi_uuuu (__r, __tab, __idx); -} - -__extension__ extern __inline poly8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx3q_p8 (poly8x16_t __r, poly8x16x3_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbx3v16qi_pppu (__r, __tab, __idx); -} - -/* vqtbx4 */ - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx4_s8 (int8x8_t __r, int8x16x4_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbx4v8qi_sssu (__r, __tab, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx4_u8 (uint8x8_t __r, uint8x16x4_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbx4v8qi_uuuu (__r, __tab, __idx); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx4_p8 (poly8x8_t __r, poly8x16x4_t __tab, uint8x8_t __idx) -{ - return __builtin_aarch64_qtbx4v8qi_pppu (__r, __tab, __idx); -} - -__extension__ extern __inline int8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx4q_s8 (int8x16_t __r, int8x16x4_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbx4v16qi_sssu (__r, __tab, __idx); -} - -__extension__ extern __inline uint8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx4q_u8 (uint8x16_t __r, uint8x16x4_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbx4v16qi_uuuu (__r, __tab, __idx); -} - -__extension__ extern __inline poly8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vqtbx4q_p8 (poly8x16_t __r, poly8x16x4_t __tab, uint8x16_t __idx) -{ - return __builtin_aarch64_qtbx4v16qi_pppu (__r, __tab, __idx); -} - /* vrecpe */ __extension__ extern __inline uint32x2_t @@ -17978,104 +17488,6 @@ vsubd_u64 (uint64_t __a, uint64_t __b) return __a - __b; } -/* vtbx1 */ - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbx1_s8 (int8x8_t __r, int8x8_t __tab, int8x8_t __idx) -{ - uint8x8_t __mask = vclt_u8 (vreinterpret_u8_s8 (__idx), - vmov_n_u8 (8)); - int8x8_t __tbl = vtbl1_s8 (__tab, __idx); - - return vbsl_s8 (__mask, __tbl, __r); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbx1_u8 (uint8x8_t __r, uint8x8_t __tab, uint8x8_t __idx) -{ - uint8x8_t __mask = vclt_u8 (__idx, vmov_n_u8 (8)); - uint8x8_t __tbl = vtbl1_u8 (__tab, __idx); - - return vbsl_u8 (__mask, __tbl, __r); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbx1_p8 (poly8x8_t __r, poly8x8_t __tab, uint8x8_t __idx) -{ - uint8x8_t __mask = vclt_u8 (__idx, vmov_n_u8 (8)); - poly8x8_t __tbl = vtbl1_p8 (__tab, __idx); - - return vbsl_p8 (__mask, __tbl, __r); -} - -/* vtbx3 */ - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbx3_s8 (int8x8_t __r, int8x8x3_t __tab, int8x8_t __idx) -{ - uint8x8_t __mask = vclt_u8 (vreinterpret_u8_s8 (__idx), - vmov_n_u8 (24)); - int8x8_t __tbl = vtbl3_s8 (__tab, __idx); - - return vbsl_s8 (__mask, __tbl, __r); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbx3_u8 (uint8x8_t __r, uint8x8x3_t __tab, uint8x8_t __idx) -{ - uint8x8_t __mask = vclt_u8 (__idx, vmov_n_u8 (24)); - uint8x8_t __tbl = vtbl3_u8 (__tab, __idx); - - return vbsl_u8 (__mask, __tbl, __r); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbx3_p8 (poly8x8_t __r, poly8x8x3_t __tab, uint8x8_t __idx) -{ - uint8x8_t __mask = vclt_u8 (__idx, vmov_n_u8 (24)); - poly8x8_t __tbl = vtbl3_p8 (__tab, __idx); - - return vbsl_p8 (__mask, __tbl, __r); -} - -/* vtbx4 */ - -__extension__ extern __inline int8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbx4_s8 (int8x8_t __r, int8x8x4_t __tab, int8x8_t __idx) -{ - int8x16x2_t __temp; - __temp.val[0] = vcombine_s8 (__tab.val[0], __tab.val[1]); - __temp.val[1] = vcombine_s8 (__tab.val[2], __tab.val[3]); - return __builtin_aarch64_qtbx2v8qi (__r, __temp, __idx); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbx4_u8 (uint8x8_t __r, uint8x8x4_t __tab, uint8x8_t __idx) -{ - uint8x16x2_t __temp; - __temp.val[0] = vcombine_u8 (__tab.val[0], __tab.val[1]); - __temp.val[1] = vcombine_u8 (__tab.val[2], __tab.val[3]); - return __builtin_aarch64_qtbx2v8qi_uuuu (__r, __temp, __idx); -} - -__extension__ extern __inline poly8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vtbx4_p8 (poly8x8_t __r, poly8x8x4_t __tab, uint8x8_t __idx) -{ - poly8x16x2_t __temp; - __temp.val[0] = vcombine_p8 (__tab.val[0], __tab.val[1]); - __temp.val[1] = vcombine_p8 (__tab.val[2], __tab.val[3]); - return __builtin_aarch64_qtbx2v8qi_pppu (__r, __temp, __idx); -} - /* vtst */ __extension__ extern __inline uint8x8_t diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vluti2.c b/gcc/testsuite/gcc.target/aarch64/neon/vluti2.c new file mode 100644 index 000000000000..9a0fef0ab359 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vluti2.c @@ -0,0 +1,263 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3 -march=armv9-a+lut" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +#define TEST_LUTI2(NAME, RET_TYPE, ARG_1_TYPE, ARG_2_TYPE) \ + RET_TYPE test_##NAME (ARG_1_TYPE vn, ARG_2_TYPE vm) \ + { \ + return NAME (vn, vm, 0); \ + } + +/* +** test_vluti2_lane_u8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_lane_u8, uint8x16_t, uint8x8_t, uint8x8_t) + +/* +** test_vluti2_laneq_u8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_laneq_u8, uint8x16_t, uint8x8_t, uint8x16_t) + +/* +** test_vluti2q_lane_u8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_lane_u8, uint8x16_t, uint8x16_t, uint8x8_t) + +/* +** test_vluti2q_laneq_u8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_laneq_u8, uint8x16_t, uint8x16_t, uint8x16_t) + +/* +** test_vluti2_lane_s8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_lane_s8, int8x16_t, int8x8_t, uint8x8_t) + +/* +** test_vluti2_laneq_s8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_laneq_s8, int8x16_t, int8x8_t, uint8x16_t) + +/* +** test_vluti2q_lane_s8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_lane_s8, int8x16_t, int8x16_t, uint8x8_t) + +/* +** test_vluti2q_laneq_s8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_laneq_s8, int8x16_t, int8x16_t, uint8x16_t) + +/* +** test_vluti2_lane_p8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_lane_p8, poly8x16_t, poly8x8_t, uint8x8_t) + +/* +** test_vluti2_laneq_p8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_laneq_p8, poly8x16_t, poly8x8_t, uint8x16_t) + +/* +** test_vluti2q_lane_p8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_lane_p8, poly8x16_t, poly8x16_t, uint8x8_t) + +/* +** test_vluti2q_laneq_p8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_laneq_p8, poly8x16_t, poly8x16_t, uint8x16_t) + +/* +** test_vluti2_lane_mf8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_lane_mf8, mfloat8x16_t, mfloat8x8_t, uint8x8_t) + +/* +** test_vluti2_laneq_mf8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_laneq_mf8, mfloat8x16_t, mfloat8x8_t, uint8x16_t) + +/* +** test_vluti2q_lane_mf8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_lane_mf8, mfloat8x16_t, mfloat8x16_t, uint8x8_t) + +/* +** test_vluti2q_laneq_mf8: +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_laneq_mf8, mfloat8x16_t, mfloat8x16_t, uint8x16_t) + +/* +** test_vluti2_lane_u16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_lane_u16, uint16x8_t, uint16x4_t, uint8x8_t) + +/* +** test_vluti2_laneq_u16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_laneq_u16, uint16x8_t, uint16x4_t, uint8x16_t) + +/* +** test_vluti2q_lane_u16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_lane_u16, uint16x8_t, uint16x8_t, uint8x8_t) + +/* +** test_vluti2q_laneq_u16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_laneq_u16, uint16x8_t, uint16x8_t, uint8x16_t) + +/* +** test_vluti2_lane_s16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_lane_s16, int16x8_t, int16x4_t, uint8x8_t) + +/* +** test_vluti2_laneq_s16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_laneq_s16, int16x8_t, int16x4_t, uint8x16_t) + +/* +** test_vluti2q_lane_s16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_lane_s16, int16x8_t, int16x8_t, uint8x8_t) + +/* +** test_vluti2q_laneq_s16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_laneq_s16, int16x8_t, int16x8_t, uint8x16_t) + +/* +** test_vluti2_lane_f16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_lane_f16, float16x8_t, float16x4_t, uint8x8_t) + +/* +** test_vluti2_laneq_f16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_laneq_f16, float16x8_t, float16x4_t, uint8x16_t) + +/* +** test_vluti2q_lane_f16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_lane_f16, float16x8_t, float16x8_t, uint8x8_t) + +/* +** test_vluti2q_laneq_f16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_laneq_f16, float16x8_t, float16x8_t, uint8x16_t) + +/* +** test_vluti2_lane_bf16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_lane_bf16, bfloat16x8_t, bfloat16x4_t, uint8x8_t) + +/* +** test_vluti2_laneq_bf16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_laneq_bf16, bfloat16x8_t, bfloat16x4_t, uint8x16_t) + +/* +** test_vluti2q_lane_bf16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_lane_bf16, bfloat16x8_t, bfloat16x8_t, uint8x8_t) + +/* +** test_vluti2q_laneq_bf16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_laneq_bf16, bfloat16x8_t, bfloat16x8_t, uint8x16_t) + +/* +** test_vluti2_lane_p16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_lane_p16, poly16x8_t, poly16x4_t, uint8x8_t) + +/* +** test_vluti2_laneq_p16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2_laneq_p16, poly16x8_t, poly16x4_t, uint8x16_t) + +/* +** test_vluti2q_lane_p16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_lane_p16, poly16x8_t, poly16x8_t, uint8x8_t) + +/* +** test_vluti2q_laneq_p16: +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI2 (vluti2q_laneq_p16, poly16x8_t, poly16x8_t, uint8x16_t) diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vluti4.c b/gcc/testsuite/gcc.target/aarch64/neon/vluti4.c new file mode 100644 index 000000000000..99ff77ae4f6b --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vluti4.c @@ -0,0 +1,138 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3 -march=armv9-a+lut" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +#define TEST_LUTI4(NAME, RET_TYPE, ARG_1_TYPE, ARG_2_TYPE) \ + RET_TYPE test_##NAME (ARG_1_TYPE vn, ARG_2_TYPE vm) \ + { \ + return NAME (vn, vm, 0); \ + } + +/* +** test_vluti4q_lane_u8: +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_lane_u8, uint8x16_t, uint8x16_t, uint8x8_t) + +/* +** test_vluti4q_laneq_u8: +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_laneq_u8, uint8x16_t, uint8x16_t, uint8x16_t) + +/* +** test_vluti4q_lane_s8: +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_lane_s8, int8x16_t, int8x16_t, uint8x8_t) + +/* +** test_vluti4q_laneq_s8: +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_laneq_s8, int8x16_t, int8x16_t, uint8x16_t) + +/* +** test_vluti4q_lane_p8: +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_lane_p8, poly8x16_t, poly8x16_t, uint8x8_t) + +/* +** test_vluti4q_laneq_p8: +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_laneq_p8, poly8x16_t, poly8x16_t, uint8x16_t) + +/* +** test_vluti4q_lane_mf8: +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_lane_mf8, mfloat8x16_t, mfloat8x16_t, uint8x8_t) + +/* +** test_vluti4q_laneq_mf8: +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_laneq_mf8, mfloat8x16_t, mfloat8x16_t, uint8x16_t) + +/* +** test_vluti4q_lane_u16_x2: +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_lane_u16_x2, uint16x8_t, uint16x8x2_t, uint8x8_t) + +/* +** test_vluti4q_laneq_u16_x2: +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_laneq_u16_x2, uint16x8_t, uint16x8x2_t, uint8x16_t) + +/* +** test_vluti4q_lane_s16_x2: +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_lane_s16_x2, int16x8_t, int16x8x2_t, uint8x8_t) + +/* +** test_vluti4q_laneq_s16_x2: +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_laneq_s16_x2, int16x8_t, int16x8x2_t, uint8x16_t) + +/* +** test_vluti4q_lane_f16_x2: +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_lane_f16_x2, float16x8_t, float16x8x2_t, uint8x8_t) + +/* +** test_vluti4q_laneq_f16_x2: +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_laneq_f16_x2, float16x8_t, float16x8x2_t, uint8x16_t) + +/* +** test_vluti4q_lane_bf16_x2: +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_lane_bf16_x2, bfloat16x8_t, bfloat16x8x2_t, uint8x8_t) + +/* +** test_vluti4q_laneq_bf16_x2: +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_laneq_bf16_x2, bfloat16x8_t, bfloat16x8x2_t, + uint8x16_t) + +/* +** test_vluti4q_lane_p16_x2: +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_lane_p16_x2, poly16x8_t, poly16x8x2_t, uint8x8_t) + +/* +** test_vluti4q_laneq_p16_x2: +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] +** ret +*/ +TEST_LUTI4 (vluti4q_laneq_p16_x2, poly16x8_t, poly16x8x2_t, uint8x16_t) diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vqtbl.c b/gcc/testsuite/gcc.target/aarch64/neon/vqtbl.c new file mode 100644 index 000000000000..d9ed12982094 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vqtbl.c @@ -0,0 +1,117 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vqtbl1_s8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl1_s8, int8x8_t, int8x16_t, uint8x8_t) + +/* +** test_vqtbl1_u8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl1_u8, uint8x8_t, uint8x16_t, uint8x8_t) + +/* +** test_vqtbl1_p8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl1_p8, poly8x8_t, poly8x16_t, uint8x8_t) + +/* +** test_vqtbl1_mf8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl1_mf8, mfloat8x8_t, mfloat8x16_t, uint8x8_t) + +/* +** test_vqtbl2_s8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl2_s8, int8x8_t, int8x16x2_t, uint8x8_t) + +/* +** test_vqtbl2_u8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl2_u8, uint8x8_t, uint8x16x2_t, uint8x8_t) + +/* +** test_vqtbl2_p8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl2_p8, poly8x8_t, poly8x16x2_t, uint8x8_t) + +/* +** test_vqtbl2_mf8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl2_mf8, mfloat8x8_t, mfloat8x16x2_t, uint8x8_t) + +/* +** test_vqtbl3_s8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl3_s8, int8x8_t, int8x16x3_t, uint8x8_t) + +/* +** test_vqtbl3_u8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl3_u8, uint8x8_t, uint8x16x3_t, uint8x8_t) + +/* +** test_vqtbl3_p8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl3_p8, poly8x8_t, poly8x16x3_t, uint8x8_t) + +/* +** test_vqtbl3_mf8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl3_mf8, mfloat8x8_t, mfloat8x16x3_t, uint8x8_t) + +/* +** test_vqtbl4_s8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl4_s8, int8x8_t, int8x16x4_t, uint8x8_t) + +/* +** test_vqtbl4_u8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl4_u8, uint8x8_t, uint8x16x4_t, uint8x8_t) + +/* +** test_vqtbl4_p8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl4_p8, poly8x8_t, poly8x16x4_t, uint8x8_t) + +/* +** test_vqtbl4_mf8: +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vqtbl4_mf8, mfloat8x8_t, mfloat8x16x4_t, uint8x8_t) + diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vqtblq.c b/gcc/testsuite/gcc.target/aarch64/neon/vqtblq.c new file mode 100644 index 000000000000..5ff00e2b5958 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vqtblq.c @@ -0,0 +1,117 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vqtbl1q_s8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl1q_s8, int8x16_t, int8x16_t, uint8x16_t) + +/* +** test_vqtbl1q_u8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl1q_u8, uint8x16_t, uint8x16_t, uint8x16_t) + +/* +** test_vqtbl1q_p8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl1q_p8, poly8x16_t, poly8x16_t, uint8x16_t) + +/* +** test_vqtbl1q_mf8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl1q_mf8, mfloat8x16_t, mfloat8x16_t, uint8x16_t) + +/* +** test_vqtbl2q_s8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl2q_s8, int8x16_t, int8x16x2_t, uint8x16_t) + +/* +** test_vqtbl2q_u8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl2q_u8, uint8x16_t, uint8x16x2_t, uint8x16_t) + +/* +** test_vqtbl2q_p8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl2q_p8, poly8x16_t, poly8x16x2_t, uint8x16_t) + +/* +** test_vqtbl2q_mf8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl2q_mf8, mfloat8x16_t, mfloat8x16x2_t, uint8x16_t) + +/* +** test_vqtbl3q_s8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl3q_s8, int8x16_t, int8x16x3_t, uint8x16_t) + +/* +** test_vqtbl3q_u8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl3q_u8, uint8x16_t, uint8x16x3_t, uint8x16_t) + +/* +** test_vqtbl3q_p8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl3q_p8, poly8x16_t, poly8x16x3_t, uint8x16_t) + +/* +** test_vqtbl3q_mf8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl3q_mf8, mfloat8x16_t, mfloat8x16x3_t, uint8x16_t) + +/* +** test_vqtbl4q_s8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl4q_s8, int8x16_t, int8x16x4_t, uint8x16_t) + +/* +** test_vqtbl4q_u8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl4q_u8, uint8x16_t, uint8x16x4_t, uint8x16_t) + +/* +** test_vqtbl4q_p8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl4q_p8, poly8x16_t, poly8x16x4_t, uint8x16_t) + +/* +** test_vqtbl4q_mf8: +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_BINARY (vqtbl4q_mf8, mfloat8x16_t, mfloat8x16x4_t, uint8x16_t) + diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vqtbx.c b/gcc/testsuite/gcc.target/aarch64/neon/vqtbx.c new file mode 100644 index 000000000000..7affd0fd0715 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vqtbx.c @@ -0,0 +1,120 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vqtbx1_s8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx1_s8, int8x8_t, int8x8_t, int8x16_t, uint8x8_t) + +/* +** test_vqtbx1_u8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx1_u8, uint8x8_t, uint8x8_t, uint8x16_t, uint8x8_t) + +/* +** test_vqtbx1_p8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx1_p8, poly8x8_t, poly8x8_t, poly8x16_t, uint8x8_t) + +/* +** test_vqtbx1_mf8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx1_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x16_t, + uint8x8_t) + +/* +** test_vqtbx2_s8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx2_s8, int8x8_t, int8x8_t, int8x16x2_t, uint8x8_t) + +/* +** test_vqtbx2_u8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx2_u8, uint8x8_t, uint8x8_t, uint8x16x2_t, uint8x8_t) + +/* +** test_vqtbx2_p8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx2_p8, poly8x8_t, poly8x8_t, poly8x16x2_t, uint8x8_t) + +/* +** test_vqtbx2_mf8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx2_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x16x2_t, + uint8x8_t) + +/* +** test_vqtbx3_s8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx3_s8, int8x8_t, int8x8_t, int8x16x3_t, uint8x8_t) + +/* +** test_vqtbx3_u8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx3_u8, uint8x8_t, uint8x8_t, uint8x16x3_t, uint8x8_t) + +/* +** test_vqtbx3_p8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx3_p8, poly8x8_t, poly8x8_t, poly8x16x3_t, uint8x8_t) + +/* +** test_vqtbx3_mf8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx3_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x16x3_t, + uint8x8_t) + +/* +** test_vqtbx4_s8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx4_s8, int8x8_t, int8x8_t, int8x16x4_t, uint8x8_t) + +/* +** test_vqtbx4_u8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx4_u8, uint8x8_t, uint8x8_t, uint8x16x4_t, uint8x8_t) + +/* +** test_vqtbx4_p8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx4_p8, poly8x8_t, poly8x8_t, poly8x16x4_t, uint8x8_t) + +/* +** test_vqtbx4_mf8: +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vqtbx4_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x16x4_t, + uint8x8_t) diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vqtbxq.c b/gcc/testsuite/gcc.target/aarch64/neon/vqtbxq.c new file mode 100644 index 000000000000..22f56191dce5 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vqtbxq.c @@ -0,0 +1,116 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vqtbx1q_s8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx1q_s8, int8x16_t, int8x16_t, int8x16_t, uint8x16_t) + +/* +** test_vqtbx1q_u8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx1q_u8, uint8x16_t, uint8x16_t, uint8x16_t, uint8x16_t) + +/* +** test_vqtbx1q_p8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx1q_p8, poly8x16_t, poly8x16_t, poly8x16_t, uint8x16_t) + +/* +** test_vqtbx1q_mf8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx1q_mf8, mfloat8x16_t, mfloat8x16_t, mfloat8x16_t, uint8x16_t) + +/* +** test_vqtbx2q_s8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx2q_s8, int8x16_t, int8x16_t, int8x16x2_t, uint8x16_t) + +/* +** test_vqtbx2q_u8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx2q_u8, uint8x16_t, uint8x16_t, uint8x16x2_t, uint8x16_t) + +/* +** test_vqtbx2q_p8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx2q_p8, poly8x16_t, poly8x16_t, poly8x16x2_t, uint8x16_t) + +/* +** test_vqtbx2q_mf8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx2q_mf8, mfloat8x16_t, mfloat8x16_t, mfloat8x16x2_t, uint8x16_t) + +/* +** test_vqtbx3q_s8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx3q_s8, int8x16_t, int8x16_t, int8x16x3_t, uint8x16_t) + +/* +** test_vqtbx3q_u8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx3q_u8, uint8x16_t, uint8x16_t, uint8x16x3_t, uint8x16_t) + +/* +** test_vqtbx3q_p8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx3q_p8, poly8x16_t, poly8x16_t, poly8x16x3_t, uint8x16_t) + +/* +** test_vqtbx3q_mf8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx3q_mf8, mfloat8x16_t, mfloat8x16_t, mfloat8x16x3_t, uint8x16_t) + +/* +** test_vqtbx4q_s8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx4q_s8, int8x16_t, int8x16_t, int8x16x4_t, uint8x16_t) + +/* +** test_vqtbx4q_u8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx4q_u8, uint8x16_t, uint8x16_t, uint8x16x4_t, uint8x16_t) + +/* +** test_vqtbx4q_p8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx4q_p8, poly8x16_t, poly8x16_t, poly8x16x4_t, uint8x16_t) + +/* +** test_vqtbx4q_mf8: +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b +** ret +*/ +TEST_TERNARY (vqtbx4q_mf8, mfloat8x16_t, mfloat8x16_t, mfloat8x16x4_t, uint8x16_t) diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vtbl.c b/gcc/testsuite/gcc.target/aarch64/neon/vtbl.c new file mode 100644 index 000000000000..903c9295075f --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vtbl.c @@ -0,0 +1,153 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vtbl1_s8: +** fmov d[0-9]+, d[0-9]+ +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl1_s8, int8x8_t, int8x8_t, int8x8_t) + +/* +** test_vtbl1_u8: +** fmov d[0-9]+, d[0-9]+ +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl1_u8, uint8x8_t, uint8x8_t, uint8x8_t) + +/* +** test_vtbl1_p8: +** fmov d[0-9]+, d[0-9]+ +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl1_p8, poly8x8_t, poly8x8_t, uint8x8_t) + +/* +** test_vtbl1_mf8: +** fmov d[0-9]+, d[0-9]+ +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl1_mf8, mfloat8x8_t, mfloat8x8_t, uint8x8_t) + +/* +** test_vtbl2_s8: +** sub sp, sp, #16 +** stp d[0-9]+, d[0-9]+, \[sp\] +** ldr q[0-9]+, \[sp\] +** add sp, sp, 16 +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl2_s8, int8x8_t, int8x8x2_t, int8x8_t) + +/* +** test_vtbl2_u8: +** sub sp, sp, #16 +** stp d[0-9]+, d[0-9]+, \[sp\] +** ldr q[0-9]+, \[sp\] +** add sp, sp, 16 +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl2_u8, uint8x8_t, uint8x8x2_t, uint8x8_t) + +/* +** test_vtbl2_p8: +** sub sp, sp, #16 +** stp d[0-9]+, d[0-9]+, \[sp\] +** ldr q[0-9]+, \[sp\] +** add sp, sp, 16 +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl2_p8, poly8x8_t, poly8x8x2_t, uint8x8_t) + +/* +** test_vtbl2_mf8: +** sub sp, sp, #16 +** stp d[0-9]+, d[0-9]+, \[sp\] +** ldr q[0-9]+, \[sp\] +** add sp, sp, 16 +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl2_mf8, mfloat8x8_t, mfloat8x8x2_t, uint8x8_t) + +/* +** test_vtbl3_s8: +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** fmov d([0-9]+), d[0-9]+ +** tbl v[0-9]+\.8b, {v\1\.16b - v\2\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl3_s8, int8x8_t, int8x8x3_t, int8x8_t) + +/* +** test_vtbl3_u8: +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** fmov d([0-9]+), d[0-9]+ +** tbl v[0-9]+\.8b, {v\1\.16b - v\2\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl3_u8, uint8x8_t, uint8x8x3_t, uint8x8_t) + +/* +** test_vtbl3_p8: +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** fmov d([0-9]+), d[0-9]+ +** tbl v[0-9]+\.8b, {v\1\.16b - v\2\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl3_p8, poly8x8_t, poly8x8x3_t, uint8x8_t) + +/* +** test_vtbl3_mf8: +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** fmov d([0-9]+), d[0-9]+ +** tbl v[0-9]+\.8b, {v\1\.16b - v\2\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl3_mf8, mfloat8x8_t, mfloat8x8x3_t, uint8x8_t) + +/* +** test_vtbl4_s8: +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl4_s8, int8x8_t, int8x8x4_t, int8x8_t) + +/* +** test_vtbl4_u8: +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl4_u8, uint8x8_t, uint8x8x4_t, uint8x8_t) + +/* +** test_vtbl4_p8: +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl4_p8, poly8x8_t, poly8x8x4_t, uint8x8_t) + +/* +** test_vtbl4_mf8: +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_BINARY (vtbl4_mf8, mfloat8x8_t, mfloat8x8x4_t, uint8x8_t) + diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vtbx.c b/gcc/testsuite/gcc.target/aarch64/neon/vtbx.c new file mode 100644 index 000000000000..71db06b801e7 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vtbx.c @@ -0,0 +1,178 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vtbx1_s8: +** fmov d[0-9]+, d[0-9]+ +** movi v[0-9]+\.8b, 0x7 +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** cmhs v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b +** bit v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vtbx1_s8, int8x8_t, int8x8_t, int8x8_t, int8x8_t) + +/* +** test_vtbx1_u8: +** fmov d[0-9]+, d[0-9]+ +** movi v[0-9]+\.8b, 0x7 +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** cmhs v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b +** bit v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vtbx1_u8, uint8x8_t, uint8x8_t, uint8x8_t, uint8x8_t) + +/* +** test_vtbx1_p8: +** fmov d[0-9]+, d[0-9]+ +** movi v[0-9]+\.8b, 0x7 +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** cmhs v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b +** bit v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vtbx1_p8, poly8x8_t, poly8x8_t, poly8x8_t, uint8x8_t) + +/* +** test_vtbx1_mf8: +** fmov d[0-9]+, d[0-9]+ +** movi v[0-9]+\.8b, 0x7 +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** cmhs v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b +** bit v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vtbx1_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x8_t, uint8x8_t) + + +/* +** test_vtbx2_s8: +** sub sp, sp, #16 +** stp d[0-9]+, d[0-9]+, \[sp\] +** ldr q[0-9]+, \[sp\] +** add sp, sp, 16 +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vtbx2_s8, int8x8_t, int8x8_t, int8x8x2_t, int8x8_t) + +/* +** test_vtbx2_u8: +** sub sp, sp, #16 +** stp d[0-9]+, d[0-9]+, \[sp\] +** ldr q[0-9]+, \[sp\] +** add sp, sp, 16 +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vtbx2_u8, uint8x8_t, uint8x8_t, uint8x8x2_t, uint8x8_t) + +/* +** test_vtbx2_p8: +** sub sp, sp, #16 +** stp d[0-9]+, d[0-9]+, \[sp\] +** ldr q[0-9]+, \[sp\] +** add sp, sp, 16 +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vtbx2_p8, poly8x8_t, poly8x8_t, poly8x8x2_t, uint8x8_t) + +/* +** test_vtbx2_mf8: +** sub sp, sp, #16 +** stp d[0-9]+, d[0-9]+, \[sp\] +** ldr q[0-9]+, \[sp\] +** add sp, sp, 16 +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vtbx2_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x8x2_t, uint8x8_t) + +/* +** test_vtbx3_s8: +** fmov d([0-9]+), d[0-9]+ +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** tbl v\2\.8b, {v\2\.16b - v\1\.16b}, v[0-9]+\.8b +** movi v\1\.8b, 0x17 +** cmhs v\1\.8b, v\1\.8b, v[0-9]+\.8b +** bit v[0-9]+\.8b, v\2\.8b, v\1\.8b +** ret +*/ +TEST_TERNARY (vtbx3_s8, int8x8_t, int8x8_t, int8x8x3_t, int8x8_t) + +/* +** test_vtbx3_u8: +** fmov d([0-9]+), d[0-9]+ +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** tbl v\2\.8b, {v\2\.16b - v\1\.16b}, v[0-9]+\.8b +** movi v\1\.8b, 0x17 +** cmhs v\1\.8b, v\1\.8b, v[0-9]+\.8b +** bit v[0-9]+\.8b, v\2\.8b, v\1\.8b +** ret +*/ +TEST_TERNARY (vtbx3_u8, uint8x8_t, uint8x8_t, uint8x8x3_t, uint8x8_t) + +/* +** test_vtbx3_p8: +** fmov d([0-9]+), d[0-9]+ +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** tbl v\2\.8b, {v\2\.16b - v\1\.16b}, v[0-9]+\.8b +** movi v\1\.8b, 0x17 +** cmhs v\1\.8b, v\1\.8b, v[0-9]+\.8b +** bit v[0-9]+\.8b, v\2\.8b, v\1\.8b +** ret +*/ +TEST_TERNARY (vtbx3_p8, poly8x8_t, poly8x8_t, poly8x8x3_t, uint8x8_t) + +/* +** test_vtbx3_mf8: +** fmov d([0-9]+), d[0-9]+ +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** tbl v\2\.8b, {v\2\.16b - v\1\.16b}, v[0-9]+\.8b +** movi v\1\.8b, 0x17 +** cmhs v\1\.8b, v\1\.8b, v[0-9]+\.8b +** bit v[0-9]+\.8b, v\2\.8b, v\1\.8b +** ret +*/ +TEST_TERNARY (vtbx3_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x8x3_t, uint8x8_t) + +/* +** test_vtbx4_s8: +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vtbx4_s8, int8x8_t, int8x8_t, int8x8x4_t, int8x8_t) + +/* +** test_vtbx4_u8: +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vtbx4_u8, uint8x8_t, uint8x8_t, uint8x8x4_t, uint8x8_t) + +/* +** test_vtbx4_p8: +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vtbx4_p8, poly8x8_t, poly8x8_t, poly8x8x4_t, uint8x8_t) + +/* +** test_vtbx4_mf8: +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b +** ret +*/ +TEST_TERNARY (vtbx4_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x8x4_t, uint8x8_t) + diff --git a/gcc/testsuite/gcc.target/aarch64/simd/mf8_data_1.c b/gcc/testsuite/gcc.target/aarch64/simd/mf8_data_1.c index e440b899f597..eddb548d7cf8 100644 --- a/gcc/testsuite/gcc.target/aarch64/simd/mf8_data_1.c +++ b/gcc/testsuite/gcc.target/aarch64/simd/mf8_data_1.c @@ -1397,8 +1397,11 @@ mfloat8x8_t test_tbl1(mfloat8x8_t a, uint8x8_t b) /* ** test_tbl2: -** zip1 v([0-9]+).2d, v0.2d, v1.2d +** sub sp, sp, #16 +** stp d0, d1, \[sp\] +** ldr q([0-9]+), \[sp\] ** tbl v0.8b, {v\1.16b}, v2.8b +** add sp, sp, 16 ** ret */ mfloat8x8_t test_tbl2(mfloat8x8x2_t a, uint8x8_t b) @@ -1526,8 +1529,11 @@ mfloat8x8_t test_tbx1(mfloat8x8_t a, mfloat8x8_t b, uint8x8_t c) /* ** test_tbx2: -** zip1 v([0-9]+).2d, v1.2d, v2.2d -** tbx v[0-9]+.8b, {v\1.16b}, v3.8b +** sub sp, sp, #16 +** stp d1, d2, \[sp\] +** ldr q([0-9]+), \[sp\] +** tbx v0.8b, {v\1.16b}, v3.8b +** add sp, sp, 16 ** ret */ mfloat8x8_t test_tbx2(mfloat8x8_t a, mfloat8x8x2_t b, uint8x8_t c) -- 2.43.0 From giuliano.belinassi@gmail.com Mon Nov 2 15:52:52 2026 From: giuliano.belinassi@gmail.com (Giuliano Belinassi) Date: Mon, 2 Nov 2026 16:52:52 +0100 Subject: [PATCH] Call symtab_node::get_create when it is suitable Message-ID: <20261102155252.2392802-1-giuliano.belinassi@suse.com> In many cases the original code checked if the decl is a variable or a function and forward the call to either varpool_node::get_create or cgraph_node::get_create. However, there is an API already for checking that: symtab_node::get_create. Hence, modify the code for the cases where this is suitable. gcc/ChangeLog: * cgraphunit.cc (symbol_table::process_same_body_aliases): Call symtab_node::get_create. * tree.cc (set_decl_section_name): Likewise. (decl_init_priority_insert): Likewise. * varasm.cc (assemble_alias): Likewise. (make_decl_one_only): Likewise. gcc/cp/ChangeLog: * decl.cc (duplicate_decls): Call symtab_node::get_create. Signed-off-by: Giuliano Belinassi --- gcc/cgraphunit.cc | 5 +---- gcc/cp/decl.cc | 5 +---- gcc/tree.cc | 14 +++----------- gcc/varasm.cc | 10 ++-------- 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc index b77f082757b..61944a9d661 100644 --- a/gcc/cgraphunit.cc +++ b/gcc/cgraphunit.cc @@ -727,10 +727,7 @@ symbol_table::process_same_body_aliases (void) symtab_node *node; FOR_EACH_SYMBOL (node) if (node->cpp_implicit_alias && !node->analyzed) - node->resolve_alias - (VAR_P (node->alias_target) - ? (symtab_node *)varpool_node::get_create (node->alias_target) - : (symtab_node *)cgraph_node::get_create (node->alias_target)); + node->resolve_alias (symtab_node::get_create (node->alias_target)); cpp_implicit_aliases_done = true; } diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 16ce7cd36b0..7243c8a3caa 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -3573,10 +3573,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) if (DECL_ONE_ONLY (newdecl)) { struct symtab_node *oldsym, *newsym; - if (TREE_CODE (olddecl) == FUNCTION_DECL) - oldsym = cgraph_node::get_create (olddecl); - else - oldsym = varpool_node::get_create (olddecl); + oldsym = symtab_node::get_create (olddecl); newsym = symtab_node::get (newdecl); oldsym->set_comdat_group (newsym->get_comdat_group ()); } diff --git a/gcc/tree.cc b/gcc/tree.cc index 7e5a53234ba..2e46b4bcdaa 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -1024,10 +1024,8 @@ set_decl_section_name (tree node, const char *value) if (!snode) return; } - else if (VAR_P (node)) - snode = varpool_node::get_create (node); else - snode = cgraph_node::get_create (node); + snode = symtab_node::get_create (node); snode->set_section (value); } @@ -1042,11 +1040,7 @@ set_decl_section_name (tree decl, const_tree other) struct symtab_node *other_node = symtab_node::get (other); if (other_node) { - struct symtab_node *decl_node; - if (VAR_P (decl)) - decl_node = varpool_node::get_create (decl); - else - decl_node = cgraph_node::get_create (decl); + struct symtab_node *decl_node = symtab_node::get_create (decl); decl_node->set_section (*other_node); } else @@ -6077,10 +6071,8 @@ decl_init_priority_insert (tree decl, priority_type priority) if (!snode) return; } - else if (VAR_P (decl)) - snode = varpool_node::get_create (decl); else - snode = cgraph_node::get_create (decl); + snode = symtab_node::get_create (decl); snode->set_init_priority (priority); } diff --git a/gcc/varasm.cc b/gcc/varasm.cc index 7ce5032a6cb..0c5f80165e9 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -6687,10 +6687,7 @@ assemble_alias (tree decl, tree target) TREE_USED (decl) = 1; /* Allow aliases to aliases. */ - if (TREE_CODE (decl) == FUNCTION_DECL) - cgraph_node::get_create (decl)->alias = true; - else - varpool_node::get_create (decl)->alias = true; + symtab_node::get_create (decl)->alias = true; /* If the target has already been emitted, we don't have to queue the alias. This saves a tad of memory. */ @@ -6938,10 +6935,7 @@ make_decl_one_only (tree decl, tree comdat_group) TREE_PUBLIC (decl) = 1; - if (VAR_P (decl)) - symbol = varpool_node::get_create (decl); - else - symbol = cgraph_node::get_create (decl); + symbol = symtab_node::get_create (decl); if (SUPPORTS_ONE_ONLY) { -- 2.56.0 From jwakely@redhat.com Mon Nov 2 15:54:18 2026 From: jwakely@redhat.com (Jonathan Wakely) Date: Mon, 2 Nov 2026 15:54:18 +0000 Subject: [PATCH 3/3] libstdc++: Fix another buffer overflow in basic_filebuf::overflow [PR118099] In-Reply-To: References: <20261023174023.845748-1-jwakely@redhat.com> <20261023174023.845748-3-jwakely@redhat.com> Message-ID: On Mon, 2 Nov 2026 at 15:30, Tomasz Kaminski wrote: > > > > On Fri, Oct 23, 2026 at 7:43?PM Jonathan Wakely wrote: >> >> The initial fix for PR 118099 handled the case where writing the pending >> output sequence to the external file failed and _M_convert_to_external >> returned false. But _M_convert_to_external can also fail by throwing an >> exception in which case the same bug exists: the put area's next pointer >> (i.e. pptr) has already been advanced and is not rewound when >> basic_filebuf::overflow exits via an exception. As in the PR 118099 >> testcase, the caller is left with pptr set past epptr, and successive >> calls to overflow will write further past the end of the managed buffer >> with each failure. > > This should go to _Guard 1/3 commit, as it will be also fixed. >> >> >> This commit fixes it by not advancing the put area's next pointer at >> all, instead we just increment the size passed to _M_convert_to_external >> to account for the extra character in the put area. This relies on the >> previous commit which changed _M_convert_to_external to no longer use >> pptr() internally (when retrying after a partial codecvt conversion). >> If _M_convert_to_external was still looking at pptr() directly and >> expecting it to have been bumped then we could not change overflow to no >> longer bump it. >> >> Because this change depends on that fix in _M_convert_to_external there >> is a potential ABI issue that needs care. If the new bump-less version >> of basic_filebuf::overflow gets inlined into a translation unit but the >> linker resolves its call to _M_convert_to_external to an old definition >> that still calls pptr(), we would not transfer the overflow character to >> the external file when retrying after a partial conversion. Although >> this scenario seems unlikely because std::filebuf and std::wfilebuf are >> both explicitly instantiated in libstdc++.so (and the explicit >> instantiations use the new definition of _M_convert_to_external) it >> would be safer to ensure the problem cannot occur. >> >> This commit adds an _M_convert_to_external(const _CharT*, streamsize) >> overload which takes a const pointer, and changes overflow to use that >> instead. This ensures that the new bump-less overflow uses a new symbol >> with the new behaviour, and will never bind to an old definition that >> inspects pptr(). The old overload taking a non-const pointer needs to be >> preserved for ABI compatibility, but can be defined to simply forward >> its arguments (after a const_cast) to the new overload. With this >> change, instantiations of the old version of overflow can safely bind to >> either the old definition of _M_convert_to_external (which calls pptr()) >> or the new definition (which doesn't) because both definitions are >> compatible with the old overflow. Instantiations of the new version of >> overflow will only ever bind to the new overload because it has a >> different mangled name. >> >> The failing_codecvt in the new test was generated by an LLM because I >> was too lazy to remember how to write codecvt facets. >> >> Assisted-by: LLM >> >> libstdc++-v3/ChangeLog: >> >> PR libstdc++/118099 >> * config/abi/pre/gnu.ver: Tighten old patterns for basic_filebuf >> and export new symbols. >> * include/bits/fstream.tcc (basic_filebuf::overflow): Do not >> bump the next pointer for the overflow character. Pass const >> pointers to _M_convert_to_external. >> (_M_convert_to_external(_CharT*, streamsize)): Forward to new >> overload. >> (_M_convert_to_external(const _CharT*, streamsize)): Define new >> overload. >> * include/std/fstream (_M_convert_to_external): Define new >> overload and suppress old overload for _GLIBCXX_INLINE_VERSION. >> * testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc: >> New test. >> * testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc: >> New test. >> --- >> >> Tested x86_64-linux. > > Some minor comments, looks good to me with them fixed. >> >> >> libstdc++-v3/config/abi/pre/gnu.ver | 7 +- >> libstdc++-v3/include/bits/fstream.tcc | 120 +++++++++--------- >> libstdc++-v3/include/std/fstream | 7 +- >> .../overflow/char/118099-codecvt.cc | 76 +++++++++++ >> .../overflow/wchar_t/118099-codecvt.cc | 76 +++++++++++ >> 5 files changed, 224 insertions(+), 62 deletions(-) >> create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc >> create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc >> >> diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver >> index 4fbb87acee3f..d846ce6d3e36 100644 >> --- a/libstdc++-v3/config/abi/pre/gnu.ver >> +++ b/libstdc++-v3/config/abi/pre/gnu.ver >> @@ -434,7 +434,9 @@ GLIBCXX_3.4 { >> _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE15*; >> _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE16*; >> _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE19*; >> - _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE2*; >> + _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE22_M_convert_to_externalEP[cw][ilx]; >> + _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE26_M_destroy_internal_buffer*; >> + _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE27_M_allocate_internal_buffer*; >> _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE3*; >> _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE4openEPKc*; >> _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE4sync*; >> @@ -2641,6 +2643,9 @@ GLIBCXX_3.4.37 { >> _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE*_S_allocate_*; >> _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE*_M_create_*; >> >> + # basic_filebuf::_M_convert_to_external(const C*, streamsize) >> + _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE22_M_convert_to_externalEPK[cw][ilx]; >> + >> } GLIBCXX_3.4.36; >> >> # Symbols in the support library (libsupc++) have their own tag. >> diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc >> index 5d13633b6841..427e7b3a0c43 100644 >> --- a/libstdc++-v3/include/bits/fstream.tcc >> +++ b/libstdc++-v3/include/bits/fstream.tcc >> @@ -561,23 +561,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >> } >> if (this->pbase() < this->pptr()) >> { >> + streamsize __n = this->pptr() - this->pbase(); >> + >> // If appropriate, append the overflow char. >> if (!__testeof) >> { >> *this->pptr() = traits_type::to_char_type(__c); >> - this->pbump(1); >> + ++__n; >> } >> >> + // This must be const _CharT* to call the right overload. >> + const _CharT* __p = this->pbase(); > > The overload based on cost is sneaky here, but I do not have much better idea. >> >> + >> // Convert pending sequence to external representation, >> - // and output. >> - if (_M_convert_to_external(this->pbase(), >> - this->pptr() - this->pbase())) >> + // and output. Include the overflow char if appropriate. >> + if (_M_convert_to_external(__p, __n)) >> { >> _M_set_buffer(0); >> __ret = traits_type::not_eof(__c); >> } >> - else if (!__testeof) >> - this->pbump(-1); >> } >> else if (_M_buf_size > 1) >> { >> @@ -596,7 +598,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >> else >> { >> // Unbuffered. >> - char_type __conv = traits_type::to_char_type(__c); >> + const char_type __conv = traits_type::to_char_type(__c); > > Could you add a comment here, about selecting overloads? >> >> if (__testeof || _M_convert_to_external(&__conv, 1)) >> { >> _M_writing = true; >> @@ -607,65 +609,63 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >> return __ret; >> } >> >> + template >> + bool >> + basic_filebuf<_CharT, _Traits>:: >> + _M_convert_to_external(const _CharT* __ibuf, streamsize __ilen) >> + { >> + if (__check_facet(_M_codecvt).always_noconv()) >> + return _M_file.xsputn(reinterpret_cast(__ibuf), __ilen) >> + == __ilen; >> + >> + // Worst-case number of external bytes needed. >> + // XXX Not done encoding() == -1. >> + const streamsize __maxlen = __ilen * _M_codecvt->max_length(); >> + char* const __buf = static_cast(__builtin_alloca(__maxlen)); >> + streamsize __blen = __maxlen; >> + >> + char* __bend; >> + const char_type* __iend; >> + codecvt_base::result __r; >> + __r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen, >> + __iend, __buf, __buf + __blen, __bend); >> + __blen = __bend - __buf; >> + >> + if (__r == codecvt_base::ok) >> + return _M_file.xsputn(__buf, __blen) == __blen; >> + else if (__r == codecvt_base::noconv) >> + return _M_file.xsputn(reinterpret_cast(__ibuf), __ilen) >> + == __ilen; >> + else if (__r == codecvt_base::error) >> + __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " >> + "conversion error")); >> + >> + // Conversion was partial, some output is in __buf. >> + if (_M_file.xsputn(__buf, __blen) != __blen) >> + return false; >> + >> + // Try once more for partial conversions. >> + __r = _M_codecvt->out(_M_state_cur, __iend, __ibuf + __ilen, >> + __iend, __buf, __buf + __maxlen, __bend); >> + >> + if (__r == codecvt_base::error) >> + __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " >> + "conversion error")); >> + >> + __blen = __bend - __buf; >> + return _M_file.xsputn(__buf, __blen) == __blen; >> + } >> + >> +#if ! _GLIBCXX_INLINE_VERSION >> + // Prior to GCC 17 basic_filebuf::overflow called this overload. >> template >> bool >> basic_filebuf<_CharT, _Traits>:: >> _M_convert_to_external(_CharT* __ibuf, streamsize __ilen) >> { >> - // Sizes of external and pending output. >> - streamsize __elen; >> - streamsize __plen; >> - if (__check_facet(_M_codecvt).always_noconv()) >> - { >> - __elen = _M_file.xsputn(reinterpret_cast(__ibuf), __ilen); >> - __plen = __ilen; >> - } >> - else >> - { >> - // Worst-case number of external bytes needed. >> - // XXX Not done encoding() == -1. >> - streamsize __blen = __ilen * _M_codecvt->max_length(); >> - char* __buf = static_cast(__builtin_alloca(__blen)); >> - >> - char* __bend; >> - const char_type* __iend; >> - codecvt_base::result __r; >> - __r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen, >> - __iend, __buf, __buf + __blen, __bend); >> - >> - if (__r == codecvt_base::ok || __r == codecvt_base::partial) >> - __blen = __bend - __buf; >> - else if (__r == codecvt_base::noconv) >> - { >> - // Same as the always_noconv case above. >> - __buf = reinterpret_cast(__ibuf); >> - __blen = __ilen; >> - } >> - else >> - __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " >> - "conversion error")); >> - >> - __elen = _M_file.xsputn(__buf, __blen); >> - __plen = __blen; >> - >> - // Try once more for partial conversions. >> - if (__r == codecvt_base::partial && __elen == __plen) >> - { >> - __r = _M_codecvt->out(_M_state_cur, __iend, __ibuf + __ilen, >> - __iend, __buf, __buf + __blen, __bend); >> - if (__r != codecvt_base::error) >> - { >> - const streamsize __rlen = __bend - __buf; >> - __elen = _M_file.xsputn(__buf, __rlen); >> - __plen = __rlen; >> - } >> - else >> - __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " >> - "conversion error")); >> - } >> - } >> - return __elen == __plen; >> + return _M_convert_to_external(const_cast(__ibuf), __ilen); > > I do not think that const_cast is needed here, we are only adding const. Without the cast the call becomes recursive. > Since we are only adding const, > single return, I would define this function inline in the fstream class body. That should not affect if the symbol > is emitted from the extern template specialization, and we are never calling it, so it should not be emmitted. Yes, I can do that. We still need a cast though. >> >> } >> +#endif >> >> template >> streamsize >> diff --git a/libstdc++-v3/include/std/fstream b/libstdc++-v3/include/std/fstream >> index 653d417c6288..9549638205ad 100644 >> --- a/libstdc++-v3/include/std/fstream >> +++ b/libstdc++-v3/include/std/fstream >> @@ -436,10 +436,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >> virtual int_type >> overflow(int_type __c = _Traits::eof()); >> >> - // Convert internal byte sequence to external, char-based >> + // Convert internal _CharT sequence to external, char-based >> // sequence via codecvt. >> + bool >> + _M_convert_to_external(const char_type*, streamsize); >> + >> +#if ! _GLIBCXX_INLINE_VERSION // ABI compat >> bool >> _M_convert_to_external(char_type*, streamsize); >> +#endif >> >> /** >> * @brief Manipulates the buffer. >> diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc >> new file mode 100644 >> index 000000000000..99645e810975 >> --- /dev/null >> +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc > > This test should be also moved to first _Guard commit. >> >> @@ -0,0 +1,76 @@ >> +// { dg-do run } >> +// { dg-require-fileio "" } >> + >> +// PR libstdc++/118099 >> +// basic_filebuf::overflow leaves streambuf in inconsistent state on I/O error >> +// >> +// Companion test of 118099.cc testing the throwing failure path in overflow: >> +// a codecvt whose do_out always returns error makes _M_convert_to_external >> +// throw after the overflow character has been written to the end of put area. >> +// If the put pointer is advanced before the throw (and only rewound on the >> +// non-throwing error path), a caller that catches the exception and keeps >> +// writing will cause overflow(c) to write past the end of the managed buffer, >> +// just like the original PR libstdc++/118099 testcase. >> + >> +#include >> +#include >> +#include >> + >> +typedef char C; >> + >> +struct failing_codecvt : std::codecvt >> +{ >> +protected: >> + result >> + do_out(state_type&, const intern_type* from, const intern_type*, >> + const intern_type*& from_next, >> + extern_type* to, extern_type*, extern_type*& to_next) const >> + { >> + from_next = from; >> + to_next = to; >> + return error; >> + } >> + >> + bool do_always_noconv() const throw() { return false; } >> +}; >> + >> +static void >> +test_pr118099_codecvt() >> +{ >> + const C val = C('x'); >> + const C canary = ~val; >> + const int N = 16; >> + C buf[N]; >> + for (int i = 0; i < N; ++i) >> + buf[i] = canary; >> + >> + std::basic_filebuf fb; >> + fb.pubimbue(std::locale(std::locale::classic(), new failing_codecvt)); >> + fb.pubsetbuf(buf, N/2); // filebuf can use buf[0..7] >> + fb.open("tmp_118099_codecvt", std::ios_base::out | std::ios_base::trunc); >> + VERIFY( fb.is_open() ); >> + >> + // Libstdc++ filebuf throws ios::failure for the codecvt error, >> + // but the standard allows overflow to return eof instead. >> + // To make this test portable, we check for either kind of error. >> + bool got_error = false; >> + for (int i = 0; i < N; ++i) > > I would again split this into two separate loops: one up to N/2, if we do not > get eof. And a second loop counting errors, and verifying there are N/2 of them. >> >> + try { >> + std::char_traits::int_type r = fb.sputc(val); >> + if (std::char_traits::eq_int_type(r, std::char_traits::eof())) >> + got_error = true; >> + } catch (const std::exception&) { >> + got_error = true; >> + } >> + VERIFY( got_error ); // a codecvt error actually happened >> + >> + for (int i = 0; i < N/2; ++i) >> + VERIFY( buf[i] == val ); >> + for (int i = N/2; i < N; ++i) >> + VERIFY( buf[i] == canary ); // nothing was written past buf[0..7] >> +} >> + >> +int main() >> +{ >> + test_pr118099_codecvt(); >> +} >> diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc >> new file mode 100644 >> index 000000000000..27420006fada >> --- /dev/null >> +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc >> @@ -0,0 +1,76 @@ >> +// { dg-do run } >> +// { dg-require-fileio "" } >> + >> +// PR libstdc++/118099 >> +// basic_filebuf::overflow leaves streambuf in inconsistent state on I/O error >> +// >> +// Companion test of 118099.cc testing the throwing failure path in overflow: >> +// a codecvt whose do_out always returns error makes _M_convert_to_external >> +// throw after the overflow character has been written to the end of put area. >> +// If the put pointer is advanced before the throw (and only rewound on the >> +// non-throwing error path), a caller that catches the exception and keeps >> +// writing will cause overflow(c) to write past the end of the managed buffer, >> +// just like the original PR libstdc++/118099 testcase. >> + >> +#include >> +#include >> +#include >> + >> +typedef wchar_t C; >> + >> +struct failing_codecvt : std::codecvt >> +{ >> +protected: >> + result >> + do_out(state_type&, const intern_type* from, const intern_type*, >> + const intern_type*& from_next, >> + extern_type* to, extern_type*, extern_type*& to_next) const >> + { >> + from_next = from; >> + to_next = to; >> + return error; >> + } >> + >> + bool do_always_noconv() const throw() { return false; } >> +}; >> + >> +static void >> +test_pr118099_codecvt() >> +{ >> + const C val = C('x'); >> + const C canary = ~val; >> + const int N = 16; >> + C buf[N]; >> + for (int i = 0; i < N; ++i) >> + buf[i] = canary; >> + >> + std::basic_filebuf fb; >> + fb.pubimbue(std::locale(std::locale::classic(), new failing_codecvt)); >> + fb.pubsetbuf(buf, N/2); // filebuf can use buf[0..7] >> + fb.open("tmp_118099_codecvt", std::ios_base::out | std::ios_base::trunc); >> + VERIFY( fb.is_open() ); >> + >> + // Libstdc++ filebuf throws ios::failure for the codecvt error, >> + // but the standard allows overflow to return eof instead. >> + // To make this test portable, we check for either kind of error. >> + bool got_error = false; >> + for (int i = 0; i < N; ++i) >> + try { >> + std::char_traits::int_type r = fb.sputc(val); >> + if (std::char_traits::eq_int_type(r, std::char_traits::eof())) >> + got_error = true; >> + } catch (const std::exception&) { >> + got_error = true; >> + } >> + VERIFY( got_error ); // a codecvt error actually happened >> + >> + for (int i = 0; i < N/2; ++i) >> + VERIFY( buf[i] == val ); >> + for (int i = N/2; i < N; ++i) >> + VERIFY( buf[i] == canary ); // nothing was written past buf[0..7] >> +} >> + >> +int main() >> +{ >> + test_pr118099_codecvt(); >> +} >> -- >> 2.56.0 >> From sloosemore@baylibre.com Mon Nov 2 16:03:42 2026 From: sloosemore@baylibre.com (Sandra Loosemore) Date: Mon, 2 Nov 2026 09:03:42 -0700 Subject: [PATCH] docs: Attempt to clarify complex literal suffixes [PR112960] In-Reply-To: <0e665624-31c2-ca15-5ec5-8f1dace36e8b@pfeifer.com> References: <2fd88fbb-f9dc-412a-b789-38a1dc234cce@baylibre.com> <0e665624-31c2-ca15-5ec5-8f1dace36e8b@pfeifer.com> Message-ID: On 10/25/26 14:48, Gerald Pfeifer wrote: > On Fri, 7 Mar 2025, Jakub Jelinek wrote: >> 2025-03-07 Jakub Jelinek >> >> PR c/112960 >> PR c/117029 >> * extend.texi (Complex): Add I and J suffixes to the list of >> complex suffixes, adjust for all of those being part of ISO C2Y, >> clarify that for -fno-ext-numeric-literals none of those are >> recognized as GNU extensions and for C++14 i is considered UDL >> even for -fext-numeric-literals when is included. > > On Fri, 7 Mar 2025, Sandra Loosemore wrote: >> Thanks for helping straighten this out! > > Indeed! > >> OK with those changes. > > How about the following additional tweaks? > > (Essentially Oxford commas, "pure -> purely", "or" -> "and" in one case, > "but" -> "and" in another to make things a bit smoother.) > > Gerald > > > >>From e24134917a9e7a24af438e52a8554e5ad6c68482 Mon Sep 17 00:00:00 2001 > From: Gerald Pfeifer > Date: Sat, 24 Oct 2026 18:14:10 +0200 > Subject: [PATCH] doc: Refine description of imaginary constants > > gcc: > PR c/112960 > PR c/117029 > * doc/extend.texi (Complex): Refine description of imaginary > constants. > --- > gcc/doc/extend.texi | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi > index a511ffe66a8..827876e78ee 100644 > --- a/gcc/doc/extend.texi > +++ b/gcc/doc/extend.texi > @@ -118,11 +118,11 @@ have real and imaginary parts of type @code{short int}; this is not > likely to be useful, but it shows that the set of complex types is > complete. > > -To write a constant with a complex data type, use the suffix @samp{i}, > -@samp{I}, @samp{j} or @samp{J} (any one; they are equivalent). For > +To write a constant with a complex data type, use any of the suffixes > +@samp{i}, @samp{I}, @samp{j}, or @samp{J} (which are equivalent). For > example, @code{2.5fi} has type @code{_Complex float} and @code{3i} has type > -@code{_Complex int}. Such a constant always has a pure imaginary > -value, but you can form any complex value you like by adding one to a > +@code{_Complex int}. Such a constant always has a purely imaginary > +value, and you can form any complex value you like by adding it to a > real constant. This is part of ISO C2Y and for older C revisions > a GNU extension. If you have an ISO C99 conforming C library > (such as the GNU C Library), and want to construct complex > @@ -134,7 +134,7 @@ For C++ if @code{-fext-numeric-literals} option is enabled, it is also > a GNU extension, otherwise it is handled like any other C++ user-defined > literal. The ISO C++14 library also defines the @samp{i} suffix, so C++14 > code that includes the @samp{} header cannot use @samp{i} for the > -GNU extension. The @samp{I}, @samp{j} or @samp{J} suffixes still have > +GNU extension. The @samp{I}, @samp{j}, and @samp{J} suffixes still have > the GNU meaning. > > GCC handles both implicit and explicit casts between the Looks fine to me. Thanks. -Sandra From mmalcomson@nvidia.com Mon Nov 2 16:25:10 2026 From: mmalcomson@nvidia.com (mmalcomson@nvidia.com) Date: Mon, 2 Nov 2026 16:25:10 +0000 Subject: [PATCH 0/4] Nits & testsuite updates OpenMP barrier patches In-Reply-To: <20261012170038.3418851-1-mmalcomson@nvidia.com> References: <20261012170038.3418851-1-mmalcomson@nvidia.com> Message-ID: <20261102162514.3475056-1-mmalcomson@nvidia.com> From: Matthew Malcomson Hi there, After applying the nits that Jakub requested I figured it worth double-checking that the names still seem sensible to others. Similarly I've removed the linux_futex_waitv effective target requests on those testcases that my agent believes cover untested areas in existing targets -- done after Thomas raised the question here: https://gcc.gnu.org/pipermail/gcc-patches/2026-October/736854.html To highlight the name changes: 1) I switched from `gomp_barrier_state_is_incremented` to `gomp_barrier_incremented`. This manages to avoid the need to leave the opening parenthesis on quite a few assertions. 2) I switched the function names using `centralized` to use `central`. N.b. I did not change the environment variable setting in the same way since searching the web for "centralized barrier" comes up with the algorithm this barrier uses while searching for "central barrier" does not. Figured the longer name was easier for users. 3) Switching `gomp_barrier_canc_wait` to `gomp_barrier_wait_n`. Again, helps with formatting to avoid the opening parenthesis at the end of the line in some calls. Things I'd like to double-check with others: 1) Are these function names OK with people? Since I was trying to address style nits I figured I should check I wasn't introducing other style nits before pushing. 2) Does the decision around the linux_futex_waitv effective target seem good to others? Have re-tested to avoid any typo problems etc. Matthew Malcomson (4): libgomp: Inline `gomp_barrier_is_incremented` libgomp: New barriers in new linux/futex_waitv target libgomp: Add focused barrier and team-lifecycle tests libgomp: Parallelise thread {re-,}initialisation libgomp/barrier.c | 8 +- libgomp/config/gcn/bar.c | 46 +- libgomp/config/gcn/bar.h | 71 +- libgomp/config/gcn/team.c | 3 +- libgomp/config/linux/bar.c | 50 +- libgomp/config/linux/bar.h | 72 +- libgomp/config/linux/futex_waitv/bar.c | 1045 +++++++++++++++++ libgomp/config/linux/futex_waitv/bar.h | 496 ++++++++ .../config/linux/futex_waitv/futex_waitv.h | 67 ++ libgomp/config/linux/futex_waitv/simple-bar.h | 66 ++ libgomp/config/linux/wait.h | 11 +- libgomp/config/nvptx/bar.c | 36 +- libgomp/config/nvptx/bar.h | 68 +- libgomp/config/nvptx/team.c | 3 +- libgomp/config/posix/bar.c | 37 +- libgomp/config/posix/bar.h | 65 +- libgomp/config/posix/pool.h | 1 + libgomp/config/posix/simple-bar.h | 12 +- libgomp/config/rtems/bar.h | 70 +- libgomp/configure | 82 +- libgomp/configure.ac | 39 + libgomp/configure.tgt | 32 +- libgomp/env.c | 59 +- libgomp/libgomp.h | 77 +- libgomp/libgomp.texi | 107 +- libgomp/single.c | 4 +- libgomp/task.c | 46 +- libgomp/team.c | 563 +++++++-- libgomp/testsuite/lib/libgomp.exp | 8 +- libgomp/testsuite/libgomp-site-extra.exp.in | 1 + .../testsuite/libgomp.c++/task-reduction-20.C | 136 +++ .../testsuite/libgomp.c++/task-reduction-21.C | 140 +++ .../gomp-barrier-type-env-auto.c | 11 + .../gomp-barrier-type-env-flat.c | 11 + .../gomp-barrier-type-env-mixed-1.c | 12 + .../gomp-barrier-type-env-mixed-2.c | 12 + .../gomp-barrier-type-env-mixed-3.c | 12 + .../gomp-barrier-type-env-mixed-4.c | 12 + .../gomp-barrier-type-env-unset.c | 10 + .../gomp-barrier-type-env.c | 11 + .../libgomp.c/artificial-team-pause.c | 45 + .../libgomp.c/barrier-copyprivate-task.c | 157 +++ .../libgomp.c/barrier-nested-team-id.c | 78 ++ .../testsuite/libgomp.c/barrier-switch-1.c | 141 +++ .../libgomp.c/barrier-task-reduction.c | 64 + .../testsuite/libgomp.c/barrier-tree-flush.c | 58 + .../testsuite/libgomp.c/barrier-tree-task.c | 136 +++ .../libgomp.c/barrier-workshare-task.c | 102 ++ .../libgomp.c/barrier_generation_overflow.c | 88 ++ .../libgomp.c/cancel-late-arrival-1.c | 132 +++ .../libgomp.c/cancel-late-arrival-2.c | 8 + .../libgomp.c/cancel-next-epoch-wrap.c | 87 ++ .../libgomp.c/cancel_in_implicit_barrier.c | 115 ++ ...n_implicit_barrier_while_primary_waiting.c | 70 ++ .../libgomp.c/cancel_incr_wraparound.c | 94 ++ .../libgomp.c/futex_waitv_overflow.c | 37 + .../libgomp.c/primary-thread-tasking.c | 80 ++ libgomp/testsuite/libgomp.c/team-held-pause.c | 43 + .../libgomp.c/team-held-pthread-exit.c | 56 + libgomp/work.c | 9 +- 60 files changed, 4842 insertions(+), 370 deletions(-) create mode 100644 libgomp/config/linux/futex_waitv/bar.c create mode 100644 libgomp/config/linux/futex_waitv/bar.h create mode 100644 libgomp/config/linux/futex_waitv/futex_waitv.h create mode 100644 libgomp/config/linux/futex_waitv/simple-bar.h create mode 100644 libgomp/testsuite/libgomp.c++/task-reduction-20.C create mode 100644 libgomp/testsuite/libgomp.c++/task-reduction-21.C create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-auto.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-flat.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-1.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-2.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-3.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-4.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-unset.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env.c create mode 100644 libgomp/testsuite/libgomp.c/artificial-team-pause.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-copyprivate-task.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-nested-team-id.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-switch-1.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-task-reduction.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-tree-flush.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-tree-task.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-workshare-task.c create mode 100644 libgomp/testsuite/libgomp.c/barrier_generation_overflow.c create mode 100644 libgomp/testsuite/libgomp.c/cancel-late-arrival-1.c create mode 100644 libgomp/testsuite/libgomp.c/cancel-late-arrival-2.c create mode 100644 libgomp/testsuite/libgomp.c/cancel-next-epoch-wrap.c create mode 100644 libgomp/testsuite/libgomp.c/cancel_in_implicit_barrier.c create mode 100644 libgomp/testsuite/libgomp.c/cancel_in_implicit_barrier_while_primary_waiting.c create mode 100644 libgomp/testsuite/libgomp.c/cancel_incr_wraparound.c create mode 100644 libgomp/testsuite/libgomp.c/futex_waitv_overflow.c create mode 100644 libgomp/testsuite/libgomp.c/primary-thread-tasking.c create mode 100644 libgomp/testsuite/libgomp.c/team-held-pause.c create mode 100644 libgomp/testsuite/libgomp.c/team-held-pthread-exit.c -- 2.43.0 From mmalcomson@nvidia.com Mon Nov 2 16:25:11 2026 From: mmalcomson@nvidia.com (mmalcomson@nvidia.com) Date: Mon, 2 Nov 2026 16:25:11 +0000 Subject: [PATCH 1/4] libgomp: Inline `gomp_barrier_is_incremented` In-Reply-To: <20261102162514.3475056-1-mmalcomson@nvidia.com> References: <20261012170038.3418851-1-mmalcomson@nvidia.com> <20261102162514.3475056-1-mmalcomson@nvidia.com> Message-ID: <20261102162514.3475056-2-mmalcomson@nvidia.com> From: Matthew Malcomson The function `gomp_barrier_state_is_incremented` is there in order to handle edge cases for when a generation gets incremented. It handles flags that might be on the generation number by checking `>` instead of `==` and it handles wraparound on the generation number. Unfortunately it had a problem where it did not handle the combination of flags on the state provided and wraparound on the generation number. I.e. if there were flags on the `state` input and the next generation would be *smaller* than the current generation due to unsigned integral overflow and hence wraparound then it could report that the generation has been incremented when it has not. While discussing that problem it was pointed out that the helper performs unnecessary checks because the barrier can only by incremented by one when this is used. In order to avoid this unnecessary work we explicitly check against one increment ahead (which naturally handles the overflow case). Moreover in the busy-wait loops of `*wait_*end` in bar.c we explicitly inline the helper to take advantage of our knowledge that `state` has no flags set on it. I found a testcase to take too long for it to be sensible to have in the testsuite. My impression is that it's so long that it doesn't even make sense to run it when the `run_expensive_tests` effective target is set but would appreciate confirmation or refutation of that. This is because it takes a long time to go through a barrier enough times to trigger wraparound. My manual testing on a shared machine showed ~4 min when on the linux/ target and drastically longer built without futex support to test the posix/ target. Testing done: - Bootstrap & regtest on aarch64 and x86_64. - Testsuite with & without OMP_WAIT_POLICY=passive - With and without configure `--enable-linux-futex=no` for posix target. - nvptx, gcn & rtems targets built. - Cross compilation & regtest on arm. libgomp/ChangeLog: * config/gcn/bar.c (gomp_team_barrier_wait_end): Inline increment check. (gomp_team_barrier_wait_cancel_end): Inline increment check. * config/gcn/bar.h (gomp_barrier_state_is_incremented): Remove function. (gomp_barrier_has_completed): Perform via equality check. * config/linux/bar.c (gomp_team_barrier_wait_end): Inline increment check. (gomp_team_barrier_wait_cancel_end): Inline increment check. * config/linux/bar.h (gomp_barrier_state_is_incremented): Remove function. (gomp_barrier_has_completed): Perform via equality check. * config/nvptx/bar.h (gomp_barrier_state_is_incremented): Remove function. (gomp_barrier_has_completed): Perform via equality check. * config/posix/bar.c (gomp_team_barrier_wait_end): Inline increment check. (gomp_team_barrier_wait_cancel_end): Inline increment check. * config/posix/bar.h (gomp_barrier_state_is_incremented): Remove function. (gomp_barrier_has_completed): Perform via equality check. * config/rtems/bar.h (gomp_barrier_state_is_incremented): Remove function. (gomp_barrier_has_completed): Perform via equality check. Signed-off-by: Matthew Malcomson --- libgomp/config/gcn/bar.c | 4 ++-- libgomp/config/gcn/bar.h | 13 ++----------- libgomp/config/linux/bar.c | 4 ++-- libgomp/config/linux/bar.h | 13 ++----------- libgomp/config/nvptx/bar.h | 13 ++----------- libgomp/config/posix/bar.c | 4 ++-- libgomp/config/posix/bar.h | 13 ++----------- libgomp/config/rtems/bar.h | 13 ++----------- 8 files changed, 16 insertions(+), 61 deletions(-) diff --git a/libgomp/config/gcn/bar.c b/libgomp/config/gcn/bar.c index 3045587f0f3..b4ea8e68a92 100644 --- a/libgomp/config/gcn/bar.c +++ b/libgomp/config/gcn/bar.c @@ -130,7 +130,7 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); } } - while (!gomp_barrier_state_is_incremented (gen, state)); + while ((gen & -BAR_INCR) != state + BAR_INCR); } void @@ -211,7 +211,7 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, gen = __atomic_load_n (&bar->generation, MEMMODEL_RELAXED); } } - while (!gomp_barrier_state_is_incremented (gen, state)); + while ((gen & -BAR_INCR) != state + BAR_INCR); return false; } diff --git a/libgomp/config/gcn/bar.h b/libgomp/config/gcn/bar.h index 6e838ff54a8..943bafc3551 100644 --- a/libgomp/config/gcn/bar.h +++ b/libgomp/config/gcn/bar.h @@ -168,20 +168,11 @@ gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) MEMMODEL_RELEASE); } -static inline bool -gomp_barrier_state_is_incremented (gomp_barrier_state_t gen, - gomp_barrier_state_t state) -{ - unsigned next_state = (state & -BAR_INCR) + BAR_INCR; - return next_state > state ? gen >= next_state : gen < state; -} - static inline bool gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar) { - /* Handling overflow in the generation. The "next" state could be less than - or greater than the current one. */ - return gomp_barrier_state_is_incremented (bar->generation, state); + unsigned int gen = bar->generation; + return (gen & -BAR_INCR) == (state & -BAR_INCR) + BAR_INCR; } #endif /* GOMP_BARRIER_H */ diff --git a/libgomp/config/linux/bar.c b/libgomp/config/linux/bar.c index bbdfc896391..330b37a9692 100644 --- a/libgomp/config/linux/bar.c +++ b/libgomp/config/linux/bar.c @@ -120,7 +120,7 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) } generation |= gen & BAR_WAITING_FOR_TASK; } - while (!gomp_barrier_state_is_incremented (gen, state)); + while ((gen & -BAR_INCR) != state + BAR_INCR); } void @@ -189,7 +189,7 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, } generation |= gen & BAR_WAITING_FOR_TASK; } - while (!gomp_barrier_state_is_incremented (gen, state)); + while ((gen & -BAR_INCR) != state + BAR_INCR); return false; } diff --git a/libgomp/config/linux/bar.h b/libgomp/config/linux/bar.h index 4dc0d3cca99..b7399f88dc0 100644 --- a/libgomp/config/linux/bar.h +++ b/libgomp/config/linux/bar.h @@ -168,20 +168,11 @@ gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) MEMMODEL_RELEASE); } -static inline bool -gomp_barrier_state_is_incremented (gomp_barrier_state_t gen, - gomp_barrier_state_t state) -{ - unsigned next_state = (state & -BAR_INCR) + BAR_INCR; - return next_state > state ? gen >= next_state : gen < state; -} - static inline bool gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar) { - /* Handling overflow in the generation. The "next" state could be less than - or greater than the current one. */ - return gomp_barrier_state_is_incremented (bar->generation, state); + unsigned int gen = bar->generation; + return (gen & -BAR_INCR) == (state & -BAR_INCR) + BAR_INCR; } #endif /* GOMP_BARRIER_H */ diff --git a/libgomp/config/nvptx/bar.h b/libgomp/config/nvptx/bar.h index 8bad3dc80b3..3085711d5a6 100644 --- a/libgomp/config/nvptx/bar.h +++ b/libgomp/config/nvptx/bar.h @@ -169,20 +169,11 @@ gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) bar->generation = (state & -BAR_INCR) + BAR_INCR; } -static inline bool -gomp_barrier_state_is_incremented (gomp_barrier_state_t gen, - gomp_barrier_state_t state) -{ - unsigned next_state = (state & -BAR_INCR) + BAR_INCR; - return next_state > state ? gen >= next_state : gen < state; -} - static inline bool gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar) { - /* Handling overflow in the generation. The "next" state could be less than - or greater than the current one. */ - return gomp_barrier_state_is_incremented (bar->generation, state); + unsigned int gen = bar->generation; + return (gen & -BAR_INCR) == (state & -BAR_INCR) + BAR_INCR; } #endif /* GOMP_BARRIER_H */ diff --git a/libgomp/config/posix/bar.c b/libgomp/config/posix/bar.c index c46659bd264..8dbf7be08ea 100644 --- a/libgomp/config/posix/bar.c +++ b/libgomp/config/posix/bar.c @@ -158,7 +158,7 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); } } - while (!gomp_barrier_state_is_incremented (gen, state)); + while ((gen & -BAR_INCR) != state + BAR_INCR); #ifdef HAVE_SYNC_BUILTINS n = __sync_add_and_fetch (&bar->arrived, -1); @@ -232,7 +232,7 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, break; } } - while (!gomp_barrier_state_is_incremented (gen, state)); + while ((gen & -BAR_INCR) != state + BAR_INCR); #ifdef HAVE_SYNC_BUILTINS n = __sync_add_and_fetch (&bar->arrived, -1); diff --git a/libgomp/config/posix/bar.h b/libgomp/config/posix/bar.h index 026daca793d..8aab3733cc7 100644 --- a/libgomp/config/posix/bar.h +++ b/libgomp/config/posix/bar.h @@ -158,20 +158,11 @@ gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) MEMMODEL_RELEASE); } -static inline bool -gomp_barrier_state_is_incremented (gomp_barrier_state_t gen, - gomp_barrier_state_t state) -{ - unsigned next_state = (state & -BAR_INCR) + BAR_INCR; - return next_state > state ? gen >= next_state : gen < state; -} - static inline bool gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar) { - /* Handling overflow in the generation. The "next" state could be less than - or greater than the current one. */ - return gomp_barrier_state_is_incremented (bar->generation, state); + unsigned int gen = bar->generation; + return (gen & -BAR_INCR) == (state & -BAR_INCR) + BAR_INCR; } #endif /* GOMP_BARRIER_H */ diff --git a/libgomp/config/rtems/bar.h b/libgomp/config/rtems/bar.h index 80fb1cd3be8..47b961c2104 100644 --- a/libgomp/config/rtems/bar.h +++ b/libgomp/config/rtems/bar.h @@ -170,20 +170,11 @@ gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) MEMMODEL_RELEASE); } -static inline bool -gomp_barrier_state_is_incremented (gomp_barrier_state_t gen, - gomp_barrier_state_t state) -{ - unsigned next_state = (state & -BAR_INCR) + BAR_INCR; - return next_state > state ? gen >= next_state : gen < state; -} - static inline bool gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar) { - /* Handling overflow in the generation. The "next" state could be less than - or greater than the current one. */ - return gomp_barrier_state_is_incremented (bar->generation, state); + unsigned int gen = bar->generation; + return (gen & -BAR_INCR) == (state & -BAR_INCR) + BAR_INCR; } #endif /* GOMP_BARRIER_H */ -- 2.43.0 From mmalcomson@nvidia.com Mon Nov 2 16:25:14 2026 From: mmalcomson@nvidia.com (mmalcomson@nvidia.com) Date: Mon, 2 Nov 2026 16:25:14 +0000 Subject: [PATCH 4/4] libgomp: Parallelise thread {re-,}initialisation In-Reply-To: <20261102162514.3475056-1-mmalcomson@nvidia.com> References: <20261012170038.3418851-1-mmalcomson@nvidia.com> <20261102162514.3475056-1-mmalcomson@nvidia.com> Message-ID: <20261102162514.3475056-5-mmalcomson@nvidia.com> From: Matthew Malcomson This patch is a separate beneficial step of the work I'm doing towards PR119588. In that bug I describe how some internal workloads are hitting some performance problems w.r.t. the creation of many parallel regions one after each other. I'm attempting to reduce overhead of parallel region creation when using a large number of threads. Earlier work adjusts the barrier design to something that performs better under heavy contention. This is a patch built on top of that earlier work, but with appropriate rebase could be independent. It addresses a different area where I've seen a performance impact. It's the area that I mentioned in the below mail to the GCC mailing list. https://gcc.gnu.org/pipermail/gcc/2025-September/246618.html The fundamental point is that the cost of teardown & setup of a parallel region for LLVM is very close to the cost of a single barrier. For us there is a significant chunk of extra work in the actual teardown and setup. When re-using a team with no changes in various ICVs there is very little work that is required to be performed on top of a plain barrier. Even when some ICV's have changed a large amount of the work that is currently in a loop performed by the primary thread while all threads are waiting on it can be moved into secondary threads. This patch makes those changes. There are three distinct but related cases: 1) When re-using a thread unchanged. 2) When re-using a thread with some changes (or when leaving a thread to exit). 3) When starting a new thread. In all of these cases `gomp_team_start` currently initialises the same value into each threads local value for all of the below: - *thr->task (initialisation) - thr->num_teams - thr->team_num - fn (either thr->fn or data->fn) - data (either thr->data or data->fn_data) - thr->ts.def_allocator Hence each of these can be handled by writing this information to a shared location on the relevant team and having each thread read the information from there. There is some data that is always set to the same value (at least in relation to the team we're running on): - thr->ts.work_share - thr->ts.last_work_share - thr->ts.single_count - thr->ts.static_trip - thr->task (where it is located) Initialisation of these is directly moved from the primary thread to the secondary threads without any new communication being added. There are some variables that are always the same for a non-nested team and always equal for all threads of a nested team: - thr->ts.active_level - thr->ts.level These are communicated to secondary threads when starting a new team via the `start_data` of the new pthread, and are left as-is for the re-use of threads in a non-nested team. Then finally there are some member variables that are kept the same as for the last team for all reused threads of a non-nested team as long as the places/affinity ICV's are not changed (and the team is reused): - thr->ts.place_partition_off - thr->ts.place_partition_len - thr->place - thr->ts.team_id - thr->team - Which thread's `release` member address is stored in which `team->ordered_release[i]`. We maintain a cache of the last used ICV's in the `team` structure. If these match then we can completely skip the loop where the primary initialises parts of each secondary threads local data. These must be provided to any new secondary threads when they are starting. The last part to allow the primary thread to avoid iterating over all secondary threads when nothing has changed is to invert the protocol used to communicate that a given thread must exit. The existing convention is that secondary threads set their own `thr->fn` to `NULL`, then the primary sets the `nthr->fn` of each thread it wants to continue to the function that said secondary thread must execute. This means the primary thread needs to perform a write on each thread that is continuing. Here I switch the convention so that the primary thread sets `thr->exit` on each of the threads it wants to exit. Those threads without this boolean flag set read the function that they are to execute from their team structure. This means the primary thread writes once per exiting thread instead of once per reused thread. In the case where the number of threads and affinity setup is not changing between parallel regions this means no work instead of O(N) work. There is still a clause in the main loop of `gomp_thread_start` checking for `thr->fn` in order to let `gomp_pause_host` and `gomp_free_thread` continue to work as intended. I could have changed those functions to adjust `pool->last_team->ti.fn` instead of setting `thr->fn` directly but it didn't seem any better either way. Only subtlety here is that in order to ensure memory safety the secondary thread must avoid performing this initialisation when `thr->fn == NULL`. If a secondary non-nested thread gets "left to exit" when a new team is started the primary thread could race ahead, cache the new team, and free the team that this secondary thread was using all before the secondary thread goes through the new initialisation code. That could lead to a use-after-free. Hence we have to early-exit when this thread is not going to perform any more work. There is a synchronisation side-benefits to putting the initialisation in each secondary thread: - gomp_init_task is now guaranteed to be called on the thread-local task *after* gomp_finish_task is called on it. This avoids any leak of `depend_hash` members. (When team_id has not changed these functions are called on the same thread, when they have changed we add a new synchronisation point between new threads and threads that have been "remapped"). ------- Testing done: - Bootstrap & regtest on aarch64 and x86_64. - With & without _LIBGOMP_CHECKING_. - Testsuite with & without OMP_WAIT_POLICY=passive for GOMP_BARRIER_TYPE=flat, GOMP_BARRIER_TYPE=tree, GOMP_BARRIER_TYPE=centralized, and unspecified barrier type. - With and without configure `--enable-linux-futex=no` for posix target. - With and without configure `--enable-linux-futex-waitv=no` to check we haven't broken original linux/ target. - Cross compilation & regtest on arm. - Built gcn, rtems, nvptx targets (just building -- not ran testsuite). - TSAN with checks against new/old "fingerprints" of warnings raised from the libgomp testsuite. Performance testing done: - SPEC 2026 speed (those benchmarks using OpenMP) - SPEC OMP 2012 - SPEC HPC 2021 (restricted to one socket) - EPCC OpenMP Microbenchmarks. - Microbenchmark mentioned in PR119588. EPCC OpenMP microbenchmarks ran with the cross-product of: - OMP_WAIT_POLICY={active,unset,passive} - OMP_PROC_BIND={close,unset} - OMP_NUM_THREADS={4,unset} - GOMP_BARRIER_TYPE={flat,tree,centralized,auto} libgomp/ChangeLog: PR libgomp/119588 * libgomp.h (struct gomp_team): Add fields for communication at team start time. New `ti` member, new `ppv` member, new `reused` boolean. * team.c (gomp_thread_start): Initialise thread-local data using members stored on team. (get_last_team): Set `team->reused` member when reusing. (gomp_new_team): Unset `team->reused` member when creating new team. (gomp_team_start): Primary thread stores data on team structure instead of copying that data to each secondary threads gomp_thread structure. Skip re-calculation of places on a reused team when inputs are the same. Signed-off-by: Matthew Malcomson --- libgomp/libgomp.h | 22 ++++ libgomp/team.c | 322 +++++++++++++++++++++++++++++++--------------- 2 files changed, 240 insertions(+), 104 deletions(-) diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h index 75d3f08e391..f3a643524e4 100644 --- a/libgomp/libgomp.h +++ b/libgomp/libgomp.h @@ -941,7 +941,28 @@ struct gomp_team #ifdef __AMDGCN__ /* Used on AMD GCN to inform threads how to launch in a team. */ struct gomp_thread_start_data thr_start_data; +#elif LIBGOMP_USE_PTHREADS + /* Cache to help initialise each secondary threads `task` when re-using a + team very many times. This allows each secondary thread to perform the + re-initialisation instead of having the primary thread need to perform + that initialisation. */ + struct thread_init { + struct gomp_task_icv task_icv_init; + struct gomp_task *task_parent_init; + struct gomp_taskgroup *task_taskgroup; + uintptr_t def_allocator; + unsigned int num_teams; + unsigned int team_num; + void (*fn) (void *data); + void *data; + } ti; + struct prev_place_vars { + unsigned int place_partition_off; + unsigned int place_partition_len; + char bind; + } ppv; #endif + bool reused; /* This array contains structures for implicit tasks. */ struct gomp_task implicit_task[]; @@ -955,6 +976,7 @@ struct gomp_thread /* This is the function that the thread should run upon launch. */ void (*fn) (void *data); void *data; + bool exit; #ifdef __AMDGCN__ /* And these are the parameters it should set. */ diff --git a/libgomp/team.c b/libgomp/team.c index c4b5af466d2..3d38b7f9587 100644 --- a/libgomp/team.c +++ b/libgomp/team.c @@ -68,18 +68,38 @@ pthread_key_t gomp_tls_key; struct gomp_thread_start_data { - void (*fn) (void *); - void *fn_data; - struct gomp_team_state ts; - struct gomp_task *task; + struct gomp_team *team; struct gomp_thread_pool *thread_pool; unsigned int place; - unsigned int num_teams; - unsigned int team_num; + unsigned team_id; + unsigned active_level; + unsigned place_partition_off; + unsigned place_partition_len; bool nested; pthread_t handle; }; +static inline void +gomp_init_team_state (struct gomp_team_state *ts, struct gomp_team *team, + unsigned team_id, unsigned active_level, + unsigned place_partition_off, + unsigned place_partition_len) +{ + ts->team = team; + ts->work_share = &team->work_shares[0]; + ts->last_work_share = NULL; + ts->team_id = team_id; + ts->level = team->prev_ts.level + 1; + ts->active_level = active_level; + ts->place_partition_off = place_partition_off; + ts->place_partition_len = place_partition_len; + ts->def_allocator = team->ti.def_allocator; +#ifdef HAVE_SYNC_BUILTINS + ts->single_count = 0; +#endif + ts->static_trip = 0; +} + /* This function is a pthread_create entry point. This contains the idle loop in which a thread waits to be called up to become part of a team. */ @@ -101,14 +121,17 @@ gomp_thread_start (void *xdata) gomp_sem_init (&thr->release, 0); /* Extract what we need from data. */ - local_fn = data->fn; - local_data = data->fn_data; + struct gomp_team *team = data->team; + gomp_init_team_state (&thr->ts, team, data->team_id, data->active_level, + data->place_partition_off, data->place_partition_len); + + local_fn = team->ti.fn; + local_data = team->ti.data; + thr->num_teams = team->ti.num_teams; + thr->team_num = team->ti.team_num; thr->thread_pool = data->thread_pool; - thr->ts = data->ts; - thr->task = data->task; thr->place = data->place; - thr->num_teams = data->num_teams; - thr->team_num = data->team_num; + thr->exit = false; #ifdef GOMP_NEEDS_THREAD_HANDLE thr->handle = data->handle; #endif @@ -116,7 +139,7 @@ gomp_thread_start (void *xdata) pthread_setspecific (gomp_tls_key, thr); #endif - thr->ts.team->ordered_release[thr->ts.team_id] = &thr->release; + team->ordered_release[thr->ts.team_id] = &thr->release; /* Make thread pool local. */ pool = thr->thread_pool; @@ -124,6 +147,10 @@ gomp_thread_start (void *xdata) if (data->nested) { struct gomp_team *team = thr->ts.team; + thr->task = &team->implicit_task[thr->ts.team_id]; + gomp_init_task (thr->task, team->ti.task_parent_init, + &team->ti.task_icv_init); + thr->task->taskgroup = team->ti.task_taskgroup; struct gomp_task *task = thr->task; gomp_barrier_wait (&team->barrier, thr->ts.team_id); @@ -138,11 +165,24 @@ gomp_thread_start (void *xdata) pool->threads[thr->ts.team_id] = thr; gomp_simple_barrier_wait (&pool->threads_dock); + + /* Ensure we initialise the task *after* the wait on threads_dock just in + case affinity changes have meant that this new thread has the same + team_id as a thread used to have. In this case we want to ensure the + `gomp_finish_task` below is certain to happen before the + `gomp_init_task` here. */ + thr->task = &team->implicit_task[thr->ts.team_id]; + gomp_init_task (thr->task, team->ti.task_parent_init, + &team->ti.task_icv_init); + thr->task->taskgroup = team->ti.task_taskgroup; + do { struct gomp_team *team = thr->ts.team; + unsigned team_id = thr->ts.team_id; struct gomp_task *task = thr->task; + thr->fn = NULL; local_fn (local_data); gomp_team_barrier_wait_final (&team->barrier, thr->ts.team_id); gomp_finish_task (task); @@ -154,15 +194,53 @@ gomp_thread_start (void *xdata) next iteration we know that it will synchronise with the primary thread before it frees this team because it will synchronise with the primary thread in the next iteration of this loop (in - `gomp_team_barrier_wait_final`). */ - if (!gomp_barrier_can_hold (&team->barrier) || thr->fn == NULL) + `gomp_team_barrier_wait_final`). + Also have to hold here if we adjusted our team_id since the above + `task` location is possibly going to be used by a newly started + thread so we have to synchronise with those. Use boolean + short-circuit to avoid data-race on thr->ts.team in case where the + final barrier can't hold threads. */ + if (!gomp_barrier_can_hold (&team->barrier) + || thr->exit + || (thr->ts.team == team && thr->ts.team_id != team_id)) gomp_simple_barrier_wait (&pool->threads_dock); - local_fn = thr->fn; - local_data = thr->data; - thr->fn = NULL; + /* Early exit because if `thr->fn == NULL` then we can't guarantee + the `thr->ts.team` hasn't been freed by the primary thread racing + ahead. Hence we don't want to write to it. */ + if (thr->exit) + break; + + /* Usually `thr->fn` is not used or set. It is used when secondary + threads are "set going" without being assigned to any team. + See `gomp_pause_host` and `gomp_free_thread`. + In this case we don't want to bother reading the team + initialisation things because they've not been set up for us. */ + if (__builtin_expect (thr->fn != NULL, 0)) + { + local_fn = thr->fn; + local_data = thr->data; + continue; + } + + team = thr->ts.team; + thr->ts.work_share = &team->work_shares[0]; + thr->ts.last_work_share = NULL; + thr->ts.def_allocator = team->ti.def_allocator; +#ifdef HAVE_SYNC_BUILTINS + thr->ts.single_count = 0; +#endif + thr->ts.static_trip = 0; + local_fn = team->ti.fn; + local_data = team->ti.data; + thr->num_teams = team->ti.num_teams; + thr->team_num = team->ti.team_num; + thr->task = &team->implicit_task[thr->ts.team_id]; + gomp_init_task (thr->task, team->ti.task_parent_init, + &team->ti.task_icv_init); + thr->task->taskgroup = team->ti.task_taskgroup; } - while (local_fn); + while (true); } gomp_sem_destroy (&thr->release); @@ -191,6 +269,7 @@ get_last_team (unsigned nthreads) "prev_barrier not within cached team: %p != %p", pool->prev_barrier, &pool->last_team->barrier); pool->last_team = NULL; + last_team->reused = true; return last_team; } } @@ -249,6 +328,7 @@ gomp_new_team (unsigned nthreads) gomp_mutex_init (&team->task_lock); team->nthreads = nthreads; + team->reused = false; } team->work_share_chunk = 8; @@ -376,13 +456,14 @@ gomp_free_thread (void *arg __attribute__((unused))) #ifdef LIBGOMP_USE_PTHREADS static unsigned -gomp_barrier_calc_wait (unsigned num_new_threads, unsigned num_exiting_threads, - unsigned old_threads_used, unsigned nthreads, - unsigned affinity_count, bool can_hold) +gomp_barrier_wait_n (unsigned num_new_threads, unsigned num_exiting_threads, + unsigned num_remapped_threads, unsigned old_threads_used, + unsigned nthreads, unsigned affinity_count, bool can_hold) { if (can_hold) { - unsigned tmp = num_new_threads + num_exiting_threads; + unsigned tmp + = num_new_threads + num_exiting_threads + num_remapped_threads; return tmp ? tmp + 1 : 0; } if (!affinity_count) @@ -404,6 +485,7 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, unsigned i, n, old_threads_used = 0; unsigned simple_barrier_n = 0; unsigned num_new_threads = 0; + unsigned num_remapped_threads = 0; unsigned spawned_new_threads __attribute__ ((unused)) = 0; unsigned num_exiting_threads = 0; pthread_attr_t thread_attr, *attr; @@ -536,6 +618,21 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, else bind = omp_proc_bind_false; + /* Copy entirely rather than copy pointer so that we have an immutable + copy for the secondary threads to take from for the time-frame that + said secondary threads are executing on. Can't copy from + `team->implicit_task[0].icv` because primary thread could have adjusted + its per-task ICV by the time the secondary thread gets around to + initialising things. */ + team->ti.task_icv_init = team->implicit_task[0].icv; + team->ti.task_parent_init = task; + team->ti.task_taskgroup = taskgroup; + team->ti.num_teams = thr->num_teams; + team->ti.team_num = thr->team_num; + team->ti.fn = fn; + team->ti.data = data; + team->ti.def_allocator = thr->ts.def_allocator; + /* We only allow the reuse of idle threads for non-nested PARALLEL regions. This appears to be implied by the semantics of threadprivate variables, but perhaps that's reading too much into @@ -548,17 +645,35 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, team->prev_ts.team_id); old_threads_used = pool->threads_used; + if (team->reused + && team->ppv.place_partition_off == thr->ts.place_partition_off + && team->ppv.place_partition_len == thr->ts.place_partition_len + && team->ppv.bind == bind) + { + gomp_assert (nthreads == old_threads_used, + "odd number of threads when re-using team: " + "nthreads = %u old_threads_used = %u\n", + nthreads, old_threads_used); + goto do_release; + } + else + { + team->ppv.place_partition_off = thr->ts.place_partition_off; + team->ppv.place_partition_len = thr->ts.place_partition_len; + team->ppv.bind = bind; + } + + if (nthreads == old_threads_used) { n = nthreads; num_new_threads = 0; num_exiting_threads = 0; simple_barrier_n - = gomp_barrier_calc_wait (num_new_threads, num_exiting_threads, - old_threads_used, nthreads, - affinity_count, - gomp_barrier_can_hold ( - pool->prev_barrier)); + = gomp_barrier_wait_n (num_new_threads, num_exiting_threads, + num_remapped_threads, old_threads_used, + nthreads, affinity_count, + gomp_barrier_can_hold (pool->prev_barrier)); if (gomp_barrier_can_hold (pool->prev_barrier)) gomp_simple_barrier_reinit (&pool->threads_dock, simple_barrier_n); } @@ -568,11 +683,10 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, num_new_threads = 0; num_exiting_threads = old_threads_used - nthreads; simple_barrier_n - = gomp_barrier_calc_wait (num_new_threads, num_exiting_threads, - old_threads_used, nthreads, - affinity_count, - gomp_barrier_can_hold ( - pool->prev_barrier)); + = gomp_barrier_wait_n (num_new_threads, num_exiting_threads, + num_remapped_threads, old_threads_used, + nthreads, affinity_count, + gomp_barrier_can_hold (pool->prev_barrier)); if (gomp_barrier_can_hold (pool->prev_barrier)) gomp_simple_barrier_reinit (&pool->threads_dock, simple_barrier_n); } @@ -590,11 +704,10 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, num_new_threads = nthreads - old_threads_used; num_exiting_threads = 0; simple_barrier_n - = gomp_barrier_calc_wait (num_new_threads, num_exiting_threads, - old_threads_used, nthreads, - affinity_count, - gomp_barrier_can_hold ( - pool->prev_barrier)); + = gomp_barrier_wait_n (num_new_threads, num_exiting_threads, + num_remapped_threads, old_threads_used, + nthreads, affinity_count, + gomp_barrier_can_hold (pool->prev_barrier)); /* Increase the barrier threshold to make sure all new threads arrive before the team is released. */ gomp_simple_barrier_reinit (&pool->threads_dock, simple_barrier_n); @@ -720,6 +833,8 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, pool->threads[j]->data = affinity_thr[l]; affinity_thr[l] = pool->threads[j]; } + else + pool->threads[j]->exit = true; pool->threads[j] = NULL; } if (nthreads > old_threads_used) @@ -759,33 +874,35 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, else nthr = pool->threads[i]; __atomic_store_n (&nthr->ts.team, team, MEMMODEL_RELEASE); - nthr->ts.work_share = &team->work_shares[0]; - nthr->ts.last_work_share = NULL; + if (team->reused && nthr->ts.team_id != i) + num_remapped_threads++; nthr->ts.team_id = i; - nthr->ts.level = team->prev_ts.level + 1; - nthr->ts.active_level = thr->ts.active_level; + gomp_assert (nthr->ts.level == 1 && team->prev_ts.level == 0, + "level indicators surprising: nthr: %u, team->prev_ts: " + "%u\n", nthr->ts.level, team->prev_ts.level); + gomp_assert (nthr->ts.active_level == 1 && thr->ts.active_level == 1, + "active_level indicators surprising: nthr: %u, thr: " + "%u\n", nthr->ts.active_level, thr->ts.active_level); nthr->ts.place_partition_off = place_partition_off; nthr->ts.place_partition_len = place_partition_len; - nthr->ts.def_allocator = thr->ts.def_allocator; -#ifdef HAVE_SYNC_BUILTINS - nthr->ts.single_count = 0; -#endif - nthr->ts.static_trip = 0; - nthr->num_teams = thr->num_teams; - nthr->team_num = thr->team_num; - nthr->task = &team->implicit_task[i]; nthr->place = place; - gomp_init_task (nthr->task, task, icv); - team->implicit_task[i].icv.nthreads_var = nthreads_var; - team->implicit_task[i].icv.bind_var = bind_var; - nthr->task->taskgroup = taskgroup; - nthr->fn = fn; - nthr->data = data; team->ordered_release[i] = &nthr->release; } if (__builtin_expect (affinity_thr != NULL, 0)) { + /* Mark each of the threads that are exiting as such. Hence in + `gomp_thread_start` they exit their main loop. */ + for (unsigned l = 0; l < team->prev_ts.place_partition_len; l++) + { + struct gomp_thread *t = affinity_thr[l]; + while (t) + { + struct gomp_thread *next = (struct gomp_thread *) t->data; + t->exit = true; + t = next; + } + } /* If AFFINITY_THR is non-NULL just because we had to permute some threads in the pool, but we've managed to find exactly as many old threads as we'd find @@ -868,18 +985,20 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, num_new_threads = (nthreads + affinity_count) - old_threads_used; num_exiting_threads = affinity_count; - simple_barrier_n - = gomp_barrier_calc_wait (num_new_threads, - num_exiting_threads, - old_threads_used, nthreads, - affinity_count, - gomp_barrier_can_hold ( - pool->prev_barrier)); - gomp_simple_barrier_reinit (&pool->threads_dock, - simple_barrier_n); } } } + else + for (unsigned j = n; j < old_threads_used; j++) + pool->threads[j]->exit = true; + + /* Account for any affinity changes & remapped threads. */ + simple_barrier_n + = gomp_barrier_wait_n (num_new_threads, num_exiting_threads, + num_remapped_threads, old_threads_used, nthreads, + affinity_count, + gomp_barrier_can_hold (pool->prev_barrier)); + gomp_simple_barrier_reinit (&pool->threads_dock, simple_barrier_n); if (i == nthreads) { @@ -888,15 +1007,18 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, num_new_threads); gomp_assert (gomp_barrier_can_hold (pool->prev_barrier) ? (simple_barrier_n - == (num_exiting_threads ? num_exiting_threads + 1 - : 0)) + == ((num_exiting_threads || num_remapped_threads) + ? (num_exiting_threads + num_remapped_threads + + 1) + : 0)) : simple_barrier_n == old_threads_used, "have calculated need simple_barrier_n == %u" " starting 0 threads, affinity_count == %u, " "old_threads_used == %u, calculated " - "num_exiting_threads == %u, nthreads == %u", + "num_exiting_threads == %u, nthreads == %u, " + "num_remapped_threads == %u", simple_barrier_n, affinity_count, old_threads_used, - num_exiting_threads, nthreads); + num_exiting_threads, nthreads, num_remapped_threads); goto do_release; } } @@ -937,8 +1059,8 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, { int err; - start_data->ts.place_partition_off = thr->ts.place_partition_off; - start_data->ts.place_partition_len = thr->ts.place_partition_len; + start_data->place_partition_off = thr->ts.place_partition_off; + start_data->place_partition_len = thr->ts.place_partition_len; start_data->place = 0; if (__builtin_expect (gomp_places_list != NULL, 0)) { @@ -972,11 +1094,11 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, if (p == (team->prev_ts.place_partition_off + team->prev_ts.place_partition_len)) p = team->prev_ts.place_partition_off; - start_data->ts.place_partition_off = p; + start_data->place_partition_off = p; if (p < rest) - start_data->ts.place_partition_len = s + 1; + start_data->place_partition_len = s + 1; else - start_data->ts.place_partition_len = s; + start_data->place_partition_len = s; } else { @@ -993,8 +1115,8 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, } else ++k; - start_data->ts.place_partition_off = p; - start_data->ts.place_partition_len = 1; + start_data->place_partition_off = p; + start_data->place_partition_len = 1; } break; } @@ -1004,29 +1126,12 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, gomp_init_thread_affinity (attr, p); } - start_data->fn = fn; - start_data->fn_data = data; - start_data->ts.team = team; - start_data->ts.work_share = &team->work_shares[0]; - start_data->ts.last_work_share = NULL; - start_data->ts.team_id = i; - start_data->ts.level = team->prev_ts.level + 1; - start_data->ts.active_level = thr->ts.active_level; - start_data->ts.def_allocator = thr->ts.def_allocator; -#ifdef HAVE_SYNC_BUILTINS - start_data->ts.single_count = 0; -#endif - start_data->ts.static_trip = 0; - start_data->num_teams = thr->num_teams; - start_data->team_num = thr->team_num; - start_data->task = &team->implicit_task[i]; - gomp_init_task (start_data->task, task, icv); - team->implicit_task[i].icv.nthreads_var = nthreads_var; - team->implicit_task[i].icv.bind_var = bind_var; - start_data->task->taskgroup = taskgroup; + start_data->team = team; + start_data->team_id = i; + + start_data->active_level = thr->ts.active_level; start_data->thread_pool = pool; start_data->nested = nested; - attr = gomp_adjust_thread_attr (attr, &thread_attr); err = pthread_create (&start_data->handle, attr, gomp_thread_start, start_data); @@ -1046,7 +1151,8 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, calc_check = (num_new_threads == (simple_barrier_n - 1)); else if (gomp_barrier_can_hold (pool->prev_barrier)) calc_check - = ((num_new_threads + num_exiting_threads) == (simple_barrier_n - 1)); + = ((num_new_threads + num_exiting_threads + num_remapped_threads) + == (simple_barrier_n - 1)); else calc_check = (num_new_threads == (simple_barrier_n - old_threads_used)); gomp_assert (calc_check, @@ -1055,9 +1161,11 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, ", nthreads: %u" ", num_new_threads: %u" ", num_exiting_threads: %u" + ", num_remapped_threads: %u" ", old_threads_used: %u", nested ? "nested" : "top-level", simple_barrier_n, nthreads, - num_new_threads, num_exiting_threads, old_threads_used); + num_new_threads, num_exiting_threads, num_remapped_threads, + old_threads_used); } if (__builtin_expect (attr == &thread_attr, 0)) @@ -1069,7 +1177,9 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, else { gomp_release_held_threads (pool, team, thr->ts.team_id); - if (num_new_threads || num_exiting_threads + if (num_new_threads + || num_exiting_threads + || num_remapped_threads || !gomp_barrier_can_hold (pool->prev_barrier)) gomp_simple_barrier_wait (&pool->threads_dock); } @@ -1119,16 +1229,20 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, if (nested) { start_data -= nthreads - 1; + struct gomp_team_state ts; for (i = 1; i < nthreads; ++i) { + gomp_init_team_state (&ts, team, start_data->team_id, + start_data->active_level, + start_data->place_partition_off, + start_data->place_partition_len); gomp_display_affinity_thread ( #ifdef LIBGOMP_USE_PTHREADS - start_data->handle, + start_data->handle, #else - gomp_thread_self (), + gomp_thread_self (), #endif - &start_data->ts, - start_data->place); + &ts, start_data->place); start_data++; } } -- 2.43.0 From mmalcomson@nvidia.com Mon Nov 2 16:25:13 2026 From: mmalcomson@nvidia.com (mmalcomson@nvidia.com) Date: Mon, 2 Nov 2026 16:25:13 +0000 Subject: [PATCH 3/4] libgomp: Add focused barrier and team-lifecycle tests In-Reply-To: <20261102162514.3475056-1-mmalcomson@nvidia.com> References: <20261012170038.3418851-1-mmalcomson@nvidia.com> <20261102162514.3475056-1-mmalcomson@nvidia.com> Message-ID: <20261102162514.3475056-4-mmalcomson@nvidia.com> From: Matthew Malcomson N.b. I do not fully understand each of the testcases here, nor have I manually verified that they cover something materially different to what is existing in the testsuite. They were generated by AI during a bug-hunting session and it seemed like useful work to retain. Due to this I'm honestly not sure whether this patch should go into GCC or not -- sending as a separate patch so that decision can be made separately. The linux/futex_waitv target changes several protocols beyond a direct GOMP_barrier call. Its tree barrier flushes data transitively, its final barrier can retain secondary threads between teams, and split work-share barriers now carry a logical thread ID. Cancellable generations also have a short, independent bit field. The tests added with the target cover direct generation arithmetic and primary task handling, but do not exercise several of these materially different paths. Add twelve focused executable tests distilled from an automated AI barrier verification search. They use public OpenMP interfaces and source-level correctness oracles; exhaustive affinity matrices, tracing, sleeps, and long stress counts from the campaign are deliberately omitted. The individual tests cover the following behavior: * barrier-tree-flush.c checks that ordinary non-atomic data is flushed through partial, exact-boundary, and over-boundary radix-four trees with 15, 16, and 17 threads. Consecutive regions also check that data is flushed when a retained team is released for its next use. * barrier-tree-task.c gates logical thread 4 into the child-gather wait while its children and the primary remain in user code. It verifies that this secondary coordinator drains the sole task at both an ordinary barrier and an implicit final barrier. * team-held-pause.c leaves a flat-barrier team retained across a one-thread region, then checks that omp_pause_resource_all releases and joins the old worker pool. * team-held-pthread-exit.c creates the same retained-team shape with a tree barrier inside a foreign initial pthread. Joining that pthread verifies that the libgomp TLS destructor releases the old barrier and frees the complete pool. * artificial-team-pause.c creates a level-zero artificial team with a target-nowait construct, waits for its task, and performs a hard pause. A following two-thread region checks that the runtime recreates the thread pool rather than dereferencing the null pool left beside the artificial team. This inherited bug remains unfixed, so execution is XFAILed on all targets; host fallback makes the test independent of offload hardware. * barrier-nested-team-id.c makes outer logical thread 1 the primary of an active nested team. It exercises direct, work-share, copyprivate, tasking, and final barriers as nested logical thread 0, then checks restoration of outer logical ID 1. * cancel-late-arrival-1.c and cancel-late-arrival-2.c share a controlled schedule in which one thread starts a cancellable barrier only after cancellation has been committed. Forced-flat and forced-tree variants verify the late-return path, then use a plain barrier to validate local generation state and team reuse. * cancel-next-epoch-wrap.c performs 255 successful cancellable barriers, completes the wrap-sensitive 256th use, and immediately cancels the next epoch. A secondary completing the successful epoch must not attribute the new BAR_CANCELLED flag to the preceding generation or roll its local state back. * barrier-workshare-task.c queues tasks before a dynamically scheduled loop and verifies that task payload data is flushed through GOMP_loop_end's split barrier. A second work-share checks reclamation while repeated 2 -> 4 -> 1 -> 3 team sizes exercise retained-worker reuse. * barrier-copyprivate-task.c forces selected logical IDs to execute GOMP_single_copy_end while their peers use GOMP_single_copy_start. It verifies that copied data and task payload data are flushed, rotates the winner for a second generation, and repeats the representative team-size transitions. * barrier-task-reduction.c creates in_reduction tasks in a work-sharing loop and verifies the result after the additional barrier in GOMP_workshare_task_reduction_unregister, again across representative team transitions. Restrict the futex-waitv implementation tests to the linux_futex_waitv effective target. Force the barrier type where a particular flat or tree protocol is under test, enable OMP_CANCELLATION only for cancellation tests, and request two active levels for the nested-ID test. Run the artificial-team test on all targets with OMP_TARGET_OFFLOAD=DISABLED and an all-target dg-xfail-run-if selector. This makes each DejaGNU directive select the configuration described by its testcase rather than relying on the host's automatic barrier or offload choice. Targeted testing on x86_64-pc-linux-gnu produced 22 expected DejaGNU passes against the in-tree futex_waitv library. Verbose DejaGNU output confirmed the effective target, per-test environment settings, and build-tree library path; the tree-flush test is unsupported in a legacy Linux build whose config_path omits linux/futex_waitv. All eleven executables also passed against a _LIBGOMP_CHECKING_ coverage build. The five most scheduling- or lifecycle-sensitive executables passed ten additional checking-runtime runs each. A separate targeted run of artificial-team-pause.c produced one expected compilation pass and one expected execution failure against the in-tree runtime, confirming its XFAIL selector. Strict warning compilation and git diff --check also pass. libgomp/ChangeLog: * testsuite/libgomp.c/artificial-team-pause.c: New test. * testsuite/libgomp.c/barrier-copyprivate-task.c: New test. * testsuite/libgomp.c/barrier-nested-team-id.c: New test. * testsuite/libgomp.c/barrier-task-reduction.c: New test. * testsuite/libgomp.c/barrier-tree-flush.c: New test. * testsuite/libgomp.c/barrier-tree-task.c: New test. * testsuite/libgomp.c/barrier-workshare-task.c: New test. * testsuite/libgomp.c/cancel-late-arrival-1.c: New test. * testsuite/libgomp.c/cancel-late-arrival-2.c: New test. * testsuite/libgomp.c/cancel-late-arrival.h: Header for new tests. * testsuite/libgomp.c/cancel-next-epoch-wrap.c: New test. * testsuite/libgomp.c/team-held-pause.c: New test. * testsuite/libgomp.c/team-held-pthread-exit.c: New test. Assisted-by: Codex Signed-off-by: Matthew Malcomson --- .../testsuite/libgomp.c++/task-reduction-20.C | 4 +- .../testsuite/libgomp.c++/task-reduction-21.C | 4 +- ...ized.c => gomp-barrier-type-env-mixed-1.c} | 0 ...ized.c => gomp-barrier-type-env-mixed-2.c} | 0 ...flat.c => gomp-barrier-type-env-mixed-3.c} | 0 ...tree.c => gomp-barrier-type-env-mixed-4.c} | 0 .../libgomp.c/artificial-team-pause.c | 45 +++++ .../libgomp.c/barrier-copyprivate-task.c | 157 ++++++++++++++++++ .../libgomp.c/barrier-nested-team-id.c | 78 +++++++++ .../testsuite/libgomp.c/barrier-switch-1.c | 16 +- .../libgomp.c/barrier-task-reduction.c | 64 +++++++ .../testsuite/libgomp.c/barrier-tree-flush.c | 58 +++++++ .../testsuite/libgomp.c/barrier-tree-task.c | 136 +++++++++++++++ .../libgomp.c/barrier-workshare-task.c | 102 ++++++++++++ .../libgomp.c/barrier_generation_overflow.c | 14 +- .../libgomp.c/cancel-late-arrival-1.c | 132 +++++++++++++++ .../libgomp.c/cancel-late-arrival-2.c | 8 + .../libgomp.c/cancel-next-epoch-wrap.c | 87 ++++++++++ .../libgomp.c/cancel_incr_wraparound.c | 2 +- .../libgomp.c/futex_waitv_overflow.c | 4 +- libgomp/testsuite/libgomp.c/team-held-pause.c | 43 +++++ .../libgomp.c/team-held-pthread-exit.c | 56 +++++++ 22 files changed, 991 insertions(+), 19 deletions(-) rename libgomp/testsuite/libgomp.c-c++-common/{gomp-barrier-type-env-flat-centralized.c => gomp-barrier-type-env-mixed-1.c} (100%) rename libgomp/testsuite/libgomp.c-c++-common/{gomp-barrier-type-env-tree-centralized.c => gomp-barrier-type-env-mixed-2.c} (100%) rename libgomp/testsuite/libgomp.c-c++-common/{gomp-barrier-type-env-centralized-flat.c => gomp-barrier-type-env-mixed-3.c} (100%) rename libgomp/testsuite/libgomp.c-c++-common/{gomp-barrier-type-env-centralized-tree.c => gomp-barrier-type-env-mixed-4.c} (100%) create mode 100644 libgomp/testsuite/libgomp.c/artificial-team-pause.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-copyprivate-task.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-nested-team-id.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-task-reduction.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-tree-flush.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-tree-task.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-workshare-task.c create mode 100644 libgomp/testsuite/libgomp.c/cancel-late-arrival-1.c create mode 100644 libgomp/testsuite/libgomp.c/cancel-late-arrival-2.c create mode 100644 libgomp/testsuite/libgomp.c/cancel-next-epoch-wrap.c create mode 100644 libgomp/testsuite/libgomp.c/team-held-pause.c create mode 100644 libgomp/testsuite/libgomp.c/team-held-pthread-exit.c diff --git a/libgomp/testsuite/libgomp.c++/task-reduction-20.C b/libgomp/testsuite/libgomp.c++/task-reduction-20.C index 161b238578a..c349e2a81aa 100644 --- a/libgomp/testsuite/libgomp.c++/task-reduction-20.C +++ b/libgomp/testsuite/libgomp.c++/task-reduction-20.C @@ -51,9 +51,9 @@ baz (S *o, S *i) o->s *= i->s; } -#pragma omp declare reduction(+ : S : omp_out.s += omp_in.s) \ +#pragma omp declare reduction(+ : S : omp_out.s += omp_in.s) \ initializer(omp_priv(0, 3)) -#pragma omp declare reduction(* : S : baz(&omp_out, &omp_in)) \ +#pragma omp declare reduction(* : S : baz(&omp_out, &omp_in)) \ initializer(bar(&omp_priv, &omp_orig)) S as = {0LL, 7}; diff --git a/libgomp/testsuite/libgomp.c++/task-reduction-21.C b/libgomp/testsuite/libgomp.c++/task-reduction-21.C index 5a42add400a..f99ce968436 100644 --- a/libgomp/testsuite/libgomp.c++/task-reduction-21.C +++ b/libgomp/testsuite/libgomp.c++/task-reduction-21.C @@ -51,9 +51,9 @@ baz (S *o, S *i) o->s *= i->s; } -#pragma omp declare reduction(+ : S : omp_out.s += omp_in.s) \ +#pragma omp declare reduction(+ : S : omp_out.s += omp_in.s) \ initializer(omp_priv(0, 3)) -#pragma omp declare reduction(* : S : baz(&omp_out, &omp_in)) \ +#pragma omp declare reduction(* : S : baz(&omp_out, &omp_in)) \ initializer(bar(&omp_priv, &omp_orig)) S as = {0LL, 7}; diff --git a/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-flat-centralized.c b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-flat-centralized.c rename to libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-1.c diff --git a/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-tree-centralized.c b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-tree-centralized.c rename to libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-2.c diff --git a/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-centralized-flat.c b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-3.c similarity index 100% rename from libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-centralized-flat.c rename to libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-3.c diff --git a/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-centralized-tree.c b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-4.c similarity index 100% rename from libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-centralized-tree.c rename to libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-4.c diff --git a/libgomp/testsuite/libgomp.c/artificial-team-pause.c b/libgomp/testsuite/libgomp.c/artificial-team-pause.c new file mode 100644 index 00000000000..5fa3be4eb17 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/artificial-team-pause.c @@ -0,0 +1,45 @@ +/* Verify that hard pause does not leave a level-zero artificial team without + a thread pool. A target-nowait construct outside a parallel region creates + such an artificial team. After its task completes, hard pause may release + runtime resources, but the following parallel region must recreate any + thread pool it needs rather than dereferencing a stale null pool. + + Force host fallback so this checks the artificial-team lifecycle without + requiring an offload device. This is XFAILed until that lifecycle bug is + fixed. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "artificial-team pause" { *-*-* } } */ +/* { dg-set-target-env-var OMP_TARGET_OFFLOAD "DISABLED" } */ + +#include +#include + +int +main (void) +{ + int target_value = 0; + int participants = 0; + + omp_set_dynamic (0); + +#pragma omp target nowait map(tofrom : target_value) + target_value = 1; + +#pragma omp taskwait + if (target_value != 1) + abort (); + + if (omp_in_parallel ()) + abort (); + + if (omp_pause_resource_all (omp_pause_hard) != 0) + abort (); + +#pragma omp parallel num_threads(2) reduction(+ : participants) + participants += 1; + + if (participants != 2) + abort (); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/barrier-copyprivate-task.c b/libgomp/testsuite/libgomp.c/barrier-copyprivate-task.c new file mode 100644 index 00000000000..c950cb25242 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/barrier-copyprivate-task.c @@ -0,0 +1,157 @@ +/* Verify task handling in the barrier used by single-copyprivate. A selected + logical thread queues tasks and is forced to win the first single region; + every other thread therefore waits in GOMP_single_copy_start while the + winner completes through GOMP_single_copy_end. The copied value, task + payload, and task count must all have been flushed when that barrier + returns. + + A second copyprivate region rotates the winner to exercise reclamation of + the first work-share. Repeated 2 -> 4 -> 1 -> 3 transitions check the + logical-ID argument while retained tree-barrier workers are reused. + + This testcase is in order to exercise team_id propagation from + GOMP_single_copy_start and GOMP_single_copy_end. + + For targets other than linux_futex_waitv this is still worth running since + it exercises controlled winners with queued tasks in the same team. This is + not something exercised elsewhere in the testsuite. */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "tree" } */ + +#include +#include +#include +#include +#include + +enum { tasks = 4, rounds = 8 }; + +struct state +{ + int queued; + int gate_first; + int gate_second; + int completed; + int first_blocks; + int second_blocks; + int after_first; + int after_second; + uint32_t payload[tasks]; +}; + +static int +read_atomic (int *value) +{ + int result; +#pragma omp atomic read + result = *value; + return result; +} + +static void +wait_for (int *value) +{ + while (!read_atomic (value)) + sched_yield (); +} + +static uint32_t +task_payload (int task, int epoch) +{ + uint32_t value = (uint32_t) (epoch * tasks + task + 1); + for (unsigned int i = 0; i < 128; ++i) + value = value * 1103515245u + 12345u + i; + return value; +} + +static void +run_region (int nthreads, int epoch) +{ + struct state state; + int first_winner = epoch % nthreads; + int second_winner = (first_winner + 1) % nthreads; + long long first_value = 0x12340000LL + epoch; + long long second_value = 0x56780000LL + epoch; + memset (&state, 0, sizeof (state)); + +#pragma omp parallel num_threads(nthreads) shared(state) \ + firstprivate(epoch, first_winner, second_winner, first_value, second_value) + { + int tid = omp_get_thread_num (); + long long copied = -1; + + if (tid == first_winner) + { + for (int task = 0; task < tasks; ++task) + { +#pragma omp task firstprivate(task, epoch) shared(state) + { + state.payload[task] = task_payload (task, epoch); +#pragma omp atomic update + state.completed++; + } + } +#pragma omp atomic write + state.queued = 1; + } + else + wait_for (&state.queued); + + if (tid != first_winner) + wait_for (&state.gate_first); +#pragma omp single copyprivate(copied) + { + if (tid != first_winner) + abort (); + copied = first_value; +#pragma omp atomic update + state.first_blocks++; +#pragma omp atomic write + state.gate_first = 1; + } + + if (copied != first_value || state.completed != tasks) + abort (); + for (int task = 0; task < tasks; ++task) + if (state.payload[task] != task_payload (task, epoch)) + abort (); +#pragma omp atomic update + state.after_first++; + + copied = -1; + if (tid != second_winner) + wait_for (&state.gate_second); +#pragma omp single copyprivate(copied) + { + if (tid != second_winner) + abort (); + copied = second_value; +#pragma omp atomic update + state.second_blocks++; +#pragma omp atomic write + state.gate_second = 1; + } + + if (copied != second_value) + abort (); +#pragma omp atomic update + state.after_second++; + } + + if (!state.queued || state.completed != tasks || state.first_blocks != 1 + || state.second_blocks != 1 || state.after_first != nthreads + || state.after_second != nthreads) + abort (); +} + +int +main (void) +{ + static const int sizes[] = { 2, 4, 1, 3 }; + int epoch = 0; + + omp_set_dynamic (0); + for (int round = 0; round < rounds; ++round) + for (int i = 0; i < 4; ++i) + run_region (sizes[i], ++epoch); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/barrier-nested-team-id.c b/libgomp/testsuite/libgomp.c/barrier-nested-team-id.c new file mode 100644 index 00000000000..fd9eca05bc8 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/barrier-nested-team-id.c @@ -0,0 +1,78 @@ +/* Verify logical barrier IDs while an outer worker is primary of a nested + team. Outer logical thread 1 becomes logical thread 0 in the nested team, + exercises direct, work-share, copyprivate, tasking, and final barriers, + then must regain outer ID 1 before using the outer barrier again. + + The test covers the ID arguments added to the barrier interfaces and the + restoration of per-thread team state across active nesting. */ +/* { dg-do run { target linux_futex_waitv } } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "tree" } */ +/* { dg-set-target-env-var OMP_MAX_ACTIVE_LEVELS "2" } */ + +#include +#include + +enum { rounds = 24 }; + +int +main (void) +{ + omp_set_dynamic (0); + omp_set_max_active_levels (2); + + for (int round = 0; round < rounds; ++round) + { + int loop_total = 0; + int task_total = 0; + +#pragma omp parallel num_threads(3) firstprivate(round) \ + shared(loop_total, task_total) + { + int outer_id = omp_get_thread_num (); + + if (outer_id == 1) + { + int inner_threads = 2 + round % 4; + +#pragma omp parallel num_threads(inner_threads) \ + firstprivate(inner_threads) \ + shared(loop_total, task_total) + { + int copied = -1; + + if (omp_get_num_threads () != inner_threads) + abort (); + +#pragma omp barrier +#pragma omp for reduction(+:loop_total) + for (int i = 0; i < inner_threads; ++i) + loop_total++; + +#pragma omp single copyprivate(copied) + copied = 0x1234; + if (copied != 0x1234) + abort (); + +#pragma omp single nowait +#pragma omp task shared(task_total) + { +#pragma omp atomic update + task_total++; + } + } + + if (omp_get_thread_num () != outer_id) + abort (); + } + +#pragma omp barrier + if (omp_get_thread_num () != outer_id) + abort (); + } + + if (loop_total != 2 + round % 4 || task_total != 1) + abort (); + } + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/barrier-switch-1.c b/libgomp/testsuite/libgomp.c/barrier-switch-1.c index 17ebb91a2a3..1d2d0ea51e8 100644 --- a/libgomp/testsuite/libgomp.c/barrier-switch-1.c +++ b/libgomp/testsuite/libgomp.c/barrier-switch-1.c @@ -1,6 +1,11 @@ /* Exercise changing between flat and centralized barriers for a live team. N.b. there should be no observable difference between switching and not, but - having a testcase at least exercises the code path. */ + having a testcase at least exercises the code path. + + The switching happens after the spin count is dynamically throttled due to + the number of threads exceeding the number of available CPU's. It is then + switched back after a helper thread completes and the number of threads + drops back down. */ /* { dg-do run { target linux_futex_waitv } } */ /* { dg-set-target-env-var GOMP_BARRIER_TYPE "auto" } */ /* { dg-set-target-env-var GOMP_SPINCOUNT "100000000" } */ @@ -93,9 +98,9 @@ main (void) } /* The current barrier is flat. Four managed threads are now running - on three available CPUs, so completion selects tree. */ + on three available CPUs, so completion selects centralized. */ barrier (); - /* Exercise the selected tree barrier. */ + /* Exercise the selected centralized barrier. */ barrier (); #pragma omp masked @@ -104,8 +109,9 @@ main (void) wait_for (&helper_finished); } - /* The current barrier is tree. The helper nested team has finished, - returning to three managed threads, so completion selects flat. */ + /* The current barrier is centralized. The helper nested team has + finished, returning to three managed threads, so completion + selects flat. */ barrier (); /* Exercise the selected flat barrier. */ barrier (); diff --git a/libgomp/testsuite/libgomp.c/barrier-task-reduction.c b/libgomp/testsuite/libgomp.c/barrier-task-reduction.c new file mode 100644 index 00000000000..8eb8934ce18 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/barrier-task-reduction.c @@ -0,0 +1,64 @@ +/* Verify the additional team barrier used in + GOMP_workshare_task_reduction_unregister. Each loop iteration creates an + in_reduction task, so the loop-end scheduling point must finish every task + and reduction before GOMP_workshare_task_reduction_unregister synchronizes + all logical IDs. + + Repeated 2 -> 4 -> 1 -> 3 transitions exercise task-reduction allocation, + unregister, and retained-team reuse with the tree barrier. This is a + focused complement to broad task-reduction language tests. */ +/* { dg-do run { target linux_futex_waitv } } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "tree" } */ + +#include +#include + +enum { rounds = 8 }; + +static long long reduction_sum; +static int completed; + +static void +run_region (int nthreads, int epoch) +{ + long long expected = (long long) nthreads * (nthreads + 1) / 2 + epoch; + reduction_sum = 0; + completed = 0; + +#pragma omp parallel num_threads(nthreads) \ + firstprivate(epoch, expected, nthreads) + { +#pragma omp for schedule(static, 1) reduction(task, + : reduction_sum) + for (int i = 0; i < nthreads; ++i) + { + long long contribution = i + 1; + if (i == 0) + contribution += epoch; +#pragma omp task firstprivate(contribution) in_reduction(+ : reduction_sum) + { + reduction_sum += contribution; +#pragma omp atomic update + completed++; + } + } + + if (reduction_sum != expected || completed != nthreads) + abort (); + } + + if (reduction_sum != expected || completed != nthreads) + abort (); +} + +int +main (void) +{ + static const int sizes[] = { 2, 4, 1, 3 }; + int epoch = 0; + + omp_set_dynamic (0); + for (int round = 0; round < rounds; ++round) + for (int i = 0; i < 4; ++i) + run_region (sizes[i], ++epoch); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/barrier-tree-flush.c b/libgomp/testsuite/libgomp.c/barrier-tree-flush.c new file mode 100644 index 00000000000..b48df91c92e --- /dev/null +++ b/libgomp/testsuite/libgomp.c/barrier-tree-flush.c @@ -0,0 +1,58 @@ +/* Verify that data is flushed through the radix-four tree barrier and through + release of a retained team. Team sizes 15, 16, and 17 exercise a partial + second tree level, its exact boundary, and the first node beyond that + boundary. + + Each thread writes ordinary, non-atomic data before an explicit barrier and + every thread verifies that the complete payload has been flushed + afterwards. Consecutive parallel regions also verify that the primary + thread's writes are flushed when workers held at the preceding final + barrier are released for their next team. */ +/* { dg-do run { target linux_futex_waitv } } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "tree" } */ + +#include +#include + +enum { max_threads = 17, rounds = 24 }; + +static int slots[max_threads]; +static int next_epoch; + +static void +run_size (int nthreads, int epoch) +{ + next_epoch = epoch; + for (int i = 0; i < nthreads; ++i) + slots[i] = 0; + +#pragma omp parallel num_threads(nthreads) firstprivate(nthreads, epoch) + { + int tid = omp_get_thread_num (); + + if (next_epoch != epoch) + abort (); + + slots[tid] = epoch; +#pragma omp barrier + + for (int i = 0; i < nthreads; ++i) + if (slots[i] != epoch) + abort (); + } + + for (int i = 0; i < nthreads; ++i) + if (slots[i] != epoch) + abort (); +} + +int +main (void) +{ + static const int sizes[] = { 15, 16, 17, 16, 15, 17 }; + + omp_set_dynamic (0); + for (int round = 0; round < rounds; ++round) + run_size (sizes[round % 6], round + 1); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/barrier-tree-task.c b/libgomp/testsuite/libgomp.c/barrier-tree-task.c new file mode 100644 index 00000000000..23aa1eb5860 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/barrier-tree-task.c @@ -0,0 +1,136 @@ +/* Verify that a secondary tree coordinator drains tasks while gathering its + children at both ordinary and final barriers. In libgomp's radix-four + topology logical thread 4 gathers threads 5 through 7. Those children and + thread 0 remain in user code until the queued task reports that thread 4 + ran it, making thread 4's child-gather wait the only runtime path that can + execute the task. + + The ordinary case checks completion and release of every participant. The + final case additionally exercises setting BAR_HOLDING_SECONDARIES after + child gathering and task draining have both completed. This is an + implementation regression test and is deliberately restricted to the new + tree backend. + + When run on targets without a tree barrier this still forces a non-last + waiter to execute a task before other threads can enter the barrier. + Forces exercising of a code path not forced elsewhere in the testsuite. */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "tree" } */ + +#include +#include +#include + +enum { rounds = 32 }; + +static void +wait_for (int *value) +{ + int observed; + do + { +#pragma omp atomic read + observed = *value; + if (!observed) + sched_yield (); + } + while (!observed); +} + +static void +run_ordinary (void) +{ + int release_coordinator = 0; + int release_others = 0; + int task_ran = 0; + int after_barrier = 0; + +#pragma omp parallel num_threads(8) \ + shared(release_coordinator, release_others, task_ran, after_barrier) + { + int tid = omp_get_thread_num (); + + if (tid == 0) + { +#pragma omp task shared(task_ran) + { + if (omp_get_thread_num () != 4) + abort (); +#pragma omp atomic write + task_ran = 1; + } + +#pragma omp atomic write + release_coordinator = 1; + wait_for (&task_ran); +#pragma omp atomic write + release_others = 1; + } + else if (tid == 4) + wait_for (&release_coordinator); + else + wait_for (&release_others); + +#pragma omp barrier + + int observed; +#pragma omp atomic read + observed = task_ran; + if (!observed) + abort (); +#pragma omp atomic update + after_barrier++; + } + + if (task_ran != 1 || after_barrier != 8) + abort (); +} + +static void +run_final (void) +{ + int release_coordinator = 0; + int release_others = 0; + int task_ran = 0; + +#pragma omp parallel num_threads(8) \ + shared(release_coordinator, release_others, task_ran) + { + int tid = omp_get_thread_num (); + + if (tid == 0) + { +#pragma omp task shared(task_ran) + { + if (omp_get_thread_num () != 4) + abort (); +#pragma omp atomic write + task_ran = 1; + } + +#pragma omp atomic write + release_coordinator = 1; + wait_for (&task_ran); +#pragma omp atomic write + release_others = 1; + } + else if (tid == 4) + wait_for (&release_coordinator); + else + wait_for (&release_others); + } + + if (task_ran != 1) + abort (); +} + +int +main (void) +{ + omp_set_dynamic (0); + for (int round = 0; round < rounds; ++round) + { + run_ordinary (); + run_final (); + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/barrier-workshare-task.c b/libgomp/testsuite/libgomp.c/barrier-workshare-task.c new file mode 100644 index 00000000000..63bd3c056ff --- /dev/null +++ b/libgomp/testsuite/libgomp.c/barrier-workshare-task.c @@ -0,0 +1,102 @@ +/* Verify the task-aware split barrier interface used in gomp_work_share_end. + Tasks are queued immediately before a dynamically scheduled loop. The + loop's implicit GOMP_loop_end barrier must drain all team tasks, flush their + payloads, and release every logical ID before a second work-share is + allocated and reclaimed. + + Repeated 2 -> 4 -> 1 -> 3 team-size transitions cover retained-worker + reuse. This test selects the flat implementation; tree split-barrier + callers are covered by the copyprivate and task-reduction tests. */ + +/* { dg-do run { target linux_futex_waitv } } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "flat" } */ + +#include +#include +#include +#include + +enum { tasks = 4, rounds = 8 }; + +struct state +{ + int completed; + int first_iterations; + int second_iterations; + int after_first; + uint32_t payload[tasks]; +}; + +static uint32_t +task_payload (int task, int epoch) +{ + uint32_t value = (uint32_t) (epoch * tasks + task + 1); + for (unsigned int i = 0; i < 128; ++i) + value = value * 1664525u + 1013904223u + i; + return value; +} + +static void +run_region (int nthreads, int epoch) +{ + struct state state; + memset (&state, 0, sizeof (state)); + +#pragma omp parallel num_threads(nthreads) firstprivate(nthreads, epoch) \ + shared(state) + { +#pragma omp single nowait + for (int task = 0; task < tasks; ++task) + { +#pragma omp task firstprivate(task, epoch) shared(state) + { + state.payload[task] = task_payload (task, epoch); +#pragma omp atomic update + state.completed++; + } + } + + /* A runtime schedule uses gomp_work_share_end's split start/end barrier + rather than lowering directly to GOMP_barrier. */ +#pragma omp for schedule(dynamic, 1) + for (int i = 0; i < nthreads * 3 + 1; ++i) + { +#pragma omp atomic update + state.first_iterations++; + } + + if (state.completed != tasks) + abort (); + for (int task = 0; task < tasks; ++task) + if (state.payload[task] != task_payload (task, epoch)) + abort (); +#pragma omp atomic update + state.after_first++; + +#pragma omp for schedule(guided, 1) + for (int i = 0; i < nthreads * 2 + 3; ++i) + { +#pragma omp atomic update + state.second_iterations++; + } + } + + if (state.completed != tasks + || state.first_iterations != nthreads * 3 + 1 + || state.second_iterations != nthreads * 2 + 3 + || state.after_first != nthreads) + abort (); +} + +int +main (void) +{ + static const int sizes[] = { 2, 4, 1, 3 }; + int epoch = 0; + + omp_set_dynamic (0); + for (int round = 0; round < rounds; ++round) + for (int i = 0; i < 4; ++i) + run_region (sizes[i], ++epoch); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/barrier_generation_overflow.c b/libgomp/testsuite/libgomp.c/barrier_generation_overflow.c index 1dc4b00e4c3..1e80b5abc5b 100644 --- a/libgomp/testsuite/libgomp.c/barrier_generation_overflow.c +++ b/libgomp/testsuite/libgomp.c/barrier_generation_overflow.c @@ -21,19 +21,19 @@ 1. A single long-lived 2-thread team executes 1,048,575 plain barriers without any tasks. That advances the non-cancellable generation to the highest value value it can hold before wraparound (0xfffff000). - 2. Thread 1 creates one deferred task and then falls moves on to the final + 2. Thread 1 creates one deferred task and then moves on to the final barrier. 3. Thread 0 waits outside that final barrier until the deferred task has - actually started. In this testcase there are no other task scheduling - points between task creation and the final barrier, so knowing the task - has started implies that thread 1 has entered the plain barrier wait - path. + actually started. In this testcase there are no other points where + libgomp will schedule tasks between task creation and the final barrier, + so knowing the task has started implies that thread 1 has entered the + plain barrier wait path. 4. Thread 0 then enters the 1,048,576th plain barrier use while the task is still running, so the wrap-sensitive raw-BAR_WAS_LAST completion check is exercised with task_count != 0. - On this Linux backend BAR_INCR = 4096, so the plain generation wraps after - 2^32 / 4096 = 1,048,576 uses of the same plain barrier generation. */ + On the futex_waitv backend BAR_INCR = 4096, so the plain generation wraps + after 2^32 / 4096 = 1,048,576 uses of the same plain barrier generation. */ static int secondary_task_started; diff --git a/libgomp/testsuite/libgomp.c/cancel-late-arrival-1.c b/libgomp/testsuite/libgomp.c/cancel-late-arrival-1.c new file mode 100644 index 00000000000..a1201f9c28f --- /dev/null +++ b/libgomp/testsuite/libgomp.c/cancel-late-arrival-1.c @@ -0,0 +1,132 @@ +/* Force late arrival at an already-cancelled flat barrier. Thread 0 is + released toward the barrier before cancellation is requested, while thread 2 + waits until thread 1 has committed cancellation before starting the same + barrier. The late waiter must return cancelled without recording an arrival + for the cancelled generation. A following plain barrier makes a runtime + with assertions enabled scan each thread-local generation and also verifies + that team reuse remains live. + + When ran on non-flat barrier still forces barrier entry after cancellation. + That is a code path not forced elsewhere in the testsuite, hence running it + on all targets. */ +/* { dg-set-target-env-var OMP_CANCELLATION "true" } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "flat" } */ + +#include +#include +#include + +enum { rounds = 64 }; + +static int early_ready; +static int late_ready; +static int cancel_committed; +static int escaped; + +static int +read_atomic (int *value) +{ + int result; +#pragma omp atomic read + result = *value; + return result; +} + +static void +wait_for (int *value) +{ + while (!read_atomic (value)) + sched_yield (); +} + +static void +mark_committed_cancel (int *active) +{ + if (*active) + { +#pragma omp atomic write + cancel_committed = 1; + } +} + +static void +run_cancelled_region (void) +{ + early_ready = 0; + late_ready = 0; + cancel_committed = 0; + escaped = 0; + +#pragma omp parallel num_threads(3) \ + shared(early_ready, late_ready, cancel_committed, escaped) + { + int tid = omp_get_thread_num (); + + if (tid == 1) + { + int mark __attribute__ ((cleanup (mark_committed_cancel))) = 1; + wait_for (&early_ready); + wait_for (&late_ready); + + /* Cleanup runs only after GOMP_cancel has committed BAR_CANCELLED + and transferred control out of this branch. */ +#pragma omp cancel parallel + abort (); + } + else + { + if (tid == 0) + { +#pragma omp atomic write + early_ready = 1; + } + else + { +#pragma omp atomic write + late_ready = 1; + wait_for (&cancel_committed); + } + +#pragma omp barrier +#pragma omp atomic update + escaped++; + } + } + + if (!cancel_committed || escaped != 0) + abort (); +} + +static void +run_plain_control (void) +{ + int arrived = 0; + +#pragma omp parallel num_threads(3) shared(arrived) + { +#pragma omp atomic update + arrived++; +#pragma omp barrier + if (read_atomic (&arrived) != 3) + abort (); + } + + if (arrived != 3) + abort (); +} + +int +main (void) +{ + if (!omp_get_cancellation ()) + abort (); + omp_set_dynamic (0); + + for (int round = 0; round < rounds; ++round) + { + run_cancelled_region (); + run_plain_control (); + } + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/cancel-late-arrival-2.c b/libgomp/testsuite/libgomp.c/cancel-late-arrival-2.c new file mode 100644 index 00000000000..71ff578e301 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/cancel-late-arrival-2.c @@ -0,0 +1,8 @@ +/* Verify late arrival at an already-cancelled tree barrier. This runs the + same controlled cancellation and checking-barrier sequence as the flat + variant while selecting the tree arrival protocol. */ +/* { dg-do run { target linux_futex_waitv } } */ +/* { dg-set-target-env-var OMP_CANCELLATION "true" } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "tree" } */ + +#include "cancel-late-arrival-1.c" diff --git a/libgomp/testsuite/libgomp.c/cancel-next-epoch-wrap.c b/libgomp/testsuite/libgomp.c/cancel-next-epoch-wrap.c new file mode 100644 index 00000000000..ae568a7feda --- /dev/null +++ b/libgomp/testsuite/libgomp.c/cancel-next-epoch-wrap.c @@ -0,0 +1,87 @@ +/* Check that cancellation of the "next" barrier is not misattributed to + cancellation of the "current" barrier. After 255 successful uses, secondary + threads arrive at use 256 before the primary. The primary completes that + barrier, wrapping the eight-bit cancellable generation to zero, and + immediately cancels the next epoch. + + A secondary still observing completion of use 256 must not treat the next + epoch's BAR_CANCELLED flag as cancellation of its successful barrier or + roll back its local generation. Every secondary must pass the first + barrier and leave only at the following cancellation point. */ +/* { dg-do run { target linux_futex_waitv } } */ +/* { dg-set-target-env-var OMP_CANCELLATION "true" } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "tree" } */ + +#include +#include +#include + +enum { threads = 2, prewrap_rounds = 255 }; + +static int target_arrived; +static int after_first; +static int escaped_second; +static int inactive_cancel; + +int +main (void) +{ + if (!omp_get_cancellation ()) + abort (); + omp_set_dynamic (0); + +#pragma omp parallel num_threads(threads) \ + shared(target_arrived, after_first, escaped_second) + { + int tid = omp_get_thread_num (); + + for (int round = 0; round < prewrap_rounds; ++round) + { +#pragma omp cancel parallel if(inactive_cancel) +#pragma omp barrier + } + + if (tid != 0) + { +#pragma omp atomic update + target_arrived++; + } + else + { + int seen; + do + { +#pragma omp atomic read + seen = target_arrived; + if (seen != threads - 1) + sched_yield (); + } + while (seen != threads - 1); + } + + /* This successful use wraps the cancellable generation to zero. */ +#pragma omp barrier + + if (tid == 0) + { + /* This cancellation belongs to the following barrier epoch. */ +#pragma omp cancel parallel + abort (); + } + else + { +#pragma omp atomic update + after_first++; + +#pragma omp barrier +#pragma omp atomic update + escaped_second++; + } + } + + if (target_arrived != threads - 1 || after_first != threads - 1 + || escaped_second != 0) + abort (); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/cancel_incr_wraparound.c b/libgomp/testsuite/libgomp.c/cancel_incr_wraparound.c index b5687b75381..c4903e9a9d3 100644 --- a/libgomp/testsuite/libgomp.c/cancel_incr_wraparound.c +++ b/libgomp/testsuite/libgomp.c/cancel_incr_wraparound.c @@ -3,7 +3,7 @@ /* Regression test for bug seen during development. This exercises the case where `gomp_barrier_handle_tasks` is called with a - `state` with non-zero flags and while the cancel generation bitfield is + `state` that has non-zero flags while the cancel generation bitfield is about to wrap around. By doing this it exercises an edge case for `gomp_barrier_incremented` where `state > gen` but `next < gen`. diff --git a/libgomp/testsuite/libgomp.c/futex_waitv_overflow.c b/libgomp/testsuite/libgomp.c/futex_waitv_overflow.c index ecfa4ed1fa3..88c64034425 100644 --- a/libgomp/testsuite/libgomp.c/futex_waitv_overflow.c +++ b/libgomp/testsuite/libgomp.c/futex_waitv_overflow.c @@ -6,7 +6,7 @@ This exercises the case where `futex_waitv` is passed values that set the top bit of the futex word. A futex word is defined to be 32 bits. The generation is an unsigned value. We delay all secondary threads before - reaching the barrier on the 524288'th time. This ensures the primary thread + reaching the barrier on the 524289'th time. This ensures the primary thread enters the barrier, does not see any threads arriving, then sleeps in the kernel on one of these threads arriving. */ #include @@ -16,7 +16,7 @@ int main () { - int warmup = 524287; + int warmup = 524288; int delayed = 1; int delay_us = 100000; diff --git a/libgomp/testsuite/libgomp.c/team-held-pause.c b/libgomp/testsuite/libgomp.c/team-held-pause.c new file mode 100644 index 00000000000..8e034eadab9 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/team-held-pause.c @@ -0,0 +1,43 @@ +/* Verify that a hard pause releases workers retained at a previous final + barrier even when a one-thread parallel region has since replaced the + current team. The serial region does not need the retained workers, so + omp_pause_resource_all must find the older prev_barrier, release it, and + join the complete worker pool without hanging or using freed team state. + This variant exercises a retained flat barrier on the futex_waitv target and + the default barrier elsewhere. */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "flat" } */ + +#include +#include + +enum { threads = 4, rounds = 16 }; + +int +main (void) +{ + omp_set_dynamic (0); + + for (int round = 0; round < rounds; ++round) + { + int participants = 0; + +#pragma omp parallel num_threads(threads) shared(participants) + { +#pragma omp atomic update + participants++; + } + if (participants != threads) + abort (); + +#pragma omp parallel num_threads(1) + { + if (omp_get_num_threads () != 1 || omp_get_thread_num () != 0) + abort (); + } + + if (omp_pause_resource_all (omp_pause_hard) != 0) + abort (); + } + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/team-held-pthread-exit.c b/libgomp/testsuite/libgomp.c/team-held-pthread-exit.c new file mode 100644 index 00000000000..6180a2980be --- /dev/null +++ b/libgomp/testsuite/libgomp.c/team-held-pthread-exit.c @@ -0,0 +1,56 @@ +/* Verify cleanup of a retained team when a foreign initial thread exits. + The pthread first leaves workers held at a multi-threaded final barrier and + then runs a one-thread parallel region, which leaves that older barrier in + the thread pool. The pthread TLS destructor of `gomp_free_thread` must + release the retained tree barrier, join all workers, and free the pool + before pthread_join returns. Repetition also checks that cleanup does not + leak state into a later foreign initial thread. */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "tree" } */ + +#include +#include +#include +#include + +enum { threads = 4, rounds = 12 }; + +static void * +run_regions (void *argument) +{ + int participants = 0; + + omp_set_dynamic (0); +#pragma omp parallel num_threads(threads) shared(participants) + { +#pragma omp atomic update + participants++; + } + if (participants != threads) + abort (); + +#pragma omp parallel num_threads(1) + { + if (omp_get_num_threads () != 1 || omp_get_thread_num () != 0) + abort (); + } + + return argument; +} + +int +main (void) +{ + for (intptr_t round = 1; round <= rounds; ++round) + { + pthread_t driver; + void *argument = (void *) round; + void *result; + + if (pthread_create (&driver, NULL, run_regions, argument) != 0) + abort (); + if (pthread_join (driver, &result) != 0 || result != argument) + abort (); + } + + return 0; +} -- 2.43.0 From forge-bot+azoff@forge-stage.sourceware.org Mon Nov 2 16:25:46 2026 From: forge-bot+azoff@forge-stage.sourceware.org (=?UTF-8?q?Torbj=C3=B6rn=20Svensson=20via=20Sourceware=20Forge?=) Date: Mon, 02 Nov 2026 16:25:46 +0000 Subject: [PATCH v1] arm: Allow unconditional noce sequences on armv8.1-m [PR122965] Message-ID: From: Torbj?rn SVENSSON The Armv8.1-M profitability hook rejects sequences other than the recognized conditional arithmetic and VSEL patterns, even when the conversion has removed the conditional entirely. There is no need to reject a sequence once the conditional is gone, so use the usual profitability checks in that case. Leave the PR116444 restriction in place when IF_THEN_ELSE remains. For armv8.1-m.main, the generated code for gcc.target/arm/epilog-1.c changes from push {r3, r4, r5, lr} ldr r4, .L5 ldr r5, [r4] tst r5, #4 csinc r2, r2, r2, eq bl bar movs r0, #0 pop {r3, r4, r5, pc} to push {r4, lr} ldr r4, .L5 ldr r4, [r4] ubfx r4, r4, #2, #1 add r2, r2, r4 bl bar movs r0, #0 pop {r4, pc} PR target/122965 gcc/ChangeLog: * config/arm/arm.cc (arm_noce_conversion_profitable_p): Use default profitability checks for unconditional sequences. gcc/testsuite/ChangeLog: * gcc.target/arm/epilog-1.c: Expect UBFX and ADD for armv8.1-m.main. Signed-off-by: Torbj?rn SVENSSON --- Following Richard?s suggestion in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122965#c2, this patch updates arm_noce_conversion_profitable_p to use the default cost metric when the proposed sequence no longer contains an IF_THEN_ELSE. Regression tested on arm-none-eabi with r17-5743-ge33129b871c302 as the baseline. OK for trunk and releases/gcc-16? -- This is a forge pull request published on the gcc-patches mailing list mailing list as requested by Torbj?rn Svensson via Sourceware Forge . Forge discussion: https://forge.sourceware.org/gcc/gcc/pulls/265 Get it locally using: ``` git fetch forge-upstream "+refs/versioned_pull/265/*:refs/versioned_pull/265/*" git switch -c "pr-265-v1" "refs/versioned_pull/265/1/head" ``` Or, download the patch at: https://forge.sourceware.org/gcc/gcc/pulls/265.diff Created on: 2026-11-02 16:15:50+00:00 Latest update: 2026-11-02 16:25:44+00:00 Changes: 2 changed files, 16 additions, 3 deletions Head revision: azoff/gcc ref pr/bics commit d89cabcbec6c11dbb3e7dbf0081e665719cf3375 Base revision: gcc/gcc ref trunk commit e33129b871c30276acfaed2b435ae5b505b73655 r17-5743-ge33129b871c302 Merge base: e33129b871c30276acfaed2b435ae5b505b73655 Requested Reviewers: rearnsha Changed files: - M: gcc/config/arm/arm.cc - M: gcc/testsuite/gcc.target/arm/epilog-1.c gcc/config/arm/arm.cc | 15 ++++++++++++++- gcc/testsuite/gcc.target/arm/epilog-1.c | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 940c689b21e0e..7bea1805e8853 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -35116,7 +35116,20 @@ arm_noce_conversion_profitable_p (rtx_insn *seq, struct noce_if_info *if_info) if (arm_is_vsel_fp_insn (seq)) return true; - return false; + /* Keep the PR116444 restriction for conditional sequences, but use + normal profitability checks when the conditional has disappeared. */ + subrtx_iterator::array_type array; + for (rtx_insn *insn = seq; insn; insn = NEXT_INSN (insn)) + { + if (!NONDEBUG_INSN_P (insn)) + continue; + + FOR_EACH_SUBRTX (iter, array, PATTERN (insn), ALL) + if (GET_CODE (*iter) == IF_THEN_ELSE) + return false; + } + + return default_noce_conversion_profitable_p (seq, if_info); } /* Output assembly to read the thread pointer from the appropriate TPIDR diff --git a/gcc/testsuite/gcc.target/arm/epilog-1.c b/gcc/testsuite/gcc.target/arm/epilog-1.c index 70aa12c63ff64..86e7abfc79ae3 100644 --- a/gcc/testsuite/gcc.target/arm/epilog-1.c +++ b/gcc/testsuite/gcc.target/arm/epilog-1.c @@ -20,8 +20,8 @@ Below block is for non-armv8.1-m.main ** | Below block is for armv8.1-m.main -** tst r[0-9]+, #4 -** csinc r2, r2, r2, eq +** ubfx (r[0-9]+), r[0-9]+, #2, #1 +** add r2, r2, \1 ** ) ** bl bar -- 2.56.0 From mmalcomson@nvidia.com Mon Nov 2 16:25:12 2026 From: mmalcomson@nvidia.com (mmalcomson@nvidia.com) Date: Mon, 2 Nov 2026 16:25:12 +0000 Subject: [PATCH 2/4] libgomp: New barriers in new linux/futex_waitv target In-Reply-To: <20261102162514.3475056-1-mmalcomson@nvidia.com> References: <20261012170038.3418851-1-mmalcomson@nvidia.com> <20261102162514.3475056-1-mmalcomson@nvidia.com> Message-ID: <20261102162514.3475056-3-mmalcomson@nvidia.com> From: Matthew Malcomson This patch introduces two scalable barriers that perform better on the microbenchmark provided in PR119588 and uses a centralized barrier based on the existing linux/ implementation when that is optimal. EPCC micro-benchmarks show significant improvement, most higher-level benchmarks show little to no improvement but some do show significant benefits. The biggest improvement I've seen is approx. 20% on Spec 2026 `tealeaf`. We introduce it in a new target directory of linux/futex_waitv since it benefits from the futex_waitv syscall introduced in Linux 5.16. The two scalable barriers are a "flat" barrier, which usually performs better when OMP_WAIT_POLICY=active, and a "tree" based barrier (to be precise is a hypercube following LLVM's implementation, but I believe "tree" conveys the most meaning to the most people) which usually performs better when OMP_WAIT_POLICY=passive. A centralized barrier based on the original linux/ barrier design performs best for a plain barrier under OMP_WAIT_POLICY=passive, but can not naturally "hold" secondary threads in the "gathered" state. We choose between these barriers based on the `spincount` (the underlying variable determined by wait policy), whether we're at the implicit barrier at the end of a parallel region, and if the user specifically requests a given barrier type with the new environment variables GOMP_BARRIER_TYPE and GOMP_FORKJOIN_BARRIER_TYPE which both accept an option of flat, tree, centralized, or auto. The outline of the flat barrier is: 1) Each thread associated with a barrier has its own ID (currently the team_id of the team that the current thread is a part of). 2) When a thread arrives at the barrier it marks its "arrived flag" as having arrived. 3) ID 0 (which is always the thread which does the bookkeeping for this team, at the top-level it's the primary thread) waits on each of the other threads "arrived flags". It executes tasks while waiting on these threads to arrive. 4) Once ID 0 sees all other threads have arrived it signals to all secondary threads that the barrier is complete via incrementing the global generation (as usual). While the outline of the tree-based barrier is: 1) Each thread associated with a barrier has its own ID (currently the team_id of the team that the current thread is a part of). 2) When a thread arrives at the barrier it first waits on any children it might have to arrive, then it indicates its arrival to its parent by incrementing its "arrived flag". They then wait on the global generation for the indication that all threads have arrived. 3) The primary thread has ID 0 and all other threads are either its direct children or children of its children. 4) When all its children have indicated their arrival to the primary thread, the primary thread then increments the global generation number to indicate to all secondary threads that the barrier has completed. Fundamental difference that affects performance being that we have thread-local "arrived" flags instead of a single counter. That means there is less contention and appears to speed up the barrier significantly when threads are hitting the barrier very hard. Another interesting difference is that the "coordinating" thread is pre-determined rather than "whichever thread hits the barrier last". - This means that the behaviour of the pre-determined "coordinating" thread must be more complicated while it's waiting on other threads to arrive. See the task handling in `gomp_team_barrier_wait_on_two_flags`. - Because we assign the "coordinating" thread to be the primary thread this does mean that in-between points (3) and (4) above the primary thread can see the results of the operations of all secondary threads. This is important for the second optimisation in this patch where we only go through one barrier per iteration in the main execution loop of `gomp_thread_start` for top-level threads. This second optimisation is as follows: - In the current libgomp implementation each non-nested thread in the thread pool works in a loop along the lines of: 1: perform work wait for all threads to have finished (gather all threads) free some data structures wait for "go" signal (wait on release) goto 1 - The "wait for all threads to have finished" and "wait for go signal" actions are both currently implemented with full barriers. - The implementation of each barrier has both of those steps -- "wait for all threads to have finished" and then all threads except the last "wait for go signal". - LLVM only has one barrier between executing parallel regions in the main loop of a cached thread as can be observed by running in the debugger or by observing the performance numbers in the micro-benchmark I added to PR119588 - We can naturally "pause" the new barrier in a way similar to LLVM so that threads only go through a barrier once per parallel region. Changes made for this optimisation: 1) Introduce the target hook `gomp_barrier_can_hold` to let generic code know when the "final" barrier holds all secondary threads until the primary thread calls `gomp_team_barrier_done_final`. When `gomp_barrier_can_hold` returns false then the semantics of the "final" barrier are essentially the same as that of the "team" barrier in that when the primary thread is past it all secondary threads are known to have been released. 2) When there are threads "held" waiting for new work, these threads are now waiting on the barrier of their previous team rather than waiting on the barrier in the "thread_pool". Hence we introduce a `prev_barrier` field on pool.h that records the team barrier of the last team -- this is the barrier that needs to be "released". - This is recorded on the thread_pool in `gomp_team_end` and used to release the secondary threads in `gomp_team_start` (plus `gomp_free_thread` and `gomp_pause_host`). 3) Change the "simple" barrier used by the thread_pool to one using the "centralized" implementation. Since we no longer go through the "simple" barrier except in the case of a new thread or an exiting thread, this barrier is no longer a performance bottleneck. That means we no longer require it to be of the faster implementation introduced in the first patch mentioned above. - This means adding back a field of `awaited` for this barrier only into the `gomp_barrier_t` data structure. - This also means that the "simple" barrier no longer needs a thread identification number. So we can remove the argument of `thr->ts.team_id` to each of these functions, which is nice because logically these functions are not tied to a given team. 4) Using a "centralized" implementation means that the extra allocation and complexity around the new barrier does not affect the "reinit" functions used in team.c. - We do however need to add some extra complexity around calculating the number of threads exiting and the number of threads starting for the transition from the old team to the new one. 5) The "final" barrier is adjusted so that once all threads have arrived and all tasks have been performed the primary thread continues while all secondary threads wait. - An interface to releasing all secondary threads is introduced and that is called on the `prev_barrier` stored on the thread pool as mentioned above. - This state of "secondaries held but primary to continue" is indicated by a new flag in the generation number. This ends up with a new split on implementation between the four kinds of barrier interface presented to the generic code: - "simple" barrier is now a centralized barrier. - "team" barrier is a more scalable, tasking barrier. This barrier is never called directly after a cancellable barrier. Hence it does not have to handle the BAR_CANCELLED flag in the generation. - "team final" barrier is a scalable tasking barrier that can break half-way through in order to provide different memory semantics. - "cancel" barrier is a scalable tasking barrier that can be cancelled. -------------- There are a few subtleties in this change to be aware of: 1) The memory ordering between secondary and primary threads has some subtle correctness reasoning. - In the existing behaviour there is an acquire-release ordering from all threads to each other after having gone through the first barrier (when the primary thread is executing code in between parallel regions). In the new change there is an acquire-release ordering from all secondary threads to the primary thread, but not one in the other direction until after the primary thread has released all other threads in the team. - I believe this is fine -- the only difference in memory ordering is visible in threads that are not running any code (secondary threads just waiting on the primary one to release them). As far as the primary thread is concerned it knows that any stores added in other threads must be visible in its own one. - The memory model semantics at barrier regions (and specifically at the entry to a parallel region) are discussed in the OpenMP standard here: https://www.openmp.org/spec-html/5.0/openmpsu96.html#x127-4920002.17.8 It explicitly calls out that on entry to a parallel region "the behavior is as if the release flush performed by the master thread on entry to the parallel region synchronizes with the acquire flush performed on entry to each implicit task that is assigned to a different thread" which is precisely the second "release" half of the barrier. The exit from a parallel region is an implicit barrier and so the documentation could be interpreted as requiring an implicit release/acquire flush both ways -- but it's hard to decide what the semantics of a release flush from the primary syncing with an acquire flush in the secondary means in the time when the secondary is not performing any code (as soon as the secondaries do start to perform code there is indeed a flush from the primary to them). 2) In gomp_barrier_handle_tasks the existing race condition between a thread leaving a tasking barrier and the primary thread changing the `team` underneath it becomes more of a problem. - TSAN pointed this out to me (surprisingly seems to work pretty well if building libgomp with TSAN). - Race condition is: - Secondary thread enters `gomp_barrier_handle_tasks` then gets interrupted. - Some other thread executes the last tasks, clears the flags, increments the generation. - Primary thread continues and eventually calls `gomp_team_start` with a new team. It stores this new team on `nthr->ts.team` while in `gomp_team_start`. - Then secondary thread restarts and reads `thr->ts.team`. This is now the *next* team. - Before this was mostly benign as the new team is initialised to all zeros so no tasks get run. With this patch we have to account for this data race as we have removed the secondary synchronisation point of the "simple barrier" in each iteration around the gomp_thread_start loop. This means that other threads could race ahead and schedule new tasks before the secondary thread wakes up. - In order to account for this I pass the "current" barrier that we're waiting on into `gomp_barrier_handle_tasks`. 3) We adjust when we save the "last_team" in `gomp_team_end`. Had to adjust something in this function in order to save the "prev_barrier" (i.e. the barrier that threads in the non-nested gomp_thread_start main loop are waiting on). - Needed to ensure that if `last_team` was used we still had access to `prev_barrier`. There was one existing case where the team of non-nested threads was not getting saved -- when there was a 1 thread artificial team in the outermost scope (that is one higher than "not nested"). - Chose to save teams in this case as well. 4) We still need to have a second barrier in the primary thread to synchronise threads that are starting (and hence were not held in the previous team barrier) or exiting (and hence will not be synchronised with primary in next iteration). The synchronisation of threads that are exiting is to ensure all threads have exited the "holding" team barrier before that team gets freed. This can happen in the below case: 1) Secondary thread A is in team barrier. 2) All tasks are done, primary thread continues. 3) Primary thread gets a new team ready that does not include A. (Previous team still saved in `pool->last_team`). 4) Primary thread releases all threads from team barrier (but A does not move due to scheduling). 5) Primary thread and all other threads in this new team perform their work. 6) Primary thread ends this new team. This replaces the previous team on `pool->last_team` and calls `free` on it. 7) Now secondary thread A gets scheduled, and attempts to use the previously freed team barrier. ------------------------------ Since we have three implementations of barriers (tree-based, flat, and centralized) we need some way to choose between them. We allow the user to specify directly with an environment variable of GOMP_BARRIER_TYPE={flat,tree,centralized,auto}, and by default adjust based on how long each thread will spin on a flag. Due to the subtleties around the barrier in between parallel regions described below we allow the user to specify this with GOMP_FORKJOIN_BARRIER_TYPE={flat,tree,centralized,auto}. N.b. `forkjoin` may be a slight misnomer as it's not used when spawning new threads like in a nested region but it matches the LLVM environment variable naming and feels like a descriptive name. Explicit selection is set at initialization time, and how long threads spin for is also mostly set at initialization time. That said, there is the possibility that the amount of spinning changes due to the number of threads started. When `gomp_managed_threads` becomes greater than `gomp_available_cpus` we switch to using `gomp_throttled_spin_count_var`. Hence in order to choose barrier type according to the amount of spinning done on a control word we need to account for this. This decision can change at runtime, we require the decision to stay constant for an entire generation of a barrier (if one thread performs a tree barrier while another performs the flat barrier, the whole would not perform either properly). The safe place to make this choice is when all threads have entered the barrier but not exited it -- we then make the decision for the next generation. At this point, other threads have all synchronised with the one making the decision and hence we can perform the write non-atomically and on the thread that is incrementing the main generation. The discussion of defaults is somewhat interesting: - For OMP_WAIT_POLICY=passive, the centralized barrier (implemented in much the same way as the existing linux/ barrier) is most performant on plain barriers (parallel region discussed below). - For OMP_WAIT_POLICY=active the flat barrier is the most performant on average in all thread-counts etc. - For the end of a PARALLEL region *without tasks being performed on it* the tree-based barrier is the most performant for OMP_WAIT_POLICY=passive (because it can perform the "hold half way" optimisation without extra synchronisation). - For the end of a PARALLEL region *with tasks being performed on it* the centralized barrier is the most performant. This because if the primary thread ends up performing tasks there is extra overhead from having to possibly wake it up from futex_wait in the tasking loop once all tasks have been completed. When that extra overhead is in place the "hold half way" optimisation is (mostly) lost. - I ran an experiment only waking up the primary thread when all tasks have completed. Performance was not obviously improved on the EPCC microbenchmarks. Note that in the above and below descriptions OMP_WAIT_POLICY={active,passive} is mostly a shorthand for "do we enter futex_wait". The biggest percentage differences are the differences between the "centralized" and "flat" barriers when OMP_WAIT_POLICY=active. The biggest absolute differences are between the "centralized" and "flat" barriers when OMP_WAIT_POLICY=passive -- but in the other direction. Hence the most-expected optimum for a given regime can be summarised as: - If OMP_WAIT_POLICY=active, use "flat". - If OMP_WAIT_POLICY=passive: - Plain barriers should be "centralized". - Implicit barriers in between parallel regions should be: - "centralized" if there will be notable tasks running on them. - "tree" if there will not be tasks running on them. With machine variance having an impact on these statements. Working on the belief that attempting to dynamically choose barrier kind based on whether the previous barrier used `futex_wait` or not is overly complicated I chose a spin_count above which we guess that `futex_wait` will not be called and use "flat" barrier above that number. This spin count is adjusted so that an unspecified OMP_WAIT_POLICY chooses the "flat" barrier. Below that spin_count we use "centralized" for plain barriers and "tree" for barriers in between PARALLEL regions. The reasons for choosing "tree" in between PARALLEL regions are two-fold: 1) The environment selection of GOMP_BARRIER_TYPE can allow choosing "centralized" all the time. 2) In the "auto" selection, we have the possibility that spin_count increases due to threads exiting. If this happens and the barrier choice goes from "centralized" to "flat" then we would have to make a distinction between `gomp_barrier_can_hold` returning information about what algorithm the *previous* final barrier ran or what algorithm the *in process* final barrier is running. - If "auto" disallows such a transition of _final barrier switching from "centralized" to either "flat" or "tree" at runtime then we don't need to be concerned about this. ------------------------------ I've had to adjust the interface to the other barriers. Most of the cases are simply to add an extra unused parameter. There are also some dummied out functions to add. Note that this patch should be included with the "overhead-reduction" patch that I have upstream at the same time. This because there is an existing race condition between `gomp_finish_task` in the secondary thread and the `gomp_init_task` that the primary thread performs. This patch changes that race condition into a deterministic incorrect ordering. The "overhead-reduction" turns it into a deterministic correct ordering. Testing done: - Bootstrap & regtest on aarch64 and x86_64. - With & without _LIBGOMP_CHECKING_. - Testsuite with & without OMP_WAIT_POLICY=passive for GOMP_BARRIER_TYPE=flat, GOMP_BARRIER_TYPE=tree, GOMP_BARRIER_TYPE=centralized, and unspecified barrier type. - With and without configure `--enable-linux-futex=no` for posix target. - With and without configure `--enable-linux-futex-waitv=no` to check we haven't broken original linux/ target. - Cross compilation & regtest on arm. - Built gcn, rtems, nvptx targets (just building -- not ran testsuite). - TSAN with checks against new/old "fingerprints" of warnings raised from the libgomp testsuite. Performance testing done: - SPEC 2026 speed (those benchmarks using OpenMP) - SPEC OMP 2012 - SPEC HPC 2021 (restricted to one socket) - EPCC OpenMP Microbenchmarks. - Microbenchmark mentioned in PR119588. EPCC OpenMP microbenchmarks ran with the cross-product of: - OMP_WAIT_POLICY={active,unset,passive} - OMP_PROC_BIND={close,unset} - OMP_NUM_THREADS={4,unset} - GOMP_BARRIER_TYPE={flat,tree,centralized,auto} libgomp/ChangeLog: * barrier.c (GOMP_barrier): Pass barrier ID argument. (GOMP_barrier_ext): Likewise. (GOMP_barrier_cancel): Likewise. (GOMP_barrier_cancel_ext): Likewise. * config/gcn/bar.c (gomp_barrier_wait_end): Add unused barrier ID argument. (gomp_barrier_wait): Take and pass barrier ID argument. (gomp_barrier_wait_last): Likewise. (gomp_team_barrier_wait_end): Likewise. Pass barrier and increment arguments to gomp_barrier_handle_tasks. (gomp_team_barrier_wait): Take and pass barrier ID argument. (gomp_team_barrier_wait_final): Likewise. (gomp_team_barrier_wait_cancel_end): Likewise. Pass barrier and increment arguments to gomp_barrier_handle_tasks. (gomp_team_barrier_wait_cancel): Take and pass barrier ID argument. * config/gcn/bar.h (gomp_barrier_init): Add unused extra allocation argument. (gomp_barrier_extra_alloc): New function. (gomp_barrier_wait): Add barrier ID argument. (gomp_barrier_wait_last): Likewise. (gomp_barrier_wait_end): Likewise. (gomp_team_barrier_wait): Likewise. (gomp_team_barrier_wait_final): Likewise. (gomp_team_barrier_wait_end): Likewise. (gomp_team_barrier_wait_cancel): Likewise. (gomp_team_barrier_wait_cancel_end): Likewise. (gomp_barrier_wait_start): Likewise. (gomp_barrier_wait_cancel_start): Likewise. (gomp_barrier_wait_final_start): Likewise. (gomp_team_barrier_done): Add unused increment argument. (gomp_barrier_has_completed): Take barrier and increment arguments. (gomp_barrier_can_hold): New function. (gomp_team_barrier_wake_on_increment): New function. (gomp_team_barrier_done_final): New function. * config/gcn/team.c (gomp_gcn_enter_kernel): Initialise prev_barrier. (gomp_thread_start): Pass barrier ID argument to gomp_team_barrier_wait_final. * config/linux/bar.c (gomp_barrier_wait_end): Add unused barrier ID argument. (gomp_barrier_wait): Take and pass barrier ID argument. (gomp_barrier_wait_last): Likewise. (gomp_team_barrier_wait_end): Likewise. Pass barrier and increment arguments to gomp_barrier_handle_tasks. (gomp_team_barrier_wait): Take and pass barrier ID argument. (gomp_team_barrier_wait_final): Likewise. (gomp_team_barrier_wait_cancel_end): Likewise. Pass barrier and increment arguments to gomp_barrier_handle_tasks. (gomp_team_barrier_wait_cancel): Take and pass barrier ID argument. * config/linux/bar.h (gomp_barrier_init): Add unused extra allocation argument. (gomp_barrier_wait): Add barrier ID argument. (gomp_barrier_wait_last): Likewise. (gomp_barrier_wait_end): Likewise. (gomp_team_barrier_wait): Likewise. (gomp_team_barrier_wait_final): Likewise. (gomp_team_barrier_wait_end): Likewise. (gomp_team_barrier_wait_cancel): Likewise. (gomp_team_barrier_wait_cancel_end): Likewise. (gomp_barrier_wait_start): Likewise. (gomp_barrier_wait_cancel_start): Likewise. (gomp_barrier_wait_final_start): Likewise. (gomp_team_barrier_done): Add unused increment argument. (gomp_barrier_has_completed): Take barrier and increment arguments. (gomp_barrier_can_hold): New function. (gomp_team_barrier_wake_on_increment): New function. (gomp_team_barrier_done_final): New function. (gomp_barrier_extra_alloc): New function. * config/linux/futex_waitv/bar.c: New file. * config/linux/futex_waitv/bar.h: New file. * config/linux/futex_waitv/futex_waitv.h: New file. * config/linux/futex_waitv/simple-bar.h: New file. * config/linux/wait.h (do_spin): Use spin_count. * config/nvptx/bar.c (gomp_barrier_wait_end): Add unused barrier ID argument. (gomp_barrier_wait): Take and pass barrier ID argument. (gomp_barrier_wait_last): Add unused barrier ID argument. (gomp_team_barrier_wait_end): Take barrier ID argument. Pass barrier and increment arguments to gomp_barrier_handle_tasks. (gomp_team_barrier_wait): Take and pass barrier ID argument. (gomp_team_barrier_wait_final): Likewise. (gomp_team_barrier_wait_cancel_end): Take barrier ID argument. Pass barrier and increment arguments to gomp_barrier_handle_tasks. (gomp_team_barrier_wait_cancel): Take and pass barrier ID argument. * config/nvptx/bar.h (gomp_barrier_init): Add unused extra allocation argument. (gomp_barrier_extra_alloc): New function. (gomp_barrier_wait): Add barrier ID argument. (gomp_barrier_wait_last): Likewise. (gomp_barrier_wait_end): Likewise. (gomp_team_barrier_wait): Likewise. (gomp_team_barrier_wait_final): Likewise. (gomp_team_barrier_wait_end): Likewise. (gomp_team_barrier_wait_cancel): Likewise. (gomp_team_barrier_wait_cancel_end): Likewise. (gomp_barrier_wait_start): Likewise. (gomp_barrier_wait_cancel_start): Likewise. (gomp_barrier_wait_final_start): Likewise. (gomp_team_barrier_done): Add unused increment argument. (gomp_barrier_has_completed): Take barrier and increment arguments. (gomp_barrier_can_hold): New function. (gomp_team_barrier_wake_on_increment): New function. (gomp_team_barrier_done_final): New function. * config/nvptx/team.c (gomp_nvptx_main): Initialise prev_barrier. (gomp_thread_start): Pass barrier ID argument to gomp_team_barrier_wait_final. * config/posix/bar.c (gomp_barrier_init): Add unused extra allocation argument. (gomp_barrier_wait): Take and pass barrier ID argument. (gomp_team_barrier_wait_end): Likewise. Pass barrier and increment arguments to gomp_barrier_handle_tasks. (gomp_team_barrier_wait_cancel_end): Likewise. (gomp_team_barrier_wait): Take and pass barrier ID argument. (gomp_team_barrier_wait_cancel): Likewise. * config/posix/bar.h (gomp_barrier_init): Add extra allocation argument. (gomp_barrier_extra_alloc): New function. (gomp_barrier_wait): Add barrier ID argument. (gomp_team_barrier_wait): Likewise. (gomp_team_barrier_wait_end): Likewise. (gomp_team_barrier_wait_cancel): Likewise. (gomp_team_barrier_wait_cancel_end): Likewise. (gomp_barrier_wait_start): Likewise. (gomp_barrier_wait_cancel_start): Likewise. (gomp_team_barrier_wait_final): Likewise. (gomp_barrier_wait_last): Likewise. (gomp_team_barrier_done): Add unused increment argument. (gomp_barrier_has_completed): Take barrier and increment arguments. (gomp_barrier_can_hold): New function. (gomp_team_barrier_wake_on_increment): New function. (gomp_team_barrier_done_final): New function. * config/posix/pool.h (gomp_get_thread_pool): Initialise prev_barrier. * config/posix/simple-bar.h (gomp_simple_barrier_init): Pass extra allocation argument. (gomp_simple_barrier_reinit): Rename local argument and pass through. (gomp_simple_barrier_wait): Pass dummy barrier ID argument. (gomp_simple_barrier_wait_last): Likewise. * config/rtems/bar.h (gomp_barrier_init): Add unused extra allocation argument. (gomp_barrier_extra_alloc): New function. (gomp_barrier_wait): Add barrier ID argument. (gomp_barrier_wait_last): Likewise. (gomp_barrier_wait_end): Likewise. (gomp_team_barrier_wait): Likewise. (gomp_team_barrier_wait_final): Likewise. (gomp_team_barrier_wait_end): Likewise. (gomp_team_barrier_wait_cancel): Likewise. (gomp_team_barrier_wait_cancel_end): Likewise. (gomp_barrier_wait_start): Likewise. (gomp_barrier_wait_cancel_start): Likewise. (gomp_barrier_wait_final_start): Likewise. (gomp_team_barrier_done): Add unused increment argument. (gomp_barrier_has_completed): Take barrier and increment arguments. (gomp_barrier_can_hold): New function. (gomp_team_barrier_wake_on_increment): New function. (gomp_team_barrier_done_final): New function. * configure: Regenerate. * configure.ac: Force SYS_futex_waitv definition. Add --enable-linux-futex-waitv handling and futex_waitv link check. Force enable_linux_futex_waitv. * configure.tgt: Add linux_path and use linux/futex_waitv in config_path when futex_waitv is enabled. * env.c (gomp_barrier_request): New variable. (gomp_forkjoin_barrier_request): Likewise. (parse_barrier_choice): New function. (omp_display_env): Display GOMP_BARRIER_TYPE and GOMP_FORKJOIN_BARRIER_TYPE. (initialize_env): Parse GOMP_BARRIER_TYPE and GOMP_FORKJOIN_BARRIER_TYPE. * libgomp.h: Include limits.h. (gomp_assert): New macro. (struct gomp_barrier_extra_alloc_needs): New structure. (enum gomp_barrier_type): New enum. (gomp_barrier_request): New declaration. (gomp_forkjoin_barrier_request): Likewise. (spin_count): New function. (struct gomp_thread_pool): Add prev_barrier member. (gomp_barrier_handle_tasks): Add barrier and increment arguments. * libgomp.texi (GOMP_BARRIER_TYPE): Document. (GOMP_FORKJOIN_BARRIER_TYPE): Likewise. * single.c (GOMP_single_copy_start): Pass barrier ID argument. (GOMP_single_copy_end): Likewise. * task.c (gomp_barrier_handle_tasks): Take barrier and increment arguments. Load thr->ts.team atomically and return early when it no longer matches the barrier being handled. Pass increment argument to barrier completion helpers. (GOMP_taskgroup_end): Pass barrier ID argument. (GOMP_workshare_task_reduction_unregister): Likewise. * team.c (gomp_release_held_threads): New function. (gomp_thread_start): Pass barrier ID arguments. Avoid the second pool barrier when the team barrier can hold secondary threads. (get_last_team): Add assertions for cached team barrier state. (gomp_new_team): Allocate aligned barrier extra storage as part of the team allocation and pass it to gomp_barrier_init. (gomp_free_thread): Release held threads and adjust pool barrier use. (gomp_barrier_wait_n): New function. (gomp_team_start): Track new and exiting threads, use pool barrier to handle these if there are any, avoid pool barrier if none and `gomp_barrier_can_hold` is true. (gomp_team_end): Pass barrier ID arguments, release nested-team threads explicitly, cache held top-level team barriers, and add assertions before freeing or caching teams. (gomp_pause_host): Release held threads and adjust pool barrier use. * testsuite/lib/libgomp.exp (check_effective_target_linux_futex_waitv): New effective target. * testsuite/libgomp-site-extra.exp.in (libgomp_config_path): New variable. * testsuite/libgomp.c++/task-reduction-20.C: New test. * testsuite/libgomp.c++/task-reduction-21.C: New test. * testsuite/libgomp.c-c++-common/gomp-barrier-type-env-auto.c: New test. * testsuite/libgomp.c-c++-common/gomp-barrier-type-env-flat.c: New test. * testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-1.c: New test. * testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-2.c: New test. * testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-3.c: New test. * testsuite/libgomp.c-c++-common/gomp-barrier-type-env-mixed-4.c: New test. * testsuite/libgomp.c-c++-common/gomp-barrier-type-env-unset.c: New test. * testsuite/libgomp.c-c++-common/gomp-barrier-type-env.c: New test. * testsuite/libgomp.c/barrier_generation_overflow.c: New test. * testsuite/libgomp.c/barrier-switch-1.c: New test. * testsuite/libgomp.c/cancel_in_implicit_barrier.c: New test. * testsuite/libgomp.c/cancel_in_implicit_barrier_while_primary_waiting.c: New test. * testsuite/libgomp.c/cancel_incr_wraparound.c: New test. * testsuite/libgomp.c/futex_waitv_overflow.c: New test. * testsuite/libgomp.c/primary-thread-tasking.c: New test. * work.c (gomp_work_share_end): Pass barrier ID argument. (gomp_work_share_end_cancel): Pass barrier ID argument. Signed-off-by: Matthew Malcomson --- libgomp/barrier.c | 8 +- libgomp/config/gcn/bar.c | 42 +- libgomp/config/gcn/bar.h | 66 +- libgomp/config/gcn/team.c | 3 +- libgomp/config/linux/bar.c | 46 +- libgomp/config/linux/bar.h | 67 +- libgomp/config/linux/futex_waitv/bar.c | 1045 +++++++++++++++++ libgomp/config/linux/futex_waitv/bar.h | 496 ++++++++ .../config/linux/futex_waitv/futex_waitv.h | 67 ++ libgomp/config/linux/futex_waitv/simple-bar.h | 66 ++ libgomp/config/linux/wait.h | 11 +- libgomp/config/nvptx/bar.c | 36 +- libgomp/config/nvptx/bar.h | 63 +- libgomp/config/nvptx/team.c | 3 +- libgomp/config/posix/bar.c | 33 +- libgomp/config/posix/bar.h | 60 +- libgomp/config/posix/pool.h | 1 + libgomp/config/posix/simple-bar.h | 12 +- libgomp/config/rtems/bar.h | 65 +- libgomp/configure | 82 +- libgomp/configure.ac | 39 + libgomp/configure.tgt | 32 +- libgomp/env.c | 59 +- libgomp/libgomp.h | 55 +- libgomp/libgomp.texi | 107 +- libgomp/single.c | 4 +- libgomp/task.c | 46 +- libgomp/team.c | 317 ++++- libgomp/testsuite/lib/libgomp.exp | 8 +- libgomp/testsuite/libgomp-site-extra.exp.in | 1 + .../testsuite/libgomp.c++/task-reduction-20.C | 136 +++ .../testsuite/libgomp.c++/task-reduction-21.C | 140 +++ .../gomp-barrier-type-env-auto.c | 11 + .../gomp-barrier-type-env-centralized-flat.c | 12 + .../gomp-barrier-type-env-centralized-tree.c | 12 + .../gomp-barrier-type-env-flat-centralized.c | 12 + .../gomp-barrier-type-env-flat.c | 11 + .../gomp-barrier-type-env-tree-centralized.c | 12 + .../gomp-barrier-type-env-unset.c | 10 + .../gomp-barrier-type-env.c | 11 + .../testsuite/libgomp.c/barrier-switch-1.c | 135 +++ .../libgomp.c/barrier_generation_overflow.c | 88 ++ .../libgomp.c/cancel_in_implicit_barrier.c | 115 ++ ...n_implicit_barrier_while_primary_waiting.c | 70 ++ .../libgomp.c/cancel_incr_wraparound.c | 94 ++ .../libgomp.c/futex_waitv_overflow.c | 37 + .../libgomp.c/primary-thread-tasking.c | 80 ++ libgomp/work.c | 9 +- 48 files changed, 3672 insertions(+), 263 deletions(-) create mode 100644 libgomp/config/linux/futex_waitv/bar.c create mode 100644 libgomp/config/linux/futex_waitv/bar.h create mode 100644 libgomp/config/linux/futex_waitv/futex_waitv.h create mode 100644 libgomp/config/linux/futex_waitv/simple-bar.h create mode 100644 libgomp/testsuite/libgomp.c++/task-reduction-20.C create mode 100644 libgomp/testsuite/libgomp.c++/task-reduction-21.C create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-auto.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-centralized-flat.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-centralized-tree.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-flat-centralized.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-flat.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-tree-centralized.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-unset.c create mode 100644 libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env.c create mode 100644 libgomp/testsuite/libgomp.c/barrier-switch-1.c create mode 100644 libgomp/testsuite/libgomp.c/barrier_generation_overflow.c create mode 100644 libgomp/testsuite/libgomp.c/cancel_in_implicit_barrier.c create mode 100644 libgomp/testsuite/libgomp.c/cancel_in_implicit_barrier_while_primary_waiting.c create mode 100644 libgomp/testsuite/libgomp.c/cancel_incr_wraparound.c create mode 100644 libgomp/testsuite/libgomp.c/futex_waitv_overflow.c create mode 100644 libgomp/testsuite/libgomp.c/primary-thread-tasking.c diff --git a/libgomp/barrier.c b/libgomp/barrier.c index d11fd710b19..8e5f5664dd6 100644 --- a/libgomp/barrier.c +++ b/libgomp/barrier.c @@ -40,7 +40,7 @@ GOMP_barrier (void) if (team == NULL) return; - gomp_team_barrier_wait (&team->barrier); + gomp_team_barrier_wait (&team->barrier, thr->ts.team_id); } void @@ -53,7 +53,7 @@ GOMP_barrier_ext (int kind __attribute__ ((unused))) if (team == NULL) return; - gomp_team_barrier_wait (&team->barrier); + gomp_team_barrier_wait (&team->barrier, thr->ts.team_id); } /* GOMP_barrier_cancel is no longer called by new code; it is only kept for @@ -68,7 +68,7 @@ GOMP_barrier_cancel (void) /* The compiler transforms to barrier_cancel when it sees that the barrier is within a construct that can cancel. Thus we should never have an orphaned cancellable barrier. */ - return gomp_team_barrier_wait_cancel (&team->barrier); + return gomp_team_barrier_wait_cancel (&team->barrier, thr->ts.team_id); } bool @@ -80,5 +80,5 @@ GOMP_barrier_cancel_ext (int kind __attribute__ ((unused))) /* The compiler transforms to barrier_cancel when it sees that the barrier is within a construct that can cancel. Thus we should never have an orphaned cancellable barrier. */ - return gomp_team_barrier_wait_cancel (&team->barrier); + return gomp_team_barrier_wait_cancel (&team->barrier, thr->ts.team_id); } diff --git a/libgomp/config/gcn/bar.c b/libgomp/config/gcn/bar.c index b4ea8e68a92..d3e4464347b 100644 --- a/libgomp/config/gcn/bar.c +++ b/libgomp/config/gcn/bar.c @@ -32,9 +32,9 @@ #include #include "libgomp.h" - void -gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) +gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned id __attribute__ ((unused))) { if (__builtin_expect (state & BAR_WAS_LAST, 0)) { @@ -48,9 +48,9 @@ gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) } void -gomp_barrier_wait (gomp_barrier_t *bar) +gomp_barrier_wait (gomp_barrier_t *bar, unsigned id) { - gomp_barrier_wait_end (bar, gomp_barrier_wait_start (bar)); + gomp_barrier_wait_end (bar, gomp_barrier_wait_start (bar, id), id); } /* Like gomp_barrier_wait, except that if the encountering thread @@ -61,12 +61,12 @@ gomp_barrier_wait (gomp_barrier_t *bar) the barrier can be safely destroyed. */ void -gomp_barrier_wait_last (gomp_barrier_t *bar) +gomp_barrier_wait_last (gomp_barrier_t *bar, unsigned id) { /* Deferring to gomp_barrier_wait does not use the optimization opportunity allowed by the interface contract for all-but-last participants. The original implementation in config/linux/bar.c handles this better. */ - gomp_barrier_wait (bar); + gomp_barrier_wait (bar, id); } void @@ -77,7 +77,8 @@ gomp_team_barrier_wake (gomp_barrier_t *bar, int count) } void -gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) +gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned id __attribute__ ((unused))) { unsigned int gen; @@ -93,7 +94,7 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) = __atomic_load_n (&team->task_count, MEMMODEL_ACQUIRE); if (__builtin_expect (task_count, 0)) { - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, 0); state &= ~BAR_WAS_LAST; } else @@ -126,7 +127,7 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); if (__builtin_expect (gen & BAR_TASK_PENDING, 0)) { - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, 0); gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); } } @@ -134,23 +135,24 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) } void -gomp_team_barrier_wait (gomp_barrier_t *bar) +gomp_team_barrier_wait (gomp_barrier_t *bar, unsigned id) { - gomp_team_barrier_wait_end (bar, gomp_barrier_wait_start (bar)); + gomp_team_barrier_wait_end (bar, gomp_barrier_wait_start (bar, id), id); } void -gomp_team_barrier_wait_final (gomp_barrier_t *bar) +gomp_team_barrier_wait_final (gomp_barrier_t *bar, unsigned id) { - gomp_barrier_state_t state = gomp_barrier_wait_final_start (bar); + gomp_barrier_state_t state = gomp_barrier_wait_final_start (bar, id); if (__builtin_expect (state & BAR_WAS_LAST, 0)) bar->awaited_final = bar->total; - gomp_team_barrier_wait_end (bar, state); + gomp_team_barrier_wait_end (bar, state, id); } bool gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, - gomp_barrier_state_t state) + gomp_barrier_state_t state, + unsigned id __attribute__ ((unused))) { unsigned int gen; @@ -170,7 +172,7 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, = __atomic_load_n (&team->task_count, MEMMODEL_ACQUIRE); if (__builtin_expect (task_count, 0)) { - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, 0); state &= ~BAR_WAS_LAST; } else @@ -207,7 +209,7 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, return true; if (__builtin_expect (gen & BAR_TASK_PENDING, 0)) { - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, 0); gen = __atomic_load_n (&bar->generation, MEMMODEL_RELAXED); } } @@ -217,9 +219,11 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, } bool -gomp_team_barrier_wait_cancel (gomp_barrier_t *bar) +gomp_team_barrier_wait_cancel (gomp_barrier_t *bar, unsigned id) { - return gomp_team_barrier_wait_cancel_end (bar, gomp_barrier_wait_start (bar)); + return gomp_team_barrier_wait_cancel_end (bar, + gomp_barrier_wait_start (bar, id), + id); } void diff --git a/libgomp/config/gcn/bar.h b/libgomp/config/gcn/bar.h index 943bafc3551..471ad88ca71 100644 --- a/libgomp/config/gcn/bar.h +++ b/libgomp/config/gcn/bar.h @@ -53,7 +53,9 @@ typedef unsigned int gomp_barrier_state_t; #define BAR_CANCELLED 4 #define BAR_INCR 8 -static inline void gomp_barrier_init (gomp_barrier_t *bar, unsigned count) +static inline void +gomp_barrier_init (gomp_barrier_t *bar, unsigned count, + void *ptr __attribute__ ((unused))) { bar->total = count; bar->awaited = count; @@ -71,22 +73,32 @@ static inline void gomp_barrier_destroy (gomp_barrier_t *bar) { } -extern void gomp_barrier_wait (gomp_barrier_t *); -extern void gomp_barrier_wait_last (gomp_barrier_t *); -extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t); -extern void gomp_team_barrier_wait (gomp_barrier_t *); -extern void gomp_team_barrier_wait_final (gomp_barrier_t *); -extern void gomp_team_barrier_wait_end (gomp_barrier_t *, - gomp_barrier_state_t); -extern bool gomp_team_barrier_wait_cancel (gomp_barrier_t *); +static inline struct gomp_barrier_extra_alloc_needs +gomp_barrier_extra_alloc (unsigned count __attribute__ ((unused))) +{ + return (struct gomp_barrier_extra_alloc_needs){0, 1}; +} + +extern void gomp_barrier_wait (gomp_barrier_t *, unsigned); +extern void gomp_barrier_wait_last (gomp_barrier_t *, unsigned); +extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t, + unsigned); + +extern void gomp_team_barrier_wait (gomp_barrier_t *, unsigned); +extern void gomp_team_barrier_wait_final (gomp_barrier_t *, unsigned); +extern void gomp_team_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t, + unsigned); + +extern bool gomp_team_barrier_wait_cancel (gomp_barrier_t *, unsigned); extern bool gomp_team_barrier_wait_cancel_end (gomp_barrier_t *, - gomp_barrier_state_t); + gomp_barrier_state_t, unsigned); extern void gomp_team_barrier_wake (gomp_barrier_t *, int); struct gomp_team; extern void gomp_team_barrier_cancel (struct gomp_team *); static inline gomp_barrier_state_t -gomp_barrier_wait_start (gomp_barrier_t *bar) +gomp_barrier_wait_start (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) { unsigned int ret = __atomic_load_n (&bar->generation, MEMMODEL_RELAXED); ret &= -BAR_INCR | BAR_CANCELLED; @@ -101,16 +113,17 @@ gomp_barrier_wait_start (gomp_barrier_t *bar) } static inline gomp_barrier_state_t -gomp_barrier_wait_cancel_start (gomp_barrier_t *bar) +gomp_barrier_wait_cancel_start (gomp_barrier_t *bar, unsigned id) { - return gomp_barrier_wait_start (bar); + return gomp_barrier_wait_start (bar, id); } /* This is like gomp_barrier_wait_start, except it decrements bar->awaited_final rather than bar->awaited and should be used for the gomp_team_end barrier only. */ static inline gomp_barrier_state_t -gomp_barrier_wait_final_start (gomp_barrier_t *bar) +gomp_barrier_wait_final_start (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) { unsigned int ret = __atomic_load_n (&bar->generation, MEMMODEL_RELAXED); ret &= -BAR_INCR | BAR_CANCELLED; @@ -160,7 +173,8 @@ gomp_team_barrier_cancelled (gomp_barrier_t *bar) } static inline void -gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) +gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned increment __attribute__ ((unused))) { /* Need the atomic store for acquire-release synchronisation with the load in `gomp_team_barrier_wait_{cancel_,}end`. See PR112356 */ @@ -169,10 +183,30 @@ gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) } static inline bool -gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar) +gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar, + unsigned increment __attribute__ ((unused))) { unsigned int gen = bar->generation; return (gen & -BAR_INCR) == (state & -BAR_INCR) + BAR_INCR; } +static inline bool +gomp_barrier_can_hold (gomp_barrier_t *bar) +{ + return false; +} + +static inline bool +gomp_team_barrier_wake_on_increment (unsigned increment + __attribute__ ((unused))) +{ + return true; +} + +/* Functions dummied out for this implementation. */ +static inline void +gomp_team_barrier_done_final (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) +{} + #endif /* GOMP_BARRIER_H */ diff --git a/libgomp/config/gcn/team.c b/libgomp/config/gcn/team.c index be148c3f8bf..0b884c25c76 100644 --- a/libgomp/config/gcn/team.c +++ b/libgomp/config/gcn/team.c @@ -110,6 +110,7 @@ gomp_gcn_enter_kernel (void) pool->threads_used = numthreads; pool->threads_busy = 1; pool->last_team = NULL; + pool->prev_barrier = NULL; gomp_simple_barrier_init (&pool->threads_dock, numthreads); thrs->thread_pool = pool; @@ -205,7 +206,7 @@ gomp_thread_start (struct gomp_thread_pool *pool) thr->fn = NULL; struct gomp_task *task = thr->task; - gomp_team_barrier_wait_final (&thr->ts.team->barrier); + gomp_team_barrier_wait_final (&thr->ts.team->barrier, thr->ts.team_id); gomp_finish_task (task); } while (1); diff --git a/libgomp/config/linux/bar.c b/libgomp/config/linux/bar.c index 330b37a9692..1ec1baa4bc1 100644 --- a/libgomp/config/linux/bar.c +++ b/libgomp/config/linux/bar.c @@ -24,15 +24,15 @@ . */ /* This is a Linux specific implementation of a barrier synchronization - mechanism for libgomp. This type is private to the library. This + mechanism for libgomp. This type is private to the library. This implementation uses atomic instructions and the futex syscall. */ #include #include "wait.h" - void -gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) +gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned id __attribute__ ((unused))) { if (__builtin_expect (state & BAR_WAS_LAST, 0)) { @@ -51,9 +51,9 @@ gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) } void -gomp_barrier_wait (gomp_barrier_t *bar) +gomp_barrier_wait (gomp_barrier_t *bar, unsigned id) { - gomp_barrier_wait_end (bar, gomp_barrier_wait_start (bar)); + gomp_barrier_wait_end (bar, gomp_barrier_wait_start (bar, id), id); } /* Like gomp_barrier_wait, except that if the encountering thread @@ -64,11 +64,11 @@ gomp_barrier_wait (gomp_barrier_t *bar) the barrier can be safely destroyed. */ void -gomp_barrier_wait_last (gomp_barrier_t *bar) +gomp_barrier_wait_last (gomp_barrier_t *bar, unsigned id) { - gomp_barrier_state_t state = gomp_barrier_wait_start (bar); + gomp_barrier_state_t state = gomp_barrier_wait_start (bar, id); if (state & BAR_WAS_LAST) - gomp_barrier_wait_end (bar, state); + gomp_barrier_wait_end (bar, state, id); } void @@ -78,7 +78,8 @@ gomp_team_barrier_wake (gomp_barrier_t *bar, int count) } void -gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) +gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned id __attribute__ ((unused))) { unsigned int generation, gen; @@ -94,7 +95,7 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) = __atomic_load_n (&team->task_count, MEMMODEL_ACQUIRE); if (__builtin_expect (task_count, 0)) { - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, BAR_INCR); state &= ~BAR_WAS_LAST; } else @@ -115,7 +116,7 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); if (__builtin_expect (gen & BAR_TASK_PENDING, 0)) { - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, BAR_INCR); gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); } generation |= gen & BAR_WAITING_FOR_TASK; @@ -124,23 +125,24 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) } void -gomp_team_barrier_wait (gomp_barrier_t *bar) +gomp_team_barrier_wait (gomp_barrier_t *bar, unsigned id) { - gomp_team_barrier_wait_end (bar, gomp_barrier_wait_start (bar)); + gomp_team_barrier_wait_end (bar, gomp_barrier_wait_start (bar, id), id); } void -gomp_team_barrier_wait_final (gomp_barrier_t *bar) +gomp_team_barrier_wait_final (gomp_barrier_t *bar, unsigned id) { - gomp_barrier_state_t state = gomp_barrier_wait_final_start (bar); + gomp_barrier_state_t state = gomp_barrier_wait_final_start (bar, id); if (__builtin_expect (state & BAR_WAS_LAST, 0)) bar->awaited_final = bar->total; - gomp_team_barrier_wait_end (bar, state); + gomp_team_barrier_wait_end (bar, state, id); } bool gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, - gomp_barrier_state_t state) + gomp_barrier_state_t state, + unsigned id __attribute__ ((unused))) { unsigned int generation, gen; @@ -160,7 +162,7 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, = __atomic_load_n (&team->task_count, MEMMODEL_ACQUIRE); if (__builtin_expect (task_count, 0)) { - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, BAR_INCR); state &= ~BAR_WAS_LAST; } else @@ -184,7 +186,7 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, return true; if (__builtin_expect (gen & BAR_TASK_PENDING, 0)) { - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, BAR_INCR); gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); } generation |= gen & BAR_WAITING_FOR_TASK; @@ -195,9 +197,11 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, } bool -gomp_team_barrier_wait_cancel (gomp_barrier_t *bar) +gomp_team_barrier_wait_cancel (gomp_barrier_t *bar, unsigned id) { - return gomp_team_barrier_wait_cancel_end (bar, gomp_barrier_wait_start (bar)); + return gomp_team_barrier_wait_cancel_end (bar, + gomp_barrier_wait_start (bar, id), + id); } void diff --git a/libgomp/config/linux/bar.h b/libgomp/config/linux/bar.h index b7399f88dc0..79bdcd34165 100644 --- a/libgomp/config/linux/bar.h +++ b/libgomp/config/linux/bar.h @@ -24,7 +24,7 @@ . */ /* This is a Linux specific implementation of a barrier synchronization - mechanism for libgomp. This type is private to the library. This + mechanism for libgomp. This type is private to the library. This implementation uses atomic instructions and the futex syscall. */ #ifndef GOMP_BARRIER_H @@ -53,7 +53,9 @@ typedef unsigned int gomp_barrier_state_t; #define BAR_CANCELLED 4 #define BAR_INCR 8 -static inline void gomp_barrier_init (gomp_barrier_t *bar, unsigned count) +static inline void +gomp_barrier_init (gomp_barrier_t *bar, unsigned count, + void *ptr __attribute__ ((unused))) { bar->total = count; bar->awaited = count; @@ -71,22 +73,25 @@ static inline void gomp_barrier_destroy (gomp_barrier_t *bar) { } -extern void gomp_barrier_wait (gomp_barrier_t *); -extern void gomp_barrier_wait_last (gomp_barrier_t *); -extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t); -extern void gomp_team_barrier_wait (gomp_barrier_t *); -extern void gomp_team_barrier_wait_final (gomp_barrier_t *); -extern void gomp_team_barrier_wait_end (gomp_barrier_t *, - gomp_barrier_state_t); -extern bool gomp_team_barrier_wait_cancel (gomp_barrier_t *); +extern void gomp_barrier_wait (gomp_barrier_t *, unsigned); +extern void gomp_barrier_wait_last (gomp_barrier_t *, unsigned); +extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t, + unsigned); + +extern void gomp_team_barrier_wait (gomp_barrier_t *, unsigned); +extern void gomp_team_barrier_wait_final (gomp_barrier_t *, unsigned); +extern void gomp_team_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t, + unsigned); +extern bool gomp_team_barrier_wait_cancel (gomp_barrier_t *, unsigned); extern bool gomp_team_barrier_wait_cancel_end (gomp_barrier_t *, - gomp_barrier_state_t); + gomp_barrier_state_t, unsigned); extern void gomp_team_barrier_wake (gomp_barrier_t *, int); struct gomp_team; extern void gomp_team_barrier_cancel (struct gomp_team *); static inline gomp_barrier_state_t -gomp_barrier_wait_start (gomp_barrier_t *bar) +gomp_barrier_wait_start (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) { unsigned int ret = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); ret &= -BAR_INCR | BAR_CANCELLED; @@ -101,16 +106,17 @@ gomp_barrier_wait_start (gomp_barrier_t *bar) } static inline gomp_barrier_state_t -gomp_barrier_wait_cancel_start (gomp_barrier_t *bar) +gomp_barrier_wait_cancel_start (gomp_barrier_t *bar, unsigned id) { - return gomp_barrier_wait_start (bar); + return gomp_barrier_wait_start (bar, id); } /* This is like gomp_barrier_wait_start, except it decrements bar->awaited_final rather than bar->awaited and should be used for the gomp_team_end barrier only. */ static inline gomp_barrier_state_t -gomp_barrier_wait_final_start (gomp_barrier_t *bar) +gomp_barrier_wait_final_start (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) { unsigned int ret = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); ret &= -BAR_INCR | BAR_CANCELLED; @@ -160,7 +166,8 @@ gomp_team_barrier_cancelled (gomp_barrier_t *bar) } static inline void -gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) +gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned increment __attribute__ ((unused))) { /* Need the atomic store for acquire-release synchronisation with the load in `gomp_team_barrier_wait_{cancel_,}end`. See PR112356 */ @@ -169,10 +176,36 @@ gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) } static inline bool -gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar) +gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar, + unsigned increment __attribute__ ((unused))) { unsigned int gen = bar->generation; return (gen & -BAR_INCR) == (state & -BAR_INCR) + BAR_INCR; } +static inline bool +gomp_barrier_can_hold (gomp_barrier_t *bar) +{ + return false; +} + +static inline bool +gomp_team_barrier_wake_on_increment (unsigned increment + __attribute__ ((unused))) +{ + return true; +} + +/* Functions dummied out for this implementation. */ +static inline void +gomp_team_barrier_done_final (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) +{} + +static inline struct gomp_barrier_extra_alloc_needs +gomp_barrier_extra_alloc (unsigned count __attribute__ ((unused))) +{ + return (struct gomp_barrier_extra_alloc_needs){0, 1}; +} + #endif /* GOMP_BARRIER_H */ diff --git a/libgomp/config/linux/futex_waitv/bar.c b/libgomp/config/linux/futex_waitv/bar.c new file mode 100644 index 00000000000..ffb27e0cc8a --- /dev/null +++ b/libgomp/config/linux/futex_waitv/bar.c @@ -0,0 +1,1045 @@ +/* Copyright The GNU Toolchain Authors. + + This file is part of the GNU Offloading and Multi Processing Library + (libgomp). + + Libgomp is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +/* This is an implementation of a barrier synchronization mechanism for libgomp + written for Linux versions > 5.16 (that have the `futex_waitv` syscall). + This type is private to the library. This implementation uses atomic + instructions and the futex and futex_waitv syscalls. */ + +#include +#include "wait.h" +#include "futex_waitv.h" + +#ifndef GOMP_USE_ALIGNED_WORK_SHARES +#error "assume GOMP_USE_ALIGNED_WORK_SHARES when allocating barrier in team.c" +#endif + +static inline gomp_barrier_state_t +gomp_central_barrier_wait_start (gomp_barrier_t *bar) +{ + unsigned ret = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + ret &= -BAR_INCR | BAR_CANCELLED; + /* A memory barrier is needed before exiting from the various forms + of gomp_barrier_wait, to satisfy OpenMP API version 3.1 section + 2.8.6 flush Construct, which says there is an implicit flush during + a barrier region. This is a convenient place to add the barrier, + so we use MEMMODEL_ACQ_REL here rather than MEMMODEL_ACQUIRE. */ + if (__atomic_add_fetch (&bar->awaited, -1, MEMMODEL_ACQ_REL) == 0) + ret |= BAR_WAS_LAST; + return ret; +} + +static inline void +gomp_central_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) +{ + gomp_assert (!(state & BAR_CANCELLED), + "BAR_CANCELLED set when using plain barrier: %u", state); + if (__builtin_expect (state & BAR_WAS_LAST, 0)) + { + /* Next time we'll be awaiting TOTAL threads again. */ + bar->awaited = bar->total; + /* No need to atomically load bar->generation here since we know we are + last and since there's no tasking no-one else is writing to this + location. */ + __atomic_store_n (&bar->generation, bar->generation + BAR_INCR, + MEMMODEL_RELEASE); + futex_wake ((int *) &bar->generation, INT_MAX); + } + else + { + do + do_wait ((int *) &bar->generation, state); + while (__atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE) == state); + } +} + +void +gomp_central_barrier_wait (gomp_barrier_t *bar) +{ + gomp_barrier_state_t state = gomp_central_barrier_wait_start (bar); + gomp_central_barrier_wait_end (bar, state); +} + +/* Like gomp_central_barrier_wait, except that if the encountering thread is + not the last one to hit the barrier, it returns immediately. The intended + usage is that a thread which intends to gomp_barrier_destroy this barrier + calls gomp_central_barrier_wait, while all other threads call + gomp_central_barrier_wait_last. When gomp_central_barrier_wait returns, the + barrier can be safely destroyed. */ + +void +gomp_central_barrier_wait_last (gomp_barrier_t *bar) +{ + gomp_barrier_state_t state = gomp_central_barrier_wait_start (bar); + if (state & BAR_WAS_LAST) + gomp_central_barrier_wait_end (bar, state); +} + +static inline void +gomp_assert_seenflags (gomp_barrier_t *bar, bool cancellable) +{ +#if _LIBGOMP_CHECKING_ + unsigned gen = __atomic_load_n (&bar->generation, MEMMODEL_RELAXED); + struct thread_lock_data *arr = bar->threadgens; + unsigned cancel_incr = cancellable ? BAR_CANCEL_INCR : 0; + unsigned incr = cancellable ? 0 : BAR_INCR; + /* Assert that all threads have been seen. */ + for (unsigned i = 0; i < bar->total; i++) + { + unsigned g = arr[i].gen; + gomp_assert ((g & BAR_GEN_MASK) == (gen & BAR_GEN_MASK) + incr, + "index %u generation is %u (global is %u)\n", i, g, gen); + gomp_assert ((g & BAR_CANCEL_GEN_MASK) + == ((gen + cancel_incr) & BAR_CANCEL_GEN_MASK), + "index %u cancel generation out of sync. Gen is %u (global " + "is %u)\n", + i, g, gen); + } + + /* Assert that generation numbers not corresponding to any thread are + cleared. This helps us test code-paths. */ + for (unsigned i = bar->total; i < bar->allocated; i++) + { + unsigned g = arr[i].gen; + gomp_assert (g == 0, + "index %u gen should be 0. Is %u (global gen is %u)\n", i, + g, gen); + } +#endif +} + +static inline void +gomp_assert_and_store_flag (unsigned *addr, unsigned val, unsigned orig, + unsigned gens, unsigned id) +{ + __atomic_store_n (addr, val, MEMMODEL_RELEASE); + futex_wake ((int *) addr, INT_MAX); + gomp_assert (orig == (gens & BAR_BOTH_GENS_MASK), + "id %u: Original flag %u != generation of %u\n", id, orig, + gens); + gomp_assert ((orig & BAR_FLAGS_MASK) == 0, + "id %u: Original flag %u has flags set\n", id, orig); +} + +static inline void +gomp_assert_and_increment_flag (gomp_barrier_t *bar, unsigned id, unsigned gens) +{ + /* Atomically update our thread-local generation for the primary thread to + observe. We are the only thread writing to this value, so we only need an + atomic store for publishing and do not need __atomic_fetch_add. */ + unsigned orig = bar->threadgens[id].gen; + unsigned new = orig + BAR_INCR; + gomp_assert_and_store_flag (&bar->threadgens[id].gen, new, orig, gens, id); +} + +static inline gomp_barrier_state_t +gomp_flat_barrier_arrive (gomp_barrier_t *bar, unsigned id) +{ + /* TODO I don't believe this MEMMODEL_ACQUIRE is needed. + Look into it later. Point being that this should only ever read a value + from last barrier or from tasks/cancellation/etc. There was already an + acquire-release ordering at exit of the last barrier, all setting of + tasks/cancellation etc are done with RELAXED memory model => using ACQUIRE + doesn't help. + + See corresponding comment in `gomp_team_barrier_cancel` when thinking + about this. + + I was pretty confident that this wasn't necessary when we *only* had a + flat barrier, not so sure now that we also have a central barrier. + Hence the TODO above that we have to look into this. */ + unsigned ret = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + ret &= (BAR_BOTH_GENS_MASK | BAR_CANCELLED); +#if !_LIBGOMP_CHECKING_ + if (id != 0) +#endif + /* Increment local flag. For thread id 0 this doesn't communicate + anything to *other* threads, but it is useful for debugging purposes. */ + gomp_assert_and_increment_flag (bar, id, ret); + + if (id == 0) + ret |= BAR_WAS_LAST; + return ret; +} + +static void +gomp_wait_on_flag (gomp_barrier_t *bar, unsigned child_tid, unsigned tstate) +{ + unsigned tmp; + struct thread_lock_data *arr = bar->threadgens; + do + { + do_wait ((int *) &arr[child_tid].gen, tstate); + tmp = __atomic_load_n (&arr[child_tid].gen, MEMMODEL_ACQUIRE); + gomp_assert (tmp == tstate || tmp == (tstate + BAR_INCR), + "thread-local state seen to be %u" + " when global gens are %u", + tmp, tstate); + } + while (tmp != (tstate + BAR_INCR)); +} + +gomp_barrier_state_t +gomp_flat_barrier_wait_start (gomp_barrier_t *bar, unsigned id) +{ + gomp_barrier_state_t state = gomp_flat_barrier_arrive (bar, id); + gomp_assert (!(state & BAR_CANCELLED), + "BAR_CANCELLED set when using plain barrier: %u", state); + if (state & BAR_WAS_LAST) + { + gomp_assert (id == 0, "secondary thread %u believes is last", id); + unsigned tstate = state & BAR_BOTH_GENS_MASK; + for (unsigned i = 1; i < bar->total; i++) + gomp_wait_on_flag (bar, i, tstate); + gomp_assert_seenflags (bar, false); + } + return state; +} + +#define hyper_iteration(ID, BAR, FINISHED, WAIT_ON_CHILD) \ + do \ + { \ + uint32_t num_threads = (BAR)->total; \ + uint32_t offset; \ + uint32_t level; \ + uint32_t branch_bits = 2; \ + uint32_t branch_factor = 1 << branch_bits; \ + for (level = 0, offset = 1; offset < num_threads; \ + level += branch_bits, offset <<= branch_bits) \ + { \ + uint32_t child; \ + uint32_t child_tid; \ + if ((((ID) >> level) & (branch_factor - 1)) != 0) \ + { \ + gomp_assert ((ID) != 0, \ + "primary thread incrementing thread local gen\n"); \ + FINISHED; \ + break; \ + } \ + for (child = 1, child_tid = (ID) + (1 << level); \ + child < branch_factor && child_tid < num_threads; \ + child++, child_tid += (1 << level)) \ + WAIT_ON_CHILD (child_tid); \ + } \ + } \ + while (0) + +gomp_barrier_state_t +gomp_tree_barrier_wait_start (gomp_barrier_t *bar, unsigned id) +{ + unsigned gstate = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + gomp_assert (!(gstate & BAR_CANCELLED), + "BAR_CANCELLED set when using plain barrier: %u", gstate); + gstate &= BAR_BOTH_GENS_MASK; + unsigned tstate = gstate & BAR_BOTH_GENS_MASK; +#define wait_on_child(child_tid) gomp_wait_on_flag (bar, child_tid, tstate) + hyper_iteration (id, bar, gomp_assert_and_increment_flag (bar, id, gstate), + wait_on_child); +#undef wait_on_child + /* At this point children threads have marked their arrival to their parent + thread but don't know that their parent thread has seen that mark. + Parent threads know that all their children have arrived here (and that + we've seen it). */ + if (id == 0) + { +#if _LIBGOMP_CHECKING_ + gomp_assert_and_increment_flag (bar, id, gstate); +#endif + gstate |= BAR_WAS_LAST; + gomp_assert_seenflags (bar, false); + } + return gstate; +} + +static inline unsigned +gomp_central_tg_barrier_fetchgen (gomp_barrier_t *bar) +{ + unsigned ret = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + ret &= BAR_BOTH_GENS_MASK | BAR_CANCELLED; + return ret; +} + +static inline unsigned +gomp_central_tg_barrier_assertions (gomp_barrier_t *bar, unsigned ret, + unsigned id) +{ + unsigned orig = bar->threadgens[id].gen; + gomp_assert (orig == (ret & BAR_BOTH_GENS_MASK), + "id %u: Original flag %u != generation of %u\n", id, orig, ret); + gomp_assert ((orig & BAR_FLAGS_MASK) == 0, + "id %u: Original flag %u has flags set\n", id, orig); + return orig; +} + +static inline unsigned +gomp_central_tg_barrier_decrement (gomp_barrier_t *bar, unsigned *await, + unsigned ret, unsigned id) +{ + /* A memory barrier is needed before exiting from the various forms + of gomp_barrier_wait, to satisfy OpenMP API version 3.1 section + 2.8.6 flush Construct, which says there is an implicit flush during + a barrier region. This is a convenient place to add the barrier, + so we use MEMMODEL_ACQ_REL here rather than MEMMODEL_ACQUIRE. */ + if (__atomic_add_fetch (await, -1, MEMMODEL_ACQ_REL) == 0) + { + ret |= BAR_WAS_LAST; + *await = bar->total; + } + return ret; +} + +gomp_barrier_state_t +gomp_central_tg_barrier_wait_start (gomp_barrier_t *bar, unsigned id) +{ + unsigned ret = gomp_central_tg_barrier_fetchgen (bar); + gomp_assert (!(ret & BAR_CANCELLED), + "BAR_CANCELLED set when using plain barrier: %u", ret); +#if !_LIBGOMP_CHECKING_ + if (id != 0) +#endif + { + unsigned orig = gomp_central_tg_barrier_assertions (bar, ret, id); + /* Does not need to be atomic as it stands because there are + happens-before relationships between barrier epochs outside of + cancellable barriers, and a cancelled barrier is directly followed by + a `final` barrier. However it seems more robust to later changes to + use an atomic operation here. */ + __atomic_store_n (&bar->threadgens[id].gen, orig + BAR_INCR, + MEMMODEL_RELAXED); + } + ret = gomp_central_tg_barrier_decrement (bar, &bar->awaited, ret, id); + return ret; +} + +void +gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned id) +{ + gomp_assert (!(state & BAR_CANCELLED), + "BAR_CANCELLED set when using plain barrier: %u", state); + if (__builtin_expect (state & BAR_WAS_LAST, 0)) + { + /* Shouldn't have anything modifying bar->generation at this point since + we have waited for all other threads to enter this function and + they're all in the `do_wait` loop below. */ + gomp_assert ((bar->generation & ~BAR_BOTH_GENS_MASK) == 0, + "flags set in gomp_barrier_wait_end: %u", + bar->generation & ~BAR_BOTH_GENS_MASK); + bar->spin_count = spin_count (); + __atomic_store_n (&bar->generation, bar->generation + BAR_INCR, + MEMMODEL_RELEASE); + futex_wake ((int *) &bar->generation, INT_MAX); + } + else + { + do + do_wait ((int *) &bar->generation, state); + while (__atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE) == state); + } +} + +/* We need to have some "ensure we're last, but perform useful work + in the meantime" behaviour. This allows the primary thread to perform + useful work while it is waiting on all secondary threads. + - Related to the fundamental difference between this barrier and the + "central" barrier where the thread doing the bookkeeping is pre-determined + as some "primary" thread and that is not necessarily the last thread to + enter the barrier. + + To do that we loop through checking each of the other threads flags. If any + are not set then we take that opportunity to check the global generation + number, if there's some task to handle then do so before going back to + checking the remaining thread-local flags. + + This approach means that the cancellable barriers work reasonably naturally. + If we're checking the global generation flag then we can see when it is + cancelled. Hence `gomp_team_barrier_cancel_wait_on_two_flags` below does + something very similar to this function here. + + When there is nothing for a thread to do we want to wait on one of two + addresses being changed (either the secondary threads control flag or the + barrier main generation). The futex_waitv syscall provides exactly that + functionality. */ +static inline void +gomp_team_barrier_wait_on_two_flags (gomp_barrier_t *bar, unsigned child_tid, + unsigned long long spincount, + unsigned gstate, unsigned tstate) +{ + /* Thought process here: + - Until we are the last thread, we are "some thread waiting on the + barrier". Hence we should doing only a variant of what is done in + `gomp_team_barrier_wait_end` for the other threads. + - The loop done in that function is: + 1) Wait on `generation` having some flag. + 2) When it changes, enforce the acquire-release semantics and + re-load. + 3) If added `BAR_TASK_PENDING`, then handle some tasks. + 4) Ignore `BAR_WAITING_FOR_TASK` flag. + - Hence the loop done in this function is: + 1) Wait on `child_tid` generation number. + - When this is not incremented, then: + 1. wait on `generation` having some flag. + 2. When it does have such a flag, enforce the acquire-release + semantics and load. + 3. If added `BAR_TASK_PENDING` then handle some tasks. + 4. Ignore `BAR_WAITING_FOR_TASK` not necessary because it's us that + would set that flag. + Differences otherwise are that we put pausing in different positions. */ + unsigned long long j; + unsigned threadgen_orig; + struct thread_lock_data *arr = bar->threadgens; +restart_loop: + /* Use `j <= spincount` here in case `gomp_spin_count_var == 0` (which can + happen with OMP_WAIT_POLICY=passive). We need to go around this loop at + least once to check and handle any changes. */ + for (j = 0; j <= spincount; j++) + { + /* Thought about using MEMMODEL_ACQUIRE or MEMMODEL_RELAXED until we + see a difference and *then* MEMMODEL_ACQUIRE for the + acquire-release semantics. Idea was that the more relaxed memory + model might provide a performance boost. Did not see any + improvement on a micro-benchmark and decided not to do that. + + TODO Question whether to run one loop checking both variables, or + two loops each checking one variable multiple times. Suspect + that one loop checking both variables is going to be more + responsive and more understandable in terms of performance + characteristics when specifying GOMP_SPINCOUNT. + However there's the chance that checking each variable + something like 10000 times and going around this loop + count/10000 times could give better throughput? */ + threadgen_orig = __atomic_load_n (&arr[child_tid].gen, MEMMODEL_ACQUIRE); + unsigned threadgen = threadgen_orig & BAR_GEN_MASK; + gomp_assert ((threadgen_orig & BAR_FLAGS_MASK) == 0, + "id %u: thread local generation has non-zero flags: " + "%u\n", + child_tid, threadgen_orig); + if (__builtin_expect (threadgen != tstate, 0)) + { + gomp_assert (threadgen == (tstate + BAR_INCR), + "thread-local state seen to be %u" + " when global state was %u.\n", + threadgen, tstate); + /* This is the only place we return from this function. */ + return; + } + unsigned gen = __atomic_load_n (&bar->generation, MEMMODEL_RELAXED); + if (__builtin_expect (gen != gstate, 0)) + { + if (gen & BAR_TASK_PENDING) + gomp_barrier_handle_tasks (gstate, bar, false); + /* When running as a logical "final" barrier the `CANCELLED` flag + can get set on the barrier if we were in a cancellable region + whose only barrier was the implicit "final" barrier at the end + of the region. Ensure we update `gstate` in this case to + avoid any unnecessary busy-waiting when nothing is actually + changing. */ + gomp_assert (!(gstate & BAR_CANCELLED) || (gen & BAR_CANCELLED), + "BAR_CANCELLED state cleared by non-primary thread" + " bar->generation: %u state: %u", + gen, gstate); + gstate |= gen & BAR_CANCELLED; + + gomp_assert (!(gen & BAR_WAITING_FOR_TASK), + "BAR_WAITING_FOR_TASK set by non-primary thread " + "gen=%d", + gen); + gomp_assert (!gomp_barrier_incremented (gen, gstate, BAR_INCR), + "global state incremented by non-primary thread " + "gen=%d", + gen); + goto restart_loop; + } + } + futex_waitv (&arr[child_tid].gen, threadgen_orig, &bar->generation, gstate); + /* One of the above values has changed, restart this loop and we can find out + what it was and deal with it accordingly. */ + goto restart_loop; +} + +gomp_barrier_state_t +gomp_team_flat_barrier_wait_start (gomp_barrier_t *bar, unsigned id) +{ + gomp_barrier_state_t state = gomp_flat_barrier_arrive (bar, id); + if (state & BAR_WAS_LAST) + { + gomp_assert (id == 0, "secondary thread %u believes is last", id); + unsigned gstate = state & (BAR_BOTH_GENS_MASK | BAR_CANCELLED); + unsigned tstate = state & BAR_GEN_MASK; + unsigned long long spincount = spin_count (); + for (unsigned i = 1; i < bar->total; i++) + gomp_team_barrier_wait_on_two_flags (bar, i, spincount, gstate, tstate); + gomp_assert_seenflags (bar, false); + } + return state; +} + +gomp_barrier_state_t +gomp_team_tree_barrier_wait_start (gomp_barrier_t *bar, unsigned id) +{ + unsigned gstate = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + gstate &= (BAR_BOTH_GENS_MASK | BAR_CANCELLED); + unsigned tstate = gstate & BAR_GEN_MASK; + unsigned long long spincount = spin_count (); +#define wait_on_child(child_tid) \ + gomp_team_barrier_wait_on_two_flags (bar, child_tid, spincount, gstate, \ + tstate) + hyper_iteration (id, bar, gomp_assert_and_increment_flag (bar, id, gstate), + wait_on_child); +#undef wait_on_child + if (id == 0) + { +#if _LIBGOMP_CHECKING_ + gomp_assert_and_increment_flag (bar, id, gstate); +#endif + gstate |= BAR_WAS_LAST; + gomp_assert_seenflags (bar, false); + } + + return gstate; +} + +gomp_barrier_state_t +gomp_team_central_tg_barrier_wait_start (gomp_barrier_t *bar, unsigned id) +{ + return gomp_central_tg_barrier_wait_start (bar, id); +} + +gomp_barrier_state_t +gomp_team_central_tg_barrier_wait_final_start (gomp_barrier_t *bar, unsigned id) +{ + unsigned ret = gomp_central_tg_barrier_fetchgen (bar); +#if !_LIBGOMP_CHECKING_ + if (id != 0) +#endif + { + unsigned orig = gomp_central_tg_barrier_assertions (bar, ret, id); + /* If the previous barrier was a tree/flat barrier that was cancelled, + then it may not have introduced a happens-before relationship between + the local threadgen load and this write. That is the only reason we + need this write to be atomic. */ + __atomic_store_n (&bar->threadgens[id].gen, orig + BAR_INCR, + MEMMODEL_RELAXED); + } + ret = gomp_central_tg_barrier_decrement (bar, &bar->awaited_final, ret, id); + return ret; +} + +static inline bool +gomp_team_barrier_primary_check_for_tasks (gomp_barrier_t *bar, + unsigned increment, + gomp_barrier_state_t state, + enum memmodel m) +{ + struct gomp_thread *thr = gomp_thread (); + struct gomp_team *team = thr->ts.team; + team->work_share_cancelled = 0; + unsigned task_count = __atomic_load_n (&team->task_count, MEMMODEL_ACQUIRE); + if (__builtin_expect (task_count, 0)) + { + gomp_barrier_handle_tasks (state, bar, increment); + return true; + } + else + { + unsigned gens = state & ~BAR_WAS_LAST; + gens = gomp_increment_gen (gens, increment); + bar->spin_count = spin_count (); + __atomic_store_n (&bar->generation, gens, m); + /* Secondary threads remain held until + gomp_team_barrier_done_final. Avoid waking them merely to observe + BAR_HOLDING_SECONDARIES and go back to sleep. At high counts of + threads that are actually waiting, futex_wake is high cost. */ + if (increment != BAR_HOLDING_SECONDARIES) + futex_wake ((int *) &bar->generation, INT_MAX); + return false; + } +} + +void +gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned id) +{ + unsigned generation, gen; + gomp_assert (!(state & BAR_CANCELLED), + "generation number includes BAR_CANCELLED in " + "gomp_team_barrier_wait_end: %u , id: %u", + state, id); + + if (__builtin_expect (state & BAR_WAS_LAST, 0)) + { + if (!gomp_team_barrier_primary_check_for_tasks (bar, BAR_INCR, state, + MEMMODEL_RELEASE)) + return; + state &= ~BAR_WAS_LAST; + } + + generation = state; + do + { + do_wait ((int *) &bar->generation, generation); + gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + gomp_assert (!(gen & BAR_CANCELLED), + "BAR_CANCELLED set on generation in team barrier" + " gen: %u generation: %u id: %u", + gen, generation, id); + if (__builtin_expect (gen & BAR_TASK_PENDING, 0)) + { + gomp_barrier_handle_tasks (state, bar, BAR_INCR); + gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + } + /* These flags will not change until this barrier is completed. + Going forward we don't want to be continually waking up checking for + whether this barrier has completed yet. */ + generation |= gen & BAR_WAITING_FOR_TASK; + /* There should be no other flags set in bar->generation outside of the + ones we explicitly handle here. */ + } + while ((gen & BAR_BOTH_GENS_MASK) != state + BAR_INCR); +} + +void +gomp_team_barrier_wait_for_tasks (gomp_barrier_t *bar, + gomp_barrier_state_t state, unsigned id) +{ + unsigned generation, gen; + bool have_cleared __attribute__ ((unused)) = false; + + if (__builtin_expect (state & BAR_WAS_LAST, 0)) + { + /* Acquire-release ordering from primary thread to secondary threads + is formed in `gomp_team_barrier_done_final` rather than this function. + That is where all secondary threads are allowed to run. + However, we do still need to perform an atomic store as-per C "data + race" requirements because there are other threads waiting in + `do_spin` that are repeatedly watching this variable. */ + if (!gomp_team_barrier_primary_check_for_tasks (bar, + BAR_HOLDING_SECONDARIES, + state, MEMMODEL_RELAXED)) + return; + state &= ~BAR_WAS_LAST; + } + + generation = state; + state &= ~BAR_CANCELLED; + do + { + /* If the primary thread ends up in this loop then the benefit of + avoiding the wake of all threads (as per + `gomp_team_barrier_primary_check_for_tasks` does above) is largely + lost in the cost of tasking etc. There is a possible protocol around + having a `primary_wake`, using `futex_waitv`, and if a secondary + thread wakes us up from `gomp_barrier_handle_tasks` then only wake the + primary up via that variable. EPCC microbenchmarks didn't show a + significant improvement and it's quite a complex protocol so we don't + do that. */ + do_wait ((int *) &bar->generation, generation); + gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + gomp_assert ((gen & BAR_CANCELLED) == (generation & BAR_CANCELLED) + /* Cancellation of *next* barrier is fine -- we will + exit. */ + || gomp_barrier_incremented (gen, generation, + BAR_HOLDING_SECONDARIES) + /* Removing cancellation flag once all threads reached + "final" barrier is also fine. */ + || ((gen & BAR_HOLDING_SECONDARIES) + && !(generation & BAR_HOLDING_SECONDARIES)) + /* Can cancel a barrier when already gotten into final + implicit barrier at the end of a parallel loop. + This happens in `cancel-parallel-3.c`. + In this case the above assertion does not hold because + We are waiting on the implicit barrier at the end of a + parallel region while some other thread is performing + work in that parallel region, hits a + `#pragma omp cancel parallel`, and sets said flag. */ + || !(generation & BAR_CANCELLED), + "unnecessary looping due to BAR_CANCELLED diff" + " gen: %u state: %u generation: %u id: %u", + gen, state, generation, id); + gomp_assert (!gomp_barrier_incremented (gen, state, + BAR_HOLDING_SECONDARIES) + || !gomp_barrier_incremented (gen, + gomp_increment_gen (state, + BAR_INCR), + BAR_HOLDING_SECONDARIES), + "generation has gone ahead of us two times!" + " gen = %u, state = %u, generation = %u", + gen, state, generation); + if (__builtin_expect (gen & BAR_TASK_PENDING, 0)) + { + gomp_barrier_handle_tasks (state, bar, BAR_HOLDING_SECONDARIES); + gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + } +#if _LIBGOMP_CHECKING_ + if (have_cleared) + gomp_assert ((!(gen & BAR_WAITING_FOR_TASK) + && !(generation & BAR_WAITING_FOR_TASK)), + "invalid state in " + "gomp_team_barrier_primary_wait_for_tasks"); + else if ((generation & BAR_WAITING_FOR_TASK) + && !(gen & BAR_WAITING_FOR_TASK)) + have_cleared = true; +#endif + generation + = (generation & ~BAR_WAITING_FOR_TASK) | (gen & BAR_WAITING_FOR_TASK); + generation = (generation & ~BAR_CANCELLED) | (gen & BAR_CANCELLED); + /* Situation where we know all tasks are finished, and we were called + with instructions to wait for all tasks to finish before letting the + primary thread exit and holding secondary threads ready to be woken + up. */ + if (id == 0 && gen & BAR_HOLDING_SECONDARIES) + return; + generation |= gen & BAR_HOLDING_SECONDARIES; + } + while ((gen & BAR_BOTH_GENS_MASK) != state + BAR_INCR); +} + +void +gomp_team_barrier_done_final (gomp_barrier_t *bar, unsigned id) +{ + if (gomp_forkjoin_barrier_request == GOMP_CENTRALIZED_BARRIER) + return; + gomp_assert (id == 0, "called with ID = %u", id); + unsigned gen = __atomic_load_n (&bar->generation, MEMMODEL_RELAXED); + gomp_assert ((gen & BAR_FLAGS_MASK) == BAR_HOLDING_SECONDARIES, + "gomp_team_barrier_done_final called with generation: %u", gen); + gen &= ~BAR_HOLDING_SECONDARIES; + gen += BAR_INCR; + bar->spin_count = spin_count (); + __atomic_store_n (&bar->generation, gen, MEMMODEL_RELEASE); + futex_wake ((int *) &bar->generation, INT_MAX); +} + +void +gomp_team_central_tg_barrier_wait_final_end (gomp_barrier_t *bar, + gomp_barrier_state_t state, + unsigned id) +{ + /* Same as gomp_team_barrier_wait_end, except that we account for + BAR_CANCELLED being set on this barrier. + - Different set of assertions + - Clear BAR_CANCELLED from `state` before iterating on tasks. + - Ensure we don't spin unnecessarily in that case. */ + unsigned generation, gen; + if (__builtin_expect (state & BAR_WAS_LAST, 0)) + { + if (!gomp_team_barrier_primary_check_for_tasks (bar, BAR_INCR, state, + MEMMODEL_RELEASE)) + return; + state &= ~BAR_WAS_LAST; + } + generation = state; + state &= ~BAR_CANCELLED; + do + { + do_wait ((int *) &bar->generation, generation); + gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + gomp_assert ((gen & BAR_CANCELLED) == (generation & BAR_CANCELLED) + /* Removing BAR_CANCELLED via incrementing generation is + OK. */ + || gomp_barrier_incremented (gen, generation, BAR_INCR) + || !(generation & BAR_CANCELLED), + "BAR_CANCELLED removed from central final barrier %u -> " + "%u, Id: %u", + generation, gen, id); + if (__builtin_expect (gen & BAR_TASK_PENDING, 0)) + { + /* We are incrementing by BAR_INCR rather than BAR_HOLDING_SECONDARIES + since central barrier can not guarantee primary is last and hence + can't implemenet "holding" barrier without extra synchronisation + (which loses most of the performance benefits of the "holding" + approach anyway). */ + gomp_barrier_handle_tasks (state, bar, BAR_INCR); + gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + } + /* These flags will not change until this barrier is completed. + Going forward we don't want to be continually waking up checking for + whether this barrier has completed yet. */ + generation |= gen & BAR_WAITING_FOR_TASK; + generation |= gen & BAR_CANCELLED; + /* There should be no other flags set in bar->generation outside of the + ones we explicitly handle here. */ + } + while ((gen & BAR_BOTH_GENS_MASK) != state + BAR_INCR); +} + +void +gomp_assert_and_increment_cancel_flag (gomp_barrier_t *bar, unsigned id, + unsigned gens) +{ + unsigned orig = bar->threadgens[id].gen; + unsigned new = BAR_INCREMENT_CANCEL (orig); + gomp_assert_and_store_flag (&bar->threadgens[id].gen, new, orig, gens, id); +} + +static inline bool +gomp_team_barrier_cancel_wait_on_two_flags (gomp_barrier_t *bar, + unsigned child_tid, + unsigned long long spincount, + unsigned gstate, unsigned tstate) +{ + unsigned long long j; + unsigned threadgen_orig; + struct thread_lock_data *arr = bar->threadgens; +restart_loop: + for (j = 0; j <= spincount; j++) + { + threadgen_orig = __atomic_load_n (&arr[child_tid].gen, MEMMODEL_ACQUIRE); + unsigned threadgen = threadgen_orig & BAR_CANCEL_GEN_MASK; + gomp_assert ((threadgen_orig & BAR_FLAGS_MASK) == 0, + "id %u: thread local generation has non-zero flags: " + "%u\n", + child_tid, threadgen_orig); + if (__builtin_expect (threadgen != tstate, 0)) + { + gomp_assert (threadgen == BAR_INCREMENT_CANCEL (tstate), + "thread-local state seen to be %u" + " when global state was %u.\n", + threadgen, tstate); + return true; + } + unsigned gen = __atomic_load_n (&bar->generation, MEMMODEL_RELAXED); + if (__builtin_expect (gen != gstate, 0)) + { + gomp_assert (!(gen & BAR_WAITING_FOR_TASK), + "BAR_WAITING_FOR_TASK set in non-primary thread " + "gen=%d", + gen); + gomp_assert (!gomp_barrier_incremented (gen, gstate, BAR_CANCEL_INCR), + "global state incremented by non-primary thread " + "gstate=%d gen=%d", + gstate, gen); + if (gen & BAR_CANCELLED) + return false; + + if (gen & BAR_TASK_PENDING) + gomp_barrier_handle_tasks (gstate, bar, false); + goto restart_loop; + } + } + futex_waitv (&arr[child_tid].gen, threadgen_orig, &bar->generation, gstate); + goto restart_loop; +} + +gomp_barrier_state_t +gomp_team_flat_barrier_wait_cancel_start (gomp_barrier_t *bar, unsigned id) +{ + unsigned ret = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + ret &= BAR_BOTH_GENS_MASK | BAR_CANCELLED; + if (ret & BAR_CANCELLED) + /* Do not return BAR_WAS_LAST because this thread is not last. + The barrier is cancelled. Some thread did not enter it. */ + return ret; + if (id == 0) + { + unsigned gstate = ret & BAR_BOTH_GENS_MASK; + unsigned tstate = ret & BAR_CANCEL_GEN_MASK; + unsigned long long spincount = spin_count (); + for (unsigned i = 1; i < bar->total; i++) + if (!gomp_team_barrier_cancel_wait_on_two_flags (bar, i, spincount, + gstate, tstate)) + return (ret | BAR_CANCELLED); + ret |= BAR_WAS_LAST; +#if _LIBGOMP_CHECKING_ + gomp_assert_and_increment_cancel_flag (bar, id, ret); +#endif + gomp_assert_seenflags (bar, true); + } + else + gomp_assert_and_increment_cancel_flag (bar, id, ret); + return ret; +} + +gomp_barrier_state_t +gomp_team_tree_barrier_wait_cancel_start (gomp_barrier_t *bar, unsigned id) +{ + unsigned gstate = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + gstate &= (BAR_BOTH_GENS_MASK | BAR_CANCELLED); + if (gstate & BAR_CANCELLED) + /* Do not return BAR_WAS_LAST because this thread is not last. + The barrier is cancelled. Some thread did not enter it. */ + return gstate; + unsigned tstate = gstate & BAR_CANCEL_GEN_MASK; + unsigned long long spincount = spin_count (); +#define wait_on_child(child_tid) \ + if (!gomp_team_barrier_cancel_wait_on_two_flags (bar, child_tid, spincount, \ + gstate, tstate)) \ + return (gstate | BAR_CANCELLED); + hyper_iteration (id, bar, + gomp_assert_and_increment_cancel_flag (bar, id, gstate), + wait_on_child); +#undef wait_on_child + if (id == 0) + { +#if _LIBGOMP_CHECKING_ + gomp_assert_and_increment_cancel_flag (bar, id, gstate); +#endif + gstate |= BAR_WAS_LAST; + gomp_assert_seenflags (bar, true); + } + return gstate; +} +#undef hyper_iteration + +gomp_barrier_state_t +gomp_team_central_tg_barrier_wait_cancel_start (gomp_barrier_t *bar, + unsigned id) +{ + unsigned ret = gomp_central_tg_barrier_fetchgen (bar); + if (ret & BAR_CANCELLED) + return ret; +#if !_LIBGOMP_CHECKING_ + if (id != 0) +#endif + { + unsigned orig = gomp_central_tg_barrier_assertions (bar, ret, id); + /* The increment of this thread-local generation number can race with a + read in the primary thread if that primary thread races ahead of us + without a sync point when the barrier gets cancelled and there is a + non-central _final barrier directly after us. */ + __atomic_store_n (&bar->threadgens[id].gen, BAR_INCREMENT_CANCEL (orig), + MEMMODEL_RELAXED); + } + ret = gomp_central_tg_barrier_decrement (bar, &bar->awaited, ret, id); + return ret; +} + +bool +gomp_team_barrier_wait_cancel_end_impl (gomp_barrier_t *bar, + gomp_barrier_state_t state, unsigned id) +{ + unsigned generation, gen; + gomp_assert (!(state & BAR_CANCELLED), + "gomp_team_barrier_wait_cancel_end_impl called when barrier " + "cancelled state: %u", + state); + + if (__builtin_expect (state & BAR_WAS_LAST, 0)) + { + /* If primary thread got here, barrier was not cancelled (barrier can not + be cancelled from a task because not closely nested in parallel + region). Hence if below function increments generation due to no + tasks remaining we don't have to worry about any other threads having + exited barrier due to cancellation beforehand. */ + if (!gomp_team_barrier_primary_check_for_tasks (bar, BAR_CANCEL_INCR, + state, MEMMODEL_RELEASE)) + return false; + state &= ~BAR_WAS_LAST; + } + + generation = state; + do + { + do_wait ((int *) &bar->generation, generation); + gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + if (__builtin_expect (gen & BAR_CANCELLED, 0)) + { + if (__builtin_expect ((gen & BAR_CANCEL_GEN_MASK) + != (state & BAR_CANCEL_GEN_MASK), + 0)) + { + /* Have cancelled a barrier just after completing the current + one. We must not reset our local state. */ + gomp_assert ((gen & BAR_CANCEL_GEN_MASK) + == (BAR_INCREMENT_CANCEL (state) + & BAR_CANCEL_GEN_MASK), + "incremented global generation (cancellable) more " + "than one gen: %u original state: %u", + gen, state); + /* Other threads could have continued on in between the time that + the primary thread signalled all other threads should wake up + and the time that we actually read `bar->generation` above. + Any one of them could be performing tasks so we can't assert + that the corresponding flag is clear. + + W.r.t. the task handling that could have been set (primary + thread increments generation telling us to go, then it + continues itself and finds an `omp task` directive and + schedules a task) we need to move on with it (PR122314). */ + gomp_assert (!(gen & BAR_WAITING_FOR_TASK), + "generation incremented while main thread is " + "still waiting for tasks: gen: %u original state:" + " %u", + gen, state); + /* *This* barrier wasn't cancelled -- the next barrier is + cancelled. Returning `false` gives that information back up + to calling functions. */ + return false; + } + /* Need to reset our thread-local generation. Don't want state to be + messed up the next time we hit a cancellable barrier. + + We are helped by the invariant that when this barrier is cancelled, + the next barrier that will be entered is a non-cancellable barrier. + That means we don't have to worry about the primary thread getting + confused by this generation being incremented to say it's reached a + cancellable barrier. Since we are the only thread that will modify + our own control word we don't need to worry about non-atomic RMW. + */ + unsigned *cgen = &bar->threadgens[id].gen; + unsigned orig = *cgen; + unsigned new = ((orig - BAR_CANCEL_INCR) & BAR_CANCEL_GEN_MASK) + | (orig & ~BAR_CANCEL_GEN_MASK); + __atomic_store_n (cgen, new, MEMMODEL_RELAXED); +#if _LIBGOMP_CHECKING_ + unsigned global_gen = gen & BAR_BOTH_GENS_MASK; + gomp_assert (new == global_gen, + "thread-local generation %u unknown modification:" + " expected %u seen %u", + id, BAR_INCREMENT_CANCEL (global_gen), orig); +#endif + return true; + } + if (__builtin_expect (gen & BAR_TASK_PENDING, 0)) + { + gomp_barrier_handle_tasks (state, bar, BAR_CANCEL_INCR); + gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); + } + generation |= gen & BAR_WAITING_FOR_TASK; + } + while ((gen & BAR_CANCEL_GEN_MASK) + != (BAR_INCREMENT_CANCEL (state) & BAR_CANCEL_GEN_MASK)); + + return false; +} + +void +gomp_team_barrier_wake (gomp_barrier_t *bar, int count) +{ + futex_wake ((int *) &bar->generation, count == 0 ? INT_MAX : count); +} + +void +gomp_team_barrier_cancel (struct gomp_team *team) +{ + /* Always set CANCEL on the barrier. This needs to be atomic because + barrier wait paths use `generation` to communicate without holding + team->task_lock. Don't need any memory-ordering here since the only thing + that BAR_CANCELLED indicates is that the barrier is cancelled (no thread + infers anything else about data being available based on this flag). */ + unsigned orig = __atomic_fetch_or (&team->barrier.generation, BAR_CANCELLED, + MEMMODEL_RELAXED); + if (!(orig & BAR_CANCELLED)) + futex_wake ((int *) &team->barrier.generation, INT_MAX); +} diff --git a/libgomp/config/linux/futex_waitv/bar.h b/libgomp/config/linux/futex_waitv/bar.h new file mode 100644 index 00000000000..d569213160e --- /dev/null +++ b/libgomp/config/linux/futex_waitv/bar.h @@ -0,0 +1,496 @@ +/* Copyright The GNU Toolchain Authors. + + This file is part of the GNU Offloading and Multi Processing Library + (libgomp). + + Libgomp is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +/* This is a Linux > 5.16 specific implementation of a barrier synchronization + mechanism for libgomp. This type is private to the library. This + implementation uses atomic instructions, and the futex and futex_waitv + syscalls. */ + +#ifndef GOMP_BARRIER_H +#define GOMP_BARRIER_H 1 + +#include "mutex.h" + +struct __attribute__ ((aligned (64))) thread_lock_data +{ + unsigned gen; +}; + +typedef struct +{ + /* Make sure total/allocated and generation are in mostly read cachelines, + awaited is in a separate cacheline and each generation structure is in a + separate cache line. */ + unsigned total __attribute__ ((aligned (64))); + unsigned allocated; + unsigned generation; + /* spin_count to use when deciding which barrier to use for the current + generation. Updated once per generation by whichever thread publishes the + generation increment to others just before that is published -- update + determines what will be used for *next* generation. Since only used once + per generation know can adjust non-atomically. It's important that this + is the same according to every thread in a given generation so all threads + perform the same barrier algorithm for any given generation. + N.b. our ability to adjust non-atomically is somewhat fragile. Most + notably we are relying on the fact that + `gomp_team_barrier_wait_cancel_end` and `gomp_team_barrier_wait_end` do + not read `bar->spin_count` to avoid C data races. */ + unsigned long long spin_count; + /* `awaited` used for "simple" or "central" barrier. */ + unsigned awaited __attribute__ ((aligned (64))); + unsigned awaited_final; + /* An *only read* cache line. */ + struct thread_lock_data *threadgens __attribute__ ((aligned (64))); +} gomp_barrier_t; + +typedef unsigned int gomp_barrier_state_t; + +/* The generation field contains a counter in the high bits, with a few + low bits dedicated to flags. Note that TASK_PENDING and WAS_LAST can + share space because WAS_LAST is never stored back to generation. */ +#define BAR_TASK_PENDING 1 +/* In this particular target BAR_WAS_LAST indicates something more like + "chosen by design to be last", but I like having the macro the same name as + it is given in other targets. */ +#define BAR_WAS_LAST 1 +#define BAR_WAITING_FOR_TASK 2 +#define BAR_CANCELLED 4 +/* Flag to indicate that primary should be released while others should be + left. */ +#define BAR_HOLDING_SECONDARIES 8 +/* Using bits 4 -> 11 for the generation number of cancellable barriers and + remaining bits for the generation number of non-cancellable barriers. */ +#define BAR_CANCEL_INCR 16 +#define BAR_INCR 4096 +#define BAR_FLAGS_MASK (~(-BAR_CANCEL_INCR)) +#define BAR_GEN_MASK (-BAR_INCR) +#define BAR_BOTH_GENS_MASK (-BAR_CANCEL_INCR) +#define BAR_CANCEL_GEN_MASK (-BAR_CANCEL_INCR & (~(-BAR_INCR))) +/* Increment BAR_CANCEL_INCR, with wrapping arithmetic within the bits assigned + to this generation number. I.e. Increment, then set bits above BAR_INCR to + what they were before. */ +#define BAR_INCREMENT_CANCEL(X) \ + ({ \ + __typeof__ (X) _X = (X); \ + (((_X + BAR_CANCEL_INCR) & BAR_CANCEL_GEN_MASK) \ + | (_X & ~BAR_CANCEL_GEN_MASK)); \ + }) + +static inline void +gomp_barrier_init (gomp_barrier_t *bar, unsigned count, void *ptr) +{ + gomp_assert ((((uintptr_t) ptr) & (__alignof (struct thread_lock_data) - 1)) + == 0, + "barrier extra allocation is misaligned: %p", ptr); + bar->threadgens = (struct thread_lock_data *) ptr; + bar->spin_count = spin_count (); + for (unsigned i = 0; i < count; ++i) + bar->threadgens[i].gen = 0; + bar->total = count; + bar->allocated = count; + bar->awaited = count; + bar->awaited_final = count; + bar->generation = 0; +} + +static inline struct gomp_barrier_extra_alloc_needs +gomp_barrier_extra_alloc (unsigned count) +{ + return (struct gomp_barrier_extra_alloc_needs){ + sizeof (struct thread_lock_data) * count, + __alignof (struct thread_lock_data)}; +} + +/* When re-initialising a barrier we know that all threads are serialised on + something else (because `gomp_barrier_can_hold` returns true. However we + still want to have memory synchronisation between each thread so still use + atomic operations. */ +static inline void +gomp_central_barrier_reinit (gomp_barrier_t *bar, unsigned nthreads) +{ + __atomic_add_fetch (&bar->awaited, nthreads - bar->total, MEMMODEL_ACQ_REL); + bar->total = nthreads; +} + +static inline void +gomp_central_barrier_init (gomp_barrier_t *bar, unsigned count) +{ + bar->threadgens = NULL; + bar->total = count; + bar->allocated = 0; + bar->awaited = count; + bar->generation = 0; +} + +static inline void +gomp_barrier_destroy (gomp_barrier_t *bar) +{} + +extern void gomp_central_barrier_wait (gomp_barrier_t *); +extern void gomp_central_barrier_wait_last (gomp_barrier_t *); + +extern gomp_barrier_state_t gomp_flat_barrier_wait_start (gomp_barrier_t *, + unsigned); +extern gomp_barrier_state_t gomp_tree_barrier_wait_start (gomp_barrier_t *, + unsigned); +extern gomp_barrier_state_t +gomp_central_tg_barrier_wait_start (gomp_barrier_t *, unsigned); +extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t, + unsigned); + +extern gomp_barrier_state_t gomp_team_flat_barrier_wait_start (gomp_barrier_t *, + unsigned); +extern gomp_barrier_state_t gomp_team_tree_barrier_wait_start (gomp_barrier_t *, + unsigned); +extern gomp_barrier_state_t +gomp_team_central_tg_barrier_wait_start (gomp_barrier_t *, unsigned); +extern gomp_barrier_state_t +gomp_team_central_tg_barrier_wait_final_start (gomp_barrier_t *, unsigned); +extern void gomp_team_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t, + unsigned); +extern void gomp_team_barrier_wait_for_tasks (gomp_barrier_t *, + gomp_barrier_state_t, unsigned); +extern void gomp_team_barrier_done_final (gomp_barrier_t *bar, unsigned id); +extern void gomp_team_central_tg_barrier_wait_final_end (gomp_barrier_t *bar, + gomp_barrier_state_t, + unsigned id); + +extern gomp_barrier_state_t +gomp_team_flat_barrier_wait_cancel_start (gomp_barrier_t *, unsigned); +extern gomp_barrier_state_t +gomp_team_tree_barrier_wait_cancel_start (gomp_barrier_t *, unsigned); +extern gomp_barrier_state_t +gomp_team_central_tg_barrier_wait_cancel_start (gomp_barrier_t *, unsigned); + +extern bool gomp_team_barrier_wait_cancel_end_impl (gomp_barrier_t *, + gomp_barrier_state_t, + unsigned); + +void gomp_team_barrier_wake (gomp_barrier_t *bar, int count); +struct gomp_team; +extern void gomp_team_barrier_cancel (struct gomp_team *); + +static inline enum gomp_barrier_type +gomp_barrier_kind_to_use (unsigned long long spin_count, bool is_final) +{ + enum gomp_barrier_type req + = is_final ? gomp_forkjoin_barrier_request : gomp_barrier_request; + /* It is important to remember that the defaults we choose here have some + interaction with the code we use for implementation. + As it stands, if we were to use "centralized" barrier based on spin_count + for the final barrier then we would have to ensure that + `gomp_barrier_can_hold` returns information describing what the + spin_count would have determined when running the last final barrier + (rather than the current one). That's a bit awkward. As it stands, + depending on workflow one could very well prefer to use GOMP_TREE_BARRIER + as the "final" barrier in low spincount because it performs drastically + better if there are not many tasks being performed on that final barrier. + If there are tasks being performed then GOMP_CENTRALIZED_BARRIER performs + best -- but that can be chosen by GOMP_BARRIER_TYPE=centralized or + GOMP_FORKJOIN_BARRIER_TYPE=centralized anyway. Hence this set of + defaults both removes some complexity and allows all optimal choices of + barrier. */ + if (req != GOMP_BARRIER_BY_SPINCOUNT) + return req; + /* 300000LL is not a number that we have solid performance numbers backing. + Want to choose FLAT barrier when we don't enter futex_wait and + centralized/tree combination otherwise. That is determined based on the + users workloads. + Using "flat" on unspecified OMP_WAIT_POLICY since I've seen some library + workloads that benefit from this. */ + return (spin_count >= 300000LL ? GOMP_FLAT_BARRIER + : is_final ? GOMP_TREE_BARRIER : GOMP_CENTRALIZED_BARRIER); +} + +static inline gomp_barrier_state_t +gomp_barrier_wait_start (gomp_barrier_t *bar, unsigned id) +{ + switch (gomp_barrier_kind_to_use (bar->spin_count, false)) + { + case GOMP_FLAT_BARRIER: + return gomp_flat_barrier_wait_start (bar, id); + case GOMP_TREE_BARRIER: + return gomp_tree_barrier_wait_start (bar, id); + case GOMP_CENTRALIZED_BARRIER: + return gomp_central_tg_barrier_wait_start (bar, id); + default: + __builtin_unreachable (); + } +} + +/* Semantics are supposed to be like gomp_barrier_wait, except that if the + encountering thread is not the last one to hit the barrier, it returns + immediately. The intended usage is that a thread which intends to + gomp_barrier_destroy this barrier calls gomp_barrier_wait, while all other + threads call gomp_barrier_wait_last. When gomp_barrier_wait returns, the + barrier can be safely destroyed. + + This is pretty difficult to implement with the `tree` based barrier. + If this thread should be the co-ordinator of a sub-group of threads then it + can't immediately exit. Instead we wait until all threads "above" it have + arrived. This fulfills the requirements of knowing that when + `gomp_barrier_wait` returns the barrier can be safely destroyed. */ +static inline void +gomp_barrier_wait_last (gomp_barrier_t *bar, unsigned id) +{ + gomp_assert (id != 0, "thread with id %u called gomp_barrier_wait_last", id); + /* After the call to `gomp_barrier_wait_start`: + - For the "flat" barrier all secondary threads mark themselves as having + arrived and will immediately exit. + - For the "tree" barrier secondary threads wait for whatever children they + are supposed to wait on and then exit. + - For the "central_tg" barrier, if there is a secondary thread that + happens to be last then it will have to signal to the primary thread + (and others) that the barrier has been reached. + For the intended use of this function we don't need to care about being + called by the primary thread (see assertion above), if we did need to care + about such things then it would require a different barrier structure. */ + gomp_barrier_state_t state = gomp_barrier_wait_start (bar, id); + if (state & BAR_WAS_LAST) + gomp_barrier_wait_end (bar, state, id); +} + +static inline void +gomp_barrier_wait (gomp_barrier_t *bar, unsigned id) +{ + gomp_barrier_state_t state = gomp_barrier_wait_start (bar, id); + gomp_barrier_wait_end (bar, state, id); +} + +static inline void +gomp_team_barrier_wait (gomp_barrier_t *bar, unsigned id) +{ + gomp_barrier_state_t state; + switch (gomp_barrier_kind_to_use (bar->spin_count, false)) + { + case GOMP_FLAT_BARRIER: + state = gomp_team_flat_barrier_wait_start (bar, id); + break; + case GOMP_TREE_BARRIER: + state = gomp_team_tree_barrier_wait_start (bar, id); + break; + case GOMP_CENTRALIZED_BARRIER: + state = gomp_team_central_tg_barrier_wait_start (bar, id); + break; + default: + __builtin_unreachable (); + } + gomp_team_barrier_wait_end (bar, state, id); +} + +static inline void +gomp_team_barrier_wait_final (gomp_barrier_t *bar, unsigned id) +{ + gomp_barrier_state_t state; + enum gomp_barrier_type type + = gomp_barrier_kind_to_use (bar->spin_count, true); + switch (type) + { + case GOMP_FLAT_BARRIER: + state = gomp_team_flat_barrier_wait_start (bar, id); + break; + case GOMP_TREE_BARRIER: + state = gomp_team_tree_barrier_wait_start (bar, id); + break; + case GOMP_CENTRALIZED_BARRIER: + state = gomp_team_central_tg_barrier_wait_final_start (bar, id); + break; + default: + __builtin_unreachable (); + } + /* Revert `awaited` to account for possibility of a cancelled central barrier + before leaving `awaited` in unknown state. */ + if (state & BAR_WAS_LAST) + bar->awaited = bar->total; + /* central barrier doesn't guarantee that primary thread is last out of + wait_start. This means it needs the BAR_HOLDING_SECONDARIES functionality + doesn't give much performance boost (there's extra synchronisation + required to get the primary last and that costs about the same as the + second barrier that we get to avoid). */ + if (type == GOMP_CENTRALIZED_BARRIER) + gomp_team_central_tg_barrier_wait_final_end (bar, state, id); + else + gomp_team_barrier_wait_for_tasks (bar, state, id); +} + +static inline gomp_barrier_state_t +gomp_barrier_wait_cancel_start (gomp_barrier_t *bar, unsigned id) +{ + switch (gomp_barrier_kind_to_use (bar->spin_count, false)) + { + case GOMP_FLAT_BARRIER: + return gomp_team_flat_barrier_wait_cancel_start (bar, id); + case GOMP_TREE_BARRIER: + return gomp_team_tree_barrier_wait_cancel_start (bar, id); + case GOMP_CENTRALIZED_BARRIER: + return gomp_team_central_tg_barrier_wait_cancel_start (bar, id); + default: + __builtin_unreachable (); + } +} + +static inline bool +gomp_team_barrier_wait_cancel (gomp_barrier_t *bar, unsigned id) +{ + gomp_barrier_state_t state = gomp_barrier_wait_cancel_start (bar, id); + + if (__builtin_expect (state & BAR_CANCELLED, 0)) + return true; + + return gomp_team_barrier_wait_cancel_end_impl (bar, state, id); +} + +static inline bool +gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, + gomp_barrier_state_t state, unsigned id) +{ + if (state & BAR_CANCELLED) + return true; + return gomp_team_barrier_wait_cancel_end_impl (bar, state, id); +} + +static inline bool +gomp_barrier_last_thread (gomp_barrier_state_t state) +{ + return state & BAR_WAS_LAST; +} + +static inline bool +gomp_barrier_can_hold (gomp_barrier_t *bar) +{ + /* As it stands never choose CENTRALIZED for final barrier by default. */ + return gomp_forkjoin_barrier_request == GOMP_CENTRALIZED_BARRIER ? false + : true; +} + +static inline bool +gomp_team_barrier_wake_on_increment (unsigned increment) +{ + return increment == BAR_HOLDING_SECONDARIES ? false : true; +} + +static inline void +gomp_team_barrier_set_task_pending (gomp_barrier_t *bar) +{ + __atomic_fetch_or (&bar->generation, BAR_TASK_PENDING, MEMMODEL_RELAXED); +} + +static inline void +gomp_team_barrier_clear_task_pending (gomp_barrier_t *bar) +{ + __atomic_fetch_and (&bar->generation, ~BAR_TASK_PENDING, MEMMODEL_RELAXED); +} + +static inline void +gomp_team_barrier_set_waiting_for_tasks (gomp_barrier_t *bar) +{ + __atomic_fetch_or (&bar->generation, BAR_WAITING_FOR_TASK, MEMMODEL_RELAXED); +} + +static inline bool +gomp_team_barrier_waiting_for_tasks (gomp_barrier_t *bar) +{ + unsigned gen = __atomic_load_n (&bar->generation, MEMMODEL_RELAXED); + return (gen & BAR_WAITING_FOR_TASK) != 0; +} + +static inline bool +gomp_team_barrier_cancelled (gomp_barrier_t *bar) +{ + unsigned gen = __atomic_load_n (&bar->generation, MEMMODEL_RELAXED); + return __builtin_expect ((gen & BAR_CANCELLED) != 0, 0); +} + +static inline unsigned +gomp_increment_gen (gomp_barrier_state_t gen, unsigned increment) +{ + unsigned gens = (gen & BAR_BOTH_GENS_MASK); + switch (increment) + { + case BAR_CANCEL_INCR: + return BAR_INCREMENT_CANCEL (gens); + /* Increment of `false` used when increment of barrier not possible. + Used when the primary thread is waiting for all other threads to arrive. + Using `false` just as something to make it clear in the code that this + function can't increment. This function still has to handle such an + argument. */ + case false: + case BAR_INCR: + return gens + BAR_INCR; + case BAR_HOLDING_SECONDARIES: + return gens | BAR_HOLDING_SECONDARIES; + default: + gomp_fatal ("unknown increment in gomp_increment_gen: %u\n", increment); + } +} + +static inline void +gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned increment) +{ + /* Using MEMMODEL_RELEASE because this will "publish" the user data written + in tasks to other threads. */ + bar->spin_count = spin_count (); + __atomic_store_n (&bar->generation, gomp_increment_gen (state, increment), + MEMMODEL_RELEASE); +} + +static inline bool +gomp_barrier_incremented (gomp_barrier_state_t gen, gomp_barrier_state_t state, + unsigned increment) +{ + /* Remove all flags from the "original state" field. + Logic of the function is that if/when we spill over the generation will be + less than the original generation. However just checking that the current + generation is less fails if it's less because flags have been cleared. + Hence check against a `state` with cleared flags. + `gomp_increment_gen` already clears flags before using `state` so this + makes no difference there. */ + state &= BAR_BOTH_GENS_MASK; + /* In the case of BAR_HOLDING_SECONDARIES the actual point at which all + threads are released is an increment of BAR_INCR after the primary thread + has continued past that temporary hold. */ + if (increment == BAR_HOLDING_SECONDARIES) + increment = BAR_INCR; + unsigned next = gomp_increment_gen (state, increment); + return __builtin_expect (next > state, 1) ? gen >= next : gen < state; +} + +static inline bool +gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar, + unsigned increment) +{ + unsigned curgen = __atomic_load_n (&bar->generation, MEMMODEL_RELAXED); + if (curgen & BAR_HOLDING_SECONDARIES) + { + gomp_assert (increment == BAR_HOLDING_SECONDARIES, + "barrier generation %u which claims holding secondaries" + " but increment was %u", + curgen, increment); + return true; + } + return gomp_barrier_incremented (curgen, state, increment); +} + +#endif /* GOMP_BARRIER_H */ diff --git a/libgomp/config/linux/futex_waitv/futex_waitv.h b/libgomp/config/linux/futex_waitv/futex_waitv.h new file mode 100644 index 00000000000..ac9a0bfee85 --- /dev/null +++ b/libgomp/config/linux/futex_waitv/futex_waitv.h @@ -0,0 +1,67 @@ +/* Copyright The GNU Toolchain Authors. + + This file is part of the GNU Offloading and Multi Processing Library + (libgomp). + + Libgomp is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +#define _GNU_SOURCE +#include + +#ifndef SYS_futex_waitv +# error SYS_futex_waitv is required for the linux/futex_waitv libgomp target +#endif + +#include +#include +#include +#include +#include + +#pragma GCC visibility push(default) +#include +#pragma GCC visibility pop + +/* Only define the interface we need. `futex_waitv` can wait on more + addresses, but the barrier code only needs two. + + See https://docs.kernel.org/userspace-api/futex2.html for documentation on + futex_waitv syscall. */ +static inline void +futex_waitv (uint32_t *addr, uint32_t val, uint32_t *addr2, uint32_t val2) +{ + struct futex_waitv addrs[2]; + addrs[0].val = val; + addrs[0].uaddr = (uint64_t) (uintptr_t) addr; + addrs[0].flags = FUTEX_PRIVATE_FLAG | FUTEX_32; + addrs[0].__reserved = 0; + addrs[1].val = val2; + addrs[1].uaddr = (uint64_t) (uintptr_t) addr2; + addrs[1].flags = FUTEX_PRIVATE_FLAG | FUTEX_32; + addrs[1].__reserved = 0; + int err __attribute__ ((unused)) + = syscall (SYS_futex_waitv, addrs, 2, 0, NULL, CLOCK_MONOTONIC); + /* If a signal woke us then we simply leave and let the loop outside of us + handle it. We never require knowledge about whether anything changed or + not. */ + gomp_assert (err >= 0 || errno == EAGAIN || errno == EINTR, + "failed with futex_waitv err = %d, message: %s", err, + strerror (errno)); +} diff --git a/libgomp/config/linux/futex_waitv/simple-bar.h b/libgomp/config/linux/futex_waitv/simple-bar.h new file mode 100644 index 00000000000..c6a26bddc42 --- /dev/null +++ b/libgomp/config/linux/futex_waitv/simple-bar.h @@ -0,0 +1,66 @@ +/* Copyright The GNU Toolchain Authors. + + This file is part of the GNU Offloading and Multi Processing Library + (libgomp). + + Libgomp is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +/* This is a simplified barrier that is suitable for thread pool + synchronization. Only a subset of full barrier API (bar.h) is exposed. */ + +#ifndef GOMP_SIMPLE_BARRIER_H +#define GOMP_SIMPLE_BARRIER_H 1 + +#include "bar.h" + +typedef struct +{ + gomp_barrier_t bar; +} gomp_simple_barrier_t; + +static inline void +gomp_simple_barrier_init (gomp_simple_barrier_t *bar, unsigned count) +{ + gomp_central_barrier_init (&bar->bar, count); +} + +static inline void +gomp_simple_barrier_reinit (gomp_simple_barrier_t *bar, unsigned nthreads) +{ + gomp_central_barrier_reinit (&bar->bar, nthreads); +} + +static inline void +gomp_simple_barrier_destroy (gomp_simple_barrier_t *bar) +{} + +static inline void +gomp_simple_barrier_wait (gomp_simple_barrier_t *bar) +{ + gomp_central_barrier_wait (&bar->bar); +} + +static inline void +gomp_simple_barrier_wait_last (gomp_simple_barrier_t *bar) +{ + gomp_central_barrier_wait_last (&bar->bar); +} + +#endif /* GOMP_SIMPLE_BARRIER_H */ diff --git a/libgomp/config/linux/wait.h b/libgomp/config/linux/wait.h index f9141408c5b..a6b235f89fc 100644 --- a/libgomp/config/linux/wait.h +++ b/libgomp/config/linux/wait.h @@ -35,6 +35,7 @@ #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 + #define FUTEX_PRIVATE_FLAG 128 #ifdef HAVE_ATTRIBUTE_VISIBILITY @@ -45,14 +46,10 @@ extern int gomp_futex_wait, gomp_futex_wake; #include -static inline int do_spin (int *addr, int val) +static inline int +do_spin (int *addr, int val) { - unsigned long long i, count = gomp_spin_count_var; - - if (__builtin_expect (__atomic_load_n (&gomp_managed_threads, - MEMMODEL_RELAXED) - > gomp_available_cpus, 0)) - count = gomp_throttled_spin_count_var; + unsigned long long i, count = spin_count (); for (i = 0; i < count; i++) if (__builtin_expect (__atomic_load_n (addr, MEMMODEL_RELAXED) != val, 0)) return 0; diff --git a/libgomp/config/nvptx/bar.c b/libgomp/config/nvptx/bar.c index 024f278e03c..6cb5649f783 100644 --- a/libgomp/config/nvptx/bar.c +++ b/libgomp/config/nvptx/bar.c @@ -31,7 +31,8 @@ #include "libgomp.h" void -gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) +gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned id __attribute__ ((unused))) { if (__builtin_expect (state & BAR_WAS_LAST, 0)) { @@ -45,9 +46,9 @@ gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) } void -gomp_barrier_wait (gomp_barrier_t *bar) +gomp_barrier_wait (gomp_barrier_t *bar, unsigned id) { - gomp_barrier_wait_end (bar, gomp_barrier_wait_start (bar)); + gomp_barrier_wait_end (bar, gomp_barrier_wait_start (bar, id), id); } /* Like gomp_barrier_wait, except that if the encountering thread @@ -58,7 +59,8 @@ gomp_barrier_wait (gomp_barrier_t *bar) the barrier can be safely destroyed. */ void -gomp_barrier_wait_last (gomp_barrier_t *bar) +gomp_barrier_wait_last (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) { /* The above described behavior matches 'bar.arrive' perfectly. */ if (bar->total > 1) @@ -77,7 +79,8 @@ gomp_barrier_wait_last (gomp_barrier_t *bar) on GPUs). */ void -gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) +gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned id __attribute__ ((unused))) { struct gomp_thread *thr = gomp_thread (); struct gomp_team *team = thr->ts.team; @@ -98,7 +101,7 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) { while (__atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE) & BAR_TASK_PENDING) - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, 0); if (bar->total > 1) asm volatile ("bar.sync 1, %0;" : : "r" (32 * bar->total)); @@ -106,25 +109,26 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) } void -gomp_team_barrier_wait (gomp_barrier_t *bar) +gomp_team_barrier_wait (gomp_barrier_t *bar, unsigned id) { - gomp_team_barrier_wait_end (bar, gomp_barrier_wait_start (bar)); + gomp_team_barrier_wait_end (bar, gomp_barrier_wait_start (bar, id), id); } void -gomp_team_barrier_wait_final (gomp_barrier_t *bar) +gomp_team_barrier_wait_final (gomp_barrier_t *bar, unsigned id) { - gomp_barrier_state_t state = gomp_barrier_wait_final_start (bar); + gomp_barrier_state_t state = gomp_barrier_wait_final_start (bar, id); if (__builtin_expect (state & BAR_WAS_LAST, 0)) bar->awaited_final = bar->total; - gomp_team_barrier_wait_end (bar, state); + gomp_team_barrier_wait_end (bar, state, id); } /* See also comments for gomp_team_barrier_wait_end. */ bool gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, - gomp_barrier_state_t state) + gomp_barrier_state_t state, + unsigned id __attribute__ ((unused))) { struct gomp_thread *thr = gomp_thread (); struct gomp_team *team = thr->ts.team; @@ -152,7 +156,7 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, { while (__atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE) & BAR_TASK_PENDING) - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, 0); if (bar->total > 1) asm volatile ("bar.sync 1, %0;" : : "r" (32 * bar->total)); @@ -162,9 +166,11 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, } bool -gomp_team_barrier_wait_cancel (gomp_barrier_t *bar) +gomp_team_barrier_wait_cancel (gomp_barrier_t *bar, unsigned id) { - return gomp_team_barrier_wait_cancel_end (bar, gomp_barrier_wait_start (bar)); + return gomp_team_barrier_wait_cancel_end (bar, + gomp_barrier_wait_start (bar, id), + id); } void diff --git a/libgomp/config/nvptx/bar.h b/libgomp/config/nvptx/bar.h index 3085711d5a6..4915b219cf0 100644 --- a/libgomp/config/nvptx/bar.h +++ b/libgomp/config/nvptx/bar.h @@ -51,7 +51,9 @@ typedef unsigned int gomp_barrier_state_t; #define BAR_CANCELLED 4 #define BAR_INCR 8 -static inline void gomp_barrier_init (gomp_barrier_t *bar, unsigned count) +static inline void +gomp_barrier_init (gomp_barrier_t *bar, unsigned count, + void *ptr __attribute__ ((unused))) { bar->total = count; bar->awaited = count; @@ -69,16 +71,23 @@ static inline void gomp_barrier_destroy (gomp_barrier_t *bar) { } -extern void gomp_barrier_wait (gomp_barrier_t *); -extern void gomp_barrier_wait_last (gomp_barrier_t *); -extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t); -extern void gomp_team_barrier_wait (gomp_barrier_t *); -extern void gomp_team_barrier_wait_final (gomp_barrier_t *); -extern void gomp_team_barrier_wait_end (gomp_barrier_t *, - gomp_barrier_state_t); -extern bool gomp_team_barrier_wait_cancel (gomp_barrier_t *); +static inline struct gomp_barrier_extra_alloc_needs +gomp_barrier_extra_alloc (unsigned count __attribute__ ((unused))) +{ + return (struct gomp_barrier_extra_alloc_needs){0, 1}; +} + +extern void gomp_barrier_wait (gomp_barrier_t *, unsigned); +extern void gomp_barrier_wait_last (gomp_barrier_t *, unsigned); +extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t, + unsigned); +extern void gomp_team_barrier_wait (gomp_barrier_t *, unsigned); +extern void gomp_team_barrier_wait_final (gomp_barrier_t *, unsigned); +extern void gomp_team_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t, + unsigned); +extern bool gomp_team_barrier_wait_cancel (gomp_barrier_t *, unsigned); extern bool gomp_team_barrier_wait_cancel_end (gomp_barrier_t *, - gomp_barrier_state_t); + gomp_barrier_state_t, unsigned); struct gomp_team; extern void gomp_team_barrier_cancel (struct gomp_team *); @@ -90,7 +99,8 @@ gomp_team_barrier_wake (gomp_barrier_t *bar, int count) } static inline gomp_barrier_state_t -gomp_barrier_wait_start (gomp_barrier_t *bar) +gomp_barrier_wait_start (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) { unsigned int ret = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); ret &= -BAR_INCR | BAR_CANCELLED; @@ -105,16 +115,17 @@ gomp_barrier_wait_start (gomp_barrier_t *bar) } static inline gomp_barrier_state_t -gomp_barrier_wait_cancel_start (gomp_barrier_t *bar) +gomp_barrier_wait_cancel_start (gomp_barrier_t *bar, unsigned id) { - return gomp_barrier_wait_start (bar); + return gomp_barrier_wait_start (bar, id); } /* This is like gomp_barrier_wait_start, except it decrements bar->awaited_final rather than bar->awaited and should be used for the gomp_team_end barrier only. */ static inline gomp_barrier_state_t -gomp_barrier_wait_final_start (gomp_barrier_t *bar) +gomp_barrier_wait_final_start (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) { unsigned int ret = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); ret &= -BAR_INCR | BAR_CANCELLED; @@ -164,16 +175,36 @@ gomp_team_barrier_cancelled (gomp_barrier_t *bar) } static inline void -gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) +gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned increment __attribute__ ((unused))) { bar->generation = (state & -BAR_INCR) + BAR_INCR; } static inline bool -gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar) +gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar, + unsigned increment __attribute__ ((unused))) { unsigned int gen = bar->generation; return (gen & -BAR_INCR) == (state & -BAR_INCR) + BAR_INCR; } +static inline bool +gomp_barrier_can_hold (gomp_barrier_t *bar) +{ + return false; +} + +static inline bool +gomp_team_barrier_wake_on_increment (unsigned increment + __attribute__ ((unused))) +{ + return true; +} + +/* Functions dummied out for this implementation. */ +static inline void +gomp_team_barrier_done_final (gomp_barrier_t *bar, unsigned id) +{} + #endif /* GOMP_BARRIER_H */ diff --git a/libgomp/config/nvptx/team.c b/libgomp/config/nvptx/team.c index 138fb4a3d90..5ec4d781906 100644 --- a/libgomp/config/nvptx/team.c +++ b/libgomp/config/nvptx/team.c @@ -104,6 +104,7 @@ gomp_nvptx_main (void (*fn) (void *), void *fn_data) pool->threads_used = ntids; pool->threads_busy = 1; pool->last_team = NULL; + pool->prev_barrier = NULL; gomp_simple_barrier_init (&pool->threads_dock, ntids); nvptx_thrs[0].thread_pool = pool; @@ -139,7 +140,7 @@ gomp_thread_start (struct gomp_thread_pool *pool) thr->fn = NULL; struct gomp_task *task = thr->task; - gomp_team_barrier_wait_final (&thr->ts.team->barrier); + gomp_team_barrier_wait_final (&thr->ts.team->barrier, thr->ts.team_id); gomp_finish_task (task); } /* Work around an NVIDIA driver bug: when generating sm_50 machine code, diff --git a/libgomp/config/posix/bar.c b/libgomp/config/posix/bar.c index 8dbf7be08ea..caf2933d659 100644 --- a/libgomp/config/posix/bar.c +++ b/libgomp/config/posix/bar.c @@ -30,9 +30,9 @@ #include "libgomp.h" - void -gomp_barrier_init (gomp_barrier_t *bar, unsigned count) +gomp_barrier_init (gomp_barrier_t *bar, unsigned count, + void *ptr __attribute__ ((unused))) { gomp_mutex_init (&bar->mutex1); #ifndef HAVE_SYNC_BUILTINS @@ -105,13 +105,14 @@ gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) } void -gomp_barrier_wait (gomp_barrier_t *barrier) +gomp_barrier_wait (gomp_barrier_t *barrier, unsigned id) { - gomp_barrier_wait_end (barrier, gomp_barrier_wait_start (barrier)); + gomp_barrier_wait_end (barrier, gomp_barrier_wait_start (barrier, id)); } void -gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) +gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned id __attribute__ ((unused))) { unsigned int n; @@ -127,7 +128,7 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) = __atomic_load_n (&team->task_count, MEMMODEL_ACQUIRE); if (task_count) { - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, BAR_INCR); if (n > 0) gomp_sem_wait (&bar->sem2); gomp_mutex_unlock (&bar->mutex1); @@ -154,7 +155,7 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); if (gen & BAR_TASK_PENDING) { - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, BAR_INCR); gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); } } @@ -175,7 +176,8 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state) bool gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, - gomp_barrier_state_t state) + gomp_barrier_state_t state, + unsigned id __attribute__ ((unused))) { unsigned int n; @@ -191,7 +193,7 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, = __atomic_load_n (&team->task_count, MEMMODEL_ACQUIRE); if (task_count) { - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, BAR_INCR); if (n > 0) gomp_sem_wait (&bar->sem2); gomp_mutex_unlock (&bar->mutex1); @@ -226,7 +228,7 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, break; if (gen & BAR_TASK_PENDING) { - gomp_barrier_handle_tasks (state); + gomp_barrier_handle_tasks (state, bar, BAR_INCR); gen = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); if (gen & BAR_CANCELLED) break; @@ -251,9 +253,10 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar, } void -gomp_team_barrier_wait (gomp_barrier_t *barrier) +gomp_team_barrier_wait (gomp_barrier_t *barrier, unsigned id) { - gomp_team_barrier_wait_end (barrier, gomp_barrier_wait_start (barrier)); + gomp_team_barrier_wait_end (barrier, gomp_barrier_wait_start (barrier, id), + id); } void @@ -266,10 +269,10 @@ gomp_team_barrier_wake (gomp_barrier_t *bar, int count) } bool -gomp_team_barrier_wait_cancel (gomp_barrier_t *bar) +gomp_team_barrier_wait_cancel (gomp_barrier_t *bar, unsigned id) { - gomp_barrier_state_t state = gomp_barrier_wait_cancel_start (bar); - return gomp_team_barrier_wait_cancel_end (bar, state); + gomp_barrier_state_t state = gomp_barrier_wait_cancel_start (bar, id); + return gomp_team_barrier_wait_cancel_end (bar, state, id); } void diff --git a/libgomp/config/posix/bar.h b/libgomp/config/posix/bar.h index 8aab3733cc7..3af38dc62bf 100644 --- a/libgomp/config/posix/bar.h +++ b/libgomp/config/posix/bar.h @@ -58,24 +58,31 @@ typedef unsigned int gomp_barrier_state_t; #define BAR_CANCELLED 4 #define BAR_INCR 8 -extern void gomp_barrier_init (gomp_barrier_t *, unsigned); +extern void gomp_barrier_init (gomp_barrier_t *, unsigned, void *); extern void gomp_barrier_reinit (gomp_barrier_t *, unsigned); extern void gomp_barrier_destroy (gomp_barrier_t *); -extern void gomp_barrier_wait (gomp_barrier_t *); +static inline struct gomp_barrier_extra_alloc_needs +gomp_barrier_extra_alloc (unsigned count __attribute__ ((unused))) +{ + return (struct gomp_barrier_extra_alloc_needs){0, 1}; +} + +extern void gomp_barrier_wait (gomp_barrier_t *, unsigned); extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t); -extern void gomp_team_barrier_wait (gomp_barrier_t *); -extern void gomp_team_barrier_wait_end (gomp_barrier_t *, - gomp_barrier_state_t); -extern bool gomp_team_barrier_wait_cancel (gomp_barrier_t *); +extern void gomp_team_barrier_wait (gomp_barrier_t *, unsigned); +extern void gomp_team_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t, + unsigned); +extern bool gomp_team_barrier_wait_cancel (gomp_barrier_t *, unsigned); extern bool gomp_team_barrier_wait_cancel_end (gomp_barrier_t *, - gomp_barrier_state_t); + gomp_barrier_state_t, unsigned); extern void gomp_team_barrier_wake (gomp_barrier_t *, int); struct gomp_team; extern void gomp_team_barrier_cancel (struct gomp_team *); static inline gomp_barrier_state_t -gomp_barrier_wait_start (gomp_barrier_t *bar) +gomp_barrier_wait_start (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) { unsigned int ret; gomp_mutex_lock (&bar->mutex1); @@ -86,7 +93,8 @@ gomp_barrier_wait_start (gomp_barrier_t *bar) } static inline gomp_barrier_state_t -gomp_barrier_wait_cancel_start (gomp_barrier_t *bar) +gomp_barrier_wait_cancel_start (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) { unsigned int ret; gomp_mutex_lock (&bar->mutex1); @@ -99,9 +107,9 @@ gomp_barrier_wait_cancel_start (gomp_barrier_t *bar) } static inline void -gomp_team_barrier_wait_final (gomp_barrier_t *bar) +gomp_team_barrier_wait_final (gomp_barrier_t *bar, unsigned id) { - gomp_team_barrier_wait (bar); + gomp_team_barrier_wait (bar, id); } static inline bool @@ -111,9 +119,9 @@ gomp_barrier_last_thread (gomp_barrier_state_t state) } static inline void -gomp_barrier_wait_last (gomp_barrier_t *bar) +gomp_barrier_wait_last (gomp_barrier_t *bar, unsigned id) { - gomp_barrier_wait (bar); + gomp_barrier_wait (bar, id); } /* All the inlines below must be called with team->task_lock @@ -150,7 +158,8 @@ gomp_team_barrier_cancelled (gomp_barrier_t *bar) } static inline void -gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) +gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned increment __attribute__ ((unused))) { /* Need the atomic store for acquire-release synchronisation with the load in `gomp_team_barrier_wait_{cancel_,}end`. See PR112356 */ @@ -159,10 +168,31 @@ gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) } static inline bool -gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar) +gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar, + unsigned increment __attribute__ ((unused))) { unsigned int gen = bar->generation; return (gen & -BAR_INCR) == (state & -BAR_INCR) + BAR_INCR; } +static inline bool +gomp_barrier_can_hold (gomp_barrier_t *bar) +{ + return false; +} + +static inline bool +gomp_team_barrier_wake_on_increment (unsigned increment + __attribute__ ((unused))) +{ + return true; +} + +/* Functions dummied out for this implementation. */ +static inline void +gomp_team_barrier_done_final (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) +{} + +/* TODO Introduce `gomp_barrier_completed`. */ #endif /* GOMP_BARRIER_H */ diff --git a/libgomp/config/posix/pool.h b/libgomp/config/posix/pool.h index 1149354a7f3..385f339fd1f 100644 --- a/libgomp/config/posix/pool.h +++ b/libgomp/config/posix/pool.h @@ -44,6 +44,7 @@ gomp_get_thread_pool (struct gomp_thread *thr, unsigned nthreads) pool->threads_size = 0; pool->threads_used = 0; pool->last_team = NULL; + pool->prev_barrier = NULL; pool->threads_busy = nthreads; thr->thread_pool = pool; pthread_setspecific (gomp_thread_destructor, thr); diff --git a/libgomp/config/posix/simple-bar.h b/libgomp/config/posix/simple-bar.h index b888a27df01..d5af670ac36 100644 --- a/libgomp/config/posix/simple-bar.h +++ b/libgomp/config/posix/simple-bar.h @@ -39,13 +39,13 @@ typedef struct static inline void gomp_simple_barrier_init (gomp_simple_barrier_t *bar, unsigned count) { - gomp_barrier_init (&bar->bar, count); + gomp_barrier_init (&bar->bar, count, NULL); } static inline void -gomp_simple_barrier_reinit (gomp_simple_barrier_t *bar, unsigned count) +gomp_simple_barrier_reinit (gomp_simple_barrier_t *sbar, unsigned nthreads) { - gomp_barrier_reinit (&bar->bar, count); + gomp_barrier_reinit (&sbar->bar, nthreads); } static inline void @@ -57,13 +57,15 @@ gomp_simple_barrier_destroy (gomp_simple_barrier_t *bar) static inline void gomp_simple_barrier_wait (gomp_simple_barrier_t *bar) { - gomp_barrier_wait (&bar->bar); + /* In default implementation the barrier ID argument is unused. */ + gomp_barrier_wait (&bar->bar, 0); } static inline void gomp_simple_barrier_wait_last (gomp_simple_barrier_t *bar) { - gomp_barrier_wait_last (&bar->bar); + /* In default implementation the barrier ID argument is unused. */ + gomp_barrier_wait_last (&bar->bar, 0); } #endif /* GOMP_SIMPLE_BARRIER_H */ diff --git a/libgomp/config/rtems/bar.h b/libgomp/config/rtems/bar.h index 47b961c2104..aacdde6c7fe 100644 --- a/libgomp/config/rtems/bar.h +++ b/libgomp/config/rtems/bar.h @@ -54,7 +54,9 @@ typedef unsigned int gomp_barrier_state_t; #define BAR_CANCELLED 4 #define BAR_INCR 8 -static inline void gomp_barrier_init (gomp_barrier_t *bar, unsigned count) +static inline void +gomp_barrier_init (gomp_barrier_t *bar, unsigned count, + void *ptr __attribute__ ((unused))) { bar->total = count; bar->awaited = count; @@ -73,22 +75,31 @@ static inline void gomp_barrier_destroy (gomp_barrier_t *bar) { } -extern void gomp_barrier_wait (gomp_barrier_t *); -extern void gomp_barrier_wait_last (gomp_barrier_t *); -extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t); -extern void gomp_team_barrier_wait (gomp_barrier_t *); -extern void gomp_team_barrier_wait_final (gomp_barrier_t *); -extern void gomp_team_barrier_wait_end (gomp_barrier_t *, - gomp_barrier_state_t); -extern bool gomp_team_barrier_wait_cancel (gomp_barrier_t *); +static inline struct gomp_barrier_extra_alloc_needs +gomp_barrier_extra_alloc (unsigned count __attribute__ ((unused))) +{ + return (struct gomp_barrier_extra_alloc_needs){0, 1}; +} + +extern void gomp_barrier_wait (gomp_barrier_t *, unsigned); +extern void gomp_barrier_wait_last (gomp_barrier_t *, unsigned); +extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t, + unsigned); + +extern void gomp_team_barrier_wait (gomp_barrier_t *, unsigned); +extern void gomp_team_barrier_wait_final (gomp_barrier_t *, unsigned); +extern void gomp_team_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t, + unsigned); +extern bool gomp_team_barrier_wait_cancel (gomp_barrier_t *, unsigned); extern bool gomp_team_barrier_wait_cancel_end (gomp_barrier_t *, - gomp_barrier_state_t); + gomp_barrier_state_t, unsigned); extern void gomp_team_barrier_wake (gomp_barrier_t *, int); struct gomp_team; extern void gomp_team_barrier_cancel (struct gomp_team *); static inline gomp_barrier_state_t -gomp_barrier_wait_start (gomp_barrier_t *bar) +gomp_barrier_wait_start (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) { unsigned int ret = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); ret &= -BAR_INCR | BAR_CANCELLED; @@ -103,16 +114,17 @@ gomp_barrier_wait_start (gomp_barrier_t *bar) } static inline gomp_barrier_state_t -gomp_barrier_wait_cancel_start (gomp_barrier_t *bar) +gomp_barrier_wait_cancel_start (gomp_barrier_t *bar, unsigned id) { - return gomp_barrier_wait_start (bar); + return gomp_barrier_wait_start (bar, id); } /* This is like gomp_barrier_wait_start, except it decrements bar->awaited_final rather than bar->awaited and should be used for the gomp_team_end barrier only. */ static inline gomp_barrier_state_t -gomp_barrier_wait_final_start (gomp_barrier_t *bar) +gomp_barrier_wait_final_start (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) { unsigned int ret = __atomic_load_n (&bar->generation, MEMMODEL_ACQUIRE); ret &= -BAR_INCR | BAR_CANCELLED; @@ -162,7 +174,8 @@ gomp_team_barrier_cancelled (gomp_barrier_t *bar) } static inline void -gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) +gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state, + unsigned increment __attribute__ ((unused))) { /* Need the atomic store for acquire-release synchronisation with the load in `gomp_team_barrier_wait_{cancel_,}end`. See PR112356 */ @@ -171,10 +184,30 @@ gomp_team_barrier_done (gomp_barrier_t *bar, gomp_barrier_state_t state) } static inline bool -gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar) +gomp_barrier_has_completed (gomp_barrier_state_t state, gomp_barrier_t *bar, + unsigned increment __attribute__ ((unused))) { unsigned int gen = bar->generation; return (gen & -BAR_INCR) == (state & -BAR_INCR) + BAR_INCR; } +static inline bool +gomp_barrier_can_hold (gomp_barrier_t *bar) +{ + return false; +} + +static inline bool +gomp_team_barrier_wake_on_increment (unsigned increment + __attribute__ ((unused))) +{ + return true; +} + +/* Functions dummied out for this implementation. */ +static inline void +gomp_team_barrier_done_final (gomp_barrier_t *bar, + unsigned id __attribute__ ((unused))) +{} + #endif /* GOMP_BARRIER_H */ diff --git a/libgomp/configure b/libgomp/configure index 6ff3899df15..39d501f9d9b 100755 --- a/libgomp/configure +++ b/libgomp/configure @@ -828,6 +828,7 @@ enable_libtool_lock enable_darwin_at_rpath enable_maintainer_mode enable_linux_futex +enable_linux_futex_waitv enable_tls enable_symvers enable_cet @@ -1488,6 +1489,9 @@ Optional Features: enable make rules and dependencies not useful (and sometimes confusing) to the casual installer --enable-linux-futex use the Linux futex system call [default=default] + --enable-linux-futex-waitv + use the Linux futex_waitv system call + [default=default] --enable-tls Use thread-local storage [default=yes] --enable-symvers=STYLE enables symbol versioning of the shared library [default=yes] @@ -11858,7 +11862,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11861 "configure" +#line 11866 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11964,7 +11968,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11967 "configure" +#line 11972 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15957,6 +15961,80 @@ if test x$enable_linux_futex = xyes; then fi + # Check whether --enable-linux-futex-waitv was given. +if test "${enable_linux_futex_waitv+set}" = set; then : + enableval=$enable_linux_futex_waitv; + case "$enableval" in + yes|no|default) ;; + *) as_fn_error $? "Unknown argument to enable/disable linux-futex-waitv" "$LINENO" 5 ;; + esac + +else + enable_linux_futex_waitv=default +fi + + + +case "$target" in + *-linux* | *-uclinux*) + if test x$enable_linux_futex != xyes; then + if test x$enable_linux_futex_waitv = xyes; then + as_fn_error $? "--enable-linux-futex-waitv requires --enable-linux-futex" "$LINENO" 5 + fi + enable_linux_futex_waitv=no + else + case "$enable_linux_futex_waitv" in + default) + enable_linux_futex_waitv=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include +int +main () +{ +syscall (SYS_futex_waitv, 0, 0, 0, 0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + enable_linux_futex_waitv=yes +else + enable_linux_futex_waitv=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ;; + yes) + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include +int +main () +{ +syscall (SYS_futex_waitv, 0, 0, 0, 0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + as_fn_error $? "SYS_futex_waitv required for --enable-linux-futex-waitv" "$LINENO" 5 +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ;; + esac + fi + ;; + *) + enable_linux_futex_waitv=no + ;; +esac + # Check for pthread_{,attr_}[sg]etaffinity_np. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ diff --git a/libgomp/configure.ac b/libgomp/configure.ac index 9ebac1fc336..810ceb39e81 100644 --- a/libgomp/configure.ac +++ b/libgomp/configure.ac @@ -260,6 +260,45 @@ esac GCC_LINUX_FUTEX(:) +LIBGOMP_ENABLE(linux-futex-waitv, default, , + [use the Linux futex_waitv system call], + permit yes|no|default) + +case "$target" in + *-linux* | *-uclinux*) + if test x$enable_linux_futex != xyes; then + if test x$enable_linux_futex_waitv = xyes; then + AC_MSG_ERROR([--enable-linux-futex-waitv requires --enable-linux-futex]) + fi + enable_linux_futex_waitv=no + else + case "$enable_linux_futex_waitv" in + default) + enable_linux_futex_waitv=no + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#include + #include ], + [syscall (SYS_futex_waitv, 0, 0, 0, 0, 0);])], + [enable_linux_futex_waitv=yes], + [enable_linux_futex_waitv=no]) + ;; + yes) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#include + #include ], + [syscall (SYS_futex_waitv, 0, 0, 0, 0, 0);])],[], + [AC_MSG_ERROR([SYS_futex_waitv required for --enable-linux-futex-waitv])]) + ;; + esac + fi + ;; + *) + enable_linux_futex_waitv=no + ;; +esac + # Check for pthread_{,attr_}[sg]etaffinity_np. AC_LINK_IFELSE( [AC_LANG_PROGRAM( diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt index a74e966fdfd..572e5a3b7ec 100644 --- a/libgomp/configure.tgt +++ b/libgomp/configure.tgt @@ -36,57 +36,63 @@ tmake_file= # Since we require POSIX threads, assume a POSIX system by default. config_path="posix" +if test x$enable_linux_futex_waitv = xyes; then + linux_path="linux/futex_waitv linux" +else + linux_path="linux" +fi + # Check for futex enabled all at once. if test x$enable_linux_futex = xyes; then case "${target}" in aarch64*-*-linux*) - config_path="linux posix" + config_path="$linux_path posix" ;; alpha*-*-linux*) - config_path="linux/alpha linux posix" + config_path="linux/alpha $linux_path posix" ;; arm*-*-linux*) - config_path="linux posix" + config_path="$linux_path posix" ;; hppa*-*-linux*) - config_path="linux posix" + config_path="$linux_path posix" ;; ia64*-*-linux*) - config_path="linux/ia64 linux posix" + config_path="linux/ia64 $linux_path posix" ;; loongarch*-*-linux*) - config_path="linux posix" + config_path="$linux_path posix" ;; mips*-*-linux*) - config_path="linux/mips linux posix" + config_path="linux/mips $linux_path posix" ;; powerpc*-*-linux*) - config_path="linux/powerpc linux posix" + config_path="linux/powerpc $linux_path posix" ;; riscv64*-*-linux*) - config_path="linux posix" + config_path="$linux_path posix" ;; s390*-*-linux*) - config_path="linux/s390 linux posix" + config_path="linux/s390 $linux_path posix" ;; tile*-*-linux*) - config_path="linux/tile linux posix" + config_path="linux/tile $linux_path posix" ;; # Note that bare i386 is not included here. We need cmpxchg. i[456]86-*-linux* | x86_64-*-linux*) - config_path="linux/x86 linux posix" + config_path="linux/x86 $linux_path posix" cat > conftestx.c < conftestx.c if ${CC} ${CFLAGS} -c -o conftestx.o conftestx.c > /dev/null 2>&1; then - config_path="linux/sparc linux posix" + config_path="linux/sparc $linux_path posix" case "`/usr/bin/file conftestx.o`" in *32-bit*) case " ${CC} ${CFLAGS}" in diff --git a/libgomp/env.c b/libgomp/env.c index 1d659ad81bd..9dcbbd72ad0 100644 --- a/libgomp/env.c +++ b/libgomp/env.c @@ -125,6 +125,9 @@ enum gomp_runtime_usm_t gomp_runtime_usm_var = GOMP_RUNTIME_USM_DISABLED; char *goacc_device_type; int goacc_device_num; int goacc_default_dims[GOMP_DIM_MAX]; +enum gomp_barrier_type gomp_barrier_request = GOMP_BARRIER_BY_SPINCOUNT; +enum gomp_barrier_type gomp_forkjoin_barrier_request + = GOMP_BARRIER_BY_SPINCOUNT; #ifndef LIBGOMP_OFFLOADED_ONLY @@ -1179,7 +1182,44 @@ parse_wait_policy (const char *env, const char *val, void *const params[]) return false; } -/* Parse the GOMP_CPU_AFFINITY environment variable. Return true if one was +/* Parse the GOMP_{FORKJOIN_,}BARRIER_TYPE environment variable. */ +static void +parse_barrier_choice (const char *name, enum gomp_barrier_type *val) +{ + char *env = getenv (name); + if (env == NULL) + return; + enum gomp_barrier_type ret; + *val = GOMP_BARRIER_BY_SPINCOUNT; + while (isspace ((unsigned char) *env)) + ++env; + if (*env == '\0') + goto invalid; + if (strncasecmp (env, "tree", 4) == 0) + ret = GOMP_TREE_BARRIER; + else if (strncasecmp (env, "flat", 4) == 0) + ret = GOMP_FLAT_BARRIER; + else if (strncasecmp (env, "centralized", 11) == 0) + { + ret = GOMP_CENTRALIZED_BARRIER; + env += 11 - 4; + } + else if (strncasecmp (env, "auto", 4) == 0) + ret = GOMP_BARRIER_BY_SPINCOUNT; + else + goto invalid; + env += 4; + while (isspace ((unsigned char) *env)) + ++env; + if (*env != '\0') + goto invalid; + *val = ret; + return; +invalid: + gomp_error ("Invalid value for environment variable %s", name); +} + +/* Parse the GOMP_CPU_AFFINITY environment varible. Return true if one was present and it was successfully parsed. */ static bool @@ -2036,6 +2076,18 @@ omp_display_env (int verbose) break; } fputs ("'\n", stderr); + fprintf (stderr, " [host] GOMP_BARRIER_TYPE = '%s'\n", + gomp_barrier_request == GOMP_FLAT_BARRIER ? "flat" + : gomp_barrier_request == GOMP_TREE_BARRIER ? "tree" + : gomp_barrier_request == GOMP_CENTRALIZED_BARRIER + ? "centralized" + : "auto"); + fprintf (stderr, " [host] GOMP_FORKJOIN_BARRIER_TYPE = '%s'\n", + gomp_forkjoin_barrier_request == GOMP_FLAT_BARRIER ? "flat" + : gomp_forkjoin_barrier_request == GOMP_TREE_BARRIER ? "tree" + : gomp_forkjoin_barrier_request == GOMP_CENTRALIZED_BARRIER + ? "centralized" + : "auto"); } fputs ("OPENMP DISPLAY ENVIRONMENT END\n", stderr); } @@ -2563,6 +2615,11 @@ initialize_env (void) gomp_error ("Stack size change failed: %s", strerror (err)); } + parse_barrier_choice ("GOMP_BARRIER_TYPE", &gomp_barrier_request); + gomp_forkjoin_barrier_request = gomp_barrier_request; + parse_barrier_choice ("GOMP_FORKJOIN_BARRIER_TYPE", + &gomp_forkjoin_barrier_request); + handle_omp_display_env (); /* OpenACC. */ diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h index c4bab109736..75d3f08e391 100644 --- a/libgomp/libgomp.h +++ b/libgomp/libgomp.h @@ -59,6 +59,7 @@ #include #include #include +#include /* Needed for memset in priority_queue.c. */ #if _LIBGOMP_CHECKING_ @@ -200,10 +201,57 @@ extern void gomp_vfatal (const char *, va_list) extern void gomp_fatal (const char *, ...) __attribute__ ((noreturn, format (printf, 1, 2))); +#if _LIBGOMP_CHECKING_ +#define gomp_assert(EXPR, MSG, ...) \ + do \ + { \ + if (!(EXPR)) \ + gomp_fatal ("%s:%d " MSG, __FILE__, __LINE__, ##__VA_ARGS__); \ + } \ + while (0) +#else +#define gomp_assert(...) \ + do \ + { \ + } \ + while (0) +#endif + struct gomp_task; struct gomp_taskgroup; struct htab; +struct gomp_barrier_extra_alloc_needs +{ + size_t size; + size_t align; +}; + +enum gomp_barrier_type +{ + GOMP_TREE_BARRIER, + GOMP_FLAT_BARRIER, + GOMP_CENTRALIZED_BARRIER, + GOMP_BARRIER_BY_SPINCOUNT +}; +extern enum gomp_barrier_type gomp_barrier_request; +extern enum gomp_barrier_type gomp_forkjoin_barrier_request; + +extern unsigned long long gomp_spin_count_var, gomp_throttled_spin_count_var; +extern unsigned long gomp_available_cpus, gomp_managed_threads; + +static inline unsigned long long +spin_count () +{ + unsigned long long count = gomp_spin_count_var; + if (__builtin_expect (__atomic_load_n (&gomp_managed_threads, + MEMMODEL_RELAXED) + > gomp_available_cpus, + 0)) + count = gomp_throttled_spin_count_var; + return count; +} + #include "priority_queue.h" #include "sem.h" #include "mutex.h" @@ -603,11 +651,10 @@ extern struct gomp_task_icv gomp_global_icv; #ifndef HAVE_SYNC_BUILTINS extern gomp_mutex_t gomp_managed_threads_lock; #endif +/* Included here for the variables. */ extern bool gomp_cancel_var; extern enum gomp_target_offload_t gomp_target_offload_var; extern int gomp_max_task_priority_var; -extern unsigned long long gomp_spin_count_var, gomp_throttled_spin_count_var; -extern unsigned long gomp_available_cpus, gomp_managed_threads; extern unsigned long *gomp_nthreads_var_list, gomp_nthreads_var_list_len; extern char *gomp_bind_var_list; extern unsigned long gomp_bind_var_list_len; @@ -970,6 +1017,7 @@ struct gomp_thread_pool /* This barrier holds and releases threads waiting in thread pools. */ gomp_simple_barrier_t threads_dock; + gomp_barrier_t *prev_barrier; }; enum gomp_cancel_kind @@ -1143,7 +1191,8 @@ extern unsigned gomp_dynamic_max_threads (void); extern void gomp_init_task (struct gomp_task *, struct gomp_task *, struct gomp_task_icv *); extern void gomp_end_task (void); -extern void gomp_barrier_handle_tasks (gomp_barrier_state_t); +extern void gomp_barrier_handle_tasks (gomp_barrier_state_t, gomp_barrier_t *, + unsigned); extern void gomp_task_maybe_wait_for_dependencies (void **); extern bool gomp_create_target_task (struct gomp_device_descr *, void (*) (void *), size_t, void **, diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi index 36fbbb3e3ef..4bb23594e89 100644 --- a/libgomp/libgomp.texi +++ b/libgomp/libgomp.texi @@ -4623,32 +4623,34 @@ host and non-host devices for which a more specific corresponding environment variable is not set. @menu -* OMP_ALLOCATOR:: Set the default allocator -* OMP_AFFINITY_FORMAT:: Set the format string used for affinity display -* OMP_CANCELLATION:: Set whether cancellation is activated -* OMP_DISPLAY_AFFINITY:: Display thread affinity information -* OMP_DISPLAY_ENV:: Show OpenMP version and environment variables -* OMP_DEFAULT_DEVICE:: Set the device used in target regions -* OMP_DYNAMIC:: Dynamic adjustment of threads -* OMP_MAX_ACTIVE_LEVELS:: Set the maximum number of nested parallel regions -* OMP_MAX_TASK_PRIORITY:: Set the maximum task priority value -* OMP_NESTED:: Nested parallel regions -* OMP_NUM_TEAMS:: Specifies the number of teams to use by teams region -* OMP_NUM_THREADS:: Specifies the number of threads to use -* OMP_PROC_BIND:: Whether threads may be moved between CPUs -* OMP_PLACES:: Specifies on which CPUs the threads should be placed -* OMP_STACKSIZE:: Set default thread stack size -* OMP_SCHEDULE:: How threads are scheduled -* OMP_TARGET_OFFLOAD:: Controls offloading behavior -* OMP_TEAMS_THREAD_LIMIT:: Set the maximum number of threads imposed by teams -* OMP_THREAD_LIMIT:: Set the maximum number of threads -* OMP_WAIT_POLICY:: How waiting threads are handled -* GOMP_CPU_AFFINITY:: Bind threads to specific CPUs -* GOMP_DEBUG:: Enable debugging output -* GOMP_RUNTIME_USM:: Control runtime Unified Shared Memory application -* GOMP_STACKSIZE:: Set default thread stack size -* GOMP_SPINCOUNT:: Set the busy-wait spin count -* GOMP_RTEMS_THREAD_POOLS:: Set the RTEMS specific thread pools +* OMP_ALLOCATOR:: Set the default allocator +* OMP_AFFINITY_FORMAT:: Set the format string used for affinity display +* OMP_CANCELLATION:: Set whether cancellation is activated +* OMP_DISPLAY_AFFINITY:: Display thread affinity information +* OMP_DISPLAY_ENV:: Show OpenMP version and environment variables +* OMP_DEFAULT_DEVICE:: Set the device used in target regions +* OMP_DYNAMIC:: Dynamic adjustment of threads +* OMP_MAX_ACTIVE_LEVELS:: Set the maximum number of nested parallel regions +* OMP_MAX_TASK_PRIORITY:: Set the maximum task priority value +* OMP_NESTED:: Nested parallel regions +* OMP_NUM_TEAMS:: Specifies the number of teams to use by teams region +* OMP_NUM_THREADS:: Specifies the number of threads to use +* OMP_PROC_BIND:: Whether threads may be moved between CPUs +* OMP_PLACES:: Specifies on which CPUs the threads should be placed +* OMP_STACKSIZE:: Set default thread stack size +* OMP_SCHEDULE:: How threads are scheduled +* OMP_TARGET_OFFLOAD:: Controls offloading behavior +* OMP_TEAMS_THREAD_LIMIT:: Set the maximum number of threads imposed by teams +* OMP_THREAD_LIMIT:: Set the maximum number of threads +* OMP_WAIT_POLICY:: How waiting threads are handled +* GOMP_BARRIER_TYPE:: Choose barrier algorithm +* GOMP_FORKJOIN_BARRIER_TYPE:: Choose parallel region implicit barrier algorithm +* GOMP_CPU_AFFINITY:: Bind threads to specific CPUs +* GOMP_DEBUG:: Enable debugging output +* GOMP_RUNTIME_USM:: Control runtime Unified Shared Memory application +* GOMP_STACKSIZE:: Set default thread stack size +* GOMP_SPINCOUNT:: Set the busy-wait spin count +* GOMP_RTEMS_THREAD_POOLS:: Set the RTEMS specific thread pools @end menu @@ -5228,6 +5230,59 @@ before waiting passively. +@node GOMP_BARRIER_TYPE +@section @env{GOMP_BARRIER_TYPE} -- Choose barrier algorithm +@cindex Environment Variable +@cindex Implementation specific setting +@table @asis +@item @emph{Description}: +Choose barrier algorithm. +This variable should be set to one of @code{flat}, @code{tree}, +@code{centralized}, or @code{auto}. This choice is only effective on targets +which have the @code{futex_waitv} syscall. As a rule of thumb, @code{flat} and +@code{tree} are faster when @env{GOMP_SPINCOUNT} is high enough that no thread +waits passively for some variable to change while @code{centralized} is faster +when some threads do wait passively. Accordingly @code{auto} chooses between +@code{flat} and @code{centralized} based on the spin count. However the +microarchitecture of the base CPU and the work a user's program is running both +matter so this is not a hard rule. + +If this is set and @env{GOMP_FORKJOIN_BARRIER_TYPE} is not set, then +@env{GOMP_FORKJOIN_BARRIER_TYPE} takes its value from this. + +@item @emph{See also}: +@ref{OMP_WAIT_POLICY}, @ref{GOMP_SPINCOUNT}, @ref{GOMP_FORKJOIN_BARRIER_TYPE} +@end table + + + +@node GOMP_FORKJOIN_BARRIER_TYPE +@section @env{GOMP_FORKJOIN_BARRIER_TYPE} -- Choose parallel region implicit barrier algorithm +@cindex Environment Variable +@cindex Implementation specific setting +@table @asis +@item @emph{Description}: +Choose barrier algorithm for the implicit barrier at the end/start of +parallel regions. This variable should be set to one of @code{flat}, +@code{tree}, @code{centralized}, or @code{auto}. This choice is only effective +on targets which have the @code{futex_waitv} syscall. As a rule of thumb, +@code{flat} and @code{tree} are faster when @env{GOMP_SPINCOUNT} is high +enough that no thread waits passively for some variable to change @emph{or} +when there are no tasks executed at this barrier. @code{centralized} is faster +when neither of these constraints holds. Accordingly @code{auto} chooses +between @code{tree} and @code{flat} based on spin count. However the +microarchitecture of the host CPU and the work a user's program is running both +matter so this is not a hard rule. + +If this is not set and @env{GOMP_BARRIER_TYPE} is set, then +@env{GOMP_FORKJOIN_BARRIER_TYPE} takes its value from @env{GOMP_BARRIER_TYPE}. + +@item @emph{See also}: +@ref{OMP_WAIT_POLICY}, @ref{GOMP_SPINCOUNT}, @ref{GOMP_BARRIER_TYPE} +@end table + + + @node GOMP_CPU_AFFINITY @section @env{GOMP_CPU_AFFINITY} -- Bind threads to specific CPUs @cindex Environment Variable diff --git a/libgomp/single.c b/libgomp/single.c index 00a84e1c9c1..cfafe55aa67 100644 --- a/libgomp/single.c +++ b/libgomp/single.c @@ -108,7 +108,7 @@ GOMP_single_copy_start (void) } else { - gomp_team_barrier_wait (&thr->ts.team->barrier); + gomp_team_barrier_wait (&thr->ts.team->barrier, thr->ts.team_id); ret = thr->ts.work_share->copyprivate; gomp_work_share_end_nowait (); @@ -129,7 +129,7 @@ GOMP_single_copy_end (void *data) if (team != NULL) { thr->ts.work_share->copyprivate = data; - gomp_team_barrier_wait (&team->barrier); + gomp_team_barrier_wait (&team->barrier, thr->ts.team_id); } gomp_work_share_end_nowait (); diff --git a/libgomp/task.c b/libgomp/task.c index 89dafb87220..9ff300d576a 100644 --- a/libgomp/task.c +++ b/libgomp/task.c @@ -1570,10 +1570,39 @@ gomp_task_run_post_remove_taskgroup (struct gomp_task *child_task) } void -gomp_barrier_handle_tasks (gomp_barrier_state_t state) +gomp_barrier_handle_tasks (gomp_barrier_state_t state, gomp_barrier_t *bar, + unsigned increment) { struct gomp_thread *thr = gomp_thread (); - struct gomp_team *team = thr->ts.team; + /* acquire-release between the store in `gomp_team_start` because otherwise + very small chance that the `team->barrier` we just read is seen as + uninitialised (despite happening before the assignment of `nthr->ts.team` + in the primary thread) and that uninitialised value happens to match + `bar`. */ + struct gomp_team *team = __atomic_load_n (&thr->ts.team, MEMMODEL_ACQUIRE); + /* When performing the barrier in between iterations of non-nested threads in + `gomp_thread_start`, there's the race condition where: + - Secondary thread calls this function. + - Some other thread finishes the last task. + - Barrier is marked as completed. + - Primary thread continues to starting a new parallel region. + - Primary thread creates a new team. + - Primary thread stores the team on this secondary threads TLS storage + (before we read the `thr->ts.team` value above. + We pass `bar` in from the barrier functions in order to identify this + case. When this happens we know that all tasks on the barrier have + completed (otherwise the primary thread would not have continued past the + barrier). Hence we can simply return. + + This race condition was mostly harmless (attempt to run tasks on the + barrier of this new team, but new team would have no tasks on it anyway). + With the switch to only have one barrier per iteration in + `gomp_thread_start` we add the possibility that we could perform tasks on + "the next" parallel region (no longer a second synch point between the + above race condition and where new tasks could be scheduled). This + outcome is something we want to avoid. */ + if (&team->barrier != bar) + return; struct gomp_task *task = thr->task; struct gomp_task *child_task = NULL; struct gomp_task *to_free = NULL; @@ -1591,7 +1620,7 @@ gomp_barrier_handle_tasks (gomp_barrier_state_t state) When `task_count == 0` we're not going to perform tasks anyway, so the problem of PR122314 is naturally avoided. */ if (team->task_count != 0 - && gomp_barrier_has_completed (state, &team->barrier)) + && gomp_barrier_has_completed (state, &team->barrier, increment)) { gomp_mutex_unlock (&team->task_lock); return; @@ -1601,9 +1630,10 @@ gomp_barrier_handle_tasks (gomp_barrier_state_t state) { if (team->task_count == 0) { - gomp_team_barrier_done (&team->barrier, state); + gomp_team_barrier_done (&team->barrier, state, increment); gomp_mutex_unlock (&team->task_lock); - gomp_team_barrier_wake (&team->barrier, 0); + if (gomp_team_barrier_wake_on_increment (increment)) + gomp_team_barrier_wake (&team->barrier, 0); return; } gomp_team_barrier_set_waiting_for_tasks (&team->barrier); @@ -1638,7 +1668,7 @@ gomp_barrier_handle_tasks (gomp_barrier_state_t state) else if (team->task_count == 0 && gomp_team_barrier_waiting_for_tasks (&team->barrier)) { - gomp_team_barrier_done (&team->barrier, state); + gomp_team_barrier_done (&team->barrier, state, increment); gomp_mutex_unlock (&team->task_lock); gomp_team_barrier_wake (&team->barrier, 0); if (to_free) @@ -2264,7 +2294,7 @@ GOMP_taskgroup_end (void) is #pragma omp target nowait that creates an implicit team with a single thread. In this case, we want to wait for all outstanding tasks in this team. */ - gomp_team_barrier_wait (&team->barrier); + gomp_team_barrier_wait (&team->barrier, thr->ts.team_id); return; } @@ -2719,7 +2749,7 @@ GOMP_workshare_task_reduction_unregister (bool cancelled) htab_free ((struct htab *) data[5]); if (!cancelled) - gomp_team_barrier_wait (&team->barrier); + gomp_team_barrier_wait (&team->barrier, thr->ts.team_id); } int diff --git a/libgomp/team.c b/libgomp/team.c index 5282a3133ba..c4b5af466d2 100644 --- a/libgomp/team.c +++ b/libgomp/team.c @@ -31,6 +31,24 @@ #include #include +static void +gomp_release_held_threads (struct gomp_thread_pool *pool, + struct gomp_team *team, unsigned team_id) +{ + gomp_assert (team_id == 0, "releasing threads from non-primary thread %u", + team_id); + if (pool->prev_barrier) + { + struct gomp_team *saved_team __attribute__ ((unused)) + = pool->last_team ? pool->last_team : team; + gomp_assert (pool->prev_barrier == &saved_team->barrier, + "prev_barrier not within cached team: %p != %p", + pool->prev_barrier, &saved_team->barrier); + gomp_team_barrier_done_final (pool->prev_barrier, team_id); + pool->prev_barrier = NULL; + } +} + #ifdef LIBGOMP_USE_PTHREADS pthread_attr_t gomp_thread_attr; @@ -62,7 +80,6 @@ struct gomp_thread_start_data pthread_t handle; }; - /* This function is a pthread_create entry point. This contains the idle loop in which a thread waits to be called up to become part of a team. */ @@ -109,12 +126,12 @@ gomp_thread_start (void *xdata) struct gomp_team *team = thr->ts.team; struct gomp_task *task = thr->task; - gomp_barrier_wait (&team->barrier); + gomp_barrier_wait (&team->barrier, thr->ts.team_id); local_fn (local_data); - gomp_team_barrier_wait_final (&team->barrier); + gomp_team_barrier_wait_final (&team->barrier, thr->ts.team_id); gomp_finish_task (task); - gomp_barrier_wait_last (&team->barrier); + gomp_barrier_wait_last (&team->barrier, thr->ts.team_id); } else { @@ -127,10 +144,19 @@ gomp_thread_start (void *xdata) struct gomp_task *task = thr->task; local_fn (local_data); - gomp_team_barrier_wait_final (&team->barrier); + gomp_team_barrier_wait_final (&team->barrier, thr->ts.team_id); gomp_finish_task (task); - - gomp_simple_barrier_wait (&pool->threads_dock); + /* Hold at the simple barrier if we're exiting. + Do this in order to synchronise with the primary thread that could + (after the next piece of work has been performed) free our team. + Need to ensure that the barrier waited on above is not freed until + we've completed it. With any threads that will be used in the + next iteration we know that it will synchronise with the primary + thread before it frees this team because it will synchronise with + the primary thread in the next iteration of this loop (in + `gomp_team_barrier_wait_final`). */ + if (!gomp_barrier_can_hold (&team->barrier) || thr->fn == NULL) + gomp_simple_barrier_wait (&pool->threads_dock); local_fn = thr->fn; local_data = thr->data; @@ -153,13 +179,20 @@ get_last_team (unsigned nthreads) struct gomp_thread *thr = gomp_thread (); if (thr->ts.team == NULL) { + gomp_assert (thr->ts.level == 0, + "looking for cached team in nested region %u thr->ts.level", + thr->ts.level); struct gomp_thread_pool *pool = gomp_get_thread_pool (thr, nthreads); struct gomp_team *last_team = pool->last_team; if (last_team != NULL && last_team->nthreads == nthreads) { - pool->last_team = NULL; - return last_team; - } + gomp_assert (!pool->prev_barrier + || pool->prev_barrier == &pool->last_team->barrier, + "prev_barrier not within cached team: %p != %p", + pool->prev_barrier, &pool->last_team->barrier); + pool->last_team = NULL; + return last_team; + } } return NULL; } @@ -175,19 +208,44 @@ gomp_new_team (unsigned nthreads) team = get_last_team (nthreads); if (team == NULL) { + void *barrier_extra; + struct gomp_barrier_extra_alloc_needs barrier_extra_alloc + = gomp_barrier_extra_alloc (nthreads); size_t extra = sizeof (team->ordered_release[0]) + sizeof (team->implicit_task[0]); + size_t team_extra = nthreads * extra; + size_t barrier_padding = 0; + if (barrier_extra_alloc.size) + { + /* `offsetof` in case the structure is padded and `implicit_task` is + not at the end of `sizeof (*team)`. */ + size_t barrier_offset + = offsetof (struct gomp_team, implicit_task) + team_extra; + gomp_assert (barrier_extra_alloc.align + <= __alignof (struct gomp_team), + "barrier extra alignment too large: %lu > %lu", + (unsigned long) barrier_extra_alloc.align, + (unsigned long) __alignof (struct gomp_team)); + barrier_padding = ((barrier_offset + barrier_extra_alloc.align - 1) + & ~(barrier_extra_alloc.align - 1)) + - barrier_offset; + } + size_t alloc_extra + = team_extra + barrier_padding + barrier_extra_alloc.size; #ifdef GOMP_USE_ALIGNED_WORK_SHARES team = gomp_aligned_alloc (__alignof (struct gomp_team), - sizeof (*team) + nthreads * extra); + sizeof (*team) + alloc_extra); #else - team = team_malloc (sizeof (*team) + nthreads * extra); + team = team_malloc (sizeof (*team) + alloc_extra); #endif #ifndef HAVE_SYNC_BUILTINS gomp_mutex_init (&team->work_share_list_free_lock); #endif - gomp_barrier_init (&team->barrier, nthreads); + barrier_extra = (char *) &team->implicit_task[nthreads] + + nthreads * sizeof (team->ordered_release[0]) + + barrier_padding; + gomp_barrier_init (&team->barrier, nthreads, barrier_extra); gomp_mutex_init (&team->task_lock); team->nthreads = nthreads; @@ -278,9 +336,11 @@ gomp_free_thread (void *arg __attribute__((unused))) nthr->data = pool; } /* This barrier undocks threads docked on pool->threads_dock. */ - gomp_simple_barrier_wait (&pool->threads_dock); - /* And this waits till all threads have called gomp_barrier_wait_last - in gomp_free_pool_helper. */ + gomp_release_held_threads (pool, NULL, thr->ts.team_id); + if (!gomp_barrier_can_hold (pool->prev_barrier)) + gomp_simple_barrier_wait (&pool->threads_dock); + /* And this waits till all threads have called + gomp_simple_barrier_wait_last in gomp_free_pool_helper. */ gomp_simple_barrier_wait (&pool->threads_dock); /* Now it is safe to destroy the barrier and free the pool. */ gomp_simple_barrier_destroy (&pool->threads_dock); @@ -315,6 +375,21 @@ gomp_free_thread (void *arg __attribute__((unused))) /* Launch a team. */ #ifdef LIBGOMP_USE_PTHREADS +static unsigned +gomp_barrier_calc_wait (unsigned num_new_threads, unsigned num_exiting_threads, + unsigned old_threads_used, unsigned nthreads, + unsigned affinity_count, bool can_hold) +{ + if (can_hold) + { + unsigned tmp = num_new_threads + num_exiting_threads; + return tmp ? tmp + 1 : 0; + } + if (!affinity_count) + return old_threads_used > nthreads ? old_threads_used : nthreads; + return nthreads + affinity_count; +} + void gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, unsigned flags, struct gomp_team *team, @@ -327,6 +402,10 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, bool nested; struct gomp_thread_pool *pool; unsigned i, n, old_threads_used = 0; + unsigned simple_barrier_n = 0; + unsigned num_new_threads = 0; + unsigned spawned_new_threads __attribute__ ((unused)) = 0; + unsigned num_exiting_threads = 0; pthread_attr_t thread_attr, *attr; unsigned long nthreads_var; char bind, bind_var; @@ -464,22 +543,61 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, only the initial program thread will modify gomp_threads. */ if (!nested) { + gomp_assert (team->prev_ts.team_id == 0, + "starting a team from thread with id %u in previous team\n", + team->prev_ts.team_id); old_threads_used = pool->threads_used; - if (nthreads <= old_threads_used) - n = nthreads; + if (nthreads == old_threads_used) + { + n = nthreads; + num_new_threads = 0; + num_exiting_threads = 0; + simple_barrier_n + = gomp_barrier_calc_wait (num_new_threads, num_exiting_threads, + old_threads_used, nthreads, + affinity_count, + gomp_barrier_can_hold ( + pool->prev_barrier)); + if (gomp_barrier_can_hold (pool->prev_barrier)) + gomp_simple_barrier_reinit (&pool->threads_dock, simple_barrier_n); + } + else if (nthreads < old_threads_used) + { + n = nthreads; + num_new_threads = 0; + num_exiting_threads = old_threads_used - nthreads; + simple_barrier_n + = gomp_barrier_calc_wait (num_new_threads, num_exiting_threads, + old_threads_used, nthreads, + affinity_count, + gomp_barrier_can_hold ( + pool->prev_barrier)); + if (gomp_barrier_can_hold (pool->prev_barrier)) + gomp_simple_barrier_reinit (&pool->threads_dock, simple_barrier_n); + } else if (old_threads_used == 0) { n = 0; + num_new_threads = nthreads - 1; + num_exiting_threads = 0; + simple_barrier_n = nthreads; gomp_simple_barrier_init (&pool->threads_dock, nthreads); } else { n = old_threads_used; - + num_new_threads = nthreads - old_threads_used; + num_exiting_threads = 0; + simple_barrier_n + = gomp_barrier_calc_wait (num_new_threads, num_exiting_threads, + old_threads_used, nthreads, + affinity_count, + gomp_barrier_can_hold ( + pool->prev_barrier)); /* Increase the barrier threshold to make sure all new threads arrive before the team is released. */ - gomp_simple_barrier_reinit (&pool->threads_dock, nthreads); + gomp_simple_barrier_reinit (&pool->threads_dock, simple_barrier_n); } /* Not true yet, but soon will be. We're going to release all @@ -640,7 +758,7 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, } else nthr = pool->threads[i]; - nthr->ts.team = team; + __atomic_store_n (&nthr->ts.team, team, MEMMODEL_RELEASE); nthr->ts.work_share = &team->work_shares[0]; nthr->ts.last_work_share = NULL; nthr->ts.team_id = i; @@ -719,14 +837,68 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, threads and all the threads we're going to let die arrive before the team is released. */ if (affinity_count) - gomp_simple_barrier_reinit (&pool->threads_dock, - nthreads + affinity_count); + { + /* Total number of threads running is: + nthreads + affinity_count + Equation to be satisfied is: + (nthreads + affinity_count == + old_threads_used + num_new_threads). + So num_new_threads + == (nthreads + affinity_count - old_threads_used) + Originally + num_new_threads == nthreads > old_threads_used + ? (nthreads - old_threads_used) + : 0; + + Now: + nthreads + num_exiting_threads + == old_threads_used + num_new_threads + So: + num_exiting_threads + == old_threads_used + num_new_threads - nthreads + == affinity_count + */ + gomp_assert (nthreads + affinity_count > old_threads_used, + "not spawning more threads but " + "reinitialising barrier " + "nthreads = %u" + ", affinity_count = %u" + ", old_threads_used = %u", + nthreads, affinity_count, old_threads_used); + num_new_threads + = (nthreads + affinity_count) - old_threads_used; + num_exiting_threads = affinity_count; + simple_barrier_n + = gomp_barrier_calc_wait (num_new_threads, + num_exiting_threads, + old_threads_used, nthreads, + affinity_count, + gomp_barrier_can_hold ( + pool->prev_barrier)); + gomp_simple_barrier_reinit (&pool->threads_dock, + simple_barrier_n); + } } } if (i == nthreads) - goto do_release; - + { + gomp_assert (num_new_threads == 0, + "calculated need %u new threads but spawning none", + num_new_threads); + gomp_assert (gomp_barrier_can_hold (pool->prev_barrier) + ? (simple_barrier_n + == (num_exiting_threads ? num_exiting_threads + 1 + : 0)) + : simple_barrier_n == old_threads_used, + "have calculated need simple_barrier_n == %u" + " starting 0 threads, affinity_count == %u, " + "old_threads_used == %u, calculated " + "num_exiting_threads == %u, nthreads == %u", + simple_barrier_n, affinity_count, old_threads_used, + num_exiting_threads, nthreads); + goto do_release; + } } if (__builtin_expect (nthreads + affinity_count > old_threads_used, 0)) @@ -858,19 +1030,49 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, attr = gomp_adjust_thread_attr (attr, &thread_attr); err = pthread_create (&start_data->handle, attr, gomp_thread_start, start_data); + spawned_new_threads += 1; start_data++; if (err != 0) gomp_fatal ("Thread creation failed: %s", strerror (err)); } + if (!nested) + { + gomp_assert (spawned_new_threads == num_new_threads, + "calculated num_new_threads != spawned_new_threads: " + " %u != %u", + num_new_threads, spawned_new_threads); + bool calc_check __attribute__ ((unused)) = false; + if (old_threads_used == 0) + calc_check = (num_new_threads == (simple_barrier_n - 1)); + else if (gomp_barrier_can_hold (pool->prev_barrier)) + calc_check + = ((num_new_threads + num_exiting_threads) == (simple_barrier_n - 1)); + else + calc_check = (num_new_threads == (simple_barrier_n - old_threads_used)); + gomp_assert (calc_check, + "simple barrier calculation incorrect for %s team: " + "simple_barrier_n: %u" + ", nthreads: %u" + ", num_new_threads: %u" + ", num_exiting_threads: %u" + ", old_threads_used: %u", + nested ? "nested" : "top-level", simple_barrier_n, nthreads, + num_new_threads, num_exiting_threads, old_threads_used); + } if (__builtin_expect (attr == &thread_attr, 0)) pthread_attr_destroy (&thread_attr); do_release: if (nested) - gomp_barrier_wait (&team->barrier); + gomp_barrier_wait (&team->barrier, thr->ts.team_id); else - gomp_simple_barrier_wait (&pool->threads_dock); + { + gomp_release_held_threads (pool, team, thr->ts.team_id); + if (num_new_threads || num_exiting_threads + || !gomp_barrier_can_hold (pool->prev_barrier)) + gomp_simple_barrier_wait (&pool->threads_dock); + } /* Decrease the barrier threshold to match the number of threads that should arrive back at the end of this team. The extra @@ -898,6 +1100,14 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, gomp_mutex_unlock (&gomp_managed_threads_lock); #endif } + else if (!nested && gomp_barrier_can_hold (pool->prev_barrier)) + { + /* Need to adjust the simple barrier threshold once it's been used in + order to account for all threads that would need to be waited on in + something like `gomp_free_thread` or `gomp_pause_thread`. */ + gomp_simple_barrier_reinit (&pool->threads_dock, nthreads); + } + if (__builtin_expect (gomp_display_affinity_var, 0)) { if (nested @@ -949,12 +1159,15 @@ gomp_team_end (void) { struct gomp_thread *thr = gomp_thread (); struct gomp_team *team = thr->ts.team; + unsigned team_id = thr->ts.team_id; /* This barrier handles all pending explicit threads. As #pragma omp cancel parallel might get awaited count in team->barrier in a inconsistent state, we need to use a different counter here. */ - gomp_team_barrier_wait_final (&team->barrier); + gomp_team_barrier_wait_final (&team->barrier, team_id); + /* After this point all tasking has finished. Just haven't told all + secondary threads that they're good to continue. */ if (__builtin_expect (team->team_cancelled, 0)) { struct gomp_work_share *ws = team->work_shares_to_free; @@ -974,8 +1187,11 @@ gomp_team_end (void) gomp_end_task (); thr->ts = team->prev_ts; + bool finished_threads __attribute__ ((unused)) = false; if (__builtin_expect (thr->ts.level != 0, 0)) { + gomp_team_barrier_done_final (&team->barrier, team_id); + finished_threads = true; #ifdef HAVE_SYNC_BUILTINS __sync_fetch_and_add (&gomp_managed_threads, 1L - team->nthreads); #else @@ -985,7 +1201,7 @@ gomp_team_end (void) #endif /* This barrier has gomp_barrier_wait_last counterparts and ensures the team can be safely destroyed. */ - gomp_barrier_wait (&team->barrier); + gomp_barrier_wait (&team->barrier, team_id); } if (__builtin_expect (team->work_shares[0].next_alloc != NULL, 0)) @@ -1001,16 +1217,45 @@ gomp_team_end (void) } gomp_sem_destroy (&team->master_release); - if (__builtin_expect (thr->ts.team != NULL, 0) + if (__builtin_expect (thr->ts.team != NULL + && (thr->ts.team->nthreads != 1 + || thr->ts.level != 0), + 0) || __builtin_expect (team->nthreads == 1, 0)) - free_team (team); + { + gomp_assert (finished_threads || team->nthreads == 1, + "freeing team while threads may be waiting on it." + " team = %p, level = %u", + team, thr->ts.level + 1); + free_team (team); + } else { struct gomp_thread_pool *pool = thr->thread_pool; if (pool->last_team) free_team (pool->last_team); pool->last_team = team; - gomp_release_thread_pool (pool); + gomp_assert (!finished_threads, + "have let threads go while still recording prev_barrier" + " level = %u, team = %p, nthreads = %u", + thr->ts.level + 1, team, team->nthreads); + gomp_assert (!pool->prev_barrier, + "previous barrier not released before it gets overridden" + " level = %u, team = %p, nthreads = %u", + thr->ts.level + 1, team, team->nthreads); + /* Only record `prev_barrier` when `gomp_barrier_can_hold`: + - It's only used when gomp_barrier_can_hold. + - Some targets have custom versions of `gomp_team_start` that doesn't + call `gomp_release_held_threads` and hence don't clear this value. + */ + if (gomp_barrier_can_hold (&team->barrier)) + pool->prev_barrier = &team->barrier; + /* Releasing pool should only happen if we're going to then + `gomp_get_thread_pool` later. When `thr->ts.team != NULL` we don't + fetch the last team and call `gomp_get_thread_pool`. Hence we don't + want to release the pool here. */ + if (thr->ts.team == NULL) + gomp_release_thread_pool (pool); } } @@ -1081,9 +1326,11 @@ gomp_pause_host (void) thrs[i] = gomp_thread_to_pthread_t (nthr); } /* This barrier undocks threads docked on pool->threads_dock. */ - gomp_simple_barrier_wait (&pool->threads_dock); - /* And this waits till all threads have called gomp_barrier_wait_last - in gomp_pause_pool_helper. */ + gomp_release_held_threads (pool, NULL, thr->ts.team_id); + if (!gomp_barrier_can_hold (pool->prev_barrier)) + gomp_simple_barrier_wait (&pool->threads_dock); + /* And this waits till all threads have called + gomp_simple_barrier_wait_last in gomp_pause_pool_helper. */ gomp_simple_barrier_wait (&pool->threads_dock); /* Now it is safe to destroy the barrier and free the pool. */ gomp_simple_barrier_destroy (&pool->threads_dock); diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp index 93e2a681cb4..4987400f2a0 100644 --- a/libgomp/testsuite/lib/libgomp.exp +++ b/libgomp/testsuite/lib/libgomp.exp @@ -389,6 +389,12 @@ proc check_effective_target_nonstandard_math_functions { } { } "-lm" ] } +proc check_effective_target_linux_futex_waitv { } { + global libgomp_config_path + return [expr { + [lsearch -exact $libgomp_config_path "linux/futex_waitv"] >= 0}] +} + # Return 1 if compiling for the specified offload target # Takes -foffload=... into account by checking OFFLOAD_TARGET_NAMES= # in the -v compiler output. @@ -453,7 +459,7 @@ proc check_effective_target_offload_device_nonshared_as { } { } } ] } - + # Return 1 if offload device is available and it has shared address space. proc check_effective_target_offload_device_shared_as { } { return [check_runtime_nocache offload_device_shared_as { diff --git a/libgomp/testsuite/libgomp-site-extra.exp.in b/libgomp/testsuite/libgomp-site-extra.exp.in index 8de14f48976..ba576251c63 100644 --- a/libgomp/testsuite/libgomp-site-extra.exp.in +++ b/libgomp/testsuite/libgomp-site-extra.exp.in @@ -1,2 +1,3 @@ set FLOCK {@FLOCK@} set SYSROOT_CFLAGS_FOR_TARGET {@SYSROOT_CFLAGS_FOR_TARGET@} +set libgomp_config_path {@config_path@} diff --git a/libgomp/testsuite/libgomp.c++/task-reduction-20.C b/libgomp/testsuite/libgomp.c++/task-reduction-20.C new file mode 100644 index 00000000000..161b238578a --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/task-reduction-20.C @@ -0,0 +1,136 @@ +extern "C" void abort (); + +struct S +{ + S (); + S (long long int, int); + ~S (); + static int cnt1, cnt2, cnt3; + long long int s; + int t; +}; + +int S::cnt1; +int S::cnt2; +int S::cnt3; + +S::S () +{ +#pragma omp atomic + cnt1++; +} + +S::S (long long int x, int y) : s (x), t (y) +{ +#pragma omp atomic update + ++cnt2; +} + +S::~S () +{ +#pragma omp atomic + cnt3 = cnt3 + 1; + if (t < 3 || t > 9 || (t & 1) == 0) + abort (); +} + +void +bar (S *p, S *o) +{ + p->s = 1; + if (o->t != 5) + abort (); + p->t = 9; +} + +static inline void +baz (S *o, S *i) +{ + if (o->t != 5 || i->t != 9) + abort (); + o->s *= i->s; +} + +#pragma omp declare reduction(+ : S : omp_out.s += omp_in.s) \ + initializer(omp_priv(0, 3)) +#pragma omp declare reduction(* : S : baz(&omp_out, &omp_in)) \ + initializer(bar(&omp_priv, &omp_orig)) + +S as = {0LL, 7}; +S &a = as; +S bs (1LL, 5); +S &b = bs; + +void +foo (S &c, S &d) +{ + int i; + for (i = 0; i < 2; i++) +#pragma omp task in_reduction(+ : c) in_reduction(* : b, d) in_reduction(+ : a) + { + a.s += 7; + b.s *= 2; + c.s += 9; + d.s *= 3; + if ((a.t != 7 && a.t != 3) || (b.t != 5 && b.t != 9) + || (c.t != 7 && c.t != 3) || (d.t != 5 && d.t != 9)) + abort (); + } +} + +void +test () +{ + S cs = {0LL, 7}; + S &c = cs; + S ds (1LL, 5); + S &d = ds; +#pragma omp parallel + { + asm volatile ("" ::: "memory"); + } +#pragma omp parallel reduction(task, + : a, c) reduction(task, * : b, d) + { +#pragma omp for + for (int i = 0; i < 4; i++) +#pragma omp task in_reduction(* : b, d) in_reduction(+ : a, c) + { + int j; + a.s += 7; + b.s *= 2; + for (j = 0; j < 2; j++) +#pragma omp task in_reduction(+ : a) in_reduction(* : b) in_reduction(+ : c) \ + in_reduction(* : d) + { + a.s += 7; + b.s *= 2; + c.s += 9; + d.s *= 3; + foo (c, d); + if ((a.t != 7 && a.t != 3) || (b.t != 5 && b.t != 9) + || (c.t != 7 && c.t != 3) || (d.t != 5 && d.t != 9)) + abort (); + } + c.s += 9; + d.s *= 3; + if ((a.t != 7 && a.t != 3) || (b.t != 5 && b.t != 9) + || (c.t != 7 && c.t != 3) || (d.t != 5 && d.t != 9)) + abort (); + } + } +#define THREEP7 (3LL * 3LL * 3LL * 3LL * 3LL * 3LL * 3LL) + if (d.s != (THREEP7 * THREEP7 * THREEP7 * THREEP7) || d.t != 5) + abort (); + if (a.s != 28 * 7 || a.t != 7 || b.s != (1L << 28) || b.t != 5 + || c.s != 28 * 9 || c.t != 7) + abort (); +} + +int +main () +{ + int c1 = S::cnt1, c2 = S::cnt2, c3 = S::cnt3; + test (); + if (S::cnt1 + S::cnt2 - c1 - c2 != S::cnt3 - c3) + abort (); +} diff --git a/libgomp/testsuite/libgomp.c++/task-reduction-21.C b/libgomp/testsuite/libgomp.c++/task-reduction-21.C new file mode 100644 index 00000000000..5a42add400a --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/task-reduction-21.C @@ -0,0 +1,140 @@ +extern "C" void abort (); + +struct S +{ + S (); + S (long long int, int); + ~S (); + static int cnt1, cnt2, cnt3; + long long int s; + int t; +}; + +int S::cnt1; +int S::cnt2; +int S::cnt3; + +S::S () +{ +#pragma omp atomic + cnt1++; +} + +S::S (long long int x, int y) : s (x), t (y) +{ +#pragma omp atomic update + ++cnt2; +} + +S::~S () +{ +#pragma omp atomic + cnt3 = cnt3 + 1; + if (t < 3 || t > 9 || (t & 1) == 0) + abort (); +} + +void +bar (S *p, S *o) +{ + p->s = 1; + if (o->t != 5) + abort (); + p->t = 9; +} + +static inline void +baz (S *o, S *i) +{ + if (o->t != 5 || i->t != 9) + abort (); + o->s *= i->s; +} + +#pragma omp declare reduction(+ : S : omp_out.s += omp_in.s) \ + initializer(omp_priv(0, 3)) +#pragma omp declare reduction(* : S : baz(&omp_out, &omp_in)) \ + initializer(bar(&omp_priv, &omp_orig)) + +S as = {0LL, 7}; +S &a = as; +S bs (1LL, 5); +S &b = bs; + +void +foo (S &c, S &d) +{ + int i; + for (i = 0; i < 2; i++) +#pragma omp task in_reduction(+ : c) in_reduction(* : b, d) in_reduction(+ : a) + { + a.s += 7; + b.s *= 2; + c.s += 9; + d.s *= 3; + if ((a.t != 7 && a.t != 3) || (b.t != 5 && b.t != 9) + || (c.t != 7 && c.t != 3) || (d.t != 5 && d.t != 9)) + abort (); + } +} + +void +test () +{ + S cs = {0LL, 7}; + S &c = cs; + S ds (1LL, 5); + S &d = ds; +#pragma omp parallel + { + for (int i = 0; i < 4; i++) +#pragma omp task + { + asm volatile ("" ::: "memory"); + } + } +#pragma omp parallel reduction(task, + : a, c) reduction(task, * : b, d) + { +#pragma omp for + for (int i = 0; i < 4; i++) +#pragma omp task in_reduction(* : b, d) in_reduction(+ : a, c) + { + int j; + a.s += 7; + b.s *= 2; + for (j = 0; j < 2; j++) +#pragma omp task in_reduction(+ : a) in_reduction(* : b) in_reduction(+ : c) \ + in_reduction(* : d) + { + a.s += 7; + b.s *= 2; + c.s += 9; + d.s *= 3; + foo (c, d); + if ((a.t != 7 && a.t != 3) || (b.t != 5 && b.t != 9) + || (c.t != 7 && c.t != 3) || (d.t != 5 && d.t != 9)) + abort (); + } + c.s += 9; + d.s *= 3; + if ((a.t != 7 && a.t != 3) || (b.t != 5 && b.t != 9) + || (c.t != 7 && c.t != 3) || (d.t != 5 && d.t != 9)) + abort (); + } + } +#define THREEP7 (3LL * 3LL * 3LL * 3LL * 3LL * 3LL * 3LL) + if (d.s != (THREEP7 * THREEP7 * THREEP7 * THREEP7) || d.t != 5) + abort (); + if (a.s != 28 * 7 || a.t != 7 || b.s != (1L << 28) || b.t != 5 + || c.s != 28 * 9 || c.t != 7) + abort (); +} + +int +main () +{ + int c1 = S::cnt1, c2 = S::cnt2, c3 = S::cnt3; + test (); + if (S::cnt1 + S::cnt2 - c1 - c2 != S::cnt3 - c3) + abort (); +} diff --git a/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-auto.c b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-auto.c new file mode 100644 index 00000000000..c84544e8a47 --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-auto.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ +/* { dg-set-target-env-var OMP_DISPLAY_ENV "verbose" } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "auto" } */ + +int +main (void) +{ + return 0; +} + +/* { dg-output ".*\\\[host] GOMP_BARRIER_TYPE = 'auto'.*\\\[host] GOMP_FORKJOIN_BARRIER_TYPE = 'auto'.*" { target native } } */ diff --git a/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-centralized-flat.c b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-centralized-flat.c new file mode 100644 index 00000000000..d83f9609742 --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-centralized-flat.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-set-target-env-var OMP_DISPLAY_ENV "verbose" } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "centralized" } */ +/* { dg-set-target-env-var GOMP_FORKJOIN_BARRIER_TYPE "flat" } */ + +int +main (void) +{ + return 0; +} + +/* { dg-output ".*\\\[host] GOMP_BARRIER_TYPE = 'centralized'.*\\\[host] GOMP_FORKJOIN_BARRIER_TYPE = 'flat'.*" { target native } } */ diff --git a/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-centralized-tree.c b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-centralized-tree.c new file mode 100644 index 00000000000..de42bd2f5ce --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-centralized-tree.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-set-target-env-var OMP_DISPLAY_ENV "verbose" } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "centralized" } */ +/* { dg-set-target-env-var GOMP_FORKJOIN_BARRIER_TYPE "tree" } */ + +int +main (void) +{ + return 0; +} + +/* { dg-output ".*\\\[host] GOMP_BARRIER_TYPE = 'centralized'.*\\\[host] GOMP_FORKJOIN_BARRIER_TYPE = 'tree'.*" { target native } } */ diff --git a/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-flat-centralized.c b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-flat-centralized.c new file mode 100644 index 00000000000..40749c6ea8e --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-flat-centralized.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-set-target-env-var OMP_DISPLAY_ENV "verbose" } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "flat" } */ +/* { dg-set-target-env-var GOMP_FORKJOIN_BARRIER_TYPE "centralized" } */ + +int +main (void) +{ + return 0; +} + +/* { dg-output ".*\\\[host] GOMP_BARRIER_TYPE = 'flat'.*\\\[host] GOMP_FORKJOIN_BARRIER_TYPE = 'centralized'.*" { target native } } */ diff --git a/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-flat.c b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-flat.c new file mode 100644 index 00000000000..52efbc5f2ad --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-flat.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ +/* { dg-set-target-env-var OMP_DISPLAY_ENV "verbose" } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "flat" } */ + +int +main (void) +{ + return 0; +} + +/* { dg-output ".*\\\[host] GOMP_BARRIER_TYPE = 'flat'.*\\\[host] GOMP_FORKJOIN_BARRIER_TYPE = 'flat'.*" { target native } } */ diff --git a/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-tree-centralized.c b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-tree-centralized.c new file mode 100644 index 00000000000..cdf26fb7282 --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-tree-centralized.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-set-target-env-var OMP_DISPLAY_ENV "verbose" } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "tree" } */ +/* { dg-set-target-env-var GOMP_FORKJOIN_BARRIER_TYPE "centralized" } */ + +int +main (void) +{ + return 0; +} + +/* { dg-output ".*\\\[host] GOMP_BARRIER_TYPE = 'tree'.*\\\[host] GOMP_FORKJOIN_BARRIER_TYPE = 'centralized'.*" { target native } } */ diff --git a/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-unset.c b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-unset.c new file mode 100644 index 00000000000..5b5ba7e9293 --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env-unset.c @@ -0,0 +1,10 @@ +/* { dg-do run } */ +/* { dg-set-target-env-var OMP_DISPLAY_ENV "verbose" } */ + +int +main (void) +{ + return 0; +} + +/* { dg-output ".*\\\[host] GOMP_BARRIER_TYPE = 'auto'.*\\\[host] GOMP_FORKJOIN_BARRIER_TYPE = 'auto'.*" { target native } } */ diff --git a/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env.c b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env.c new file mode 100644 index 00000000000..6e8ff706466 --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/gomp-barrier-type-env.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ +/* { dg-set-target-env-var OMP_DISPLAY_ENV "verbose" } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "tree" } */ + +int +main (void) +{ + return 0; +} + +/* { dg-output ".*\\\[host] GOMP_BARRIER_TYPE = 'tree'.*\\\[host] GOMP_FORKJOIN_BARRIER_TYPE = 'tree'.*" { target native } } */ diff --git a/libgomp/testsuite/libgomp.c/barrier-switch-1.c b/libgomp/testsuite/libgomp.c/barrier-switch-1.c new file mode 100644 index 00000000000..17ebb91a2a3 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/barrier-switch-1.c @@ -0,0 +1,135 @@ +/* Exercise changing between flat and centralized barriers for a live team. + N.b. there should be no observable difference between switching and not, but + having a testcase at least exercises the code path. */ +/* { dg-do run { target linux_futex_waitv } } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "auto" } */ +/* { dg-set-target-env-var GOMP_SPINCOUNT "100000000" } */ +/* { dg-set-target-env-var OMP_DYNAMIC "false" } */ +/* { dg-set-target-env-var OMP_MAX_ACTIVE_LEVELS "2" } */ + +#define _GNU_SOURCE 1 +#include +#include +#include +#include +#include +#include + +static _Atomic int start_helper; +static _Atomic int helper_active; +static _Atomic int stop_helper; +static _Atomic int helper_finished; + +static void +wait_for (const _Atomic int *flag) +{ + while (!atomic_load_explicit (flag, memory_order_acquire)) + sched_yield (); +} + +static void +barrier (void) +{ +#pragma omp barrier +} + +/* Restrict the process before libgomp is reinitialised so that + gomp_available_cpus is three. With the main nested team active there are + three managed threads. Starting the helper nested team increases that to + four, making spin_count switch to its throttled value. */ +static bool +restrict_to_three_cpus_and_reexec (void) +{ + if (getenv ("GOMP_BARRIER_SWITCH_REEXEC")) + return true; + + cpu_set_t available; + cpu_set_t selected; + if (sched_getaffinity (0, sizeof (available), &available) != 0) + return false; + + CPU_ZERO (&selected); + int count = 0; + for (int cpu = 0; cpu < CPU_SETSIZE && count != 3; ++cpu) + if (CPU_ISSET (cpu, &available)) + { + CPU_SET (cpu, &selected); + ++count; + } + if (count != 3 + || sched_setaffinity (0, sizeof (selected), &selected) != 0 + || setenv ("GOMP_BARRIER_SWITCH_REEXEC", "1", 1) != 0) + return false; + + execl ("/proc/self/exe", "barrier-switch-1", NULL); + abort (); +} + +int +main (void) +{ + if (!restrict_to_three_cpus_and_reexec ()) + return 0; + + omp_set_dynamic (0); + omp_set_max_active_levels (2); + +#pragma omp parallel num_threads(2) + { + if (omp_get_thread_num () == 0) + { + /* Keep this nested team alive while its sibling team changes the global + number of managed threads. */ +#pragma omp parallel num_threads(2) + { + /* Initially three managed threads run on three available CPUs. This + barrier is flat and selects flat for the next generation. */ + barrier (); + +#pragma omp masked + { + atomic_store_explicit (&start_helper, 1, memory_order_release); + wait_for (&helper_active); + } + + /* The current barrier is flat. Four managed threads are now running + on three available CPUs, so completion selects tree. */ + barrier (); + /* Exercise the selected tree barrier. */ + barrier (); + +#pragma omp masked + { + atomic_store_explicit (&stop_helper, 1, memory_order_release); + wait_for (&helper_finished); + } + + /* The current barrier is tree. The helper nested team has finished, + returning to three managed threads, so completion selects flat. */ + barrier (); + /* Exercise the selected flat barrier. */ + barrier (); + } + } + else + { + wait_for (&start_helper); + + /* This sibling nested team adds one managed thread until both members + leave the region. */ +#pragma omp parallel num_threads(2) + { +#pragma omp masked + atomic_store_explicit (&helper_active, 1, memory_order_release); + + wait_for (&stop_helper); + } + + /* Nested-team workers are removed from gomp_managed_threads before the + nested parallel construct returns. */ + atomic_store_explicit (&helper_finished, 1, memory_order_release); + } + } + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/barrier_generation_overflow.c b/libgomp/testsuite/libgomp.c/barrier_generation_overflow.c new file mode 100644 index 00000000000..1dc4b00e4c3 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/barrier_generation_overflow.c @@ -0,0 +1,88 @@ +/* We only run this for linux/futex_waitv targets because they have their + generation number wrap at a much lower value than other targets. The much + higher value of other targets takes a very long time to reach -- so much + that the default DejaGNU timeout treats it as a timeout anyway. */ +/* { dg-do run { target linux_futex_waitv } } */ +/* Including the numbers for both futex_waitv and non-futex_waitv targets even + though we only run on futex_waitv targets. Just for anyone reading this + file -- does not make any difference to how the testcase is ran. */ +/* { dg-additional-options "-DPREWRAP_BARRIERS=1048575" { target linux_futex_waitv } } */ +/* { dg-additional-options "-DPREWRAP_BARRIERS=536870911" { target { ! linux_futex_waitv } } } */ +#include +#include + +#define NTHREADS 2 +#define TASK_USLEEP 500000 + +/* This is the plain-barrier analogue of cancel_incr_wraparound.c. + The structure deliberately mirrors the 2-thread cancellable-generation + wraparound testcase: + + 1. A single long-lived 2-thread team executes 1,048,575 plain barriers + without any tasks. That advances the non-cancellable generation to the + highest value value it can hold before wraparound (0xfffff000). + 2. Thread 1 creates one deferred task and then falls moves on to the final + barrier. + 3. Thread 0 waits outside that final barrier until the deferred task has + actually started. In this testcase there are no other task scheduling + points between task creation and the final barrier, so knowing the task + has started implies that thread 1 has entered the plain barrier wait + path. + 4. Thread 0 then enters the 1,048,576th plain barrier use while the task is + still running, so the wrap-sensitive raw-BAR_WAS_LAST completion check is + exercised with task_count != 0. + + On this Linux backend BAR_INCR = 4096, so the plain generation wraps after + 2^32 / 4096 = 1,048,576 uses of the same plain barrier generation. */ + +static int secondary_task_started; + +static void +hold_barrier_task (void) +{ +#pragma omp atomic write + secondary_task_started = 1; + usleep (TASK_USLEEP); +} + +int +main (void) +{ + omp_set_dynamic (0); + secondary_task_started = 0; + +#pragma omp parallel num_threads(NTHREADS) shared(secondary_task_started) + { + int tid = omp_get_thread_num (); + + for (int round = 0; round < PREWRAP_BARRIERS; ++round) + { +#pragma omp barrier + } + + if (tid == 1) + { +#pragma omp task + hold_barrier_task (); + } + + if (tid == 0) + { + int seen = 0; + while (!seen) + { +#pragma omp atomic read + seen = secondary_task_started; + } + } + + /* Thread 1 has already entered the barrier and started the deferred task + above before thread 0 enters this wrap-sensitive 1,048,576th plain + barrier use. This means that we can force the check in + `gomp_barrier_has_completed` to be ran using a `state` which has + `BAR_WAS_LAST` set on it. */ +#pragma omp barrier + } + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/cancel_in_implicit_barrier.c b/libgomp/testsuite/libgomp.c/cancel_in_implicit_barrier.c new file mode 100644 index 00000000000..0d78382f4a4 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/cancel_in_implicit_barrier.c @@ -0,0 +1,115 @@ +/* + Test functionality of cancelling a region with no cancellation point. + I.e. this tests the `_final` barrier being able to handle cancellation + mid-way. + + N.b. this testcase was triggering an assertion during development of the + linux/futex_waitv target. It's here as a regression test, but the failure + mode is only really visible when testing a libgomp built with assertions. + The code should still work either way so it's not problematic to run each + time, but catching the performance problem that would be a real issue is not + very feasible. + While the problem was only seen in on that target I run the testcase on all + targets just for the sake of exercising code paths. + + For information's sake: the performance problem was that threads could + busy-wait when we judge they should have entering the kernel. They would do + this because the code assumed the `BAR_CANCELLED` flag would not change and + they checked the originally read generation against their most recently read + generation to see whether to continue spinning or sleep. + */ +/* { dg-do run } */ +/* { dg-set-target-env-var OMP_CANCELLATION "true" } */ + +#include +#include + +#define NUM_THREADS 4 +#define NUM_TASKS 500 + +/* Each task does busy work to keep tasks pending at the barrier. */ +#define TASK_WORK 500000 + +static volatile int tasks_executed; +static volatile int tasks_total; + +/* Goal is to trigger `BAR_CANCELLED` getting set on the barrier generation + flag while many threads are already waiting on the `*_final` barrier at the + end of this parallel region. + + We have tasks running in order to ensure that the setting of `BAR_CANCELLED` + happens while secondary threads are in the tasking loop of + `gomp_team_barrier_wait_for_tasks`. */ +int +main (void) +{ + if (!omp_get_cancellation ()) + abort (); + omp_set_dynamic (0); + omp_set_num_threads (NUM_THREADS); + + for (int trial = 0; trial < 20; trial++) + { +#pragma omp atomic write + tasks_executed = 0; +#pragma omp atomic write + tasks_total = 0; + +#pragma omp parallel num_threads(NUM_THREADS) + { + int tid = omp_get_thread_num (); + +#pragma omp single nowait + { + for (int i = 0; i < NUM_TASKS; i++) + { +#pragma omp task + { + /* Busy work to keep the task running for ~1ms. + Gives the thread that hopes to cancel the barrier enough + time to observe that some tasks have executed and cancel the + barrier all tasks have been completed. */ + volatile int y = 0; + for (int j = 0; j < TASK_WORK; j++) + y++; +#pragma omp atomic update + tasks_executed += 1; + } + } + } + + if (tid == 0) + { + /* Wait for some tasks to get executed. As soon as there is at + least one task getting executed cancel the barrier. This should + hopefully cancel the barrier before all tasks have been + completed (and observation shows this to be the case). I.e. + ensures that other threads are in the relevant task handling loop + when the barrier is cancelled. */ + int executed; +#pragma omp atomic read + executed = tasks_executed; + while (executed == 0) + { +#pragma omp atomic read + executed = tasks_executed; + }; +#pragma omp cancel parallel + } + } + + int n_exec; +#pragma omp atomic read + n_exec = tasks_executed; + /* If you're seeing an abort here then it is not a sign that libgomp is + failing. Rather it is a sign that the timings in this testsuite do + not match your machine. I.e. your machine completed the tasks too + fast for this testcase to be stressing anything. + + That means this testcase may need to be updated, and without this + abort we would not notice. */ + if (n_exec == NUM_TASKS) + abort (); + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/cancel_in_implicit_barrier_while_primary_waiting.c b/libgomp/testsuite/libgomp.c/cancel_in_implicit_barrier_while_primary_waiting.c new file mode 100644 index 00000000000..ccfe3ab1055 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/cancel_in_implicit_barrier_while_primary_waiting.c @@ -0,0 +1,70 @@ +/* Test functionality of cancelling a region with no cancellable barrier. + On the `futex_waitv` target in this case the implicit barrier at the end of + the parallel region sees the BAR_CANCELLED flag and needs to be able to + handle it. + + While it needs to be able to handle it, it still needs to wait for all + threads, because this is not a cancellable barrier it is the implicit + non-cancellable barrier at the end of the parallel region. + + Still run the testcase on all targets for breadth of testing. */ +/* { dg-do run } */ +/* { dg-set-target-env-var OMP_CANCELLATION "true" } */ +#include +#include + +int +main (void) +{ + omp_set_dynamic (0); + + for (int round = 0; round < 200; ++round) + { + int phase = 0; + +#pragma omp parallel num_threads(8) + { + int tid = omp_get_thread_num (); + + if (tid == 0) + { + /* Primary goes straight through to barrier, and waits for other + threads to arrive. Publish that we are about to fall into the + final barrier so the non-primary coordination can start. */ +#pragma omp atomic write + phase = 1; + } + else if (tid == 1) + { + /* We need one non-primary thread to issue the cancel while the + primary is still waiting for secondaries to arrive. */ + while (1) + { + int seen; +#pragma omp atomic read + seen = phase; + if (seen >= 1) + break; + } +#pragma omp atomic write + phase = 2; +#pragma omp cancel parallel if (1) + } + else if (tid == 2) + { + /* Second non-primary thread holds the primary thread until the + region has been cancelled. */ + while (1) + { + int seen; +#pragma omp atomic read + seen = phase; + if (seen >= 2) + break; + } + } + } + } + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/cancel_incr_wraparound.c b/libgomp/testsuite/libgomp.c/cancel_incr_wraparound.c new file mode 100644 index 00000000000..b5687b75381 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/cancel_incr_wraparound.c @@ -0,0 +1,94 @@ +/* { dg-do run { target linux_futex_waitv } } */ +/* { dg-set-target-env-var OMP_CANCELLATION "true" } */ +/* Regression test for bug seen during development. + + This exercises the case where `gomp_barrier_handle_tasks` is called with a + `state` with non-zero flags and while the cancel generation bitfield is + about to wrap around. By doing this it exercises an edge case for + `gomp_barrier_incremented` where `state > gen` but `next < gen`. + + On the futex_waitv backend the cancellable generation uses BAR_CANCEL_INCR = + 16 and 8 dedicated bits, so the wrap-sensitive state can only be exhibited + after 256 uses of the same cancel-capable barrier generation. This test + has some pre-wrap rounds to get to the wrap-sensitive state before running + the edge case. */ + +#include +#include + +#define NTHREADS 2 +#define PREWRAP_ROUNDS 255 +#define TASK_USLEEP 200000 + +static volatile int inactive_cancel; +static int secondary_task_started; + +static inline void +cheap_work (int i) +{ + asm volatile ("" : : "r"(i) : "memory"); +} + +static void +hold_barrier_task (void) +{ +#pragma omp atomic write + secondary_task_started = 1; + usleep (TASK_USLEEP); +} + +static void +run_outer_round (void) +{ + inactive_cancel = 0; + secondary_task_started = 0; + +#pragma omp parallel num_threads(NTHREADS) shared(secondary_task_started) + { + int tid = omp_get_thread_num (); + + /* These 255 loop-end barriers, plus the explicit barrier below, give the + same cancel-capable barrier 256 uses on this 2-thread team. */ + for (int round = 0; round < PREWRAP_ROUNDS; ++round) + { +#pragma omp cancel parallel if (tid == 0 && inactive_cancel) +#pragma omp for schedule(static, 1) + for (int i = 0; i < NTHREADS; ++i) + cheap_work (i + round); + } + + if (tid == 1) + { +#pragma omp task + hold_barrier_task (); + } + +#pragma omp cancel parallel if (tid == 0 && inactive_cancel) + if (tid == 0) + { + int seen = 0; + while (!seen) + { +#pragma omp atomic read + seen = secondary_task_started; + } + } + + /* If we did everything right, thread 1 has already entered the + cancellable barrier wait path and started the deferred task above + before thread 0 enters this wrap-sensitive barrier use. That deferred + task should be long-running enough that the primary thread can go + through the initial part of the barrier and start attempting to perform + tasks before all tasks have been completed. */ +#pragma omp barrier + } +} + +int +main (void) +{ + omp_set_dynamic (0); + omp_set_schedule (omp_sched_static, 1); + run_outer_round (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/futex_waitv_overflow.c b/libgomp/testsuite/libgomp.c/futex_waitv_overflow.c new file mode 100644 index 00000000000..ecfa4ed1fa3 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/futex_waitv_overflow.c @@ -0,0 +1,37 @@ +/* { dg-do run { target linux_futex_waitv } } */ +/* { dg-set-target-env-var GOMP_SPINCOUNT "0" } */ +/* { dg-set-target-env-var GOMP_BARRIER_TYPE "flat" } */ +/* Regression test for bug seen during development. + + This exercises the case where `futex_waitv` is passed values that set the + top bit of the futex word. A futex word is defined to be 32 bits. The + generation is an unsigned value. We delay all secondary threads before + reaching the barrier on the 524288'th time. This ensures the primary thread + enters the barrier, does not see any threads arriving, then sleeps in the + kernel on one of these threads arriving. */ +#include +#include +#include + +int +main () +{ + int warmup = 524287; + int delayed = 1; + int delay_us = 100000; + + omp_set_dynamic (0); + +#pragma omp parallel num_threads(4) + { + int tid = omp_get_thread_num (); + for (int round = 0; round < warmup + delayed; ++round) + { + if (round >= warmup && tid != 0) + usleep (delay_us); +#pragma omp barrier + } + } + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/primary-thread-tasking.c b/libgomp/testsuite/libgomp.c/primary-thread-tasking.c new file mode 100644 index 00000000000..e4d2efb857a --- /dev/null +++ b/libgomp/testsuite/libgomp.c/primary-thread-tasking.c @@ -0,0 +1,80 @@ +/* Test to check our primary thread can execute some tasks while waiting for + other threads. This to check an edge-case in a recent implementation of the + barrier tasking mechanism. + I don't believe there's any way to guarantee that a task will be run on a + given thread. Hence I don't know anywhere I can put an `abort` and say we + failed. However I can set things up so that we'll timeout if the primary + thread is not executing any tasks. That timeout will at least count as a + fail. + + Idea here being that we keep spawning tasks until one is handled by the + primary thread. Meanwhile we give the secondary threads lots of + opportunities to sleep and let the primary thread take a task. */ +/* { dg-do run { target *-*-linux* } } */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include + +int wake_flag = 0; + +void +continue_until_on_thread0 () +{ + if (omp_get_thread_num () == 0) + { + __atomic_fetch_add (&wake_flag, 1, memory_order_relaxed); + syscall (SYS_futex, &wake_flag, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, INT_MAX); + } + else + { + /* If the flag has been set try again. Otherwise put another few tasks + * on the task queue. */ + if (__atomic_load_n (&wake_flag, memory_order_relaxed)) + { + return; + } +#pragma omp task + continue_until_on_thread0 (); +#pragma omp task + continue_until_on_thread0 (); +#pragma omp task + continue_until_on_thread0 (); + syscall (SYS_futex, &wake_flag, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, NULL); + } +} + +void +foo () +{ +#pragma omp parallel + { + if (omp_get_thread_num () != 0) + { +#pragma omp task + continue_until_on_thread0 (); +#pragma omp task + continue_until_on_thread0 (); + /* Wait on the master thread to have executed one of the tasks. */ + int val = __atomic_load_n (&wake_flag, memory_order_acquire); + while (val == 0) + { + syscall (SYS_futex, &wake_flag, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, + val, NULL); + val = __atomic_load_n (&wake_flag, memory_order_acquire); + } + } + } +} + +int +main () +{ + foo (); + return 0; +} diff --git a/libgomp/work.c b/libgomp/work.c index 5f23232ce77..280fa242fd5 100644 --- a/libgomp/work.c +++ b/libgomp/work.c @@ -240,7 +240,7 @@ gomp_work_share_end (void) return; } - bstate = gomp_barrier_wait_start (&team->barrier); + bstate = gomp_barrier_wait_start (&team->barrier, thr->ts.team_id); if (gomp_barrier_last_thread (bstate)) { @@ -251,7 +251,7 @@ gomp_work_share_end (void) } } - gomp_team_barrier_wait_end (&team->barrier, bstate); + gomp_team_barrier_wait_end (&team->barrier, bstate, thr->ts.team_id); thr->ts.last_work_share = NULL; } @@ -266,7 +266,7 @@ gomp_work_share_end_cancel (void) gomp_barrier_state_t bstate; /* Cancellable work sharing constructs cannot be orphaned. */ - bstate = gomp_barrier_wait_cancel_start (&team->barrier); + bstate = gomp_barrier_wait_cancel_start (&team->barrier, thr->ts.team_id); if (gomp_barrier_last_thread (bstate)) { @@ -278,7 +278,8 @@ gomp_work_share_end_cancel (void) } thr->ts.last_work_share = NULL; - return gomp_team_barrier_wait_cancel_end (&team->barrier, bstate); + return gomp_team_barrier_wait_cancel_end (&team->barrier, bstate, + thr->ts.team_id); } /* The current thread is done with its current work sharing construct. -- 2.43.0 From jskumari@linux.ibm.com Mon Nov 2 16:32:49 2026 From: jskumari@linux.ibm.com (Surya Kumari Jangala) Date: Mon, 2 Nov 2026 22:02:49 +0530 Subject: [PATCH] rs6000: Fix _mm_movemask intrinsics on Power10BE [PR127274] In-Reply-To: <8c9b617c-d13a-439c-b115-e3e11f3efe4c@linux.ibm.com> References: <37110534-9d82-419a-851a-311579d1b227@linux.ibm.com> <8c9b617c-d13a-439c-b115-e3e11f3efe4c@linux.ibm.com> Message-ID: <6c250564-5b9c-4fd7-9dc6-f269215fc3b8@linux.ibm.com> On 02/11/26 4:36 PM, jeevitha wrote: > > > On 28/10/26 4:49 pm, Surya Kumari Jangala wrote: >> LGTM. Ok to upstream. >> >> -Surya > > Hi, > > This patch has been committed to trunk. Can I backport it to all open branches? Yes, approved for backporting. -Surya > > Thanks, > Jeevitha P. > >> On 28/09/26 5:43 PM, jeevitha wrote: >>> Hi All, >>> >>> The following patch has been bootstrapped and regtested on powerpc64le-linux >>> and powerpc64-linux. >>> >>> The Power10 implementation of the SSE movemask intrinsics uses >>> vec_extractm(). On big-endian PowerPC, the vector element order >>> causes vec_extractm() to produce the mask bits in a different >>> order than required by the SSE movemask intrinsics. >>> >>> Reverse the vector element order with vec_reve() on big-endian Power10 >>> before calling vec_extractm(). This ensures that _mm_movemask_pd(), >>> _mm_movemask_ps(), and _mm_movemask_epi8() produce the same results on >>> both big and little endian targets. >>> >>> 2026-09-28 Jeevitha Palanisamy >>> >>> gcc/ >>> PR target/127274 >>> * config/rs6000/emmintrin.h (_mm_movemask_pd): Reverse vector >>> element order on big-endian Power10 before calling vec_extractm(). >>> (_mm_movemask_epi8): Likewise. >>> * config/rs6000/xmmintrin.h (_mm_movemask_ps): Likewise. >>> >>> diff --git a/gcc/config/rs6000/emmintrin.h b/gcc/config/rs6000/emmintrin.h >>> index 4d442d2e965..551be83617d 100644 >>> --- a/gcc/config/rs6000/emmintrin.h >>> +++ b/gcc/config/rs6000/emmintrin.h >>> @@ -1234,6 +1234,9 @@ extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artifici >>> _mm_movemask_pd (__m128d __A) >>> { >>> #ifdef _ARCH_PWR10 >>> +#ifdef __BIG_ENDIAN__ >>> + __A = vec_reve (__A); >>> +#endif >>> return vec_extractm ((__v2du) __A); >>> #else >>> __vector unsigned long long __result; >>> @@ -2031,6 +2034,9 @@ extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artifici >>> _mm_movemask_epi8 (__m128i __A) >>> { >>> #ifdef _ARCH_PWR10 >>> +#ifdef __BIG_ENDIAN__ >>> + __A = (__m128i) vec_reve ((__v16qu) __A); >>> +#endif >>> return vec_extractm ((__v16qu) __A); >>> #else >>> __vector unsigned long long __result; >>> diff --git a/gcc/config/rs6000/xmmintrin.h b/gcc/config/rs6000/xmmintrin.h >>> index bd5be193b44..d98d4b3570c 100644 >>> --- a/gcc/config/rs6000/xmmintrin.h >>> +++ b/gcc/config/rs6000/xmmintrin.h >>> @@ -1353,6 +1353,9 @@ extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artifici >>> _mm_movemask_ps (__m128 __A) >>> { >>> #ifdef _ARCH_PWR10 >>> +#ifdef __BIG_ENDIAN__ >>> + __A = vec_reve (__A); >>> +#endif >>> return vec_extractm ((__vector unsigned int) __A); >>> #else >>> __vector unsigned long long __result; >> > From karl.meakin@arm.com Mon Nov 2 16:32:24 2026 From: karl.meakin@arm.com (Karl Meakin) Date: Mon, 2 Nov 2026 16:32:24 +0000 Subject: [PATCH] aarch64: Port Neon table lookup intrinsics to new framework In-Reply-To: <20261102154618.134988-1-abhishek.kaushik@arm.com> References: <20261102154618.134988-1-abhishek.kaushik@arm.com> Message-ID: <04f8ea26-bf8a-4389-859e-966a58706069@arm.com> On 02/11/2026 15:46, Abhishek Kaushik wrote: > This patch ports the Neon table lookup intrinsics to the new pragma-based framework. > > Bootstrapped and regression tested on aarch64-linux-gnu. > > gcc/ChangeLog: > > * config/aarch64/aarch64-acle-builtins.cc (DEF_NEON_FUNCTION_GS): > Define. > (DEF_NEON_FUNCTION): Use DEF_NEON_FUNCTION_GS. > * config/aarch64/aarch64-acle-builtins.h (TYPES_neon_tbl_s8): > Define. > (TYPES_neon_tbl_other): Likewise. > (TYPES_neon_luti2_b): Likewise. > (TYPES_neon_luti2_h): Likewise. > (types_neon_tbl_s8): Likewise. > (types_neon_tbl_other): Likewise. > * config/aarch64/aarch64-neon-builtins-base.cc: Include > emit-rtl.h. > (gimple_exact_insn::fold): Expand definition. > (gimple_table_lookup): New class. > (gimple_table_lookup::expand): Build multi-register table results > directly and perform legacy TBX lookup before generating masks. > (gimple_luti): Likewise. > (vtbl1): Define. > (vtbl2): Likewise. > (vtbl3): Likewise. > (vtbl4): Likewise. > (vqtbl1): Likewise. > (vqtbl2): Likewise. > (vqtbl3): Likewise. > (vqtbl4): Likewise. > (vqtbl1q): Likewise. > (vqtbl2q): Likewise. > (vqtbl3q): Likewise. > (vqtbl4q): Likewise. > (vtbx1): Likewise. > (vtbx2): Likewise. > (vtbx3): Likewise. > (vtbx4): Likewise. > (vqtbx1): Likewise. > (vqtbx2): Likewise. > (vqtbx3): Likewise. > (vqtbx4): Likewise. > (vqtbx1q): Likewise. > (vqtbx2q): Likewise. > (vqtbx3q): Likewise. > (vqtbx4q): Likewise. > (vluti2_lane): Likewise. > (vluti2_laneq): Likewise. > (vluti2q_lane): Likewise. > (vluti2q_laneq): Likewise. > (vluti4q_lane): Likewise. > (vluti4q_laneq): Likewise. > * config/aarch64/aarch64-neon-builtins-base.def: Add table > lookup intrinsic definitions. > * config/aarch64/aarch64-neon-builtins.def (DEF_NEON_FUNCTION_GS): > Define. > * config/aarch64/aarch64-simd-pragma-builtins.def: Remove table > lookup intrinsic definitions. > * config/aarch64/arm_neon.h: Remove inline definitions of table > lookup intrinsics. > > gcc/testsuite/ChangeLog: > > * gcc.target/aarch64/neon/vluti2.c: New test. > * gcc.target/aarch64/neon/vluti4.c: New test. > * gcc.target/aarch64/neon/vqtbl.c: New test. > * gcc.target/aarch64/neon/vqtblq.c: New test. > * gcc.target/aarch64/neon/vqtbx.c: New test. > * gcc.target/aarch64/neon/vqtbxq.c: New test. > * gcc.target/aarch64/neon/vtbl.c: New test. > * gcc.target/aarch64/neon/vtbx.c: New test. Don't split the `vqtbl` and `vqtblq` variants into separate files. Put them all into `vtbl.c`. Likewise for `vtbx.c`. > * gcc.target/aarch64/simd/mf8_data_1.c: Update table > lookup expectations. > --- > gcc/config/aarch64/aarch64-acle-builtins.cc | 15 +- > gcc/config/aarch64/aarch64-acle-builtins.h | 18 + > .../aarch64/aarch64-neon-builtins-base.cc | 216 ++++++- > .../aarch64/aarch64-neon-builtins-base.def | 74 +++ > gcc/config/aarch64/aarch64-neon-builtins.def | 7 + > .../aarch64/aarch64-simd-pragma-builtins.def | 78 --- > gcc/config/aarch64/arm_neon.h | 588 ------------------ > .../gcc.target/aarch64/neon/vluti2.c | 263 ++++++++ > .../gcc.target/aarch64/neon/vluti4.c | 138 ++++ > gcc/testsuite/gcc.target/aarch64/neon/vqtbl.c | 117 ++++ > .../gcc.target/aarch64/neon/vqtblq.c | 117 ++++ > gcc/testsuite/gcc.target/aarch64/neon/vqtbx.c | 120 ++++ > .../gcc.target/aarch64/neon/vqtbxq.c | 116 ++++ > gcc/testsuite/gcc.target/aarch64/neon/vtbl.c | 153 +++++ > gcc/testsuite/gcc.target/aarch64/neon/vtbx.c | 178 ++++++ > .../gcc.target/aarch64/simd/mf8_data_1.c | 12 +- > 16 files changed, 1535 insertions(+), 675 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vluti2.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vluti4.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vqtbl.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vqtblq.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vqtbx.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vqtbxq.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vtbl.c > create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vtbx.c > > diff --git a/gcc/config/aarch64/aarch64-acle-builtins.cc b/gcc/config/aarch64/aarch64-acle-builtins.cc > index 2d52443a68ca..2f51be1ff92f 100644 > --- a/gcc/config/aarch64/aarch64-acle-builtins.cc > +++ b/gcc/config/aarch64/aarch64-acle-builtins.cc > @@ -187,18 +187,23 @@ constexpr group_suffix_info group_suffixes[] = { > { "", 0, 1 } > }; > > -constexpr const aarch64_acle::function_group_info neon_function_groups[] = { > -#define DEF_NEON_FUNCTION(NAME, TYPES, SHAPE_ARGS) \ > +constexpr const aarch64_acle::function_group_info > +neon_function_groups[] = { > +#define DEF_NEON_FUNCTION_GS(NAME, TYPES, GROUPS, SHAPE_ARGS) \ > { \ > /* .base_name = */ #NAME, \ > - /* .base = */ &aarch64_acle::functions::NAME, \ > + /* .base = */ &aarch64_acle::functions::NAME, \ Unnecessary reformatting > /* .shape = */ &aarch64_acle::shapes::SHAPE_NAME (NAME, TYPES),\ > /* .types = */ aarch64_acle::types_##TYPES, \ > - /* .groups = */ aarch64_acle::groups_none, \ > + /* .groups = */ aarch64_acle::groups_##GROUPS, \ > /* .preds = */ aarch64_acle::preds_none, \ > /* .extensions = */ aarch64_required_extensions::REQUIRED_EXTENSIONS,\ > /* .fpm_mode = */ aarch64_acle::FPM_unused, \ > }, > + > +#define DEF_NEON_FUNCTION(NAME, TYPES, SHAPE_ARGS) \ > + DEF_NEON_FUNCTION_GS (NAME, TYPES, none, SHAPE_ARGS) > + > #include "aarch64-neon-builtins.def" > }; > > @@ -3916,7 +3921,7 @@ function_expander::expand () > if (fpm_mode == FPM_set) > { > /* The last element of these functions is always an fpm_t that must be > - written to FPMR before the call to the instruction itself. */ > + written to FPMR before the call to the instruction itself. */ Unnecessary reformatting > rtx fpm = args.last (); > gcc_assert (CONST_INT_P (fpm) || GET_MODE (fpm) == DImode); > emit_move_insn (gen_rtx_REG (DImode, FPM_REGNUM), fpm); > diff --git a/gcc/config/aarch64/aarch64-acle-builtins.h b/gcc/config/aarch64/aarch64-acle-builtins.h > index 1572594872b9..b625e6a0a463 100644 > --- a/gcc/config/aarch64/aarch64-acle-builtins.h > +++ b/gcc/config/aarch64/aarch64-acle-builtins.h > @@ -2056,6 +2056,20 @@ function_expander::result_mode () const > TYPES_neon_reinterpretq1 (D, p64), \ > TYPES_neon_reinterpretq1 (D, p128) > > +/* _s8. */ > +#define TYPES_neon_tbl_s8(S, D, T) \ > + S (s8) > + > +/* _u8, _p8 and _mf8. */ > +#define TYPES_neon_tbl_other(S, D, T) \ > + S (u8), S (p8), S (mf8) > + > +#define TYPES_neon_luti2_b(S, D, T) \ > + S (u8), S (s8), S (p8), S (mf8) > + > +#define TYPES_neon_luti2_h(S, D, T) \ > + S (u16), S (s16), S (f16), S (bf16), S (p16) > + > /* Describe a tuple of type suffixes in which only the first is used. */ > #define DEF_VECTOR_TYPE(X) \ > { TYPE_SUFFIX_ ## X, NUM_TYPE_SUFFIXES, NUM_TYPE_SUFFIXES } > @@ -2228,6 +2242,10 @@ DEF_SVE_TYPES_ARRAY (neon_rev32); > DEF_SVE_TYPES_ARRAY (neon_rev64); > DEF_SVE_TYPES_ARRAY (neon_reinterpret); > DEF_SVE_TYPES_ARRAY (neon_reinterpretq); > +DEF_SVE_TYPES_ARRAY (neon_tbl_s8); > +DEF_SVE_TYPES_ARRAY (neon_tbl_other); > +DEF_SVE_TYPES_ARRAY (neon_luti2_b); > +DEF_SVE_TYPES_ARRAY (neon_luti2_h); > > static const group_suffix_index groups_none[] = { > GROUP_none, NUM_GROUP_SUFFIXES > diff --git a/gcc/config/aarch64/aarch64-neon-builtins-base.cc b/gcc/config/aarch64/aarch64-neon-builtins-base.cc > index b00aed7c7d77..53ac7dac7700 100644 > --- a/gcc/config/aarch64/aarch64-neon-builtins-base.cc > +++ b/gcc/config/aarch64/aarch64-neon-builtins-base.cc > @@ -43,6 +43,7 @@ > #include "aarch64-neon-builtins-base.h" > #include "aarch64-neon-builtins-functions.h" > #include "gimple-fold.h" > +#include "emit-rtl.h" > > namespace aarch64_acle { > /* Build a cast expression, `(TYPE)EXPR`, if necessary to make an expression > @@ -168,7 +169,10 @@ class gimple_function_base : public function_base > > template struct gimple_exact_insn : gimple_function_base > { > - gimple *fold (gimple_folder &) const override { return nullptr; } > + gimple *fold (gimple_folder &) const override > + { > + return nullptr; > + } Unnecessary reformating > rtx expand (function_expander &e) const override > { > return e.use_exact_insn (insn); > @@ -623,6 +627,180 @@ public: > } > }; > > +/* Expand legacy NEON vtbl1-4 and vtbx1-4. > + N is the number of 64-bit vectors in the lookup table. */ > +template > +class gimple_table_lookup : public gimple_function_base > +{ > + bool m_is_tbx; > + insn_code m_code; > + unsigned int m_table_arg; > + > +public: > + constexpr gimple_table_lookup (bool tbx = false) > + : m_is_tbx (tbx), > + m_code (tbx && (N == 2 || N == 4) > + ? (N == 2 ? CODE_FOR_aarch64_qtbx1v8qi > + : CODE_FOR_aarch64_qtbx2v8qi) > + : (N <= 2 ? CODE_FOR_aarch64_qtbl1v8qi > + : CODE_FOR_aarch64_qtbl2v8qi)), > + m_table_arg (tbx ? 1 : 0) Remove the `m_code` and `m_table_arg` member variables and derive them from `N` and `m_is_tbx` in the body of `expand`. > + { > + static_assert (N >= 1 && N <= 4, > + "Invalid number of table vectors"); `static_assert` does not need to appear in a function body, it can be at the same level as the function declarations and will get checked at template-expansion time. > + } > + > + gimple *fold (gimple_folder &) const override > + { > + return nullptr; > + } > + > + rtx expand (function_expander &e) const override > + { > + rtx parts[N]; > + > + /* vtbl1 and vtbx1 take a single V8QI vector. The remaining > + intrinsics take a tuple of N V8QI vectors. */ > + if (N == 1) > + parts[0] = e.args[m_table_arg]; > + else > + { > + machine_mode mode = GET_MODE (e.args[m_table_arg]); > + > + gcc_assert ((N == 2 && mode == V2x8QImode) > + || (N == 3 && mode == V3x8QImode) > + || (N == 4 && mode == V4x8QImode)); > + > + rtx tuple = force_reg (mode, e.args[m_table_arg]); > + > + /* Extract the individual 64-bit table vectors. */ > + for (unsigned int i = 0; i < N; ++i) > + parts[i] = simplify_gen_subreg (V8QImode, tuple, > + mode, i * 8); > + } > + > + /* Construct the full hardware table. N == 1 or 2 requires > + one 128-bit register; N == 3 or 4 requires two. */ > + rtx table = N > 2 ? gen_reg_rtx (V2x16QImode) > + : gen_reg_rtx (V16QImode); > + > + /* Construct the first 128-bit table register. > + For N == 1, zero the unused upper eight bytes. */ > + rtx first = N > 2 ? simplify_gen_subreg (V16QImode, table, > + V2x16QImode, 0) > + : table; > + > + rtx upper = N >= 2 ? parts[1] > + : CONST0_RTX (V8QImode); > + > + emit_insn (gen_aarch64_combinev8qi (first, > + parts[0], upper)); > + > + if (N > 2) > + { > + rtx second = simplify_gen_subreg (V16QImode, table, > + V2x16QImode, 16); > + > + upper = N == 4 ? parts[3] > + : CONST0_RTX (V8QImode); > + > + emit_insn (gen_aarch64_combinev8qi (second, > + parts[2], upper)); > + } > + > + /* Legacy vtbx1 and vtbx3 have tables of 8 and 24 bytes, > + respectively. Hardware TBX accepts tables whose sizes > + are multiples of 16 bytes, so the padded bytes must > + not overwrite the original destination. */ > + if (m_is_tbx && (N == 1 || N == 3)) > + { > + rtx indices = force_reg (V8QImode, e.args[2]); > + > + /* Perform the table lookup. */ > + rtx lookup = gen_reg_rtx (V8QImode); > + > + if (N == 1) > + emit_insn (gen_aarch64_qtbl1v8qi (lookup, table, > + indices)); > + else > + emit_insn (gen_aarch64_qtbl2v8qi (lookup, table, > + indices)); > + > + /* Generate a mask for indices within the logical table. > + The maximum valid index is 7 for vtbx1 and 23 for vtbx3. */ > + rtx limit = gen_const_vec_duplicate (V8QImode, > + GEN_INT (8 * N - 1)); > + limit = force_reg (V8QImode, limit); > + > + rtx mask = gen_reg_rtx (V8QImode); > + > + /* mask[i] = 0xff if indices[i] <= 8 * N - 1. */ > + emit_insn (gen_aarch64_cmgeuv8qi (mask, limit, indices)); > + > + /* Select lookup for valid indices, otherwise preserve the > + original destination. */ > + rtx result = gen_reg_rtx (V8QImode); > + > + rtx fallback = force_reg (V8QImode, e.args[0]); > + > + emit_insn (gen_aarch64_simd_bslv8qi (result, mask, > + lookup, fallback)); > + return result; > + } > + > + /* All vtbl variants, and vtbx2/vtbx4, map directly onto > + the corresponding TBL or TBX instruction after packing. */ > + e.args[m_table_arg] = table; > + return e.use_exact_insn (m_code); > + } > +}; > + > +/* Expand NEON LUTI2 and LUTI4 intrinsics. > + BITS_PER_INDEX is the number of bits per lookup index. */ > +template > +class gimple_luti : public gimple_function_base > +{ > +public: > + gimple *fold (gimple_folder &) const override > + { > + return nullptr; > + } > + > + rtx expand (function_expander &e) const override > + { > + static_assert (BITS_PER_INDEX == 2 || BITS_PER_INDEX == 4); > + > + rtx table = e.args[0]; > + > + /* LUTI2 uses only the low 64 bits of the table. > + The 128-bit table forms are provided for convenience. */ > + if (BITS_PER_INDEX == 2 > + && known_eq (GET_MODE_BITSIZE (GET_MODE (table)), 128u)) > + { > + machine_mode mode > + = aarch64_v64_mode (GET_MODE_INNER (GET_MODE (table))) > + .require (); > + > + table = gen_lowpart (mode, table); > + } > + > + /* Select the instruction based on the table and index modes. */ > + insn_code icode > + = code_for_aarch64_lut (GET_MODE (table), > + GET_MODE (e.args[1])); > + > + gcc_assert (icode != CODE_FOR_nothing); > + > + e.add_output_operand (icode); > + e.add_input_operand (icode, table); > + e.add_input_operand (icode, e.args[1]); > + e.add_input_operand (icode, e.args[2]); > + e.add_integer_operand (BITS_PER_INDEX); > + > + return e.generate_insn (icode); > + } > +}; > + > tree > ext_mask (gimple_folder &f) > { > @@ -860,6 +1038,42 @@ NEON_FUNCTION (vzip1, vzip1q, gimple_permute, (zip_mask)) > NEON_FUNCTION (vzip2, vzip2q, gimple_permute, (zip_mask)) > NEON_FUNCTION (vzip, vzipq, gimple_permute_pair, (zip_mask, zip_mask)) > > +// Table lookup > +NEON_FUNCTION (vtbl1, gimple_table_lookup<1>,) > +NEON_FUNCTION (vtbl2, gimple_table_lookup<2>,) > +NEON_FUNCTION (vtbl3, gimple_table_lookup<3>,) > +NEON_FUNCTION (vtbl4, gimple_table_lookup<4>,) > +NEON_FUNCTION (vqtbl1, gimple_exact_insn,) > +NEON_FUNCTION (vqtbl2, gimple_exact_insn,) > +NEON_FUNCTION (vqtbl3, gimple_exact_insn,) > +NEON_FUNCTION (vqtbl4, gimple_exact_insn,) > +NEON_FUNCTION (vqtbl1q, gimple_exact_insn,) > +NEON_FUNCTION (vqtbl2q, gimple_exact_insn,) > +NEON_FUNCTION (vqtbl3q, gimple_exact_insn,) > +NEON_FUNCTION (vqtbl4q, gimple_exact_insn,) > +NEON_FUNCTION (vtbx1, gimple_table_lookup<1>, (true)) > +NEON_FUNCTION (vtbx2, gimple_table_lookup<2>, (true)) > +NEON_FUNCTION (vtbx3, gimple_table_lookup<3>, (true)) > +NEON_FUNCTION (vtbx4, gimple_table_lookup<4>, (true)) > +NEON_FUNCTION (vqtbx1, gimple_exact_insn,) > +NEON_FUNCTION (vqtbx2, gimple_exact_insn,) > +NEON_FUNCTION (vqtbx3, gimple_exact_insn,) > +NEON_FUNCTION (vqtbx4, gimple_exact_insn,) > +NEON_FUNCTION (vqtbx1q, gimple_exact_insn,) > +NEON_FUNCTION (vqtbx2q, gimple_exact_insn,) > +NEON_FUNCTION (vqtbx3q, gimple_exact_insn,) > +NEON_FUNCTION (vqtbx4q, gimple_exact_insn,) Parameterise the `aarch64_qtbl` insns over the argument modes, so that these can all be combined: +NEON_FUNCTION (vqtbl1, vqtbl2, vqtbl3, vqtbl4, vqtbl1q, vqtbl2q, vqtbl3q, vqtbl4q, gimple_exact_insn,) +NEON_FUNCTION (vqtbx1, vqtbx2, vqtbx3, vqtbx4, vqtbx1q, vqtbx2q, vqtbx3q, vqtbx4q, gimple_exact_insn,) > + > +// Table lookup with 2-bit indices > +NEON_FUNCTION (vluti2_lane, gimple_luti<2>,) > +NEON_FUNCTION (vluti2_laneq, gimple_luti<2>,) > +NEON_FUNCTION (vluti2q_lane, gimple_luti<2>,) > +NEON_FUNCTION (vluti2q_laneq, gimple_luti<2>,) > + > +// Table lookup with 4-bit indices > +NEON_FUNCTION (vluti4q_lane, gimple_luti<4>,) > +NEON_FUNCTION (vluti4q_laneq, gimple_luti<4>,) Combine multiple lines with the same class into one NEON_FUNCTION call: +// Table lookup with 2-bit or 4-bit indices +NEON_FUNCTION (vluti2_lane, vluti2_laneq, vluti2q_lane, vluti2q_laneq, gimple_luti<2>,) +NEON_FUNCTION (vluti4q_lane, vluti4q_laneq, gimple_luti<4>,) > + > // AES > NEON_FUNCTION (vaeseq, gimple_exact_insn,) > NEON_FUNCTION (vaesdq, gimple_exact_insn,) > diff --git a/gcc/config/aarch64/aarch64-neon-builtins-base.def b/gcc/config/aarch64/aarch64-neon-builtins-base.def > index df33c37c34fc..a723a5cc5584 100644 > --- a/gcc/config/aarch64/aarch64-neon-builtins-base.def > +++ b/gcc/config/aarch64/aarch64-neon-builtins-base.def > @@ -261,6 +261,80 @@ DEF_NEON_FUNCTION (vzip2q, bhsd_neon, ("Q0,Q0,Q0")) > DEF_NEON_FUNCTION (vzipq, bhs_neon, ("Q0x2,Q0,Q0")) > #undef REQUIRED_EXTENSIONS > > +// Table lookup > +#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD) > +DEF_NEON_FUNCTION (vtbl1, neon_tbl_s8, ("D0,D0,D0")) > +DEF_NEON_FUNCTION (vtbl1, neon_tbl_other, ("D0,D0,Du0")) > +DEF_NEON_FUNCTION (vtbl2, neon_tbl_s8, ("D0,D0x2,D0")) > +DEF_NEON_FUNCTION (vtbl2, neon_tbl_other, ("D0,D0x2,Du0")) > +DEF_NEON_FUNCTION (vtbl3, neon_tbl_s8, ("D0,D0x3,D0")) > +DEF_NEON_FUNCTION (vtbl3, neon_tbl_other, ("D0,D0x3,Du0")) > +DEF_NEON_FUNCTION (vtbl4, neon_tbl_s8, ("D0,D0x4,D0")) > +DEF_NEON_FUNCTION (vtbl4, neon_tbl_other, ("D0,D0x4,Du0")) > +DEF_NEON_FUNCTION (vqtbl1, neon_rev16, ("D0,Q0,Du0")) > +DEF_NEON_FUNCTION (vqtbl2, neon_rev16, ("D0,Q0x2,Du0")) > +DEF_NEON_FUNCTION (vqtbl3, neon_rev16, ("D0,Q0x3,Du0")) > +DEF_NEON_FUNCTION (vqtbl4, neon_rev16, ("D0,Q0x4,Du0")) > +DEF_NEON_FUNCTION (vqtbl1q, neon_rev16, ("Q0,Q0,Qu0")) > +DEF_NEON_FUNCTION (vqtbl2q, neon_rev16, ("Q0,Q0x2,Qu0")) > +DEF_NEON_FUNCTION (vqtbl3q, neon_rev16, ("Q0,Q0x3,Qu0")) > +DEF_NEON_FUNCTION (vqtbl4q, neon_rev16, ("Q0,Q0x4,Qu0")) > +DEF_NEON_FUNCTION (vtbx1, neon_tbl_s8, ("D0,D0,D0,D0")) > +DEF_NEON_FUNCTION (vtbx1, neon_tbl_other, ("D0,D0,D0,Du0")) > +DEF_NEON_FUNCTION (vtbx2, neon_tbl_s8, ("D0,D0,D0x2,D0")) > +DEF_NEON_FUNCTION (vtbx2, neon_tbl_other, ("D0,D0,D0x2,Du0")) > +DEF_NEON_FUNCTION (vtbx3, neon_tbl_s8, ("D0,D0,D0x3,D0")) > +DEF_NEON_FUNCTION (vtbx3, neon_tbl_other, ("D0,D0,D0x3,Du0")) > +DEF_NEON_FUNCTION (vtbx4, neon_tbl_s8, ("D0,D0,D0x4,D0")) > +DEF_NEON_FUNCTION (vtbx4, neon_tbl_other, ("D0,D0,D0x4,Du0")) > +DEF_NEON_FUNCTION (vqtbx1, neon_rev16, ("D0,D0,Q0,Du0")) > +DEF_NEON_FUNCTION (vqtbx2, neon_rev16, ("D0,D0,Q0x2,Du0")) > +DEF_NEON_FUNCTION (vqtbx3, neon_rev16, ("D0,D0,Q0x3,Du0")) > +DEF_NEON_FUNCTION (vqtbx4, neon_rev16, ("D0,D0,Q0x4,Du0")) > +DEF_NEON_FUNCTION (vqtbx1q, neon_rev16, ("Q0,Q0,Q0,Qu0")) > +DEF_NEON_FUNCTION (vqtbx2q, neon_rev16, ("Q0,Q0,Q0x2,Qu0")) > +DEF_NEON_FUNCTION (vqtbx3q, neon_rev16, ("Q0,Q0,Q0x3,Qu0")) > +DEF_NEON_FUNCTION (vqtbx4q, neon_rev16, ("Q0,Q0,Q0x4,Qu0")) > +#undef REQUIRED_EXTENSIONS > + `neon_tbl_s8` and `neon_tbl_other` are always used together, so why not include `neon_tbl_other` in `neon_tbl_s8`? > +/* Lookup table read with packed 2-bit indices. */ > +#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_LUT) > + > +/* 8-bit result elements. */ > +DEF_NEON_FUNCTION (vluti2_lane, neon_luti2_b, > + ("Q0,D0,Du8,ss32", range<2, 0, 1>)) > +DEF_NEON_FUNCTION (vluti2_laneq, neon_luti2_b, > + ("Q0,D0,Qu8,ss32", range<2, 0, 3>)) > +DEF_NEON_FUNCTION (vluti2q_lane, neon_luti2_b, > + ("Q0,Q0,Du8,ss32", range<2, 0, 1>)) > +DEF_NEON_FUNCTION (vluti2q_laneq, neon_luti2_b, > + ("Q0,Q0,Qu8,ss32", range<2, 0, 3>)) > + > +/* 16-bit result elements. */ > +DEF_NEON_FUNCTION (vluti2_lane, neon_luti2_h, > + ("Q0,D0,Du8,ss32", range<2, 0, 3>)) > +DEF_NEON_FUNCTION (vluti2_laneq, neon_luti2_h, > + ("Q0,D0,Qu8,ss32", range<2, 0, 7>)) > +DEF_NEON_FUNCTION (vluti2q_lane, neon_luti2_h, > + ("Q0,Q0,Du8,ss32", range<2, 0, 3>)) > +DEF_NEON_FUNCTION (vluti2q_laneq, neon_luti2_h, > + ("Q0,Q0,Qu8,ss32", range<2, 0, 7>)) > + > +/* 8-bit forms: no group suffix. */ > +DEF_NEON_FUNCTION (vluti4q_lane, neon_luti2_b, > + ("Q0,Q0,Du8,ss32", range<2, 0, 0>)) > + > +DEF_NEON_FUNCTION (vluti4q_laneq, neon_luti2_b, > + ("Q0,Q0,Qu8,ss32", range<2, 0, 1>)) > + > +/* 16-bit forms: the name ends with _x2. */ > +DEF_NEON_FUNCTION_GS (vluti4q_lane, neon_luti2_h, x2, > + ("Q0,Q0x2,Du8,ss32", range<2, 0, 1>)) > + > +DEF_NEON_FUNCTION_GS (vluti4q_laneq, neon_luti2_h, x2, > + ("Q0,Q0x2,Qu8,ss32", range<2, 0, 3>)) > +#undef REQUIRED_EXTENSIONS > + Please layout the `DEF_NEON_FUNCTION{_GS}`s on a single line, even if it exceeds the line length limit, and keep the arguments horizontally aligned > // AES > #define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD | AARCH64_FL_AES) > DEF_NEON_FUNCTION (vaeseq, b_unsigned, ("Q0,Q0,Q0")) > diff --git a/gcc/config/aarch64/aarch64-neon-builtins.def b/gcc/config/aarch64/aarch64-neon-builtins.def > index 58630eebe489..02bb5591b8ce 100644 > --- a/gcc/config/aarch64/aarch64-neon-builtins.def > +++ b/gcc/config/aarch64/aarch64-neon-builtins.def > @@ -25,6 +25,12 @@ > #define DEF_NEON_FUNCTION(NAME, TYPES, SHAPE_ARGS) > #endif > > +/* Define a NEON function with an explicit group suffix. */ > +#ifndef DEF_NEON_FUNCTION_GS > +#define DEF_NEON_FUNCTION_GS(NAME, TYPES, GROUPS, SHAPE_ARGS) \ > + DEF_NEON_FUNCTION (NAME, TYPES, SHAPE_ARGS) > +#endif > + > /* Helper for generating the name of the function_group's corresponding > neon_shape instance. */ > #define OBJ_NAME(NAME, TYPES) NAME ## _ ## TYPES ## _obj > @@ -36,5 +42,6 @@ > #include "aarch64-neon-builtins-base.def" > > #undef DEF_NEON_FUNCTION > +#undef DEF_NEON_FUNCTION_GS > #undef OBJ_NAME > #undef SHAPE_NAME > diff --git a/gcc/config/aarch64/aarch64-simd-pragma-builtins.def b/gcc/config/aarch64/aarch64-simd-pragma-builtins.def > index 92ae493800ea..6bd4e8e89714 100644 > --- a/gcc/config/aarch64/aarch64-simd-pragma-builtins.def > +++ b/gcc/config/aarch64/aarch64-simd-pragma-builtins.def > @@ -78,36 +78,6 @@ > ENTRY_BINARY (NAME##q_f32, f32q, f32q, s32q, UNSPEC, FLAGS) \ > ENTRY_BINARY (NAME##q_f64, f64q, f64q, s64q, UNSPEC, FLAGS) > > -#undef ENTRY_TERNARY_VLUT8 > -#define ENTRY_TERNARY_VLUT8(T) \ > - ENTRY_BINARY_LANE (vluti2_lane_##T##8, T##8q, T##8, u8, \ > - UNSPEC_LUTI2, QUIET) \ > - ENTRY_BINARY_LANE (vluti2_laneq_##T##8, T##8q, T##8, u8q, \ > - UNSPEC_LUTI2, QUIET) \ > - ENTRY_BINARY_LANE (vluti2q_lane_##T##8, T##8q, T##8q, u8, \ > - UNSPEC_LUTI2, QUIET) \ > - ENTRY_BINARY_LANE (vluti2q_laneq_##T##8, T##8q, T##8q, u8q, \ > - UNSPEC_LUTI2, QUIET) \ > - ENTRY_BINARY_LANE (vluti4q_lane_##T##8, T##8q, T##8q, u8, \ > - UNSPEC_LUTI4, QUIET) \ > - ENTRY_BINARY_LANE (vluti4q_laneq_##T##8, T##8q, T##8q, u8q, \ > - UNSPEC_LUTI4, QUIET) > - > -#undef ENTRY_TERNARY_VLUT16 > -#define ENTRY_TERNARY_VLUT16(T) \ > - ENTRY_BINARY_LANE (vluti2_lane_##T##16, T##16q, T##16, u8, \ > - UNSPEC_LUTI2, QUIET) \ > - ENTRY_BINARY_LANE (vluti2_laneq_##T##16, T##16q, T##16, u8q, \ > - UNSPEC_LUTI2, QUIET) \ > - ENTRY_BINARY_LANE (vluti2q_lane_##T##16, T##16q, T##16q, u8, \ > - UNSPEC_LUTI2, QUIET) \ > - ENTRY_BINARY_LANE (vluti2q_laneq_##T##16, T##16q, T##16q, u8q, \ > - UNSPEC_LUTI2, QUIET) \ > - ENTRY_BINARY_LANE (vluti4q_lane_##T##16_x2, T##16q, T##16qx2, u8, \ > - UNSPEC_LUTI4, QUIET) \ > - ENTRY_BINARY_LANE (vluti4q_laneq_##T##16_x2, T##16q, T##16qx2, u8q, \ > - UNSPEC_LUTI4, QUIET) > - > #undef ENTRY_UNARY_VQ_BHF > #define ENTRY_UNARY_VQ_BHF(N, T1, UNSPEC, FLAGS) \ > ENTRY_UNARY (N##_bf16_mf8_fpm, bf16q, T1, UNSPEC, FLAGS) \ > @@ -140,20 +110,6 @@ ENTRY_BINARY_VHSDF (vamax, UNSPEC_FAMAX, FP) > ENTRY_BINARY_VHSDF (vamin, UNSPEC_FAMIN, FP) > #undef REQUIRED_EXTENSIONS > > -// lut > -#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_LUT) > -ENTRY_TERNARY_VLUT8 (p) > -ENTRY_TERNARY_VLUT8 (s) > -ENTRY_TERNARY_VLUT8 (u) > -ENTRY_TERNARY_VLUT8 (mf) > - > -ENTRY_TERNARY_VLUT16 (bf) > -ENTRY_TERNARY_VLUT16 (f) > -ENTRY_TERNARY_VLUT16 (p) > -ENTRY_TERNARY_VLUT16 (s) > -ENTRY_TERNARY_VLUT16 (u) > -#undef REQUIRED_EXTENSIONS > - > // fpm conversion > #define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_FP8) > ENTRY_UNARY_VQ_BHF (vcvt1, mf8, UNSPEC_F1CVTL_FP8, FP8) > @@ -287,37 +243,3 @@ ENTRY_STORE (vst1q_mf8_x4, mf8_scalar_ptr, mf8qx4, UNSPEC_ST1x4) > ENTRY_STORE_LANE (vst4_lane_mf8, mf8_scalar_ptr, mf8x4, UNSPEC_ST4_LANE) > ENTRY_STORE_LANE (vst4q_lane_mf8, mf8_scalar_ptr, mf8qx4, UNSPEC_ST4_LANE) > #undef REQUIRED_EXTENSIONS > - > -// tbl > -#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD) > -ENTRY_BINARY (vtbl1_mf8, mf8, mf8, u8, UNSPEC_TBL, QUIET) > -ENTRY_BINARY (vtbl2_mf8, mf8, mf8x2, u8, UNSPEC_TBL, QUIET) > -ENTRY_BINARY (vtbl3_mf8, mf8, mf8x3, u8, UNSPEC_TBL, QUIET) > -ENTRY_BINARY (vtbl4_mf8, mf8, mf8x4, u8, UNSPEC_TBL, QUIET) > - > -ENTRY_BINARY (vqtbl1_mf8, mf8, mf8q, u8, UNSPEC_TBL, QUIET) > -ENTRY_BINARY (vqtbl1q_mf8, mf8q, mf8q, u8q, UNSPEC_TBL, QUIET) > -ENTRY_BINARY (vqtbl2_mf8, mf8, mf8qx2, u8, UNSPEC_TBL, QUIET) > -ENTRY_BINARY (vqtbl2q_mf8, mf8q, mf8qx2, u8q, UNSPEC_TBL, QUIET) > -ENTRY_BINARY (vqtbl3_mf8, mf8, mf8qx3, u8, UNSPEC_TBL, QUIET) > -ENTRY_BINARY (vqtbl3q_mf8, mf8q, mf8qx3, u8q, UNSPEC_TBL, QUIET) > -ENTRY_BINARY (vqtbl4_mf8, mf8, mf8qx4, u8, UNSPEC_TBL, QUIET) > -ENTRY_BINARY (vqtbl4q_mf8, mf8q, mf8qx4, u8q, UNSPEC_TBL, QUIET) > -#undef REQUIRED_EXTENSIONS > - > -// tbx > -#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD) > -ENTRY_TERNARY (vtbx1_mf8, mf8, mf8, mf8, u8, UNSPEC_TBX, QUIET) > -ENTRY_TERNARY (vtbx2_mf8, mf8, mf8, mf8x2, u8, UNSPEC_TBX, QUIET) > -ENTRY_TERNARY (vtbx3_mf8, mf8, mf8, mf8x3, u8, UNSPEC_TBX, QUIET) > -ENTRY_TERNARY (vtbx4_mf8, mf8, mf8, mf8x4, u8, UNSPEC_TBX, QUIET) > - > -ENTRY_TERNARY (vqtbx1_mf8, mf8, mf8, mf8q, u8, UNSPEC_TBX, QUIET) > -ENTRY_TERNARY (vqtbx1q_mf8, mf8q, mf8q, mf8q, u8q, UNSPEC_TBX, QUIET) > -ENTRY_TERNARY (vqtbx2_mf8, mf8, mf8, mf8qx2, u8, UNSPEC_TBX, QUIET) > -ENTRY_TERNARY (vqtbx2q_mf8, mf8q, mf8q, mf8qx2, u8q, UNSPEC_TBX, QUIET) > -ENTRY_TERNARY (vqtbx3_mf8, mf8, mf8, mf8qx3, u8, UNSPEC_TBX, QUIET) > -ENTRY_TERNARY (vqtbx3q_mf8, mf8q, mf8q, mf8qx3, u8q, UNSPEC_TBX, QUIET) > -ENTRY_TERNARY (vqtbx4_mf8, mf8, mf8, mf8qx4, u8, UNSPEC_TBX, QUIET) > -ENTRY_TERNARY (vqtbx4q_mf8, mf8q, mf8q, mf8qx4, u8q, UNSPEC_TBX, QUIET) > -#undef REQUIRED_EXTENSIONS > diff --git a/gcc/config/aarch64/arm_neon.h b/gcc/config/aarch64/arm_neon.h > index 7b5926ca21b2..e991ae806f8f 100644 > --- a/gcc/config/aarch64/arm_neon.h > +++ b/gcc/config/aarch64/arm_neon.h > @@ -4514,232 +4514,6 @@ vqrdmulhq_laneq_s32 (int32x4_t __a, int32x4_t __b, const int __c) > return __builtin_aarch64_sqrdmulh_laneqv4si (__a, __b, __c); > } > > -/* Table intrinsics. */ > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl1_p8 (poly8x16_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbl1v8qi_ppu (__tab, __idx); > -} > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl1_s8 (int8x16_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbl1v8qi_ssu (__tab, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl1_u8 (uint8x16_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbl1v8qi_uuu (__tab, __idx); > -} > - > -__extension__ extern __inline poly8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl1q_p8 (poly8x16_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbl1v16qi_ppu (__tab, __idx); > -} > - > -__extension__ extern __inline int8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl1q_s8 (int8x16_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbl1v16qi_ssu (__tab, __idx); > -} > - > -__extension__ extern __inline uint8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl1q_u8 (uint8x16_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbl1v16qi_uuu (__tab, __idx); > -} > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx1_s8 (int8x8_t __r, int8x16_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbx1v8qi_sssu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx1_u8 (uint8x8_t __r, uint8x16_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbx1v8qi_uuuu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx1_p8 (poly8x8_t __r, poly8x16_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbx1v8qi_pppu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline int8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx1q_s8 (int8x16_t __r, int8x16_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbx1v16qi_sssu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline uint8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx1q_u8 (uint8x16_t __r, uint8x16_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbx1v16qi_uuuu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline poly8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx1q_p8 (poly8x16_t __r, poly8x16_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbx1v16qi_pppu (__r, __tab, __idx); > -} > - > -/* V7 legacy table intrinsics. */ > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbl1_s8 (int8x8_t __tab, int8x8_t __idx) > -{ > - int8x16_t __temp = vcombine_s8 (__tab, > - vcreate_s8 (__AARCH64_UINT64_C (0x0))); > - return __builtin_aarch64_qtbl1v8qi (__temp, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbl1_u8 (uint8x8_t __tab, uint8x8_t __idx) > -{ > - uint8x16_t __temp = vcombine_u8 (__tab, > - vcreate_u8 (__AARCH64_UINT64_C (0x0))); > - return __builtin_aarch64_qtbl1v8qi_uuu (__temp, __idx); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbl1_p8 (poly8x8_t __tab, uint8x8_t __idx) > -{ > - poly8x16_t __temp = vcombine_p8 (__tab, > - vcreate_p8 (__AARCH64_UINT64_C (0x0))); > - return __builtin_aarch64_qtbl1v8qi_ppu (__temp, __idx); > -} > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbl2_s8 (int8x8x2_t __tab, int8x8_t __idx) > -{ > - int8x16_t __temp = vcombine_s8 (__tab.val[0], __tab.val[1]); > - return __builtin_aarch64_qtbl1v8qi (__temp, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbl2_u8 (uint8x8x2_t __tab, uint8x8_t __idx) > -{ > - uint8x16_t __temp = vcombine_u8 (__tab.val[0], __tab.val[1]); > - return __builtin_aarch64_qtbl1v8qi_uuu (__temp, __idx); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbl2_p8 (poly8x8x2_t __tab, uint8x8_t __idx) > -{ > - poly8x16_t __temp = vcombine_p8 (__tab.val[0], __tab.val[1]); > - return __builtin_aarch64_qtbl1v8qi_ppu (__temp, __idx); > -} > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbl3_s8 (int8x8x3_t __tab, int8x8_t __idx) > -{ > - int8x16x2_t __temp; > - __temp.val[0] = vcombine_s8 (__tab.val[0], __tab.val[1]); > - __temp.val[1] = vcombine_s8 (__tab.val[2], > - vcreate_s8 (__AARCH64_UINT64_C (0x0))); > - return __builtin_aarch64_qtbl2v8qi (__temp, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbl3_u8 (uint8x8x3_t __tab, uint8x8_t __idx) > -{ > - uint8x16x2_t __temp; > - __temp.val[0] = vcombine_u8 (__tab.val[0], __tab.val[1]); > - __temp.val[1] = vcombine_u8 (__tab.val[2], > - vcreate_u8 (__AARCH64_UINT64_C (0x0))); > - return __builtin_aarch64_qtbl2v8qi_uuu (__temp, __idx); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbl3_p8 (poly8x8x3_t __tab, uint8x8_t __idx) > -{ > - poly8x16x2_t __temp; > - __temp.val[0] = vcombine_p8 (__tab.val[0], __tab.val[1]); > - __temp.val[1] = vcombine_p8 (__tab.val[2], > - vcreate_p8 (__AARCH64_UINT64_C (0x0))); > - return __builtin_aarch64_qtbl2v8qi_ppu (__temp, __idx); > -} > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbl4_s8 (int8x8x4_t __tab, int8x8_t __idx) > -{ > - int8x16x2_t __temp; > - __temp.val[0] = vcombine_s8 (__tab.val[0], __tab.val[1]); > - __temp.val[1] = vcombine_s8 (__tab.val[2], __tab.val[3]); > - return __builtin_aarch64_qtbl2v8qi (__temp, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbl4_u8 (uint8x8x4_t __tab, uint8x8_t __idx) > -{ > - uint8x16x2_t __temp; > - __temp.val[0] = vcombine_u8 (__tab.val[0], __tab.val[1]); > - __temp.val[1] = vcombine_u8 (__tab.val[2], __tab.val[3]); > - return __builtin_aarch64_qtbl2v8qi_uuu (__temp, __idx); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbl4_p8 (poly8x8x4_t __tab, uint8x8_t __idx) > -{ > - poly8x16x2_t __temp; > - __temp.val[0] = vcombine_p8 (__tab.val[0], __tab.val[1]); > - __temp.val[1] = vcombine_p8 (__tab.val[2], __tab.val[3]); > - return __builtin_aarch64_qtbl2v8qi_ppu (__temp, __idx); > -} > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbx2_s8 (int8x8_t __r, int8x8x2_t __tab, int8x8_t __idx) > -{ > - int8x16_t __temp = vcombine_s8 (__tab.val[0], __tab.val[1]); > - return __builtin_aarch64_qtbx1v8qi (__r, __temp, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbx2_u8 (uint8x8_t __r, uint8x8x2_t __tab, uint8x8_t __idx) > -{ > - uint8x16_t __temp = vcombine_u8 (__tab.val[0], __tab.val[1]); > - return __builtin_aarch64_qtbx1v8qi_uuuu (__r, __temp, __idx); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbx2_p8 (poly8x8_t __r, poly8x8x2_t __tab, uint8x8_t __idx) > -{ > - poly8x16_t __temp = vcombine_p8 (__tab.val[0], __tab.val[1]); > - return __builtin_aarch64_qtbx1v8qi_pppu (__r, __temp, __idx); > -} > - > /* End of temporary inline asm. */ > > /* Start of optimal implementations in approved order. */ > @@ -14564,270 +14338,6 @@ vqshrund_n_s64 (int64_t __a, const int __b) > return (int32_t) __builtin_aarch64_sqshrun_ndi (__a, __b); > } > > -/* vqtbl2 */ > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl2_s8 (int8x16x2_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbl2v8qi_ssu (__tab, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl2_u8 (uint8x16x2_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbl2v8qi_uuu (__tab, __idx); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl2_p8 (poly8x16x2_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbl2v8qi_ppu (__tab, __idx); > -} > - > -__extension__ extern __inline int8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl2q_s8 (int8x16x2_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbl2v16qi_ssu (__tab, __idx); > -} > - > -__extension__ extern __inline uint8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl2q_u8 (uint8x16x2_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbl2v16qi_uuu (__tab, __idx); > -} > - > -__extension__ extern __inline poly8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl2q_p8 (poly8x16x2_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbl2v16qi_ppu (__tab, __idx); > -} > - > -/* vqtbl3 */ > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl3_s8 (int8x16x3_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbl3v8qi_ssu (__tab, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl3_u8 (uint8x16x3_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbl3v8qi_uuu (__tab, __idx); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl3_p8 (poly8x16x3_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbl3v8qi_ppu (__tab, __idx); > -} > - > -__extension__ extern __inline int8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl3q_s8 (int8x16x3_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbl3v16qi_ssu (__tab, __idx); > -} > - > -__extension__ extern __inline uint8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl3q_u8 (uint8x16x3_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbl3v16qi_uuu (__tab, __idx); > -} > - > -__extension__ extern __inline poly8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl3q_p8 (poly8x16x3_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbl3v16qi_ppu (__tab, __idx); > -} > - > -/* vqtbl4 */ > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl4_s8 (int8x16x4_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbl4v8qi_ssu (__tab, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl4_u8 (uint8x16x4_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbl4v8qi_uuu (__tab, __idx); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl4_p8 (poly8x16x4_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbl4v8qi_ppu (__tab, __idx); > -} > - > -__extension__ extern __inline int8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl4q_s8 (int8x16x4_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbl4v16qi_ssu (__tab, __idx); > -} > - > -__extension__ extern __inline uint8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl4q_u8 (uint8x16x4_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbl4v16qi_uuu (__tab, __idx); > -} > - > -__extension__ extern __inline poly8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbl4q_p8 (poly8x16x4_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbl4v16qi_ppu (__tab, __idx); > -} > - > -/* vqtbx2 */ > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx2_s8 (int8x8_t __r, int8x16x2_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbx2v8qi_sssu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx2_u8 (uint8x8_t __r, uint8x16x2_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbx2v8qi_uuuu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx2_p8 (poly8x8_t __r, poly8x16x2_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbx2v8qi_pppu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline int8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx2q_s8 (int8x16_t __r, int8x16x2_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbx2v16qi_sssu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline uint8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx2q_u8 (uint8x16_t __r, uint8x16x2_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbx2v16qi_uuuu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline poly8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx2q_p8 (poly8x16_t __r, poly8x16x2_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbx2v16qi_pppu (__r, __tab, __idx); > -} > - > -/* vqtbx3 */ > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx3_s8 (int8x8_t __r, int8x16x3_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbx3v8qi_sssu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx3_u8 (uint8x8_t __r, uint8x16x3_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbx3v8qi_uuuu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx3_p8 (poly8x8_t __r, poly8x16x3_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbx3v8qi_pppu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline int8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx3q_s8 (int8x16_t __r, int8x16x3_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbx3v16qi_sssu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline uint8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx3q_u8 (uint8x16_t __r, uint8x16x3_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbx3v16qi_uuuu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline poly8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx3q_p8 (poly8x16_t __r, poly8x16x3_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbx3v16qi_pppu (__r, __tab, __idx); > -} > - > -/* vqtbx4 */ > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx4_s8 (int8x8_t __r, int8x16x4_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbx4v8qi_sssu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx4_u8 (uint8x8_t __r, uint8x16x4_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbx4v8qi_uuuu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx4_p8 (poly8x8_t __r, poly8x16x4_t __tab, uint8x8_t __idx) > -{ > - return __builtin_aarch64_qtbx4v8qi_pppu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline int8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx4q_s8 (int8x16_t __r, int8x16x4_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbx4v16qi_sssu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline uint8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx4q_u8 (uint8x16_t __r, uint8x16x4_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbx4v16qi_uuuu (__r, __tab, __idx); > -} > - > -__extension__ extern __inline poly8x16_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vqtbx4q_p8 (poly8x16_t __r, poly8x16x4_t __tab, uint8x16_t __idx) > -{ > - return __builtin_aarch64_qtbx4v16qi_pppu (__r, __tab, __idx); > -} > - > /* vrecpe */ > > __extension__ extern __inline uint32x2_t > @@ -17978,104 +17488,6 @@ vsubd_u64 (uint64_t __a, uint64_t __b) > return __a - __b; > } > > -/* vtbx1 */ > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbx1_s8 (int8x8_t __r, int8x8_t __tab, int8x8_t __idx) > -{ > - uint8x8_t __mask = vclt_u8 (vreinterpret_u8_s8 (__idx), > - vmov_n_u8 (8)); > - int8x8_t __tbl = vtbl1_s8 (__tab, __idx); > - > - return vbsl_s8 (__mask, __tbl, __r); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbx1_u8 (uint8x8_t __r, uint8x8_t __tab, uint8x8_t __idx) > -{ > - uint8x8_t __mask = vclt_u8 (__idx, vmov_n_u8 (8)); > - uint8x8_t __tbl = vtbl1_u8 (__tab, __idx); > - > - return vbsl_u8 (__mask, __tbl, __r); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbx1_p8 (poly8x8_t __r, poly8x8_t __tab, uint8x8_t __idx) > -{ > - uint8x8_t __mask = vclt_u8 (__idx, vmov_n_u8 (8)); > - poly8x8_t __tbl = vtbl1_p8 (__tab, __idx); > - > - return vbsl_p8 (__mask, __tbl, __r); > -} > - > -/* vtbx3 */ > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbx3_s8 (int8x8_t __r, int8x8x3_t __tab, int8x8_t __idx) > -{ > - uint8x8_t __mask = vclt_u8 (vreinterpret_u8_s8 (__idx), > - vmov_n_u8 (24)); > - int8x8_t __tbl = vtbl3_s8 (__tab, __idx); > - > - return vbsl_s8 (__mask, __tbl, __r); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbx3_u8 (uint8x8_t __r, uint8x8x3_t __tab, uint8x8_t __idx) > -{ > - uint8x8_t __mask = vclt_u8 (__idx, vmov_n_u8 (24)); > - uint8x8_t __tbl = vtbl3_u8 (__tab, __idx); > - > - return vbsl_u8 (__mask, __tbl, __r); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbx3_p8 (poly8x8_t __r, poly8x8x3_t __tab, uint8x8_t __idx) > -{ > - uint8x8_t __mask = vclt_u8 (__idx, vmov_n_u8 (24)); > - poly8x8_t __tbl = vtbl3_p8 (__tab, __idx); > - > - return vbsl_p8 (__mask, __tbl, __r); > -} > - > -/* vtbx4 */ > - > -__extension__ extern __inline int8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbx4_s8 (int8x8_t __r, int8x8x4_t __tab, int8x8_t __idx) > -{ > - int8x16x2_t __temp; > - __temp.val[0] = vcombine_s8 (__tab.val[0], __tab.val[1]); > - __temp.val[1] = vcombine_s8 (__tab.val[2], __tab.val[3]); > - return __builtin_aarch64_qtbx2v8qi (__r, __temp, __idx); > -} > - > -__extension__ extern __inline uint8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbx4_u8 (uint8x8_t __r, uint8x8x4_t __tab, uint8x8_t __idx) > -{ > - uint8x16x2_t __temp; > - __temp.val[0] = vcombine_u8 (__tab.val[0], __tab.val[1]); > - __temp.val[1] = vcombine_u8 (__tab.val[2], __tab.val[3]); > - return __builtin_aarch64_qtbx2v8qi_uuuu (__r, __temp, __idx); > -} > - > -__extension__ extern __inline poly8x8_t > -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > -vtbx4_p8 (poly8x8_t __r, poly8x8x4_t __tab, uint8x8_t __idx) > -{ > - poly8x16x2_t __temp; > - __temp.val[0] = vcombine_p8 (__tab.val[0], __tab.val[1]); > - __temp.val[1] = vcombine_p8 (__tab.val[2], __tab.val[3]); > - return __builtin_aarch64_qtbx2v8qi_pppu (__r, __temp, __idx); > -} > - > /* vtst */ > > __extension__ extern __inline uint8x8_t > diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vluti2.c b/gcc/testsuite/gcc.target/aarch64/neon/vluti2.c > new file mode 100644 > index 000000000000..9a0fef0ab359 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/neon/vluti2.c > @@ -0,0 +1,263 @@ > +/* { dg-do compile } */ > +/* { dg-additional-options "-O3 -march=armv9-a+lut" } */ > +/* { dg-final { check-function-bodies "**" "" } } */ > + > +#include "arm_neon_test.h" > + > +#define TEST_LUTI2(NAME, RET_TYPE, ARG_1_TYPE, ARG_2_TYPE) \ > + RET_TYPE test_##NAME (ARG_1_TYPE vn, ARG_2_TYPE vm) \ > + { \ > + return NAME (vn, vm, 0); \ > + } > + > +/* > +** test_vluti2_lane_u8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_lane_u8, uint8x16_t, uint8x8_t, uint8x8_t) > + > +/* > +** test_vluti2_laneq_u8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_laneq_u8, uint8x16_t, uint8x8_t, uint8x16_t) > + > +/* > +** test_vluti2q_lane_u8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_lane_u8, uint8x16_t, uint8x16_t, uint8x8_t) > + > +/* > +** test_vluti2q_laneq_u8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_laneq_u8, uint8x16_t, uint8x16_t, uint8x16_t) > + > +/* > +** test_vluti2_lane_s8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_lane_s8, int8x16_t, int8x8_t, uint8x8_t) > + > +/* > +** test_vluti2_laneq_s8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_laneq_s8, int8x16_t, int8x8_t, uint8x16_t) > + > +/* > +** test_vluti2q_lane_s8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_lane_s8, int8x16_t, int8x16_t, uint8x8_t) > + > +/* > +** test_vluti2q_laneq_s8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_laneq_s8, int8x16_t, int8x16_t, uint8x16_t) > + > +/* > +** test_vluti2_lane_p8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_lane_p8, poly8x16_t, poly8x8_t, uint8x8_t) > + > +/* > +** test_vluti2_laneq_p8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_laneq_p8, poly8x16_t, poly8x8_t, uint8x16_t) > + > +/* > +** test_vluti2q_lane_p8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_lane_p8, poly8x16_t, poly8x16_t, uint8x8_t) > + > +/* > +** test_vluti2q_laneq_p8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_laneq_p8, poly8x16_t, poly8x16_t, uint8x16_t) > + > +/* > +** test_vluti2_lane_mf8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_lane_mf8, mfloat8x16_t, mfloat8x8_t, uint8x8_t) > + > +/* > +** test_vluti2_laneq_mf8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_laneq_mf8, mfloat8x16_t, mfloat8x8_t, uint8x16_t) > + > +/* > +** test_vluti2q_lane_mf8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_lane_mf8, mfloat8x16_t, mfloat8x16_t, uint8x8_t) > + > +/* > +** test_vluti2q_laneq_mf8: > +** luti2 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_laneq_mf8, mfloat8x16_t, mfloat8x16_t, uint8x16_t) > + > +/* > +** test_vluti2_lane_u16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_lane_u16, uint16x8_t, uint16x4_t, uint8x8_t) > + > +/* > +** test_vluti2_laneq_u16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_laneq_u16, uint16x8_t, uint16x4_t, uint8x16_t) > + > +/* > +** test_vluti2q_lane_u16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_lane_u16, uint16x8_t, uint16x8_t, uint8x8_t) > + > +/* > +** test_vluti2q_laneq_u16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_laneq_u16, uint16x8_t, uint16x8_t, uint8x16_t) > + > +/* > +** test_vluti2_lane_s16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_lane_s16, int16x8_t, int16x4_t, uint8x8_t) > + > +/* > +** test_vluti2_laneq_s16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_laneq_s16, int16x8_t, int16x4_t, uint8x16_t) > + > +/* > +** test_vluti2q_lane_s16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_lane_s16, int16x8_t, int16x8_t, uint8x8_t) > + > +/* > +** test_vluti2q_laneq_s16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_laneq_s16, int16x8_t, int16x8_t, uint8x16_t) > + > +/* > +** test_vluti2_lane_f16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_lane_f16, float16x8_t, float16x4_t, uint8x8_t) > + > +/* > +** test_vluti2_laneq_f16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_laneq_f16, float16x8_t, float16x4_t, uint8x16_t) > + > +/* > +** test_vluti2q_lane_f16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_lane_f16, float16x8_t, float16x8_t, uint8x8_t) > + > +/* > +** test_vluti2q_laneq_f16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_laneq_f16, float16x8_t, float16x8_t, uint8x16_t) > + > +/* > +** test_vluti2_lane_bf16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_lane_bf16, bfloat16x8_t, bfloat16x4_t, uint8x8_t) > + > +/* > +** test_vluti2_laneq_bf16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_laneq_bf16, bfloat16x8_t, bfloat16x4_t, uint8x16_t) > + > +/* > +** test_vluti2q_lane_bf16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_lane_bf16, bfloat16x8_t, bfloat16x8_t, uint8x8_t) > + > +/* > +** test_vluti2q_laneq_bf16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_laneq_bf16, bfloat16x8_t, bfloat16x8_t, uint8x16_t) > + > +/* > +** test_vluti2_lane_p16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_lane_p16, poly16x8_t, poly16x4_t, uint8x8_t) > + > +/* > +** test_vluti2_laneq_p16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2_laneq_p16, poly16x8_t, poly16x4_t, uint8x16_t) > + > +/* > +** test_vluti2q_lane_p16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_lane_p16, poly16x8_t, poly16x8_t, uint8x8_t) > + > +/* > +** test_vluti2q_laneq_p16: > +** luti2 v[0-9]+\.8h, {v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI2 (vluti2q_laneq_p16, poly16x8_t, poly16x8_t, uint8x16_t) > diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vluti4.c b/gcc/testsuite/gcc.target/aarch64/neon/vluti4.c > new file mode 100644 > index 000000000000..99ff77ae4f6b > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/neon/vluti4.c > @@ -0,0 +1,138 @@ > +/* { dg-do compile } */ > +/* { dg-additional-options "-O3 -march=armv9-a+lut" } */ > +/* { dg-final { check-function-bodies "**" "" } } */ > + > +#include "arm_neon_test.h" > + > +#define TEST_LUTI4(NAME, RET_TYPE, ARG_1_TYPE, ARG_2_TYPE) \ > + RET_TYPE test_##NAME (ARG_1_TYPE vn, ARG_2_TYPE vm) \ > + { \ > + return NAME (vn, vm, 0); \ > + } > + > +/* > +** test_vluti4q_lane_u8: > +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_lane_u8, uint8x16_t, uint8x16_t, uint8x8_t) > + > +/* > +** test_vluti4q_laneq_u8: > +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_laneq_u8, uint8x16_t, uint8x16_t, uint8x16_t) > + > +/* > +** test_vluti4q_lane_s8: > +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_lane_s8, int8x16_t, int8x16_t, uint8x8_t) > + > +/* > +** test_vluti4q_laneq_s8: > +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_laneq_s8, int8x16_t, int8x16_t, uint8x16_t) > + > +/* > +** test_vluti4q_lane_p8: > +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_lane_p8, poly8x16_t, poly8x16_t, uint8x8_t) > + > +/* > +** test_vluti4q_laneq_p8: > +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_laneq_p8, poly8x16_t, poly8x16_t, uint8x16_t) > + > +/* > +** test_vluti4q_lane_mf8: > +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_lane_mf8, mfloat8x16_t, mfloat8x16_t, uint8x8_t) > + > +/* > +** test_vluti4q_laneq_mf8: > +** luti4 v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_laneq_mf8, mfloat8x16_t, mfloat8x16_t, uint8x16_t) > + > +/* > +** test_vluti4q_lane_u16_x2: > +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_lane_u16_x2, uint16x8_t, uint16x8x2_t, uint8x8_t) > + > +/* > +** test_vluti4q_laneq_u16_x2: > +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_laneq_u16_x2, uint16x8_t, uint16x8x2_t, uint8x16_t) > + > +/* > +** test_vluti4q_lane_s16_x2: > +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_lane_s16_x2, int16x8_t, int16x8x2_t, uint8x8_t) > + > +/* > +** test_vluti4q_laneq_s16_x2: > +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_laneq_s16_x2, int16x8_t, int16x8x2_t, uint8x16_t) > + > +/* > +** test_vluti4q_lane_f16_x2: > +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_lane_f16_x2, float16x8_t, float16x8x2_t, uint8x8_t) > + > +/* > +** test_vluti4q_laneq_f16_x2: > +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_laneq_f16_x2, float16x8_t, float16x8x2_t, uint8x16_t) > + > +/* > +** test_vluti4q_lane_bf16_x2: > +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_lane_bf16_x2, bfloat16x8_t, bfloat16x8x2_t, uint8x8_t) > + > +/* > +** test_vluti4q_laneq_bf16_x2: > +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_laneq_bf16_x2, bfloat16x8_t, bfloat16x8x2_t, > + uint8x16_t) > + > +/* > +** test_vluti4q_lane_p16_x2: > +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_lane_p16_x2, poly16x8_t, poly16x8x2_t, uint8x8_t) > + > +/* > +** test_vluti4q_laneq_p16_x2: > +** luti4 v[0-9]+\.8h, {v[0-9]+\.8h, v[0-9]+\.8h}, v[0-9]+\[0\] > +** ret > +*/ > +TEST_LUTI4 (vluti4q_laneq_p16_x2, poly16x8_t, poly16x8x2_t, uint8x16_t) > diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vqtbl.c b/gcc/testsuite/gcc.target/aarch64/neon/vqtbl.c > new file mode 100644 > index 000000000000..d9ed12982094 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/neon/vqtbl.c > @@ -0,0 +1,117 @@ > +/* { dg-do compile } */ > +/* { dg-final { check-function-bodies "**" "" } } */ > + > +#include "arm_neon_test.h" > + > +/* > +** test_vqtbl1_s8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl1_s8, int8x8_t, int8x16_t, uint8x8_t) > + > +/* > +** test_vqtbl1_u8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl1_u8, uint8x8_t, uint8x16_t, uint8x8_t) > + > +/* > +** test_vqtbl1_p8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl1_p8, poly8x8_t, poly8x16_t, uint8x8_t) > + > +/* > +** test_vqtbl1_mf8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl1_mf8, mfloat8x8_t, mfloat8x16_t, uint8x8_t) > + > +/* > +** test_vqtbl2_s8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl2_s8, int8x8_t, int8x16x2_t, uint8x8_t) > + > +/* > +** test_vqtbl2_u8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl2_u8, uint8x8_t, uint8x16x2_t, uint8x8_t) > + > +/* > +** test_vqtbl2_p8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl2_p8, poly8x8_t, poly8x16x2_t, uint8x8_t) > + > +/* > +** test_vqtbl2_mf8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl2_mf8, mfloat8x8_t, mfloat8x16x2_t, uint8x8_t) > + > +/* > +** test_vqtbl3_s8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl3_s8, int8x8_t, int8x16x3_t, uint8x8_t) > + > +/* > +** test_vqtbl3_u8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl3_u8, uint8x8_t, uint8x16x3_t, uint8x8_t) > + > +/* > +** test_vqtbl3_p8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl3_p8, poly8x8_t, poly8x16x3_t, uint8x8_t) > + > +/* > +** test_vqtbl3_mf8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl3_mf8, mfloat8x8_t, mfloat8x16x3_t, uint8x8_t) > + > +/* > +** test_vqtbl4_s8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl4_s8, int8x8_t, int8x16x4_t, uint8x8_t) > + > +/* > +** test_vqtbl4_u8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl4_u8, uint8x8_t, uint8x16x4_t, uint8x8_t) > + > +/* > +** test_vqtbl4_p8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl4_p8, poly8x8_t, poly8x16x4_t, uint8x8_t) > + > +/* > +** test_vqtbl4_mf8: > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vqtbl4_mf8, mfloat8x8_t, mfloat8x16x4_t, uint8x8_t) > + > diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vqtblq.c b/gcc/testsuite/gcc.target/aarch64/neon/vqtblq.c > new file mode 100644 > index 000000000000..5ff00e2b5958 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/neon/vqtblq.c > @@ -0,0 +1,117 @@ > +/* { dg-do compile } */ > +/* { dg-final { check-function-bodies "**" "" } } */ > + > +#include "arm_neon_test.h" > + > +/* > +** test_vqtbl1q_s8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl1q_s8, int8x16_t, int8x16_t, uint8x16_t) > + > +/* > +** test_vqtbl1q_u8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl1q_u8, uint8x16_t, uint8x16_t, uint8x16_t) > + > +/* > +** test_vqtbl1q_p8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl1q_p8, poly8x16_t, poly8x16_t, uint8x16_t) > + > +/* > +** test_vqtbl1q_mf8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl1q_mf8, mfloat8x16_t, mfloat8x16_t, uint8x16_t) > + > +/* > +** test_vqtbl2q_s8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl2q_s8, int8x16_t, int8x16x2_t, uint8x16_t) > + > +/* > +** test_vqtbl2q_u8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl2q_u8, uint8x16_t, uint8x16x2_t, uint8x16_t) > + > +/* > +** test_vqtbl2q_p8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl2q_p8, poly8x16_t, poly8x16x2_t, uint8x16_t) > + > +/* > +** test_vqtbl2q_mf8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl2q_mf8, mfloat8x16_t, mfloat8x16x2_t, uint8x16_t) > + > +/* > +** test_vqtbl3q_s8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl3q_s8, int8x16_t, int8x16x3_t, uint8x16_t) > + > +/* > +** test_vqtbl3q_u8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl3q_u8, uint8x16_t, uint8x16x3_t, uint8x16_t) > + > +/* > +** test_vqtbl3q_p8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl3q_p8, poly8x16_t, poly8x16x3_t, uint8x16_t) > + > +/* > +** test_vqtbl3q_mf8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl3q_mf8, mfloat8x16_t, mfloat8x16x3_t, uint8x16_t) > + > +/* > +** test_vqtbl4q_s8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl4q_s8, int8x16_t, int8x16x4_t, uint8x16_t) > + > +/* > +** test_vqtbl4q_u8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl4q_u8, uint8x16_t, uint8x16x4_t, uint8x16_t) > + > +/* > +** test_vqtbl4q_p8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl4q_p8, poly8x16_t, poly8x16x4_t, uint8x16_t) > + > +/* > +** test_vqtbl4q_mf8: > +** tbl v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_BINARY (vqtbl4q_mf8, mfloat8x16_t, mfloat8x16x4_t, uint8x16_t) > + > diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vqtbx.c b/gcc/testsuite/gcc.target/aarch64/neon/vqtbx.c > new file mode 100644 > index 000000000000..7affd0fd0715 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/neon/vqtbx.c > @@ -0,0 +1,120 @@ > +/* { dg-do compile } */ > +/* { dg-final { check-function-bodies "**" "" } } */ > + > +#include "arm_neon_test.h" > + > +/* > +** test_vqtbx1_s8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx1_s8, int8x8_t, int8x8_t, int8x16_t, uint8x8_t) > + > +/* > +** test_vqtbx1_u8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx1_u8, uint8x8_t, uint8x8_t, uint8x16_t, uint8x8_t) > + > +/* > +** test_vqtbx1_p8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx1_p8, poly8x8_t, poly8x8_t, poly8x16_t, uint8x8_t) > + > +/* > +** test_vqtbx1_mf8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx1_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x16_t, > + uint8x8_t) > + > +/* > +** test_vqtbx2_s8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx2_s8, int8x8_t, int8x8_t, int8x16x2_t, uint8x8_t) > + > +/* > +** test_vqtbx2_u8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx2_u8, uint8x8_t, uint8x8_t, uint8x16x2_t, uint8x8_t) > + > +/* > +** test_vqtbx2_p8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx2_p8, poly8x8_t, poly8x8_t, poly8x16x2_t, uint8x8_t) > + > +/* > +** test_vqtbx2_mf8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx2_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x16x2_t, > + uint8x8_t) > + > +/* > +** test_vqtbx3_s8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx3_s8, int8x8_t, int8x8_t, int8x16x3_t, uint8x8_t) > + > +/* > +** test_vqtbx3_u8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx3_u8, uint8x8_t, uint8x8_t, uint8x16x3_t, uint8x8_t) > + > +/* > +** test_vqtbx3_p8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx3_p8, poly8x8_t, poly8x8_t, poly8x16x3_t, uint8x8_t) > + > +/* > +** test_vqtbx3_mf8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx3_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x16x3_t, > + uint8x8_t) > + > +/* > +** test_vqtbx4_s8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx4_s8, int8x8_t, int8x8_t, int8x16x4_t, uint8x8_t) > + > +/* > +** test_vqtbx4_u8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx4_u8, uint8x8_t, uint8x8_t, uint8x16x4_t, uint8x8_t) > + > +/* > +** test_vqtbx4_p8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx4_p8, poly8x8_t, poly8x8_t, poly8x16x4_t, uint8x8_t) > + > +/* > +** test_vqtbx4_mf8: > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vqtbx4_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x16x4_t, > + uint8x8_t) > diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vqtbxq.c b/gcc/testsuite/gcc.target/aarch64/neon/vqtbxq.c > new file mode 100644 > index 000000000000..22f56191dce5 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/neon/vqtbxq.c > @@ -0,0 +1,116 @@ > +/* { dg-do compile } */ > +/* { dg-final { check-function-bodies "**" "" } } */ > + > +#include "arm_neon_test.h" > + > +/* > +** test_vqtbx1q_s8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx1q_s8, int8x16_t, int8x16_t, int8x16_t, uint8x16_t) > + > +/* > +** test_vqtbx1q_u8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx1q_u8, uint8x16_t, uint8x16_t, uint8x16_t, uint8x16_t) > + > +/* > +** test_vqtbx1q_p8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx1q_p8, poly8x16_t, poly8x16_t, poly8x16_t, uint8x16_t) > + > +/* > +** test_vqtbx1q_mf8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx1q_mf8, mfloat8x16_t, mfloat8x16_t, mfloat8x16_t, uint8x16_t) > + > +/* > +** test_vqtbx2q_s8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx2q_s8, int8x16_t, int8x16_t, int8x16x2_t, uint8x16_t) > + > +/* > +** test_vqtbx2q_u8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx2q_u8, uint8x16_t, uint8x16_t, uint8x16x2_t, uint8x16_t) > + > +/* > +** test_vqtbx2q_p8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx2q_p8, poly8x16_t, poly8x16_t, poly8x16x2_t, uint8x16_t) > + > +/* > +** test_vqtbx2q_mf8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx2q_mf8, mfloat8x16_t, mfloat8x16_t, mfloat8x16x2_t, uint8x16_t) > + > +/* > +** test_vqtbx3q_s8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx3q_s8, int8x16_t, int8x16_t, int8x16x3_t, uint8x16_t) > + > +/* > +** test_vqtbx3q_u8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx3q_u8, uint8x16_t, uint8x16_t, uint8x16x3_t, uint8x16_t) > + > +/* > +** test_vqtbx3q_p8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx3q_p8, poly8x16_t, poly8x16_t, poly8x16x3_t, uint8x16_t) > + > +/* > +** test_vqtbx3q_mf8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx3q_mf8, mfloat8x16_t, mfloat8x16_t, mfloat8x16x3_t, uint8x16_t) > + > +/* > +** test_vqtbx4q_s8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx4q_s8, int8x16_t, int8x16_t, int8x16x4_t, uint8x16_t) > + > +/* > +** test_vqtbx4q_u8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx4q_u8, uint8x16_t, uint8x16_t, uint8x16x4_t, uint8x16_t) > + > +/* > +** test_vqtbx4q_p8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx4q_p8, poly8x16_t, poly8x16_t, poly8x16x4_t, uint8x16_t) > + > +/* > +** test_vqtbx4q_mf8: > +** tbx v[0-9]+\.16b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.16b > +** ret > +*/ > +TEST_TERNARY (vqtbx4q_mf8, mfloat8x16_t, mfloat8x16_t, mfloat8x16x4_t, uint8x16_t) > diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vtbl.c b/gcc/testsuite/gcc.target/aarch64/neon/vtbl.c > new file mode 100644 > index 000000000000..903c9295075f > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/neon/vtbl.c > @@ -0,0 +1,153 @@ > +/* { dg-do compile } */ > +/* { dg-final { check-function-bodies "**" "" } } */ > + > +#include "arm_neon_test.h" > + > +/* > +** test_vtbl1_s8: > +** fmov d[0-9]+, d[0-9]+ > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl1_s8, int8x8_t, int8x8_t, int8x8_t) > + > +/* > +** test_vtbl1_u8: > +** fmov d[0-9]+, d[0-9]+ > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl1_u8, uint8x8_t, uint8x8_t, uint8x8_t) > + > +/* > +** test_vtbl1_p8: > +** fmov d[0-9]+, d[0-9]+ > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl1_p8, poly8x8_t, poly8x8_t, uint8x8_t) > + > +/* > +** test_vtbl1_mf8: > +** fmov d[0-9]+, d[0-9]+ > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl1_mf8, mfloat8x8_t, mfloat8x8_t, uint8x8_t) > + > +/* > +** test_vtbl2_s8: > +** sub sp, sp, #16 > +** stp d[0-9]+, d[0-9]+, \[sp\] > +** ldr q[0-9]+, \[sp\] > +** add sp, sp, 16 > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl2_s8, int8x8_t, int8x8x2_t, int8x8_t) > + > +/* > +** test_vtbl2_u8: > +** sub sp, sp, #16 > +** stp d[0-9]+, d[0-9]+, \[sp\] > +** ldr q[0-9]+, \[sp\] > +** add sp, sp, 16 > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl2_u8, uint8x8_t, uint8x8x2_t, uint8x8_t) > + > +/* > +** test_vtbl2_p8: > +** sub sp, sp, #16 > +** stp d[0-9]+, d[0-9]+, \[sp\] > +** ldr q[0-9]+, \[sp\] > +** add sp, sp, 16 > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl2_p8, poly8x8_t, poly8x8x2_t, uint8x8_t) > + > +/* > +** test_vtbl2_mf8: > +** sub sp, sp, #16 > +** stp d[0-9]+, d[0-9]+, \[sp\] > +** ldr q[0-9]+, \[sp\] > +** add sp, sp, 16 > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl2_mf8, mfloat8x8_t, mfloat8x8x2_t, uint8x8_t) > + > +/* > +** test_vtbl3_s8: > +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** fmov d([0-9]+), d[0-9]+ > +** tbl v[0-9]+\.8b, {v\1\.16b - v\2\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl3_s8, int8x8_t, int8x8x3_t, int8x8_t) > + > +/* > +** test_vtbl3_u8: > +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** fmov d([0-9]+), d[0-9]+ > +** tbl v[0-9]+\.8b, {v\1\.16b - v\2\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl3_u8, uint8x8_t, uint8x8x3_t, uint8x8_t) > + > +/* > +** test_vtbl3_p8: > +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** fmov d([0-9]+), d[0-9]+ > +** tbl v[0-9]+\.8b, {v\1\.16b - v\2\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl3_p8, poly8x8_t, poly8x8x3_t, uint8x8_t) > + > +/* > +** test_vtbl3_mf8: > +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** fmov d([0-9]+), d[0-9]+ > +** tbl v[0-9]+\.8b, {v\1\.16b - v\2\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl3_mf8, mfloat8x8_t, mfloat8x8x3_t, uint8x8_t) > + > +/* > +** test_vtbl4_s8: > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl4_s8, int8x8_t, int8x8x4_t, int8x8_t) > + > +/* > +** test_vtbl4_u8: > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl4_u8, uint8x8_t, uint8x8x4_t, uint8x8_t) > + > +/* > +** test_vtbl4_p8: > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl4_p8, poly8x8_t, poly8x8x4_t, uint8x8_t) > + > +/* > +** test_vtbl4_mf8: > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_BINARY (vtbl4_mf8, mfloat8x8_t, mfloat8x8x4_t, uint8x8_t) > + > diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vtbx.c b/gcc/testsuite/gcc.target/aarch64/neon/vtbx.c > new file mode 100644 > index 000000000000..71db06b801e7 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/neon/vtbx.c > @@ -0,0 +1,178 @@ > +/* { dg-do compile } */ > +/* { dg-final { check-function-bodies "**" "" } } */ > + > +#include "arm_neon_test.h" > + > +/* > +** test_vtbx1_s8: > +** fmov d[0-9]+, d[0-9]+ > +** movi v[0-9]+\.8b, 0x7 > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** cmhs v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b > +** bit v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx1_s8, int8x8_t, int8x8_t, int8x8_t, int8x8_t) > + > +/* > +** test_vtbx1_u8: > +** fmov d[0-9]+, d[0-9]+ > +** movi v[0-9]+\.8b, 0x7 > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** cmhs v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b > +** bit v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx1_u8, uint8x8_t, uint8x8_t, uint8x8_t, uint8x8_t) > + > +/* > +** test_vtbx1_p8: > +** fmov d[0-9]+, d[0-9]+ > +** movi v[0-9]+\.8b, 0x7 > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** cmhs v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b > +** bit v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx1_p8, poly8x8_t, poly8x8_t, poly8x8_t, uint8x8_t) > + > +/* > +** test_vtbx1_mf8: > +** fmov d[0-9]+, d[0-9]+ > +** movi v[0-9]+\.8b, 0x7 > +** tbl v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** cmhs v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b > +** bit v[0-9]+\.8b, v[0-9]+\.8b, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx1_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x8_t, uint8x8_t) > + > + > +/* > +** test_vtbx2_s8: > +** sub sp, sp, #16 > +** stp d[0-9]+, d[0-9]+, \[sp\] > +** ldr q[0-9]+, \[sp\] > +** add sp, sp, 16 > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx2_s8, int8x8_t, int8x8_t, int8x8x2_t, int8x8_t) > + > +/* > +** test_vtbx2_u8: > +** sub sp, sp, #16 > +** stp d[0-9]+, d[0-9]+, \[sp\] > +** ldr q[0-9]+, \[sp\] > +** add sp, sp, 16 > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx2_u8, uint8x8_t, uint8x8_t, uint8x8x2_t, uint8x8_t) > + > +/* > +** test_vtbx2_p8: > +** sub sp, sp, #16 > +** stp d[0-9]+, d[0-9]+, \[sp\] > +** ldr q[0-9]+, \[sp\] > +** add sp, sp, 16 > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx2_p8, poly8x8_t, poly8x8_t, poly8x8x2_t, uint8x8_t) > + > +/* > +** test_vtbx2_mf8: > +** sub sp, sp, #16 > +** stp d[0-9]+, d[0-9]+, \[sp\] > +** ldr q[0-9]+, \[sp\] > +** add sp, sp, 16 > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx2_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x8x2_t, uint8x8_t) > + > +/* > +** test_vtbx3_s8: > +** fmov d([0-9]+), d[0-9]+ > +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** tbl v\2\.8b, {v\2\.16b - v\1\.16b}, v[0-9]+\.8b > +** movi v\1\.8b, 0x17 > +** cmhs v\1\.8b, v\1\.8b, v[0-9]+\.8b > +** bit v[0-9]+\.8b, v\2\.8b, v\1\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx3_s8, int8x8_t, int8x8_t, int8x8x3_t, int8x8_t) > + > +/* > +** test_vtbx3_u8: > +** fmov d([0-9]+), d[0-9]+ > +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** tbl v\2\.8b, {v\2\.16b - v\1\.16b}, v[0-9]+\.8b > +** movi v\1\.8b, 0x17 > +** cmhs v\1\.8b, v\1\.8b, v[0-9]+\.8b > +** bit v[0-9]+\.8b, v\2\.8b, v\1\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx3_u8, uint8x8_t, uint8x8_t, uint8x8x3_t, uint8x8_t) > + > +/* > +** test_vtbx3_p8: > +** fmov d([0-9]+), d[0-9]+ > +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** tbl v\2\.8b, {v\2\.16b - v\1\.16b}, v[0-9]+\.8b > +** movi v\1\.8b, 0x17 > +** cmhs v\1\.8b, v\1\.8b, v[0-9]+\.8b > +** bit v[0-9]+\.8b, v\2\.8b, v\1\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx3_p8, poly8x8_t, poly8x8_t, poly8x8x3_t, uint8x8_t) > + > +/* > +** test_vtbx3_mf8: > +** fmov d([0-9]+), d[0-9]+ > +** zip1 v([0-9]+)\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** tbl v\2\.8b, {v\2\.16b - v\1\.16b}, v[0-9]+\.8b > +** movi v\1\.8b, 0x17 > +** cmhs v\1\.8b, v\1\.8b, v[0-9]+\.8b > +** bit v[0-9]+\.8b, v\2\.8b, v\1\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx3_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x8x3_t, uint8x8_t) > + > +/* > +** test_vtbx4_s8: > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx4_s8, int8x8_t, int8x8_t, int8x8x4_t, int8x8_t) > + > +/* > +** test_vtbx4_u8: > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx4_u8, uint8x8_t, uint8x8_t, uint8x8x4_t, uint8x8_t) > + > +/* > +** test_vtbx4_p8: > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx4_p8, poly8x8_t, poly8x8_t, poly8x8x4_t, uint8x8_t) > + > +/* > +** test_vtbx4_mf8: > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** zip1 v[0-9]+\.2d, v[0-9]+\.2d, v[0-9]+\.2d > +** tbx v[0-9]+\.8b, {v[0-9]+\.16b - v[0-9]+\.16b}, v[0-9]+\.8b > +** ret > +*/ > +TEST_TERNARY (vtbx4_mf8, mfloat8x8_t, mfloat8x8_t, mfloat8x8x4_t, uint8x8_t) > + > diff --git a/gcc/testsuite/gcc.target/aarch64/simd/mf8_data_1.c b/gcc/testsuite/gcc.target/aarch64/simd/mf8_data_1.c > index e440b899f597..eddb548d7cf8 100644 > --- a/gcc/testsuite/gcc.target/aarch64/simd/mf8_data_1.c > +++ b/gcc/testsuite/gcc.target/aarch64/simd/mf8_data_1.c > @@ -1397,8 +1397,11 @@ mfloat8x8_t test_tbl1(mfloat8x8_t a, uint8x8_t b) > > /* > ** test_tbl2: > -** zip1 v([0-9]+).2d, v0.2d, v1.2d > +** sub sp, sp, #16 > +** stp d0, d1, \[sp\] > +** ldr q([0-9]+), \[sp\] > ** tbl v0.8b, {v\1.16b}, v2.8b > +** add sp, sp, 16 > ** ret > */ > mfloat8x8_t test_tbl2(mfloat8x8x2_t a, uint8x8_t b) > @@ -1526,8 +1529,11 @@ mfloat8x8_t test_tbx1(mfloat8x8_t a, mfloat8x8_t b, uint8x8_t c) > > /* > ** test_tbx2: > -** zip1 v([0-9]+).2d, v1.2d, v2.2d > -** tbx v[0-9]+.8b, {v\1.16b}, v3.8b > +** sub sp, sp, #16 > +** stp d1, d2, \[sp\] > +** ldr q([0-9]+), \[sp\] > +** tbx v0.8b, {v\1.16b}, v3.8b > +** add sp, sp, 16 > ** ret > */ > mfloat8x8_t test_tbx2(mfloat8x8_t a, mfloat8x8x2_t b, uint8x8_t c) This is a codegen regression, please fix From 16567adigashreesh@gmail.com Mon Nov 2 16:48:33 2026 From: 16567adigashreesh@gmail.com (Shreesh Adiga) Date: Mon, 2 Nov 2026 22:18:33 +0530 Subject: [PATCH 1/2] middle-end: Fix CRC computation for 24-iteration loops [PR127984] Message-ID: <20261102164834.532328-1-16567adigashreesh@gmail.com> The CRC optimization incorrectly recognizes loops with 24 iterations as valid CRC calculation loops and generates code to compute 32-iterations using __builtin_crc32_data32 which is incorrect transformation. Remove support for 24-iteration loops from the CRC loop iteration count check, since such loops should not be considered by this optimization. PR middle-end/127984 gcc/ChangeLog: * gimple-crc-optimization.cc (class crc_optimization): Updated comments to remove 24. (crc_optimization::loop_contains_two_conditional_bb): Updated comments to remove 24. (crc_optimization::satisfies_crc_loop_iteration_count): Updated the check to avoid 24-iteration loops. gcc/testsuite/ChangeLog: * gcc.dg/pr127984.c: New test. Signed-off-by: Shreesh Adiga <16567adigashreesh@gmail.com> --- gcc/gimple-crc-optimization.cc | 11 +++++------ gcc/testsuite/gcc.dg/pr127984.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr127984.c diff --git a/gcc/gimple-crc-optimization.cc b/gcc/gimple-crc-optimization.cc index ec985148e08..4c9c08a0ac0 100644 --- a/gcc/gimple-crc-optimization.cc +++ b/gcc/gimple-crc-optimization.cc @@ -74,7 +74,7 @@ class crc_optimization { /* This is the main function that checks whether the given LOOP calculates CRC and extracts details of the CRC calculation. - The main idea is to find the innermost loop with 8, 16, 24, 32, 64 + The main idea is to find the innermost loop with 8, 16, 32, 64 iterations and xor instruction (xor is the key operation for naive CRC calculation). Then, checks that the variable is shifted by one before/after being used in xor. @@ -98,7 +98,7 @@ class crc_optimization { unsigned loop_num_nodes); /* Checks the FUNC_LOOP loop's iteration number. - The loop for CRC calculation may do 8, 16, 24, 32, 64 iterations. */ + The loop for CRC calculation may do 8, 16, 32, 64 iterations. */ bool satisfies_crc_loop_iteration_count (class loop *func_loop); /* This function checks if the XOR_STMT is used for CRC calculation. @@ -885,7 +885,7 @@ crc_optimization::loop_contains_two_conditional_bb (basic_block *loop_bbs, } /* Checks the FUNC_LOOP loop's iteration number. - The loop for CRC calculation may do 8, 16, 24, 32, 64 iterations. */ + The loop for CRC calculation may do 8, 16, 32, 64 iterations. */ bool crc_optimization::satisfies_crc_loop_iteration_count (class loop *func_loop) @@ -911,8 +911,7 @@ crc_optimization::satisfies_crc_loop_iteration_count (class loop *func_loop) HOST_WIDE_INT_PRINT_UNSIGNED ".\n", loop_iteration_number); if ((loop_iteration_number == 7 || loop_iteration_number == 15 - || loop_iteration_number == 23 || loop_iteration_number == 31 - || loop_iteration_number == 63)) + || loop_iteration_number == 31 || loop_iteration_number == 63)) return true; } if (stderr && (dump_flags & TDF_DETAILS)) @@ -923,7 +922,7 @@ crc_optimization::satisfies_crc_loop_iteration_count (class loop *func_loop) /* This is the main function that checks whether the given LOOP calculates CRC and extracts details of the CRC calculation. - The main idea is to find the innermost loop with 8, 16, 24, 32, 64 + The main idea is to find the innermost loop with 8, 16, 32, 64 iterations and xor instruction (xor is the key operation for naive CRC calculation). Then, checks that the variable is shifted by one before/after being used in xor. diff --git a/gcc/testsuite/gcc.dg/pr127984.c b/gcc/testsuite/gcc.dg/pr127984.c new file mode 100644 index 00000000000..8f08185d612 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr127984.c @@ -0,0 +1,15 @@ +/* PR middle-end/127984 */ +/* { dg-options "-O2" } */ +/* { dg-do run } */ + +__attribute__((noipa)) unsigned f(unsigned crc) { + for (int i = 0; i < 24; i++) { + if (crc & 1) crc = (crc >> 1) ^ 0xEDB88320; else crc >>= 1; + } + return crc; +} + +int main(void) { + if (f(0xFFFFFFFF) != 0xBE26ED) + __builtin_abort(); +} -- 2.56.0 From 16567adigashreesh@gmail.com Mon Nov 2 16:48:34 2026 From: 16567adigashreesh@gmail.com (Shreesh Adiga) Date: Mon, 2 Nov 2026 22:18:34 +0530 Subject: [PATCH 2/2] middle-end: Validate CRC size and reject 128-bit CRC loop optimization [PR127335] In-Reply-To: <20261102164834.532328-1-16567adigashreesh@gmail.com> References: <20261102164834.532328-1-16567adigashreesh@gmail.com> Message-ID: <20261102164834.532328-2-16567adigashreesh@gmail.com> The CRC optimization does not support CRC calculations with a precision greater than 64 bits. Reject CRC calculations where the precision of the CRC argument exceeds 64 bits, preventing the optimization from processing larger CRC sizes. This prevents ICE (`tree_to_uhwi`) on a > 2^64 polynomial constant. PR middle-end/127335 gcc/ChangeLog: * gimple-crc-optimization.cc (crc_optimization::validate_crc_and_data): Validated CRC size and reject >64 bits CRC optimization. gcc/testsuite/ChangeLog: * gcc.dg/pr127335.c: New test. Signed-off-by: Shreesh Adiga <16567adigashreesh@gmail.com> --- gcc/gimple-crc-optimization.cc | 8 ++++++++ gcc/testsuite/gcc.dg/pr127335.c | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr127335.c diff --git a/gcc/gimple-crc-optimization.cc b/gcc/gimple-crc-optimization.cc index 4c9c08a0ac0..4e28ec5ecc1 100644 --- a/gcc/gimple-crc-optimization.cc +++ b/gcc/gimple-crc-optimization.cc @@ -1123,6 +1123,14 @@ bool crc_optimization::validate_crc_and_data () if (TYPE_PRECISION (TREE_TYPE (m_crc_arg)) < data_size) return false; + /* We don't support the case where CRC size is larger than 64. */ + if (TYPE_PRECISION (TREE_TYPE (m_crc_arg)) > 64) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "CRC size is bigger than 64, skipping.\n"); + return false; + } + /* Set m_data_arg if a PHI node for data exists, and check its size against loop iterations. This is the case when data and CRC are XOR-ed in the loop. */ diff --git a/gcc/testsuite/gcc.dg/pr127335.c b/gcc/testsuite/gcc.dg/pr127335.c new file mode 100644 index 00000000000..dcc79580b8e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr127335.c @@ -0,0 +1,16 @@ +/* PR middle-end/127335 */ +/* { dg-options "-O2" } */ +typedef unsigned __int128 u128; + +u128 crc128 (u128 seed) +{ + u128 c = seed; + for (int k = 0; k < 8; k++) + { + if (c & 1) + c = (((u128) 0xedb88320edb88320ULL << 64) | 0x1234567890abcdefULL) ^ (c >> 1); + else + c = c >> 1; + } + return c; +} -- 2.56.0 From jakub@redhat.com Mon Nov 2 16:57:25 2026 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 2 Nov 2026 17:57:25 +0100 Subject: [PATCH] libstdc++: Export apply_result, is_applicable, and is_nothrow_applicable from std module In-Reply-To: <20261029171541.923427-4-tkaminsk@redhat.com> References: <20261029171541.923427-1-tkaminsk@redhat.com> <20261029171541.923427-4-tkaminsk@redhat.com> Message-ID: On Thu, Oct 29, 2026 at 05:53:49PM +0100, Tomasz Kami?ski wrote: > This implements C++26 paper: P1317R2, "Remove return type deduction > in std::apply". > > The traits are implemented in terms of __(noexcept_)?unpack_tuple_like_v > machinery, in consequence the definitions of corresponding primary templates > are moved to . Partial specializations remain defined in > bits/stl_pair.h and bits/range_utils.h, i.e. with of before definitions > of corresponding types, which guarantees that they are visible at point > of instantiation depending on them. > > While query trait is_applicable, is_nothrow_applicable could be expressed > in terms of __(noexcept_)?unpack_tuple_like_v that produces boolean value, > apply_result requires unpacking tuple to invoke_result. To handle above, > __unpack_tuple_like_impl is introduced, whose value is object of trait > type (false_type for non tuple like), and thus does not require presence > of value member. Thanks for working on this. This patch regresses FAIL: g++.dg/plugin/std-module-exports-c++26.C -fplugin=./std_module_exports_plugin.so (test for excess errors) FAIL: g++.dg/plugin/std-module-exports-c++29.C -fplugin=./std_module_exports_plugin.so (test for excess errors) Here is an incremental fix for that, tested on x86_64-linux, ok for trunk if this series is approved? 2026-11-02 Jakub Jelinek * src/c++23/std.cc.in (std::apply_result, std::apply_result_t, std::is_applicable, std::is_applicable_v, std::is_nothrow_applicable, std::is_nothrow_applicable_v): New exports for C++26. --- a/libstdc++-v3/src/c++23/std.cc.in 2026-10-14 11:17:48.208100670 +0200 +++ b/libstdc++-v3/src/c++23/std.cc.in 2026-11-02 17:40:18.478850112 +0100 @@ -3626,6 +3626,14 @@ export namespace std #if __cpp_lib_within_lifetime >= 202306L using std::is_within_lifetime; #endif +#if __cpp_lib_apply >= 202506L + using std::apply_result; + using std::apply_result_t; + using std::is_applicable; + using std::is_applicable_v; + using std::is_nothrow_applicable; + using std::is_nothrow_applicable_v; +#endif } // Jakub From jakub@redhat.com Mon Nov 2 17:00:09 2026 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 2 Nov 2026 18:00:09 +0100 Subject: [PATCH 0/4] Nits & testsuite updates OpenMP barrier patches In-Reply-To: <20261102162514.3475056-1-mmalcomson@nvidia.com> References: <20261012170038.3418851-1-mmalcomson@nvidia.com> <20261102162514.3475056-1-mmalcomson@nvidia.com> Message-ID: On Mon, Nov 02, 2026 at 04:25:10PM +0000, mmalcomson@nvidia.com wrote: > After applying the nits that Jakub requested I figured it worth > double-checking that the names still seem sensible to others. > > Similarly I've removed the linux_futex_waitv effective target requests > on those testcases that my agent believes cover untested areas in > existing targets -- done after Thomas raised the question here: > https://gcc.gnu.org/pipermail/gcc-patches/2026-October/736854.html > > To highlight the name changes: > 1) I switched from `gomp_barrier_state_is_incremented` to > `gomp_barrier_incremented`. This manages to avoid the need to leave > the opening parenthesis on quite a few assertions. > 2) I switched the function names using `centralized` to use `central`. > N.b. I did not change the environment variable setting in the same > way since searching the web for "centralized barrier" comes up with > the algorithm this barrier uses while searching for "central barrier" > does not. Figured the longer name was easier for users. > 3) Switching `gomp_barrier_canc_wait` to `gomp_barrier_wait_n`. Again, > helps with formatting to avoid the opening parenthesis at the end of > the line in some calls. > > Things I'd like to double-check with others: > 1) Are these function names OK with people? > Since I was trying to address style nits I figured I should check I > wasn't introducing other style nits before pushing. > 2) Does the decision around the linux_futex_waitv effective target seem > good to others? > > Have re-tested to avoid any typo problems etc. > > Matthew Malcomson (4): > libgomp: Inline `gomp_barrier_is_incremented` > libgomp: New barriers in new linux/futex_waitv target > libgomp: Add focused barrier and team-lifecycle tests > libgomp: Parallelise thread {re-,}initialisation Ok for the series. Jakub From jwakely@redhat.com Mon Nov 2 17:04:31 2026 From: jwakely@redhat.com (Jonathan Wakely) Date: Mon, 2 Nov 2026 17:04:31 +0000 Subject: [PATCH] libstdc++: Export apply_result, is_applicable, and is_nothrow_applicable from std module In-Reply-To: References: <20261029171541.923427-1-tkaminsk@redhat.com> <20261029171541.923427-4-tkaminsk@redhat.com> Message-ID: On Mon, 2 Nov 2026 at 16:57, Jakub Jelinek wrote: > > On Thu, Oct 29, 2026 at 05:53:49PM +0100, Tomasz Kami?ski wrote: > > This implements C++26 paper: P1317R2, "Remove return type deduction > > in std::apply". > > > > The traits are implemented in terms of __(noexcept_)?unpack_tuple_like_v > > machinery, in consequence the definitions of corresponding primary templates > > are moved to . Partial specializations remain defined in > > bits/stl_pair.h and bits/range_utils.h, i.e. with of before definitions > > of corresponding types, which guarantees that they are visible at point > > of instantiation depending on them. > > > > While query trait is_applicable, is_nothrow_applicable could be expressed > > in terms of __(noexcept_)?unpack_tuple_like_v that produces boolean value, > > apply_result requires unpacking tuple to invoke_result. To handle above, > > __unpack_tuple_like_impl is introduced, whose value is object of trait > > type (false_type for non tuple like), and thus does not require presence > > of value member. > > Thanks for working on this. > > This patch regresses > FAIL: g++.dg/plugin/std-module-exports-c++26.C -fplugin=./std_module_exports_plugin.so (test for excess errors) > FAIL: g++.dg/plugin/std-module-exports-c++29.C -fplugin=./std_module_exports_plugin.so (test for excess errors) > > Here is an incremental fix for that, tested on x86_64-linux, > ok for trunk if this series is approved? Conditionally OK - thanks > > 2026-11-02 Jakub Jelinek > > * src/c++23/std.cc.in (std::apply_result, std::apply_result_t, > std::is_applicable, std::is_applicable_v, std::is_nothrow_applicable, > std::is_nothrow_applicable_v): New exports for C++26. > > --- a/libstdc++-v3/src/c++23/std.cc.in 2026-10-14 11:17:48.208100670 +0200 > +++ b/libstdc++-v3/src/c++23/std.cc.in 2026-11-02 17:40:18.478850112 +0100 > @@ -3626,6 +3626,14 @@ export namespace std > #if __cpp_lib_within_lifetime >= 202306L > using std::is_within_lifetime; > #endif > +#if __cpp_lib_apply >= 202506L > + using std::apply_result; > + using std::apply_result_t; > + using std::is_applicable; > + using std::is_applicable_v; > + using std::is_nothrow_applicable; > + using std::is_nothrow_applicable_v; > +#endif > } > > // > > > Jakub > From vineet.gupta@linux.dev Mon Nov 2 17:18:47 2026 From: vineet.gupta@linux.dev (Vineet Gupta) Date: Mon, 2 Nov 2026 09:18:47 -0800 Subject: [PATCH] gcse: Don't hoist an expression across a jump that modifies it [PR127847] In-Reply-To: References: <20261013025133.2628132-1-vineet.gupta@linux.dev> <3fc445aa-8142-437f-9b6b-bf701c24430a@oss.qualcomm.com> Message-ID: <02efeafd-2705-4d29-9e09-31f980838fdf@linux.dev> On 11/1/26 8:34 PM, Jeff Law wrote: > On 10/23/26 5:45 PM, Vineet Gupta wrote: >> It seems prune_expressions is for pruning blocks with an incoming >> abnormal edge. the right place for this handling. asm goto has >> ordinary edges: bb 2 -> bb 3 is fallthru and bb 2 -> bb 4 (label) has >> no flags. > Correct, but it's going to be hard to split edges out of an asm goto. > So in many respects it's like an abnormal, hence the desire to use those > mechansisms rth put into gcse.c so many years ago. > >> In fact looking in prune_expressions' comment, >> >> " It would >> ? be best to implement this check along the lines of >> ? should_hoist_expr_to_dom where the target block is already known >> ? and, hence, there's no need to conservatively prune expressions on >> ? "intermediate" set-and-jump instructions." >> >> which is what this patch does. > Oh ;-)? You can tell it's been a long time since I looked at this stuff. :-) So it seems that we have explored the solution space and IMO the proposed patch is better suited than prune_expressions. If not, I'm happy to try any other things that you want looked at or ruled out. Thx, -Vineet From vineet.gupta@linux.dev Mon Nov 2 17:22:03 2026 From: vineet.gupta@linux.dev (Vineet Gupta) Date: Mon, 2 Nov 2026 09:22:03 -0800 Subject: [PATCH v4] combine: Don't put two volatile reads into one insn [PR127851] In-Reply-To: <54200047-510f-47b4-8763-3793266814fe@oss.qualcomm.com> References: <20261013084407.2984553-1-vineet.gupta@linux.dev> <20261014052122.3454958-1-vineet.gupta@linux.dev> <20261014091527.3620282-1-vineet.gupta@linux.dev> <051ba417-99ec-4cc8-8407-7205334b3e3f@oss.qualcomm.com> <20261021211758.3144964-1-vineet.gupta@linux.dev> <63aa2519-de41-4fd3-bd3b-b5389a5759ae@oss.qualcomm.com> <9ba9fbcf-b21d-44c8-bf2b-7f90d68d21f4@linux.dev> <54200047-510f-47b4-8763-3793266814fe@oss.qualcomm.com> Message-ID: On 11/1/26 8:31 PM, Jeff Law wrote: >>>>> FYI, the i386.md fix was specific to compare patterns, and as Jeff >>>>> pointed out, that approach results in a maintenance hell, as it >>>>> requires manually changing all RTX patterns that accept two or more >>>>> memory operands with the insn check that allows at most one volatile >>>>> operand. AFAICS, the same effect can be achieved in recog_for_combine >>>>> with some RTX walker that rejects invalid RTXes at the point of >>>>> recognition. I don't know if this is the most optimal solution, but as >>>>> shown with my i386.md experiment, it works. >>>> Eh, no. Combine can split insns internally, and we have to reject >>>> combined insns with multiple volatile ops before they get split. >>> Feels like we need to catch this class of problems when we have the >>> unaltered i0..i3.? There's a ton of code to reject classes of >>> combinations that aren't going to work for some reason or another, this >>> feels like just another set of constraints to encode there.? Of course, >>> I'm not inside the code, so I may be drastically oversimplifying. >> For v5 which I have currently tested (and bootstrapped on x86 and >> arm64) this is done post split and it allows the split results only if >> the orig order is maintained for which it needs to snapshot the order >> before. >> >> What Uros and you are suggesting here is to check pre-split and if I >> understand correctly reject whenever the combine pattern has volatile >> reads from two different insns, w/o worrying about the ordering at all >> ? This might actually be simpler, as it avoids the snapshoting. Let me >> give this a try. >> >> But in the mean time I can send out v5 as it now. > I was coming at it from the angle of you can't know order once you start > those SUBST calls.? So ISTM that you want to check fairly early. The v5 posted at [1] does it super early. Thx, -Vineet [1] https://inbox.sourceware.org/gcc-patches/20261023202208.1952060-1-vineet.gupta@linux.dev/ From tkaminsk@redhat.com Mon Nov 2 17:40:05 2026 From: tkaminsk@redhat.com (Tomasz Kaminski) Date: Mon, 2 Nov 2026 18:40:05 +0100 Subject: [PATCH 3/3] libstdc++: Fix another buffer overflow in basic_filebuf::overflow [PR118099] In-Reply-To: References: <20261023174023.845748-1-jwakely@redhat.com> <20261023174023.845748-3-jwakely@redhat.com> Message-ID: On Mon, Nov 2, 2026 at 4:54?PM Jonathan Wakely wrote: > On Mon, 2 Nov 2026 at 15:30, Tomasz Kaminski wrote: > > > > > > > > On Fri, Oct 23, 2026 at 7:43?PM Jonathan Wakely > wrote: > >> > >> The initial fix for PR 118099 handled the case where writing the pending > >> output sequence to the external file failed and _M_convert_to_external > >> returned false. But _M_convert_to_external can also fail by throwing an > >> exception in which case the same bug exists: the put area's next pointer > >> (i.e. pptr) has already been advanced and is not rewound when > >> basic_filebuf::overflow exits via an exception. As in the PR 118099 > >> testcase, the caller is left with pptr set past epptr, and successive > >> calls to overflow will write further past the end of the managed buffer > >> with each failure. > > > > This should go to _Guard 1/3 commit, as it will be also fixed. > >> > >> > >> This commit fixes it by not advancing the put area's next pointer at > >> all, instead we just increment the size passed to _M_convert_to_external > >> to account for the extra character in the put area. This relies on the > >> previous commit which changed _M_convert_to_external to no longer use > >> pptr() internally (when retrying after a partial codecvt conversion). > >> If _M_convert_to_external was still looking at pptr() directly and > >> expecting it to have been bumped then we could not change overflow to no > >> longer bump it. > >> > >> Because this change depends on that fix in _M_convert_to_external there > >> is a potential ABI issue that needs care. If the new bump-less version > >> of basic_filebuf::overflow gets inlined into a translation unit but the > >> linker resolves its call to _M_convert_to_external to an old definition > >> that still calls pptr(), we would not transfer the overflow character to > >> the external file when retrying after a partial conversion. Although > >> this scenario seems unlikely because std::filebuf and std::wfilebuf are > >> both explicitly instantiated in libstdc++.so (and the explicit > >> instantiations use the new definition of _M_convert_to_external) it > >> would be safer to ensure the problem cannot occur. > >> > >> This commit adds an _M_convert_to_external(const _CharT*, streamsize) > >> overload which takes a const pointer, and changes overflow to use that > >> instead. This ensures that the new bump-less overflow uses a new symbol > >> with the new behaviour, and will never bind to an old definition that > >> inspects pptr(). The old overload taking a non-const pointer needs to be > >> preserved for ABI compatibility, but can be defined to simply forward > >> its arguments (after a const_cast) to the new overload. With this > >> change, instantiations of the old version of overflow can safely bind to > >> either the old definition of _M_convert_to_external (which calls pptr()) > >> or the new definition (which doesn't) because both definitions are > >> compatible with the old overflow. Instantiations of the new version of > >> overflow will only ever bind to the new overload because it has a > >> different mangled name. > >> > >> The failing_codecvt in the new test was generated by an LLM because I > >> was too lazy to remember how to write codecvt facets. > >> > >> Assisted-by: LLM > >> > >> libstdc++-v3/ChangeLog: > >> > >> PR libstdc++/118099 > >> * config/abi/pre/gnu.ver: Tighten old patterns for basic_filebuf > >> and export new symbols. > >> * include/bits/fstream.tcc (basic_filebuf::overflow): Do not > >> bump the next pointer for the overflow character. Pass const > >> pointers to _M_convert_to_external. > >> (_M_convert_to_external(_CharT*, streamsize)): Forward to new > >> overload. > >> (_M_convert_to_external(const _CharT*, streamsize)): Define new > >> overload. > >> * include/std/fstream (_M_convert_to_external): Define new > >> overload and suppress old overload for _GLIBCXX_INLINE_VERSION. > >> * testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc: > >> New test. > >> * > testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc: > >> New test. > >> --- > >> > >> Tested x86_64-linux. > > > > Some minor comments, looks good to me with them fixed. > >> > >> > >> libstdc++-v3/config/abi/pre/gnu.ver | 7 +- > >> libstdc++-v3/include/bits/fstream.tcc | 120 +++++++++--------- > >> libstdc++-v3/include/std/fstream | 7 +- > >> .../overflow/char/118099-codecvt.cc | 76 +++++++++++ > >> .../overflow/wchar_t/118099-codecvt.cc | 76 +++++++++++ > >> 5 files changed, 224 insertions(+), 62 deletions(-) > >> create mode 100644 > libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc > >> create mode 100644 > libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc > >> > >> diff --git a/libstdc++-v3/config/abi/pre/gnu.ver > b/libstdc++-v3/config/abi/pre/gnu.ver > >> index 4fbb87acee3f..d846ce6d3e36 100644 > >> --- a/libstdc++-v3/config/abi/pre/gnu.ver > >> +++ b/libstdc++-v3/config/abi/pre/gnu.ver > >> @@ -434,7 +434,9 @@ GLIBCXX_3.4 { > >> _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE15*; > >> _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE16*; > >> _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE19*; > >> - _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE2*; > >> + > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE22_M_convert_to_externalEP[cw][ilx]; > >> + > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE26_M_destroy_internal_buffer*; > >> + > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE27_M_allocate_internal_buffer*; > >> _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE3*; > >> _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE4openEPKc*; > >> _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE4sync*; > >> @@ -2641,6 +2643,9 @@ GLIBCXX_3.4.37 { > >> > _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE*_S_allocate_*; > >> > _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE*_M_create_*; > >> > >> + # basic_filebuf::_M_convert_to_external(const C*, streamsize) > >> + > _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE22_M_convert_to_externalEPK[cw][ilx]; > >> + > >> } GLIBCXX_3.4.36; > >> > >> # Symbols in the support library (libsupc++) have their own tag. > >> diff --git a/libstdc++-v3/include/bits/fstream.tcc > b/libstdc++-v3/include/bits/fstream.tcc > >> index 5d13633b6841..427e7b3a0c43 100644 > >> --- a/libstdc++-v3/include/bits/fstream.tcc > >> +++ b/libstdc++-v3/include/bits/fstream.tcc > >> @@ -561,23 +561,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > >> } > >> if (this->pbase() < this->pptr()) > >> { > >> + streamsize __n = this->pptr() - this->pbase(); > >> + > >> // If appropriate, append the overflow char. > >> if (!__testeof) > >> { > >> *this->pptr() = traits_type::to_char_type(__c); > >> - this->pbump(1); > >> + ++__n; > >> } > >> > >> + // This must be const _CharT* to call the right overload. > >> + const _CharT* __p = this->pbase(); > > > > The overload based on cost is sneaky here, but I do not have much better > idea. > >> > >> + > >> // Convert pending sequence to external representation, > >> - // and output. > >> - if (_M_convert_to_external(this->pbase(), > >> - this->pptr() - this->pbase())) > >> + // and output. Include the overflow char if appropriate. > >> + if (_M_convert_to_external(__p, __n)) > >> { > >> _M_set_buffer(0); > >> __ret = traits_type::not_eof(__c); > >> } > >> - else if (!__testeof) > >> - this->pbump(-1); > >> } > >> else if (_M_buf_size > 1) > >> { > >> @@ -596,7 +598,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > >> else > >> { > >> // Unbuffered. > >> - char_type __conv = traits_type::to_char_type(__c); > >> + const char_type __conv = traits_type::to_char_type(__c); > > > > Could you add a comment here, about selecting overloads? > >> > >> if (__testeof || _M_convert_to_external(&__conv, 1)) > >> { > >> _M_writing = true; > >> @@ -607,65 +609,63 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > >> return __ret; > >> } > >> > >> + template > >> + bool > >> + basic_filebuf<_CharT, _Traits>:: > >> + _M_convert_to_external(const _CharT* __ibuf, streamsize __ilen) > >> + { > >> + if (__check_facet(_M_codecvt).always_noconv()) > >> + return _M_file.xsputn(reinterpret_cast(__ibuf), > __ilen) > >> + == __ilen; > >> + > >> + // Worst-case number of external bytes needed. > >> + // XXX Not done encoding() == -1. > >> + const streamsize __maxlen = __ilen * _M_codecvt->max_length(); > >> + char* const __buf = > static_cast(__builtin_alloca(__maxlen)); > >> + streamsize __blen = __maxlen; > >> + > >> + char* __bend; > >> + const char_type* __iend; > >> + codecvt_base::result __r; > >> + __r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen, > >> + __iend, __buf, __buf + __blen, __bend); > >> + __blen = __bend - __buf; > >> + > >> + if (__r == codecvt_base::ok) > >> + return _M_file.xsputn(__buf, __blen) == __blen; > >> + else if (__r == codecvt_base::noconv) > >> + return _M_file.xsputn(reinterpret_cast(__ibuf), > __ilen) > >> + == __ilen; > >> + else if (__r == codecvt_base::error) > >> + __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " > >> + "conversion error")); > >> + > >> + // Conversion was partial, some output is in __buf. > >> + if (_M_file.xsputn(__buf, __blen) != __blen) > >> + return false; > >> + > >> + // Try once more for partial conversions. > >> + __r = _M_codecvt->out(_M_state_cur, __iend, __ibuf + __ilen, > >> + __iend, __buf, __buf + __maxlen, __bend); > >> + > >> + if (__r == codecvt_base::error) > >> + __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " > >> + "conversion error")); > >> + > >> + __blen = __bend - __buf; > >> + return _M_file.xsputn(__buf, __blen) == __blen; > >> + } > >> + > >> +#if ! _GLIBCXX_INLINE_VERSION > >> + // Prior to GCC 17 basic_filebuf::overflow called this overload. > >> template > >> bool > >> basic_filebuf<_CharT, _Traits>:: > >> _M_convert_to_external(_CharT* __ibuf, streamsize __ilen) > >> { > >> - // Sizes of external and pending output. > >> - streamsize __elen; > >> - streamsize __plen; > >> - if (__check_facet(_M_codecvt).always_noconv()) > >> - { > >> - __elen = _M_file.xsputn(reinterpret_cast(__ibuf), > __ilen); > >> - __plen = __ilen; > >> - } > >> - else > >> - { > >> - // Worst-case number of external bytes needed. > >> - // XXX Not done encoding() == -1. > >> - streamsize __blen = __ilen * _M_codecvt->max_length(); > >> - char* __buf = static_cast(__builtin_alloca(__blen)); > >> - > >> - char* __bend; > >> - const char_type* __iend; > >> - codecvt_base::result __r; > >> - __r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen, > >> - __iend, __buf, __buf + __blen, __bend); > >> - > >> - if (__r == codecvt_base::ok || __r == codecvt_base::partial) > >> - __blen = __bend - __buf; > >> - else if (__r == codecvt_base::noconv) > >> - { > >> - // Same as the always_noconv case above. > >> - __buf = reinterpret_cast(__ibuf); > >> - __blen = __ilen; > >> - } > >> - else > >> - > __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " > >> - "conversion error")); > >> - > >> - __elen = _M_file.xsputn(__buf, __blen); > >> - __plen = __blen; > >> - > >> - // Try once more for partial conversions. > >> - if (__r == codecvt_base::partial && __elen == __plen) > >> - { > >> - __r = _M_codecvt->out(_M_state_cur, __iend, __ibuf + > __ilen, > >> - __iend, __buf, __buf + __blen, > __bend); > >> - if (__r != codecvt_base::error) > >> - { > >> - const streamsize __rlen = __bend - __buf; > >> - __elen = _M_file.xsputn(__buf, __rlen); > >> - __plen = __rlen; > >> - } > >> - else > >> - > __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " > >> - "conversion error")); > >> - } > >> - } > >> - return __elen == __plen; > >> + return _M_convert_to_external(const_cast(__ibuf), > __ilen); > > > > I do not think that const_cast is needed here, we are only adding const. > > Without the cast the call becomes recursive. > I meant we can do static_cast here, when I see const_cast, I think of casting const away. > > > Since we are only adding const, > > single return, I would define this function inline in the fstream class > body. That should not affect if the symbol > > is emitted from the extern template specialization, and we are never > calling it, so it should not be emmitted. > > Yes, I can do that. We still need a cast though. > > >> > >> } > >> +#endif > >> > >> template > >> streamsize > >> diff --git a/libstdc++-v3/include/std/fstream > b/libstdc++-v3/include/std/fstream > >> index 653d417c6288..9549638205ad 100644 > >> --- a/libstdc++-v3/include/std/fstream > >> +++ b/libstdc++-v3/include/std/fstream > >> @@ -436,10 +436,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > >> virtual int_type > >> overflow(int_type __c = _Traits::eof()); > >> > >> - // Convert internal byte sequence to external, char-based > >> + // Convert internal _CharT sequence to external, char-based > >> // sequence via codecvt. > >> + bool > >> + _M_convert_to_external(const char_type*, streamsize); > >> + > >> +#if ! _GLIBCXX_INLINE_VERSION // ABI compat > >> bool > >> _M_convert_to_external(char_type*, streamsize); > >> +#endif > >> > >> /** > >> * @brief Manipulates the buffer. > >> diff --git > a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc > b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc > >> new file mode 100644 > >> index 000000000000..99645e810975 > >> --- /dev/null > >> +++ > b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/118099-codecvt.cc > > > > This test should be also moved to first _Guard commit. > >> > >> @@ -0,0 +1,76 @@ > >> +// { dg-do run } > >> +// { dg-require-fileio "" } > >> + > >> +// PR libstdc++/118099 > >> +// basic_filebuf::overflow leaves streambuf in inconsistent state on > I/O error > >> +// > >> +// Companion test of 118099.cc testing the throwing failure path in > overflow: > >> +// a codecvt whose do_out always returns error makes > _M_convert_to_external > >> +// throw after the overflow character has been written to the end of > put area. > >> +// If the put pointer is advanced before the throw (and only rewound > on the > >> +// non-throwing error path), a caller that catches the exception and > keeps > >> +// writing will cause overflow(c) to write past the end of the managed > buffer, > >> +// just like the original PR libstdc++/118099 testcase. > >> + > >> +#include > >> +#include > >> +#include > >> + > >> +typedef char C; > >> + > >> +struct failing_codecvt : std::codecvt > >> +{ > >> +protected: > >> + result > >> + do_out(state_type&, const intern_type* from, const intern_type*, > >> + const intern_type*& from_next, > >> + extern_type* to, extern_type*, extern_type*& to_next) const > >> + { > >> + from_next = from; > >> + to_next = to; > >> + return error; > >> + } > >> + > >> + bool do_always_noconv() const throw() { return false; } > >> +}; > >> + > >> +static void > >> +test_pr118099_codecvt() > >> +{ > >> + const C val = C('x'); > >> + const C canary = ~val; > >> + const int N = 16; > >> + C buf[N]; > >> + for (int i = 0; i < N; ++i) > >> + buf[i] = canary; > >> + > >> + std::basic_filebuf fb; > >> + fb.pubimbue(std::locale(std::locale::classic(), new > failing_codecvt)); > >> + fb.pubsetbuf(buf, N/2); // filebuf can use buf[0..7] > >> + fb.open("tmp_118099_codecvt", std::ios_base::out | > std::ios_base::trunc); > >> + VERIFY( fb.is_open() ); > >> + > >> + // Libstdc++ filebuf throws ios::failure for the codecvt error, > >> + // but the standard allows overflow to return eof instead. > >> + // To make this test portable, we check for either kind of error. > >> + bool got_error = false; > >> + for (int i = 0; i < N; ++i) > > > > I would again split this into two separate loops: one up to N/2, if we > do not > > get eof. And a second loop counting errors, and verifying there are N/2 > of them. > >> > >> + try { > >> + std::char_traits::int_type r = fb.sputc(val); > >> + if (std::char_traits::eq_int_type(r, > std::char_traits::eof())) > >> + got_error = true; > >> + } catch (const std::exception&) { > >> + got_error = true; > >> + } > >> + VERIFY( got_error ); // a codecvt error actually happened > >> + > >> + for (int i = 0; i < N/2; ++i) > >> + VERIFY( buf[i] == val ); > >> + for (int i = N/2; i < N; ++i) > >> + VERIFY( buf[i] == canary ); // nothing was written past buf[0..7] > >> +} > >> + > >> +int main() > >> +{ > >> + test_pr118099_codecvt(); > >> +} > >> diff --git > a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc > b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc > >> new file mode 100644 > >> index 000000000000..27420006fada > >> --- /dev/null > >> +++ > b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/118099-codecvt.cc > >> @@ -0,0 +1,76 @@ > >> +// { dg-do run } > >> +// { dg-require-fileio "" } > >> + > >> +// PR libstdc++/118099 > >> +// basic_filebuf::overflow leaves streambuf in inconsistent state on > I/O error > >> +// > >> +// Companion test of 118099.cc testing the throwing failure path in > overflow: > >> +// a codecvt whose do_out always returns error makes > _M_convert_to_external > >> +// throw after the overflow character has been written to the end of > put area. > >> +// If the put pointer is advanced before the throw (and only rewound > on the > >> +// non-throwing error path), a caller that catches the exception and > keeps > >> +// writing will cause overflow(c) to write past the end of the managed > buffer, > >> +// just like the original PR libstdc++/118099 testcase. > >> + > >> +#include > >> +#include > >> +#include > >> + > >> +typedef wchar_t C; > >> + > >> +struct failing_codecvt : std::codecvt > >> +{ > >> +protected: > >> + result > >> + do_out(state_type&, const intern_type* from, const intern_type*, > >> + const intern_type*& from_next, > >> + extern_type* to, extern_type*, extern_type*& to_next) const > >> + { > >> + from_next = from; > >> + to_next = to; > >> + return error; > >> + } > >> + > >> + bool do_always_noconv() const throw() { return false; } > >> +}; > >> + > >> +static void > >> +test_pr118099_codecvt() > >> +{ > >> + const C val = C('x'); > >> + const C canary = ~val; > >> + const int N = 16; > >> + C buf[N]; > >> + for (int i = 0; i < N; ++i) > >> + buf[i] = canary; > >> + > >> + std::basic_filebuf fb; > >> + fb.pubimbue(std::locale(std::locale::classic(), new > failing_codecvt)); > >> + fb.pubsetbuf(buf, N/2); // filebuf can use buf[0..7] > >> + fb.open("tmp_118099_codecvt", std::ios_base::out | > std::ios_base::trunc); > >> + VERIFY( fb.is_open() ); > >> + > >> + // Libstdc++ filebuf throws ios::failure for the codecvt error, > >> + // but the standard allows overflow to return eof instead. > >> + // To make this test portable, we check for either kind of error. > >> + bool got_error = false; > >> + for (int i = 0; i < N; ++i) > >> + try { > >> + std::char_traits::int_type r = fb.sputc(val); > >> + if (std::char_traits::eq_int_type(r, > std::char_traits::eof())) > >> + got_error = true; > >> + } catch (const std::exception&) { > >> + got_error = true; > >> + } > >> + VERIFY( got_error ); // a codecvt error actually happened > >> + > >> + for (int i = 0; i < N/2; ++i) > >> + VERIFY( buf[i] == val ); > >> + for (int i = N/2; i < N; ++i) > >> + VERIFY( buf[i] == canary ); // nothing was written past buf[0..7] > >> +} > >> + > >> +int main() > >> +{ > >> + test_pr118099_codecvt(); > >> +} > >> -- > >> 2.56.0 > >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tkaminsk@redhat.com Mon Nov 2 17:47:49 2026 From: tkaminsk@redhat.com (Tomasz Kaminski) Date: Mon, 2 Nov 2026 18:47:49 +0100 Subject: [PATCH] libstdc++: Export apply_result, is_applicable, and is_nothrow_applicable from std module In-Reply-To: References: <20261029171541.923427-1-tkaminsk@redhat.com> <20261029171541.923427-4-tkaminsk@redhat.com> Message-ID: On Mon, Nov 2, 2026 at 6:04?PM Jonathan Wakely wrote: > On Mon, 2 Nov 2026 at 16:57, Jakub Jelinek wrote: > > > > On Thu, Oct 29, 2026 at 05:53:49PM +0100, Tomasz Kami?ski wrote: > > > This implements C++26 paper: P1317R2, "Remove return type deduction > > > in std::apply". > > > > > > The traits are implemented in terms of > __(noexcept_)?unpack_tuple_like_v > > > machinery, in consequence the definitions of corresponding primary > templates > > > are moved to . Partial specializations remain defined in > > > bits/stl_pair.h and bits/range_utils.h, i.e. with of before definitions > > > of corresponding types, which guarantees that they are visible at point > > > of instantiation depending on them. > > > > > > While query trait is_applicable, is_nothrow_applicable could be > expressed > > > in terms of __(noexcept_)?unpack_tuple_like_v that produces boolean > value, > > > apply_result requires unpacking tuple to invoke_result. To handle > above, > > > __unpack_tuple_like_impl is introduced, whose value is object of trait > > > type (false_type for non tuple like), and thus does not require > presence > > > of value member. > > > > Thanks for working on this. > > > > This patch regresses > > FAIL: g++.dg/plugin/std-module-exports-c++26.C > -fplugin=./std_module_exports_plugin.so (test for excess errors) > > FAIL: g++.dg/plugin/std-module-exports-c++29.C > -fplugin=./std_module_exports_plugin.so (test for excess errors) > > > > Here is an incremental fix for that, tested on x86_64-linux, > > ok for trunk if this series is approved? > I will include that in the patch v2, if you do not mind. > > Conditionally OK - thanks > > > > > 2026-11-02 Jakub Jelinek > > > > * src/c++23/std.cc.in (std::apply_result, std::apply_result_t, > > std::is_applicable, std::is_applicable_v, > std::is_nothrow_applicable, > > std::is_nothrow_applicable_v): New exports for C++26. > > > > --- a/libstdc++-v3/src/c++23/std.cc.in 2026-10-14 11:17:48.208100670 > +0200 > > +++ b/libstdc++-v3/src/c++23/std.cc.in 2026-11-02 17:40:18.478850112 > +0100 > > @@ -3626,6 +3626,14 @@ export namespace std > > #if __cpp_lib_within_lifetime >= 202306L > > using std::is_within_lifetime; > > #endif > > +#if __cpp_lib_apply >= 202506L > > + using std::apply_result; > > + using std::apply_result_t; > > + using std::is_applicable; > > + using std::is_applicable_v; > > + using std::is_nothrow_applicable; > > + using std::is_nothrow_applicable_v; > > +#endif > > } > > > > // > > > > > > Jakub > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From amacleod@redhat.com Mon Nov 2 17:49:51 2026 From: amacleod@redhat.com (Andrew MacLeod) Date: Mon, 2 Nov 2026 12:49:51 -0500 Subject: [COMMITTED] Add get_bitmask to prange_storage Message-ID: Its very inefficient to create a prange from prange_storage only to extract the bitmask. This a common request with the alignment extracted from the bitmask now. This patch allows the bitmask to be directly extracted from the prange_storage object. Bootstraps on x86_64-pc-linux-gnu with no regressions. Pushed. Andrew Extract a bitmask directly from a prange_storage. This is far more efficient than constructing a prange in order to extract it. * tree-ssanames.cc (get_nonzero_bits_1): Call get_bitmask directly from a prange_storage. (get_ptr_info_alignment): Likewise. * value-range-storage.cc (prange_storage::get_bitmask): New. * value-range-storage.h (prange_storage::get_bitmask): New prototype. --- gcc/tree-ssanames.cc | 15 +++++++-------- gcc/value-range-storage.cc | 36 ++++++++++++++++++++++++++++++++++++ gcc/value-range-storage.h | 1 + 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc index d4414e261cc..565ebda14cd 100644 --- a/gcc/tree-ssanames.cc +++ b/gcc/tree-ssanames.cc @@ -589,9 +589,9 @@ get_nonzero_bits_1 (const_tree name) // need to extract the bitmask like integers do. if (POINTER_TYPE_P (TREE_TYPE (name))) { - prange tmp; - range_info_get_range (name, tmp); - return tmp.get_bitmask ().get_nonzero_bits (); + prange_storage *s = ssa_name_prange_storage (name); + gcc_checking_assert (s); + return s->get_bitmask (TREE_TYPE (name)).get_nonzero_bits (); } if (!irange::supports_p (TREE_TYPE (name))) @@ -841,16 +841,15 @@ get_ptr_info_alignment (const_tree name, unsigned int *alignp, if (!POINTER_TYPE_P (TREE_TYPE (name)) || !SSA_NAME_RANGE_INFO (name)) return false; - prange r; - range_info_get_range (name, r); - if (r.undefined_p ()) + prange_storage *s = ssa_name_prange_storage (name); + if (!s) return false; - bool known = bitmask_to_alignment (r.get_bitmask (), alignp, misalignp); + bool known = bitmask_to_alignment (s->get_bitmask (TREE_TYPE (name)), + alignp, misalignp); /* Legacy fields may know less, but useful alignment must be implied by the bitmask. Alignment one carries no information. */ - prange_storage *s = ssa_name_prange_storage (name); gcc_checking_assert (s->align <= 1 || (known && *alignp >= s->align && (*misalignp & (s->align - 1)) == s->misalign)); diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc index 35997372e7c..62879585b6d 100644 --- a/gcc/value-range-storage.cc +++ b/gcc/value-range-storage.cc @@ -883,6 +883,42 @@ prange_storage::fits_p (const prange &r) const return num_words <= m_trailing_ints.num_elements (); } +irange_bitmask +prange_storage::get_bitmask (tree type) const +{ + gcc_checking_assert (m_kind != PR_UNDEFINED); + unsigned prec = TYPE_PRECISION (type); + unsigned index = 0; + + switch (m_kind) + { + case PR_VARYING: + return irange_bitmask (prec); + + case PR_ZERO: + return irange_bitmask (type, wi::zero (prec), wi::zero (prec)); + + case PR_NONZERO: + case PR_FULL: + break; + + case PR_OTHER: + index = 2; + break; + + default: + gcc_unreachable (); + } + + if (m_has_bitmask) + { + wide_int value = get_word (index++, type); + wide_int mask = get_word (index++, type); + return irange_bitmask (value, mask); + } + return irange_bitmask (prec); +} + static vrange_allocator ggc_vrange_allocator (true); diff --git a/gcc/value-range-storage.h b/gcc/value-range-storage.h index f4c264d5ede..a3a2821a445 100644 --- a/gcc/value-range-storage.h +++ b/gcc/value-range-storage.h @@ -131,6 +131,7 @@ public: void get_prange (prange &r, tree type) const; bool equal_p (const prange &r) const; bool fits_p (const prange &r) const; + irange_bitmask get_bitmask (tree type) const; void dump () const; // The points-to solution for the SSA name is flow insensitive and is -- 2.56.0 From amacleod@redhat.com Mon Nov 2 17:52:25 2026 From: amacleod@redhat.com (Andrew MacLeod) Date: Mon, 2 Nov 2026 12:52:25 -0500 Subject: [PATCH] Remove null from pt_solution Message-ID: I was planning to keep pt.null and non-zero ranges in sync with each other for a while, but it turns out that isn't necessary. Thre is only one place (!!!!) that actually sets pt.null to 0 (meaning the range is nonnull) It is in tree-ssa-structalias.cc find_what_p_points_to() and it determines nonnullness based on : get_range_query (DECL_STRUCT_FUNCTION (fndecl))->range_of_expr (vr, p); bool nonnull = !vr.contains_zero_p (); <..> if (nonnull) set_ptr_nonnull (p); So it is only setting nonnull in pt_solution if the range is already nonzero. It might be possible we dont even need to do this now... but its unclear to me whether that query may sometimes pick up information from the pass and transferring it to the global range that might not have been there before. I expect we can remove it and I'll try a run with an assert... but that can be a follow on. Therefore, this patch removes null from the pt_solution and adjusts callers and utilities, leaving that single set_ptr_nonnull call. Queries that use to use !pt.null are now replaced with ptr_nonnull_p (name). This also means pt_solution no longer contains any flow sensitive range information, so there are numerous cleanup/adjustments for that. Bootstraps on x86_64-pc-linux-gnu with no regressions. OK? Andrew The null field in pt_solution is a remnant from when no range for a pointer was stored, and an extra bit in the alias structure was ultized to communicate non-nullness. This is now fully tracked by a prange, and is no longer needed. Add a couple of helpers as well to prange_storage and ptr_nonnull_p () now replaces !pt.null as a query. This also means that a pt_solution no longer has any flow sensitive information in it, and that pointers are no longer "special" from that perspective. gcc/ * gimple-pretty-print.cc (pp_points_to_solution): Do not print null field. * tree-ssa-alias.cc (ptrs_compare_unequal): Use ptr_nonnull_p. (dump_points_to_solution): Don't print null field. (same_addr_size_stores_p): Use ptr_nonnull_p. * tree-ssa-alias.h (pt_solution::null): Remove bit member. * tree-ssa-structalias.cc (find_what_var_points_to): Ignore null. (find_what_p_points_to): Likewise. (pt_solution_reset): Likewise. (pt_solution_ior_into): Likewise. (ipa_escaped_pt): Don't set null field. * tree-ssanames.cc (set_range_info): Do not check pt_solution for the null field. (ptr_nonnull_p): New. (set_ptr_nonnull): Update to Remove 0 from the range. (reset_flow_sensitive_info): No need to clear the null field in pt_solution. (flow_sensitive_info_storage::save): Move to header. (flow_sensitive_info_storage::restore): Move to header. (flow_sensitive_info_storage::ave_and_clear: Move to header. (flow_sensitive_info_storage::clear_storage: Move to header. * tree-ssanames.h (ptr_nonnull_p): New prototype. (flow_sensitive_info_storage::save): Simplify and inline. (flow_sensitive_info_storage::restore): Likewise. (flow_sensitive_info_storage::ave_and_clear): Likewise. (flow_sensitive_info_storage::clear_storage): Likewise. (flow_sensitive_info_storage::null): Remove member. * value-query.cc (get_ssa_name_ptr_info_nonnull): Delete. (gimple_range_global): Do not check pt_solution null field. * value-range-storage.cc (prange_storage::set_nonnull): New. * value-range-storage.h (prange_storage::nonnull_p): New. (prange_storage::set_nonnull): New prototype. gcc/testsuite/ * gcc.dg/torture/pr39074-2.c: Remove NULL from pt output. * gcc.dg/torture/pr39074.c: Likewise. --- gcc/gimple-pretty-print.cc | 2 - gcc/testsuite/gcc.dg/torture/pr39074-2.c | 2 +- gcc/testsuite/gcc.dg/torture/pr39074.c | 2 +- gcc/tree-ssa-alias.cc | 9 +-- gcc/tree-ssa-alias.h | 4 - gcc/tree-ssa-structalias.cc | 12 +-- gcc/tree-ssanames.cc | 93 +++++------------------- gcc/tree-ssanames.h | 39 +++++++--- gcc/value-query.cc | 40 ++-------- gcc/value-range-storage.cc | 46 ++++++++++++ gcc/value-range-storage.h | 24 ++++++ 11 files changed, 131 insertions(+), 142 deletions(-) diff --git a/gcc/gimple-pretty-print.cc b/gcc/gimple-pretty-print.cc index 69148dd5cbd..1af0910f148 100644 --- a/gcc/gimple-pretty-print.cc +++ b/gcc/gimple-pretty-print.cc @@ -822,8 +822,6 @@ pp_points_to_solution (pretty_printer *pp, const pt_solution *pt) pp_string (pp, "escaped "); if (pt->ipa_escaped) pp_string (pp, "unit-escaped "); - if (pt->null) - pp_string (pp, "null "); if (pt->const_pool) pp_string (pp, "const-pool "); if (pt->vars diff --git a/gcc/testsuite/gcc.dg/torture/pr39074-2.c b/gcc/testsuite/gcc.dg/torture/pr39074-2.c index 16c10e88277..ea9c0d3e9d2 100644 --- a/gcc/testsuite/gcc.dg/torture/pr39074-2.c +++ b/gcc/testsuite/gcc.dg/torture/pr39074-2.c @@ -31,4 +31,4 @@ int main() } /* { dg-final { scan-tree-dump "y.\?.._. = { i }" "alias" } } */ -/* { dg-final { scan-tree-dump "y.\?.._., points-to NULL, points-to vars: { D..... }" "alias" } } */ +/* { dg-final { scan-tree-dump "y.\?.._., points-to vars: { D..... }" "alias" } } */ diff --git a/gcc/testsuite/gcc.dg/torture/pr39074.c b/gcc/testsuite/gcc.dg/torture/pr39074.c index eec4873405d..d28b35e118e 100644 --- a/gcc/testsuite/gcc.dg/torture/pr39074.c +++ b/gcc/testsuite/gcc.dg/torture/pr39074.c @@ -30,4 +30,4 @@ int main() } /* { dg-final { scan-tree-dump "y.\?.._. = { i }" "alias" } } */ -/* { dg-final { scan-tree-dump "y.\?.._., points-to NULL, points-to vars: { D..... }" "alias" } } */ +/* { dg-final { scan-tree-dump "y.\?.._., points-to vars: { D..... }" "alias" } } */ diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc index 23490c07ecd..41072b4d5d9 100644 --- a/gcc/tree-ssa-alias.cc +++ b/gcc/tree-ssa-alias.cc @@ -516,7 +516,7 @@ ptrs_compare_unequal (tree ptr1, tree ptr2) || pt1->vars_contains_restrict || pt1->vars_contains_interposable) return false; - if (integer_zerop (ptr2) && !pt1->null) + if (integer_zerop (ptr2) && ptr_nonnull_p (ptr1)) return true; if (TREE_CODE (ptr2) == SSA_NAME) { @@ -525,7 +525,7 @@ ptrs_compare_unequal (tree ptr1, tree ptr2) || pt2->vars_contains_restrict || pt2->vars_contains_interposable) return false; - if ((!pt1->null || !pt2->null) + if ((ptr_nonnull_p (ptr1) || ptr_nonnull_p (ptr2)) /* ??? We do not represent FUNCTION_DECL and LABEL_DECL in pt.vars but only set pt.vars_contains_nonlocal. This makes compares involving those and other nonlocals @@ -683,9 +683,6 @@ dump_points_to_solution (FILE *file, const pt_solution *pt) if (pt->ipa_escaped) fprintf (file, ", points-to unit escaped"); - if (pt->null) - fprintf (file, ", points-to NULL"); - if (pt->const_pool) fprintf (file, ", points-to const-pool"); @@ -3399,7 +3396,7 @@ same_addr_size_stores_p (tree base1, poly_int64 offset1, poly_int64 size1, /* Be conservative with non-call exceptions when the address might be NULL. */ - if (cfun->can_throw_non_call_exceptions && pt->null) + if (cfun->can_throw_non_call_exceptions && !ptr_nonnull_p (ptr)) return false; /* Check that ptr points relative to obj. */ diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h index 2e6344a0b6e..a67293ae4ae 100644 --- a/gcc/tree-ssa-alias.h +++ b/gcc/tree-ssa-alias.h @@ -43,10 +43,6 @@ struct GTY(()) pt_solution reference. */ unsigned int ipa_escaped : 1; - /* Nonzero if the points-to set includes 'nothing', the points-to set - includes memory at address NULL. */ - unsigned int null : 1; - /* Nonzero if the points-to set includes a readonly object like a STRING_CST that does not have an underlying declaration but will end up in the constant pool. */ diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc index 1db7c69be65..af8100d49a5 100644 --- a/gcc/tree-ssa-structalias.cc +++ b/gcc/tree-ssa-structalias.cc @@ -874,11 +874,9 @@ find_what_var_points_to (tree fndecl, varinfo_t orig_vi) { varinfo_t vi = get_varinfo (i); - if (vi->is_artificial_var) + if (vi->is_artificial_var && vi->id != nothing_id) { - if (vi->id == nothing_id) - pt->null = 1; - else if (vi->id == escaped_id) + if (vi->id == escaped_id) { if (in_ipa_mode) pt->ipa_escaped = 1; @@ -948,8 +946,6 @@ find_what_p_points_to (tree fndecl, tree p) return; pt_solution pt = find_what_var_points_to (fndecl, vi); - /* Conservatively set to NULL from PTA (to true). */ - pt.null = 1; set_ssa_name_pt_solution (p, pt); /* Preserve pointer nonnull globally computed. */ if (nonnull) @@ -993,7 +989,6 @@ pt_solution_reset (struct pt_solution *pt) { memset (pt, 0, sizeof (struct pt_solution)); pt->anything = true; - pt->null = true; } /* Set the points-to solution *PT to point only to the variables @@ -1046,7 +1041,6 @@ pt_solution_ior_into (struct pt_solution *dest, struct pt_solution *src) dest->nonlocal |= src->nonlocal; dest->escaped |= src->escaped; dest->ipa_escaped |= src->ipa_escaped; - dest->null |= src->null; dest->const_pool |= src->const_pool ; dest->vars_contains_nonlocal |= src->vars_contains_nonlocal; dest->vars_contains_escaped |= src->vars_contains_escaped; @@ -1834,7 +1828,7 @@ make_pass_build_ealias (gcc::context *ctxt) /* IPA PTA solutions for ESCAPED. */ struct pt_solution ipa_escaped_pt - = { true, false, false, false, false, false, + = { true, false, false, false, false, false, false, false, false, false, false, NULL }; diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc index 680f795f4ff..827aed0ab80 100644 --- a/gcc/tree-ssanames.cc +++ b/gcc/tree-ssanames.cc @@ -497,14 +497,6 @@ set_range_info (tree name, const vrange &r) if (!tmp.intersect (r) || tmp.undefined_p ()) return false; - if (POINTER_TYPE_P (type)) - { - // Preserve nonnullness in the points-to solution as well. - pt_solution *pt = get_pt_solution (name); - if (!tmp.contains_zero_p () && pt->null) - set_ptr_nonnull (name); - } - if (!range_info_set_range (name, tmp)) return false; @@ -523,13 +515,31 @@ set_range_info (tree name, const vrange &r) return true; } +/* query nonnull attribute for pointer NAME. */ + +bool +ptr_nonnull_p (tree name) +{ + gcc_assert (POINTER_TYPE_P (TREE_TYPE (name))); + prange_storage *ps = ssa_name_prange_storage (name); + return ps ? ps->nonnull_p (TREE_TYPE (name)) : false; +} + /* Set nonnull attribute to pointer NAME. */ void set_ptr_nonnull (tree name) { gcc_assert (POINTER_TYPE_P (TREE_TYPE (name))); - get_pt_solution (name)->null = 0; + prange_storage *ps = ssa_name_prange_storage (name); + if (ps) + { + ps->set_nonnull (TREE_TYPE (name)); + return; + } + prange pr; + pr.set_nonzero (TREE_TYPE (name)); + range_info_set_range (name, pr); } /* Update the non-zero bits bitmask of NAME. */ @@ -1038,13 +1048,7 @@ reset_flow_sensitive_info (tree name) pt_solution *pt = s ? s->pt : NULL; SSA_NAME_RANGE_INFO (name) = NULL; if (pt) - { - set_pt_solution (name, pt); - /* [E]VRP can derive context sensitive alignment info and - non-nullness properties. We must reset both. The alignment went - with the range storage above; only the nullness is left. */ - pt->null = 1; - } + set_pt_solution (name, pt); // Clear range info in the current range query. get_range_query (cfun)->reset_range_info (name); @@ -1178,60 +1182,3 @@ make_pass_release_ssa_names (gcc::context *ctxt) { return new pass_release_ssa_names (ctxt); } - -/* Save and restore of flow sensitive information. */ - -/* Save off the flow sensitive info from NAME. */ - -void -flow_sensitive_info_storage::save (tree name) -{ - gcc_assert (state == 0); - range_info = SSA_NAME_RANGE_INFO (name); - if (!POINTER_TYPE_P (TREE_TYPE (name))) - { - state = 1; - return; - } - state = -1; - const pt_solution *pt = ssa_name_pt_solution (name); - null = pt ? pt->null : true; -} - -/* Restore the flow sensitive info from NAME. */ - -void -flow_sensitive_info_storage::restore (tree name) -{ - gcc_assert (state != 0); - /* The storage carries the range, its bitmask and -- for now -- the - alignment, so reinstating it restores all three. Only the nullness - lives outside it. */ - SSA_NAME_RANGE_INFO (name) = range_info; - if (!POINTER_TYPE_P (TREE_TYPE (name))) - { - gcc_assert (state == 1); - return; - } - gcc_assert (state == -1); - prange_storage *s = ssa_name_prange_storage (name); - if (s && s->pt) - s->pt->null = null; -} - -/* Save off the flow sensitive info from NAME. - And reset the flow sensitive info of NAME. */ - -void -flow_sensitive_info_storage::save_and_clear (tree name) -{ - save (name); - reset_flow_sensitive_info (name); -} - -/* Clear the storage. */ -void -flow_sensitive_info_storage::clear_storage (void) -{ - state = 0; -} diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h index bbd5890c4ff..6ddf5d1fca5 100644 --- a/gcc/tree-ssanames.h +++ b/gcc/tree-ssanames.h @@ -56,6 +56,7 @@ extern bool get_ptr_info_alignment (const_tree, unsigned int *, extern void mark_ptr_info_alignment_unknown (tree); extern void set_ptr_info_alignment (tree, unsigned int, unsigned int); extern void set_ptr_nonnull (tree); +extern bool ptr_nonnull_p (tree); extern tree copy_ssa_name_fn (struct function *, tree, gimple *); extern tree duplicate_ssa_name_fn (struct function *, tree, gimple *); @@ -122,21 +123,35 @@ make_temp_ssa_name (tree type, gimple *stmt, const char *name) class flow_sensitive_info_storage { public: - void save (tree); - void save_and_clear (tree); - void restore (tree); - void clear_storage (); + /* Save the flow sensitive info from NAME. */ + inline void save (tree name) + { + gcc_checking_assert (state == 0); + range_info = SSA_NAME_RANGE_INFO (name); + state = 1; + } + + /* Restore the flow sensitive info from NAME. */ + inline void restore (tree name) const + { + gcc_checking_assert (state == 1); + SSA_NAME_RANGE_INFO (name) = range_info; + } + + /* Save the flow sensitive info from NAME and reset that info. */ + inline void save_and_clear (tree name) + { + save (name); + reset_flow_sensitive_info (name); + } + + /* Clear the storage. */ + inline void clear_storage () { state = 0; } private: - /* 0 means there is nothing saved. - 1 means non pointer is saved. - -1 means a pointer type is saved. - -2 means a pointer type is saved but no information was saved. */ + /* 0 means there is nothing saved. 1 means something is saved. */ int state = 0; - /* The range info, which for a pointer also carries the bitmask and the - alignment, so those need no separate slot here. */ + /* The range info contains all flow sensitive information now. */ vrange_storage *range_info = nullptr; - /* Flow sensitive pointer information not held in the range. */ - bool null = true; }; #endif /* GCC_TREE_SSANAMES_H */ diff --git a/gcc/value-query.cc b/gcc/value-query.cc index e5290075243..a35029237ec 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -592,26 +592,6 @@ get_ssa_name_range_info (vrange &r, const_tree name) r.set_varying (type); } -// Return nonnull attribute of pointer NAME from its points-to solution. - -static inline bool -get_ssa_name_ptr_info_nonnull (const_tree name) -{ - gcc_assert (POINTER_TYPE_P (TREE_TYPE (name))); - const pt_solution *pt = ssa_name_pt_solution (name); - if (pt == NULL) - return false; - /* TODO Now pt->null is conservatively set to true in PTA - analysis. vrp is the only pass (including ipa-vrp) - that clears pt.null via set_ptr_nonnull when it knows - for sure. PTA will preserves the pt.null value set by VRP. - - When PTA analysis is improved, pt.anything, pt.nonlocal - and pt.escaped may also has to be considered before - deciding that pointer cannot point to NULL. */ - return !pt->null; -} - // Update the global range for NAME into the SSA_RANGE_NAME_INFO and // Return the legacy global range for NAME if it has one, otherwise // return VARYING. @@ -639,13 +619,12 @@ gimple_range_global (vrange &r, tree name, struct function *fun) // ~[0, 0]. Note that this is only valid with default definitions // of PARM_DECLs if (POINTER_TYPE_P (type) - && ((cfun && fun == cfun && nonnull_arg_p (sym)) - || get_ssa_name_ptr_info_nonnull (name))) - { - prange nz (type); - nz.set_nonzero (type); - r.intersect (nz); - } + && ((cfun && fun == cfun && nonnull_arg_p (sym)))) + { + prange nz (type); + nz.set_nonzero (type); + r.intersect (nz); + } } // If this is a local automatic with no definition, use undefined. else if (TREE_CODE (sym) != RESULT_DECL) @@ -658,13 +637,6 @@ gimple_range_global (vrange &r, tree name, struct function *fun) get_ssa_name_range_info (r, name); if (r.undefined_p ()) r.set_varying (type); - // pt.null may still carry non-nullness the stored range does not. - if (POINTER_TYPE_P (type) && get_ssa_name_ptr_info_nonnull (name)) - { - prange nz (type); - nz.set_nonzero (type); - r.intersect (nz); - } } else r.set_varying (type); diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc index 62879585b6d..bb2a58788b3 100644 --- a/gcc/value-range-storage.cc +++ b/gcc/value-range-storage.cc @@ -883,6 +883,52 @@ prange_storage::fits_p (const prange &r) const return num_words <= m_trailing_ints.num_elements (); } +// Ensure this range of type TYPE does not contain zero. + +void +prange_storage::set_nonnull (tree type) +{ + gcc_checking_assert (m_kind != PR_UNDEFINED); + switch (m_kind) + { + case PR_VARYING: + case PR_FULL: + m_kind = PR_NONZERO; + return; + + case PR_NONZERO: + return; + + case PR_ZERO: + m_kind = PR_UNDEFINED; + return; + + case PR_OTHER: + if (get_word (0, type) != 0) + return; + // [0,1] -> [1,1] is a special case and requires adjustments. + // otherwise we can simply set the lower bound to 1. + if (get_word (1, type) != 1) + set_word (0, wi::one (TYPE_PRECISION (type)), type); + else + { + // This is very uncoomon, and rather than trying to cover + // the edge cases (ie, bitmask present, points to) + // simply load the range, remove zero, and resave it. + prange pr; + this->get_vrange (pr, type); + prange nz; + nz.set_nonzero (type); + if (pr.intersect (nz)) + this->set_prange (pr); + } + return; + + default: + gcc_unreachable (); + } +} + irange_bitmask prange_storage::get_bitmask (tree type) const { diff --git a/gcc/value-range-storage.h b/gcc/value-range-storage.h index a3a2821a445..b58a2f23bd3 100644 --- a/gcc/value-range-storage.h +++ b/gcc/value-range-storage.h @@ -132,6 +132,8 @@ public: bool equal_p (const prange &r) const; bool fits_p (const prange &r) const; irange_bitmask get_bitmask (tree type) const; + bool nonnull_p (tree type) const; + void set_nonnull (tree type); void dump () const; // The points-to solution for the SSA name is flow insensitive and is @@ -162,6 +164,28 @@ private: trailing_wide_ints m_trailing_ints; }; +// Return TRUE if this range of type TYPE does not contain zero. + +inline bool +prange_storage::nonnull_p (tree type) const +{ + switch (m_kind) + { + case PR_UNDEFINED: + case PR_VARYING: + case PR_ZERO: + case PR_FULL: + return false; + case PR_NONZERO: + return true; + case PR_OTHER: + return (get_word (0, type) != 0); + default: + gcc_unreachable (); + } +} + + // Efficient memory storage for an frange. class GTY((tag ("VR_FRANGE"))) frange_storage : public vrange_storage -- 2.56.0 From ncm@cantrip.org Mon Nov 2 17:52:32 2026 From: ncm@cantrip.org (Nathan Myers) Date: Mon, 2 Nov 2026 12:52:32 -0500 Subject: [PATCH v4] libstdc++: improve string construction from streambuf [PR112925] Message-ID: <20261102175253.226515-1-ncm@cantrip.org> Changes in v4: - Use ranges::begin(__rg) in place of __rg.begin(). - Comment reuse of held copy of streambuf iterator. - Fix up whitespace. - Fix up changelog formatting. Changes in v3: - Remove check for __is_constant_evaluated. - Gate the shortcut on string's _Traits matching the default, like the streambuf iterator's traits. Changes in v2: - When constructing from a streambuf iterator range, ensure its sentinel is another streambuf iterator, or default_sentinel. - Add #pragma diagnostic push for "if constexpr" in c++11. - Add c++11 test for construction from raw iterators. - Add test with a sentinel in place of default-ctor'd iterator. - Add test with range pipeline. - Remove spurious 'constexpr' in test. Constructing a string from a streambuf iterator pair or range has been found to be 3x faster using the streambuf member `sgetn`. This is the minimal implementation as outlined in [PR112925]. Future improvements might include doing the same optimization when appending, and preallocating when the final size can be known. libstdc++-v3/ChangeLog: PR libstdc++/112925 * include/bits/basic_string.h (basic_string range ctor): Special-case ranges of streambuf iterators. * include/bits/basic_string.tcc (_M_construct): Special-case streambuf iterators. These always consume the whole stream. * testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc: New test, construction from two istreambuf_iterators. * testsuite/21_strings/basic_string/cons/from_range2.cc: New tests, construction from ranges. --- libstdc++-v3/include/bits/basic_string.h | 12 ++++- libstdc++-v3/include/bits/basic_string.tcc | 20 ++++++++ .../basic_string/cons/char/from_sbufiter.cc | 24 +++++++++ .../basic_string/cons/from_range2.cc | 50 +++++++++++++++++++ 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index fd9419220a4..3748f4164bd 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -826,7 +826,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 basic_string(from_range_t, _Rg&& __rg, const _Alloc& __a = _Alloc()) : basic_string(__a) { - if constexpr (ranges::forward_range<_Rg> || ranges::sized_range<_Rg>) + using _SbufIter = istreambuf_iterator<_CharT, char_traits<_CharT>>; + if constexpr (requires { + requires is_same_v, _SbufIter>; + requires is_same_v, _SbufIter> || + is_same_v, default_sentinel_t>; }) + { + _M_construct(ranges::begin(__rg), _SbufIter(), + input_iterator_tag{}); + } + else if constexpr (ranges::forward_range<_Rg> + || ranges::sized_range<_Rg>) { const auto __n = static_cast(ranges::distance(__rg)); reserve(__n); diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index de82e997888..b10563df73a 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -199,6 +199,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_init_local_buf(); + // NB: size() (i.e. _M_length) is initialized only at the end. while (__beg != __end && __len < __capacity) { _M_local_buf[__len++] = *__beg; @@ -228,6 +229,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_data(__another.__ptr); _M_capacity(__capacity); } + +#if __cplusplus >= 201103L +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr + + using _SbufIter = istreambuf_iterator<_CharT, char_traits<_CharT>>; + if constexpr (is_same<_InIterator, _SbufIter>::value && + is_same<_Traits, char_traits<_CharT>>::value) + { + auto __r = std::__copy_n_a(__beg, __capacity - __len, + _M_data() + __len, false); + __len = __r - data(); + // We continue using __beg after passing it to copy_n_a. + // That is permitted for streambuf iterators. + continue; + } + +# pragma GCC diagnostic pop +#endif traits_type::assign(_M_data()[__len++], static_cast<_CharT>(*__beg)); ++__beg; diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc new file mode 100644 index 00000000000..338dcbcdd27 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc @@ -0,0 +1,24 @@ +// { dg-do run { target c++11 } } + +#include +#include +#include +#include +#include + +std::string abcs{"abcdefghijklmnopqrstuvwxyz"}; +std::string twice{abcs + " " + abcs}; + +void +test_iters() +{ + std::istringstream stream{twice}; + std::istreambuf_iterator iter{stream}, end; + std::string str{iter, end}; + VERIFY(str == twice); +} + +int main() +{ + test_iters(); +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc new file mode 100644 index 00000000000..7dd98b5c29b --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/from_range2.cc @@ -0,0 +1,50 @@ +// { dg-do run { target c++23 } } + +#include +#include +#include +#include +#include +#include + +std::string abcs{"abcdefghijklmnopqrstuvwxyz"}; +std::string twice{abcs + " " + abcs}; + +void +test_range() +{ + std::istringstream stream{twice}; + std::istreambuf_iterator it{stream}, end; + std::ranges::subrange range{it, end}; + std::basic_string str{std::from_range, range}; + VERIFY(str == twice); +} + +void +test_sentinel() +{ + std::istringstream stream{twice}; + std::istreambuf_iterator it{stream}, end; + std::ranges::subrange range{it, std::default_sentinel}; + std::basic_string str{std::from_range, range}; + VERIFY(str == twice); +} + +void +test_take() +{ + std::istringstream stream{twice}; + std::istreambuf_iterator it{stream}, end; + std::ranges::subrange range{it, std::default_sentinel}; + std::basic_string str{std::from_range, + range | std::views::take_while([](char c){ return c != ' '; }) }; + VERIFY(str == abcs); +} + + +int main() +{ + test_range(); + test_sentinel(); + test_take(); +} -- 2.56.0 From amacleod@redhat.com Mon Nov 2 17:54:16 2026 From: amacleod@redhat.com (Andrew MacLeod) Date: Mon, 2 Nov 2026 12:54:16 -0500 Subject: [PATCH] Remove alignment fields Message-ID: <7661b573-2422-4f77-9160-cd34e3131f80@redhat.com> The alignment fields are in a prange_storage object just for verification that the bitmasks ae returning the same values. At some point we'll want to remove the fields and just leave the bitmask calculations I'm OK to do it now, or we can hold of and let things run in the wild for a bit longer. bootstraps on x86_64-pc-linux-gnu with no regressions. OK for trunk now? or hold off or a bit? Andrew Alignment is now tracked in prange's bitfields. There is no longer a need to keep seperate align and misalign fields as the bitmask can answer the same question. * tree-ssanames.cc (range_info_set_range): Do not save and restore alignment fields when storage changes. (get_ptr_info_alignment): Do not use alignment fields. (mark_ptr_info_alignment_unknown): Ditto. (set_ptr_info_alignment): Ditto. (duplicate_ssa_name_range_info): Ditto. * value-range-storage.cc (prange_storage::prange_storage): Ditto. * value-range-storage.h (prange_storage::align): Remove. (prange_storage::misalign): Remove. --- gcc/tree-ssanames.cc | 42 +++++--------------------------------- gcc/value-range-storage.cc | 2 -- gcc/value-range-storage.h | 6 ------ 3 files changed, 5 insertions(+), 45 deletions(-) diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc index 827aed0ab80..8f6e922e007 100644 --- a/gcc/tree-ssanames.cc +++ b/gcc/tree-ssanames.cc @@ -173,27 +173,20 @@ range_info_set_range (tree name, const vrange &r) { if (!SSA_NAME_RANGE_INFO (name) || !range_info_fits_p (name, r)) { - // Preserve SSA-owned points-to and alignment information when the + // Preserve SSA-owned points-to information when the // variable-sized range storage must grow. pt_solution *pt = NULL; - unsigned int align = 0, misalign = 0; if (prange_storage *old = ssa_name_prange_storage (name)) - { - pt = old->pt; - align = old->align; - misalign = old->misalign; - } + pt = old->pt; if (SSA_NAME_RANGE_INFO (name)) range_info_free (name); vrange_storage *mem = range_info_alloc (name, r); - if (mem && (pt || align)) + if (mem && pt) { gcc_checking_assert (mem->m_discriminator == VR_PRANGE); prange_storage *s = static_cast (mem); s->pt = pt; - s->align = align; - s->misalign = misalign; } return mem != NULL; } @@ -852,18 +845,11 @@ get_ptr_info_alignment (const_tree name, unsigned int *alignp, return false; prange_storage *s = ssa_name_prange_storage (name); - if (!s) return false; - bool known = bitmask_to_alignment (s->get_bitmask (TREE_TYPE (name)), - alignp, misalignp); - - gcc_checking_assert (s->align <= 1 - || (known && *alignp >= s->align - && (*misalignp & (s->align - 1)) == s->misalign)); - - return known; + return bitmask_to_alignment (s->get_bitmask (TREE_TYPE (name)), + alignp, misalignp); } /* Clear NAME's known bits independently of the legacy alignment fields. */ @@ -871,14 +857,6 @@ get_ptr_info_alignment (const_tree name, unsigned int *alignp, void mark_ptr_info_alignment_unknown (tree name) { - prange_storage *pi = ssa_name_prange_storage (name); - - if (pi) - { - pi->align = 0; - pi->misalign = 0; - } - if (!SSA_NAME_RANGE_INFO (name)) return; @@ -922,12 +900,6 @@ set_ptr_info_alignment (tree name, unsigned int align, unsigned int misalign) r.update_bitmask (cur); if (r.undefined_p () || !range_info_set_range (name, r)) return; - - /* Transitional fields are updated only after the range accepts the - refinement. Reacquire storage since the update may reallocate it. */ - prange_storage *s = ssa_name_prange_storage (name); - s->align = align; - s->misalign = misalign; } @@ -999,10 +971,6 @@ duplicate_ssa_name_range_info (tree name, tree src) so it has to be copied as part of the same operation. */ if (POINTER_TYPE_P (TREE_TYPE (src))) duplicate_ssa_name_ptr_info (name, src); - - unsigned align, misalign; - if (get_ptr_info_alignment (src, &align, &misalign)) - set_ptr_info_alignment (name, align, misalign); } /* For a SSA copy DEST = SRC duplicate SSA info present on DEST to SRC diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc index bb2a58788b3..b7b23e380e4 100644 --- a/gcc/value-range-storage.cc +++ b/gcc/value-range-storage.cc @@ -642,8 +642,6 @@ prange_storage::prange_storage (const prange &r) : vrange_storage (VR_PRANGE) // Only the accessors in tree-ssanames.cc ever make them non-zero, and // range_info_set_range carries them across a reallocation. pt = NULL; - align = 0; - misalign = 0; unsigned num_words; enum prange_kind kind = prange_format (r, num_words); diff --git a/gcc/value-range-storage.h b/gcc/value-range-storage.h index b58a2f23bd3..d721961c6c2 100644 --- a/gcc/value-range-storage.h +++ b/gcc/value-range-storage.h @@ -140,12 +140,6 @@ public: // reached only through ssa_name_pt_solution. struct pt_solution *pt; - // Alignment and misalignment of the pointer in bytes. Together - // align and misalign specify low known bits of the pointer. - // ptr & (align - 1) == misalign. - unsigned int align; - unsigned int misalign; - private: DISABLE_COPY_AND_ASSIGN (prange_storage); prange_storage (const prange &r); -- 2.56.0 From amacleod@redhat.com Mon Nov 2 18:47:34 2026 From: amacleod@redhat.com (Andrew MacLeod) Date: Mon, 2 Nov 2026 13:47:34 -0500 Subject: [COMMITTED] Inline ssa_name_pt_solution Message-ID: <82e7564c-3912-4333-a3d7-4f5c399ed685@redhat.com> There are enough calls to ssa_name_pt_solution now to warrant inlining it. This requires value-range-storage.h to be included in a couple of other places, and streamline the function itself. Bootstrapped on x86_64-pc-linux-gnu with no regressions. Pushed. Andrew * gimple.h: Include value-range-storage.h. * tree-ssanames.cc (ssa_name_pt_solution): Move to... * tree-ssanames.h (ssa_name_pt_solution): Here and adjust. * tree-vrp.h: Include value-range-storage.h. --- gcc/gimple.h | 1 + gcc/tree-ssanames.cc | 9 --------- gcc/tree-ssanames.h | 10 +++++++++- gcc/tree-vrp.h | 1 + 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gcc/gimple.h b/gcc/gimple.h index 0245e5e0934..f8f5b01ba85 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-expr.h" #include "bitmap.h" #include "value-range.h" +#include "value-range-storage.h" #include "value-query.h" typedef gimple *gimple_seq_node; diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc index 8f6e922e007..c760d9370ad 100644 --- a/gcc/tree-ssanames.cc +++ b/gcc/tree-ssanames.cc @@ -140,15 +140,6 @@ get_pt_solution (tree name) return pt; } -/* Return NAME's points-to solution, or NULL if none exists. */ - -const pt_solution * -ssa_name_pt_solution (const_tree name) -{ - prange_storage *s = ssa_name_prange_storage (name); - return s ? s->pt : NULL; -} - /* Make PT the points-to solution for NAME. */ void diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h index 6ddf5d1fca5..78136871027 100644 --- a/gcc/tree-ssanames.h +++ b/gcc/tree-ssanames.h @@ -22,7 +22,15 @@ along with GCC; see the file COPYING3. If not see /* Return NAME's points-to solution, or NULL if it has none. Returns NULL for a non pointer type. */ -extern const pt_solution *ssa_name_pt_solution (const_tree name); +inline const pt_solution * +ssa_name_pt_solution (const_tree name) +{ + vrange_storage *mem = SSA_NAME_RANGE_INFO (name); + if (!mem || mem->m_discriminator != VR_PRANGE) + return NULL; + prange_storage *s = static_cast (mem); + return s->pt; +} /* Make PT the points-to solution for NAME, which must have pointer type. */ extern void set_ssa_name_pt_solution (tree name, const pt_solution &pt); diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h index 2b88ba5230d..ce82c06eca4 100644 --- a/gcc/tree-vrp.h +++ b/gcc/tree-vrp.h @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see #define GCC_TREE_VRP_H #include "value-range.h" +#include "value-range-storage.h" extern int compare_values (tree, tree); -- 2.56.0 From david.faust@oss.qualcomm.com Mon Nov 2 18:59:43 2026 From: david.faust@oss.qualcomm.com (David Faust) Date: Mon, 2 Nov 2026 10:59:43 -0800 Subject: [PATCH 2/2] bpf: CO-RE consumer of deferred constants In-Reply-To: <20261101025438.271424-1-yjn@yjn-systems.com> References: <20261101025158.271216-1-yjn@yjn-systems.com> <20261101025438.271424-1-yjn@yjn-systems.com> Message-ID: Hi Jasper, On 10/31/26 7:54 PM, York Jasper Niebuhr wrote: > Use deferred constants to preserve semantic information required for BPF > CO-RE relocations. > > Mark enum types for deferred enum values and record types carrying > "preserve_access_index" for deferred field offsets. Deferred constants > encountered during BPF lowering are either turned into CO-RE relocations > or resolved to their ordinary compile-time values when no relocation is > requested. > > Add a "preserve_enum_values" attribute for enum types. Enumerators of a > type carrying this attribute automatically generate > BPF_RELO_ENUMVAL_VALUE relocations. Thanks for the patch and for discussing at the gccbpf meeting today. This is interesting work and would be good to have for the backend. Having such an attribute to parallel the preserve_access_index attribute would be a nice improvement for usability. Currently BPF program authors need to remember to manually annotate access to kernel enums with the appropriate builtin. Inserting relos for offsetof when used on preserve-access-index types would also be a good improvement. As we discussed, it may be good to good to split the new attribute into its own patch since that will need some coordination with the kernel and clang folks. Minor but I think "preserve_enum_value" (non-plural) would be more inline with the naming used by existing CO-RE builtins/attributes/macros. > > Remove the bpf_enum_mappings workaround in favor of direct enum identity > recovery from deferred cst arguments to __builtin_preserve_enum_value. > > For record types carrying "preserve_access_index", deferred field > offsets originating from offsetof expressions are converted into > BPF_RELO_FIELD_BYTE_OFFSET relocations. Cupertino is most familiar with the existing CO-RE implementation so it would be good if he can take a more detailed look. Overall the changes seem sensible to me. I have a few questions/comments inline below. > > BPF CO-RE relocations can not currently be emitted for static data. Add > an IPA pass which resolves deferred constants in static initializers > before the generic deferred-constant barrier. Initializers which would > require CO-RE relocations are diagnosed. Support for such initializers > could be added in the future by generating relocated runtime > initialization code, for cases such as: > > struct task_struct { > ... > int x; > ... > } __attribute__((preserve_access_index)); > > static size_t OFF_X = offsetof (struct task_struct, x); Curious whether you tried compiling the kernel BPF selftests with this patch and whether this was actually a problem in practice, i.e. whether any of the selftests fail to compile. I will check and experiment a bit, but we might need to support this. Note you should also add ChangeLog entires for each patch. Thanks! > > Signed-off-by: York Jasper Niebuhr > --- > gcc/config/bpf/bpf-passes.def | 1 + > gcc/config/bpf/bpf-protos.h | 3 + > gcc/config/bpf/bpf.cc | 24 + > gcc/config/bpf/core-builtins.cc | 637 ++++++++++++++++-- > .../gcc.target/bpf/core-auto-drain-1.c | 29 + > .../gcc.target/bpf/core-auto-enum-value-1.c | 33 + > .../gcc.target/bpf/core-auto-field-offset-1.c | 36 + > 7 files changed, 712 insertions(+), 51 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/bpf/core-auto-drain-1.c > create mode 100644 gcc/testsuite/gcc.target/bpf/core-auto-enum-value-1.c > create mode 100644 gcc/testsuite/gcc.target/bpf/core-auto-field-offset-1.c > > diff --git a/gcc/config/bpf/bpf-passes.def b/gcc/config/bpf/bpf-passes.def > index eb0e9837d3a..eb0507fbec0 100644 > --- a/gcc/config/bpf/bpf-passes.def > +++ b/gcc/config/bpf/bpf-passes.def > @@ -18,3 +18,4 @@ > . */ > > INSERT_PASS_BEFORE (pass_lower_omp, 1, pass_lower_bpf_core); > +INSERT_PASS_BEFORE (pass_deferred_cst_barrier, 1, pass_bpf_deferred_static); > diff --git a/gcc/config/bpf/bpf-protos.h b/gcc/config/bpf/bpf-protos.h > index eee260b799b..db1e379577b 100644 > --- a/gcc/config/bpf/bpf-protos.h > +++ b/gcc/config/bpf/bpf-protos.h > @@ -36,6 +36,9 @@ const char *bpf_output_move (rtx *operands, const char *templ); > class gimple_opt_pass; > gimple_opt_pass *make_pass_lower_bpf_core (gcc::context *ctxt); > > +class simple_ipa_opt_pass; > +simple_ipa_opt_pass *make_pass_bpf_deferred_static (gcc::context *ctxt); > + > bool bpf_expand_cpymem (rtx *, bool); > bool bpf_expand_setmem (rtx *); > > diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc > index d852e2fbd70..06fd34ff542 100644 > --- a/gcc/config/bpf/bpf.cc > +++ b/gcc/config/bpf/bpf.cc > @@ -138,6 +138,25 @@ bpf_handle_preserve_access_index_attribute (tree *node, tree name, > return NULL_TREE; > } > > +/* Handle preserve_enum_values attribute, which can be applied to > + enums. Just warn for non-enumeration types. */ > + > +static tree > +bpf_handle_preserve_enum_values_attribute (tree *node, tree name, > + tree args ATTRIBUTE_UNUSED, > + int flags ATTRIBUTE_UNUSED, > + bool *no_add_attrs) > +{ > + if (TREE_CODE (*node) != ENUMERAL_TYPE) > + { > + warning (OPT_Wattributes, > + "%qE attribute only applies to enumeration types", name); > + *no_add_attrs = true; > + } > + > + return NULL_TREE; > +} > + > /* Target-specific attributes. */ > > TARGET_GNU_ATTRIBUTES (bpf_attribute_table, > @@ -155,6 +174,11 @@ TARGET_GNU_ATTRIBUTES (bpf_attribute_table, > { "preserve_access_index", 0, -1, false, true, false, true, > bpf_handle_preserve_access_index_attribute, NULL }, > > + /* CO-RE supoort: attribute to mark that all occurrences of values > + of the declared enum should be recorded. */ > + { "preserve_enum_values", 0, 0, false, true, false, true, > + bpf_handle_preserve_enum_values_attribute, NULL }, > + > /* Support for `naked' function attribute. */ > { "naked", 0, 1, false, false, false, false, > bpf_handle_fndecl_attribute, NULL } > diff --git a/gcc/config/bpf/core-builtins.cc b/gcc/config/bpf/core-builtins.cc > index a5c973cd385..9930026119e 100644 > --- a/gcc/config/bpf/core-builtins.cc > +++ b/gcc/config/bpf/core-builtins.cc > @@ -42,6 +42,9 @@ along with GCC; see the file COPYING3. If not see > #include "tree-pass.h" > #include "plugin.h" > #include "gimplify.h" > +#include "gimplify-me.h" > +#include "cgraph.h" > +#include "deferred-cst.h" > > #include "ctfc.h" > #include "btf.h" > @@ -356,6 +359,45 @@ is_attr_preserve_access (tree t) > return false; > } > > +/* Like is_attr_preserve_access, but FIELD is a FIELD_DECL. Returns > + true if FIELD belongs to a struct type with the > + PRESERVE_ACCESS_INDEX attribute. */ > + > +static bool > +is_attr_preserve_access_field (tree field) > +{ > + gcc_assert (field && TREE_CODE (field) == FIELD_DECL); > + > + tree type = DECL_FIELD_CONTEXT (field); > + > + return (type > + && TREE_CODE (type) == RECORD_TYPE > + && lookup_attribute ("preserve_access_index", > + TYPE_ATTRIBUTES (type))); > +} > + > +/* Handling for __attribute__((preserve_enum_values)) for BPF CO-RE support. > + > + This attribute marks an enum type as "preserve", so that every use > + of its values should be recorded and replayed by the BPF loader; > + This is just the same functionality as __builtin_preserve_enum_value, > + but in the form of an attribute for an entire enumeral type. */ > + > +/* True if DECL is a literal of an enumeral type which is marked with the > + PRESERVE_ENUM_VALUES attribute. */ > + > +static bool > +is_attr_preserve_enum_values (tree decl) > +{ > + gcc_assert (TREE_CODE (decl) == CONST_DECL); > + > + tree type = TREE_TYPE (decl); > + gcc_assert (TREE_CODE (type) == ENUMERAL_TYPE); > + > + return lookup_attribute ("preserve_enum_values", > + TYPE_ATTRIBUTES (type)) != NULL_TREE; > +} > + > static tree > root_for_core_field_info (tree node) > { > @@ -812,7 +854,6 @@ process_field_expr (struct cr_builtins *data) > return ret; > } > > -static GTY(()) hash_map *bpf_enum_mappings; > tree enum_value_type = NULL_TREE; > > static int > @@ -832,6 +873,74 @@ get_index_for_enum_value (tree type, tree expr) > return -1; > } > > +static bool > +deferred_enum_value_call_p (tree expr) > +{ > + return (expr > + && TREE_CODE (expr) == CALL_EXPR > + && CALL_EXPR_IFN (expr) == IFN_DEFERRED_CST_ENUM_VALUE); > +} > + > +static tree > +enum_decl_from_deferred_call (tree call) > +{ > + if (!deferred_enum_value_call_p (call) > + || call_expr_nargs (call) != 1) > + return NULL_TREE; > + > + tree decl > + = deferred_cst_ifn_enum_value_decl (CALL_EXPR_ARG (call, 0)); > + > + if (!decl > + || TREE_CODE (decl) != CONST_DECL > + || TREE_CODE (TREE_TYPE (decl)) != ENUMERAL_TYPE) > + return NULL_TREE; > + > + return decl; > +} > + > +static bool > +deferred_field_offset_call_p (tree expr) > +{ > + return (expr > + && TREE_CODE (expr) == CALL_EXPR > + && CALL_EXPR_IFN (expr) == IFN_DEFERRED_CST_FIELD_OFFSET); > +} > + > +static tree > +field_decl_from_deferred_call (tree call) > +{ > + if (!deferred_field_offset_call_p (call) > + || call_expr_nargs (call) != 1) > + return NULL_TREE; > + > + tree field > + = deferred_cst_ifn_field_offset_field (CALL_EXPR_ARG (call, 0)); > + > + if (!field || TREE_CODE (field) != FIELD_DECL) > + return NULL_TREE; > + > + return field; > +} > + > +/* Helper for pack_enum_value to retrieve the CONST_DECL for an enum > + value that is given as argument to __builtin_preserve_enum_value. > + > + ENUM_VALUE is expected to be a DEFERRED_CST_EXPR wrapping only a > + call to IFN_DEFERRED_CST_ENUM_VALUE, resembling a builtin parameter > + that is only a canonical enum value (no complex expressions). > + > + Returns NULL_TREE on failure. */ > + > +static tree > +deferred_cst_canonical_enum_value_decl (tree enum_value) > +{ > + if (!enum_value || TREE_CODE (enum_value) != DEFERRED_CST_EXPR) > + return NULL_TREE; > + > + return enum_decl_from_deferred_call (TREE_OPERAND (enum_value, 0)); > +} > + > /* Pack helper for the __builtin_preserve_enum_value. */ > > static struct cr_local > @@ -842,9 +951,8 @@ pack_enum_value (tree *args, enum btf_core_reloc_kind kind, > ret.reloc_decision = REPLACE_CREATE_RELOCATION; > ret.fail = false; > > - tree *result = NULL; > tree tmp = args[0]; > - tree enum_value = args[1]; > + tree deferred_enum_value = args[1]; > tree type = NULL_TREE; > > /* Deconstructing "*(typeof (enum_type) *) enum_value" to collect both the > @@ -859,33 +967,25 @@ pack_enum_value (tree *args, enum btf_core_reloc_kind kind, > ret.fail = true; > } > > - if (TREE_CODE (enum_value) != INTEGER_CST) > - goto pack_enum_value_fail; > - > - result = bpf_enum_mappings->get (enum_value); > - if (result == NULL) > - goto pack_enum_value_fail; > - > - tmp = *result; > - > - if (TREE_CODE (tmp) != CONST_DECL) > + tree enum_value > + = deferred_cst_canonical_enum_value_decl (deferred_enum_value); > + if (enum_value == NULL_TREE) > { > -pack_enum_value_fail: > bpf_error ("invalid enum value argument for enum value builtin"); > ret.fail = true; > } > else > { > - ret.reloc_data.expr = tmp; > + ret.reloc_data.expr = enum_value; > if (kind == BPF_RELO_ENUMVAL_VALUE) > - ret.reloc_data.default_value = enum_value; > + ret.reloc_data.default_value = DECL_INITIAL (enum_value); > else > ret.reloc_data.default_value = integer_one_node; > } > > - if (ret.fail == false ) > + if (ret.fail == false) > { > - int index = get_index_for_enum_value (type, tmp); > + int index = get_index_for_enum_value (type, enum_value); > if (index == -1 || index >= (1 << 16)) > { > bpf_error ("enum value in CO-RE builtin cannot be represented"); > @@ -1101,10 +1201,15 @@ read_kind (tree kind, char max_value, char enum_offset) > if (kind == NULL_TREE) > goto invalid_kind_arg_error; > > - if (TREE_CODE (kind) != CONST_DECL > - && TREE_CODE (kind) == NOP_EXPR) > + if (TREE_CODE (kind) == NOP_EXPR) > kind = TREE_OPERAND (kind, 0); > > + if (TREE_CODE (kind) == DEFERRED_CST_EXPR) > + kind = deferred_cst_canonical_enum_value_decl (kind); > + > + if (kind == NULL_TREE) > + goto invalid_kind_arg_error; > + > if (TREE_CODE (kind) == CONST_DECL) > kind = DECL_INITIAL (kind); > > @@ -1178,8 +1283,10 @@ kind_preserve_type_info (tree *args, int nargs) > return BPF_RELO_INVALID; > } > > -/* Plugin handler used in the parser that allows to collect enum value > - information that other wise would be folded and non recoverable. */ > +/* Plugin handler used in the parser that allows to mark all enum types > + and struct types attributed with "preserve_access_index" for constant > + deferral. This preserves information that would otherwise be > + folded by the frontend and non recoverable. */ > > void > bpf_handle_plugin_finish_type (void *event_data, > @@ -1187,22 +1294,12 @@ bpf_handle_plugin_finish_type (void *event_data, > { > tree type = (tree) event_data; > > - if (bpf_enum_mappings == NULL) > - bpf_enum_mappings = hash_map::create_ggc (10); > - > if (TREE_CODE (type) == ENUMERAL_TYPE) > - for (tree l = TYPE_VALUES (type); l; l = TREE_CHAIN (l)) > - { > - tree value = TREE_VALUE (l); > - > - tree initial = DECL_INITIAL (value); > - initial = copy_node (initial); > - DECL_INITIAL (value) = initial; > - > - tree *found = bpf_enum_mappings->get (initial); > - if (found == NULL) > - bpf_enum_mappings->put (initial, value); > - } > + deferred_cst_mark_type (type); > + else if (TREE_CODE (type) == RECORD_TYPE > + && lookup_attribute ("preserve_access_index", > + TYPE_ATTRIBUTES (type))) > + deferred_cst_mark_type (type); > } > > /* Initializes support information to process CO-RE builtins. > @@ -1258,6 +1355,25 @@ bpf_init_core_builtins (void) > bpf_handle_plugin_finish_type, NULL); > } > > +static tree > +construct_core_reloc_from_data (location_t loc, > + struct cr_builtins *reloc_data, > + builtin_helpers helper) > +{ > + int index = search_builtin_data (helper.compare, reloc_data); > + > + if (index == -1) > + index = allocate_builtin_data (); > + > + struct cr_builtins *data = get_builtin_data (index); > + memcpy (data, reloc_data, sizeof (struct cr_builtins)); > + > + tree fndecl = bpf_builtins[BPF_BUILTIN_CORE_RELOC]; > + > + return build_call_expr_loc (loc, fndecl, 1, > + build_int_cst (integer_type_node, index)); > +} > + > /* This function returns the related __builtin_core_reloc call tree node to a > particular CO-RE builtin definition in FNDECL when called with > arguments ARGS. */ > @@ -1294,23 +1410,364 @@ construct_builtin_core_reloc (location_t loc, tree fndecl, tree *args, > return error_mark_node; > > if (local_data.reloc_decision == REPLACE_CREATE_RELOCATION) > + return construct_core_reloc_from_data (loc, > + &local_data.reloc_data, > + helper); > + } > + return NULL_TREE; > +} > + > +/* Build a relocation for the enumerator DECL at LOC. */ > + > +static tree > +bpf_core_enum_value_reloc (location_t loc, tree decl) > +{ > + gcc_assert (TREE_CODE (decl) == CONST_DECL); > + > + tree type = TREE_TYPE (decl); > + gcc_assert (TREE_CODE (type) == ENUMERAL_TYPE); > + > + int enum_index = get_index_for_enum_value (type, decl); > + > + if (enum_index < 0 || enum_index >= (1 << 16)) > + { > + error_at (loc, > + "enum value cannot be represented in BPF CO-RE relocation"); > + return error_mark_node; > + } Hm, isn't this exact check already done by pack_enum_type ? Is it needed also here? > + > + struct cr_builtins data; > + memset (&data, 0, sizeof (data)); > + > + data.expr = decl; > + data.type = type; > + data.default_value = DECL_INITIAL (decl); > + data.kind = BPF_RELO_ENUMVAL_VALUE; > + data.orig_builtin_code = BPF_BUILTIN_PRESERVE_ENUM_VALUE; > + data.orig_arg_expr = decl; > + > + builtin_helpers helper > + = core_builtin_helpers[BPF_BUILTIN_PRESERVE_ENUM_VALUE]; > + > + return construct_core_reloc_from_data (loc, &data, helper); > +} > + > +/* Build a relocation for the offset of FIELD at LOC. Internally > + constructs a component reference for FIELD and passes it through > + the existing preserve-field-info builtin machinery. */ > + > +static tree > +bpf_core_field_offset_reloc (location_t loc, tree field) > +{ > + gcc_assert (TREE_CODE (field) == FIELD_DECL); > + > + tree record_type = DECL_FIELD_CONTEXT (field); > + gcc_assert (TREE_CODE (record_type) == RECORD_TYPE); > + > + /* Build an artificial COMPONENT_REF solely to feed the existing > + preserve-field-info packing machinery. */ > + tree object = build_decl (loc, VAR_DECL, NULL_TREE, record_type); > + DECL_ARTIFICIAL (object) = 1; > + DECL_IGNORED_P (object) = 1; > + > + tree ref = build3_loc (loc, COMPONENT_REF, TREE_TYPE (field), > + object, field, NULL_TREE); > + > + tree args[2]; > + args[0] = ref; > + args[1] = build_int_cst (integer_type_node, BPF_FIELD_BYTE_OFFSET); > + > + tree fndecl = bpf_builtins[BPF_BUILTIN_PRESERVE_FIELD_INFO]; > + > + return construct_builtin_core_reloc (loc, fndecl, args, 2); > +} > + > +enum bpf_deferred_mode > +{ > + BPF_DEFERRED_GIMPLE, > + BPF_DEFERRED_STATIC > +}; > + > + > +/* Lower the expression EXPR under a DEFERRED_CST_EXPR wrapper according > + to MODE. > + > + Deferred enum values and field offsets selected for CO-RE via type > + attributes are replaced by corresponding relocation expressions. > + > + Deferred values that are not selected for CO-RE are resolved to > + their ordinary compile-time values. > + > + In BPF_DEFERRED_STATIC mode, CO-RE relocations may not be emitted. > + Future instrumentation logic could automatically generate update-code > + or relocations for static data that depends on CO-RE values. > +*/ > + > +static tree > +bpf_lower_deferred_inner (tree expr, enum bpf_deferred_mode mode) > +{ > + if (!expr) > + return NULL_TREE; > + > + if (CONSTANT_CLASS_P (expr)) > + return expr; > + > + if (TREE_CODE (expr) == DEFERRED_CST_EXPR) > + { > + error_at (EXPR_LOCATION (expr), "nested deferred constant expression"); > + return error_mark_node; Can this error case result from valid code, or is it something that would only arise from the compiler doing something incorrect? > + } > + > + if (deferred_enum_value_call_p (expr)) > + { > + tree decl = enum_decl_from_deferred_call (expr); > + > + if (!decl) > + { > + error_at (EXPR_LOCATION (expr), > + "malformed deferred enum value"); > + return error_mark_node; Same question here, and I think once more below. If these malformations are a result of compiler doing something wrong then I think a gcc_assert (decl) is warranted instead, i.e. ICE. > + } > + > + if (!is_attr_preserve_enum_values (decl)) > + return fold_convert_loc (EXPR_LOCATION (expr), > + TREE_TYPE (expr), > + DECL_INITIAL (decl)); > + > + if (mode == BPF_DEFERRED_STATIC) > + { > + error_at (EXPR_LOCATION (expr), > + "BPF CO-RE enum values are not yet supported " > + "in static initializers"); > + > + /* Remove the deferred node after diagnosing, so that the generic > + deferred-CST barrier doesn't diagnose it again. */ > + return fold_convert_loc (EXPR_LOCATION (expr), > + TREE_TYPE (expr), > + DECL_INITIAL (decl)); > + } > + > + tree reloc > + = bpf_core_enum_value_reloc (EXPR_LOCATION (expr), decl); > + > + if (reloc == error_mark_node) > + return reloc; > + > + return fold_convert_loc (EXPR_LOCATION (expr), > + TREE_TYPE (expr), reloc); > + } > + > + if (deferred_field_offset_call_p (expr)) > + { > + tree field = field_decl_from_deferred_call (expr); > + > + if (!field) > { > - int index = search_builtin_data (helper.compare, > - &local_data.reloc_data); > - if (index == -1) > - index = allocate_builtin_data (); > - struct cr_builtins *data = get_builtin_data (index); > - memcpy (data, &local_data.reloc_data, sizeof (struct cr_builtins)); > - > - tree fndecl = bpf_builtins[BPF_BUILTIN_CORE_RELOC]; > - return build_call_expr_loc (loc, > - fndecl, 1, > - build_int_cst (integer_type_node, index)); > + error_at (EXPR_LOCATION (expr), > + "malformed deferred field offset"); > + return error_mark_node; > } > + > + if (!is_attr_preserve_access_field (field)) > + return fold_convert_loc (EXPR_LOCATION (expr), > + TREE_TYPE (expr), > + byte_position (field)); > + > + if (mode == BPF_DEFERRED_STATIC) > + { > + error_at (EXPR_LOCATION (expr), > + "BPF CO-RE field offsets are not yet supported " > + "in static initializers"); > + > + return fold_convert_loc (EXPR_LOCATION (expr), > + TREE_TYPE (expr), > + byte_position (field)); > + } > + > + tree reloc > + = bpf_core_field_offset_reloc (EXPR_LOCATION (expr), field); > + > + if (reloc == error_mark_node) > + return reloc; > + > + return fold_convert_loc (EXPR_LOCATION (expr), > + TREE_TYPE (expr), reloc); > } > + > + tree copy = copy_node (expr); > + > + for (int i = 0; i < TREE_OPERAND_LENGTH (expr); ++i) > + { > + tree op = TREE_OPERAND (expr, i); > + > + if (!op) > + continue; > + > + TREE_OPERAND (copy, i) > + = bpf_lower_deferred_inner (op, mode); > + } > + > + return mode == BPF_DEFERRED_STATIC ? fold (copy) : copy; > +} > + > +/* Lower a deferred constant expression WRAPPER according to the > + transformations defined in bpf_lower_deferred_inner. */ > + > +static tree > +bpf_lower_deferred_wrapper (tree wrapper, enum bpf_deferred_mode mode) > +{ > + gcc_assert (wrapper && TREE_CODE (wrapper) == DEFERRED_CST_EXPR); > + > + tree inner = TREE_OPERAND (wrapper, 0); > + return bpf_lower_deferred_inner (inner, mode); > +} > + > +/* Tree-walk callback for lowering deferred constants in GIMPLE statements. > + > + Replaces each DEFERRED_CST_EXPR with its lowered and gimplified > + equivalent. Any new gimple statements are inserted immediately > + before the current statement. */ > + > +static tree > +bpf_lower_deferred_tree (tree *tp, int *walk_subtrees, void *data) > +{ > + tree node = *tp; > + > + if (!node) > + return NULL_TREE; > + > + if (TYPE_P (node) || DECL_P (node)) > + { > + *walk_subtrees = 0; > + return NULL_TREE; > + } > + > + if (TREE_CODE (node) != DEFERRED_CST_EXPR) > + return NULL_TREE; > + > + struct walk_stmt_info *wi > + = static_cast (data); > + > + /* First transform the complete deferred expression. */ > + tree replacement > + = bpf_lower_deferred_wrapper (node, BPF_DEFERRED_GIMPLE); > + > + if (replacement == error_mark_node) > + { > + *tp = replacement; > + *walk_subtrees = 0; > + return NULL_TREE; > + } > + > + /* Turn the resulting GENERIC expression into a GIMPLE value. Any > + statements required to compute it are emitted into BEFORE. */ > + gimple_seq before = NULL; > + > + push_gimplify_context (); > + > + gimplify_expr (&replacement, &before, NULL, > + is_gimple_val, fb_rvalue); > + > + pop_gimplify_context (NULL); > + > + /* Insert computation of REPLACEMENT immediately before the > + statement containing the original DEFERRED_CST_EXPR. */ > + if (before) > + gsi_insert_seq_before (&wi->gsi, before, GSI_SAME_STMT); > + > + /* REPLACEMENT is now a valid GIMPLE value. */ > + *tp = replacement; > + > + /* Do not walk the newly generated expression. */ > + *walk_subtrees = 0; > + > return NULL_TREE; > } > > +/* Return true if the initializer expression EXPR contains deferred > + constants. */ > + > +static bool > +bpf_initializer_has_deferred (tree expr) > +{ > + if (!expr || DECL_P (expr) || TYPE_P (expr)) > + return false; > + > + if (TREE_CODE (expr) == DEFERRED_CST_EXPR) > + return true; > + > + if (TREE_CODE (expr) == CONSTRUCTOR) > + { > + unsigned HOST_WIDE_INT i; > + tree index, value; > + > + FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (expr), i, index, value) > + if (bpf_initializer_has_deferred (value)) > + return true; > + > + return false; > + } > + > + for (int i = 0; i < TREE_OPERAND_LENGTH (expr); ++i) > + if (bpf_initializer_has_deferred (TREE_OPERAND (expr, i))) > + return true; > + > + return false; > +} > + > +/* Resolves deferred constants in the static initializer expression > + EXPR. Deferred constants that do not require CO-RE relocations > + (because the corresponding types are not attributed accordingly) > + are replaced with their ordinary compile-time values. > + > + Expressions that would require CO-RE relocations are diagnosed as > + errors. Support for those may be added in the future. */ > + > +static tree > +bpf_transform_initializer (tree expr) > +{ > + if (!expr || DECL_P (expr) || TYPE_P (expr) || CONSTANT_CLASS_P (expr)) > + return expr; > + > + if (TREE_CODE (expr) == DEFERRED_CST_EXPR) > + return bpf_lower_deferred_wrapper (expr, BPF_DEFERRED_STATIC); > + > + if (TREE_CODE (expr) == CONSTRUCTOR) > + { > + vec *elts = NULL; > + unsigned HOST_WIDE_INT i; > + tree index, value; > + > + FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (expr), i, index, value) > + { > + tree replacement = bpf_transform_initializer (value); > + CONSTRUCTOR_APPEND_ELT (elts, index, replacement); > + } > + > + tree result = build_constructor (TREE_TYPE (expr), elts); > + > + TREE_CONSTANT (result) = TREE_CONSTANT (expr); > + TREE_STATIC (result) = TREE_STATIC (expr); > + > + return result; > + } > + > + if (!bpf_initializer_has_deferred (expr)) > + return expr; > + > + tree copy = copy_node (expr); > + > + for (int i = 0; i < TREE_OPERAND_LENGTH (expr); ++i) > + { > + tree op = TREE_OPERAND (expr, i); > + > + if (op) > + TREE_OPERAND (copy, i) = bpf_transform_initializer (op); > + } > + > + return fold (copy); > +} > + > /* This function constructs the CO-RE safe code around field expressions. > If the expression is an array access, create an offset by multiplying the > index access by the __builtin_type_info call requesting the size of the > @@ -1944,11 +2401,13 @@ core_make_builtins (tree *tp, int *walk_subtrees, void *data) > return NULL_TREE; > } > > -/* This is the entry point for the pass_data_lower_bpg_core. It walks all the > +/* This is the entry point for the pass_lower_bpf_core. It walks all the > statements in gimple, looking for expressions that are suppose to be CO-RE > preserve_access_index attributed, and should not. > - It first splits CO-RE expressions from non CO-RE ones. > - Then the CO-RE expressions are processed by core_make_builtins which will > + It first instruments only deferred constant field offsets and enum values, > + turning those relevant to CO-RE into relocations. > + Then it splits all CO-RE expressions from non CO-RE ones. > + Finally, the CO-RE expressions are processed by core_make_builtins which will > create the required builtins that will result in the CO-RE relocations. */ > static unsigned int > execute_lower_bpf_core (void) > @@ -1962,6 +2421,11 @@ execute_lower_bpf_core (void) > struct walk_stmt_info wi; > memset (&wi, 0, sizeof (wi)); > > + /* Deferred constants are still represented as GENERIC expression trees > + embedded in GIMPLE operands. Replace their leaves with ordinary > + constants or BPF CO-RE relocation calls. */ > + walk_gimple_seq_mod (&body, NULL, bpf_lower_deferred_tree, &wi); > + > /* Early split to guarantee base of expression is a preserve_access_index > structure. */ > walk_gimple_seq_mod (&body, NULL, gimple_core_early_split_expr, &wi); > @@ -1971,6 +2435,45 @@ execute_lower_bpf_core (void) > return 0; > } > > +/* This is the entry point for pass_bpf_deferred_static. It iterates > + over all static initializers to lower deferred constants. */ > + > +static unsigned int > +execute_bpf_deferred_static (void) > +{ > + if (!TARGET_BPF_CORE) > + return 0; > + > + varpool_node *vnode; > + > + FOR_EACH_VARIABLE (vnode) > + { > + tree decl = vnode->decl; > + > + if (!decl > + || TREE_CODE (decl) != VAR_DECL > + || DECL_EXTERNAL (decl) > + || !TREE_STATIC (decl)) > + continue; > + > + tree init = DECL_INITIAL (decl); > + > + if (!init || !bpf_initializer_has_deferred (init)) > + continue; > + > + tree replacement = bpf_transform_initializer (init); > + > + DECL_INITIAL (decl) = replacement; > + > + /* Even after emitting an error for an attributed leaf we replace it by > + its local compile-time value. Therefore absolutely no deferred node > + should survive this pass. */ > + gcc_assert (!bpf_initializer_has_deferred (replacement)); > + } > + > + return 0; > +} > + > namespace { > > const pass_data pass_data_lower_bpf_core = > @@ -2001,6 +2504,32 @@ public: > > }; /* class pass_lower_bpf_core */ > > +const pass_data pass_data_bpf_deferred_static = > +{ > + SIMPLE_IPA_PASS, /* type */ > + "bpf_deferred_static", /* name */ > + OPTGROUP_NONE, /* optinfo_flags */ > + TV_NONE, /* tv_id */ > + 0, /* properties_required */ > + 0, /* properties_provided */ > + 0, /* properties_destroyed */ > + 0, /* todo_flags_start */ > + 0, /* todo_flags_finish */ > +}; > + > +class pass_bpf_deferred_static : public simple_ipa_opt_pass > +{ > +public: > + pass_bpf_deferred_static (gcc::context *ctxt) > + : simple_ipa_opt_pass (pass_data_bpf_deferred_static, ctxt) > + {} > + > + unsigned int execute (function *) final override > + { > + return execute_bpf_deferred_static (); > + } > +}; > + > } /* anon namespace */ > > gimple_opt_pass * > @@ -2009,4 +2538,10 @@ make_pass_lower_bpf_core (gcc::context *ctxt) > return new pass_lower_bpf_core (ctxt); > } > > +simple_ipa_opt_pass * > +make_pass_bpf_deferred_static (gcc::context *ctxt) > +{ > + return new pass_bpf_deferred_static (ctxt); > +} > + > #include "gt-core-builtins.h" > diff --git a/gcc/testsuite/gcc.target/bpf/core-auto-drain-1.c b/gcc/testsuite/gcc.target/bpf/core-auto-drain-1.c > new file mode 100644 > index 00000000000..660b5df9d3f > --- /dev/null > +++ b/gcc/testsuite/gcc.target/bpf/core-auto-drain-1.c > @@ -0,0 +1,29 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O0 -dA -gbtf -mco-re -masm=normal" } */ > + > +enum E > +{ > + A = 1, > + B = 2 > +}; > + > +int > +foo (void) > +{ > + return B; > +} > + > +struct S > +{ > + int a; > + long b; > + int c; > +}; > + > +unsigned long > +bar (void) > +{ > + return __builtin_offsetof (struct S, c); > +} > + > +/* { dg-final { scan-assembler-not "bpfcr_kind" } } */ > diff --git a/gcc/testsuite/gcc.target/bpf/core-auto-enum-value-1.c b/gcc/testsuite/gcc.target/bpf/core-auto-enum-value-1.c > new file mode 100644 > index 00000000000..2bd21fa6146 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/bpf/core-auto-enum-value-1.c > @@ -0,0 +1,33 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O0 -dA -gbtf -mco-re -masm=normal" } */ > + > +enum E > +{ > + A = 1, > + B = 1, > + C = 3 > +} __attribute__((preserve_enum_values)); > + > +int > +foo (void) > +{ > + return A + B + C; > +} > + > +/* Check the local values. A and B deliberately have the same value. */ > +/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],1" 2 } } */ > +/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],3" 1 } } */ > + > +/* Check the BTF access strings for the three enumerators. */ > +/* { dg-final { scan-assembler-times "ascii \"0.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ > +/* { dg-final { scan-assembler-times "ascii \"1.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ > +/* { dg-final { scan-assembler-times "ascii \"2.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ > + > +/* Check that the relocations identify A, B and C independently. */ > +/* { dg-final { scan-assembler-times "bpfcr_type \\(E\\)" 3 } } */ > +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0\"\\)" 1 } } */ > +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"1\"\\)" 1 } } */ > +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"2\"\\)" 1 } } */ > + > +/* All three are BPF_CORE_ENUMVAL_VALUE relocations. */ > +/* { dg-final { scan-assembler-times "0xb\[\t \]+\[^\n\]*bpfcr_kind" 3 } } */ > diff --git a/gcc/testsuite/gcc.target/bpf/core-auto-field-offset-1.c b/gcc/testsuite/gcc.target/bpf/core-auto-field-offset-1.c > new file mode 100644 > index 00000000000..e06d42ef45c > --- /dev/null > +++ b/gcc/testsuite/gcc.target/bpf/core-auto-field-offset-1.c > @@ -0,0 +1,36 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O0 -dA -gbtf -mco-re -masm=normal" } */ > + > +struct S > +{ > + int a; > + long b; > + int c; > +} __attribute__((preserve_access_index)); > + > +unsigned long > +foo (void) > +{ > + return (__builtin_offsetof (struct S, a) > + + __builtin_offsetof (struct S, b) > + + __builtin_offsetof (struct S, c)); > +} > + > +/* Check the local field offsets. */ > +/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],0" 1 } } */ > +/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],8" 1 } } */ > +/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],16" 1 } } */ > + > +/* Check the BTF access strings. */ > +/* { dg-final { scan-assembler-times "ascii \"0:0.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ > +/* { dg-final { scan-assembler-times "ascii \"0:1.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ > +/* { dg-final { scan-assembler-times "ascii \"0:2.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ > + > +/* Check that each relocation identifies the correct field. */ > +/* { dg-final { scan-assembler-times "bpfcr_type \\(struct S\\)" 3 } } */ > +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0:0\"\\)" 1 } } */ > +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0:1\"\\)" 1 } } */ > +/* { dg-final { scan-assembler-times "bpfcr_astr_off \\(\"0:2\"\\)" 1 } } */ > + > +/* All three are BPF_FIELD_BYTE_OFFSET relocations. */ > +/* { dg-final { scan-assembler-times "0\[\t \]+\[^\n\]*bpfcr_kind" 3 } } */ From dmalcolm@redhat.com Mon Nov 2 19:24:19 2026 From: dmalcolm@redhat.com (David Malcolm) Date: Mon, 02 Nov 2026 14:24:19 -0500 Subject: [pushed: r17-5669] analyzer: add analyzer-graphs=yes|no option to SARIF output In-Reply-To: References: <20261028150205.3705520-1-dmalcolm@redhat.com> <5b109a8298ec57c47a18752ce5942b7a99d5a81a.camel@redhat.com> Message-ID: On Mon, 2026-11-02 at 10:38 +0100, Rainer Orth wrote: > Hi David, > > > On Thu, 2026-10-29 at 09:43 +0100, Andreas Schwab wrote: > > > g++ -std=c++14 -c?? -g -O2 -DIN_GCC??? -fno-exceptions -fno-rtti > > > - > > > fasynchronous-unwind-tables -W -Wall -Wno-error=narrowing - > > > Wwrite- > > > strings -Wcast-qual -Wno-format -Wmissing-format-attribute - > > > Wconditionally-supported -Woverloaded-virtual -pedantic -Wno- > > > long- > > > long -Wno-variadic-macros -Wno-overlength-strings? - > > > DHAVE_CONFIG_H? - > > > DGENERATOR_FILE -I. -Ibuild -I../../gcc -I../../gcc/build - > > > I../../gcc/../include? -I../../gcc/../libcpp/include? \ > > > ??????? -o build/print-rtl.o ../../gcc/print-rtl.cc > > > In file included from ../../gcc/print-rtl.cc:57: > > > ../../gcc/json.h:226:57: error: ?std::string? has not been > > > declared > > > ? 226 |?? const json::string *set_string (const char *key, > > > std::string utf8_value); > > > ????? |???????????????????????????????????????????????????????? > > > ^~~~~~ > > > ../../gcc/json.h:25:1: note: ?std::string? is defined in header > > > ??; this is probably fixable by adding ?#include > > > ? > > > ?? 24 | #include "label-text.h" > > > ? +++ |+#include > > > ?? 25 | > > > make[3]: *** [Makefile:3297: build/print-rtl.o] Error 1 > > > > [adding the list this time] > > > > Sorry about the breakage.?? Does the attached patch fix things for > > you? > > worked for me to unbreak amd64-pc-openbsd8.0 bootstrap. Thanks; I've pushed it as r17-5823-g40597e5d10c882. Sorry again about the breakage. Dave From dmalcolm@redhat.com Mon Nov 2 19:24:00 2026 From: dmalcolm@redhat.com (David Malcolm) Date: Mon, 02 Nov 2026 14:24:00 -0500 Subject: [pushed: r17-5669] analyzer: add analyzer-graphs=yes|no option to SARIF output In-Reply-To: References: <20261028150205.3705520-1-dmalcolm@redhat.com> <5b109a8298ec57c47a18752ce5942b7a99d5a81a.camel@redhat.com> Message-ID: On Mon, 2026-11-02 at 13:19 +0100, Andreas Schwab wrote: > On Okt 30 2026, David Malcolm wrote: > > > Sorry about the breakage.?? Does the attached patch fix things for > > you? > > Yes, it does. Thanks; I've pushed it as r17-5823-g40597e5d10c882. Sorry again about the breakage. Dave From dmalcolm@redhat.com Mon Nov 2 19:30:18 2026 From: dmalcolm@redhat.com (David Malcolm) Date: Mon, 2 Nov 2026 14:30:18 -0500 Subject: [pushed: r17-5824] json: expose ASSERT_PRINT_EQ as ASSERT_JSON_PRINT_EQ Message-ID: <20261102193018.1295716-1-dmalcolm@redhat.com> Replace a couple of repeated ASSERT_PRINT_EQ for selftests of json with a single ASSERT_JSON_PRINT_EQ in json.h. No functional change intended. Successfully bootstrapped & regrtested on aarch64-unknown-linux-gnu. Pushed to trunk as r17-5824-gb958cb790e142d. gcc/ChangeLog: * json-parsing.cc (ASSERT_PRINT_EQ): Move to json.h and rename to ASSERT_JSON_PRINT_EQ. (selftest::test_parse_string): Update for above renaming. (selftest::test_parse_number): Likewise. (selftest::test_parse_array): Likewise. (selftest::test_parse_literals): Likewise. (selftest::test_parse_empty_object): Likewise. * json.cc (selftest::assert_print_eq): Rename to... (selftest::assert_json_print_eq): ...this. (ASSERT_PRINT_EQ): Delete. (selftest::test_writing_objects): Update for renaming of ASSERT_PRINT_EQ to ASSERT_JSON_PRINT_EQ. (selftest::test_writing_arrays): Likewise. (selftest::test_writing_float_numbers): Likewise. (selftest::test_writing_integer_numbers): Likewise. (selftest::test_writing_strings): Likewise. (selftest::test_writing_literals): Likewise. (selftest::test_formatting): Likewise. (selftest::test_comparisons): Likewise. * json.h (selftest::assert_print_eq): Rename decl to... (selftest::assert_json_print_eq): ...this. (ASSERT_JSON_PRINT_EQ): New, moved here from json-parsing.cc. Signed-off-by: David Malcolm --- gcc/json-parsing.cc | 27 +++++------ gcc/json.cc | 106 ++++++++++++++++++++++---------------------- gcc/json.h | 13 ++++-- 3 files changed, 74 insertions(+), 72 deletions(-) diff --git a/gcc/json-parsing.cc b/gcc/json-parsing.cc index acbcff8ed44..db9566853f8 100644 --- a/gcc/json-parsing.cc +++ b/gcc/json-parsing.cc @@ -1420,9 +1420,6 @@ namespace selftest { /* Selftests. */ -#define ASSERT_PRINT_EQ(JV, FORMATTED, EXPECTED_JSON) \ - assert_print_eq (SELFTEST_LOCATION, JV, FORMATTED, EXPECTED_JSON) - /* Implementation detail of ASSERT_RANGE_EQ. */ static void @@ -1921,7 +1918,7 @@ test_parse_string () const json::value *jv = tc.get_value (); ASSERT_EQ (jv->get_kind (), JSON_STRING); ASSERT_STREQ (as_a (jv)->get_string (), "foo"); - ASSERT_PRINT_EQ (*jv, true, "\"foo\""); + ASSERT_JSON_PRINT_EQ (*jv, true, "\"foo\""); auto range = tc.get_range_for_value (jv); ASSERT_TRUE (range); ASSERT_RANGE_EQ (*range, @@ -1937,7 +1934,7 @@ test_parse_string () ASSERT_EQ (jv->get_kind (), JSON_STRING); ASSERT_STREQ (as_a (jv)->get_string (), "before \"quoted\" after"); - ASSERT_PRINT_EQ (*jv, true, contains_quotes); + ASSERT_JSON_PRINT_EQ (*jv, true, contains_quotes); auto range = tc.get_range_for_value (jv); ASSERT_TRUE (range); ASSERT_RANGE_EQ (*range, @@ -1976,7 +1973,7 @@ test_parse_string () ASSERT_STREQ (as_a (jv)->get_string (), "\346\226\207" "\345\255\227" "\345\214\226" "\343\201\221"); /* Result of dump should be UTF-8 encoded, with quotes. */ - ASSERT_PRINT_EQ (*jv, false, mojibake); + ASSERT_JSON_PRINT_EQ (*jv, false, mojibake); auto range = tc.get_range_for_value (jv); ASSERT_TRUE (range); ASSERT_RANGE_EQ (*range, @@ -1995,7 +1992,7 @@ test_parse_string () ASSERT_STREQ (as_a (jv)->get_string (), "\346\226\207" "\345\255\227" "\345\214\226" "\343\201\221"); /* Result of dump should be UTF-8 encoded, with quotes. */ - ASSERT_PRINT_EQ (*jv, false, mojibake); + ASSERT_JSON_PRINT_EQ (*jv, false, mojibake); auto range = tc.get_range_for_value (jv); ASSERT_TRUE (range); ASSERT_RANGE_EQ (*range, @@ -2017,7 +2014,7 @@ test_parse_number () const json::value *jv = tc.get_value (); ASSERT_EQ (jv->get_kind (), JSON_INTEGER); ASSERT_EQ (as_a (jv)->get (), 42.0); - ASSERT_PRINT_EQ (*jv, true, "42"); + ASSERT_JSON_PRINT_EQ (*jv, true, "42"); auto range = tc.get_range_for_value (jv); ASSERT_TRUE (range); ASSERT_RANGE_EQ (*range, @@ -2032,7 +2029,7 @@ test_parse_number () const json::value *jv = tc.get_value (); ASSERT_EQ (jv->get_kind (), JSON_INTEGER); ASSERT_EQ (as_a (jv)->get (), -17.0); - ASSERT_PRINT_EQ (*jv, true, "-17"); + ASSERT_JSON_PRINT_EQ (*jv, true, "-17"); auto range = tc.get_range_for_value (jv); ASSERT_TRUE (range); ASSERT_RANGE_EQ (*range, @@ -2074,7 +2071,7 @@ test_parse_number () const json::value *jv = tc.get_value (); ASSERT_EQ (jv->get_kind (), JSON_INTEGER); ASSERT_EQ (as_a (jv)->get (), 4200); - ASSERT_PRINT_EQ (*jv, true, "4200"); + ASSERT_JSON_PRINT_EQ (*jv, true, "4200"); auto range = tc.get_range_for_value (jv); ASSERT_TRUE (range); ASSERT_RANGE_EQ (*range, @@ -2126,7 +2123,7 @@ test_parse_array () offset, line_1, offset, offset, line_1, offset); } - ASSERT_PRINT_EQ (*jv, false, "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); + ASSERT_JSON_PRINT_EQ (*jv, false, "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"); } /* Verify that JSON object parsing works. */ @@ -2208,7 +2205,7 @@ test_parse_literals () const json::value *jv = tc.get_value (); ASSERT_NE (jv, nullptr); ASSERT_EQ (jv->get_kind (), JSON_TRUE); - ASSERT_PRINT_EQ (*jv, false, "true"); + ASSERT_JSON_PRINT_EQ (*jv, false, "true"); auto range = tc.get_range_for_value (jv); ASSERT_TRUE (range); ASSERT_RANGE_EQ (*range, @@ -2222,7 +2219,7 @@ test_parse_literals () const json::value *jv = tc.get_value (); ASSERT_NE (jv, nullptr); ASSERT_EQ (jv->get_kind (), JSON_FALSE); - ASSERT_PRINT_EQ (*jv, false, "false"); + ASSERT_JSON_PRINT_EQ (*jv, false, "false"); auto range = tc.get_range_for_value (jv); ASSERT_TRUE (range); ASSERT_RANGE_EQ (*range, @@ -2236,7 +2233,7 @@ test_parse_literals () const json::value *jv = tc.get_value (); ASSERT_NE (jv, nullptr); ASSERT_EQ (jv->get_kind (), JSON_NULL); - ASSERT_PRINT_EQ (*jv, false, "null"); + ASSERT_JSON_PRINT_EQ (*jv, false, "null"); auto range = tc.get_range_for_value (jv); ASSERT_TRUE (range); ASSERT_RANGE_EQ (*range, @@ -2284,7 +2281,7 @@ test_parse_empty_object () const json::value *jv = tc.get_value (); ASSERT_NE (jv, nullptr); ASSERT_EQ (jv->get_kind (), JSON_OBJECT); - ASSERT_PRINT_EQ (*jv, true, "{}"); + ASSERT_JSON_PRINT_EQ (*jv, true, "{}"); auto range = tc.get_range_for_value (jv); ASSERT_TRUE (range); ASSERT_RANGE_EQ (*range, diff --git a/gcc/json.cc b/gcc/json.cc index c776d02d335..af3346516fe 100644 --- a/gcc/json.cc +++ b/gcc/json.cc @@ -714,19 +714,16 @@ namespace selftest { /* Verify that JV->print () prints EXPECTED_JSON. */ void -assert_print_eq (const location &loc, - const json::value &jv, - bool formatted, - const char *expected_json) +assert_json_print_eq (const location &loc, + const json::value &jv, + bool formatted, + const char *expected_json) { pretty_printer pp; jv.print (&pp, formatted); ASSERT_STREQ_AT (loc, expected_json, pp_formatted_text (&pp)); } -#define ASSERT_PRINT_EQ(JV, FORMATTED, EXPECTED_JSON) \ - assert_print_eq (SELFTEST_LOCATION, JV, FORMATTED, EXPECTED_JSON) - /* Verify that object::get works as expected. */ static void @@ -751,13 +748,15 @@ test_writing_objects () /* This test relies on json::object writing out key/value pairs in key-insertion order. */ - ASSERT_PRINT_EQ (obj, true, - "{\"foo\": \"bar\",\n" - " \"baz\": \"quux\",\n" - " \"\\\"\\\\\\b\\f\\n\\r\\t\": \"value for awkward key\"}"); - ASSERT_PRINT_EQ (obj, false, - "{\"foo\": \"bar\", \"baz\": \"quux\"" - ", \"\\\"\\\\\\b\\f\\n\\r\\t\": \"value for awkward key\"}"); + ASSERT_JSON_PRINT_EQ + (obj, true, + "{\"foo\": \"bar\",\n" + " \"baz\": \"quux\",\n" + " \"\\\"\\\\\\b\\f\\n\\r\\t\": \"value for awkward key\"}"); + ASSERT_JSON_PRINT_EQ + (obj, false, + "{\"foo\": \"bar\", \"baz\": \"quux\"" + ", \"\\\"\\\\\\b\\f\\n\\r\\t\": \"value for awkward key\"}"); } /* Verify that JSON arrays are written correctly. */ @@ -766,17 +765,17 @@ static void test_writing_arrays () { array arr; - ASSERT_PRINT_EQ (arr, true, "[]"); + ASSERT_JSON_PRINT_EQ (arr, true, "[]"); arr.append (new json::string ("foo")); - ASSERT_PRINT_EQ (arr, true, "[\"foo\"]"); + ASSERT_JSON_PRINT_EQ (arr, true, "[\"foo\"]"); arr.append_string ("bar"); - ASSERT_PRINT_EQ (arr, true, - "[\"foo\",\n" - " \"bar\"]"); - ASSERT_PRINT_EQ (arr, false, - "[\"foo\", \"bar\"]"); + ASSERT_JSON_PRINT_EQ (arr, true, + "[\"foo\",\n" + " \"bar\"]"); + ASSERT_JSON_PRINT_EQ (arr, false, + "[\"foo\", \"bar\"]"); } /* Verify that JSON numbers are written correctly. */ @@ -784,20 +783,20 @@ test_writing_arrays () static void test_writing_float_numbers () { - ASSERT_PRINT_EQ (float_number (0), true, "0"); - ASSERT_PRINT_EQ (float_number (42), true, "42"); - ASSERT_PRINT_EQ (float_number (-100), true, "-100"); - ASSERT_PRINT_EQ (float_number (123456789), true, "1.23457e+08"); + ASSERT_JSON_PRINT_EQ (float_number (0), true, "0"); + ASSERT_JSON_PRINT_EQ (float_number (42), true, "42"); + ASSERT_JSON_PRINT_EQ (float_number (-100), true, "-100"); + ASSERT_JSON_PRINT_EQ (float_number (123456789), true, "1.23457e+08"); } static void test_writing_integer_numbers () { - ASSERT_PRINT_EQ (integer_number (0), true, "0"); - ASSERT_PRINT_EQ (integer_number (42), true, "42"); - ASSERT_PRINT_EQ (integer_number (-100), true, "-100"); - ASSERT_PRINT_EQ (integer_number (123456789), true, "123456789"); - ASSERT_PRINT_EQ (integer_number (-123456789), true, "-123456789"); + ASSERT_JSON_PRINT_EQ (integer_number (0), true, "0"); + ASSERT_JSON_PRINT_EQ (integer_number (42), true, "42"); + ASSERT_JSON_PRINT_EQ (integer_number (-100), true, "-100"); + ASSERT_JSON_PRINT_EQ (integer_number (123456789), true, "123456789"); + ASSERT_JSON_PRINT_EQ (integer_number (-123456789), true, "-123456789"); } /* Verify that JSON strings are written correctly. */ @@ -806,16 +805,17 @@ static void test_writing_strings () { string foo ("foo"); - ASSERT_PRINT_EQ (foo, true, "\"foo\""); + ASSERT_JSON_PRINT_EQ (foo, true, "\"foo\""); string contains_quotes ("before \"quoted\" after"); - ASSERT_PRINT_EQ (contains_quotes, true, "\"before \\\"quoted\\\" after\""); + ASSERT_JSON_PRINT_EQ (contains_quotes, true, + "\"before \\\"quoted\\\" after\""); const char data[] = {'a', 'b', 'c', 'd', '\0', 'e', 'f'}; string not_terminated (data, 3); - ASSERT_PRINT_EQ (not_terminated, true, "\"abc\""); + ASSERT_JSON_PRINT_EQ (not_terminated, true, "\"abc\""); string embedded_null (data, sizeof data); - ASSERT_PRINT_EQ (embedded_null, true, "\"abcd\\0ef\""); + ASSERT_JSON_PRINT_EQ (embedded_null, true, "\"abcd\\0ef\""); } /* Verify that JSON literals are written correctly. */ @@ -823,12 +823,12 @@ test_writing_strings () static void test_writing_literals () { - ASSERT_PRINT_EQ (literal (JSON_TRUE), true, "true"); - ASSERT_PRINT_EQ (literal (JSON_FALSE), true, "false"); - ASSERT_PRINT_EQ (literal (JSON_NULL), true, "null"); + ASSERT_JSON_PRINT_EQ (literal (JSON_TRUE), true, "true"); + ASSERT_JSON_PRINT_EQ (literal (JSON_FALSE), true, "false"); + ASSERT_JSON_PRINT_EQ (literal (JSON_NULL), true, "null"); - ASSERT_PRINT_EQ (literal (true), true, "true"); - ASSERT_PRINT_EQ (literal (false), true, "false"); + ASSERT_JSON_PRINT_EQ (literal (true), true, "true"); + ASSERT_JSON_PRINT_EQ (literal (false), true, "false"); } /* Verify that nested values are formatted correctly when written. @@ -858,18 +858,18 @@ test_formatting () /* This test relies on json::object writing out key/value pairs in key-insertion order. */ - ASSERT_PRINT_EQ (obj, true, - ("{\"str\": \"bar\",\n" - " \"child\": {\"grandchild\": {\"arr\": [0,\n" - " 1,\n" - " 2],\n" - " \"int\": 1066},\n" - " \"int\": 1776},\n" - " \"int\": 42}")); - ASSERT_PRINT_EQ (obj, false, - ("{\"str\": \"bar\", \"child\": {\"grandchild\":" - " {\"arr\": [0, 1, 2], \"int\": 1066}," - " \"int\": 1776}, \"int\": 42}")); + ASSERT_JSON_PRINT_EQ (obj, true, + ("{\"str\": \"bar\",\n" + " \"child\": {\"grandchild\": {\"arr\": [0,\n" + " 1,\n" + " 2],\n" + " \"int\": 1066},\n" + " \"int\": 1776},\n" + " \"int\": 42}")); + ASSERT_JSON_PRINT_EQ (obj, false, + ("{\"str\": \"bar\", \"child\": {\"grandchild\":" + " {\"arr\": [0, 1, 2], \"int\": 1066}," + " \"int\": 1776}, \"int\": 42}")); } /* Helper function for reporting failure of JSON comparisons. */ @@ -1043,8 +1043,8 @@ test_comparisons () obj_4.set_integer ("year", 1066); obj_4.set_string ("foo", "bar"); ASSERT_JSON_EQ (obj_2, obj_4); - ASSERT_PRINT_EQ (obj_2, false, "{\"foo\": \"bar\", \"year\": 1066}"); - ASSERT_PRINT_EQ (obj_4, false, "{\"year\": 1066, \"foo\": \"bar\"}"); + ASSERT_JSON_PRINT_EQ (obj_2, false, "{\"foo\": \"bar\", \"year\": 1066}"); + ASSERT_JSON_PRINT_EQ (obj_4, false, "{\"year\": 1066, \"foo\": \"bar\"}"); /* Arrays. */ diff --git a/gcc/json.h b/gcc/json.h index e32cd99d08a..1d98e803db0 100644 --- a/gcc/json.h +++ b/gcc/json.h @@ -529,13 +529,18 @@ namespace selftest { class location; -extern void assert_print_eq (const location &loc, - const json::value &jv, - bool formatted, - const char *expected_json); +extern void assert_json_print_eq (const location &loc, + const json::value &jv, + bool formatted, + const char *expected_json); } // namespace selftest +#define ASSERT_JSON_PRINT_EQ(JV, FORMATTED, EXPECTED_JSON) \ + SELFTEST_BEGIN_STMT \ + assert_json_print_eq ((SELFTEST_LOCATION), (JV), (FORMATTED), (EXPECTED_JSON)); \ + SELFTEST_END_STMT + #endif /* #if CHECKING_P */ #endif /* GCC_JSON_H */ -- 2.56.0 From dmalcolm@redhat.com Mon Nov 2 19:30:57 2026 From: dmalcolm@redhat.com (David Malcolm) Date: Mon, 2 Nov 2026 14:30:57 -0500 Subject: [pushed: r17-5825] testsuite: delete analyzer_cpython_plugin.cc and its test files Message-ID: <20261102193059.1297208-1-dmalcolm@redhat.com> This hasn't worked for Python 3.11 onwards (due to changes to how CPython does reference-counting), and is about to be further bit-rotted into not compiling by my rewrite to how the analyzer tracks symbolic values. Delete the plugin and its test cases; if there's interest in porting it we can always get it back from source control. Successfully regrtested on aarch64-unknown-linux-gnu. Pushed to trunk as r17-5825-gd77bceecd39b5b. gcc/testsuite/ChangeLog: * gcc.dg/plugin/analyzer_cpython_plugin.cc: Delete test plugin. * gcc.dg/plugin/cpython-plugin-test-PyList_Append.c: Delete test. * gcc.dg/plugin/cpython-plugin-test-PyList_New.c: Delete test. * gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c: Delete test. * gcc.dg/plugin/cpython-plugin-test-no-Python-h.c: Delete test. * gcc.dg/plugin/plugin.exp (plugin_test_list): Drop the above. Signed-off-by: David Malcolm --- .../gcc.dg/plugin/analyzer_cpython_plugin.cc | 1521 ----------------- .../cpython-plugin-test-PyList_Append.c | 78 - .../plugin/cpython-plugin-test-PyList_New.c | 38 - .../cpython-plugin-test-PyLong_FromLong.c | 38 - .../plugin/cpython-plugin-test-no-Python-h.c | 8 - gcc/testsuite/gcc.dg/plugin/plugin.exp | 5 - 6 files changed, 1688 deletions(-) delete mode 100644 gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.cc delete mode 100644 gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-PyList_Append.c delete mode 100644 gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-PyList_New.c delete mode 100644 gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c delete mode 100644 gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-no-Python-h.c diff --git a/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.cc b/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.cc deleted file mode 100644 index da1eed95cc3..00000000000 --- a/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.cc +++ /dev/null @@ -1,1521 +0,0 @@ -/* -fanalyzer plugin for CPython extension modules */ -/* { dg-options "-g" } */ - -#include "analyzer/common.h" -#include "gcc-plugin.h" -#include "tree.h" -#include "function.h" -#include "basic-block.h" -#include "gimple.h" -#include "gimple-iterator.h" -#include "diagnostic-core.h" -#include "graphviz.h" -#include "options.h" -#include "cgraph.h" -#include "tree-dfa.h" -#include "stringpool.h" -#include "convert.h" -#include "target.h" -#include "fold-const.h" -#include "tree-pretty-print.h" -#include "diagnostics/color.h" -#include "diagnostics/metadata.h" -#include "tristate.h" -#include "bitmap.h" -#include "selftest.h" -#include "function.h" -#include "json.h" -#include "analyzer/common.h" -#include "analyzer/analyzer-language.h" -#include "analyzer/analyzer-logging.h" -#include "ordered-hash-map.h" -#include "options.h" -#include "cgraph.h" -#include "cfg.h" -#include "digraph.h" -#include "analyzer/supergraph.h" -#include "sbitmap.h" -#include "context.h" -#include "channels.h" -#include "analyzer/call-string.h" -#include "analyzer/program-point.h" -#include "analyzer/store.h" -#include "analyzer/region-model.h" -#include "analyzer/call-details.h" -#include "analyzer/call-info.h" -#include "analyzer/exploded-graph.h" - -int plugin_is_GPL_compatible; - -#if ENABLE_ANALYZER -static GTY (()) hash_map *analyzer_stashed_types; -static GTY (()) hash_map *analyzer_stashed_globals; - -namespace ana { -namespace cpython_plugin { - -static tree -get_field_by_name (tree type, const char *name, bool complain = true) -{ - gcc_assert (type); - gcc_assert (name); - for (tree field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) - { - if (TREE_CODE (field) == FIELD_DECL) - if (tree id = DECL_NAME (field)) - { - const char *field_name = IDENTIFIER_POINTER (id); - if (strcmp (field_name, name) == 0) - return field; - } - - /* Prior to python 3.11, ob_refcnt was a field of PyObject. - In Python 3.11 ob_refcnt was moved to an anonymous union within - PyObject (as part of PEP 683 "Immortal Objects, Using a - Fixed Refcount"). */ - if (strcmp (name, "ob_refcnt") == 0 - && TREE_CODE (field) == FIELD_DECL - && DECL_NAME (field) == NULL_TREE - && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))) - if (tree subfield = get_field_by_name (TREE_TYPE (field), name, false)) - return subfield; - } - if (complain) - inform (UNKNOWN_LOCATION, "could not find field %qs of CPython type %qT", - name, type); - return NULL_TREE; -} - -/* Global state and utils for working with the CPython API. - - Attempt to provide some isolation against changes to the API in - different versions of CPython. - - This only persists during the analyzer, and thus doesn't need - to interact with the garbage collector. */ - -class api -{ -public: - bool init_from_stashed_types (); - - // Get RECORD_TYPE for PyObject - tree - get_type_PyObject () const - { - gcc_assert (m_type_PyObject); - return m_type_PyObject; - } - - // Get FIELD_DECL for PyObject's "ob_refcnt" - tree - get_field_PyObject_ob_refcnt () const - { - gcc_assert (m_field_PyObject_ob_refcnt); - return m_field_PyObject_ob_refcnt; - } - - // Get FIELD_DECL for PyObject's "ob_type" - tree - get_field_PyObject_ob_type () const - { - gcc_assert (m_field_PyObject_ob_type); - return m_field_PyObject_ob_type; - } - - // Get POINTER_TYPE for "PyObject *" - tree - get_type_PyObject_ptr () const - { - gcc_assert (m_type_PyObject_ptr); - return m_type_PyObject_ptr; - } - - // Get POINTER_TYPE for "PyObject **" - tree - get_type_PyObject_ptr_ptr () const - { - gcc_assert (m_type_PyObject_ptr_ptr); - return m_type_PyObject_ptr_ptr; - } - - // Get RECORD_TYPE for CPython's PyVarObject - tree - get_type_PyVarObject () const - { - gcc_assert (m_type_PyVarObject); - return m_type_PyVarObject; - } - - // Get FIELD_DECL for PyVarObject's "ob_size" - tree - get_field_PyVarObject_ob_size () const - { - gcc_assert (m_field_PyVarObject_ob_size); - return m_field_PyVarObject_ob_size; - } - - // Get RECORD_TYPE for CPython's PyListObject - tree - get_type_PyListObject () const - { - gcc_assert (m_type_PyListObject); - return m_type_PyListObject; - } - - // Get RECORD_TYPE for CPython's PyLongObject - tree - get_type_PyLongObject () const - { - gcc_assert (m_type_PyLongObject); - return m_type_PyLongObject; - } - - // Get FIELD_DECL for PyListObject's "ob_item" - tree - get_field_PyListObject_ob_item () const - { - gcc_assert (m_field_PyListObject_ob_item); - return m_field_PyListObject_ob_item; - } - - // Get VAR_DECL for CPython's global var PyList_Type - tree - get_vardecl_PyList_Type () const - { - gcc_assert (m_vardecl_PyList_Type); - return m_vardecl_PyList_Type; - } - - // Get VAR_DECL for CPython's global var PyLong_Type - tree - get_vardecl_PyLong_Type () const - { - gcc_assert (m_vardecl_PyLong_Type); - return m_vardecl_PyLong_Type; - } - - /* Get an ana::svalue for "sizeof (PyObject *)". */ - const svalue * - get_sval_sizeof_PyObject_ptr (region_model_manager *mgr) const - { - tree size_tree = TYPE_SIZE_UNIT (m_type_PyObject_ptr); - const svalue *sizeof_sval = mgr->get_or_create_constant_svalue (size_tree); - return sizeof_sval; - } - - /* Update MODEL to set OB_BASE_REGION's ob_refcnt to 1. */ - void - init_ob_refcnt_field (region_model *model, - const region *ob_base_region, - region_model_context *ctxt) - { - region_model_manager *mgr = model->get_manager (); - tree ob_refcnt_tree = get_field_PyObject_ob_refcnt (); - const region *ob_refcnt_region - = mgr->get_field_region (ob_base_region, ob_refcnt_tree); - const svalue *refcnt_one_sval - = mgr->get_or_create_int_cst (size_type_node, 1); - model->set_value (ob_refcnt_region, refcnt_one_sval, ctxt); - } - - /* Update MODEL to set OB_BASE_REGION's ob_type to point to - PYTYPE_VAR_DECL_PTR. */ - void - set_ob_type_field (region_model *model, - const region *ob_base_region, - tree pytype_var_decl_ptr, - region_model_context *ctxt) - { - region_model_manager *mgr = model->get_manager (); - const region *pylist_type_region - = mgr->get_region_for_global (pytype_var_decl_ptr); - tree pytype_var_decl_ptr_type - = build_pointer_type (TREE_TYPE (pytype_var_decl_ptr)); - const svalue *pylist_type_ptr_sval - = mgr->get_ptr_svalue (pytype_var_decl_ptr_type, pylist_type_region); - tree ob_type_field = get_field_PyObject_ob_type (); - const region *ob_type_region - = mgr->get_field_region (ob_base_region, ob_type_field); - model->set_value (ob_type_region, pylist_type_ptr_sval, ctxt); - } - - /* Initialize OB_BASE_REGION as a PyObject_HEAD - i.e. set "ob_refcnt" to 1 and "ob_type" to PYTYPE_VAR_DECL_PTR. */ - void - init_PyObject_HEAD (region_model *model, - const region *ob_base_region, - tree pytype_var_decl_ptr, - region_model_context *ctxt) - { - // Initialize ob_refcnt field to 1. - init_ob_refcnt_field (model, ob_base_region, ctxt); - - /* Get pointer svalue for PYTYPE_VAR_DECL_PTR then - assign it to ob_type field. */ - set_ob_type_field (model, ob_base_region, - pytype_var_decl_ptr, ctxt); - } - - // Get subregion for ob_refcnt within a PyObject instance - const region * - get_region_PyObject_ob_refcnt (region_model_manager *mgr, - const region *pyobject_instance_reg) - { - const region *ob_refcnt_region - = mgr->get_field_region (pyobject_instance_reg, - m_field_PyObject_ob_refcnt); - return ob_refcnt_region; - } - - void - do_Py_INCREF (region_model *model, - const region *pyobject_instance_reg, - region_model_context *ctxt) - { - region_model_manager *mgr = model->get_manager (); - const region *ob_refcnt_region - = get_region_PyObject_ob_refcnt (mgr, pyobject_instance_reg); - inc_field_val (model, ob_refcnt_region, size_type_node, ctxt); - } - - // Get subregion for ob_size within a PyVarObject instance - const region * - get_region_PyVarObject_ob_size (region_model_manager *mgr, - const region *pyvarobject_instance_reg) - { - const region *ob_size_region - = mgr->get_field_region (pyvarobject_instance_reg, - m_field_PyVarObject_ob_size); - return ob_size_region; - } - - /* Attempt to get the subregion for the "ob_digit" field within - PYLONG_REGION, a PyLongObject instance. */ - const region * - get_region_PyLongObject_ob_digit (region_model_manager *mgr, - const region *pylong_region) - { - if (tree ob_digit_field - = get_field_by_name (m_type_PyLongObject, "ob_digit", false)) - { - const region *ob_digit_region - = mgr->get_field_region (pylong_region, ob_digit_field); - return ob_digit_region; - } - - /* TODO: https://github.com/python/cpython/pull/101292 - moved "ob_digit" from struct _longobject to a new field long_value - of a new struct _PyLongValue. */ - - return nullptr; - } - - /* Increment the value of FIELD_REGION in the MODEL by 1. Optionally - capture the old and new svalues if OLD_SVAL and NEW_SVAL pointers are - provided. */ - void - inc_field_val (region_model *model, - const region *field_region, const tree type_node, - region_model_context *ctxt, - const svalue **old_sval = nullptr, - const svalue **new_sval = nullptr) - { - region_model_manager *mgr = model->get_manager (); - const svalue *tmp_old_sval = model->get_store_value (field_region, ctxt); - const svalue *one_sval = mgr->get_or_create_int_cst (type_node, 1); - const svalue *tmp_new_sval - = mgr->get_or_create_binop (type_node, PLUS_EXPR, tmp_old_sval, one_sval); - - model->set_value (field_region, tmp_new_sval, ctxt); - - if (old_sval) - *old_sval = tmp_old_sval; - - if (new_sval) - *new_sval = tmp_new_sval; - } - -private: - // PyObject - tree m_type_PyObject; // RECORD_TYPE - tree m_field_PyObject_ob_refcnt; // FIELD_DECL - tree m_field_PyObject_ob_type; // FIELD_DECL - - // POINTER_TYPE for "PyObject *" - tree m_type_PyObject_ptr; - - // POINTER_TYPE for "PyObject **" - tree m_type_PyObject_ptr_ptr; - - // PyVarObject - tree m_type_PyVarObject; // RECORD_TYPE - tree m_field_PyVarObject_ob_size; // FIELD_DECL - - // PyListObject - tree m_type_PyListObject; // RECORD_TYPE - tree m_field_PyListObject_ob_item; // FIELD_DECL - tree m_vardecl_PyList_Type; // VAR_DECL for CPython's global var PyList_Type - - // PyLongObject - tree m_type_PyLongObject; // RECORD_TYPE - tree m_vardecl_PyLong_Type; // VAR_DECL for CPython's global var PyLong_Type - -} api; - -/* Retrieve the "ob_base" field's region from OBJECT_RECORD within - NEW_OBJECT_REGION and set its value in the MODEL to PYOBJ_SVALUE. */ -static const region * -get_ob_base_region (region_model_manager *mgr, region_model *model, - const region *new_object_region, tree object_record, - const svalue *pyobj_svalue, const call_details &cd) -{ - tree ob_base_tree = get_field_by_name (object_record, "ob_base"); - const region *ob_base_region - = mgr->get_field_region (new_object_region, ob_base_tree); - model->set_value (ob_base_region, pyobj_svalue, cd.get_ctxt ()); - return ob_base_region; -} - -/* Initialize and retrieve a region within the MODEL for a PyObject - and set its value to OBJECT_SVALUE. */ -static const region * -init_pyobject_region (region_model_manager *mgr, region_model *model, - const svalue *object_svalue, const call_details &cd) -{ - const region *pyobject_region = model->get_or_create_region_for_heap_alloc ( - NULL, cd.get_ctxt (), true, &cd); - model->set_value (pyobject_region, object_svalue, cd.get_ctxt ()); - return pyobject_region; -} - -class pyobj_init_fail : public failed_call_info -{ -public: - pyobj_init_fail (const call_details &cd) : failed_call_info (cd) {} - - bool - update_model (region_model *model, const exploded_edge *, - region_model_context *ctxt) const final override - { - /* Return NULL; everything else is unchanged. */ - const call_details cd (get_call_details (model, ctxt)); - region_model_manager *mgr = cd.get_manager (); - if (cd.get_lhs_type ()) - { - const svalue *zero - = mgr->get_or_create_int_cst (cd.get_lhs_type (), 0); - model->set_value (cd.get_lhs_region (), zero, cd.get_ctxt ()); - } - return true; - } -}; - -class refcnt_mismatch : public pending_diagnostic_subclass -{ -public: - refcnt_mismatch (const region *base_region, - const svalue *ob_refcnt, - const svalue *actual_refcnt, - tree reg_tree, - tree expected_refcnt_tree, - tree actual_refcnt_tree) - : m_base_region (base_region), - m_ob_refcnt (ob_refcnt), - m_actual_refcnt (actual_refcnt), - m_reg_tree (reg_tree), - m_expected_refcnt_tree (expected_refcnt_tree), - m_actual_refcnt_tree (actual_refcnt_tree) - { - } - - const char * - get_kind () const final override - { - return "refcnt_mismatch"; - } - - bool - operator== (const refcnt_mismatch &other) const - { - return (m_base_region == other.m_base_region - && m_ob_refcnt == other.m_ob_refcnt - && m_actual_refcnt == other.m_actual_refcnt); - } - - int get_controlling_option () const final override - { - return 0; - } - - bool - emit (diagnostic_emission_context &ctxt) final override - { - bool warned; - warned = ctxt.warn ("expected %qE to have " - "reference count: %qE but ob_refcnt field is: %qE", - m_reg_tree, - m_actual_refcnt_tree, - m_expected_refcnt_tree); - return warned; - } - - void mark_interesting_stuff (interesting_t *interest) final override - { - if (m_base_region) - interest->add_region_creation (m_base_region); - } - -private: - const region *m_base_region; - const svalue *m_ob_refcnt; - const svalue *m_actual_refcnt; - tree m_reg_tree; - tree m_expected_refcnt_tree; - tree m_actual_refcnt_tree; -}; - -/* Retrieves the svalue associated with the ob_refcnt field of the base region. - */ -static const svalue * -retrieve_ob_refcnt_sval (const region *base_reg, const region_model *model, - region_model_context *ctxt) -{ - region_model_manager *mgr = model->get_manager (); - tree ob_refcnt_tree = api.get_field_PyObject_ob_refcnt (); - const region *ob_refcnt_region - = mgr->get_field_region (base_reg, ob_refcnt_tree); - const svalue *ob_refcnt_sval - = model->get_store_value (ob_refcnt_region, ctxt); - return ob_refcnt_sval; -} - -static void -increment_region_refcnt (hash_map &map, const region *key) -{ - bool existed; - auto &refcnt = map.get_or_insert (key, &existed); - refcnt = existed ? refcnt + 1 : 1; -} - - -/* Recursively fills in region_to_refcnt with the references owned by - pyobj_ptr_sval. */ -static void -count_pyobj_references (const region_model *model, - hash_map ®ion_to_refcnt, - const svalue *pyobj_ptr_sval, - hash_set &seen) -{ - if (!pyobj_ptr_sval) - return; - - const auto *pyobj_region_sval = pyobj_ptr_sval->dyn_cast_region_svalue (); - const auto *pyobj_initial_sval = pyobj_ptr_sval->dyn_cast_initial_svalue (); - if (!pyobj_region_sval && !pyobj_initial_sval) - return; - - // todo: support initial sval (e.g passed in as parameter) - if (pyobj_initial_sval) - { - // increment_region_refcnt (region_to_refcnt, - // pyobj_initial_sval->get_region ()); - return; - } - - const region *pyobj_region = pyobj_region_sval->get_pointee (); - if (!pyobj_region || seen.contains (pyobj_region)) - return; - - seen.add (pyobj_region); - - if (pyobj_ptr_sval->get_type () == api.get_type_PyObject_ptr ()) - increment_region_refcnt (region_to_refcnt, pyobj_region); - - const auto *curr_store = model->get_store (); - const auto *retval_cluster = curr_store->get_cluster (pyobj_region); - if (!retval_cluster) - return; - - const auto &retval_binding_map = retval_cluster->get_map (); - - for (const auto &binding : retval_binding_map) - { - const svalue *binding_sval = binding.m_sval; - const svalue *unwrapped_sval = binding_sval->unwrap_any_unmergeable (); - const region *pointee = unwrapped_sval->maybe_get_region (); - - if (pointee && pointee->get_kind () == RK_HEAP_ALLOCATED) - count_pyobj_references (model, region_to_refcnt, binding_sval, seen); - } -} - -/* Compare ob_refcnt field vs the actual reference count of a region */ -static void -check_refcnt (const region_model *model, - const region_model *old_model, - region_model_context *ctxt, - const hash_map::iterator::reference_pair region_refcnt) -{ - region_model_manager *mgr = model->get_manager (); - const auto &curr_region = region_refcnt.first; - const auto &actual_refcnt = region_refcnt.second; - const svalue *ob_refcnt_sval - = retrieve_ob_refcnt_sval (curr_region, model, ctxt); - const svalue *actual_refcnt_sval = mgr->get_or_create_int_cst ( - ob_refcnt_sval->get_type (), actual_refcnt); - - if (ob_refcnt_sval != actual_refcnt_sval - && ob_refcnt_sval->get_kind () != SK_UNKNOWN - && actual_refcnt_sval->get_kind () != SK_UNKNOWN) - { - const svalue *curr_reg_sval - = mgr->get_ptr_svalue (api.get_type_PyObject_ptr (), curr_region); - tree reg_tree = old_model->get_representative_tree (curr_reg_sval); - if (!reg_tree) - return; - tree expected_refcnt_tree - = old_model->get_representative_tree (ob_refcnt_sval); - if (!expected_refcnt_tree) - return; - tree actual_refcnt_tree - = old_model->get_representative_tree (actual_refcnt_sval); - if (!actual_refcnt_tree) - return; - - const auto &eg = ctxt->get_eg (); - auto pd = std::make_unique (curr_region, ob_refcnt_sval, - actual_refcnt_sval, - reg_tree, - expected_refcnt_tree, - actual_refcnt_tree); - if (pd && eg) - ctxt->warn (std::move (pd), - make_ploc_fixer_for_epath_for_leak_diagnostic (*eg, - NULL_TREE)); - } -} - -static void -check_refcnts (const region_model *model, - const region_model *old_model, - const svalue *retval, - region_model_context *ctxt, - hash_map ®ion_to_refcnt) -{ - for (const auto ®ion_refcnt : region_to_refcnt) - { - check_refcnt (model, old_model, ctxt, region_refcnt); - } -} - -/* Validates the reference count of all Python objects. */ -void -pyobj_refcnt_checker (const region_model *model, - const region_model *old_model, - const svalue *retval, - region_model_context *ctxt) -{ - if (!ctxt) - return; - - hash_map region_to_refcnt; - hash_set seen_regions; - - count_pyobj_references (model, region_to_refcnt, retval, seen_regions); - check_refcnts (model, old_model, retval, ctxt, region_to_refcnt); -} - -/* Counts the actual pyobject references from all clusters in the model's - * store. */ -static void -count_all_references (const region_model *model, - hash_map ®ion_to_refcnt) -{ - for (const auto &cluster : *model->get_store ()) - { - auto curr_region = cluster.first; - if (curr_region->get_kind () != RK_HEAP_ALLOCATED) - continue; - - increment_region_refcnt (region_to_refcnt, curr_region); - - auto binding_cluster = cluster.second; - for (const auto &binding : binding_cluster->get_map ()) - { - const svalue *binding_sval = binding.m_sval; - - const svalue *unwrapped_sval - = binding_sval->unwrap_any_unmergeable (); - // if (unwrapped_sval->get_type () != api.m_type_PyObject_ptr) - // continue; - - const region *pointee = unwrapped_sval->maybe_get_region (); - if (!pointee || pointee->get_kind () != RK_HEAP_ALLOCATED) - continue; - - increment_region_refcnt (region_to_refcnt, pointee); - } - } -} - -static void -dump_refcnt_info (const hash_map ®ion_to_refcnt, - const region_model *model, - region_model_context *ctxt) -{ - region_model_manager *mgr = model->get_manager (); - pretty_printer pp; - pp_format_decoder (&pp) = default_tree_printer; - pp_show_color (&pp) = pp_show_color (global_dc->get_reference_printer ()); - pp.set_output_stream (stderr); - - for (const auto ®ion_refcnt : region_to_refcnt) - { - auto region = region_refcnt.first; - auto actual_refcnt = region_refcnt.second; - const svalue *ob_refcnt_sval - = retrieve_ob_refcnt_sval (region, model, ctxt); - const svalue *actual_refcnt_sval = mgr->get_or_create_int_cst ( - ob_refcnt_sval->get_type (), actual_refcnt); - - region->dump_to_pp (&pp, true); - pp_string (&pp, " ? ob_refcnt: "); - ob_refcnt_sval->dump_to_pp (&pp, true); - pp_string (&pp, " actual refcnt: "); - actual_refcnt_sval->dump_to_pp (&pp, true); - pp_newline (&pp); - } - pp_string (&pp, "~~~~~~~~\n"); - pp_flush (&pp); -} - -class kf_analyzer_cpython_dump_refcounts : public known_function -{ -public: - bool matches_call_types_p (const call_details &cd) const final override - { - return cd.num_args () == 0; - } - void impl_call_pre (const call_details &cd) const final override - { - region_model_context *ctxt = cd.get_ctxt (); - if (!ctxt) - return; - region_model *model = cd.get_model (); - hash_map region_to_refcnt; - count_all_references(model, region_to_refcnt); - dump_refcnt_info(region_to_refcnt, model, ctxt); - } -}; - -/* Some concessions were made to -simplify the analysis process when comparing kf_PyList_Append with the -real implementation. In particular, PyList_Append performs some -optimization internally to try and avoid calls to realloc if -possible. For simplicity, we assume that realloc is called every time. -Also, we grow the size by just 1 (to ensure enough space for adding a -new element) rather than abide by the heuristics that the actual implementation -follows. */ -class kf_PyList_Append : public known_function -{ -public: - bool - matches_call_types_p (const call_details &cd) const final override - { - return (cd.num_args () == 2 && cd.arg_is_pointer_p (0) - && cd.arg_is_pointer_p (1)); - } - void impl_call_pre (const call_details &cd) const final override; - void impl_call_post (const call_details &cd) const final override; -}; - -void -kf_PyList_Append::impl_call_pre (const call_details &cd) const -{ - region_model_manager *mgr = cd.get_manager (); - region_model *model = cd.get_model (); - - const svalue *pylist_sval = cd.get_arg_svalue (0); - const region *pylist_reg - = model->deref_rvalue (pylist_sval, cd.get_arg_tree (0), cd.get_ctxt ()); - - const svalue *newitem_sval = cd.get_arg_svalue (1); - const region *newitem_reg - = model->deref_rvalue (pylist_sval, cd.get_arg_tree (0), cd.get_ctxt ()); - - // Skip checks if unknown etc - if (pylist_sval->get_kind () != SK_REGION - && pylist_sval->get_kind () != SK_CONSTANT) - return; - - // PyList_Check - tree ob_type_field = api.get_field_PyObject_ob_type (); - const region *ob_type_region - = mgr->get_field_region (pylist_reg, ob_type_field); - const svalue *stored_sval - = model->get_store_value (ob_type_region, cd.get_ctxt ()); - const region *pylist_type_region - = mgr->get_region_for_global (api.get_vardecl_PyList_Type ()); - tree pylisttype_vardecl_ptr - = build_pointer_type (TREE_TYPE (api.get_vardecl_PyList_Type ())); - const svalue *pylist_type_ptr - = mgr->get_ptr_svalue (pylisttype_vardecl_ptr, pylist_type_region); - - if (stored_sval != pylist_type_ptr) - { - // TODO: emit diagnostic -Wanalyzer-type-error - cd.get_ctxt ()->terminate_path (); - return; - } - - // Check that new_item is not null. - { - const svalue *null_ptr - = mgr->get_or_create_int_cst (newitem_sval->get_type (), 0); - if (!model->add_constraint (newitem_sval, NE_EXPR, null_ptr, - cd.get_ctxt ())) - { - // TODO: emit diagnostic here - cd.get_ctxt ()->terminate_path (); - return; - } - } -} - -void -kf_PyList_Append::impl_call_post (const call_details &cd) const -{ - /* Three custom subclasses of custom_edge_info, for handling the various - outcomes of "realloc". */ - - /* Concrete custom_edge_info: a realloc call that fails, returning NULL. - */ - class realloc_failure : public failed_call_info - { - public: - realloc_failure (const call_details &cd) : failed_call_info (cd) {} - - bool - update_model (region_model *model, const exploded_edge *, - region_model_context *ctxt) const final override - { - const call_details cd (get_call_details (model, ctxt)); - region_model_manager *mgr = cd.get_manager (); - - const svalue *pylist_sval = cd.get_arg_svalue (0); - const region *pylist_reg = model->deref_rvalue ( - pylist_sval, cd.get_arg_tree (0), cd.get_ctxt ()); - - /* Identify ob_item field and set it to NULL. */ - tree ob_item_field = api.get_field_PyListObject_ob_item (); - const region *ob_item_reg - = mgr->get_field_region (pylist_reg, ob_item_field); - const svalue *old_ptr_sval - = model->get_store_value (ob_item_reg, cd.get_ctxt ()); - - if (const region_svalue *old_reg - = old_ptr_sval->dyn_cast_region_svalue ()) - { - const region *freed_reg = old_reg->get_pointee (); - model->unbind_region_and_descendents (freed_reg, poison_kind::freed); - model->unset_dynamic_extents (freed_reg); - } - - const svalue *null_sval = mgr->get_or_create_null_ptr (api.get_type_PyObject_ptr_ptr ()); - model->set_value (ob_item_reg, null_sval, cd.get_ctxt ()); - - if (cd.get_lhs_type ()) - { - const svalue *neg_one - = mgr->get_or_create_int_cst (cd.get_lhs_type (), -1); - cd.maybe_set_lhs(neg_one); - } - return true; - } - }; - - class realloc_success_no_move : public call_info - { - public: - realloc_success_no_move (const call_details &cd) : call_info (cd) {} - - void - print_desc (pretty_printer &pp) const final override - { - pp_printf (&pp, - "when %qE succeeds, without moving underlying buffer", - get_fndecl ()); - } - - bool - update_model (region_model *model, const exploded_edge *, - region_model_context *ctxt) const final override - { - const call_details cd (get_call_details (model, ctxt)); - region_model_manager *mgr = cd.get_manager (); - - const svalue *pylist_sval = cd.get_arg_svalue (0); - const region *pylist_reg = model->deref_rvalue ( - pylist_sval, cd.get_arg_tree (0), cd.get_ctxt ()); - - const svalue *newitem_sval = cd.get_arg_svalue (1); - const region *newitem_reg = model->deref_rvalue ( - newitem_sval, cd.get_arg_tree (1), cd.get_ctxt ()); - - const region *ob_size_region - = api.get_region_PyVarObject_ob_size (mgr, pylist_reg); - const svalue *ob_size_sval = nullptr; - const svalue *new_size_sval = nullptr; - api.inc_field_val (model, ob_size_region, integer_type_node, ctxt, - &ob_size_sval, &new_size_sval); - - const svalue *sizeof_sval = mgr->get_or_create_cast ( - ob_size_sval->get_type (), api.get_sval_sizeof_PyObject_ptr (mgr)); - const svalue *num_allocated_bytes = mgr->get_or_create_binop ( - size_type_node, MULT_EXPR, sizeof_sval, new_size_sval); - - tree ob_item_field = api.get_field_PyListObject_ob_item (); - const region *ob_item_region - = mgr->get_field_region (pylist_reg, ob_item_field); - const svalue *ob_item_ptr_sval - = model->get_store_value (ob_item_region, cd.get_ctxt ()); - - /* We can only grow in place with a non-NULL pointer and no unknown - */ - { - const svalue *null_ptr = mgr->get_or_create_null_ptr (api.get_type_PyObject_ptr_ptr ()); - if (!model->add_constraint (ob_item_ptr_sval, NE_EXPR, null_ptr, - cd.get_ctxt ())) - { - return false; - } - } - - const unmergeable_svalue *underlying_svalue - = ob_item_ptr_sval->dyn_cast_unmergeable_svalue (); - const svalue *target_svalue = nullptr; - const region_svalue *target_region_svalue = nullptr; - - if (underlying_svalue) - { - target_svalue = underlying_svalue->get_arg (); - if (target_svalue->get_kind () != SK_REGION) - { - return false; - } - } - else - { - if (ob_item_ptr_sval->get_kind () != SK_REGION) - { - return false; - } - target_svalue = ob_item_ptr_sval; - } - - target_region_svalue = target_svalue->dyn_cast_region_svalue (); - const region *curr_reg = target_region_svalue->get_pointee (); - - if (compat_types_p (num_allocated_bytes->get_type (), size_type_node)) - model->set_dynamic_extents (curr_reg, num_allocated_bytes, ctxt); - - model->set_value (ob_size_region, new_size_sval, ctxt); - - const svalue *offset_sval = mgr->get_or_create_binop ( - size_type_node, MULT_EXPR, sizeof_sval, ob_size_sval); - const region *element_region - = mgr->get_offset_region (curr_reg, api.get_type_PyObject_ptr_ptr (), offset_sval); - model->set_value (element_region, newitem_sval, cd.get_ctxt ()); - - // Increment ob_refcnt of appended item. - api.do_Py_INCREF (model, newitem_reg, ctxt); - - if (cd.get_lhs_type ()) - { - const svalue *zero - = mgr->get_or_create_int_cst (cd.get_lhs_type (), 0); - cd.maybe_set_lhs(zero); - } - return true; - } - }; - - class realloc_success_move : public call_info - { - public: - realloc_success_move (const call_details &cd) : call_info (cd) {} - - void - print_desc (pretty_printer &pp) const final override - { - pp_printf (&pp, - "when %qE succeeds, moving buffer", - get_fndecl ()); - } - - bool - update_model (region_model *model, const exploded_edge *, - region_model_context *ctxt) const final override - { - const call_details cd (get_call_details (model, ctxt)); - region_model_manager *mgr = cd.get_manager (); - const svalue *pylist_sval = cd.get_arg_svalue (0); - const region *pylist_reg = model->deref_rvalue ( - pylist_sval, cd.get_arg_tree (0), cd.get_ctxt ()); - - const svalue *newitem_sval = cd.get_arg_svalue (1); - const region *newitem_reg = model->deref_rvalue ( - newitem_sval, cd.get_arg_tree (1), cd.get_ctxt ()); - - const region *ob_size_region - = api.get_region_PyVarObject_ob_size (mgr, pylist_reg); - const svalue *old_ob_size_sval = nullptr; - const svalue *new_ob_size_sval = nullptr; - api.inc_field_val (model, ob_size_region, integer_type_node, ctxt, - &old_ob_size_sval, &new_ob_size_sval); - - const svalue *sizeof_sval = mgr->get_or_create_cast ( - old_ob_size_sval->get_type (), api.get_sval_sizeof_PyObject_ptr (mgr)); - const svalue *new_size_sval = mgr->get_or_create_binop ( - size_type_node, MULT_EXPR, sizeof_sval, new_ob_size_sval); - - tree ob_item_field = api.get_field_PyListObject_ob_item (); - const region *ob_item_reg - = mgr->get_field_region (pylist_reg, ob_item_field); - const svalue *old_ptr_sval - = model->get_store_value (ob_item_reg, cd.get_ctxt ()); - - /* Create the new region. */ - const region *new_reg = model->get_or_create_region_for_heap_alloc ( - new_size_sval, cd.get_ctxt ()); - const svalue *new_ptr_sval - = mgr->get_ptr_svalue (api.get_type_PyObject_ptr_ptr (), new_reg); - if (!model->add_constraint (new_ptr_sval, NE_EXPR, old_ptr_sval, - cd.get_ctxt ())) - return false; - - if (const region_svalue *old_reg - = old_ptr_sval->dyn_cast_region_svalue ()) - { - const region *freed_reg = old_reg->get_pointee (); - const svalue *old_size_sval = model->get_dynamic_extents (freed_reg); - if (old_size_sval) - { - const svalue *copied_size_sval - = get_copied_size (model, old_size_sval, new_size_sval); - const region *copied_old_reg = mgr->get_sized_region ( - freed_reg, api.get_type_PyObject_ptr_ptr (), copied_size_sval); - const svalue *buffer_content_sval - = model->get_store_value (copied_old_reg, cd.get_ctxt ()); - const region *copied_new_reg = mgr->get_sized_region ( - new_reg, api.get_type_PyObject_ptr_ptr (), copied_size_sval); - model->set_value (copied_new_reg, buffer_content_sval, - cd.get_ctxt ()); - } - else - { - model->mark_region_as_unknown (freed_reg, cd.get_uncertainty ()); - } - - model->unbind_region_and_descendents (freed_reg, poison_kind::freed); - model->unset_dynamic_extents (freed_reg); - } - - const svalue *null_ptr = mgr->get_or_create_null_ptr (api.get_type_PyObject_ptr_ptr ()); - if (!model->add_constraint (new_ptr_sval, NE_EXPR, null_ptr, - cd.get_ctxt ())) - return false; - - model->set_value (ob_size_region, new_ob_size_sval, ctxt); - model->set_value (ob_item_reg, new_ptr_sval, cd.get_ctxt ()); - - const svalue *offset_sval = mgr->get_or_create_binop ( - size_type_node, MULT_EXPR, sizeof_sval, old_ob_size_sval); - const region *element_region - = mgr->get_offset_region (new_reg, api.get_type_PyObject_ptr_ptr (), offset_sval); - model->set_value (element_region, newitem_sval, cd.get_ctxt ()); - - // Increment ob_refcnt of appended item. - api.do_Py_INCREF (model, newitem_reg, ctxt); - - if (cd.get_lhs_type ()) - { - const svalue *zero - = mgr->get_or_create_int_cst (cd.get_lhs_type (), 0); - cd.maybe_set_lhs(zero); - } - return true; - } - - private: - /* Return the lesser of OLD_SIZE_SVAL and NEW_SIZE_SVAL. - If unknown, OLD_SIZE_SVAL is returned. */ - const svalue * - get_copied_size (region_model *model, const svalue *old_size_sval, - const svalue *new_size_sval) const - { - tristate res - = model->eval_condition (old_size_sval, GT_EXPR, new_size_sval); - switch (res.get_value ()) - { - case tristate::TS_TRUE: - return new_size_sval; - case tristate::TS_FALSE: - case tristate::TS_UNKNOWN: - return old_size_sval; - default: - gcc_unreachable (); - } - } - }; - - /* Body of kf_PyList_Append::impl_call_post. */ - if (cd.get_ctxt ()) - { - cd.get_ctxt ()->bifurcate (std::make_unique (cd)); - cd.get_ctxt ()->bifurcate (std::make_unique (cd)); - cd.get_ctxt ()->bifurcate (std::make_unique (cd)); - cd.get_ctxt ()->terminate_path (); - } -} - -class kf_PyList_New : public known_function -{ -public: - bool - matches_call_types_p (const call_details &cd) const final override - { - return (cd.num_args () == 1 && cd.arg_is_integral_p (0)); - } - void impl_call_post (const call_details &cd) const final override; -}; - -void -kf_PyList_New::impl_call_post (const call_details &cd) const -{ - class success : public success_call_info - { - public: - success (const call_details &cd) : success_call_info (cd) {} - - bool - update_model (region_model *model, const exploded_edge *, - region_model_context *ctxt) const final override - { - const call_details cd (get_call_details (model, ctxt)); - region_model_manager *mgr = cd.get_manager (); - - const svalue *pyobj_svalue - = mgr->get_or_create_unknown_svalue (api.get_type_PyObject ()); - const svalue *varobj_svalue - = mgr->get_or_create_unknown_svalue (api.get_type_PyVarObject ()); - const svalue *pylist_svalue - = mgr->get_or_create_unknown_svalue (api.get_type_PyListObject ()); - - const svalue *size_sval = cd.get_arg_svalue (0); - - const region *pylist_region - = init_pyobject_region (mgr, model, pylist_svalue, cd); - - /* - typedef struct - { - PyObject_VAR_HEAD - PyObject **ob_item; - Py_ssize_t allocated; - } PyListObject; - */ - tree varobj_field = get_field_by_name (api.get_type_PyListObject (), - "ob_base"); - const region *varobj_region - = mgr->get_field_region (pylist_region, varobj_field); - model->set_value (varobj_region, varobj_svalue, cd.get_ctxt ()); - - tree ob_item_field = api.get_field_PyListObject_ob_item (); - const region *ob_item_region - = mgr->get_field_region (pylist_region, ob_item_field); - - const svalue *zero_sval = mgr->get_or_create_int_cst (size_type_node, 0); - const svalue *casted_size_sval - = mgr->get_or_create_cast (size_type_node, size_sval); - const svalue *size_cond_sval = mgr->get_or_create_binop ( - size_type_node, LE_EXPR, casted_size_sval, zero_sval); - - // if size <= 0, ob_item = NULL - - if (tree_int_cst_equal (size_cond_sval->maybe_get_constant (), - integer_one_node)) - { - const svalue *null_sval - = mgr->get_or_create_null_ptr (api.get_type_PyObject_ptr_ptr ()); - model->set_value (ob_item_region, null_sval, cd.get_ctxt ()); - } - else // calloc - { - const svalue *sizeof_sval = mgr->get_or_create_cast ( - size_sval->get_type (), api.get_sval_sizeof_PyObject_ptr (mgr)); - const svalue *prod_sval = mgr->get_or_create_binop ( - size_type_node, MULT_EXPR, sizeof_sval, size_sval); - const region *ob_item_sized_region - = model->get_or_create_region_for_heap_alloc (prod_sval, - cd.get_ctxt ()); - model->zero_fill_region (ob_item_sized_region, cd.get_ctxt ()); - const svalue *ob_item_ptr_sval - = mgr->get_ptr_svalue (api.get_type_PyObject_ptr_ptr (), - ob_item_sized_region); - const svalue *ob_item_unmergeable - = mgr->get_or_create_unmergeable (ob_item_ptr_sval); - model->set_value (ob_item_region, ob_item_unmergeable, - cd.get_ctxt ()); - } - - /* - typedef struct { - PyObject ob_base; - Py_ssize_t ob_size; // Number of items in variable part - } PyVarObject; - */ - const region *ob_base_region - = get_ob_base_region (mgr, model, varobj_region, - api.get_type_PyVarObject (), - pyobj_svalue, cd); - - const region *ob_size_region - = api.get_region_PyVarObject_ob_size (mgr, varobj_region); - model->set_value (ob_size_region, size_sval, cd.get_ctxt ()); - - api.init_PyObject_HEAD (model, ob_base_region, - api.get_vardecl_PyList_Type (), ctxt); - - if (cd.get_lhs_type ()) - { - const svalue *ptr_sval - = mgr->get_ptr_svalue (cd.get_lhs_type (), pylist_region); - cd.maybe_set_lhs (ptr_sval); - } - return true; - } - }; - - if (cd.get_ctxt ()) - { - cd.get_ctxt ()->bifurcate (std::make_unique (cd)); - cd.get_ctxt ()->bifurcate (std::make_unique (cd)); - cd.get_ctxt ()->terminate_path (); - } -} - -class kf_PyLong_FromLong : public known_function -{ -public: - bool - matches_call_types_p (const call_details &cd) const final override - { - return (cd.num_args () == 1 && cd.arg_is_integral_p (0)); - } - void impl_call_post (const call_details &cd) const final override; -}; - -void -kf_PyLong_FromLong::impl_call_post (const call_details &cd) const -{ - class success : public success_call_info - { - public: - success (const call_details &cd) : success_call_info (cd) {} - - bool - update_model (region_model *model, const exploded_edge *, - region_model_context *ctxt) const final override - { - const call_details cd (get_call_details (model, ctxt)); - region_model_manager *mgr = cd.get_manager (); - - const svalue *pyobj_svalue - = mgr->get_or_create_unknown_svalue (api.get_type_PyObject ()); - const svalue *pylongobj_sval - = mgr->get_or_create_unknown_svalue (api.get_type_PyLongObject ()); - - const region *pylong_region - = init_pyobject_region (mgr, model, pylongobj_sval, cd); - - // Create a region for the base PyObject within the PyLongObject. - const region *ob_base_region = get_ob_base_region ( - mgr, model, pylong_region, api.get_type_PyLongObject (), pyobj_svalue, cd); - - api.init_PyObject_HEAD (model, ob_base_region, - api.get_vardecl_PyLong_Type (), ctxt); - - // Set the PyLongObject value. - if (const region *ob_digit_region - = api.get_region_PyLongObject_ob_digit (mgr, pylong_region)) - { - const svalue *ob_digit_sval = cd.get_arg_svalue (0); - model->set_value (ob_digit_region, ob_digit_sval, cd.get_ctxt ()); - } - - if (cd.get_lhs_type ()) - { - const svalue *ptr_sval - = mgr->get_ptr_svalue (cd.get_lhs_type (), pylong_region); - cd.maybe_set_lhs (ptr_sval); - } - return true; - } - }; - - if (cd.get_ctxt ()) - { - cd.get_ctxt ()->bifurcate (std::make_unique (cd)); - cd.get_ctxt ()->bifurcate (std::make_unique (cd)); - cd.get_ctxt ()->terminate_path (); - } -} - -static void -maybe_stash_named_type (logger *logger, const translation_unit &tu, - const char *name) -{ - LOG_FUNC_1 (logger, "name: %qs", name); - if (!analyzer_stashed_types) - analyzer_stashed_types = hash_map::create_ggc (); - - tree id = get_identifier (name); - if (tree t = tu.lookup_type_by_id (id)) - { - gcc_assert (TREE_CODE (t) == RECORD_TYPE); - analyzer_stashed_types->put (id, t); - if (logger) - logger->log ("found %qs: %qE", name, t); - } - else - { - if (logger) - logger->log ("%qs: not found", name); - } -} - -static void -maybe_stash_global_var (logger *logger, const translation_unit &tu, - const char *name) -{ - LOG_FUNC_1 (logger, "name: %qs", name); - if (!analyzer_stashed_globals) - analyzer_stashed_globals = hash_map::create_ggc (); - - tree id = get_identifier (name); - if (tree t = tu.lookup_global_var_by_id (id)) - { - gcc_assert (TREE_CODE (t) == VAR_DECL); - analyzer_stashed_globals->put (id, t); - if (logger) - logger->log ("found %qs: %qE", name, t); - } - else - { - if (logger) - logger->log ("%qs: not found", name); - } -} - -static void -stash_named_types (logger *logger, const translation_unit &tu) -{ - LOG_SCOPE (logger); - - maybe_stash_named_type (logger, tu, "PyObject"); - maybe_stash_named_type (logger, tu, "PyListObject"); - maybe_stash_named_type (logger, tu, "PyVarObject"); - maybe_stash_named_type (logger, tu, "PyLongObject"); -} - -static void -stash_global_vars (logger *logger, const translation_unit &tu) -{ - LOG_SCOPE (logger); - - maybe_stash_global_var (logger, tu, "PyLong_Type"); - maybe_stash_global_var (logger, tu, "PyList_Type"); -} - -static tree -get_stashed_type_by_name (const char *name) -{ - if (!analyzer_stashed_types) - return NULL_TREE; - tree id = get_identifier (name); - if (tree *slot = analyzer_stashed_types->get (id)) - { - gcc_assert (TREE_CODE (*slot) == RECORD_TYPE); - return *slot; - } - inform (UNKNOWN_LOCATION, "could not find CPython type %qs", name); - return NULL_TREE; -} - -static tree -get_stashed_global_var_by_name (const char *name) -{ - if (!analyzer_stashed_globals) - return NULL_TREE; - tree id = get_identifier (name); - if (tree *slot = analyzer_stashed_globals->get (id)) - { - gcc_assert (TREE_CODE (*slot) == VAR_DECL); - return *slot; - } - inform (UNKNOWN_LOCATION, "could not find CPython global %qs", name); - return NULL_TREE; -} - -/* Attempt to find the various types for the CPython API, which - we hope were stashed when the frontend ran. - - Return true if we found enough to run the plugin, - false if it doesn't make sense to run it. */ - -bool -api::init_from_stashed_types () -{ - memset (this, 0, sizeof (*this)); - - m_type_PyObject = get_stashed_type_by_name ("PyObject"); - if (!m_type_PyObject) - return false; - gcc_assert (TREE_CODE (m_type_PyObject) == RECORD_TYPE); - - m_field_PyObject_ob_refcnt - = get_field_by_name (m_type_PyObject, "ob_refcnt"); - if (!m_field_PyObject_ob_refcnt) - return false; - - m_field_PyObject_ob_type - = get_field_by_name (m_type_PyObject, "ob_type"); - if (!m_field_PyObject_ob_type) - return false; - - /* PyVarObject. */ - m_type_PyVarObject = get_stashed_type_by_name ("PyVarObject"); - if (!m_type_PyVarObject) - return false; - gcc_assert (TREE_CODE (m_type_PyVarObject) == RECORD_TYPE); - m_field_PyVarObject_ob_size - = get_field_by_name (m_type_PyVarObject, "ob_size"); - if (!m_field_PyVarObject_ob_size) - return false; - - /* PyListObject. */ - m_type_PyListObject = get_stashed_type_by_name ("PyListObject"); - if (!m_type_PyListObject) - return false; - m_field_PyListObject_ob_item - = get_field_by_name (m_type_PyListObject, "ob_item"); - if (!m_field_PyListObject_ob_item) - return false; - - m_vardecl_PyList_Type = get_stashed_global_var_by_name ("PyList_Type"); - if (!m_vardecl_PyList_Type) - return false; - - /* PyLongObject. */ - m_type_PyLongObject = get_stashed_type_by_name ("PyLongObject"); - if (!m_type_PyLongObject) - return false; - - m_vardecl_PyLong_Type = get_stashed_global_var_by_name ("PyLong_Type"); - if (!m_vardecl_PyLong_Type) - return false; - - m_type_PyObject_ptr = build_pointer_type (m_type_PyObject); - m_type_PyObject_ptr_ptr = build_pointer_type (m_type_PyObject_ptr); - - return true; -} - -void -sorry_no_cpython_plugin () -{ - sorry ("%qs definitions not found." - " Please ensure to %qs.)", - "Python/C API", "#include "); -} - -namespace analyzer_events = ::gcc::topics::analyzer_events; - -class analyzer_events_subscriber : public analyzer_events::subscriber -{ -public: - analyzer_events_subscriber () - : m_init_failed (false) - { - } - - void - on_message (const analyzer_events::on_tu_finished &msg) final override - { - LOG_SCOPE (msg.m_logger); - stash_named_types (msg.m_logger, msg.m_tu); - stash_global_vars (msg.m_logger, msg.m_tu); - } - - void - on_message (const analyzer_events::on_ana_init &m) final override - { - LOG_SCOPE (m.get_logger ()); - - if (!api.init_from_stashed_types ()) - { - sorry_no_cpython_plugin (); - m_init_failed = true; - return; - } - gcc_assert (api.get_type_PyObject ()); - - m.register_known_function ("PyList_Append", - std::make_unique ()); - m.register_known_function ("PyList_New", - std::make_unique ()); - m.register_known_function ("PyLong_FromLong", - std::make_unique ()); - m.register_known_function - ("__analyzer_cpython_dump_refcounts", - std::make_unique ()); - } - - void - on_message (const analyzer_events::on_frame_popped &msg) final override - { - if (m_init_failed) - return; - pyobj_refcnt_checker (msg.m_new_model, - msg.m_old_model, - msg.m_retval, - msg.m_ctxt); - } - -private: - bool m_init_failed; -} event_sub; - -} // namespace ana::cpython_plugin -} // namespace ana - -#endif /* #if ENABLE_ANALYZER */ - -int -plugin_init (struct plugin_name_args *plugin_info, - struct plugin_gcc_version *version) -{ -#if ENABLE_ANALYZER - const char *plugin_name = plugin_info->base_name; - if (0) - inform (input_location, "got here; %qs", plugin_name); - g->get_channels ().analyzer_events_channel.add_subscriber - (ana::cpython_plugin::event_sub); -#else - sorry_no_analyzer (); -#endif - return 0; -} diff --git a/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-PyList_Append.c b/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-PyList_Append.c deleted file mode 100644 index e1efd9efda5..00000000000 --- a/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-PyList_Append.c +++ /dev/null @@ -1,78 +0,0 @@ -/* { dg-do compile } */ -/* { dg-require-effective-target analyzer } */ -/* { dg-options "-fanalyzer" } */ -/* { dg-require-python-h "" } */ - - -#define PY_SSIZE_T_CLEAN -#include -#include "../analyzer/analyzer-decls.h" - -PyObject * -test_PyListAppend (long n) -{ - PyObject *item = PyLong_FromLong (n); - PyObject *list = PyList_New (0); - PyList_Append(list, item); - return list; /* { dg-warning "leak of 'item'" } */ - /* { dg-warning "expected 'item' to have reference count" "" { target *-*-* } .-1 } */ -} - -PyObject * -test_PyListAppend_2 (long n) -{ - PyObject *item = PyLong_FromLong (n); - if (!item) - return NULL; - - __analyzer_eval (item->ob_refcnt == 1); /* { dg-warning "TRUE" } */ - PyObject *list = PyList_New (n); - if (!list) - { - Py_DECREF(item); - return NULL; - } - - __analyzer_eval (list->ob_refcnt == 1); /* { dg-warning "TRUE" } */ - - if (PyList_Append (list, item) < 0) - __analyzer_eval (item->ob_refcnt == 1); /* { dg-warning "TRUE" } */ - else - __analyzer_eval (item->ob_refcnt == 2); /* { dg-warning "TRUE" } */ - return list; /* { dg-warning "leak of 'item'" } */ - /* { dg-warning "expected 'item' to have reference count" "" { target *-*-* } .-1 } */ -} - - -PyObject * -test_PyListAppend_3 (PyObject *item, PyObject *list) -{ - PyList_Append (list, item); - return list; -} - -PyObject * -test_PyListAppend_4 (long n) -{ - PyObject *item = PyLong_FromLong (n); - PyObject *list = NULL; - PyList_Append(list, item); - return list; -} - -PyObject * -test_PyListAppend_5 () -{ - PyObject *list = PyList_New (0); - PyList_Append(list, NULL); - return list; -} - -PyObject * -test_PyListAppend_6 () -{ - PyObject *item = NULL; - PyObject *list = NULL; - PyList_Append(list, item); - return list; -} \ No newline at end of file diff --git a/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-PyList_New.c b/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-PyList_New.c deleted file mode 100644 index 1d28e66b490..00000000000 --- a/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-PyList_New.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do compile } */ -/* { dg-require-effective-target analyzer } */ -/* { dg-options "-fanalyzer" } */ -/* { dg-require-python-h "" } */ - - -#define PY_SSIZE_T_CLEAN -#include -#include "../analyzer/analyzer-decls.h" - -PyObject * -test_PyList_New (Py_ssize_t len) -{ - PyObject *obj = PyList_New (len); - if (obj) - { - __analyzer_eval (obj->ob_refcnt == 1); /* { dg-warning "TRUE" } */ - __analyzer_eval (PyList_CheckExact (obj)); /* { dg-warning "TRUE" } */ - } - else - __analyzer_dump_path (); /* { dg-message "path" } */ - return obj; -} - -void -test_PyList_New_2 () -{ - PyObject *obj = PyList_New (0); -} /* { dg-warning "leak of 'obj'" } */ - -PyObject *test_stray_incref_PyList () -{ - PyObject *p = PyList_New (2); - if (p) - Py_INCREF (p); - return p; - /* { dg-warning "expected 'p' to have reference count" "" { target *-*-* } .-1 } */ -} \ No newline at end of file diff --git a/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c b/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c deleted file mode 100644 index 6ac593964ba..00000000000 --- a/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-do compile } */ -/* { dg-require-effective-target analyzer } */ -/* { dg-options "-fanalyzer" } */ -/* { dg-require-python-h "" } */ - - -#define PY_SSIZE_T_CLEAN -#include -#include "../analyzer/analyzer-decls.h" - -PyObject * -test_PyLong_New (long n) -{ - PyObject *obj = PyLong_FromLong (n); - if (obj) - { - __analyzer_eval (obj->ob_refcnt == 1); /* { dg-warning "TRUE" } */ - __analyzer_eval (PyLong_CheckExact (obj)); /* { dg-warning "TRUE" } */ - } - else - __analyzer_dump_path (); /* { dg-message "path" } */ - return obj; -} - -void -test_PyLong_New_2 (long n) -{ - PyObject *obj = PyLong_FromLong (n); -} /* { dg-warning "leak of 'obj'" } */ - -PyObject *test_stray_incref_PyLong (long val) -{ - PyObject *p = PyLong_FromLong (val); - if (p) - Py_INCREF (p); - return p; - /* { dg-warning "expected 'p' to have reference count" "" { target *-*-* } .-1 } */ -} \ No newline at end of file diff --git a/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-no-Python-h.c b/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-no-Python-h.c deleted file mode 100644 index c105074042a..00000000000 --- a/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-no-Python-h.c +++ /dev/null @@ -1,8 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-fanalyzer" } */ -/* { dg-require-effective-target analyzer } */ -/* { dg-message "'Python/C API' definitions not found. Please ensure to '#include '." "" { target *-*-* } 0 } */ - -void test_no_python_plugin () -{ -} \ No newline at end of file diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp index deef8e8570c..0a65ead5235 100644 --- a/gcc/testsuite/gcc.dg/plugin/plugin.exp +++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp @@ -195,11 +195,6 @@ set plugin_test_list [list \ taint-pr112974.c \ taint-pr112975.c \ taint-pr112977.c } \ - { analyzer_cpython_plugin.cc \ - cpython-plugin-test-no-Python-h.c \ - cpython-plugin-test-PyList_Append.c \ - cpython-plugin-test-PyList_New.c \ - cpython-plugin-test-PyLong_FromLong.c } \ { progress_notifications_plugin.cc } \ ] -- 2.56.0 From morin-mikael@orange.fr Mon Nov 2 19:59:20 2026 From: morin-mikael@orange.fr (Mikael Morin) Date: Mon, 2 Nov 2026 20:59:20 +0100 Subject: [PATCH] fortran: Use polymorphic assignment to copy a class value to a temporary [PR128349] Message-ID: <20261102195920.118751-1-morin-mikael@orange.fr> From: Mikael Morin Fortran-tested on aarch64-unknown-linux-gnu and powerpc64-unknown-linux-gnu without regression, and it fixes the transfer_class_5.f90 regression with -m32 on powerpc. I plan to push to trunk in two days if I don't get any comment about it. -- >8 -- Propagate class information from the original variable when copying to a temporary, so that the copy assignment doesn't fall back to non-polymorphic assignment. In the example added to the testsuite here, the class container doesn't appear as prefix of the array reference, because of a temporary variable. As a result, in trans_scalar_class_assign, the call to gfc_get_class_from_expr is unable to guess any reference to the class container, and we fall back to non-polymorphic assignment. This change uses the class container reference that is already saved by the scalarizer, and copies it to the expression metadata. And in trans_scalar_class_assign, usage of that class container metadata is tried first if it is present, before falling back to the existing handling if not. PR fortran/128349 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_variable): Set class container expression from the one saved by the scalarizer. (trans_scalar_class_assign): Use previously set class container expression if it's available. gcc/testsuite/ChangeLog: * gfortran.dg/unlimited_polymorphic_34.f90: New test. --- gcc/fortran/trans-expr.cc | 6 ++- .../gfortran.dg/unlimited_polymorphic_34.f90 | 41 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/unlimited_polymorphic_34.f90 diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index c81051f7162..558de49cbed 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -1966,7 +1966,10 @@ trans_scalar_class_assign (stmtblock_t *block, gfc_se *lse, gfc_se *rse) if (!GFC_CLASS_TYPE_P (TREE_TYPE (rse->expr)) || not_call_expr) { - tmp = gfc_get_class_from_expr (rse->expr); + if (rse->class_container != NULL_TREE) + tmp = rse->class_container; + else + tmp = gfc_get_class_from_expr (rse->expr); if (tmp == NULL_TREE) return false; rse_expr = gfc_evaluate_now (tmp, block); @@ -3187,6 +3190,7 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr) && ref->u.ar.type != AR_ELEMENT); else gfc_conv_tmp_array_ref (se); + se->class_container = ss_info->class_container; } else { diff --git a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_34.f90 b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_34.f90 new file mode 100644 index 00000000000..748d453794d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_34.f90 @@ -0,0 +1,41 @@ +! { dg-do run } +! +! PR fortran/PR128349 +! Check that to evaluate the TRANSFER intrinsic call, the copy to a temporary +! array is done using the polymorphic copy function instead of a regular +! assignment of void pointer values. + +program prog + implicit none + integer, parameter :: n = 5 + type :: t1 + integer :: c1, c2, c3 + end type + type :: t2 + integer :: c1, c2, c3 + end type + type(t1) :: a(n) + integer :: i + a = [ (t1(2*i+1, 3*i*i+2, 5*i*i+3), i=1, n) ] + call sub(a) +contains + subroutine sub(x) + class(*), intent(in) :: x(:) + type(t2) :: y(n) + call check_t2(transfer(x, y)) + end subroutine + subroutine check_t2(x) + type(t2), target, intent(in) :: x(:) + call check(x%c1, [3, 5, 7, 9, 11], 1) + call check(x%c2, [5, 14, 29, 50, 77], 2) + call check(x%c3, [8, 23, 48, 83, 128], 3) + end subroutine + subroutine check(x, y, e) + integer, intent(in) :: x(:), y(:), e + if (size(x) /= size(y)) error stop e*10+8 + !do i=1,size(x) + ! print *, e*10+i, (x(i) == y(i) ? "PASS" : "FAIL"), x(i), y(i) + !end do + if (any(x /= y)) error stop e*10+9 + end subroutine +end program -- 2.53.0 From botcazou@adacore.com Mon Nov 2 20:02:40 2026 From: botcazou@adacore.com (Eric Botcazou) Date: Mon, 02 Nov 2026 21:02:40 +0100 Subject: [PATCH] tree-optimization/127475 - avoid get_same_sized_vectype In-Reply-To: References: Message-ID: <2431365.ElGaqSPkdT@fomalhaut> > This avoids using get_same_sized_vectype in vectorizable_induction > where we only want a signed/unsigned variant of vectype. This > avoids the oddball scalar boolean type handling in that function. > > Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. > > PR tree-optimization/127475 > * tree-vect-loop.cc (vectorizable_induction): Use > signed_or_unsigned_type_for to get the step vectype. May I backport this onto the 16 branch? I have attached an Ada testcase that triggers the same ICE in const_vector_mask_from_tree as reported in the PR when compiled for Aarch64 at -O2 with a 16.x compiler, which is a regression from the 15.x compiler. * gnat.dg/specs/vect1.ads: New test. -- Eric Botcazou -------------- next part -------------- A non-text attachment was scrubbed... Name: vect1.ads Type: text/x-adasrc Size: 249 bytes Desc: not available URL: From morin-mikael@orange.fr Mon Nov 2 20:33:52 2026 From: morin-mikael@orange.fr (Mikael Morin) Date: Mon, 2 Nov 2026 21:33:52 +0100 Subject: [PATCH] libgfortran: [PR127893] Look up cached units without the unit rwlock In-Reply-To: References: Message-ID: <0a03d3a4-4d25-4e3b-a8ba-799700fb1e0c@orange.fr> Le 02/11/2026 ? 01:34, Jerry D a ?crit?: > Hi all, > > See the attached patch. The bugzilla comments show the testing results > form this change. This brought back some memories from doing the initial > unit caching. It makes sense to avoid using locks when not necessary. > > It has been tested on Mac M4 iOS and x86_64-linux. I also tested this in > an ARM container running under qemu. > > Regression tested. > > OK for mainline? OK. > > Regards, > > Jerry > From oleksandr.kulkov@grlab.org Mon Nov 2 20:50:04 2026 From: oleksandr.kulkov@grlab.org (Oleksandr Kulkov) Date: Mon, 2 Nov 2026 20:50:04 +0000 Subject: [PATCH v2] ipa: Allow inlining expanded target_clones [PR95796] Message-ID: This fixes the missed inlining reported in PR ipa/95796. Functions with matching target_clones attributes remain uninlinable after their versions are generated. The C-family target_clones attribute handler sets DECL_UNINLINABLE. Generated versions inherit that flag, preventing inlining even after matching caller and callee versions have been selected. Reject inlining while the target_clones attribute is present, without caching that temporary restriction in DECL_UNINLINABLE. Once version expansion replaces the attribute, the usual inlining checks apply. Add C and C++ checks for inlining matching versions and a negative check for different target lists. Keep the PR95778 call-routing tests focused on their existing assertions by marking their callees noinline. OK for trunk? If approved, please commit this on my behalf. Bootstrapped and regression-tested on x86_64-pc-linux-gnu at 7d652a985309ac5cd1492a505805bbd2c3781598 on 8 October 2026, with the default languages and multilib enabled, including check-c++-all. No new regressions compared with the unmodified base. gcc/c-family/ChangeLog: PR ipa/95796 * c-attribs.cc (handle_target_clones_attribute): Do not set DECL_UNINLINABLE for target_clones. gcc/ChangeLog: PR ipa/95796 * tree-inline.cc (tree_inlinable_function_p): Reject an unexpanded target_clones function without caching the restriction. gcc/testsuite/ChangeLog: PR ipa/95796 * g++.target/i386/pr95796-1.C: New test. * gcc.target/i386/pr95778-1.c (f2): Add noinline. * gcc.target/i386/pr95778-2.c (f2): Likewise. * gcc.target/i386/pr95796-1.c: New test. * gcc.target/i386/pr95796-3.c: New test. * gcc.target/i386/tct-ipa-inline-ice.c: Remove obsolete comment. Signed-off-by: Oleksandr Kulkov --- v2: no code changes. Resent inline with the DCO sign-off and maintainer CC. v1: Assisted-by: OpenAI Codex diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc index 470054f04..ab7c6f6eb 100644 --- a/gcc/c-family/c-attribs.cc +++ b/gcc/c-family/c-attribs.cc @@ -5786,9 +5786,6 @@ handle_target_clones_attribute (tree *node, tree name, tree ARG_UNUSED (args), "single % attribute is ignored"); *no_add_attrs = true; } - else - /* Do not inline functions with multiple clone targets. */ - DECL_UNINLINABLE (*node) = 1; } else { diff --git a/gcc/testsuite/g++.target/i386/pr95796-1.C b/gcc/testsuite/g++.target/i386/pr95796-1.C new file mode 100644 index 000000000..8bd554516 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/pr95796-1.C @@ -0,0 +1,21 @@ +/* PR ipa/95796 */ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +template +__attribute__((target_clones("default", "sse4.2"))) +static T +helper (T x) +{ + return 3 * x + 1; +} + +__attribute__((target_clones("sse4.2", "default"))) +unsigned +caller (unsigned x) +{ + return helper (x); +} + +/* { dg-final { scan-tree-dump-not "= helper" "optimized" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr95778-1.c b/gcc/testsuite/gcc.target/i386/pr95778-1.c index 18f838321..e537fd578 100644 --- a/gcc/testsuite/gcc.target/i386/pr95778-1.c +++ b/gcc/testsuite/gcc.target/i386/pr95778-1.c @@ -2,7 +2,7 @@ /* { dg-options "-O3 -fPIC -fno-asynchronous-unwind-tables" } */ /* { dg-require-ifunc "" } */ -__attribute__((target_clones("default,avx2"))) +__attribute__((noinline, target_clones("default,avx2"))) static int f2(int *p) { diff --git a/gcc/testsuite/gcc.target/i386/pr95778-2.c b/gcc/testsuite/gcc.target/i386/pr95778-2.c index 9ef513aab..339086671 100644 --- a/gcc/testsuite/gcc.target/i386/pr95778-2.c +++ b/gcc/testsuite/gcc.target/i386/pr95778-2.c @@ -2,7 +2,7 @@ /* { dg-options "-O3 -fPIC -fno-asynchronous-unwind-tables" } */ /* { dg-require-ifunc "" } */ -__attribute__((visibility("internal"),target_clones("default,avx2"))) +__attribute__((noinline, visibility("internal"),target_clones("default,avx2"))) int f2(int *p) { diff --git a/gcc/testsuite/gcc.target/i386/pr95796-1.c b/gcc/testsuite/gcc.target/i386/pr95796-1.c new file mode 100644 index 000000000..4d62a989d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr95796-1.c @@ -0,0 +1,22 @@ +/* PR ipa/95796 */ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +__attribute__((target_clones("default", "sse4.2"))) +static unsigned +helper (unsigned x) +{ + return 3 * x + 1; +} + +__attribute__((target_clones("sse4.2", "default"))) +unsigned +caller (unsigned x) +{ + return helper (x); +} + +/* Both callers should inline the matching helper, despite the different + order of the target_clones arguments. */ +/* { dg-final { scan-tree-dump-not "= helper" "optimized" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr95796-3.c b/gcc/testsuite/gcc.target/i386/pr95796-3.c new file mode 100644 index 000000000..1c3c45ffd --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr95796-3.c @@ -0,0 +1,23 @@ +/* PR ipa/95796 */ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +__attribute__((target_clones("default", "avx2"))) +static unsigned +helper (unsigned x) +{ + return 3 * x + 1; +} + +__attribute__((target_clones("default", "sse4.2"))) +unsigned +caller (unsigned x) +{ + return helper (x); +} + +/* The caller's target_clones list does not determine which version of the + helper the resolver would select. Do not inline the unexpanded helper + during early inlining and thereby bypass the resolver. */ +/* { dg-final { scan-tree-dump "= helper \\(" "optimized" } } */ diff --git a/gcc/testsuite/gcc.target/i386/tct-ipa-inline-ice.c b/gcc/testsuite/gcc.target/i386/tct-ipa-inline-ice.c index b8f77372e..6f390613f 100644 --- a/gcc/testsuite/gcc.target/i386/tct-ipa-inline-ice.c +++ b/gcc/testsuite/gcc.target/i386/tct-ipa-inline-ice.c @@ -1,8 +1,5 @@ /* Test function multiversioning and inlining of a function with a - target_clones attribute. Note, we need to allow inlining of - target_clones functions, see - "Do not inline functions with multiple clone targets." in c-attribs.cc, - otherwise the test would not trigger the ICE. */ + target_clones attribute. */ /* { dg-do assemble } */ /* { dg-require-ifunc "" } */ /* { dg-options "-O3" } */ diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc index 8162b1f50..425221449 100644 --- a/gcc/tree-inline.cc +++ b/gcc/tree-inline.cc @@ -4216,6 +4216,12 @@ tree_inlinable_function_p (tree fn) bool do_warning; tree always_inline; + /* Do not inline a target_clones function before its versions have been + expanded. This restriction is temporary: unlike the other reasons below, + it must not be cached in DECL_UNINLINABLE and inherited by the clones. */ + if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (fn))) + return false; + /* If we've already decided this function shouldn't be inlined, there's no need to check again. */ if (DECL_UNINLINABLE (fn)) From morin-mikael@orange.fr Mon Nov 2 20:54:34 2026 From: morin-mikael@orange.fr (Mikael Morin) Date: Mon, 2 Nov 2026 21:54:34 +0100 Subject: [PATCH] fortran: Delay creation of tree nodes after early return Message-ID: <20261102205434.131781-1-morin-mikael@orange.fr> From: Mikael Morin I noticed this while working on the PR128349 fix. Fortran-tested on aarch64-unknown-linux-gnu. I plan to push to mainline tomorrow or so. -- >8 -- In trans_scalar_class_assign, some tree nodes that are created are not used if the early return path is taken. Delay their creation. gcc/fortran/ChangeLog: * trans-expr.cc (trans_scalar_class_assign): Delay creation of tree nodes after early return. --- gcc/fortran/trans-expr.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index c81051f7162..b477ead6900 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -1982,11 +1982,6 @@ trans_scalar_class_assign (stmtblock_t *block, gfc_se *lse, gfc_se *rse) class_data = gfc_conv_descriptor_data_get (class_data); class_data = gfc_evaluate_now (class_data, block); - zero = build_int_cst (TREE_TYPE (class_data), 0); - cond = fold_build2_loc (input_location, NE_EXPR, - logical_type_node, - class_data, zero); - /* Copy the rhs to the lhs. */ fcn = gfc_vptr_copy_get (gfc_class_vptr_get (rse_expr)); fcn = build_fold_indirect_ref_loc (input_location, fcn); @@ -2000,6 +1995,11 @@ trans_scalar_class_assign (stmtblock_t *block, gfc_se *lse, gfc_se *rse) if (not_call_expr) return true; + zero = build_int_cst (TREE_TYPE (class_data), 0); + cond = fold_build2_loc (input_location, NE_EXPR, + logical_type_node, + class_data, zero); + /* Finalize the class data if needed. */ gfc_init_block (&inner_block); fcn = gfc_vptr_final_get (gfc_class_vptr_get (rse_expr)); -- 2.53.0 From oleksandr.kulkov@grlab.org Mon Nov 2 20:50:15 2026 From: oleksandr.kulkov@grlab.org (Oleksandr Kulkov) Date: Mon, 2 Nov 2026 15:50:15 -0500 Subject: [PATCH v2] ipa-cp: Normalize bit lattices before folding jump functions [PR128092] Message-ID: Bits above the source type's precision can be unknown in the IPA lattice. Extend the value and mask according to the operation type before passing them to bit_value_binop or bit_value_unop. Otherwise value_mask_to_min_max can mistake those upper bits for a varying sign bit and fold MAX_EXPR to the wrong operand. Bootstrapped and regression-tested on x86_64-pc-linux-gnu at 7d652a985309ac5cd1492a505805bbd2c3781598 on 23 October 2026, with the default languages and --disable-multilib. No new regressions compared with the unmodified base. The libgomp tests were rerun after correcting a local Tcl module-path issue. OK for trunk? If approved, please commit it on my behalf. gcc/ChangeLog: PR ipa/128092 * ipa-cp.cc (ipcp_bits_lattice::meet_with): Extend the source value and mask to the operation type before folding. gcc/testsuite/ChangeLog: PR ipa/128092 * g++.dg/torture/pr128092.C: New test. Signed-off-by: Oleksandr Kulkov --- v2: no code changes. Resent inline with the DCO sign-off and maintainer CC. v1: Assisted-by: OpenAI Codex diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index cecc8d17f..daea1da62 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -1050,6 +1050,9 @@ ipcp_bits_lattice::meet_with (ipcp_bits_lattice& other, unsigned precision, return false; widest_int adjusted_value, adjusted_mask; + /* The lattice may mark bits above PRECISION as unknown. */ + widest_int value = wi::ext (other.get_value (), precision, sgn); + widest_int mask = wi::ext (other.get_mask (), precision, sgn); if (TREE_CODE_CLASS (code) == tcc_binary) { @@ -1058,7 +1061,7 @@ ipcp_bits_lattice::meet_with (ipcp_bits_lattice& other, unsigned precision, get_value_and_mask (operand, &o_value, &o_mask); bit_value_binop (code, sgn, precision, &adjusted_value, &adjusted_mask, - sgn, precision, other.get_value (), other.get_mask (), + sgn, precision, value, mask, TYPE_SIGN (type), TYPE_PRECISION (type), o_value, o_mask); if (wi::sext (adjusted_mask, precision) == -1) @@ -1068,8 +1071,7 @@ ipcp_bits_lattice::meet_with (ipcp_bits_lattice& other, unsigned precision, else if (TREE_CODE_CLASS (code) == tcc_unary) { bit_value_unop (code, sgn, precision, &adjusted_value, - &adjusted_mask, sgn, precision, other.get_value (), - other.get_mask ()); + &adjusted_mask, sgn, precision, value, mask); if (wi::sext (adjusted_mask, precision) == -1) return set_to_bottom (); diff --git a/gcc/testsuite/g++.dg/torture/pr128092.C b/gcc/testsuite/g++.dg/torture/pr128092.C new file mode 100644 index 000000000..152026430 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr128092.C @@ -0,0 +1,20 @@ +/* { dg-do run { target c++11 } } */ + +[[gnu::noinline]] static unsigned +f (unsigned x) +{ + return x; +} + +[[gnu::noinline]] static unsigned +g (int x) +{ + return f (x > 0 ? x : 0); +} + +int +main () +{ + if (g (1) + g (0) != 1) + __builtin_abort (); +} From anlauf@gmx.de Mon Nov 2 20:59:16 2026 From: anlauf@gmx.de (Harald Anlauf) Date: Mon, 2 Nov 2026 21:59:16 +0100 Subject: [PATCH] fortran: Use polymorphic assignment to copy a class value to a temporary [PR128349] In-Reply-To: <20261102195920.118751-1-morin-mikael@orange.fr> References: <20261102195920.118751-1-morin-mikael@orange.fr> Message-ID: Am 02.11.26 um 8:59 PM schrieb Mikael Morin: > From: Mikael Morin > > Fortran-tested on aarch64-unknown-linux-gnu and powerpc64-unknown-linux-gnu > without regression, and it fixes the transfer_class_5.f90 regression > with -m32 on powerpc. > I plan to push to trunk in two days if I don't get any comment about it. This look good to me. OK for trunk. > -- >8 -- > > Propagate class information from the original variable when copying to a > temporary, so that the copy assignment doesn't fall back to non-polymorphic > assignment. > > In the example added to the testsuite here, the class container doesn't > appear as prefix of the array reference, because of a temporary variable. > As a result, in trans_scalar_class_assign, the call to > gfc_get_class_from_expr is unable to guess any reference to the class > container, and we fall back to non-polymorphic assignment. > > This change uses the class container reference that is already saved by > the scalarizer, and copies it to the expression metadata. And in > trans_scalar_class_assign, usage of that class container metadata is tried > first if it is present, before falling back to the existing handling if not. > > PR fortran/128349 > > gcc/fortran/ChangeLog: > > * trans-expr.cc (gfc_conv_variable): Set class container > expression from the one saved by the scalarizer. > (trans_scalar_class_assign): Use previously set class container > expression if it's available. > > gcc/testsuite/ChangeLog: > > * gfortran.dg/unlimited_polymorphic_34.f90: New test. > --- > gcc/fortran/trans-expr.cc | 6 ++- > .../gfortran.dg/unlimited_polymorphic_34.f90 | 41 +++++++++++++++++++ > 2 files changed, 46 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gfortran.dg/unlimited_polymorphic_34.f90 > > diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc > index c81051f7162..558de49cbed 100644 > --- a/gcc/fortran/trans-expr.cc > +++ b/gcc/fortran/trans-expr.cc > @@ -1966,7 +1966,10 @@ trans_scalar_class_assign (stmtblock_t *block, gfc_se *lse, gfc_se *rse) > if (!GFC_CLASS_TYPE_P (TREE_TYPE (rse->expr)) > || not_call_expr) > { > - tmp = gfc_get_class_from_expr (rse->expr); > + if (rse->class_container != NULL_TREE) > + tmp = rse->class_container; > + else > + tmp = gfc_get_class_from_expr (rse->expr); > if (tmp == NULL_TREE) > return false; > rse_expr = gfc_evaluate_now (tmp, block); > @@ -3187,6 +3190,7 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr) > && ref->u.ar.type != AR_ELEMENT); > else > gfc_conv_tmp_array_ref (se); > + se->class_container = ss_info->class_container; > } > else > { > diff --git a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_34.f90 b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_34.f90 > new file mode 100644 > index 00000000000..748d453794d > --- /dev/null > +++ b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_34.f90 > @@ -0,0 +1,41 @@ > +! { dg-do run } > +! > +! PR fortran/PR128349 > +! Check that to evaluate the TRANSFER intrinsic call, the copy to a temporary > +! array is done using the polymorphic copy function instead of a regular > +! assignment of void pointer values. > + > +program prog > + implicit none > + integer, parameter :: n = 5 > + type :: t1 > + integer :: c1, c2, c3 > + end type > + type :: t2 > + integer :: c1, c2, c3 > + end type > + type(t1) :: a(n) > + integer :: i > + a = [ (t1(2*i+1, 3*i*i+2, 5*i*i+3), i=1, n) ] > + call sub(a) > +contains > + subroutine sub(x) > + class(*), intent(in) :: x(:) > + type(t2) :: y(n) > + call check_t2(transfer(x, y)) > + end subroutine > + subroutine check_t2(x) > + type(t2), target, intent(in) :: x(:) > + call check(x%c1, [3, 5, 7, 9, 11], 1) > + call check(x%c2, [5, 14, 29, 50, 77], 2) > + call check(x%c3, [8, 23, 48, 83, 128], 3) > + end subroutine > + subroutine check(x, y, e) > + integer, intent(in) :: x(:), y(:), e > + if (size(x) /= size(y)) error stop e*10+8 > + !do i=1,size(x) > + ! print *, e*10+i, (x(i) == y(i) ? "PASS" : "FAIL"), x(i), y(i) > + !end do > + if (any(x /= y)) error stop e*10+9 > + end subroutine > +end program From anlauf@gmx.de Mon Nov 2 20:59:16 2026 From: anlauf@gmx.de (Harald Anlauf) Date: Mon, 2 Nov 2026 21:59:16 +0100 Subject: [PATCH] fortran: Use polymorphic assignment to copy a class value to a temporary [PR128349] In-Reply-To: <20261102195920.118751-1-morin-mikael@orange.fr> References: <20261102195920.118751-1-morin-mikael@orange.fr> Message-ID: Am 02.11.26 um 8:59 PM schrieb Mikael Morin: > From: Mikael Morin > > Fortran-tested on aarch64-unknown-linux-gnu and powerpc64-unknown-linux-gnu > without regression, and it fixes the transfer_class_5.f90 regression > with -m32 on powerpc. > I plan to push to trunk in two days if I don't get any comment about it. This look good to me. OK for trunk. > -- >8 -- > > Propagate class information from the original variable when copying to a > temporary, so that the copy assignment doesn't fall back to non-polymorphic > assignment. > > In the example added to the testsuite here, the class container doesn't > appear as prefix of the array reference, because of a temporary variable. > As a result, in trans_scalar_class_assign, the call to > gfc_get_class_from_expr is unable to guess any reference to the class > container, and we fall back to non-polymorphic assignment. > > This change uses the class container reference that is already saved by > the scalarizer, and copies it to the expression metadata. And in > trans_scalar_class_assign, usage of that class container metadata is tried > first if it is present, before falling back to the existing handling if not. > > PR fortran/128349 > > gcc/fortran/ChangeLog: > > * trans-expr.cc (gfc_conv_variable): Set class container > expression from the one saved by the scalarizer. > (trans_scalar_class_assign): Use previously set class container > expression if it's available. > > gcc/testsuite/ChangeLog: > > * gfortran.dg/unlimited_polymorphic_34.f90: New test. > --- > gcc/fortran/trans-expr.cc | 6 ++- > .../gfortran.dg/unlimited_polymorphic_34.f90 | 41 +++++++++++++++++++ > 2 files changed, 46 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gfortran.dg/unlimited_polymorphic_34.f90 > > diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc > index c81051f7162..558de49cbed 100644 > --- a/gcc/fortran/trans-expr.cc > +++ b/gcc/fortran/trans-expr.cc > @@ -1966,7 +1966,10 @@ trans_scalar_class_assign (stmtblock_t *block, gfc_se *lse, gfc_se *rse) > if (!GFC_CLASS_TYPE_P (TREE_TYPE (rse->expr)) > || not_call_expr) > { > - tmp = gfc_get_class_from_expr (rse->expr); > + if (rse->class_container != NULL_TREE) > + tmp = rse->class_container; > + else > + tmp = gfc_get_class_from_expr (rse->expr); > if (tmp == NULL_TREE) > return false; > rse_expr = gfc_evaluate_now (tmp, block); > @@ -3187,6 +3190,7 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr) > && ref->u.ar.type != AR_ELEMENT); > else > gfc_conv_tmp_array_ref (se); > + se->class_container = ss_info->class_container; > } > else > { > diff --git a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_34.f90 b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_34.f90 > new file mode 100644 > index 00000000000..748d453794d > --- /dev/null > +++ b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_34.f90 > @@ -0,0 +1,41 @@ > +! { dg-do run } > +! > +! PR fortran/PR128349 > +! Check that to evaluate the TRANSFER intrinsic call, the copy to a temporary > +! array is done using the polymorphic copy function instead of a regular > +! assignment of void pointer values. > + > +program prog > + implicit none > + integer, parameter :: n = 5 > + type :: t1 > + integer :: c1, c2, c3 > + end type > + type :: t2 > + integer :: c1, c2, c3 > + end type > + type(t1) :: a(n) > + integer :: i > + a = [ (t1(2*i+1, 3*i*i+2, 5*i*i+3), i=1, n) ] > + call sub(a) > +contains > + subroutine sub(x) > + class(*), intent(in) :: x(:) > + type(t2) :: y(n) > + call check_t2(transfer(x, y)) > + end subroutine > + subroutine check_t2(x) > + type(t2), target, intent(in) :: x(:) > + call check(x%c1, [3, 5, 7, 9, 11], 1) > + call check(x%c2, [5, 14, 29, 50, 77], 2) > + call check(x%c3, [8, 23, 48, 83, 128], 3) > + end subroutine > + subroutine check(x, y, e) > + integer, intent(in) :: x(:), y(:), e > + if (size(x) /= size(y)) error stop e*10+8 > + !do i=1,size(x) > + ! print *, e*10+i, (x(i) == y(i) ? "PASS" : "FAIL"), x(i), y(i) > + !end do > + if (any(x /= y)) error stop e*10+9 > + end subroutine > +end program From anlauf@gmx.de Mon Nov 2 21:00:50 2026 From: anlauf@gmx.de (Harald Anlauf) Date: Mon, 2 Nov 2026 22:00:50 +0100 Subject: [PATCH] fortran: Delay creation of tree nodes after early return In-Reply-To: <20261102205434.131781-1-morin-mikael@orange.fr> References: <20261102205434.131781-1-morin-mikael@orange.fr> Message-ID: <735d7580-82da-4a19-95be-402f07562571@gmx.de> Am 02.11.26 um 9:54 PM schrieb Mikael Morin: > From: Mikael Morin > > I noticed this while working on the PR128349 fix. > Fortran-tested on aarch64-unknown-linux-gnu. > I plan to push to mainline tomorrow or so.OK. OK. > -- >8 -- > > In trans_scalar_class_assign, some tree nodes that are created are not used > if the early return path is taken. Delay their creation. > > gcc/fortran/ChangeLog: > > * trans-expr.cc (trans_scalar_class_assign): Delay creation of tree > nodes after early return. > --- > gcc/fortran/trans-expr.cc | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc > index c81051f7162..b477ead6900 100644 > --- a/gcc/fortran/trans-expr.cc > +++ b/gcc/fortran/trans-expr.cc > @@ -1982,11 +1982,6 @@ trans_scalar_class_assign (stmtblock_t *block, gfc_se *lse, gfc_se *rse) > class_data = gfc_conv_descriptor_data_get (class_data); > class_data = gfc_evaluate_now (class_data, block); > > - zero = build_int_cst (TREE_TYPE (class_data), 0); > - cond = fold_build2_loc (input_location, NE_EXPR, > - logical_type_node, > - class_data, zero); > - > /* Copy the rhs to the lhs. */ > fcn = gfc_vptr_copy_get (gfc_class_vptr_get (rse_expr)); > fcn = build_fold_indirect_ref_loc (input_location, fcn); > @@ -2000,6 +1995,11 @@ trans_scalar_class_assign (stmtblock_t *block, gfc_se *lse, gfc_se *rse) > if (not_call_expr) > return true; > > + zero = build_int_cst (TREE_TYPE (class_data), 0); > + cond = fold_build2_loc (input_location, NE_EXPR, > + logical_type_node, > + class_data, zero); > + > /* Finalize the class data if needed. */ > gfc_init_block (&inner_block); > fcn = gfc_vptr_final_get (gfc_class_vptr_get (rse_expr)); From rdapp.gcc@gmail.com Mon Nov 2 21:27:29 2026 From: rdapp.gcc@gmail.com (Robin Dapp) Date: Mon, 02 Nov 2026 22:27:29 +0100 Subject: [PATCH v5] Recognize predicated-index PHI during vectorization analysis In-Reply-To: References: <4863a9ace09dca08fc03090693176e6217bd27e6.1790337786.git.Raghesh.Aloor@amd.com> Message-ID: Hi Raghesh, The checking code looks reasonable to me now. Just a bit of bikeshedding :) > --- a/gcc/testsuite/lib/target-supports.exp > +++ b/gcc/testsuite/lib/target-supports.exp > @@ -10105,6 +10105,14 @@ proc check_effective_target_vect_masked_store { } { > || [check_effective_target_riscv_v] }] > } > > +# Return 1 if the target supports vector compress stores. > + > +proc check_effective_target_vect_compress { } { > + return [expr { [check_avx_available] This should be avx512f or something I presume? I realize it's a bit awkward to require avx512 now when the tests for this patch don't even require it yet but as the goal is compress, we should match that at the requirement level. For the tests you'll probably need something like { dg-additional-options "-mavx512f" { ...? Test -2 is not fully accurate in terms of what it checks but as we're going to adjust it for the real codegen anyway, I don't think it matters much. That said, I don't think we need a v6. Was your plan to commit individually or wait until everything fits nicely together? All in one would be nicer so we could see how everything works together (and in case we notice something that needs changing here after all). -- Regards Robin From anlauf@gmx.de Mon Nov 2 21:41:18 2026 From: anlauf@gmx.de (Harald Anlauf) Date: Mon, 2 Nov 2026 22:41:18 +0100 Subject: [PATCH] libgfortran/103886 - enable 64-bit time_t on 32-bit glibc targets In-Reply-To: <4s9r5146-rqnp-057r-916r-86339nnrop71@fhfr.qr> References: <4s9r5146-rqnp-057r-916r-86339nnrop71@fhfr.qr> Message-ID: Hi Richard! Am 31.10.26 um 7:57 PM schrieb Richard Biener: > PR114895 reports that on 32-bit glibc targets with 32-bit time_t, stat() > fails with EOVERFLOW once file timestamps are past 2038-01-19. > The LIBGFOR_CHECK_WORKING_STAT configure test then fails, HAVE_WORKING_STAT > is left undefined, and the build of io/unix.c breaks, since the > !HAVE_WORKING_STAT code path there is only usable on MinGW. > This can be reproduced e.g. by building the 32-bit multilib in a VM whose > clock is set past 2038. > > Fix this by building libgfortran with 64-bit time_t where the C library > supports it as requested by PR103886. A new LIBGFOR_CHECK_TIME_BITS64 > check, run right after AC_SYS_LARGEFILE, tests whether time_t is already > 64 bits wide and, if not, whether defining _TIME_BITS to 64 makes it so; > in that case _TIME_BITS is defined to 64 in config.h. glibc only accepts > _TIME_BITS=64 together with _FILE_OFFSET_BITS=64, so the check relies on > the _FILE_OFFSET_BITS setting from AC_SYS_LARGEFILE and does nothing > when configured with --disable-largefile. > > No exported libgfortran interface uses time_t, struct stat or other > time-related C types; the time_t uses are all in internal helpers, so > the library ABI does not change. Note that intrinsics returning or > taking default-kind INTEGER values (e.g. TIME, or STAT with an INTEGER(4) > array) still truncate to 32 bits; this change only makes the internal > handling and the 64-bit variants correct past 2038. > > Bootstrap and regtest running on x86_64-unknown-linux-gnu. I'll see > to also somehow test a native i?86 build (the x86_64 32bit multilib > exercises it though). Given the toplevel configure.ac --disable-year2038 > and it's comments I've opted for selectively enabling libgfortran since > it is one of the target libraries which suffers from issues but switching > has no effects on its ABI (and it has that build failure recorded in > PR114895). Also PR114065 reports Ada will fail to build with > -D_TIME_BITS=64 ... > > OK for trunk? I am not really an expert in this area, but then nobody has stepped in so far. I think this is OK. There are other (non-standard) intrinsics, like TIME8(), which allow the user to handle date past the critical one. Users with legacy codes will have to audit them anyway in the coming 11 years... We may add a notice to the 17.x release notes with the above info. You may wait for another 24h or so to see if someone else sees a critical issue. Thanks, Harald > Thanks, > Richard. > > PR libfortran/103886 > PR libfortran/114895 > libgfortran/ > * acinclude.m4 (LIBGFOR_CHECK_TIME_BITS64): New check for > 64-bit time_t support. > * configure.ac: Invoke LIBGFOR_CHECK_TIME_BITS64. > * configure: Regenerate. > * config.h.in: Regenerate. > --- > libgfortran/acinclude.m4 | 25 ++++++++++++++++ > libgfortran/config.h.in | 3 ++ > libgfortran/configure | 62 ++++++++++++++++++++++++++++++++++++++++ > libgfortran/configure.ac | 1 + > 4 files changed, 91 insertions(+) > > diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4 > index 118bed2b41b..890516a6aed 100644 > --- a/libgfortran/acinclude.m4 > +++ b/libgfortran/acinclude.m4 > @@ -178,6 +178,31 @@ if test x"$libgfor_cv_have_crlf" = xyes; then > AC_DEFINE(HAVE_CRLF, 1, [Define if CRLF is line terminator.]) > fi]) > > +dnl Check for 64-bit time_t support on 32-bit platforms (Y2038 safety). > +dnl glibc only accepts _TIME_BITS=64 together with _FILE_OFFSET_BITS=64, > +dnl so rely on AC_SYS_LARGEFILE having put the latter into confdefs.h; > +dnl with --disable-largefile the probe fails and _TIME_BITS is not set. > +AC_DEFUN([LIBGFOR_CHECK_TIME_BITS64], [ > + AC_REQUIRE([AC_SYS_LARGEFILE]) > + AC_CACHE_CHECK([for 64-bit time_t], [libgfor_cv_time_bits64], [ > + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ > +#include > +#include > +int verify_y2038[(sizeof (time_t) >= 8) ? 1 : -1]; > +]])], [libgfor_cv_time_bits64="already 64-bit"], [ > + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ > +#define _TIME_BITS 64 > +#include > +#include > +int verify_y2038[(sizeof (time_t) >= 8) ? 1 : -1]; > +]])], [libgfor_cv_time_bits64="yes"], [libgfor_cv_time_bits64="no"]) > + ]) > + ]) > + if test "x$libgfor_cv_time_bits64" = xyes; then > + AC_DEFINE([_TIME_BITS], [64], [Define to 64 to enable 64-bit time_t on 32-bit systems.]) > + fi > +]) > + > dnl Check whether the st_ino and st_dev stat fields taken together uniquely > dnl identify the file within the system. This is should be true for POSIX > dnl systems; it is known to be false on mingw32. > diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in > index 1d4bbfbb4a9..7a57b9a6208 100644 > --- a/libgfortran/config.h.in > +++ b/libgfortran/config.h.in > @@ -1266,6 +1266,9 @@ > /* Define to 1 if you need to in order for `stat' and other things to work. */ > #undef _POSIX_SOURCE > > +/* Define to 64 to enable 64-bit time_t on 32-bit systems. */ > +#undef _TIME_BITS > + > /* Define to the type of a signed integer type wide enough to hold a pointer, > if such a type exists, and if the system does not define it. */ > #undef intptr_t > diff --git a/libgfortran/configure b/libgfortran/configure > index c7d2c6666bf..6aeba503714 100755 > --- a/libgfortran/configure > +++ b/libgfortran/configure > @@ -16987,6 +16987,68 @@ rm -rf conftest* > fi > > > + > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit time_t" >&5 > +$as_echo_n "checking for 64-bit time_t... " >&6; } > +if ${libgfor_cv_time_bits64+:} false; then : > + $as_echo_n "(cached) " >&6 > +else > + > + cat confdefs.h - <<_ACEOF >conftest.$ac_ext > +/* end confdefs.h. */ > + > +#include > +#include > +int verify_y2038[(sizeof (time_t) >= 8) ? 1 : -1]; > + > +int > +main () > +{ > + > + ; > + return 0; > +} > +_ACEOF > +if ac_fn_c_try_compile "$LINENO"; then : > + libgfor_cv_time_bits64="already 64-bit" > +else > + > + cat confdefs.h - <<_ACEOF >conftest.$ac_ext > +/* end confdefs.h. */ > + > +#define _TIME_BITS 64 > +#include > +#include > +int verify_y2038[(sizeof (time_t) >= 8) ? 1 : -1]; > + > +int > +main () > +{ > + > + ; > + return 0; > +} > +_ACEOF > +if ac_fn_c_try_compile "$LINENO"; then : > + libgfor_cv_time_bits64="yes" > +else > + libgfor_cv_time_bits64="no" > +fi > +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > + > +fi > +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > + > +fi > +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgfor_cv_time_bits64" >&5 > +$as_echo "$libgfor_cv_time_bits64" >&6; } > + if test "x$libgfor_cv_time_bits64" = xyes; then > + > +$as_echo "#define _TIME_BITS 64" >>confdefs.h > + > + fi > + > + > # Types > ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" > if test "x$ac_cv_type_off_t" = xyes; then : > diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac > index c50112df91c..95d986f1308 100644 > --- a/libgfortran/configure.ac > +++ b/libgfortran/configure.ac > @@ -287,6 +287,7 @@ AC_SUBST(extra_ldflags_libgfortran) > LIBGFOR_WORKING_GFORTRAN > > AC_SYS_LARGEFILE > +LIBGFOR_CHECK_TIME_BITS64 > > # Types > AC_TYPE_OFF_T > > base-commit: ada5b8f08739b26bf76558c9d5157cbbdd16c205 > prerequisite-patch-id: e52d299db98b0892f974152cd9fa5f6859fec5b7 > prerequisite-patch-id: 39da6ec3264bae454fa504f127cd5b80a0662f04 > prerequisite-patch-id: 6d6c263a964425334ad8c2edd4dd89dcbff44bfe > prerequisite-patch-id: 9a12a1706cbdff1edf8959682cd3cf9d900cd8f1 > prerequisite-patch-id: b24057443c46d6979436cce479836178b19355de > prerequisite-patch-id: d61bf2c4249ecd3d9da5eeda002d332ed3a8b4fd > prerequisite-patch-id: 59cbeca60f782f48f945bc532c2235a50de6f0e5 > prerequisite-patch-id: 8eddd3172e2007d0fc591124a56b372dfe83e683 > prerequisite-patch-id: 862842dd3742066d039f66ffe9528bc490308c50 > prerequisite-patch-id: e413d39d9af45f25483eaf229cf883c771444fbb > prerequisite-patch-id: 2faef186ad1d816bb104d89638bc4cec6d863a46 > prerequisite-patch-id: b32cceb111f4f57798e4b1d58822281e7bbaf25e > prerequisite-patch-id: 08ff1c06921c5e253d911128be3a8ebb76137d3c > prerequisite-patch-id: 72aa7ba47bd81909871a9e1a2e9de14f2cf42174 > prerequisite-patch-id: 2ce10434bf0a7ab22e27ff177073e10b4b7d0d72 > prerequisite-patch-id: 68776813e47d3d411bef2f4229a589711887ca6c > prerequisite-patch-id: e286b2e30887f3f43a3458c7c9b3f8c8b513a91b > prerequisite-patch-id: dc07b9957107f8b453a87ad64fd8477ae26e370c From anlauf@gmx.de Mon Nov 2 21:41:18 2026 From: anlauf@gmx.de (Harald Anlauf) Date: Mon, 2 Nov 2026 22:41:18 +0100 Subject: [PATCH] libgfortran/103886 - enable 64-bit time_t on 32-bit glibc targets In-Reply-To: <4s9r5146-rqnp-057r-916r-86339nnrop71@fhfr.qr> References: <4s9r5146-rqnp-057r-916r-86339nnrop71@fhfr.qr> Message-ID: Hi Richard! Am 31.10.26 um 7:57 PM schrieb Richard Biener: > PR114895 reports that on 32-bit glibc targets with 32-bit time_t, stat() > fails with EOVERFLOW once file timestamps are past 2038-01-19. > The LIBGFOR_CHECK_WORKING_STAT configure test then fails, HAVE_WORKING_STAT > is left undefined, and the build of io/unix.c breaks, since the > !HAVE_WORKING_STAT code path there is only usable on MinGW. > This can be reproduced e.g. by building the 32-bit multilib in a VM whose > clock is set past 2038. > > Fix this by building libgfortran with 64-bit time_t where the C library > supports it as requested by PR103886. A new LIBGFOR_CHECK_TIME_BITS64 > check, run right after AC_SYS_LARGEFILE, tests whether time_t is already > 64 bits wide and, if not, whether defining _TIME_BITS to 64 makes it so; > in that case _TIME_BITS is defined to 64 in config.h. glibc only accepts > _TIME_BITS=64 together with _FILE_OFFSET_BITS=64, so the check relies on > the _FILE_OFFSET_BITS setting from AC_SYS_LARGEFILE and does nothing > when configured with --disable-largefile. > > No exported libgfortran interface uses time_t, struct stat or other > time-related C types; the time_t uses are all in internal helpers, so > the library ABI does not change. Note that intrinsics returning or > taking default-kind INTEGER values (e.g. TIME, or STAT with an INTEGER(4) > array) still truncate to 32 bits; this change only makes the internal > handling and the 64-bit variants correct past 2038. > > Bootstrap and regtest running on x86_64-unknown-linux-gnu. I'll see > to also somehow test a native i?86 build (the x86_64 32bit multilib > exercises it though). Given the toplevel configure.ac --disable-year2038 > and it's comments I've opted for selectively enabling libgfortran since > it is one of the target libraries which suffers from issues but switching > has no effects on its ABI (and it has that build failure recorded in > PR114895). Also PR114065 reports Ada will fail to build with > -D_TIME_BITS=64 ... > > OK for trunk? I am not really an expert in this area, but then nobody has stepped in so far. I think this is OK. There are other (non-standard) intrinsics, like TIME8(), which allow the user to handle date past the critical one. Users with legacy codes will have to audit them anyway in the coming 11 years... We may add a notice to the 17.x release notes with the above info. You may wait for another 24h or so to see if someone else sees a critical issue. Thanks, Harald > Thanks, > Richard. > > PR libfortran/103886 > PR libfortran/114895 > libgfortran/ > * acinclude.m4 (LIBGFOR_CHECK_TIME_BITS64): New check for > 64-bit time_t support. > * configure.ac: Invoke LIBGFOR_CHECK_TIME_BITS64. > * configure: Regenerate. > * config.h.in: Regenerate. > --- > libgfortran/acinclude.m4 | 25 ++++++++++++++++ > libgfortran/config.h.in | 3 ++ > libgfortran/configure | 62 ++++++++++++++++++++++++++++++++++++++++ > libgfortran/configure.ac | 1 + > 4 files changed, 91 insertions(+) > > diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4 > index 118bed2b41b..890516a6aed 100644 > --- a/libgfortran/acinclude.m4 > +++ b/libgfortran/acinclude.m4 > @@ -178,6 +178,31 @@ if test x"$libgfor_cv_have_crlf" = xyes; then > AC_DEFINE(HAVE_CRLF, 1, [Define if CRLF is line terminator.]) > fi]) > > +dnl Check for 64-bit time_t support on 32-bit platforms (Y2038 safety). > +dnl glibc only accepts _TIME_BITS=64 together with _FILE_OFFSET_BITS=64, > +dnl so rely on AC_SYS_LARGEFILE having put the latter into confdefs.h; > +dnl with --disable-largefile the probe fails and _TIME_BITS is not set. > +AC_DEFUN([LIBGFOR_CHECK_TIME_BITS64], [ > + AC_REQUIRE([AC_SYS_LARGEFILE]) > + AC_CACHE_CHECK([for 64-bit time_t], [libgfor_cv_time_bits64], [ > + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ > +#include > +#include > +int verify_y2038[(sizeof (time_t) >= 8) ? 1 : -1]; > +]])], [libgfor_cv_time_bits64="already 64-bit"], [ > + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ > +#define _TIME_BITS 64 > +#include > +#include > +int verify_y2038[(sizeof (time_t) >= 8) ? 1 : -1]; > +]])], [libgfor_cv_time_bits64="yes"], [libgfor_cv_time_bits64="no"]) > + ]) > + ]) > + if test "x$libgfor_cv_time_bits64" = xyes; then > + AC_DEFINE([_TIME_BITS], [64], [Define to 64 to enable 64-bit time_t on 32-bit systems.]) > + fi > +]) > + > dnl Check whether the st_ino and st_dev stat fields taken together uniquely > dnl identify the file within the system. This is should be true for POSIX > dnl systems; it is known to be false on mingw32. > diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in > index 1d4bbfbb4a9..7a57b9a6208 100644 > --- a/libgfortran/config.h.in > +++ b/libgfortran/config.h.in > @@ -1266,6 +1266,9 @@ > /* Define to 1 if you need to in order for `stat' and other things to work. */ > #undef _POSIX_SOURCE > > +/* Define to 64 to enable 64-bit time_t on 32-bit systems. */ > +#undef _TIME_BITS > + > /* Define to the type of a signed integer type wide enough to hold a pointer, > if such a type exists, and if the system does not define it. */ > #undef intptr_t > diff --git a/libgfortran/configure b/libgfortran/configure > index c7d2c6666bf..6aeba503714 100755 > --- a/libgfortran/configure > +++ b/libgfortran/configure > @@ -16987,6 +16987,68 @@ rm -rf conftest* > fi > > > + > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit time_t" >&5 > +$as_echo_n "checking for 64-bit time_t... " >&6; } > +if ${libgfor_cv_time_bits64+:} false; then : > + $as_echo_n "(cached) " >&6 > +else > + > + cat confdefs.h - <<_ACEOF >conftest.$ac_ext > +/* end confdefs.h. */ > + > +#include > +#include > +int verify_y2038[(sizeof (time_t) >= 8) ? 1 : -1]; > + > +int > +main () > +{ > + > + ; > + return 0; > +} > +_ACEOF > +if ac_fn_c_try_compile "$LINENO"; then : > + libgfor_cv_time_bits64="already 64-bit" > +else > + > + cat confdefs.h - <<_ACEOF >conftest.$ac_ext > +/* end confdefs.h. */ > + > +#define _TIME_BITS 64 > +#include > +#include > +int verify_y2038[(sizeof (time_t) >= 8) ? 1 : -1]; > + > +int > +main () > +{ > + > + ; > + return 0; > +} > +_ACEOF > +if ac_fn_c_try_compile "$LINENO"; then : > + libgfor_cv_time_bits64="yes" > +else > + libgfor_cv_time_bits64="no" > +fi > +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > + > +fi > +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > + > +fi > +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgfor_cv_time_bits64" >&5 > +$as_echo "$libgfor_cv_time_bits64" >&6; } > + if test "x$libgfor_cv_time_bits64" = xyes; then > + > +$as_echo "#define _TIME_BITS 64" >>confdefs.h > + > + fi > + > + > # Types > ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" > if test "x$ac_cv_type_off_t" = xyes; then : > diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac > index c50112df91c..95d986f1308 100644 > --- a/libgfortran/configure.ac > +++ b/libgfortran/configure.ac > @@ -287,6 +287,7 @@ AC_SUBST(extra_ldflags_libgfortran) > LIBGFOR_WORKING_GFORTRAN > > AC_SYS_LARGEFILE > +LIBGFOR_CHECK_TIME_BITS64 > > # Types > AC_TYPE_OFF_T > > base-commit: ada5b8f08739b26bf76558c9d5157cbbdd16c205 > prerequisite-patch-id: e52d299db98b0892f974152cd9fa5f6859fec5b7 > prerequisite-patch-id: 39da6ec3264bae454fa504f127cd5b80a0662f04 > prerequisite-patch-id: 6d6c263a964425334ad8c2edd4dd89dcbff44bfe > prerequisite-patch-id: 9a12a1706cbdff1edf8959682cd3cf9d900cd8f1 > prerequisite-patch-id: b24057443c46d6979436cce479836178b19355de > prerequisite-patch-id: d61bf2c4249ecd3d9da5eeda002d332ed3a8b4fd > prerequisite-patch-id: 59cbeca60f782f48f945bc532c2235a50de6f0e5 > prerequisite-patch-id: 8eddd3172e2007d0fc591124a56b372dfe83e683 > prerequisite-patch-id: 862842dd3742066d039f66ffe9528bc490308c50 > prerequisite-patch-id: e413d39d9af45f25483eaf229cf883c771444fbb > prerequisite-patch-id: 2faef186ad1d816bb104d89638bc4cec6d863a46 > prerequisite-patch-id: b32cceb111f4f57798e4b1d58822281e7bbaf25e > prerequisite-patch-id: 08ff1c06921c5e253d911128be3a8ebb76137d3c > prerequisite-patch-id: 72aa7ba47bd81909871a9e1a2e9de14f2cf42174 > prerequisite-patch-id: 2ce10434bf0a7ab22e27ff177073e10b4b7d0d72 > prerequisite-patch-id: 68776813e47d3d411bef2f4229a589711887ca6c > prerequisite-patch-id: e286b2e30887f3f43a3458c7c9b3f8c8b513a91b > prerequisite-patch-id: dc07b9957107f8b453a87ad64fd8477ae26e370c From jakub@redhat.com Mon Nov 2 22:12:52 2026 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 2 Nov 2026 23:12:52 +0100 Subject: [PATCH] libstdc++: Export apply_result, is_applicable, and is_nothrow_applicable from std module In-Reply-To: References: <20261029171541.923427-1-tkaminsk@redhat.com> <20261029171541.923427-4-tkaminsk@redhat.com> Message-ID: On Mon, Nov 02, 2026 at 06:47:49PM +0100, Tomasz Kaminski wrote: > > > Here is an incremental fix for that, tested on x86_64-linux, > > > ok for trunk if this series is approved? > > > I will include that in the patch v2, if you do not mind. Ok, thanks. Jakub From jvdelisle2@gmail.com Mon Nov 2 22:37:13 2026 From: jvdelisle2@gmail.com (Jerry D) Date: Mon, 2 Nov 2026 14:37:13 -0800 Subject: [PATCH] libgfortran: [PR127893] Look up cached units without the unit rwlock In-Reply-To: <0a03d3a4-4d25-4e3b-a8ba-799700fb1e0c@orange.fr> References: <0a03d3a4-4d25-4e3b-a8ba-799700fb1e0c@orange.fr> Message-ID: On 11/2/26 12:33 PM, Mikael Morin wrote: > Le 02/11/2026 ? 01:34, Jerry D a ?crit?: >> Hi all, >> >> See the attached patch. The bugzilla comments show the testing results form >> this change. This brought back some memories from doing the initial unit >> caching. It makes sense to avoid using locks when not necessary. >> >> It has been tested on Mac M4 iOS and x86_64-linux. I also tested this in an >> ARM container running under qemu. >> >> Regression tested. >> >> OK for mainline? > > OK. > >> >> Regards, >> >> Jerry >> Thanks Mikael, Pushed commit r17-5826-gc91294dca7d29682c55c8b989c0197f84eb57e53 From ak@linux.intel.com Mon Nov 2 22:42:39 2026 From: ak@linux.intel.com (Andi Kleen) Date: Mon, 2 Nov 2026 14:42:39 -0800 Subject: [PATCH 11/11] [AutoFDO] Follow the PGO bootstrap stage flow In-Reply-To: <20261030073725.65113-13-kvivekananda@nvidia.com> References: <20261030073725.65113-1-kvivekananda@nvidia.com> <20261030073725.65113-13-kvivekananda@nvidia.com> Message-ID: On Fri, Oct 30, 2026 at 06:37:25PM +1100, Kugan Vivekanandarajah wrote: > Make autoprofiledbootstrap follow PGO's profile, train, and feedback > flow. Stageautoprofile builds a debuggable compiler, which builds > stageautotrain under perf. Stageautofeedback then rebuilds GCC with > the generated AutoFDO profiles. > > Build stageautotrain with LTO to train lto1. Match profiles by build > ID and enable partial training because the build does not exercise all > compiler paths. Thanks for working on this. What are the perf numbers of the compiler on large files vs instrumented PGO now? Did we recover? -Andi From ubizjak@gmail.com Mon Nov 2 22:42:43 2026 From: ubizjak@gmail.com (Uros Bizjak) Date: Mon, 2 Nov 2026 23:42:43 +0100 Subject: [pushed] i386: Add "memory" clobber to SGX and PCONFIG intrinsics [PR128283] Message-ID: The ENCLS, ENCLU, ENCLV and PCONFIG inline asm wrappers pass pointers to buffers in general registers, but do not declare that the instructions access memory. As a result, DSE can remove stores that initialize the input structures and FRE can fold loads from the output buffers. Add "memory" to the clobber list of all of them. Also add the missing "cc" clobber to __encls_edbgrd, since EDBGRD modifies the status flags, and remove the superfluous "\n\t" from the end of the asm templates. PR target/128283 gcc/ChangeLog: * config/i386/sgxintrin.h (__encls_bc, __encls_bcd, __encls_c) (__encls_edbgrd, __encls_generic, __enclu_bc, __enclu_bcd) (__enclu_eenter, __enclu_eexit, __enclu_generic, __enclv_bc) (__enclv_cd, __enclv_generic): Add "memory" clobber. Remove "\n\t" from asm template. (__encls_edbgrd): Also add "cc" clobber. * config/i386/pconfigintrin.h (__pconfig_b, __pconfig_generic): Add "memory" clobber. Remove "\n\t" from asm template. gcc/testsuite/ChangeLog: * gcc.target/i386/pr128283-1.c: New test. * gcc.target/i386/pr128283-2.c: Ditto. Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32}. Uros. -------------- next part -------------- diff --git a/gcc/config/i386/pconfigintrin.h b/gcc/config/i386/pconfigintrin.h index e3ff36e62b5..33ef551660d 100644 --- a/gcc/config/i386/pconfigintrin.h +++ b/gcc/config/i386/pconfigintrin.h @@ -35,16 +35,16 @@ #endif /* __PCONFIG__ */ #define __pconfig_b(leaf, b, retval) \ - __asm__ __volatile__ ("pconfig\n\t" \ + __asm__ __volatile__ ("pconfig" \ : "=a" (retval) \ : "a" (leaf), "b" (b) \ - : "cc") + : "cc", "memory") #define __pconfig_generic(leaf, b, c, d, retval) \ - __asm__ __volatile__ ("pconfig\n\t" \ + __asm__ __volatile__ ("pconfig" \ : "=a" (retval), "=b" (b), "=c" (c), "=d" (d) \ : "a" (leaf), "b" (b), "c" (c), "d" (d) \ - : "cc") + : "cc", "memory") extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) diff --git a/gcc/config/i386/sgxintrin.h b/gcc/config/i386/sgxintrin.h index 62dc461de72..8f25eeb51c3 100644 --- a/gcc/config/i386/sgxintrin.h +++ b/gcc/config/i386/sgxintrin.h @@ -31,81 +31,82 @@ #endif /* __SGX__ */ #define __encls_bc(leaf, b, c, retval) \ - __asm__ __volatile__ ("encls\n\t" \ + __asm__ __volatile__ ("encls" \ : "=a" (retval) \ : "a" (leaf), "b" (b), "c" (c) \ - : "cc") + : "cc", "memory") #define __encls_bcd(leaf, b, c, d, retval) \ - __asm__ __volatile__("encls\n\t" \ + __asm__ __volatile__("encls" \ : "=a" (retval) \ : "a" (leaf), "b" (b), "c" (c), "d" (d) \ - : "cc") + : "cc", "memory") #define __encls_c(leaf, c, retval) \ - __asm__ __volatile__("encls\n\t" \ + __asm__ __volatile__("encls" \ : "=a" (retval) \ : "a" (leaf), "c" (c) \ - : "cc") + : "cc", "memory") #define __encls_edbgrd(leaf, b, c, retval) \ - __asm__ __volatile__("encls\n\t" \ + __asm__ __volatile__("encls" \ : "=a" (retval), "=b" (b) \ - : "a" (leaf), "c" (c)) + : "a" (leaf), "c" (c) \ + : "cc", "memory") #define __encls_generic(leaf, b, c, d, retval) \ - __asm__ __volatile__("encls\n\t" \ + __asm__ __volatile__("encls" \ : "=a" (retval), "=b" (b), "=c" (c), "=d" (d)\ : "a" (leaf), "b" (b), "c" (c), "d" (d) \ - : "cc") + : "cc", "memory") #define __enclu_bc(leaf, b, c, retval) \ - __asm__ __volatile__("enclu\n\t" \ + __asm__ __volatile__("enclu" \ : "=a" (retval) \ : "a" (leaf), "b" (b), "c" (c) \ - : "cc") + : "cc", "memory") #define __enclu_bcd(leaf, b, c, d, retval) \ - __asm__ __volatile__("enclu\n\t" \ + __asm__ __volatile__("enclu" \ : "=a" (retval) \ : "a" (leaf), "b" (b), "c" (c), "d" (d) \ - : "cc") + : "cc", "memory") #define __enclu_eenter(leaf, b, c, retval) \ - __asm__ __volatile__("enclu\n\t" \ + __asm__ __volatile__("enclu" \ : "=a" (retval), "=c" (c) \ : "a" (leaf), "b" (b), "c" (c) \ - : "cc") + : "cc", "memory") #define __enclu_eexit(leaf, b, c, retval) \ - __asm__ __volatile__("enclu\n\t" \ + __asm__ __volatile__("enclu" \ : "=a" (retval), "=c" (c) \ : "a" (leaf), "b" (b) \ - : "cc") + : "cc", "memory") #define __enclu_generic(leaf, b, c, d, retval) \ - __asm__ __volatile__("enclu\n\t" \ + __asm__ __volatile__("enclu" \ : "=a" (retval), "=b" (b), "=c" (c), "=d" (d)\ : "a" (leaf), "b" (b), "c" (c), "d" (d) \ - : "cc") + : "cc", "memory") #define __enclv_bc(leaf, b, c, retval) \ - __asm__ __volatile__("enclv\n\t" \ + __asm__ __volatile__("enclv" \ : "=a" (retval) \ : "a" (leaf), "b" (b), "c" (c) \ - : "cc") + : "cc", "memory") #define __enclv_cd(leaf, c, d, retval) \ - __asm__ __volatile__("enclv\n\t" \ + __asm__ __volatile__("enclv" \ : "=a" (retval) \ : "a" (leaf), "c" (c), "d" (d) \ - : "cc") + : "cc", "memory") #define __enclv_generic(leaf, b, c, d, retval) \ - __asm__ __volatile__("enclv\n\t" \ + __asm__ __volatile__("enclv" \ : "=a" (retval), "=b" (b), "=c" (c), "=d" (d)\ : "a" (leaf), "b" (b), "c" (c), "d" (d) \ - : "cc") + : "cc", "memory") extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) diff --git a/gcc/testsuite/gcc.target/i386/pr128283-1.c b/gcc/testsuite/gcc.target/i386/pr128283-1.c new file mode 100644 index 00000000000..2f0a8b29a2c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr128283-1.c @@ -0,0 +1,18 @@ +/* PR target/128283 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -msgx -fdump-tree-optimized" } */ + +#include +#include + +uint64_t +derive_sgx_key (uint64_t *req_aligned) +{ + uint64_t key[2] __attribute__((aligned(16))) = {0, 0}; + size_t d[3] = {(size_t)req_aligned, (size_t)key, 0}; + + _enclu_u32(1 /* EGETKEY */, d); + return key[0]; +} + +/* { dg-final { scan-tree-dump " = key\\\[0\\\];" "optimized" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr128283-2.c b/gcc/testsuite/gcc.target/i386/pr128283-2.c new file mode 100644 index 00000000000..65f1b5c182b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr128283-2.c @@ -0,0 +1,24 @@ +/* PR target/128283 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mpconfig -fdump-tree-optimized" } */ + +#include +#include + +struct mktme_kp +{ + uint16_t keyid; + uint32_t ctrl; + uint8_t pad[186]; +} __attribute__((aligned(256))); + +unsigned int +program_mktme (uint16_t kid) +{ + struct mktme_kp kp = { .keyid = kid, .ctrl = 1 }; + size_t d[3] = { (size_t) &kp, 0, 0 }; + + return _pconfig_u32 (0 /* MKTME_KEY_PROGRAM */, d); +} + +/* { dg-final { scan-tree-dump "kp.ctrl = 1;" "optimized" } } */ From ubizjak@gmail.com Mon Nov 2 22:45:03 2026 From: ubizjak@gmail.com (Uros Bizjak) Date: Mon, 2 Nov 2026 23:45:03 +0100 Subject: [pushed] i386: Fix the leaf number of PCONFIG MKTME_KEY_PROGRAM Message-ID: The SDM selects the MKTME_KEY_PROGRAM leaf function by loading EAX with 0. The value 1 is the identifier of its target (TME-MK), not the leaf number, and PCONFIG raises #GP(0) for any leaf other than 0. _pconfig_u32 used 1 for __PCONFIG_KEY_PROGRAM, so the real leaf 0 never took the __pconfig_b path, which declares that only RAX is modified, while the invalid constant leaf 1 did. Use 0 and fix pconfig-1.c, which used the wrong value as well. gcc/ChangeLog: * config/i386/pconfigintrin.h (_pconfig_u32): Change the value of __PCONFIG_KEY_PROGRAM to 0x00. gcc/testsuite/ChangeLog: * gcc.target/i386/pconfig-1.c (PCONFIG_KEY_PROGRAM): Change to 0x00. Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32}. Uros. -------------- next part -------------- diff --git a/gcc/config/i386/pconfigintrin.h b/gcc/config/i386/pconfigintrin.h index 33ef551660d..37d4c572dfb 100644 --- a/gcc/config/i386/pconfigintrin.h +++ b/gcc/config/i386/pconfigintrin.h @@ -52,7 +52,7 @@ _pconfig_u32 (const unsigned int __L, size_t __D[]) { enum __pconfig_type { - __PCONFIG_KEY_PROGRAM = 0x01, + __PCONFIG_KEY_PROGRAM = 0x00, }; unsigned int __R = 0; diff --git a/gcc/testsuite/gcc.target/i386/pconfig-1.c b/gcc/testsuite/gcc.target/i386/pconfig-1.c index 40b4c0c1272..8ba4689da3a 100644 --- a/gcc/testsuite/gcc.target/i386/pconfig-1.c +++ b/gcc/testsuite/gcc.target/i386/pconfig-1.c @@ -6,7 +6,7 @@ extern unsigned int leaf; -#define PCONFIG_KEY_PROGRAM 0x01 +#define PCONFIG_KEY_PROGRAM 0x00 int test () { From ubizjak@gmail.com Mon Nov 2 22:46:37 2026 From: ubizjak@gmail.com (Uros Bizjak) Date: Mon, 2 Nov 2026 23:46:37 +0100 Subject: [pushed] i386: Emit ENDBR for cf_check functions that are only called directly Message-ID: The cf_check attribute documents that ENDBR is placed at function entry, but rest_of_insert_endbr_and_patchable_area skips ENDBR for functions where only_called_directly_p is true. Honor cf_check unconditionally; nocf_check still takes precedence. Assisted-by: Claude Sonnet 5.5 PR target/128360 gcc/ChangeLog: * config/i386/i386-features.cc (rest_of_insert_endbr_and_patchable_area): Emit ENDBR for functions with cf_check attribute even when they are only called directly. gcc/testsuite/ChangeLog: * gcc.target/i386/pr128360-1.c: New test. * gcc.target/i386/pr128360-2.c: Ditto. * gcc.target/i386/pr128360-3.c: Ditto. Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32}. Uros. -------------- next part -------------- diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc index 83768b3b2bc..430e2b910e5 100644 --- a/gcc/config/i386/i386-features.cc +++ b/gcc/config/i386/i386-features.cc @@ -3149,15 +3149,14 @@ rest_of_insert_endbr_and_patchable_area (bool need_endbr, EB. */ if (!lookup_attribute ("nocf_check", TYPE_ATTRIBUTES (TREE_TYPE (cfun->decl))) - && (!flag_manual_endbr - || lookup_attribute ("cf_check", - DECL_ATTRIBUTES (cfun->decl))) - && (!cgraph_node::get (cfun->decl)->only_called_directly_p () - || ix86_cmodel == CM_LARGE - || ix86_cmodel == CM_LARGE_PIC - || flag_force_indirect_call - || (TARGET_DLLIMPORT_DECL_ATTRIBUTES - && DECL_DLLIMPORT_P (cfun->decl)))) + && (lookup_attribute ("cf_check", DECL_ATTRIBUTES (cfun->decl)) + || (!flag_manual_endbr + && (!cgraph_node::get (cfun->decl)->only_called_directly_p () + || ix86_cmodel == CM_LARGE + || ix86_cmodel == CM_LARGE_PIC + || flag_force_indirect_call + || (TARGET_DLLIMPORT_DECL_ATTRIBUTES + && DECL_DLLIMPORT_P (cfun->decl)))))) { if (crtl->profile && flag_fentry) { diff --git a/gcc/testsuite/gcc.target/i386/pr128360-1.c b/gcc/testsuite/gcc.target/i386/pr128360-1.c new file mode 100644 index 00000000000..9cd51ac6a82 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr128360-1.c @@ -0,0 +1,25 @@ +/* PR target/128360 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcf-protection=branch -mmanual-endbr -march=x86-64" } */ + +static __attribute__((cf_check, noinline, noclone)) int +static_cf_target (int x) +{ + __asm__ volatile ("" : "+r" (x)); + return x + 1; +} + +extern __attribute__((cf_check, noinline, noclone)) int +extern_cf_target (int x) +{ + __asm__ volatile ("" : "+r" (x)); + return x + 2; +} + +int +caller (int x) +{ + return static_cf_target (x) + extern_cf_target (x); +} + +/* { dg-final { scan-assembler-times "endbr(32|64)" 2 } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr128360-2.c b/gcc/testsuite/gcc.target/i386/pr128360-2.c new file mode 100644 index 00000000000..1f78f098ab8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr128360-2.c @@ -0,0 +1,25 @@ +/* PR target/128360 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcf-protection=branch -march=x86-64" } */ + +static __attribute__((cf_check, noinline, noclone)) int +static_cf_target (int x) +{ + __asm__ volatile ("" : "+r" (x)); + return x + 1; +} + +extern __attribute__((cf_check, noinline, noclone)) int +extern_cf_target (int x) +{ + __asm__ volatile ("" : "+r" (x)); + return x + 2; +} + +int +caller (int x) +{ + return static_cf_target (x) + extern_cf_target (x); +} + +/* { dg-final { scan-assembler-times "endbr(32|64)" 3 } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr128360-3.c b/gcc/testsuite/gcc.target/i386/pr128360-3.c new file mode 100644 index 00000000000..97f52ce16bb --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr128360-3.c @@ -0,0 +1,25 @@ +/* PR target/128360 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcf-protection=branch -march=x86-64" } */ + +static __attribute__((noinline, noclone)) int +static_cf_target (int x) +{ + __asm__ volatile ("" : "+r" (x)); + return x + 1; +} + +extern __attribute__((noinline, noclone)) int +extern_cf_target (int x) +{ + __asm__ volatile ("" : "+r" (x)); + return x + 2; +} + +int +caller (int x) +{ + return static_cf_target (x) + extern_cf_target (x); +} + +/* { dg-final { scan-assembler-times "endbr(32|64)" 2 } } */ From Raghesh.Aloor@amd.com Mon Nov 2 23:58:36 2026 From: Raghesh.Aloor@amd.com (Raghesh Aloor) Date: Tue, 3 Nov 2026 05:28:36 +0530 Subject: [PATCH v5] Recognize predicated-index PHI during vectorization analysis In-Reply-To: References: <4863a9ace09dca08fc03090693176e6217bd27e6.1790337786.git.Raghesh.Aloor@amd.com> Message-ID: On Tue Nov 3, 2026 at 2:57 AM IST, Robin Dapp wrote: > Hi Raghesh, > > The checking code looks reasonable to me now. Just a bit of > bikeshedding :) > >> --- a/gcc/testsuite/lib/target-supports.exp >> +++ b/gcc/testsuite/lib/target-supports.exp >> @@ -10105,6 +10105,14 @@ proc check_effective_target_vect_masked_store { } { >> || [check_effective_target_riscv_v] }] >> } >> >> +# Return 1 if the target supports vector compress stores. >> + >> +proc check_effective_target_vect_compress { } { >> + return [expr { [check_avx_available] > > This should be avx512f or something I presume? I realize it's a bit > awkward to require avx512 now when the tests for this patch don't even > require it yet but as the goal is compress, we should match that at the > requirement level. > > For the tests you'll probably need something like > { dg-additional-options "-mavx512f" { ...? > Will add this. > Test -2 is not fully accurate in terms of what it checks but as we're > going to adjust it for the real codegen anyway, I don't think it matters > much. > > That said, I don't think we need a v6. Was your plan to commit > individually or wait until everything fits nicely together? All in one > would be nicer so we could see how everything works together (and in > case we notice something that needs changing here after all). Hi Robin, I am working on the next phase of pairing the predicated-index phi with the mask store. Planning to send the initial patch in couple of days. We shall wait to commit everything together. Regards, Raghesh From josmyers@redhat.com Tue Nov 3 00:11:14 2026 From: josmyers@redhat.com (Joseph Myers) Date: Tue, 3 Nov 2026 00:11:14 +0000 (UTC) Subject: [PATCH 0/2] Preserve semantic origins through C constant folding In-Reply-To: <20261101025158.271216-1-yjn@yjn-systems.com> References: <20261101025158.271216-1-yjn@yjn-systems.com> Message-ID: <2c8d000d-72b5-378e-b8fe-baa04fec0f8b@redhat.com> I don't see any testcases of what these attributes do at the C language level. For each context requiring an integer constant expression, I'd expect a test using constants that have the new attribute, showing what happens if you use an expression containing such a constant in such a context. (With a variant where in fact the expression's value doesn't depend on the value of the constant, e.g. if it's C - C or C * 0 for C being such a constant.) -- Joseph S. Myers josmyers@redhat.com From josmyers@redhat.com Tue Nov 3 00:15:02 2026 From: josmyers@redhat.com (Joseph Myers) Date: Tue, 3 Nov 2026 00:15:02 +0000 (UTC) Subject: [PATCH v10 0/4] implement defer statements as per ts 25755 In-Reply-To: <20261101201530.2684116-1-navi@vlhl.dev> References: <20261101201530.2684116-1-navi@vlhl.dev> Message-ID: On Sun, 1 Nov 2026, navi wrote: > fixed a rebase mistake, updated the document url on 4/4, and fixed up > typos on docs. On the same date this series was posted there was also another new revision, N4001. (I'm guessing that's very close to what will go for DIS ballot. I don't know what's changed since the previous draft.) -- Joseph S. Myers josmyers@redhat.com From richard.ball@arm.com Tue Nov 3 01:16:18 2026 From: richard.ball@arm.com (richard.ball@arm.com) Date: Tue, 3 Nov 2026 01:16:18 +0000 Subject: [PATCH v2] aarch64: Port NEON conversion intrinsics Message-ID: <20261103011618.3083518-1-richard.ball@arm.com> From: Richard Ball v2: Addresses comments to handle formatting and improve readability. This patch moves the NEON conversion intrinsics over to the new system and removes them from the arm-neon.h file. gcc/ChangeLog: * config/aarch64/aarch64-acle-builtins.h (TYPES_neon_cvt, TYPES_neon_cvt_fp16, TYPES_neon_cvt_rounding, TYPES_neon_cvtd_n, TYPES_neon_cvtd_scalar, TYPES_neon_cvtd_rounding_scalar, TYPES_neon_cvts_rounding_scalar, TYPES_neon_cvt_narrow, TYPES_neon_cvt_narrow_fp16, TYPES_neon_cvtx_narrow, TYPES_neon_cvtbf16_narrow, TYPES_neon_cvtbf16_widen, neon_cvt, neon_cvt_fp16, neon_cvt_rounding, neon_cvt_rounding_fp16, neon_cvtd_n, neon_cvts_n, neon_cvtd_scalar, neon_cvtd_rounding_scalar, neon_cvts_scalar, neon_cvts_rounding_scalar, neon_cvt_widen, neon_cvt_widen_fp16, neon_cvt_narrow, neon_cvt_narrow_fp16, neon_cvtx_narrow, neon_cvtbf16_narrow, neon_cvtbf16_widen): New Shapes. * config/aarch64/aarch64-neon-builtins-base.cc (enum class): Add neon_cvt_kind enum. (struct neon_cvt_mode_codes): Struct for Lookup table. (get_neon_cvt_icode): Function helper for Lookup table. (build_64bit_cvt): Function to handle 64 bit conversions. (class gimple_cvt): New intrinsic handler. (class gimple_cvt_scalar): Likewise. (class gimple_cvt_n): Likewise. (NEON_FUNCTION): New functions. * config/aarch64/aarch64-neon-builtins-base.def (vcvt, vcvtq, vcvta, vcvtaq, vcvtp, vcvtpq, vcvtm, vcvtmq, vcvtn, vcvtnq, vcvtd, vcvts, vcvtad, vcvtas, vcvtmd, vcvtms, vcvtpd, vcvtps, vcvtnd, vcvtns, vcvt_n, vcvtq_n, vcvtd_n, vcvts_n, vcvt_high, vcvtx, vcvtx_high, vcvtxd, vcvtq_high, vcvtq_low): New functions. * config/aarch64/aarch64-simd.md (3): Replaced. (@fcvtzs3): Add support for @. (3): Replaced. (@fcvtzu3): Add support for @. (@scvtf3): Likewise. (@ucvtf3): Likewise. * config/aarch64/aarch64.md (3): Replaced. (@fcvtzs3): Add support for @. (@fcvtzu3): Likewise. (3): Replaced. (@scvtf3): Add support for @. (@ucvtf3): Likewise. * config/aarch64/arm_neon.h (vcvtx_f32_f64, vcvtx_high_f32_f64, vcvtxd_f32_f64, vcltd_f64, vcltz_f32, vcltz_f64, vcltz_s8, vcltz_s16, vcltz_s32, vcltz_s64, vcltzq_f32, vcltzq_f64, vcltzq_s8, vcltzq_s16, vcltzq_s32, vcltzq_s64, vcltzs_f32, vcltzd_s64, vcltzd_f64, vcvt_f16_f32, vcvt_high_f16_f32, vcvt_f32_f64, vcvt_high_f32_f64, vcvt_f32_f16, vcvt_f64_f32, vcvt_high_f32_f16, vcvt_high_f64_f32, vcvtd_n_f64_s64, vcvtd_n_f64_u64, vcvts_n_f32_s32, vcvts_n_f32_u32, vcvt_n_f32_s32, vcvt_n_f32_u32, vcvt_n_f64_s64, vcvt_n_f64_u64, vcvtq_n_f32_s32, vcvtq_n_f32_u32, vcvtq_n_f64_s64, vcvtq_n_f64_u64, vcvtd_n_s64_f64, vcvtd_n_u64_f64, vcvts_n_s32_f32, vcvts_n_u32_f32, vcvt_n_s32_f32, vcvt_n_u32_f32, vcvt_n_s64_f64, vcvt_n_u64_f64, vcvtq_n_s32_f32, vcvtq_n_u32_f32, vcvtq_n_s64_f64, vcvtq_n_u64_f64, vcvtd_f64_s64, vcvtd_f64_u64, vcvts_f32_s32, vcvts_f32_u32, vcvt_f32_s32, vcvt_f32_u32, vcvt_f64_s64, vcvt_f64_u64, vcvtq_f32_s32, vcvtq_f32_u32, vcvtq_f64_s64, vcvtq_f64_u64, vcvtd_s64_f64, vcvtd_s32_f64, vcvtd_u64_f64, vcvtd_u32_f64, vcvts_s32_f32, vcvts_s64_f32, vcvts_u32_f32, vcvts_u64_f32, vcvt_s32_f32, vcvt_u32_f32, vcvtq_s32_f32, vcvtq_u32_f32, vcvt_s64_f64, vcvt_u64_f64, vcvtq_s64_f64, vcvtq_u64_f64, vcvtad_s64_f64, vcvtad_s32_f64, vcvtad_u64_f64, vcvtad_u32_f64, vcvtas_s32_f32, vcvtas_s64_f32, vcvtas_u32_f32, vcvtas_u64_f32, vcvta_s32_f32, vcvta_u32_f32, vcvtaq_s32_f32, vcvtaq_u32_f32, vcvta_s64_f64, vcvta_u64_f64, vcvtaq_s64_f64, vcvtaq_u64_f64, vcvtmd_s64_f64, vcvtmd_s32_f64, vcvtmd_u64_f64, vcvtmd_u32_f64, vcvtms_s32_f32, vcvtms_s64_f32, vcvtms_u32_f32, vcvtms_u64_f32, vcvtm_s32_f32, vcvtm_u32_f32, vcvtmq_s32_f32, vcvtmq_u32_f32, vcvtm_s64_f64, vcvtm_u64_f64, vcvtmq_s64_f64, vcvtmq_u64_f64, vcvtnd_s64_f64, vcvtnd_s32_f64, vcvtnd_u64_f64, vcvtnd_u32_f64, vcvtns_s32_f32, vcvtns_s64_f32, vcvtns_u32_f32, vcvtns_u64_f32, vcvtn_s32_f32, vcvtn_u32_f32, vcvtnq_s32_f32, vcvtnq_u32_f32, vcvtn_s64_f64, vcvtn_u64_f64, vcvtnq_s64_f64, vcvtnq_u64_f64, vcvtpd_s64_f64, vcvtpd_s32_f64, vcvtpd_u64_f64, vcvtpd_u32_f64, vcvtps_s32_f32, vcvtps_s64_f32, vcvtps_u32_f32, vcvtps_u64_f32, vcvtp_s32_f32, vcvtp_u32_f32, vcvtpq_s32_f32, vcvtpq_u32_f32, vcvtp_s64_f64, vcvtp_u64_f64, vcvtpq_s64_f64, vcvtpq_u64_f64, vcvt_f16_s16, vcvtq_f16_s16, vcvt_f16_u16, vcvtq_f16_u16, vcvt_s16_f16, vcvtq_s16_f16, vcvt_u16_f16, vcvtq_u16_f16, vcvta_s16_f16, vcvtaq_s16_f16, vcvta_u16_f16, vcvtaq_u16_f16, vcvtm_s16_f16, vcvtmq_s16_f16, vcvtm_u16_f16, vcvtmq_u16_f16, vcvtn_s16_f16, vcvtnq_s16_f16, vcvtn_u16_f16, vcvtnq_u16_f16, vcvtp_s16_f16, vcvtpq_s16_f16, vcvtp_u16_f16, vcvtpq_u16_f16, vcvt_n_f16_s16, vcvtq_n_f16_s16, vcvt_n_f16_u16, vcvtq_n_f16_u16, vcvt_n_s16_f16, vcvtq_n_s16_f16, vcvt_n_u16_f16, vcvtq_n_u16_f16, vcvt_f32_bf16, vcvtq_low_f32_bf16, vcvtq_high_f32_bf16, vcvt_bf16_f32, vcvtq_low_bf16_f32, vcvtq_high_bf16_f32): Removed. * optabs.def (OPTAB_CL): Add new optabs. gcc/testsuite/ChangeLog: * gcc.target/aarch64/advsimd-intrinsics/bfcvtn-nobf16.c: Changed Error message. * gcc.target/aarch64/float_truncate_zero.c: Add +fp16. * gcc.target/aarch64/neon/arm_neon_test.h: Add UNARY_N. * gcc.target/aarch64/neon/vcvt.c: New test. * gcc.target/aarch64/neon/vcvt_highlo.c: New test. * gcc.target/aarch64/neon/vcvt_n.c: New test. * gcc.target/aarch64/neon/vcvta.c: New test. * gcc.target/aarch64/neon/vcvtd.c: New test. * gcc.target/aarch64/neon/vcvtds_n.c: New test. * gcc.target/aarch64/neon/vcvtm.c: New test. * gcc.target/aarch64/neon/vcvtn.c: New test. * gcc.target/aarch64/neon/vcvtp.c: New test. * gcc.target/aarch64/neon/vcvts.c: New test. --- gcc/config/aarch64/aarch64-acle-builtins.h | 105 ++ .../aarch64/aarch64-neon-builtins-base.cc | 601 ++++++++ .../aarch64/aarch64-neon-builtins-base.def | 65 + gcc/config/aarch64/aarch64-simd.md | 34 +- gcc/config/aarch64/aarch64.md | 40 +- gcc/config/aarch64/arm_neon.h | 1281 +---------------- .../advsimd-intrinsics/bfcvtn-nobf16.c | 3 +- .../gcc.target/aarch64/float_truncate_zero.c | 2 +- .../gcc.target/aarch64/neon/arm_neon_test.h | 6 + gcc/testsuite/gcc.target/aarch64/neon/vcvt.c | 172 +++ .../gcc.target/aarch64/neon/vcvt_highlo.c | 123 ++ .../gcc.target/aarch64/neon/vcvt_n.c | 172 +++ gcc/testsuite/gcc.target/aarch64/neon/vcvta.c | 90 ++ gcc/testsuite/gcc.target/aarch64/neon/vcvtd.c | 158 ++ .../gcc.target/aarch64/neon/vcvtds_n.c | 59 + gcc/testsuite/gcc.target/aarch64/neon/vcvtm.c | 90 ++ gcc/testsuite/gcc.target/aarch64/neon/vcvtn.c | 90 ++ gcc/testsuite/gcc.target/aarch64/neon/vcvtp.c | 90 ++ gcc/testsuite/gcc.target/aarch64/neon/vcvts.c | 158 ++ 19 files changed, 2092 insertions(+), 1247 deletions(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vcvt.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vcvt_highlo.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vcvt_n.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vcvta.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vcvtd.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vcvtds_n.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vcvtm.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vcvtn.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vcvtp.c create mode 100644 gcc/testsuite/gcc.target/aarch64/neon/vcvts.c diff --git a/gcc/config/aarch64/aarch64-acle-builtins.h b/gcc/config/aarch64/aarch64-acle-builtins.h index 1572594872b9..12b9b45e6d2f 100644 --- a/gcc/config/aarch64/aarch64-acle-builtins.h +++ b/gcc/config/aarch64/aarch64-acle-builtins.h @@ -2056,6 +2056,94 @@ function_expander::result_mode () const TYPES_neon_reinterpretq1 (D, p64), \ TYPES_neon_reinterpretq1 (D, p128) +#define TYPES_neon_cvt(S, D, T) \ + D (s32, f32), \ + D (u32, f32), \ + D (f32, s32), \ + D (f32, u32), \ + D (s64, f64), \ + D (u64, f64), \ + D (f64, s64), \ + D (f64, u64) + +#define TYPES_neon_cvt_fp16(S, D, T) \ + D (f16, s16), \ + D (f16, u16), \ + D (s16, f16), \ + D (u16, f16) + +#define TYPES_neon_cvt_rounding(S, D, T) \ + D (s32, f32), \ + D (u32, f32), \ + D (s64, f64), \ + D (u64, f64) + + #define TYPES_neon_cvt_rounding_fp16(S, D, T) \ + D (s16, f16), \ + D (u16, f16) + +#define TYPES_neon_cvtd_n(S, D, T) \ + D (f64, s64), \ + D (f64, u64), \ + D (s64, f64), \ + D (u64, f64) + + #define TYPES_neon_cvts_n(S, D, T) \ + D (f32, s32), \ + D (f32, u32), \ + D (s32, f32), \ + D (u32, f32) + +#define TYPES_neon_cvtd_scalar(S, D, T) \ + D (s64, f64), \ + D (u64, f64), \ + D (f64, s64), \ + D (f64, u64), \ + D (s32, f64), \ + D (u32, f64) + +#define TYPES_neon_cvtd_rounding_scalar(S, D, T) \ + D (s64, f64), \ + D (u64, f64), \ + D (s32, f64), \ + D (u32, f64) + + #define TYPES_neon_cvts_scalar(S, D, T) \ + D (s32, f32), \ + D (u32, f32), \ + D (f32, s32), \ + D (f32, u32), \ + D (s64, f32), \ + D (u64, f32) + +#define TYPES_neon_cvts_rounding_scalar(S, D, T) \ + D (s32, f32), \ + D (u32, f32), \ + D (s64, f32), \ + D (u64, f32) + + #define TYPES_neon_cvt_widen(S, D, T) \ + D (f64, f32) + + #define TYPES_neon_cvt_widen_fp16(S, D, T) \ + D (f32, f16) + +#define TYPES_neon_cvt_narrow(S, D, T) \ + D (f32, f64) + +#define TYPES_neon_cvt_narrow_fp16(S, D, T) \ + D (f16, f32) + +#define TYPES_neon_cvtx_narrow(S, D, T) \ + D (f32, f64) + +#define TYPES_neon_cvtbf16_narrow(S, D, T) \ + D (bf16, f32) + +#define TYPES_neon_cvtbf16_widen(S, D, T) \ + D (f32, bf16) + + /* Describe a tuple of type suffixes in which only the first is used. */ #define DEF_VECTOR_TYPE(X) \ { TYPE_SUFFIX_ ## X, NUM_TYPE_SUFFIXES, NUM_TYPE_SUFFIXES } @@ -2228,6 +2316,23 @@ DEF_SVE_TYPES_ARRAY (neon_rev32); DEF_SVE_TYPES_ARRAY (neon_rev64); DEF_SVE_TYPES_ARRAY (neon_reinterpret); DEF_SVE_TYPES_ARRAY (neon_reinterpretq); +DEF_SVE_TYPES_ARRAY (neon_cvt); +DEF_SVE_TYPES_ARRAY (neon_cvt_fp16); +DEF_SVE_TYPES_ARRAY (neon_cvt_rounding); +DEF_SVE_TYPES_ARRAY (neon_cvt_rounding_fp16); +DEF_SVE_TYPES_ARRAY (neon_cvtd_n); +DEF_SVE_TYPES_ARRAY (neon_cvts_n); +DEF_SVE_TYPES_ARRAY (neon_cvtd_scalar); +DEF_SVE_TYPES_ARRAY (neon_cvtd_rounding_scalar); +DEF_SVE_TYPES_ARRAY (neon_cvts_scalar); +DEF_SVE_TYPES_ARRAY (neon_cvts_rounding_scalar); +DEF_SVE_TYPES_ARRAY (neon_cvt_widen); +DEF_SVE_TYPES_ARRAY (neon_cvt_widen_fp16); +DEF_SVE_TYPES_ARRAY (neon_cvt_narrow); +DEF_SVE_TYPES_ARRAY (neon_cvt_narrow_fp16); +DEF_SVE_TYPES_ARRAY (neon_cvtx_narrow); +DEF_SVE_TYPES_ARRAY (neon_cvtbf16_narrow); +DEF_SVE_TYPES_ARRAY (neon_cvtbf16_widen); static const group_suffix_index groups_none[] = { GROUP_none, NUM_GROUP_SUFFIXES diff --git a/gcc/config/aarch64/aarch64-neon-builtins-base.cc b/gcc/config/aarch64/aarch64-neon-builtins-base.cc index b00aed7c7d77..c6fd3078f5cb 100644 --- a/gcc/config/aarch64/aarch64-neon-builtins-base.cc +++ b/gcc/config/aarch64/aarch64-neon-builtins-base.cc @@ -623,6 +623,588 @@ public: } }; +enum class neon_cvt_kind +{ + cvt, + cvt_truncextend, + cvta, + cvtm, + cvtp, + cvtn, + cvtn_signed, + cvt_scalar, + cvt_signed_scalar, + cvta_scalar, + cvtm_scalar, + cvtp_scalar, + cvtn_scalar, + cvtn_signed_scalar, + cvt_n, + cvt_high, + cvtx, + cvtx_high, + cvtx_scalar, + cvtq_high, + cvtq_low +}; + +struct neon_cvt_mode_codes +{ + neon_cvt_kind kind; + machine_mode from_mode; + machine_mode to_mode; + insn_code icode; +}; + +static const neon_cvt_mode_codes neon_cvt_mode_table[] = +{ + { + neon_cvt_kind::cvt_high, E_V8HFmode, E_VOIDmode, + CODE_FOR_vec_unpacks_hi_v8hf + }, + { + neon_cvt_kind::cvt_high, E_V4SFmode, E_VOIDmode, + CODE_FOR_vec_unpacks_hi_v4sf + }, + { + neon_cvt_kind::cvt_high, E_V4HFmode, E_VOIDmode, + CODE_FOR_aarch64_float_truncate_hi_v8hf + }, + { + neon_cvt_kind::cvt_high, E_V2SFmode, E_VOIDmode, + CODE_FOR_aarch64_float_truncate_hi_v4sf + }, + { + neon_cvt_kind::cvtq_high, E_VOIDmode, E_V8BFmode, + CODE_FOR_aarch64_bfcvtn2v8bf + }, + { + neon_cvt_kind::cvtq_high, E_VOIDmode, E_V4SFmode, + CODE_FOR_aarch64_vbfcvt_highv8bf + }, + { + neon_cvt_kind::cvtq_low, E_V8BFmode, E_VOIDmode, + CODE_FOR_aarch64_vbfcvtv8bf + }, + { + neon_cvt_kind::cvtq_low, E_V4SFmode, E_VOIDmode, + CODE_FOR_aarch64_bfcvtn_qv8bf + }, + { + neon_cvt_kind::cvtx, E_VOIDmode, E_VOIDmode, + CODE_FOR_aarch64_float_trunc_rodd_lo_v2sf + }, + { + neon_cvt_kind::cvtx_high, E_VOIDmode, E_VOIDmode, + CODE_FOR_aarch64_float_trunc_rodd_hi_v4sf + }, + { + neon_cvt_kind::cvtx_scalar, E_VOIDmode, E_VOIDmode, + CODE_FOR_aarch64_float_trunc_rodd_df + }, + { + neon_cvt_kind::cvt_truncextend, E_V4HFmode, E_VOIDmode, + CODE_FOR_extendv4hfv4sf2 + }, + { + neon_cvt_kind::cvt_truncextend, E_V2SFmode, E_VOIDmode, + CODE_FOR_extendv2sfv2df2 + }, + { + neon_cvt_kind::cvt_truncextend, E_V4SFmode, E_V4BFmode, + CODE_FOR_aarch64_bfcvtnv4bf + }, + { + neon_cvt_kind::cvt_truncextend, E_V4SFmode, E_V4HFmode, + CODE_FOR_truncv4sfv4hf2 + }, + { + neon_cvt_kind::cvt_truncextend, E_V2DFmode, E_VOIDmode, + CODE_FOR_truncv2dfv2sf2 + }, + { + neon_cvt_kind::cvt_truncextend, E_V4BFmode, E_VOIDmode, + CODE_FOR_aarch64_vbfcvtv4bf + }, + /* CVTA - round to nearest, ties away (unsigned). */ + { neon_cvt_kind::cvta, E_V2SFmode, E_V2SImode, CODE_FOR_lrounduv2sfv2si2}, + { neon_cvt_kind::cvta, E_V4SFmode, E_V4SImode, CODE_FOR_lrounduv4sfv4si2}, + { neon_cvt_kind::cvta, E_V2DFmode, E_V2DImode, CODE_FOR_lrounduv2dfv2di2}, + { neon_cvt_kind::cvta, E_V4HFmode, E_V4HImode, CODE_FOR_lrounduv4hfv4hi2}, + { neon_cvt_kind::cvta, E_V8HFmode, E_V8HImode, CODE_FOR_lrounduv8hfv8hi2}, + + /* CVTM - round towards minus infinity (unsigned). */ + { neon_cvt_kind::cvtm, E_V2SFmode, E_V2SImode, CODE_FOR_lflooruv2sfv2si2}, + { neon_cvt_kind::cvtm, E_V4SFmode, E_V4SImode, CODE_FOR_lflooruv4sfv4si2}, + { neon_cvt_kind::cvtm, E_V2DFmode, E_V2DImode, CODE_FOR_lflooruv2dfv2di2}, + { neon_cvt_kind::cvtm, E_V4HFmode, E_V4HImode, CODE_FOR_lflooruv4hfv4hi2}, + { neon_cvt_kind::cvtm, E_V8HFmode, E_V8HImode, CODE_FOR_lflooruv8hfv8hi2}, + + /* CVTP - round towards plus infinity (unsigned). */ + { neon_cvt_kind::cvtp, E_V2SFmode, E_V2SImode, CODE_FOR_lceiluv2sfv2si2}, + { neon_cvt_kind::cvtp, E_V4SFmode, E_V4SImode, CODE_FOR_lceiluv4sfv4si2}, + { neon_cvt_kind::cvtp, E_V2DFmode, E_V2DImode, CODE_FOR_lceiluv2dfv2di2}, + { neon_cvt_kind::cvtp, E_V4HFmode, E_V4HImode, CODE_FOR_lceiluv4hfv4hi2}, + { neon_cvt_kind::cvtp, E_V8HFmode, E_V8HImode, CODE_FOR_lceiluv8hfv8hi2}, + + /* CVTN - round to nearest, ties to even (signed). */ + { neon_cvt_kind::cvtn_signed, E_V2SFmode, E_V2SImode, + CODE_FOR_lfrintnv2sfv2si2}, + { neon_cvt_kind::cvtn_signed, E_V4SFmode, E_V4SImode, + CODE_FOR_lfrintnv4sfv4si2}, + { neon_cvt_kind::cvtn_signed, E_V2DFmode, E_V2DImode, + CODE_FOR_lfrintnv2dfv2di2}, + { neon_cvt_kind::cvtn_signed, E_V4HFmode, E_V4HImode, + CODE_FOR_lfrintnv4hfv4hi2}, + { neon_cvt_kind::cvtn_signed, E_V8HFmode, E_V8HImode, + CODE_FOR_lfrintnv8hfv8hi2}, + + /* CVTN - round to nearest, ties to even (unsigned). */ + { neon_cvt_kind::cvtn, E_V2SFmode, E_V2SImode, CODE_FOR_lfrintnuv2sfv2si2}, + { neon_cvt_kind::cvtn, E_V4SFmode, E_V4SImode, CODE_FOR_lfrintnuv4sfv4si2}, + { neon_cvt_kind::cvtn, E_V2DFmode, E_V2DImode, CODE_FOR_lfrintnuv2dfv2di2}, + { neon_cvt_kind::cvtn, E_V4HFmode, E_V4HImode, CODE_FOR_lfrintnuv4hfv4hi2}, + { neon_cvt_kind::cvtn, E_V8HFmode, E_V8HImode, CODE_FOR_lfrintnuv8hfv8hi2}, + + /* CVTA scalar - round to nearest, ties away (unsigned). */ + { neon_cvt_kind::cvta_scalar, E_DFmode, E_DImode, CODE_FOR_lroundudfdi2}, + { neon_cvt_kind::cvta_scalar, E_DFmode, E_SImode, CODE_FOR_lroundudfsi2}, + { neon_cvt_kind::cvta_scalar, E_SFmode, E_DImode, CODE_FOR_lroundusfdi2}, + { neon_cvt_kind::cvta_scalar, E_SFmode, E_SImode, CODE_FOR_lroundusfsi2}, + + /* CVTM scalar - round towards minus infinity (unsigned). */ + { neon_cvt_kind::cvtm_scalar, E_DFmode, E_DImode, CODE_FOR_lfloorudfdi2}, + { neon_cvt_kind::cvtm_scalar, E_DFmode, E_SImode, CODE_FOR_lfloorudfsi2}, + { neon_cvt_kind::cvtm_scalar, E_SFmode, E_DImode, CODE_FOR_lfloorusfdi2}, + { neon_cvt_kind::cvtm_scalar, E_SFmode, E_SImode, CODE_FOR_lfloorusfsi2}, + + /* CVTP scalar - round towards plus infinity (unsigned). */ + { neon_cvt_kind::cvtp_scalar, E_DFmode, E_DImode, CODE_FOR_lceiludfdi2}, + { neon_cvt_kind::cvtp_scalar, E_DFmode, E_SImode, CODE_FOR_lceiludfsi2}, + { neon_cvt_kind::cvtp_scalar, E_SFmode, E_DImode, CODE_FOR_lceilusfdi2}, + { neon_cvt_kind::cvtp_scalar, E_SFmode, E_SImode, CODE_FOR_lceilusfsi2}, + + /* CVTN scalar - round to nearest, ties to even (signed). */ + { neon_cvt_kind::cvtn_signed_scalar, E_DFmode, E_DImode, + CODE_FOR_lfrintndfdi2}, + { neon_cvt_kind::cvtn_signed_scalar, E_DFmode, E_SImode, + CODE_FOR_lfrintndfsi2}, + { neon_cvt_kind::cvtn_signed_scalar, E_SFmode, E_DImode, + CODE_FOR_lfrintnsfdi2}, + { neon_cvt_kind::cvtn_signed_scalar, E_SFmode, E_SImode, + CODE_FOR_lfrintnsfsi2}, + + /* CVTN scalar - round to nearest, ties to even (unsigned). */ + { neon_cvt_kind::cvtn_scalar, E_DFmode, E_DImode, CODE_FOR_lfrintnudfdi2}, + { neon_cvt_kind::cvtn_scalar, E_DFmode, E_SImode, CODE_FOR_lfrintnudfsi2}, + { neon_cvt_kind::cvtn_scalar, E_SFmode, E_DImode, CODE_FOR_lfrintnusfdi2}, + { neon_cvt_kind::cvtn_scalar, E_SFmode, E_SImode, CODE_FOR_lfrintnusfsi2}, + + /* CVT scalar - floating-point to integer (signed). */ + { neon_cvt_kind::cvt_signed_scalar, E_SFmode, E_SImode, + CODE_FOR_fix_truncsfsi2 }, + { neon_cvt_kind::cvt_signed_scalar, E_SFmode, E_DImode, + CODE_FOR_fix_truncsfdi2 }, + { neon_cvt_kind::cvt_signed_scalar, E_DFmode, E_SImode, + CODE_FOR_fix_truncdfsi2 }, + { neon_cvt_kind::cvt_signed_scalar, E_DFmode, E_DImode, + CODE_FOR_fix_truncdfdi2 }, + + /* CVT scalar - floating-point to integer (unsigned). */ + { neon_cvt_kind::cvt_scalar, E_SFmode, E_SImode, + CODE_FOR_fixuns_truncsfsi2 }, + { neon_cvt_kind::cvt_scalar, E_SFmode, E_DImode, + CODE_FOR_fixuns_truncsfdi2 }, + { neon_cvt_kind::cvt_scalar, E_DFmode, E_SImode, + CODE_FOR_fixuns_truncdfsi2 }, + { neon_cvt_kind::cvt_scalar, E_DFmode, E_DImode, + CODE_FOR_fixuns_truncdfdi2 }, + + /* CVT scalar - integer to floating-point (signed). */ + { neon_cvt_kind::cvt_signed_scalar, E_SImode, E_SFmode, + CODE_FOR_floatsisf2 }, + { neon_cvt_kind::cvt_signed_scalar, E_DImode, E_SFmode, + CODE_FOR_floatdisf2 }, + { neon_cvt_kind::cvt_signed_scalar, E_SImode, E_DFmode, + CODE_FOR_floatsidf2 }, + { neon_cvt_kind::cvt_signed_scalar, E_DImode, E_DFmode, + CODE_FOR_floatdidf2 }, + + /* CVT scalar - integer to floating-point (unsigned). */ + { neon_cvt_kind::cvt_scalar, E_SImode, E_SFmode, CODE_FOR_floatunssisf2 }, + { neon_cvt_kind::cvt_scalar, E_DImode, E_SFmode, CODE_FOR_floatunsdisf2 }, + { neon_cvt_kind::cvt_scalar, E_SImode, E_DFmode, CODE_FOR_floatunssidf2 }, + { neon_cvt_kind::cvt_scalar, E_DImode, E_DFmode, CODE_FOR_floatunsdidf2 }, +}; + +static insn_code +get_neon_cvt_icode (neon_cvt_kind kind, + machine_mode from_mode, + machine_mode to_mode) +{ + for (const auto &entry : neon_cvt_mode_table) + if (entry.kind == kind + && (entry.from_mode == E_VOIDmode + || entry.from_mode == from_mode) + && (entry.to_mode == E_VOIDmode + || entry.to_mode == to_mode)) + return entry.icode; + + gcc_unreachable (); +} + +rtx +build_64bit_cvt (auto_vec args, bool unsigned_p, + bool float_p, + neon_cvt_kind m_kind) +{ + rtx op = force_reg (V1DFmode, args[0]); + rtx scalar_in = gen_lowpart (DFmode, op); + rtx scalar_out = gen_reg_rtx (DImode); + machine_mode scalar_mode = DImode; + machine_mode target_mode = V1DImode; + + switch (m_kind) + { + case neon_cvt_kind::cvta: + if (unsigned_p) + emit_insn (gen_lroundudfdi2 (scalar_out, scalar_in)); + else + emit_insn (gen_lrounddfdi2 (scalar_out, scalar_in)); + break; + + case neon_cvt_kind::cvtm: + if (unsigned_p) + emit_insn (gen_lfloorudfdi2 (scalar_out, scalar_in)); + else + emit_insn (gen_lfloordfdi2 (scalar_out, scalar_in)); + break; + + case neon_cvt_kind::cvtp: + if (unsigned_p) + emit_insn (gen_lceiludfdi2 (scalar_out, scalar_in)); + else + emit_insn (gen_lceildfdi2 (scalar_out, scalar_in)); + break; + + case neon_cvt_kind::cvtn: + if (unsigned_p) + emit_insn (gen_lfrintnudfdi2 (scalar_out, scalar_in)); + else + emit_insn (gen_lfrintndfdi2 (scalar_out, scalar_in)); + break; + + case neon_cvt_kind::cvt_n: + if (float_p) + { + op = force_reg (V1DImode, args[0]); + scalar_in = gen_lowpart (DImode, op); + scalar_out = gen_reg_rtx (DFmode); + target_mode = V1DFmode; + scalar_mode = DFmode; + if (unsigned_p) + emit_insn (gen_ucvtfdi3 (scalar_out, scalar_in, args[1])); + else + emit_insn (gen_scvtfdi3 (scalar_out, scalar_in, args[1])); + } + else + { + if (unsigned_p) + emit_insn (gen_fcvtzudf3 (scalar_out, scalar_in, args[1])); + else + emit_insn (gen_fcvtzsdf3 (scalar_out, scalar_in, args[1])); + } + break; + + default: + gcc_unreachable (); + } + /* Put the scalar result back into a V1DI. */ + + rtx target = gen_reg_rtx (target_mode); + + emit_move_insn (target, + simplify_gen_subreg (target_mode, + scalar_out, + scalar_mode, 0)); + + return target; +} + + +class gimple_cvt : public gimple_function_base +{ +public: + constexpr gimple_cvt (neon_cvt_kind kind) + : m_kind (kind) + {} + + gimple *fold (gimple_folder &f) const override + { + tree arg = gimple_call_arg (f.call, 0); + tree arg_type = TREE_TYPE (arg); + tree ret_type = TREE_TYPE (f.lhs); + const auto &to = f.type_suffix (0); + const auto &from = f.type_suffix (1); + if (!VECTOR_TYPE_P (arg_type) || !VECTOR_TYPE_P (ret_type)) + return nullptr; + if (known_eq (TYPE_VECTOR_SUBPARTS (arg_type), 1U) + && known_eq (TYPE_VECTOR_SUBPARTS (ret_type), 1U) + && m_kind == neon_cvt_kind::cvt) + { + auto ret_elem_type = TREE_TYPE (ret_type); + + auto scalar_arg + = f.force_val (build_lane_get (arg, size_zero_node)); + tree_code code; + + if (to.integer_p && from.float_p) + code = FIX_TRUNC_EXPR; + else if (to.float_p && from.integer_p) + code = FLOAT_EXPR; + else + gcc_unreachable (); + + tree scalar_result + = f.force_val (fold_build1 (code, ret_elem_type, scalar_arg)); + + return gimple_build_assign + (f.lhs, build_vec_dup (ret_type, scalar_result)); + } + return nullptr; + } + + rtx expand (function_expander &e) const override + { + machine_mode to_mode = e.result_mode (); + machine_mode from_mode = GET_MODE (e.args[0]); + neon_cvt_kind kind = m_kind; + insn_code icode; + + const auto &to = e.type_suffix (0); + const auto &from = e.type_suffix (1); + + convert_optab optab; + + if (GET_MODE (e.args[0]) == V1DFmode + && kind != neon_cvt_kind::cvt) + { + return build_64bit_cvt (e.args, to.unsigned_p, to.float_p, kind); + } + + if (to.element_bits != from.element_bits) + { + if (kind == neon_cvt_kind::cvt) + kind = neon_cvt_kind::cvt_truncextend; + icode = get_neon_cvt_icode (kind, from_mode, to_mode); + gcc_assert (icode != CODE_FOR_nothing); + return e.use_exact_insn (icode); + } + + if (to.float_p) + { + gcc_assert (kind == neon_cvt_kind::cvt); + optab = from.unsigned_p ? ufloat_optab : sfloat_optab; + } + else + { + switch (kind) + { + case neon_cvt_kind::cvt: + optab = to.unsigned_p ? ufix_optab : sfix_optab; + break; + + case neon_cvt_kind::cvta: + if (to.unsigned_p) + { + icode = get_neon_cvt_icode (kind, from_mode, to_mode); + gcc_assert (icode != CODE_FOR_nothing); + return e.use_exact_insn (icode); + } + else + optab = lround_optab; + break; + + case neon_cvt_kind::cvtm: + if (to.unsigned_p) + { + icode = get_neon_cvt_icode (kind, from_mode, to_mode); + gcc_assert (icode != CODE_FOR_nothing); + return e.use_exact_insn (icode); + } + else + optab = lfloor_optab; + break; + + case neon_cvt_kind::cvtp: + if (to.unsigned_p) + { + icode = get_neon_cvt_icode (kind, from_mode, to_mode); + gcc_assert (icode != CODE_FOR_nothing); + return e.use_exact_insn (icode); + } + else + optab = lceil_optab; + break; + + case neon_cvt_kind::cvtn: + if (!to.unsigned_p) + { + kind = neon_cvt_kind::cvtn_signed; + } + icode = get_neon_cvt_icode (kind, from_mode, to_mode); + gcc_assert (icode != CODE_FOR_nothing); + return e.use_exact_insn (icode); + + default: + gcc_unreachable (); + } + } + + icode = convert_optab_handler (optab, to_mode, from_mode); + gcc_assert (icode != CODE_FOR_nothing); + return e.use_exact_insn (icode); + } + +private: + neon_cvt_kind m_kind; +}; + +class gimple_cvt_scalar : public gimple_function_base +{ +public: + constexpr gimple_cvt_scalar (neon_cvt_kind kind) + : m_kind (kind) + {} + + gimple *fold (gimple_folder &) const override + { + return nullptr; + } + + rtx expand (function_expander &e) const override + { + machine_mode to_mode = e.result_mode (); + machine_mode from_mode = GET_MODE (e.args[0]); + insn_code icode; + neon_cvt_kind kind = m_kind; + + const auto &to = e.type_suffix (0); + const auto &from = e.type_suffix (1); + + bool unsigned_p = to.float_p + ? from.unsigned_p + : to.unsigned_p; + + convert_optab optab; + switch (kind) + { + case neon_cvt_kind::cvt_scalar: + if (!unsigned_p) + { + kind = neon_cvt_kind::cvt_signed_scalar; + } + icode = get_neon_cvt_icode (kind, from_mode, to_mode); + gcc_assert (icode != CODE_FOR_nothing); + return e.use_exact_insn (icode); + break; + + case neon_cvt_kind::cvta_scalar: + if (to.unsigned_p) + { + icode = get_neon_cvt_icode (kind, from_mode, to_mode); + gcc_assert (icode != CODE_FOR_nothing); + return e.use_exact_insn (icode); + } + else + optab = lround_optab; + break; + + case neon_cvt_kind::cvtm_scalar: + if (to.unsigned_p) + { + icode = get_neon_cvt_icode (kind, from_mode, to_mode); + gcc_assert (icode != CODE_FOR_nothing); + return e.use_exact_insn (icode); + } + else + optab = lfloor_optab; + break; + + case neon_cvt_kind::cvtp_scalar: + if (to.unsigned_p) + { + icode = get_neon_cvt_icode (kind, from_mode, to_mode); + gcc_assert (icode != CODE_FOR_nothing); + return e.use_exact_insn (icode); + } + else + optab = lceil_optab; + break; + + case neon_cvt_kind::cvtn_scalar: + if (!to.unsigned_p) + { + kind = neon_cvt_kind::cvtn_signed_scalar; + } + icode = get_neon_cvt_icode (kind, from_mode, to_mode); + gcc_assert (icode != CODE_FOR_nothing); + return e.use_exact_insn (icode); + + default: + gcc_unreachable (); + } + + icode = convert_optab_handler (optab, to_mode, from_mode); + gcc_assert (icode != CODE_FOR_nothing); + return e.use_exact_insn (icode); + } + +private: + neon_cvt_kind m_kind; +}; + +class gimple_cvt_n : public gimple_function_base +{ +public: + constexpr gimple_cvt_n (neon_cvt_kind kind) + : m_kind (kind) + {} + + gimple *fold (gimple_folder &) const override + { + return nullptr; + } + + rtx expand (function_expander &e) const override + { + machine_mode from_mode = GET_MODE (e.args[0]); + const auto &to = e.type_suffix (0); + const auto &from = e.type_suffix (1); + + if (GET_MODE (e.args[0]) == V1DFmode + || GET_MODE (e.args[0]) == V1DImode) + { + if (to.float_p) + return build_64bit_cvt (e.args, from.unsigned_p, to.float_p, m_kind); + else + return build_64bit_cvt (e.args, to.unsigned_p, to.float_p, m_kind); + } + + insn_code icode; + if (to.float_p) + icode = from.unsigned_p ? code_for_ucvtf3 (from_mode) + : code_for_scvtf3 (from_mode); + else + icode = to.unsigned_p ? code_for_fcvtzu3 (from_mode) + : code_for_fcvtzs3 (from_mode); + return e.use_exact_insn (icode); + } + +private: + neon_cvt_kind m_kind; +}; + tree ext_mask (gimple_folder &f) { @@ -898,4 +1480,23 @@ NEON_FUNCTION (vsm3partw2q, gimple_exact_insn,) // SM4 NEON_FUNCTION (vsm4eq, gimple_exact_insn,) NEON_FUNCTION (vsm4ekeyq, gimple_exact_insn,) + +// Conversions +NEON_FUNCTION (vcvt, vcvtq, gimple_cvt, (neon_cvt_kind::cvt)) +NEON_FUNCTION (vcvta, vcvtaq, gimple_cvt, (neon_cvt_kind::cvta)) +NEON_FUNCTION (vcvtp, vcvtpq, gimple_cvt, (neon_cvt_kind::cvtp)) +NEON_FUNCTION (vcvtm, vcvtmq, gimple_cvt, (neon_cvt_kind::cvtm)) +NEON_FUNCTION (vcvtn, vcvtnq, gimple_cvt, (neon_cvt_kind::cvtn)) +NEON_FUNCTION (vcvtd, vcvts, gimple_cvt_scalar, (neon_cvt_kind::cvt_scalar)) +NEON_FUNCTION (vcvtad, vcvtas, gimple_cvt_scalar, (neon_cvt_kind::cvta_scalar)) +NEON_FUNCTION (vcvtpd, vcvtps, gimple_cvt_scalar, (neon_cvt_kind::cvtp_scalar)) +NEON_FUNCTION (vcvtmd, vcvtms, gimple_cvt_scalar, (neon_cvt_kind::cvtm_scalar)) +NEON_FUNCTION (vcvtnd, vcvtns, gimple_cvt_scalar, (neon_cvt_kind::cvtn_scalar)) +NEON_FUNCTION (vcvt_n, vcvtq_n, vcvtd_n, vcvts_n, gimple_cvt_n, (neon_cvt_kind::cvt_n)) +NEON_FUNCTION (vcvt_high, gimple_cvt, (neon_cvt_kind::cvt_high)) +NEON_FUNCTION (vcvtx, gimple_cvt, (neon_cvt_kind::cvtx)) +NEON_FUNCTION (vcvtx_high, gimple_cvt, (neon_cvt_kind::cvtx_high)) +NEON_FUNCTION (vcvtxd, gimple_cvt, (neon_cvt_kind::cvtx_scalar)) +NEON_FUNCTION (vcvtq_high, gimple_cvt, (neon_cvt_kind::cvtq_high)) +NEON_FUNCTION (vcvtq_low, gimple_cvt, (neon_cvt_kind::cvtq_low)) } diff --git a/gcc/config/aarch64/aarch64-neon-builtins-base.def b/gcc/config/aarch64/aarch64-neon-builtins-base.def index df33c37c34fc..524e0f4755dc 100644 --- a/gcc/config/aarch64/aarch64-neon-builtins-base.def +++ b/gcc/config/aarch64/aarch64-neon-builtins-base.def @@ -261,6 +261,71 @@ DEF_NEON_FUNCTION (vzip2q, bhsd_neon, ("Q0,Q0,Q0")) DEF_NEON_FUNCTION (vzipq, bhs_neon, ("Q0x2,Q0,Q0")) #undef REQUIRED_EXTENSIONS +// Conversions +#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD) +DEF_NEON_FUNCTION (vcvt, neon_cvt, ("D0,D1")) +DEF_NEON_FUNCTION (vcvtq, neon_cvt, ("Q0,Q1")) +DEF_NEON_FUNCTION (vcvta, neon_cvt_rounding, ("D0,D1")) +DEF_NEON_FUNCTION (vcvtaq, neon_cvt_rounding, ("Q0,Q1")) +DEF_NEON_FUNCTION (vcvtp, neon_cvt_rounding, ("D0,D1")) +DEF_NEON_FUNCTION (vcvtpq, neon_cvt_rounding, ("Q0,Q1")) +DEF_NEON_FUNCTION (vcvtm, neon_cvt_rounding, ("D0,D1")) +DEF_NEON_FUNCTION (vcvtmq, neon_cvt_rounding, ("Q0,Q1")) +DEF_NEON_FUNCTION (vcvtn, neon_cvt_rounding, ("D0,D1")) +DEF_NEON_FUNCTION (vcvtnq, neon_cvt_rounding, ("Q0,Q1")) +DEF_NEON_FUNCTION (vcvtd, neon_cvtd_scalar, ("s0,s1")) +DEF_NEON_FUNCTION (vcvts, neon_cvts_scalar, ("s0,s1")) +DEF_NEON_FUNCTION (vcvtad, neon_cvtd_rounding_scalar, ("s0,s1")) +DEF_NEON_FUNCTION (vcvtas, neon_cvts_rounding_scalar, ("s0,s1")) +DEF_NEON_FUNCTION (vcvtmd, neon_cvtd_rounding_scalar, ("s0,s1")) +DEF_NEON_FUNCTION (vcvtms, neon_cvts_rounding_scalar, ("s0,s1")) +DEF_NEON_FUNCTION (vcvtpd, neon_cvtd_rounding_scalar, ("s0,s1")) +DEF_NEON_FUNCTION (vcvtps, neon_cvts_rounding_scalar, ("s0,s1")) +DEF_NEON_FUNCTION (vcvtnd, neon_cvtd_rounding_scalar, ("s0,s1")) +DEF_NEON_FUNCTION (vcvtns, neon_cvts_rounding_scalar, ("s0,s1")) +DEF_NEON_FUNCTION (vcvt_n, neon_cvt, ("D0,D1,ss32")) +DEF_NEON_FUNCTION (vcvtq_n, neon_cvt, ("Q0,Q1,ss32")) +DEF_NEON_FUNCTION (vcvtd_n, neon_cvtd_n, ("s0,s1,ss32")) +DEF_NEON_FUNCTION (vcvts_n, neon_cvts_n, ("s0,s1,ss32")) +DEF_NEON_FUNCTION (vcvt, neon_cvt_widen, ("Q0,D1")) +DEF_NEON_FUNCTION (vcvt, neon_cvt_narrow, ("D0,Q1")) +DEF_NEON_FUNCTION (vcvt_high, neon_cvt_widen, ("Q0,Q1")) +DEF_NEON_FUNCTION (vcvt_high, neon_cvt_narrow, ("Q0,D0,Q1")) +DEF_NEON_FUNCTION (vcvtx, neon_cvtx_narrow, (("D0,Q1"))) +DEF_NEON_FUNCTION (vcvtx_high, neon_cvtx_narrow, ("Q0,D0,Q1")) +DEF_NEON_FUNCTION (vcvtxd, neon_cvtx_narrow, (("s0,s1"))) +#undef REQUIRED_EXTENSIONS + +// Conversions (FP16) +#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD | AARCH64_FL_F16) +DEF_NEON_FUNCTION (vcvt, neon_cvt_fp16, ("D0,D1")) +DEF_NEON_FUNCTION (vcvtq, neon_cvt_fp16, ("Q0,Q1")) +DEF_NEON_FUNCTION (vcvta, neon_cvt_rounding_fp16, ("D0,D1")) +DEF_NEON_FUNCTION (vcvtaq, neon_cvt_rounding_fp16, ("Q0,Q1")) +DEF_NEON_FUNCTION (vcvtp, neon_cvt_rounding_fp16, ("D0,D1")) +DEF_NEON_FUNCTION (vcvtpq, neon_cvt_rounding_fp16, ("Q0,Q1")) +DEF_NEON_FUNCTION (vcvtm, neon_cvt_rounding_fp16, ("D0,D1")) +DEF_NEON_FUNCTION (vcvtmq, neon_cvt_rounding_fp16, ("Q0,Q1")) +DEF_NEON_FUNCTION (vcvtn, neon_cvt_rounding_fp16, ("D0,D1")) +DEF_NEON_FUNCTION (vcvtnq, neon_cvt_rounding_fp16, ("Q0,Q1")) +DEF_NEON_FUNCTION (vcvt_n, neon_cvt_fp16, ("D0,D1,ss32")) +DEF_NEON_FUNCTION (vcvtq_n, neon_cvt_fp16, ("Q0,Q1,ss32")) +DEF_NEON_FUNCTION (vcvt, neon_cvt_widen_fp16, ("Q0,D1")) +DEF_NEON_FUNCTION (vcvt, neon_cvt_narrow_fp16, ("D0,Q1")) +DEF_NEON_FUNCTION (vcvt_high, neon_cvt_widen_fp16, ("Q0,Q1")) +DEF_NEON_FUNCTION (vcvt_high, neon_cvt_narrow_fp16, ("Q0,D0,Q1")) +#undef REQUIRED_EXTENSIONS + +// Conversions (BF16) +#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD | AARCH64_FL_BF16) +DEF_NEON_FUNCTION (vcvt, neon_cvtbf16_widen, ("Q0,DB")) +DEF_NEON_FUNCTION (vcvt, neon_cvtbf16_narrow, ("DB,Q1")) +DEF_NEON_FUNCTION (vcvtq_high, neon_cvtbf16_narrow, ("QB,QB,Q1")) +DEF_NEON_FUNCTION (vcvtq_high, neon_cvtbf16_widen, ("Q0,QB")) +DEF_NEON_FUNCTION (vcvtq_low, neon_cvtbf16_narrow, ("QB,Q1")) +DEF_NEON_FUNCTION (vcvtq_low, neon_cvtbf16_widen, ("Q0,QB")) +#undef REQUIRED_EXTENSIONS + // AES #define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_SIMD | AARCH64_FL_AES) DEF_NEON_FUNCTION (vaeseq, b_unsigned, ("Q0,Q0,Q0")) diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index 53c2cbf0f687..80669c5d5c69 100644 --- a/gcc/config/aarch64/aarch64-simd.md +++ b/gcc/config/aarch64/aarch64-simd.md @@ -3486,25 +3486,47 @@ ;; Convert between fixed-point and floating-point (vector modes) -(define_insn "3" +(define_insn "@fcvtzs3" [(set (match_operand: 0 "register_operand" "=w") (unspec: [(match_operand:VHSDF 1 "register_operand" "w") (match_operand:SI 2 "immediate_operand" "i")] - FCVT_F2FIXED))] + UNSPEC_FCVTZS))] "TARGET_SIMD" - "\t%0, %1, #%2" + "fcvtzs\t%0, %1, #%2" [(set_attr "type" "neon_fp_to_int_")] ) -(define_insn "3" +(define_insn "@fcvtzu3" + [(set (match_operand: 0 "register_operand" "=w") + (unspec: + [(match_operand:VHSDF 1 "register_operand" "w") + (match_operand:SI 2 "immediate_operand" "i")] + UNSPEC_FCVTZU))] + "TARGET_SIMD" + "fcvtzu\t%0, %1, #%2" + [(set_attr "type" "neon_fp_to_int_")] +) + +(define_insn "@scvtf3" + [(set (match_operand: 0 "register_operand" "=w") + (unspec: + [(match_operand:VDQ_HSDI 1 "register_operand" "w") + (match_operand:SI 2 "immediate_operand" "i")] + UNSPEC_SCVTF))] + "TARGET_SIMD" + "scvtf\t%0, %1, #%2" + [(set_attr "type" "neon_int_to_fp_")] +) + +(define_insn "@ucvtf3" [(set (match_operand: 0 "register_operand" "=w") (unspec: [(match_operand:VDQ_HSDI 1 "register_operand" "w") (match_operand:SI 2 "immediate_operand" "i")] - FCVT_FIXED2F))] + UNSPEC_UCVTF))] "TARGET_SIMD" - "\t%0, %1, #%2" + "ucvtf\t%0, %1, #%2" [(set_attr "type" "neon_int_to_fp_")] ) diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index f977232536e8..6b6216494c43 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -7514,27 +7514,51 @@ ;; Convert between fixed-point and floating-point (scalar modes) -(define_insn "3" +(define_insn "@fcvtzs3" [(set (match_operand: 0 "register_operand") (unspec: [(match_operand:GPF 1 "register_operand") (match_operand:SI 2 "immediate_operand")] - FCVT_F2FIXED))] + UNSPEC_FCVTZS))] + "" + {@ [ cons: =0 , 1 , 2 ; attrs: type , arch ] + [ r , w , i ; f_cvtf2i , fp ] fcvtzs\t%0, %1, #%2 + [ w , w , i ; neon_fp_to_int_ , simd ] fcvtzs\t%0, %1, #%2 + } +) + +(define_insn "@fcvtzu3" + [(set (match_operand: 0 "register_operand") + (unspec: [(match_operand:GPF 1 "register_operand") + (match_operand:SI 2 "immediate_operand")] + UNSPEC_FCVTZU))] "" {@ [ cons: =0 , 1 , 2 ; attrs: type , arch ] - [ r , w , i ; f_cvtf2i , fp ] \t%0, %1, #%2 - [ w , w , i ; neon_fp_to_int_ , simd ] \t%0, %1, #%2 + [ r , w , i ; f_cvtf2i , fp ] fcvtzu\t%0, %1, #%2 + [ w , w , i ; neon_fp_to_int_ , simd ] fcvtzu\t%0, %1, #%2 } ) -(define_insn "3" +(define_insn "@scvtf3" [(set (match_operand: 0 "register_operand") (unspec: [(match_operand:GPI 1 "register_operand") (match_operand:SI 2 "immediate_operand")] - FCVT_FIXED2F))] + UNSPEC_SCVTF))] + "" + {@ [ cons: =0 , 1 , 2 ; attrs: type , arch ] + [ w , r , i ; f_cvti2f , fp ] scvtf\t%0, %1, #%2 + [ w , w , i ; neon_int_to_fp_ , simd ] scvtf\t%0, %1, #%2 + } +) + +(define_insn "@ucvtf3" + [(set (match_operand: 0 "register_operand") + (unspec: [(match_operand:GPI 1 "register_operand") + (match_operand:SI 2 "immediate_operand")] + UNSPEC_UCVTF))] "" {@ [ cons: =0 , 1 , 2 ; attrs: type , arch ] - [ w , r , i ; f_cvti2f , fp ] \t%0, %1, #%2 - [ w , w , i ; neon_int_to_fp_ , simd ] \t%0, %1, #%2 + [ w , r , i ; f_cvti2f , fp ] ucvtf\t%0, %1, #%2 + [ w , w , i ; neon_int_to_fp_ , simd ] ucvtf\t%0, %1, #%2 } ) diff --git a/gcc/config/aarch64/arm_neon.h b/gcc/config/aarch64/arm_neon.h index 7b5926ca21b2..2e70a704d0db 100644 --- a/gcc/config/aarch64/arm_neon.h +++ b/gcc/config/aarch64/arm_neon.h @@ -1717,27 +1717,6 @@ vaddlvq_u32 (uint32x4_t __a) return __builtin_aarch64_uaddlvv4si_uu (__a); } -__extension__ extern __inline float32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtx_f32_f64 (float64x2_t __a) -{ - return __builtin_aarch64_float_trunc_rodd_lo_v2sf (__a); -} - -__extension__ extern __inline float32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtx_high_f32_f64 (float32x2_t __a, float64x2_t __b) -{ - return __builtin_aarch64_float_trunc_rodd_hi_v4sf (__a, __b); -} - -__extension__ extern __inline float32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtxd_f32_f64 (float64_t __a) -{ - return __builtin_aarch64_float_trunc_rodd_df (__a); -} - __extension__ extern __inline float32x2_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) vmla_n_f32 (float32x2_t __a, float32x2_t __b, float32_t __c) @@ -6749,1012 +6728,120 @@ vcltd_u64 (uint64_t __a, uint64_t __b) return __a < __b ? -1ll : 0ll; } -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltd_f64 (float64_t __a, float64_t __b) -{ - return __a < __b ? -1ll : 0ll; -} - -/* vcltz - vector. */ - -__extension__ extern __inline uint32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltz_f32 (float32x2_t __a) -{ - return (uint32x2_t) (__a < 0.0f); -} - -__extension__ extern __inline uint64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltz_f64 (float64x1_t __a) -{ - return (uint64x1_t) (__a < (float64x1_t) {0.0}); -} - -__extension__ extern __inline uint8x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltz_s8 (int8x8_t __a) -{ - return (uint8x8_t) (__a < 0); -} - -__extension__ extern __inline uint16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltz_s16 (int16x4_t __a) -{ - return (uint16x4_t) (__a < 0); -} - -__extension__ extern __inline uint32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltz_s32 (int32x2_t __a) -{ - return (uint32x2_t) (__a < 0); -} - -__extension__ extern __inline uint64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltz_s64 (int64x1_t __a) -{ - return (uint64x1_t) (__a < __AARCH64_INT64_C (0)); -} - -__extension__ extern __inline uint32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltzq_f32 (float32x4_t __a) -{ - return (uint32x4_t) (__a < 0.0f); -} - -__extension__ extern __inline uint64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltzq_f64 (float64x2_t __a) -{ - return (uint64x2_t) (__a < 0.0); -} - -__extension__ extern __inline uint8x16_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltzq_s8 (int8x16_t __a) -{ - return (uint8x16_t) (__a < 0); -} - -__extension__ extern __inline uint16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltzq_s16 (int16x8_t __a) -{ - return (uint16x8_t) (__a < 0); -} - -__extension__ extern __inline uint32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltzq_s32 (int32x4_t __a) -{ - return (uint32x4_t) (__a < 0); -} - -__extension__ extern __inline uint64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltzq_s64 (int64x2_t __a) -{ - return (uint64x2_t) (__a < __AARCH64_INT64_C (0)); -} - -/* vcltz - scalar. */ - -__extension__ extern __inline uint32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltzs_f32 (float32_t __a) -{ - return __a < 0.0f ? -1 : 0; -} - -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltzd_s64 (int64_t __a) -{ - return __a < 0 ? -1ll : 0ll; -} - -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcltzd_f64 (float64_t __a) -{ - return __a < 0.0 ? -1ll : 0ll; -} - -/* vcvt (double -> float). */ - -__extension__ extern __inline float16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_f16_f32 (float32x4_t __a) -{ - return __builtin_aarch64_float_truncate_lo_v4hf (__a); -} - -__extension__ extern __inline float16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_high_f16_f32 (float16x4_t __a, float32x4_t __b) -{ - return __builtin_aarch64_float_truncate_hi_v8hf (__a, __b); -} - -__extension__ extern __inline float32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_f32_f64 (float64x2_t __a) -{ - return __builtin_aarch64_float_truncate_lo_v2sf (__a); -} - -__extension__ extern __inline float32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_high_f32_f64 (float32x2_t __a, float64x2_t __b) -{ - return __builtin_aarch64_float_truncate_hi_v4sf (__a, __b); -} - -/* vcvt (float -> double). */ - -__extension__ extern __inline float32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_f32_f16 (float16x4_t __a) -{ - return __builtin_aarch64_float_extend_lo_v4sf (__a); -} - -__extension__ extern __inline float64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_f64_f32 (float32x2_t __a) -{ - - return __builtin_aarch64_float_extend_lo_v2df (__a); -} - -__extension__ extern __inline float32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_high_f32_f16 (float16x8_t __a) -{ - return __builtin_aarch64_vec_unpacks_hi_v8hf (__a); -} - -__extension__ extern __inline float64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_high_f64_f32 (float32x4_t __a) -{ - return __builtin_aarch64_vec_unpacks_hi_v4sf (__a); -} - -/* vcvt (fixed-point -> float). */ - -__extension__ extern __inline float64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtd_n_f64_s64 (int64_t __a, const int __b) -{ - return __builtin_aarch64_scvtfdi (__a, __b); -} - -__extension__ extern __inline float64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtd_n_f64_u64 (uint64_t __a, const int __b) -{ - return __builtin_aarch64_ucvtfdi_sus (__a, __b); -} - -__extension__ extern __inline float32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvts_n_f32_s32 (int32_t __a, const int __b) -{ - return __builtin_aarch64_scvtfsi (__a, __b); -} - -__extension__ extern __inline float32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvts_n_f32_u32 (uint32_t __a, const int __b) -{ - return __builtin_aarch64_ucvtfsi_sus (__a, __b); -} - -__extension__ extern __inline float32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_n_f32_s32 (int32x2_t __a, const int __b) -{ - return __builtin_aarch64_scvtfv2si (__a, __b); -} - -__extension__ extern __inline float32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_n_f32_u32 (uint32x2_t __a, const int __b) -{ - return __builtin_aarch64_ucvtfv2si_sus (__a, __b); -} - -__extension__ extern __inline float64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_n_f64_s64 (int64x1_t __a, const int __b) -{ - return (float64x1_t) - { __builtin_aarch64_scvtfdi (vget_lane_s64 (__a, 0), __b) }; -} - -__extension__ extern __inline float64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_n_f64_u64 (uint64x1_t __a, const int __b) -{ - return (float64x1_t) - { __builtin_aarch64_ucvtfdi_sus (vget_lane_u64 (__a, 0), __b) }; -} - -__extension__ extern __inline float32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_n_f32_s32 (int32x4_t __a, const int __b) -{ - return __builtin_aarch64_scvtfv4si (__a, __b); -} - -__extension__ extern __inline float32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_n_f32_u32 (uint32x4_t __a, const int __b) -{ - return __builtin_aarch64_ucvtfv4si_sus (__a, __b); -} - -__extension__ extern __inline float64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_n_f64_s64 (int64x2_t __a, const int __b) -{ - return __builtin_aarch64_scvtfv2di (__a, __b); -} - -__extension__ extern __inline float64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_n_f64_u64 (uint64x2_t __a, const int __b) -{ - return __builtin_aarch64_ucvtfv2di_sus (__a, __b); -} - -/* vcvt (float -> fixed-point). */ - -__extension__ extern __inline int64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtd_n_s64_f64 (float64_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzsdf (__a, __b); -} - -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtd_n_u64_f64 (float64_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzudf_uss (__a, __b); -} - -__extension__ extern __inline int32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvts_n_s32_f32 (float32_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzssf (__a, __b); -} - -__extension__ extern __inline uint32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvts_n_u32_f32 (float32_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzusf_uss (__a, __b); -} - -__extension__ extern __inline int32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_n_s32_f32 (float32x2_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzsv2sf (__a, __b); -} - -__extension__ extern __inline uint32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_n_u32_f32 (float32x2_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzuv2sf_uss (__a, __b); -} - -__extension__ extern __inline int64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_n_s64_f64 (float64x1_t __a, const int __b) -{ - return (int64x1_t) - { __builtin_aarch64_fcvtzsdf (vget_lane_f64 (__a, 0), __b) }; -} - -__extension__ extern __inline uint64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_n_u64_f64 (float64x1_t __a, const int __b) -{ - return (uint64x1_t) - { __builtin_aarch64_fcvtzudf_uss (vget_lane_f64 (__a, 0), __b) }; -} - -__extension__ extern __inline int32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_n_s32_f32 (float32x4_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzsv4sf (__a, __b); -} - -__extension__ extern __inline uint32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_n_u32_f32 (float32x4_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzuv4sf_uss (__a, __b); -} - -__extension__ extern __inline int64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_n_s64_f64 (float64x2_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzsv2df (__a, __b); -} - -__extension__ extern __inline uint64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_n_u64_f64 (float64x2_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzuv2df_uss (__a, __b); -} - -/* vcvt (int -> float) */ - -__extension__ extern __inline float64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtd_f64_s64 (int64_t __a) -{ - return (float64_t) __a; -} - -__extension__ extern __inline float64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtd_f64_u64 (uint64_t __a) -{ - return (float64_t) __a; -} - -__extension__ extern __inline float32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvts_f32_s32 (int32_t __a) -{ - return (float32_t) __a; -} - -__extension__ extern __inline float32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvts_f32_u32 (uint32_t __a) -{ - return (float32_t) __a; -} - -__extension__ extern __inline float32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_f32_s32 (int32x2_t __a) -{ - return __builtin_aarch64_floatv2siv2sf (__a); -} - -__extension__ extern __inline float32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_f32_u32 (uint32x2_t __a) -{ - return __builtin_aarch64_floatunsv2siv2sf ((int32x2_t) __a); -} - -__extension__ extern __inline float64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_f64_s64 (int64x1_t __a) -{ - return (float64x1_t) { vget_lane_s64 (__a, 0) }; -} - -__extension__ extern __inline float64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_f64_u64 (uint64x1_t __a) -{ - return (float64x1_t) { vget_lane_u64 (__a, 0) }; -} - -__extension__ extern __inline float32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_f32_s32 (int32x4_t __a) -{ - return __builtin_aarch64_floatv4siv4sf (__a); -} - -__extension__ extern __inline float32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_f32_u32 (uint32x4_t __a) -{ - return __builtin_aarch64_floatunsv4siv4sf ((int32x4_t) __a); -} - -__extension__ extern __inline float64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_f64_s64 (int64x2_t __a) -{ - return __builtin_aarch64_floatv2div2df (__a); -} - -__extension__ extern __inline float64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_f64_u64 (uint64x2_t __a) -{ - return __builtin_aarch64_floatunsv2div2df ((int64x2_t) __a); -} - -/* vcvt (float -> int) */ - -__extension__ extern __inline int64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtd_s64_f64 (float64_t __a) -{ - return (int64_t) __a; -} - -__extension__ extern __inline int32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtd_s32_f64 (float64_t __a) -{ - return (int32_t) __a; -} - -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtd_u64_f64 (float64_t __a) -{ - return (uint64_t) __a; -} - -__extension__ extern __inline uint32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtd_u32_f64 (float64_t __a) -{ - return (uint32_t) __a; -} - -__extension__ extern __inline int32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvts_s32_f32 (float32_t __a) -{ - return (int32_t) __a; -} - -__extension__ extern __inline int64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvts_s64_f32 (float32_t __a) -{ - return (int64_t) __a; -} - -__extension__ extern __inline uint32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvts_u32_f32 (float32_t __a) -{ - return (uint32_t) __a; -} - -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvts_u64_f32 (float32_t __a) -{ - return (uint64_t) __a; -} - -__extension__ extern __inline int32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_s32_f32 (float32x2_t __a) -{ - return __builtin_aarch64_lbtruncv2sfv2si (__a); -} - -__extension__ extern __inline uint32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_u32_f32 (float32x2_t __a) -{ - return __builtin_aarch64_lbtruncuv2sfv2si_us (__a); -} - -__extension__ extern __inline int32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_s32_f32 (float32x4_t __a) -{ - return __builtin_aarch64_lbtruncv4sfv4si (__a); -} - -__extension__ extern __inline uint32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_u32_f32 (float32x4_t __a) -{ - return __builtin_aarch64_lbtruncuv4sfv4si_us (__a); -} - -__extension__ extern __inline int64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_s64_f64 (float64x1_t __a) -{ - return (int64x1_t) {vcvtd_s64_f64 (__a[0])}; -} - -__extension__ extern __inline uint64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_u64_f64 (float64x1_t __a) -{ - return (uint64x1_t) {vcvtd_u64_f64 (__a[0])}; -} - -__extension__ extern __inline int64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_s64_f64 (float64x2_t __a) -{ - return __builtin_aarch64_lbtruncv2dfv2di (__a); -} - -__extension__ extern __inline uint64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_u64_f64 (float64x2_t __a) -{ - return __builtin_aarch64_lbtruncuv2dfv2di_us (__a); -} - -/* vcvta */ - -__extension__ extern __inline int64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtad_s64_f64 (float64_t __a) -{ - return __builtin_aarch64_lrounddfdi (__a); -} - -__extension__ extern __inline int32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtad_s32_f64 (float64_t __a) -{ - return __builtin_aarch64_lrounddfsi (__a); -} - -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtad_u64_f64 (float64_t __a) -{ - return __builtin_aarch64_lroundudfdi_us (__a); -} - -__extension__ extern __inline uint32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtad_u32_f64 (float64_t __a) -{ - return __builtin_aarch64_lroundudfsi_us (__a); -} - -__extension__ extern __inline int32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtas_s32_f32 (float32_t __a) -{ - return __builtin_aarch64_lroundsfsi (__a); -} - -__extension__ extern __inline int64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtas_s64_f32 (float32_t __a) -{ - return __builtin_aarch64_lroundsfdi (__a); -} - -__extension__ extern __inline uint32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtas_u32_f32 (float32_t __a) -{ - return __builtin_aarch64_lroundusfsi_us (__a); -} - -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtas_u64_f32 (float32_t __a) -{ - return __builtin_aarch64_lroundusfdi_us (__a); -} - -__extension__ extern __inline int32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvta_s32_f32 (float32x2_t __a) -{ - return __builtin_aarch64_lroundv2sfv2si (__a); -} - -__extension__ extern __inline uint32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvta_u32_f32 (float32x2_t __a) -{ - return __builtin_aarch64_lrounduv2sfv2si_us (__a); -} - -__extension__ extern __inline int32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtaq_s32_f32 (float32x4_t __a) -{ - return __builtin_aarch64_lroundv4sfv4si (__a); -} - -__extension__ extern __inline uint32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtaq_u32_f32 (float32x4_t __a) -{ - return __builtin_aarch64_lrounduv4sfv4si_us (__a); -} - -__extension__ extern __inline int64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvta_s64_f64 (float64x1_t __a) -{ - return (int64x1_t) {vcvtad_s64_f64 (__a[0])}; -} - -__extension__ extern __inline uint64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvta_u64_f64 (float64x1_t __a) -{ - return (uint64x1_t) {vcvtad_u64_f64 (__a[0])}; -} - -__extension__ extern __inline int64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtaq_s64_f64 (float64x2_t __a) -{ - return __builtin_aarch64_lroundv2dfv2di (__a); -} - -__extension__ extern __inline uint64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtaq_u64_f64 (float64x2_t __a) -{ - return __builtin_aarch64_lrounduv2dfv2di_us (__a); -} - -/* vcvtm */ - -__extension__ extern __inline int64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtmd_s64_f64 (float64_t __a) -{ - return __builtin_llfloor (__a); -} - -__extension__ extern __inline int32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtmd_s32_f64 (float64_t __a) -{ - return __builtin_aarch64_lfloordfsi (__a); -} - -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtmd_u64_f64 (float64_t __a) -{ - return __builtin_aarch64_lfloorudfdi_us (__a); -} - -__extension__ extern __inline uint32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtmd_u32_f64 (float64_t __a) -{ - return __builtin_aarch64_lfloorudfsi_us (__a); -} - -__extension__ extern __inline int32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtms_s32_f32 (float32_t __a) -{ - return __builtin_ifloorf (__a); -} - -__extension__ extern __inline int64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtms_s64_f32 (float32_t __a) -{ - return __builtin_aarch64_lfloorsfdi (__a); -} - -__extension__ extern __inline uint32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtms_u32_f32 (float32_t __a) -{ - return __builtin_aarch64_lfloorusfsi_us (__a); -} - -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtms_u64_f32 (float32_t __a) -{ - return __builtin_aarch64_lfloorusfdi_us (__a); -} - -__extension__ extern __inline int32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtm_s32_f32 (float32x2_t __a) -{ - return __builtin_aarch64_lfloorv2sfv2si (__a); -} - -__extension__ extern __inline uint32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtm_u32_f32 (float32x2_t __a) -{ - return __builtin_aarch64_lflooruv2sfv2si_us (__a); -} - -__extension__ extern __inline int32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtmq_s32_f32 (float32x4_t __a) -{ - return __builtin_aarch64_lfloorv4sfv4si (__a); -} - -__extension__ extern __inline uint32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtmq_u32_f32 (float32x4_t __a) -{ - return __builtin_aarch64_lflooruv4sfv4si_us (__a); -} - -__extension__ extern __inline int64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtm_s64_f64 (float64x1_t __a) -{ - return (int64x1_t) {vcvtmd_s64_f64 (__a[0])}; -} - -__extension__ extern __inline uint64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtm_u64_f64 (float64x1_t __a) -{ - return (uint64x1_t) {vcvtmd_u64_f64 (__a[0])}; -} - -__extension__ extern __inline int64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtmq_s64_f64 (float64x2_t __a) -{ - return __builtin_aarch64_lfloorv2dfv2di (__a); -} - -__extension__ extern __inline uint64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtmq_u64_f64 (float64x2_t __a) -{ - return __builtin_aarch64_lflooruv2dfv2di_us (__a); -} - -/* vcvtn */ - -__extension__ extern __inline int64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtnd_s64_f64 (float64_t __a) -{ - return __builtin_aarch64_lfrintndfdi (__a); -} - -__extension__ extern __inline int64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtnd_s32_f64 (float64_t __a) -{ - return __builtin_aarch64_lfrintndfsi (__a); -} - -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtnd_u64_f64 (float64_t __a) -{ - return __builtin_aarch64_lfrintnudfdi_us (__a); -} - -__extension__ extern __inline uint32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtnd_u32_f64 (float64_t __a) -{ - return __builtin_aarch64_lfrintnudfsi_us (__a); -} - -__extension__ extern __inline int32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtns_s32_f32 (float32_t __a) -{ - return __builtin_aarch64_lfrintnsfsi (__a); -} - -__extension__ extern __inline int64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtns_s64_f32 (float32_t __a) -{ - return __builtin_aarch64_lfrintnsfdi (__a); -} - -__extension__ extern __inline uint32_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtns_u32_f32 (float32_t __a) -{ - return __builtin_aarch64_lfrintnusfsi_us (__a); -} -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtns_u64_f32 (float32_t __a) -{ - return __builtin_aarch64_lfrintnusfdi_us (__a); -} - -__extension__ extern __inline int32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtn_s32_f32 (float32x2_t __a) -{ - return __builtin_aarch64_lfrintnv2sfv2si (__a); -} - -__extension__ extern __inline uint32x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtn_u32_f32 (float32x2_t __a) -{ - return __builtin_aarch64_lfrintnuv2sfv2si_us (__a); -} - -__extension__ extern __inline int32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtnq_s32_f32 (float32x4_t __a) -{ - return __builtin_aarch64_lfrintnv4sfv4si (__a); -} - -__extension__ extern __inline uint32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtnq_u32_f32 (float32x4_t __a) -{ - return __builtin_aarch64_lfrintnuv4sfv4si_us (__a); -} - -__extension__ extern __inline int64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtn_s64_f64 (float64x1_t __a) -{ - return (int64x1_t) {vcvtnd_s64_f64 (__a[0])}; -} - -__extension__ extern __inline uint64x1_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtn_u64_f64 (float64x1_t __a) -{ - return (uint64x1_t) {vcvtnd_u64_f64 (__a[0])}; -} - -__extension__ extern __inline int64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtnq_s64_f64 (float64x2_t __a) -{ - return __builtin_aarch64_lfrintnv2dfv2di (__a); -} - -__extension__ extern __inline uint64x2_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtnq_u64_f64 (float64x2_t __a) -{ - return __builtin_aarch64_lfrintnuv2dfv2di_us (__a); -} - -/* vcvtp */ - -__extension__ extern __inline int64_t +__extension__ extern __inline uint64_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtpd_s64_f64 (float64_t __a) +vcltd_f64 (float64_t __a, float64_t __b) { - return __builtin_llceil (__a); + return __a < __b ? -1ll : 0ll; } -__extension__ extern __inline int32_t +/* vcltz - vector. */ + +__extension__ extern __inline uint32x2_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtpd_s32_f64 (float64_t __a) +vcltz_f32 (float32x2_t __a) { - return __builtin_aarch64_lceildfsi (__a); + return (uint32x2_t) (__a < 0.0f); } -__extension__ extern __inline uint64_t +__extension__ extern __inline uint64x1_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtpd_u64_f64 (float64_t __a) +vcltz_f64 (float64x1_t __a) { - return __builtin_aarch64_lceiludfdi_us (__a); + return (uint64x1_t) (__a < (float64x1_t) {0.0}); } -__extension__ extern __inline uint32_t +__extension__ extern __inline uint8x8_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtpd_u32_f64 (float64_t __a) +vcltz_s8 (int8x8_t __a) { - return __builtin_aarch64_lceiludfsi_us (__a); + return (uint8x8_t) (__a < 0); } -__extension__ extern __inline int32_t +__extension__ extern __inline uint16x4_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtps_s32_f32 (float32_t __a) +vcltz_s16 (int16x4_t __a) { - return __builtin_iceilf (__a); + return (uint16x4_t) (__a < 0); } -__extension__ extern __inline int64_t +__extension__ extern __inline uint32x2_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtps_s64_f32 (float32_t __a) +vcltz_s32 (int32x2_t __a) { - return __builtin_aarch64_lceilsfdi (__a); + return (uint32x2_t) (__a < 0); } -__extension__ extern __inline uint32_t +__extension__ extern __inline uint64x1_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtps_u32_f32 (float32_t __a) +vcltz_s64 (int64x1_t __a) { - return __builtin_aarch64_lceilusfsi_us (__a); + return (uint64x1_t) (__a < __AARCH64_INT64_C (0)); } -__extension__ extern __inline uint64_t +__extension__ extern __inline uint32x4_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtps_u64_f32 (float32_t __a) +vcltzq_f32 (float32x4_t __a) { - return __builtin_aarch64_lceilusfdi_us (__a); + return (uint32x4_t) (__a < 0.0f); } -__extension__ extern __inline int32x2_t +__extension__ extern __inline uint64x2_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtp_s32_f32 (float32x2_t __a) +vcltzq_f64 (float64x2_t __a) { - return __builtin_aarch64_lceilv2sfv2si (__a); + return (uint64x2_t) (__a < 0.0); } -__extension__ extern __inline uint32x2_t +__extension__ extern __inline uint8x16_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtp_u32_f32 (float32x2_t __a) +vcltzq_s8 (int8x16_t __a) { - return __builtin_aarch64_lceiluv2sfv2si_us (__a); + return (uint8x16_t) (__a < 0); } -__extension__ extern __inline int32x4_t +__extension__ extern __inline uint16x8_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtpq_s32_f32 (float32x4_t __a) +vcltzq_s16 (int16x8_t __a) { - return __builtin_aarch64_lceilv4sfv4si (__a); + return (uint16x8_t) (__a < 0); } __extension__ extern __inline uint32x4_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtpq_u32_f32 (float32x4_t __a) +vcltzq_s32 (int32x4_t __a) { - return __builtin_aarch64_lceiluv4sfv4si_us (__a); + return (uint32x4_t) (__a < 0); } -__extension__ extern __inline int64x1_t +__extension__ extern __inline uint64x2_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtp_s64_f64 (float64x1_t __a) +vcltzq_s64 (int64x2_t __a) { - return (int64x1_t) {vcvtpd_s64_f64 (__a[0])}; + return (uint64x2_t) (__a < __AARCH64_INT64_C (0)); } -__extension__ extern __inline uint64x1_t +/* vcltz - scalar. */ + +__extension__ extern __inline uint32_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtp_u64_f64 (float64x1_t __a) +vcltzs_f32 (float32_t __a) { - return (uint64x1_t) {vcvtpd_u64_f64 (__a[0])}; + return __a < 0.0f ? -1 : 0; } -__extension__ extern __inline int64x2_t +__extension__ extern __inline uint64_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtpq_s64_f64 (float64x2_t __a) +vcltzd_s64 (int64_t __a) { - return __builtin_aarch64_lceilv2dfv2di (__a); + return __a < 0 ? -1ll : 0ll; } -__extension__ extern __inline uint64x2_t +__extension__ extern __inline uint64_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtpq_u64_f64 (float64x2_t __a) +vcltzd_f64 (float64_t __a) { - return __builtin_aarch64_lceiluv2dfv2di_us (__a); + return __a < 0.0 ? -1ll : 0ll; } /* vfma */ @@ -18385,174 +17472,6 @@ vcltzq_f16 (float16x8_t __a) return __builtin_aarch64_cmltv8hf_uss (__a, vdupq_n_f16 (0.0f)); } -__extension__ extern __inline float16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_f16_s16 (int16x4_t __a) -{ - return __builtin_aarch64_floatv4hiv4hf (__a); -} - -__extension__ extern __inline float16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_f16_s16 (int16x8_t __a) -{ - return __builtin_aarch64_floatv8hiv8hf (__a); -} - -__extension__ extern __inline float16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_f16_u16 (uint16x4_t __a) -{ - return __builtin_aarch64_floatunsv4hiv4hf ((int16x4_t) __a); -} - -__extension__ extern __inline float16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_f16_u16 (uint16x8_t __a) -{ - return __builtin_aarch64_floatunsv8hiv8hf ((int16x8_t) __a); -} - -__extension__ extern __inline int16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_s16_f16 (float16x4_t __a) -{ - return __builtin_aarch64_lbtruncv4hfv4hi (__a); -} - -__extension__ extern __inline int16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_s16_f16 (float16x8_t __a) -{ - return __builtin_aarch64_lbtruncv8hfv8hi (__a); -} - -__extension__ extern __inline uint16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_u16_f16 (float16x4_t __a) -{ - return __builtin_aarch64_lbtruncuv4hfv4hi_us (__a); -} - -__extension__ extern __inline uint16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_u16_f16 (float16x8_t __a) -{ - return __builtin_aarch64_lbtruncuv8hfv8hi_us (__a); -} - -__extension__ extern __inline int16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvta_s16_f16 (float16x4_t __a) -{ - return __builtin_aarch64_lroundv4hfv4hi (__a); -} - -__extension__ extern __inline int16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtaq_s16_f16 (float16x8_t __a) -{ - return __builtin_aarch64_lroundv8hfv8hi (__a); -} - -__extension__ extern __inline uint16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvta_u16_f16 (float16x4_t __a) -{ - return __builtin_aarch64_lrounduv4hfv4hi_us (__a); -} - -__extension__ extern __inline uint16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtaq_u16_f16 (float16x8_t __a) -{ - return __builtin_aarch64_lrounduv8hfv8hi_us (__a); -} - -__extension__ extern __inline int16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtm_s16_f16 (float16x4_t __a) -{ - return __builtin_aarch64_lfloorv4hfv4hi (__a); -} - -__extension__ extern __inline int16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtmq_s16_f16 (float16x8_t __a) -{ - return __builtin_aarch64_lfloorv8hfv8hi (__a); -} - -__extension__ extern __inline uint16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtm_u16_f16 (float16x4_t __a) -{ - return __builtin_aarch64_lflooruv4hfv4hi_us (__a); -} - -__extension__ extern __inline uint16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtmq_u16_f16 (float16x8_t __a) -{ - return __builtin_aarch64_lflooruv8hfv8hi_us (__a); -} - -__extension__ extern __inline int16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtn_s16_f16 (float16x4_t __a) -{ - return __builtin_aarch64_lfrintnv4hfv4hi (__a); -} - -__extension__ extern __inline int16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtnq_s16_f16 (float16x8_t __a) -{ - return __builtin_aarch64_lfrintnv8hfv8hi (__a); -} - -__extension__ extern __inline uint16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtn_u16_f16 (float16x4_t __a) -{ - return __builtin_aarch64_lfrintnuv4hfv4hi_us (__a); -} - -__extension__ extern __inline uint16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtnq_u16_f16 (float16x8_t __a) -{ - return __builtin_aarch64_lfrintnuv8hfv8hi_us (__a); -} - -__extension__ extern __inline int16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtp_s16_f16 (float16x4_t __a) -{ - return __builtin_aarch64_lceilv4hfv4hi (__a); -} - -__extension__ extern __inline int16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtpq_s16_f16 (float16x8_t __a) -{ - return __builtin_aarch64_lceilv8hfv8hi (__a); -} - -__extension__ extern __inline uint16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtp_u16_f16 (float16x4_t __a) -{ - return __builtin_aarch64_lceiluv4hfv4hi_us (__a); -} - -__extension__ extern __inline uint16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtpq_u16_f16 (float16x8_t __a) -{ - return __builtin_aarch64_lceiluv8hfv8hi_us (__a); -} - __extension__ extern __inline float16x4_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) vneg_f16 (float16x4_t __a) @@ -18737,62 +17656,6 @@ vcltq_f16 (float16x8_t __a, float16x8_t __b) return __builtin_aarch64_cmltv8hf_uss (__a, __b); } -__extension__ extern __inline float16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_n_f16_s16 (int16x4_t __a, const int __b) -{ - return __builtin_aarch64_scvtfv4hi (__a, __b); -} - -__extension__ extern __inline float16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_n_f16_s16 (int16x8_t __a, const int __b) -{ - return __builtin_aarch64_scvtfv8hi (__a, __b); -} - -__extension__ extern __inline float16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_n_f16_u16 (uint16x4_t __a, const int __b) -{ - return __builtin_aarch64_ucvtfv4hi_sus (__a, __b); -} - -__extension__ extern __inline float16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_n_f16_u16 (uint16x8_t __a, const int __b) -{ - return __builtin_aarch64_ucvtfv8hi_sus (__a, __b); -} - -__extension__ extern __inline int16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_n_s16_f16 (float16x4_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzsv4hf (__a, __b); -} - -__extension__ extern __inline int16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_n_s16_f16 (float16x8_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzsv8hf (__a, __b); -} - -__extension__ extern __inline uint16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_n_u16_f16 (float16x4_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzuv4hf_uss (__a, __b); -} - -__extension__ extern __inline uint16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_n_u16_f16 (float16x8_t __a, const int __b) -{ - return __builtin_aarch64_fcvtzuv8hf_uss (__a, __b); -} - __extension__ extern __inline float16x4_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) vdiv_f16 (float16x4_t __a, float16x4_t __b) @@ -20545,48 +19408,6 @@ vbfmlaltq_laneq_f32 (float32x4_t __r, bfloat16x8_t __a, bfloat16x8_t __b, return __builtin_aarch64_bfmlalt_lane_qv4sf (__r, __a, __b, __index); } -__extension__ extern __inline float32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_f32_bf16 (bfloat16x4_t __a) -{ - return __builtin_aarch64_vbfcvtv4bf (__a); -} - -__extension__ extern __inline float32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_low_f32_bf16 (bfloat16x8_t __a) -{ - return __builtin_aarch64_vbfcvtv8bf (__a); -} - -__extension__ extern __inline float32x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_high_f32_bf16 (bfloat16x8_t __a) -{ - return __builtin_aarch64_vbfcvt_highv8bf (__a); -} - -__extension__ extern __inline bfloat16x4_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvt_bf16_f32 (float32x4_t __a) -{ - return __builtin_aarch64_bfcvtnv4bf (__a); -} - -__extension__ extern __inline bfloat16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_low_bf16_f32 (float32x4_t __a) -{ - return __builtin_aarch64_bfcvtn_qv8bf (__a); -} - -__extension__ extern __inline bfloat16x8_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -vcvtq_high_bf16_f32 (bfloat16x8_t __inactive, float32x4_t __a) -{ - return __builtin_aarch64_bfcvtn2v8bf (__inactive, __a); -} - __extension__ extern __inline bfloat16x4x2_t __attribute__ ((__always_inline__, __gnu_inline__,__artificial__)) vld2_lane_bf16 (const bfloat16_t * __ptr, bfloat16x4x2_t __b, const int __c) diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvtn-nobf16.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvtn-nobf16.c index b3b6db123586..9a6dc241d4c2 100644 --- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvtn-nobf16.c +++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/bfcvtn-nobf16.c @@ -5,6 +5,5 @@ bfloat16x4_t test_bfcvtn (float32x4_t a) { - /* { dg-error "inlining failed .* 'vcvt_bf16_f32" "" { target *-*-* } 0 } */ - return vcvt_bf16_f32 (a); + return vcvt_bf16_f32 (a); /* { dg-error "ACLE function 'vcvt_bf16_f32' requires ISA extension 'bf16'" } */ } diff --git a/gcc/testsuite/gcc.target/aarch64/float_truncate_zero.c b/gcc/testsuite/gcc.target/aarch64/float_truncate_zero.c index 41775d164a50..e73898f42d9a 100644 --- a/gcc/testsuite/gcc.target/aarch64/float_truncate_zero.c +++ b/gcc/testsuite/gcc.target/aarch64/float_truncate_zero.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-additional-options "--save-temps -O1" } */ +/* { dg-additional-options "--save-temps -O1 -march=armv8.2-a+fp16" } */ /* { dg-final { check-function-bodies "**" "" "" } } */ #include diff --git a/gcc/testsuite/gcc.target/aarch64/neon/arm_neon_test.h b/gcc/testsuite/gcc.target/aarch64/neon/arm_neon_test.h index fe90b124cc7b..3152718cda1b 100644 --- a/gcc/testsuite/gcc.target/aarch64/neon/arm_neon_test.h +++ b/gcc/testsuite/gcc.target/aarch64/neon/arm_neon_test.h @@ -7,6 +7,12 @@ #define TEST_UNARY(NAME, RET_TYPE, ARG_1_TYPE) \ RET_TYPE test_##NAME (ARG_1_TYPE a) { return NAME (a); } +#define TEST_UNARY_N(NAME, RET_TYPE, ARG1_TYPE, N) \ + RET_TYPE test_##NAME (ARG1_TYPE a) \ + { \ + return NAME (a, N); \ + } + #define TEST_UNIFORM_UNARY(NAME, TYPE) TEST_UNARY (NAME, TYPE, TYPE) #define TEST_BINARY(NAME, RET_TYPE, ARG_1_TYPE, ARG_2_TYPE) \ diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vcvt.c b/gcc/testsuite/gcc.target/aarch64/neon/vcvt.c new file mode 100644 index 000000000000..35608cdff91d --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vcvt.c @@ -0,0 +1,172 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vcvt_s32_f32: +** fcvtzs v0.2s, v0.2s +** ret +*/ +TEST_UNARY (vcvt_s32_f32, int32x2_t, float32x2_t) + +/* +** test_vcvt_u32_f32: +** fcvtzu v0.2s, v0.2s +** ret +*/ +TEST_UNARY (vcvt_u32_f32, uint32x2_t, float32x2_t) + +/* +** test_vcvt_s64_f64: +** fcvtzs d0, d0 +** ret +*/ +TEST_UNARY (vcvt_s64_f64, int64x1_t, float64x1_t) + +/* +** test_vcvt_u64_f64: +** fcvtzu d0, d0 +** ret +*/ +TEST_UNARY (vcvt_u64_f64, uint64x1_t, float64x1_t) + +/* +** test_vcvt_u16_f16: +** fcvtzu v0.4h, v0.4h +** ret +*/ +TEST_UNARY (vcvt_u16_f16, uint16x4_t, float16x4_t) + +/* +** test_vcvt_s16_f16: +** fcvtzs v0.4h, v0.4h +** ret +*/ +TEST_UNARY (vcvt_s16_f16, int16x4_t, float16x4_t) + +/* +** test_vcvt_f32_s32: +** scvtf v0.2s, v0.2s +** ret +*/ +TEST_UNARY (vcvt_f32_s32, float32x2_t, int32x2_t) + +/* +** test_vcvt_f32_u32: +** ucvtf v0.2s, v0.2s +** ret +*/ +TEST_UNARY (vcvt_f32_u32, float32x2_t, uint32x2_t) + +/* +** test_vcvt_f64_s64: +** scvtf d0, d0 +** ret +*/ +TEST_UNARY (vcvt_f64_s64, float64x1_t, int64x1_t) + +/* +** test_vcvt_f64_u64: +** ucvtf d0, d0 +** ret +*/ +TEST_UNARY (vcvt_f64_u64, float64x1_t, uint64x1_t) + +/* +** test_vcvt_f16_u16: +** ucvtf v0.4h, v0.4h +** ret +*/ +TEST_UNARY (vcvt_f16_u16, float16x4_t, uint16x4_t) + +/* +** test_vcvt_f16_s16: +** scvtf v0.4h, v0.4h +** ret +*/ +TEST_UNARY (vcvt_f16_s16, float16x4_t, int16x4_t) + +/* +** test_vcvtq_s32_f32: +** fcvtzs v0.4s, v0.4s +** ret +*/ +TEST_UNARY (vcvtq_s32_f32, int32x4_t, float32x4_t) + +/* +** test_vcvtq_u32_f32: +** fcvtzu v0.4s, v0.4s +** ret +*/ +TEST_UNARY (vcvtq_u32_f32, uint32x4_t, float32x4_t) + +/* +** test_vcvtq_s64_f64: +** fcvtzs v0.2d, v0.2d +** ret +*/ +TEST_UNARY (vcvtq_s64_f64, int64x2_t, float64x2_t) + +/* +** test_vcvtq_u64_f64: +** fcvtzu v0.2d, v0.2d +** ret +*/ +TEST_UNARY (vcvtq_u64_f64, uint64x2_t, float64x2_t) + +/* +** test_vcvtq_u16_f16: +** fcvtzu v0.8h, v0.8h +** ret +*/ +TEST_UNARY (vcvtq_u16_f16, uint16x8_t, float16x8_t) + +/* +** test_vcvtq_s16_f16: +** fcvtzs v0.8h, v0.8h +** ret +*/ +TEST_UNARY (vcvtq_s16_f16, int16x8_t, float16x8_t) + +/* +** test_vcvtq_f32_s32: +** scvtf v0.4s, v0.4s +** ret +*/ +TEST_UNARY (vcvtq_f32_s32, float32x4_t, int32x4_t) + +/* +** test_vcvtq_f32_u32: +** ucvtf v0.4s, v0.4s +** ret +*/ +TEST_UNARY (vcvtq_f32_u32, float32x4_t, uint32x4_t) + +/* +** test_vcvtq_f64_s64: +** scvtf v0.2d, v0.2d +** ret +*/ +TEST_UNARY (vcvtq_f64_s64, float64x2_t, int64x2_t) + +/* +** test_vcvtq_f64_u64: +** ucvtf v0.2d, v0.2d +** ret +*/ +TEST_UNARY (vcvtq_f64_u64, float64x2_t, uint64x2_t) + +/* +** test_vcvtq_f16_u16: +** ucvtf v0.8h, v0.8h +** ret +*/ +TEST_UNARY (vcvtq_f16_u16, float16x8_t, uint16x8_t) + +/* +** test_vcvtq_f16_s16: +** scvtf v0.8h, v0.8h +** ret +*/ +TEST_UNARY (vcvtq_f16_s16, float16x8_t, int16x8_t) \ No newline at end of file diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vcvt_highlo.c b/gcc/testsuite/gcc.target/aarch64/neon/vcvt_highlo.c new file mode 100644 index 000000000000..ac9f53fcb998 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vcvt_highlo.c @@ -0,0 +1,123 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vcvt_f32_f16: +** fcvtl v0.4s, v0.4h +** ret +*/ +TEST_UNARY (vcvt_f32_f16, float32x4_t, float16x4_t) + +/* +** test_vcvt_f64_f32: +** fcvtl v0.2d, v0.2s +** ret +*/ +TEST_UNARY (vcvt_f64_f32, float64x2_t, float32x2_t) + +/* +** test_vcvt_f16_f32: +** fcvtn v0.4h, v0.4s +** ret +*/ +TEST_UNARY (vcvt_f16_f32, float16x4_t, float32x4_t) + +/* +** test_vcvt_f32_f64: +** fcvtn v0.2s, v0.2d +** ret +*/ +TEST_UNARY (vcvt_f32_f64, float32x2_t, float64x2_t) + +/* +** test_vcvt_high_f32_f16: +** fcvtl2 v0.4s, v0.8h +** ret +*/ +TEST_UNARY (vcvt_high_f32_f16, float32x4_t, float16x8_t) + +/* +** test_vcvt_high_f64_f32: +** fcvtl2 v0.2d, v0.4s +** ret +*/ +TEST_UNARY (vcvt_high_f64_f32, float64x2_t, float32x4_t) + +/* +** test_vcvt_high_f16_f32: +** fcvtn2 v0.8h, v1.4s +** ret +*/ +TEST_BINARY (vcvt_high_f16_f32, float16x8_t, float16x4_t, float32x4_t) + +/* +** test_vcvt_high_f32_f64: +** fcvtn2 v0.4s, v1.2d +** ret +*/ +TEST_BINARY (vcvt_high_f32_f64, float32x4_t, float32x2_t, float64x2_t) + +/* +** test_vcvtx_f32_f64: +** fcvtxn v0.2s, v0.2d +** ret +*/ +TEST_UNARY (vcvtx_f32_f64, float32x2_t, float64x2_t) + +/* +** test_vcvtx_high_f32_f64: +** fcvtxn2 v0.4s, v1.2d +** ret +*/ +TEST_BINARY (vcvtx_high_f32_f64, float32x4_t, float32x2_t, float64x2_t) + +/* +** test_vcvtxd_f32_f64: +** fcvtxn s0, d0 +** ret +*/ +TEST_UNARY (vcvtxd_f32_f64, float32_t, float64_t) + +/* +** test_vcvt_bf16_f32: +** bfcvtn v0.4h, v0.4s +** ret +*/ +TEST_UNARY (vcvt_bf16_f32, bfloat16x4_t, float32x4_t) + +/* +** test_vcvtq_high_bf16_f32: +** bfcvtn2 v0.8h, v1.4s +** ret +*/ +TEST_BINARY (vcvtq_high_bf16_f32, bfloat16x8_t, bfloat16x8_t, float32x4_t) + +/* +** test_vcvtq_low_bf16_f32: +** bfcvtn v0.4h, v0.4s +** ret +*/ +TEST_UNARY (vcvtq_low_bf16_f32, bfloat16x8_t, float32x4_t) + +/* +** test_vcvt_f32_bf16: +** shll v0.4s, v0.4h, #16 +** ret +*/ +TEST_UNARY (vcvt_f32_bf16, float32x4_t, bfloat16x4_t) + +/* +** test_vcvtq_high_f32_bf16: +** shll2 v0.4s, v0.8h, #16 +** ret +*/ +TEST_UNARY (vcvtq_high_f32_bf16, float32x4_t, bfloat16x8_t) + +/* +** test_vcvtq_low_f32_bf16: +** shll v0.4s, v0.4h, #16 +** ret +*/ +TEST_UNARY (vcvtq_low_f32_bf16, float32x4_t, bfloat16x8_t) \ No newline at end of file diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vcvt_n.c b/gcc/testsuite/gcc.target/aarch64/neon/vcvt_n.c new file mode 100644 index 000000000000..e2625c0a1824 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vcvt_n.c @@ -0,0 +1,172 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vcvt_n_s32_f32: +** fcvtzs v0.2s, v0.2s, #16 +** ret +*/ +TEST_UNARY_N (vcvt_n_s32_f32, int32x2_t, float32x2_t, 16) + +/* +** test_vcvt_n_u32_f32: +** fcvtzu v0.2s, v0.2s, #16 +** ret +*/ +TEST_UNARY_N (vcvt_n_u32_f32, uint32x2_t, float32x2_t, 16) + +/* +** test_vcvt_n_s64_f64: +** fcvtzs d0, d0, #16 +** ret +*/ +TEST_UNARY_N (vcvt_n_s64_f64, int64x1_t, float64x1_t, 16) + +/* +** test_vcvt_n_u64_f64: +** fcvtzu d0, d0, #16 +** ret +*/ +TEST_UNARY_N (vcvt_n_u64_f64, uint64x1_t, float64x1_t, 16) + +/* +** test_vcvt_n_u16_f16: +** fcvtzu v0.4h, v0.4h, #16 +** ret +*/ +TEST_UNARY_N (vcvt_n_u16_f16, uint16x4_t, float16x4_t, 16) + +/* +** test_vcvt_n_s16_f16: +** fcvtzs v0.4h, v0.4h, #16 +** ret +*/ +TEST_UNARY_N (vcvt_n_s16_f16, int16x4_t, float16x4_t, 16) + +/* +** test_vcvt_n_f32_s32: +** scvtf v0.2s, v0.2s, #16 +** ret +*/ +TEST_UNARY_N (vcvt_n_f32_s32, float32x2_t, int32x2_t, 16) + +/* +** test_vcvt_n_f32_u32: +** ucvtf v0.2s, v0.2s, #16 +** ret +*/ +TEST_UNARY_N (vcvt_n_f32_u32, float32x2_t, uint32x2_t, 16) + +/* +** test_vcvt_n_f64_s64: +** scvtf d0, d0, #16 +** ret +*/ +TEST_UNARY_N (vcvt_n_f64_s64, float64x1_t, int64x1_t, 16) + +/* +** test_vcvt_n_f64_u64: +** ucvtf d0, d0, #16 +** ret +*/ +TEST_UNARY_N (vcvt_n_f64_u64, float64x1_t, uint64x1_t, 16) + +/* +** test_vcvt_n_f16_u16: +** ucvtf v0.4h, v0.4h, #16 +** ret +*/ +TEST_UNARY_N (vcvt_n_f16_u16, float16x4_t, uint16x4_t, 16) + +/* +** test_vcvt_n_f16_s16: +** scvtf v0.4h, v0.4h, #16 +** ret +*/ +TEST_UNARY_N (vcvt_n_f16_s16, float16x4_t, int16x4_t, 16) + +/* +** test_vcvtq_n_s32_f32: +** fcvtzs v0.4s, v0.4s, #16 +** ret +*/ +TEST_UNARY_N (vcvtq_n_s32_f32, int32x4_t, float32x4_t, 16) + +/* +** test_vcvtq_n_u32_f32: +** fcvtzu v0.4s, v0.4s, #16 +** ret +*/ +TEST_UNARY_N (vcvtq_n_u32_f32, uint32x4_t, float32x4_t, 16) + +/* +** test_vcvtq_n_s64_f64: +** fcvtzs v0.2d, v0.2d, #16 +** ret +*/ +TEST_UNARY_N (vcvtq_n_s64_f64, int64x2_t, float64x2_t, 16) + +/* +** test_vcvtq_n_u64_f64: +** fcvtzu v0.2d, v0.2d, #16 +** ret +*/ +TEST_UNARY_N (vcvtq_n_u64_f64, uint64x2_t, float64x2_t, 16) + +/* +** test_vcvtq_n_u16_f16: +** fcvtzu v0.8h, v0.8h, #16 +** ret +*/ +TEST_UNARY_N (vcvtq_n_u16_f16, uint16x8_t, float16x8_t, 16) + +/* +** test_vcvtq_n_s16_f16: +** fcvtzs v0.8h, v0.8h, #16 +** ret +*/ +TEST_UNARY_N (vcvtq_n_s16_f16, int16x8_t, float16x8_t, 16) + +/* +** test_vcvtq_n_f32_s32: +** scvtf v0.4s, v0.4s, #16 +** ret +*/ +TEST_UNARY_N (vcvtq_n_f32_s32, float32x4_t, int32x4_t, 16) + +/* +** test_vcvtq_n_f32_u32: +** ucvtf v0.4s, v0.4s, #16 +** ret +*/ +TEST_UNARY_N (vcvtq_n_f32_u32, float32x4_t, uint32x4_t, 16) + +/* +** test_vcvtq_n_f64_s64: +** scvtf v0.2d, v0.2d, #16 +** ret +*/ +TEST_UNARY_N (vcvtq_n_f64_s64, float64x2_t, int64x2_t, 16) + +/* +** test_vcvtq_n_f64_u64: +** ucvtf v0.2d, v0.2d, #16 +** ret +*/ +TEST_UNARY_N (vcvtq_n_f64_u64, float64x2_t, uint64x2_t, 16) + +/* +** test_vcvtq_n_f16_u16: +** ucvtf v0.8h, v0.8h, #16 +** ret +*/ +TEST_UNARY_N (vcvtq_n_f16_u16, float16x8_t, uint16x8_t, 16) + +/* +** test_vcvtq_n_f16_s16: +** scvtf v0.8h, v0.8h, #16 +** ret +*/ +TEST_UNARY_N (vcvtq_n_f16_s16, float16x8_t, int16x8_t, 16) \ No newline at end of file diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vcvta.c b/gcc/testsuite/gcc.target/aarch64/neon/vcvta.c new file mode 100644 index 000000000000..51dbefb082e4 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vcvta.c @@ -0,0 +1,90 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vcvta_s32_f32: +** fcvtas v0.2s, v0.2s +** ret +*/ +TEST_UNARY (vcvta_s32_f32, int32x2_t, float32x2_t) + +/* +** test_vcvta_u32_f32: +** fcvtau v0.2s, v0.2s +** ret +*/ +TEST_UNARY (vcvta_u32_f32, uint32x2_t, float32x2_t) + +/* +** test_vcvta_s64_f64: +** fcvtas x0, d0 +** fmov d0, x0 +** ret +*/ +TEST_UNARY (vcvta_s64_f64, int64x1_t, float64x1_t) + +/* +** test_vcvta_u64_f64: +** fcvtau x0, d0 +** fmov d0, x0 +** ret +*/ +TEST_UNARY (vcvta_u64_f64, uint64x1_t, float64x1_t) + +/* +** test_vcvta_u16_f16: +** fcvtau v0.4h, v0.4h +** ret +*/ +TEST_UNARY (vcvta_u16_f16, uint16x4_t, float16x4_t) + +/* +** test_vcvta_s16_f16: +** fcvtas v0.4h, v0.4h +** ret +*/ +TEST_UNARY (vcvta_s16_f16, int16x4_t, float16x4_t) + +/* +** test_vcvtaq_s32_f32: +** fcvtas v0.4s, v0.4s +** ret +*/ +TEST_UNARY (vcvtaq_s32_f32, int32x4_t, float32x4_t) + +/* +** test_vcvtaq_u32_f32: +** fcvtau v0.4s, v0.4s +** ret +*/ +TEST_UNARY (vcvtaq_u32_f32, uint32x4_t, float32x4_t) + +/* +** test_vcvtaq_s64_f64: +** fcvtas v0.2d, v0.2d +** ret +*/ +TEST_UNARY (vcvtaq_s64_f64, int64x2_t, float64x2_t) + +/* +** test_vcvtaq_u64_f64: +** fcvtau v0.2d, v0.2d +** ret +*/ +TEST_UNARY (vcvtaq_u64_f64, uint64x2_t, float64x2_t) + +/* +** test_vcvtaq_u16_f16: +** fcvtau v0.8h, v0.8h +** ret +*/ +TEST_UNARY (vcvtaq_u16_f16, uint16x8_t, float16x8_t) + +/* +** test_vcvtaq_s16_f16: +** fcvtas v0.8h, v0.8h +** ret +*/ +TEST_UNARY (vcvtaq_s16_f16, int16x8_t, float16x8_t) \ No newline at end of file diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vcvtd.c b/gcc/testsuite/gcc.target/aarch64/neon/vcvtd.c new file mode 100644 index 000000000000..c8620c29a0fd --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vcvtd.c @@ -0,0 +1,158 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vcvtd_s32_f64: +** fcvtzs w0, d0 +** ret +*/ +TEST_UNARY (vcvtd_s32_f64, int32_t, float64_t) + +/* +** test_vcvtd_u32_f64: +** fcvtzu w0, d0 +** ret +*/ +TEST_UNARY (vcvtd_u32_f64, uint32_t, float64_t) + +/* +** test_vcvtd_s64_f64: +** fcvtzs x0, d0 +** ret +*/ +TEST_UNARY (vcvtd_s64_f64, int64_t, float64_t) + +/* +** test_vcvtd_u64_f64: +** fcvtzu x0, d0 +** ret +*/ +TEST_UNARY (vcvtd_u64_f64, uint64_t, float64_t) + +/* +** test_vcvtd_f64_s64: +** scvtf d0, x0 +** ret +*/ +TEST_UNARY (vcvtd_f64_s64, float64_t, int64_t) + +/* +** test_vcvtd_f64_u64: +** ucvtf d0, x0 +** ret +*/ +TEST_UNARY (vcvtd_f64_u64, float64_t, uint64_t) + +/* +** test_vcvtad_s32_f64: +** fcvtas w0, d0 +** ret +*/ +TEST_UNARY (vcvtad_s32_f64, int32_t, float64_t) + +/* +** test_vcvtad_u32_f64: +** fcvtau w0, d0 +** ret +*/ +TEST_UNARY (vcvtad_u32_f64, uint32_t, float64_t) + +/* +** test_vcvtad_s64_f64: +** fcvtas x0, d0 +** ret +*/ +TEST_UNARY (vcvtad_s64_f64, int64_t, float64_t) + +/* +** test_vcvtad_u64_f64: +** fcvtau x0, d0 +** ret +*/ +TEST_UNARY (vcvtad_u64_f64, uint64_t, float64_t) + +/* +** test_vcvtmd_s32_f64: +** fcvtms w0, d0 +** ret +*/ +TEST_UNARY (vcvtmd_s32_f64, int32_t, float64_t) + +/* +** test_vcvtmd_u32_f64: +** fcvtmu w0, d0 +** ret +*/ +TEST_UNARY (vcvtmd_u32_f64, uint32_t, float64_t) + +/* +** test_vcvtmd_s64_f64: +** fcvtms x0, d0 +** ret +*/ +TEST_UNARY (vcvtmd_s64_f64, int64_t, float64_t) + +/* +** test_vcvtmd_u64_f64: +** fcvtmu x0, d0 +** ret +*/ +TEST_UNARY (vcvtmd_u64_f64, uint64_t, float64_t) + +/* +** test_vcvtpd_s32_f64: +** fcvtps w0, d0 +** ret +*/ +TEST_UNARY (vcvtpd_s32_f64, int32_t, float64_t) + +/* +** test_vcvtpd_u32_f64: +** fcvtpu w0, d0 +** ret +*/ +TEST_UNARY (vcvtpd_u32_f64, uint32_t, float64_t) + +/* +** test_vcvtpd_s64_f64: +** fcvtps x0, d0 +** ret +*/ +TEST_UNARY (vcvtpd_s64_f64, int64_t, float64_t) + +/* +** test_vcvtpd_u64_f64: +** fcvtpu x0, d0 +** ret +*/ +TEST_UNARY (vcvtpd_u64_f64, uint64_t, float64_t) + +/* +** test_vcvtnd_s32_f64: +** fcvtns w0, d0 +** ret +*/ +TEST_UNARY (vcvtnd_s32_f64, int32_t, float64_t) + +/* +** test_vcvtnd_u32_f64: +** fcvtnu w0, d0 +** ret +*/ +TEST_UNARY (vcvtnd_u32_f64, uint32_t, float64_t) + +/* +** test_vcvtnd_s64_f64: +** fcvtns x0, d0 +** ret +*/ +TEST_UNARY (vcvtnd_s64_f64, int64_t, float64_t) + +/* +** test_vcvtnd_u64_f64: +** fcvtnu x0, d0 +** ret +*/ +TEST_UNARY (vcvtnd_u64_f64, uint64_t, float64_t) diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vcvtds_n.c b/gcc/testsuite/gcc.target/aarch64/neon/vcvtds_n.c new file mode 100644 index 000000000000..36b2da1cf49b --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vcvtds_n.c @@ -0,0 +1,59 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vcvtd_n_s64_f64: +** fcvtzs x0, d0, #16 +** ret +*/ +TEST_UNARY_N (vcvtd_n_s64_f64, int64_t, float64_t, 16) + +/* +** test_vcvtd_n_u64_f64: +** fcvtzu x0, d0, #16 +** ret +*/ +TEST_UNARY_N (vcvtd_n_u64_f64, uint64_t, float64_t, 16) + +/* +** test_vcvtd_n_f64_s64: +** scvtf d0, x0, #16 +** ret +*/ +TEST_UNARY_N (vcvtd_n_f64_s64, float64_t, int64_t, 16) + +/* +** test_vcvtd_n_f64_u64: +** ucvtf d0, x0, #16 +** ret +*/ +TEST_UNARY_N (vcvtd_n_f64_u64, float64_t, uint64_t, 16) +/* +** test_vcvts_n_s32_f32: +** fcvtzs w0, s0, #16 +** ret +*/ +TEST_UNARY_N (vcvts_n_s32_f32, int32_t, float32_t, 16) + +/* +** test_vcvts_n_u32_f32: +** fcvtzu w0, s0, #16 +** ret +*/ +TEST_UNARY_N (vcvts_n_u32_f32, uint32_t, float32_t, 16) + +/* +** test_vcvts_n_f32_s32: +** scvtf s0, w0, #16 +** ret +*/ +TEST_UNARY_N (vcvts_n_f32_s32, float32_t, int32_t, 16) + +/* +** test_vcvts_n_f32_u32: +** ucvtf s0, w0, #16 +** ret +*/ +TEST_UNARY_N (vcvts_n_f32_u32, float32_t, uint32_t, 16) \ No newline at end of file diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vcvtm.c b/gcc/testsuite/gcc.target/aarch64/neon/vcvtm.c new file mode 100644 index 000000000000..8fb70b8d405e --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vcvtm.c @@ -0,0 +1,90 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vcvtm_s32_f32: +** fcvtms v0.2s, v0.2s +** ret +*/ +TEST_UNARY (vcvtm_s32_f32, int32x2_t, float32x2_t) + +/* +** test_vcvtm_u32_f32: +** fcvtmu v0.2s, v0.2s +** ret +*/ +TEST_UNARY (vcvtm_u32_f32, uint32x2_t, float32x2_t) + +/* +** test_vcvtm_s64_f64: +** fcvtms x0, d0 +** fmov d0, x0 +** ret +*/ +TEST_UNARY (vcvtm_s64_f64, int64x1_t, float64x1_t) + +/* +** test_vcvtm_u64_f64: +** fcvtmu x0, d0 +** fmov d0, x0 +** ret +*/ +TEST_UNARY (vcvtm_u64_f64, uint64x1_t, float64x1_t) + +/* +** test_vcvtm_u16_f16: +** fcvtmu v0.4h, v0.4h +** ret +*/ +TEST_UNARY (vcvtm_u16_f16, uint16x4_t, float16x4_t) + +/* +** test_vcvtm_s16_f16: +** fcvtms v0.4h, v0.4h +** ret +*/ +TEST_UNARY (vcvtm_s16_f16, int16x4_t, float16x4_t) + +/* +** test_vcvtmq_s32_f32: +** fcvtms v0.4s, v0.4s +** ret +*/ +TEST_UNARY (vcvtmq_s32_f32, int32x4_t, float32x4_t) + +/* +** test_vcvtmq_u32_f32: +** fcvtmu v0.4s, v0.4s +** ret +*/ +TEST_UNARY (vcvtmq_u32_f32, uint32x4_t, float32x4_t) + +/* +** test_vcvtmq_s64_f64: +** fcvtms v0.2d, v0.2d +** ret +*/ +TEST_UNARY (vcvtmq_s64_f64, int64x2_t, float64x2_t) + +/* +** test_vcvtmq_u64_f64: +** fcvtmu v0.2d, v0.2d +** ret +*/ +TEST_UNARY (vcvtmq_u64_f64, uint64x2_t, float64x2_t) + +/* +** test_vcvtmq_u16_f16: +** fcvtmu v0.8h, v0.8h +** ret +*/ +TEST_UNARY (vcvtmq_u16_f16, uint16x8_t, float16x8_t) + +/* +** test_vcvtmq_s16_f16: +** fcvtms v0.8h, v0.8h +** ret +*/ +TEST_UNARY (vcvtmq_s16_f16, int16x8_t, float16x8_t) \ No newline at end of file diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vcvtn.c b/gcc/testsuite/gcc.target/aarch64/neon/vcvtn.c new file mode 100644 index 000000000000..2d5daa044395 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vcvtn.c @@ -0,0 +1,90 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vcvtn_s32_f32: +** fcvtns v0.2s, v0.2s +** ret +*/ +TEST_UNARY (vcvtn_s32_f32, int32x2_t, float32x2_t) + +/* +** test_vcvtn_u32_f32: +** fcvtnu v0.2s, v0.2s +** ret +*/ +TEST_UNARY (vcvtn_u32_f32, uint32x2_t, float32x2_t) + +/* +** test_vcvtn_s64_f64: +** fcvtns x0, d0 +** fmov d0, x0 +** ret +*/ +TEST_UNARY (vcvtn_s64_f64, int64x1_t, float64x1_t) + +/* +** test_vcvtn_u64_f64: +** fcvtnu x0, d0 +** fmov d0, x0 +** ret +*/ +TEST_UNARY (vcvtn_u64_f64, uint64x1_t, float64x1_t) + +/* +** test_vcvtn_u16_f16: +** fcvtnu v0.4h, v0.4h +** ret +*/ +TEST_UNARY (vcvtn_u16_f16, uint16x4_t, float16x4_t) + +/* +** test_vcvtn_s16_f16: +** fcvtns v0.4h, v0.4h +** ret +*/ +TEST_UNARY (vcvtn_s16_f16, int16x4_t, float16x4_t) + +/* +** test_vcvtnq_s32_f32: +** fcvtns v0.4s, v0.4s +** ret +*/ +TEST_UNARY (vcvtnq_s32_f32, int32x4_t, float32x4_t) + +/* +** test_vcvtnq_u32_f32: +** fcvtnu v0.4s, v0.4s +** ret +*/ +TEST_UNARY (vcvtnq_u32_f32, uint32x4_t, float32x4_t) + +/* +** test_vcvtnq_s64_f64: +** fcvtns v0.2d, v0.2d +** ret +*/ +TEST_UNARY (vcvtnq_s64_f64, int64x2_t, float64x2_t) + +/* +** test_vcvtnq_u64_f64: +** fcvtnu v0.2d, v0.2d +** ret +*/ +TEST_UNARY (vcvtnq_u64_f64, uint64x2_t, float64x2_t) + +/* +** test_vcvtnq_u16_f16: +** fcvtnu v0.8h, v0.8h +** ret +*/ +TEST_UNARY (vcvtnq_u16_f16, uint16x8_t, float16x8_t) + +/* +** test_vcvtnq_s16_f16: +** fcvtns v0.8h, v0.8h +** ret +*/ +TEST_UNARY (vcvtnq_s16_f16, int16x8_t, float16x8_t) \ No newline at end of file diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vcvtp.c b/gcc/testsuite/gcc.target/aarch64/neon/vcvtp.c new file mode 100644 index 000000000000..945bd3dd68b4 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vcvtp.c @@ -0,0 +1,90 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vcvtp_s32_f32: +** fcvtps v0.2s, v0.2s +** ret +*/ +TEST_UNARY (vcvtp_s32_f32, int32x2_t, float32x2_t) + +/* +** test_vcvtp_u32_f32: +** fcvtpu v0.2s, v0.2s +** ret +*/ +TEST_UNARY (vcvtp_u32_f32, uint32x2_t, float32x2_t) + +/* +** test_vcvtp_s64_f64: +** fcvtps x0, d0 +** fmov d0, x0 +** ret +*/ +TEST_UNARY (vcvtp_s64_f64, int64x1_t, float64x1_t) + +/* +** test_vcvtp_u64_f64: +** fcvtpu x0, d0 +** fmov d0, x0 +** ret +*/ +TEST_UNARY (vcvtp_u64_f64, uint64x1_t, float64x1_t) + +/* +** test_vcvtp_u16_f16: +** fcvtpu v0.4h, v0.4h +** ret +*/ +TEST_UNARY (vcvtp_u16_f16, uint16x4_t, float16x4_t) + +/* +** test_vcvtp_s16_f16: +** fcvtps v0.4h, v0.4h +** ret +*/ +TEST_UNARY (vcvtp_s16_f16, int16x4_t, float16x4_t) + +/* +** test_vcvtpq_s32_f32: +** fcvtps v0.4s, v0.4s +** ret +*/ +TEST_UNARY (vcvtpq_s32_f32, int32x4_t, float32x4_t) + +/* +** test_vcvtpq_u32_f32: +** fcvtpu v0.4s, v0.4s +** ret +*/ +TEST_UNARY (vcvtpq_u32_f32, uint32x4_t, float32x4_t) + +/* +** test_vcvtpq_s64_f64: +** fcvtps v0.2d, v0.2d +** ret +*/ +TEST_UNARY (vcvtpq_s64_f64, int64x2_t, float64x2_t) + +/* +** test_vcvtpq_u64_f64: +** fcvtpu v0.2d, v0.2d +** ret +*/ +TEST_UNARY (vcvtpq_u64_f64, uint64x2_t, float64x2_t) + +/* +** test_vcvtpq_u16_f16: +** fcvtpu v0.8h, v0.8h +** ret +*/ +TEST_UNARY (vcvtpq_u16_f16, uint16x8_t, float16x8_t) + +/* +** test_vcvtpq_s16_f16: +** fcvtps v0.8h, v0.8h +** ret +*/ +TEST_UNARY (vcvtpq_s16_f16, int16x8_t, float16x8_t) \ No newline at end of file diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vcvts.c b/gcc/testsuite/gcc.target/aarch64/neon/vcvts.c new file mode 100644 index 000000000000..f7fdded8a977 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/neon/vcvts.c @@ -0,0 +1,158 @@ +/* { dg-do compile } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "arm_neon_test.h" + +/* +** test_vcvts_s32_f32: +** fcvtzs w0, s0 +** ret +*/ +TEST_UNARY (vcvts_s32_f32, int32_t, float32_t) + +/* +** test_vcvts_u32_f32: +** fcvtzu w0, s0 +** ret +*/ +TEST_UNARY (vcvts_u32_f32, uint32_t, float32_t) + +/* +** test_vcvts_s64_f32: +** fcvtzs x0, s0 +** ret +*/ +TEST_UNARY (vcvts_s64_f32, int64_t, float32_t) + +/* +** test_vcvts_u64_f32: +** fcvtzu x0, s0 +** ret +*/ +TEST_UNARY (vcvts_u64_f32, uint64_t, float32_t) + +/* +** test_vcvts_f32_s32: +** scvtf s0, w0 +** ret +*/ +TEST_UNARY (vcvts_f32_s32, float32_t, int32_t) + +/* +** test_vcvts_f32_u32: +** ucvtf s0, w0 +** ret +*/ +TEST_UNARY (vcvts_f32_u32, float32_t, uint32_t) + +/* +** test_vcvtas_s32_f32: +** fcvtas w0, s0 +** ret +*/ +TEST_UNARY (vcvtas_s32_f32, int32_t, float32_t) + +/* +** test_vcvtas_u32_f32: +** fcvtau w0, s0 +** ret +*/ +TEST_UNARY (vcvtas_u32_f32, uint32_t, float32_t) + +/* +** test_vcvtas_s64_f32: +** fcvtas x0, s0 +** ret +*/ +TEST_UNARY (vcvtas_s64_f32, int64_t, float32_t) + +/* +** test_vcvtas_u64_f32: +** fcvtau x0, s0 +** ret +*/ +TEST_UNARY (vcvtas_u64_f32, uint64_t, float32_t) + +/* +** test_vcvtms_s32_f32: +** fcvtms w0, s0 +** ret +*/ +TEST_UNARY (vcvtms_s32_f32, int32_t, float32_t) + +/* +** test_vcvtms_u32_f32: +** fcvtmu w0, s0 +** ret +*/ +TEST_UNARY (vcvtms_u32_f32, uint32_t, float32_t) + +/* +** test_vcvtms_s64_f32: +** fcvtms x0, s0 +** ret +*/ +TEST_UNARY (vcvtms_s64_f32, int64_t, float32_t) + +/* +** test_vcvtms_u64_f32: +** fcvtmu x0, s0 +** ret +*/ +TEST_UNARY (vcvtms_u64_f32, uint64_t, float32_t) + +/* +** test_vcvtps_s32_f32: +** fcvtps w0, s0 +** ret +*/ +TEST_UNARY (vcvtps_s32_f32, int32_t, float32_t) + +/* +** test_vcvtps_u32_f32: +** fcvtpu w0, s0 +** ret +*/ +TEST_UNARY (vcvtps_u32_f32, uint32_t, float32_t) + +/* +** test_vcvtps_s64_f32: +** fcvtps x0, s0 +** ret +*/ +TEST_UNARY (vcvtps_s64_f32, int64_t, float32_t) + +/* +** test_vcvtps_u64_f32: +** fcvtpu x0, s0 +** ret +*/ +TEST_UNARY (vcvtps_u64_f32, uint64_t, float32_t) + +/* +** test_vcvtns_s32_f32: +** fcvtns w0, s0 +** ret +*/ +TEST_UNARY (vcvtns_s32_f32, int32_t, float32_t) + +/* +** test_vcvtns_u32_f32: +** fcvtnu w0, s0 +** ret +*/ +TEST_UNARY (vcvtns_u32_f32, uint32_t, float32_t) + +/* +** test_vcvtns_s64_f32: +** fcvtns x0, s0 +** ret +*/ +TEST_UNARY (vcvtns_s64_f32, int64_t, float32_t) + +/* +** test_vcvtns_u64_f32: +** fcvtnu x0, s0 +** ret +*/ +TEST_UNARY (vcvtns_u64_f32, uint64_t, float32_t) -- 2.34.1 From david.faust@oss.qualcomm.com Tue Nov 3 02:09:09 2026 From: david.faust@oss.qualcomm.com (David Faust) Date: Mon, 2 Nov 2026 18:09:09 -0800 Subject: [PATCH 2/2] bpf: CO-RE consumer of deferred constants In-Reply-To: <20261101025438.271424-1-yjn@yjn-systems.com> References: <20261101025158.271216-1-yjn@yjn-systems.com> <20261101025438.271424-1-yjn@yjn-systems.com> Message-ID: <9d858e82-a769-4fcb-af3e-3b90e508b0dc@oss.qualcomm.com> On 10/31/26 7:54 PM, York Jasper Niebuhr wrote: > Use deferred constants to preserve semantic information required for BPF > CO-RE relocations. > > Mark enum types for deferred enum values and record types carrying > "preserve_access_index" for deferred field offsets. Deferred constants > encountered during BPF lowering are either turned into CO-RE relocations > or resolved to their ordinary compile-time values when no relocation is > requested. > > Add a "preserve_enum_values" attribute for enum types. Enumerators of a > type carrying this attribute automatically generate > BPF_RELO_ENUMVAL_VALUE relocations. > > Remove the bpf_enum_mappings workaround in favor of direct enum identity > recovery from deferred cst arguments to __builtin_preserve_enum_value. > > For record types carrying "preserve_access_index", deferred field > offsets originating from offsetof expressions are converted into > BPF_RELO_FIELD_BYTE_OFFSET relocations. > > BPF CO-RE relocations can not currently be emitted for static data. Add > an IPA pass which resolves deferred constants in static initializers > before the generic deferred-constant barrier. Initializers which would > require CO-RE relocations are diagnosed. Support for such initializers > could be added in the future by generating relocated runtime > initialization code, for cases such as: > > struct task_struct { > ... > int x; > ... > } __attribute__((preserve_access_index)); > > static size_t OFF_X = offsetof (struct task_struct, x); > So I gave this a try to see if the above static initializer thing is an issue for the kernel selftests. Instead I encountered another problem when using an enumerator to index into an array, e.g.: enum bpf_map_type { BPF_MAP_TYPE_START, BPF_MAP_TYPE_RINGBUF, __BPF_MAP_TYPE_MAX }; int a[BPF_MAP_TYPE_RINGBUF]; $ ./xgcc -B. ~/playpen/bpf/defer.c -c /home/dfaust/playpen/bpf/defer.c:8:5: error: variably modified ?a? at file scope 8 | int a[BPF_MAP_TYPE_RINGBUF]; | ^ It's coming from this spot in c-decl.cc grokdeclarator:7444 else if ((decl_context == NORMAL || decl_context == FIELD) && current_scope == file_scope) { error_at (loc, "variably modified %qE at file scope", name); size = integer_one_node; } Not sure whether this indicates a bug in the C/middle-end portion, or due to how it is being used from the BPF backend, e.g. if the plugin_finish_type hook needs to take more care rather than just marking any enumeral type. From pan2.li@intel.com Tue Nov 3 02:08:48 2026 From: pan2.li@intel.com (pan2.li@intel.com) Date: Tue, 3 Nov 2026 10:08:48 +0800 Subject: [PATCH v1 1/4] RISC-V: Fix reg overlap for vs1 of the widening float reduction In-Reply-To: <20261103021109.3293351-1-pan2.li@intel.com> References: <20261103021109.3293351-1-pan2.li@intel.com> Message-ID: <20261103021109.3293351-2-pan2.li@intel.com> From: Pan Li Like the widening integer reduction, the vs1 of the widening float reduction (aka vfwredosum.vs and vfwredusum.vs) is read with EEW = 2 * SEW while the vs2 is read with EEW = SEW. The section 5.2 of the vector spec reserves any encoding in which one vector register supplies source operands with two or more different EEWs. Thus, the vs1 must not fall inside the vs2 register group, but we may have below asm dump when the vs1 comes from the vs2 register group. vfwredosum.vs v4,v4,v5 Take the Wn3 constraint for the operand 4 (aka vs1) of the widening float reduction. See below issue of the riscv-isa-manual for more details. https://github.com/riscv/riscv-isa-manual/issues/2350 gcc/ChangeLog: * config/riscv/vector.md: Take the Wn3 constraint for the operand 4 of the widening float reduction. Signed-off-by: Pan Li --- gcc/config/riscv/vector.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md index 8a97f35967f..7fbee404694 100644 --- a/gcc/config/riscv/vector.md +++ b/gcc/config/riscv/vector.md @@ -8240,7 +8240,7 @@ (define_insn "@pred_" (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (unspec: [ (match_operand:VF_HS 3 "register_operand" " vr, vr") - (match_operand: 4 "register_operand" " vr, vr") + (match_operand: 4 "register_operand" " Wn3, Wn3") ] ANY_FWREDUC_SUM) (match_operand: 2 "vector_merge_operand" " vu, 0")] UNSPEC_REDUC))] "TARGET_VECTOR" -- 2.43.0 From pan2.li@intel.com Tue Nov 3 02:08:47 2026 From: pan2.li@intel.com (pan2.li@intel.com) Date: Tue, 3 Nov 2026 10:08:47 +0800 Subject: [PATCH v1 0/4] RISC-V: Allow RVV register overlap for vfwredosum/vfwredusum.vs Message-ID: <20261103021109.3293351-1-pan2.li@intel.com> From: Pan Li Like v[sz]ext.vf8, we continue the support for vfwredosum/vfwredusum.vs. The below test suites are passed for this patch: 1. The rv64gcv fully regression tests. Pan Li (4): RISC-V: Fix reg overlap for vs1 of the widening float reduction RISC-V: Add test cases for vfwredosum.vs reg overlap RISC-V: Add test cases for vfwredusum.vs reg overlap RISC-V: Add more test cases for vfwred[ou]sum.vs gcc/config/riscv/vector.md | 2 +- .../group_overlap/vfwredosum_vs-f16-m1.c | 29 +++++++++ .../group_overlap/vfwredosum_vs-f16-m2.c | 32 ++++++++++ .../group_overlap/vfwredosum_vs-f16-m4.c | 32 ++++++++++ .../group_overlap/vfwredosum_vs-f16-m8.c | 32 ++++++++++ .../group_overlap/vfwredosum_vs-f32-m1.c | 29 +++++++++ .../group_overlap/vfwredosum_vs-f32-m2.c | 32 ++++++++++ .../group_overlap/vfwredosum_vs-f32-m4.c | 32 ++++++++++ .../group_overlap/vfwredosum_vs-f32-m8.c | 32 ++++++++++ .../group_overlap/vfwredusum_vs-f16-m1.c | 29 +++++++++ .../group_overlap/vfwredusum_vs-f16-m2.c | 32 ++++++++++ .../group_overlap/vfwredusum_vs-f16-m4.c | 32 ++++++++++ .../group_overlap/vfwredusum_vs-f16-m8.c | 32 ++++++++++ .../group_overlap/vfwredusum_vs-f32-m1.c | 29 +++++++++ .../group_overlap/vfwredusum_vs-f32-m2.c | 32 ++++++++++ .../group_overlap/vfwredusum_vs-f32-m4.c | 32 ++++++++++ .../group_overlap/vfwredusum_vs-f32-m8.c | 32 ++++++++++ .../gcc.target/riscv/rvv/base/pr112431-63.c | 59 +++++++++++++++++++ .../gcc.target/riscv/rvv/base/pr112431-64.c | 59 +++++++++++++++++++ 19 files changed, 619 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m4.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m8.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m4.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m8.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m4.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m8.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m4.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m8.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-63.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-64.c -- 2.43.0 From pan2.li@intel.com Tue Nov 3 02:08:49 2026 From: pan2.li@intel.com (pan2.li@intel.com) Date: Tue, 3 Nov 2026 10:08:49 +0800 Subject: [PATCH v1 2/4] RISC-V: Add test cases for vfwredosum.vs reg overlap In-Reply-To: <20261103021109.3293351-1-pan2.li@intel.com> References: <20261103021109.3293351-1-pan2.li@intel.com> Message-ID: <20261103021109.3293351-3-pan2.li@intel.com> From: Pan Li Add test cases to ensure the vs1 of the vfwredosum.vs doesn't overlap the register group of the vs2. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m1.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m2.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m4.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m8.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m1.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m2.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m4.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m8.c: New test. Signed-off-by: Pan Li --- .../group_overlap/vfwredosum_vs-f16-m1.c | 29 +++++++++++++++++ .../group_overlap/vfwredosum_vs-f16-m2.c | 32 +++++++++++++++++++ .../group_overlap/vfwredosum_vs-f16-m4.c | 32 +++++++++++++++++++ .../group_overlap/vfwredosum_vs-f16-m8.c | 32 +++++++++++++++++++ .../group_overlap/vfwredosum_vs-f32-m1.c | 29 +++++++++++++++++ .../group_overlap/vfwredosum_vs-f32-m2.c | 32 +++++++++++++++++++ .../group_overlap/vfwredosum_vs-f32-m4.c | 32 +++++++++++++++++++ .../group_overlap/vfwredosum_vs-f32-m8.c | 32 +++++++++++++++++++ 8 files changed, 250 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m4.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m8.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m4.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m8.c diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m1.c new file mode 100644 index 00000000000..229bca72a3b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat32m1_t +reinterpret_f16m1_f32m1 (vfloat16m1_t v) +{ + vuint16m1_t u = __riscv_vreinterpret_v_f16m1_u16m1 (v); + vuint32m1_t wu = __riscv_vreinterpret_v_u16m1_u32m1 (u); + + return __riscv_vreinterpret_v_u32m1_f32m1 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_1( + __riscv_vsetvlmax_e16m1, + vfloat16m1_t, + vfloat32m1_t, + __riscv_vle16_v_f16m1, + reinterpret_f16m1_f32m1, + __riscv_vfwredosum_vs_f16m1_f32m1, + __riscv_vse32_v_f32m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_LMUL1_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v0,v2,v3([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v5,v1,v4([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v1,v1([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v2,v2([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m2.c new file mode 100644 index 00000000000..9905eb23ea1 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m2.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat32m2_t +reinterpret_f16m2_f32m2 (vfloat16m2_t v) +{ + vuint16m2_t u = __riscv_vreinterpret_v_f16m2_u16m2 (v); + vuint32m2_t wu = __riscv_vreinterpret_v_u16m2_u32m2 (u); + + return __riscv_vreinterpret_v_u32m2_f32m2 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e16m2, + vfloat16m2_t, + vfloat32m1_t, + vfloat32m2_t, + __riscv_vle16_v_f16m2, + reinterpret_f16m2_f32m2, + __riscv_vget_v_f32m2_f32m1, + 1, + __riscv_vfwredosum_vs_f16m2_f32m1, + __riscv_vse32_v_f32m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v4,v4,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v2,v2,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v2,v(2|3)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v4,v(4|5)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m4.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m4.c new file mode 100644 index 00000000000..6fc6bd441e7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m4.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat32m4_t +reinterpret_f16m4_f32m4 (vfloat16m4_t v) +{ + vuint16m4_t u = __riscv_vreinterpret_v_f16m4_u16m4 (v); + vuint32m4_t wu = __riscv_vreinterpret_v_u16m4_u32m4 (u); + + return __riscv_vreinterpret_v_u32m4_f32m4 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e16m4, + vfloat16m4_t, + vfloat32m1_t, + vfloat32m4_t, + __riscv_vle16_v_f16m4, + reinterpret_f16m4_f32m4, + __riscv_vget_v_f32m4_f32m1, + 3, + __riscv_vfwredosum_vs_f16m4_f32m1, + __riscv_vse32_v_f32m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v8,v8,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v4,v4,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v4,v(4|5|6|7)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v8,v(8|9|10|11)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m8.c new file mode 100644 index 00000000000..107341e14bc --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m8.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat32m8_t +reinterpret_f16m8_f32m8 (vfloat16m8_t v) +{ + vuint16m8_t u = __riscv_vreinterpret_v_f16m8_u16m8 (v); + vuint32m8_t wu = __riscv_vreinterpret_v_u16m8_u32m8 (u); + + return __riscv_vreinterpret_v_u32m8_f32m8 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e16m8, + vfloat16m8_t, + vfloat32m1_t, + vfloat32m8_t, + __riscv_vle16_v_f16m8, + reinterpret_f16m8_f32m8, + __riscv_vget_v_f32m8_f32m1, + 7, + __riscv_vfwredosum_vs_f16m8_f32m1, + __riscv_vse32_v_f32m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v16,v16,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v8,v8,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v8,v(8|9|10|11|12|13|14|15)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v16,v(16|17|18|19|20|21|22|23)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m1.c new file mode 100644 index 00000000000..9b7542959d2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat64m1_t +reinterpret_f32m1_f64m1 (vfloat32m1_t v) +{ + vuint32m1_t u = __riscv_vreinterpret_v_f32m1_u32m1 (v); + vuint64m1_t wu = __riscv_vreinterpret_v_u32m1_u64m1 (u); + + return __riscv_vreinterpret_v_u64m1_f64m1 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_1( + __riscv_vsetvlmax_e32m1, + vfloat32m1_t, + vfloat64m1_t, + __riscv_vle32_v_f32m1, + reinterpret_f32m1_f64m1, + __riscv_vfwredosum_vs_f32m1_f64m1, + __riscv_vse64_v_f64m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_LMUL1_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v0,v2,v3([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v5,v1,v4([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v1,v1([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v2,v2([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m2.c new file mode 100644 index 00000000000..6efdacc639f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m2.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat64m2_t +reinterpret_f32m2_f64m2 (vfloat32m2_t v) +{ + vuint32m2_t u = __riscv_vreinterpret_v_f32m2_u32m2 (v); + vuint64m2_t wu = __riscv_vreinterpret_v_u32m2_u64m2 (u); + + return __riscv_vreinterpret_v_u64m2_f64m2 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e32m2, + vfloat32m2_t, + vfloat64m1_t, + vfloat64m2_t, + __riscv_vle32_v_f32m2, + reinterpret_f32m2_f64m2, + __riscv_vget_v_f64m2_f64m1, + 1, + __riscv_vfwredosum_vs_f32m2_f64m1, + __riscv_vse64_v_f64m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v4,v4,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v2,v2,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v2,v(2|3)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v4,v(4|5)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m4.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m4.c new file mode 100644 index 00000000000..4d8f6eff6b6 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m4.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat64m4_t +reinterpret_f32m4_f64m4 (vfloat32m4_t v) +{ + vuint32m4_t u = __riscv_vreinterpret_v_f32m4_u32m4 (v); + vuint64m4_t wu = __riscv_vreinterpret_v_u32m4_u64m4 (u); + + return __riscv_vreinterpret_v_u64m4_f64m4 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e32m4, + vfloat32m4_t, + vfloat64m1_t, + vfloat64m4_t, + __riscv_vle32_v_f32m4, + reinterpret_f32m4_f64m4, + __riscv_vget_v_f64m4_f64m1, + 3, + __riscv_vfwredosum_vs_f32m4_f64m1, + __riscv_vse64_v_f64m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v8,v8,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v4,v4,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v4,v(4|5|6|7)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v8,v(8|9|10|11)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m8.c new file mode 100644 index 00000000000..66652766053 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m8.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat64m8_t +reinterpret_f32m8_f64m8 (vfloat32m8_t v) +{ + vuint32m8_t u = __riscv_vreinterpret_v_f32m8_u32m8 (v); + vuint64m8_t wu = __riscv_vreinterpret_v_u32m8_u64m8 (u); + + return __riscv_vreinterpret_v_u64m8_f64m8 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e32m8, + vfloat32m8_t, + vfloat64m1_t, + vfloat64m8_t, + __riscv_vle32_v_f32m8, + reinterpret_f32m8_f64m8, + __riscv_vget_v_f64m8_f64m1, + 7, + __riscv_vfwredosum_vs_f32m8_f64m1, + __riscv_vse64_v_f64m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v16,v16,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v8,v8,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v8,v(8|9|10|11|12|13|14|15)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v16,v(16|17|18|19|20|21|22|23)([^0-9]|$)} } } */ -- 2.43.0 From pan2.li@intel.com Tue Nov 3 02:08:50 2026 From: pan2.li@intel.com (pan2.li@intel.com) Date: Tue, 3 Nov 2026 10:08:50 +0800 Subject: [PATCH v1 3/4] RISC-V: Add test cases for vfwredusum.vs reg overlap In-Reply-To: <20261103021109.3293351-1-pan2.li@intel.com> References: <20261103021109.3293351-1-pan2.li@intel.com> Message-ID: <20261103021109.3293351-4-pan2.li@intel.com> From: Pan Li Add test cases to ensure the vs1 of the vfwredusum.vs doesn't overlap the register group of the vs2. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m1.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m2.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m4.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m8.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m1.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m2.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m4.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m8.c: New test. Signed-off-by: Pan Li --- .../group_overlap/vfwredusum_vs-f16-m1.c | 29 +++++++++++++++++ .../group_overlap/vfwredusum_vs-f16-m2.c | 32 +++++++++++++++++++ .../group_overlap/vfwredusum_vs-f16-m4.c | 32 +++++++++++++++++++ .../group_overlap/vfwredusum_vs-f16-m8.c | 32 +++++++++++++++++++ .../group_overlap/vfwredusum_vs-f32-m1.c | 29 +++++++++++++++++ .../group_overlap/vfwredusum_vs-f32-m2.c | 32 +++++++++++++++++++ .../group_overlap/vfwredusum_vs-f32-m4.c | 32 +++++++++++++++++++ .../group_overlap/vfwredusum_vs-f32-m8.c | 32 +++++++++++++++++++ 8 files changed, 250 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m4.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m8.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m4.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m8.c diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m1.c new file mode 100644 index 00000000000..559d7cc2b1a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat32m1_t +reinterpret_f16m1_f32m1 (vfloat16m1_t v) +{ + vuint16m1_t u = __riscv_vreinterpret_v_f16m1_u16m1 (v); + vuint32m1_t wu = __riscv_vreinterpret_v_u16m1_u32m1 (u); + + return __riscv_vreinterpret_v_u32m1_f32m1 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_1( + __riscv_vsetvlmax_e16m1, + vfloat16m1_t, + vfloat32m1_t, + __riscv_vle16_v_f16m1, + reinterpret_f16m1_f32m1, + __riscv_vfwredusum_vs_f16m1_f32m1, + __riscv_vse32_v_f32m1, + vfwredusum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_LMUL1_X2) + +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v0,v2,v3([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v5,v1,v4([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v1,v1([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v2,v2([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m2.c new file mode 100644 index 00000000000..bd13ccb60db --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m2.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat32m2_t +reinterpret_f16m2_f32m2 (vfloat16m2_t v) +{ + vuint16m2_t u = __riscv_vreinterpret_v_f16m2_u16m2 (v); + vuint32m2_t wu = __riscv_vreinterpret_v_u16m2_u32m2 (u); + + return __riscv_vreinterpret_v_u32m2_f32m2 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e16m2, + vfloat16m2_t, + vfloat32m1_t, + vfloat32m2_t, + __riscv_vle16_v_f16m2, + reinterpret_f16m2_f32m2, + __riscv_vget_v_f32m2_f32m1, + 1, + __riscv_vfwredusum_vs_f16m2_f32m1, + __riscv_vse32_v_f32m1, + vfwredusum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v4,v4,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v2,v2,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v2,v(2|3)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v4,v(4|5)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m4.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m4.c new file mode 100644 index 00000000000..e3e93a2c7c0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m4.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat32m4_t +reinterpret_f16m4_f32m4 (vfloat16m4_t v) +{ + vuint16m4_t u = __riscv_vreinterpret_v_f16m4_u16m4 (v); + vuint32m4_t wu = __riscv_vreinterpret_v_u16m4_u32m4 (u); + + return __riscv_vreinterpret_v_u32m4_f32m4 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e16m4, + vfloat16m4_t, + vfloat32m1_t, + vfloat32m4_t, + __riscv_vle16_v_f16m4, + reinterpret_f16m4_f32m4, + __riscv_vget_v_f32m4_f32m1, + 3, + __riscv_vfwredusum_vs_f16m4_f32m1, + __riscv_vse32_v_f32m1, + vfwredusum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v8,v8,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v4,v4,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v4,v(4|5|6|7)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v8,v(8|9|10|11)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m8.c new file mode 100644 index 00000000000..6e80ce6d797 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f16-m8.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat32m8_t +reinterpret_f16m8_f32m8 (vfloat16m8_t v) +{ + vuint16m8_t u = __riscv_vreinterpret_v_f16m8_u16m8 (v); + vuint32m8_t wu = __riscv_vreinterpret_v_u16m8_u32m8 (u); + + return __riscv_vreinterpret_v_u32m8_f32m8 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e16m8, + vfloat16m8_t, + vfloat32m1_t, + vfloat32m8_t, + __riscv_vle16_v_f16m8, + reinterpret_f16m8_f32m8, + __riscv_vget_v_f32m8_f32m1, + 7, + __riscv_vfwredusum_vs_f16m8_f32m1, + __riscv_vse32_v_f32m1, + vfwredusum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v16,v16,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v8,v8,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v8,v(8|9|10|11|12|13|14|15)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v16,v(16|17|18|19|20|21|22|23)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m1.c new file mode 100644 index 00000000000..0b4d54861a5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat64m1_t +reinterpret_f32m1_f64m1 (vfloat32m1_t v) +{ + vuint32m1_t u = __riscv_vreinterpret_v_f32m1_u32m1 (v); + vuint64m1_t wu = __riscv_vreinterpret_v_u32m1_u64m1 (u); + + return __riscv_vreinterpret_v_u64m1_f64m1 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_1( + __riscv_vsetvlmax_e32m1, + vfloat32m1_t, + vfloat64m1_t, + __riscv_vle32_v_f32m1, + reinterpret_f32m1_f64m1, + __riscv_vfwredusum_vs_f32m1_f64m1, + __riscv_vse64_v_f64m1, + vfwredusum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_LMUL1_X2) + +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v0,v2,v3([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v5,v1,v4([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v1,v1([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v2,v2([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m2.c new file mode 100644 index 00000000000..e41a7c2fc4d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m2.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat64m2_t +reinterpret_f32m2_f64m2 (vfloat32m2_t v) +{ + vuint32m2_t u = __riscv_vreinterpret_v_f32m2_u32m2 (v); + vuint64m2_t wu = __riscv_vreinterpret_v_u32m2_u64m2 (u); + + return __riscv_vreinterpret_v_u64m2_f64m2 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e32m2, + vfloat32m2_t, + vfloat64m1_t, + vfloat64m2_t, + __riscv_vle32_v_f32m2, + reinterpret_f32m2_f64m2, + __riscv_vget_v_f64m2_f64m1, + 1, + __riscv_vfwredusum_vs_f32m2_f64m1, + __riscv_vse64_v_f64m1, + vfwredusum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v4,v4,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v2,v2,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v2,v(2|3)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v4,v(4|5)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m4.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m4.c new file mode 100644 index 00000000000..bd0c2ced267 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m4.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat64m4_t +reinterpret_f32m4_f64m4 (vfloat32m4_t v) +{ + vuint32m4_t u = __riscv_vreinterpret_v_f32m4_u32m4 (v); + vuint64m4_t wu = __riscv_vreinterpret_v_u32m4_u64m4 (u); + + return __riscv_vreinterpret_v_u64m4_f64m4 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e32m4, + vfloat32m4_t, + vfloat64m1_t, + vfloat64m4_t, + __riscv_vle32_v_f32m4, + reinterpret_f32m4_f64m4, + __riscv_vget_v_f64m4_f64m1, + 3, + __riscv_vfwredusum_vs_f32m4_f64m1, + __riscv_vse64_v_f64m1, + vfwredusum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v8,v8,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v4,v4,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v4,v(4|5|6|7)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v8,v(8|9|10|11)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m8.c new file mode 100644 index 00000000000..dd1a7931fe2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredusum_vs-f32-m8.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat64m8_t +reinterpret_f32m8_f64m8 (vfloat32m8_t v) +{ + vuint32m8_t u = __riscv_vreinterpret_v_f32m8_u32m8 (v); + vuint64m8_t wu = __riscv_vreinterpret_v_u32m8_u64m8 (u); + + return __riscv_vreinterpret_v_u64m8_f64m8 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e32m8, + vfloat32m8_t, + vfloat64m1_t, + vfloat64m8_t, + __riscv_vle32_v_f32m8, + reinterpret_f32m8_f64m8, + __riscv_vget_v_f64m8_f64m1, + 7, + __riscv_vfwredusum_vs_f32m8_f64m1, + __riscv_vse64_v_f64m1, + vfwredusum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v16,v16,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredusum\.vs\s+v8,v8,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v8,v(8|9|10|11|12|13|14|15)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,v16,v(16|17|18|19|20|21|22|23)([^0-9]|$)} } } */ -- 2.43.0 From pan2.li@intel.com Tue Nov 3 02:08:51 2026 From: pan2.li@intel.com (pan2.li@intel.com) Date: Tue, 3 Nov 2026 10:08:51 +0800 Subject: [PATCH v1 4/4] RISC-V: Add more test cases for vfwred[ou]sum.vs In-Reply-To: <20261103021109.3293351-1-pan2.li@intel.com> References: <20261103021109.3293351-1-pan2.li@intel.com> Message-ID: <20261103021109.3293351-5-pan2.li@intel.com> From: Pan Li For vs1 not overlap the vs2 register group asm check when the vs1 comes from the vs2 register group. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/pr112431-63.c: New test. * gcc.target/riscv/rvv/base/pr112431-64.c: New test. Signed-off-by: Pan Li --- .../gcc.target/riscv/rvv/base/pr112431-63.c | 59 +++++++++++++++++++ .../gcc.target/riscv/rvv/base/pr112431-64.c | 59 +++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-63.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-64.c diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-63.c b/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-63.c new file mode 100644 index 00000000000..ece90a42dfe --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-63.c @@ -0,0 +1,59 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3" } */ + +#include "riscv_vector.h" + +void +foo (void *in, void *out, int n) +{ + for (int i = 0; i < n; i++) + { + asm volatile("nop" ::: "memory"); + vfloat32m4_t v0 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v0_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v0))), 3); + vfloat64m1_t r0 = __riscv_vfwredosum_vs_f32m4_f64m1 (v0, v0_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v1 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v1_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v1))), 3); + vfloat64m1_t r1 = __riscv_vfwredosum_vs_f32m4_f64m1 (v1, v1_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v2 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v2_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v2))), 3); + vfloat64m1_t r2 = __riscv_vfwredosum_vs_f32m4_f64m1 (v2, v2_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v3 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v3_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v3))), 3); + vfloat64m1_t r3 = __riscv_vfwredosum_vs_f32m4_f64m1 (v3, v3_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v4 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v4_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v4))), 3); + vfloat64m1_t r4 = __riscv_vfwredosum_vs_f32m4_f64m1 (v4, v4_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v5 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v5_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v5))), 3); + vfloat64m1_t r5 = __riscv_vfwredosum_vs_f32m4_f64m1 (v5, v5_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v6 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v6_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v6))), 3); + vfloat64m1_t r6 = __riscv_vfwredosum_vs_f32m4_f64m1 (v6, v6_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v7 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t r7 = __riscv_vfwredosum_vs_f32m4_f64m1 (v7, __riscv_vfmv_v_f_f64m1 (0.0, 4), 4); + + asm volatile("nop" ::: "memory"); + __riscv_vse64_v_f64m1 (out, r0, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r1, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r2, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r3, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r4, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r5, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r6, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r7, 4);out+=100; + } +} + +/* { dg-final { scan-assembler-not {vmv2r} } } */ +/* { dg-final { scan-assembler-not {vmv4r} } } */ +/* { dg-final { scan-assembler-not {vmv8r} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,(v0,v[0-3]|v4,v[4-7]|v8,v([89]|1[01])|v12,v1[2-5]|v16,v1[6-9]|v20,v2[0-3]|v24,v2[4-7]|v28,v(2[89]|3[01]))([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-64.c b/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-64.c new file mode 100644 index 00000000000..0fbb737205c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-64.c @@ -0,0 +1,59 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3" } */ + +#include "riscv_vector.h" + +void +foo (void *in, void *out, int n) +{ + for (int i = 0; i < n; i++) + { + asm volatile("nop" ::: "memory"); + vfloat32m4_t v0 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v0_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v0))), 3); + vfloat64m1_t r0 = __riscv_vfwredusum_vs_f32m4_f64m1 (v0, v0_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v1 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v1_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v1))), 3); + vfloat64m1_t r1 = __riscv_vfwredusum_vs_f32m4_f64m1 (v1, v1_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v2 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v2_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v2))), 3); + vfloat64m1_t r2 = __riscv_vfwredusum_vs_f32m4_f64m1 (v2, v2_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v3 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v3_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v3))), 3); + vfloat64m1_t r3 = __riscv_vfwredusum_vs_f32m4_f64m1 (v3, v3_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v4 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v4_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v4))), 3); + vfloat64m1_t r4 = __riscv_vfwredusum_vs_f32m4_f64m1 (v4, v4_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v5 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v5_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v5))), 3); + vfloat64m1_t r5 = __riscv_vfwredusum_vs_f32m4_f64m1 (v5, v5_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v6 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t v6_w = __riscv_vget_v_f64m4_f64m1 (__riscv_vreinterpret_v_i64m4_f64m4 (__riscv_vreinterpret_v_i32m4_i64m4 (__riscv_vreinterpret_v_f32m4_i32m4 (v6))), 3); + vfloat64m1_t r6 = __riscv_vfwredusum_vs_f32m4_f64m1 (v6, v6_w, 4); + asm volatile("nop" ::: "memory"); + vfloat32m4_t v7 = __riscv_vle32_v_f32m4 (in, 4);in+=100; + vfloat64m1_t r7 = __riscv_vfwredusum_vs_f32m4_f64m1 (v7, __riscv_vfmv_v_f_f64m1 (0.0, 4), 4); + + asm volatile("nop" ::: "memory"); + __riscv_vse64_v_f64m1 (out, r0, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r1, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r2, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r3, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r4, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r5, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r6, 4);out+=100; + __riscv_vse64_v_f64m1 (out, r7, 4);out+=100; + } +} + +/* { dg-final { scan-assembler-not {vmv2r} } } */ +/* { dg-final { scan-assembler-not {vmv4r} } } */ +/* { dg-final { scan-assembler-not {vmv8r} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-assembler-not {vfwredusum\.vs\s+v[0-9]+,(v0,v[0-3]|v4,v[4-7]|v8,v([89]|1[01])|v12,v1[2-5]|v16,v1[6-9]|v20,v2[0-3]|v24,v2[4-7]|v28,v(2[89]|3[01]))([^0-9]|$)} } } */ -- 2.43.0 From crazylht@gmail.com Tue Nov 3 02:29:49 2026 From: crazylht@gmail.com (Hongtao Liu) Date: Mon, 02 Nov 2026 18:29:49 -0800 Subject: [PATCH] i386: Emit mask fma for conditional fma [PR128221] In-Reply-To: <20261102073233.196185-1-haochen.jiang@intel.com> References: <20261102073233.196185-1-haochen.jiang@intel.com> Message-ID: On Sun Nov 1, 2026 at 11:32 PM PST, Haochen Jiang wrote: > Hi all, > > Previosly on trunk, we will emit fma + masked mov for conditional > fma, it will get the correct result, but those masked values > causing exception will be calculated under this scenario. Those > thrown out excpetions are not expected. Use mask fma instead of fma > to do that. > > After using mask fma, we lose some ablitiy to merge, do it directly > in the new ix86_expand_cond_fma for some scenarios to avoid extra > moves. > > Regtested on x86-64. Ok for trunk (and maybe backport)? Ok for trunk. I prefer not to backport. > > Thx, > Haochen > > gcc/ChangeLog: > > PR target/128221 > * config/i386/i386-expand.cc > (ix86_expand_cond_fma): New function to expand conditional fma. > * config/i386/i386-protos.h (ix86_expand_cond_fma): Ditto. > * config/i386/sse.md > (cond_fma): Use new ix86_expand_cond_fma. > (cond_fms): Ditto. > (cond_fnma): Ditto. > (cond_fnms): Ditto. > > gcc/testsuite/ChangeLog: > > PR target/128221 > * gcc.target/i386/pr128221-1a.c: New test. > * gcc.target/i386/pr128221-1b.c: Ditto. > * gcc.target/i386/pr128221-2.c: Ditto. > --- > gcc/config/i386/i386-expand.cc | 37 ++++++++++++++ > gcc/config/i386/i386-protos.h | 1 + > gcc/config/i386/sse.md | 40 ++------------- > gcc/testsuite/gcc.target/i386/pr128221-1a.c | 26 ++++++++++ > gcc/testsuite/gcc.target/i386/pr128221-1b.c | 39 +++++++++++++++ > gcc/testsuite/gcc.target/i386/pr128221-2.c | 55 +++++++++++++++++++++ > 6 files changed, 162 insertions(+), 36 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/i386/pr128221-1a.c > create mode 100644 gcc/testsuite/gcc.target/i386/pr128221-1b.c > create mode 100644 gcc/testsuite/gcc.target/i386/pr128221-2.c > > diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc > index 8a6f0280ac6..68b19ec624d 100644 > --- a/gcc/config/i386/i386-expand.cc > +++ b/gcc/config/i386/i386-expand.cc > @@ -4767,6 +4767,43 @@ ix86_expand_fp_movcc (rtx operands[]) > return true; > } > > +/* Expand a conditional fma: operands[0] = operands[1] > + ? fma (operands[2], operands[3], operands[4]) : operands[5]. */ > + > +void > +ix86_expand_cond_fma (rtx operands[], bool neg_mult, bool neg_add) > +{ > + machine_mode mode = GET_MODE (operands[0]); > + rtx mask = operands[1]; > + rtx op1 = operands[2], op2 = operands[3], op3 = operands[4]; > + rtx op4 = operands[5]; > + rtx tmp, fma; > + > + /* The multiplication is commutative, so an else value equal to the > + second operand for mult can be merged just like first operand > + after swapping. */ > + if (rtx_equal_p (op4, op2)) > + std::swap (op1, op2); > + > + fma = gen_rtx_FMA (mode, neg_mult ? gen_rtx_NEG (mode, op1) : op1, > + op2, neg_add ? gen_rtx_NEG (mode, op3) : op3); > + > + /* Do not emit an extra move. */ > + if (rtx_equal_p (op4, op1) > + || rtx_equal_p (op4, op3) > + || op4 == CONST0_RTX (mode)) > + { > + emit_insn (gen_rtx_SET (operands[0], > + gen_rtx_VEC_MERGE (mode, fma, op4, mask))); > + return; > + } > + > + tmp = gen_reg_rtx (mode); > + emit_insn (gen_rtx_SET (tmp, gen_rtx_VEC_MERGE (mode, fma, > + CONST0_RTX (mode), mask))); > + emit_move_insn (operands[0], gen_rtx_VEC_MERGE (mode, tmp, op4, mask)); > +} > + > /* Helper for ix86_cmp_code_to_pcmp_immediate for int modes. */ > > static int > diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h > index 949f6296462..788ad443b44 100644 > --- a/gcc/config/i386/i386-protos.h > +++ b/gcc/config/i386/i386-protos.h > @@ -158,6 +158,7 @@ extern void ix86_expand_branch (enum rtx_code, rtx, rtx, rtx); > extern void ix86_expand_setcc (rtx, enum rtx_code, rtx, rtx); > extern bool ix86_expand_int_movcc (rtx[]); > extern bool ix86_expand_fp_movcc (rtx[]); > +extern void ix86_expand_cond_fma (rtx[], bool, bool); > extern bool ix86_expand_fp_vcond (rtx[]); > extern bool ix86_expand_int_vcond (rtx[]); > extern void ix86_expand_vec_perm (rtx[]); > diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md > index 1456c92e498..705e45d1c94 100644 > --- a/gcc/config/i386/sse.md > +++ b/gcc/config/i386/sse.md > @@ -6412,15 +6412,7 @@ > (match_operand: 1 "register_operand")))] > "TARGET_AVX512F" > { > - rtx tmp = gen_reg_rtx (mode); > - emit_insn (gen_fma4 (tmp, > - operands[2], > - operands[3], > - operands[4])); > - emit_move_insn (operands[0], gen_rtx_VEC_MERGE (mode, > - tmp, > - operands[5], > - operands[1])); > + ix86_expand_cond_fma (operands, false, false); > DONE; > }) > > @@ -6517,15 +6509,7 @@ > (match_operand: 1 "register_operand")))] > "TARGET_AVX512F" > { > - rtx tmp = gen_reg_rtx (mode); > - emit_insn (gen_fms4 (tmp, > - operands[2], > - operands[3], > - operands[4])); > - emit_move_insn (operands[0], gen_rtx_VEC_MERGE (mode, > - tmp, > - operands[5], > - operands[1])); > + ix86_expand_cond_fma (operands, false, true); > DONE; > }) > > @@ -6624,15 +6608,7 @@ > (match_operand: 1 "register_operand")))] > "TARGET_AVX512F" > { > - rtx tmp = gen_reg_rtx (mode); > - emit_insn (gen_fnma4 (tmp, > - operands[2], > - operands[3], > - operands[4])); > - emit_move_insn (operands[0], gen_rtx_VEC_MERGE (mode, > - tmp, > - operands[5], > - operands[1])); > + ix86_expand_cond_fma (operands, true, false); > DONE; > }) > > @@ -6734,15 +6710,7 @@ > (match_operand: 1 "register_operand")))] > "TARGET_AVX512F" > { > - rtx tmp = gen_reg_rtx (mode); > - emit_insn (gen_fnms4 (tmp, > - operands[2], > - operands[3], > - operands[4])); > - emit_move_insn (operands[0], gen_rtx_VEC_MERGE (mode, > - tmp, > - operands[5], > - operands[1])); > + ix86_expand_cond_fma (operands, true, true); > DONE; > }) > > diff --git a/gcc/testsuite/gcc.target/i386/pr128221-1a.c b/gcc/testsuite/gcc.target/i386/pr128221-1a.c > new file mode 100644 > index 00000000000..1cdc64d7ee7 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/pr128221-1a.c > @@ -0,0 +1,26 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O3 -mavx512f -mprefer-vector-width=512" } */ > + > +#define N 1024 > + > +double a[N], b[N], c[N]; > +int m[N]; > + > +#define DEF_COND_FMA(NAME, EXPR) \ > + void \ > + NAME (double w, double e) \ > + { \ > + for (int i = 0; i < N; i++) \ > + a[i] = m[i] ? (EXPR) : e; \ > + } > + > +DEF_COND_FMA (fma_test, a[i] + b[i] * w) > +DEF_COND_FMA (fms_test, b[i] * w - c[i]) > +DEF_COND_FMA (fnma_test, c[i] - b[i] * w) > +DEF_COND_FMA (fnms_test, -b[i] * w - c[i]) > + > +/* { dg-final { scan-assembler "vfmadd\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ > +/* { dg-final { scan-assembler "vfmsub\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ > +/* { dg-final { scan-assembler "vfnmadd\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ > +/* { dg-final { scan-assembler "vfnmsub\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ > +/* { dg-final { scan-assembler-not "vfn?m(?:add|sub)\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" } } */ > diff --git a/gcc/testsuite/gcc.target/i386/pr128221-1b.c b/gcc/testsuite/gcc.target/i386/pr128221-1b.c > new file mode 100644 > index 00000000000..e876b78d8e1 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/pr128221-1b.c > @@ -0,0 +1,39 @@ > +/* PR target/128221 */ > +/* { dg-do compile } */ > +/* { dg-options "-O3 -mavx512f -mprefer-vector-width=512" } */ > + > +#define N 1024 > + > +double a[N], b[N], c[N], d[N]; > +int m[N]; > + > +#define DEF_COND_FMA(NAME, EXPR, ELSE) \ > + void \ > + NAME (void) \ > + { \ > + for (int i = 0; i < N; i++) \ > + a[i] = m[i] ? (EXPR) : (ELSE); \ > + } > + > +#define DEF_COND_FMA_ALL(NAME, EXPR) \ > + DEF_COND_FMA (NAME##_z, EXPR, 0.0) \ > + DEF_COND_FMA (NAME##_mul1, EXPR, b[i]) \ > + DEF_COND_FMA (NAME##_mul2, EXPR, c[i]) \ > + DEF_COND_FMA (NAME##_add, EXPR, d[i]) > + > +DEF_COND_FMA_ALL (fma, b[i] * c[i] + d[i]) > +DEF_COND_FMA_ALL (fms, b[i] * c[i] - d[i]) > +DEF_COND_FMA_ALL (fnma, d[i] - b[i] * c[i]) > +DEF_COND_FMA_ALL (fnms, -b[i] * c[i] - d[i]) > + > +/* { dg-final { scan-assembler "vfmadd\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ > +/* { dg-final { scan-assembler "vfmadd\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" } } */ > +/* { dg-final { scan-assembler "vfmsub\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ > +/* { dg-final { scan-assembler "vfmsub\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" } } */ > +/* { dg-final { scan-assembler "vfnmadd\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ > +/* { dg-final { scan-assembler "vfnmadd\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" } } */ > +/* { dg-final { scan-assembler "vfnmsub\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" } } */ > +/* { dg-final { scan-assembler "vfnmsub\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" } } */ > +/* { dg-final { scan-assembler-not "vfn?m(?:add|sub)\[0-9\]+pd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" } } */ > +/* { dg-final { scan-assembler-not "vblendm" } } */ > +/* { dg-final { scan-assembler-not "vmov\[a-z0-9\]+\[ \\t\]+%zmm\[0-9\]+, %zmm\[0-9\]+\{%k" } } */ > diff --git a/gcc/testsuite/gcc.target/i386/pr128221-2.c b/gcc/testsuite/gcc.target/i386/pr128221-2.c > new file mode 100644 > index 00000000000..5fbc9410a0d > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/pr128221-2.c > @@ -0,0 +1,55 @@ > +/* { dg-do run } */ > +/* { dg-options "-O3 -mavx512f -mprefer-vector-width=512" } */ > +/* { dg-require-effective-target avx512f } */ > +/* { dg-require-effective-target fenv_exceptions } */ > + > +#include > +#include "avx512f-check.h" > +#include "pr128221-1.c" > + > +#define W 1800.0 > +#define E -1e34 > + > +static void > +check (void (*fn) (double, double), int op) > +{ > + for (int i = 0; i < N; i++) > + { > + m[i] = i & 1; > + /* Overflows only in the lanes where m[i] is zero. */ > + b[i] = m[i] ? 1.0 : 1e307; > + a[i] = 2.0; > + c[i] = 3.0; > + } > + > + feclearexcept (FE_ALL_EXCEPT); > + fn (W, E); > + if (fetestexcept (FE_OVERFLOW)) > + abort (); > + > + for (int i = 0; i < N; i++) > + { > + double r; > + if (!m[i]) > + r = E; > + else if (op == 0) > + r = 2.0 + W; > + else if (op == 1) > + r = W - 3.0; > + else if (op == 2) > + r = 3.0 - W; > + else > + r = -W - 3.0; > + if (a[i] != r) > + abort (); > + } > +} > + > +static void > +avx512f_test (void) > +{ > + check (fma_test, 0); > + check (fms_test, 1); > + check (fnma_test, 2); > + check (fnms_test, 3); > +} > -- > 2.31.1 From chenzhongyao.hit@gmail.com Tue Nov 3 02:46:13 2026 From: chenzhongyao.hit@gmail.com (Zhongyao Chen) Date: Tue, 3 Nov 2026 02:46:13 +0000 Subject: [PATCH v2] RISC-V: Support per-LMUL vector permute cost Message-ID: <20261103024613.2727-1-chen.zhongyao@zte.com.cn> Turn the permute_cost into an array indexed by LMUL (1, 2, 4, 8) to model non-linear permute scaling, defaulting to quadratic scaling ({1, 4, 16, 64}) for generic cores. Regtested on rv64gcv, showed regressions in 4 files: - gcc.target/riscv/rvv/autovec/partial/slp-{1,3,5}.c: Prefers vlseg8 because generic segment cost is too cheap (1). - gcc.target/riscv/rvv/autovec/vls/bswap16-0.c: bswap16 is costed as vec_perm, so quadratic scaling avoids large LMUL. I leave testcases untouched for now. - For slp-{1,3,5}.c, will introduce a segment cost table in a separate patch. - For bswap16-0.c, currently we can't tell if it's a cheaper perm. Robin is working on vect; once that allows us to do fine-grained permute costing, this can be refined into dedicated cost tables for gather/slide/compress. After that this can be fixed. To Bohan: please check if the updated xt_c9501_vls_vector_cost numbers look reasonable to you. gcc/ChangeLog: * config/riscv/riscv-protos.h (struct common_vector_cost): Change permute_cost to array. * config/riscv/riscv-vector-costs.cc (costs::adjust_stmt_cost): Skip linear LMUL scaling for vec_perm. * config/riscv/riscv.cc (rvv_vls_vector_cost): Update permute_cost. (rvv_vla_vector_cost): Likewise. (xt_c9501_vls_vector_cost): Likewise. (riscv_builtin_vectorization_cost): Query permute_cost by LMUL. Signed-off-by: Zhongyao Chen --- gcc/config/riscv/riscv-protos.h | 4 ++-- gcc/config/riscv/riscv-vector-costs.cc | 6 ++++-- gcc/config/riscv/riscv.cc | 10 ++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h index c0fb2839780..e24b474d591 100644 --- a/gcc/config/riscv/riscv-protos.h +++ b/gcc/config/riscv/riscv-protos.h @@ -270,8 +270,8 @@ struct common_vector_cost /* Cost of a scalar-to-vector operation. */ const int scalar_to_vec_cost; - /* Cost of a permute operation. */ - const int permute_cost; + /* Cost of a permute operation for LMUL 1, 2, 4, 8. */ + const int permute_cost[4]; /* Cost of an aligned vector load. */ const int align_load_cost; diff --git a/gcc/config/riscv/riscv-vector-costs.cc b/gcc/config/riscv/riscv-vector-costs.cc index 924a0330103..9eeeaff05c0 100644 --- a/gcc/config/riscv/riscv-vector-costs.cc +++ b/gcc/config/riscv/riscv-vector-costs.cc @@ -1523,8 +1523,10 @@ costs::adjust_stmt_cost (enum vect_cost_for_stmt kind, loop_vec_info loop, /* Apply LMUL cost scaling uniformly to all vector operations. Larger LMUL values have higher latency and register pressure, - which affects performance regardless of loop structure. */ - if (VECTOR_TYPE_P (vectype)) + which affects performance regardless of loop structure. + Permutes have already looked up their per-LMUL cost table in + builtin_vectorization_cost. */ + if (VECTOR_TYPE_P (vectype) && kind != vec_perm) { unsigned lmul_factor = get_lmul_cost_scaling (TYPE_MODE (vectype)); if (lmul_factor > 1) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index bed695ccae4..17fcdb6f764 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -406,7 +406,7 @@ static const common_vector_cost rvv_vls_vector_cost = { 1, /* segment_permute (8) */ 1, /* vec_to_scalar_cost */ 1, /* scalar_to_vec_cost */ - 1, /* permute_cost */ + {1, 4, 16, 64}, /* permute_cost. */ 1, /* align_load_cost */ 1, /* align_store_cost */ 2, /* unalign_load_cost */ @@ -439,7 +439,7 @@ static const scalable_vector_cost rvv_vla_vector_cost = { 1, /* segment_permute (8) */ 1, /* vec_to_scalar_cost */ 1, /* scalar_to_vec_cost */ - 1, /* permute_cost */ + {1, 4, 16, 64}, /* permute_cost. */ 1, /* align_load_cost */ 1, /* align_store_cost */ 2, /* unalign_load_cost */ @@ -751,7 +751,7 @@ static const common_vector_cost xt_c9501_vls_vector_cost = { 12, /* segment_permute (8) */ 2, /* vec_to_scalar_cost */ 2, /* scalar_to_vec_cost */ - 4, /* permute_cost */ + {4, 16, 64, 256}, /* permute_cost. */ 6, /* align_load_cost */ 1, /* align_store_cost */ 8, /* unalign_load_cost */ @@ -14557,7 +14557,9 @@ riscv_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, return costs->cond_not_taken_branch_cost; case vec_perm: - return common_costs->permute_cost; + return is_frac_vlmul_p (TYPE_MODE (vectype)) + ? common_costs->permute_cost[LMUL_1] + : common_costs->permute_cost[get_vlmul (TYPE_MODE (vectype))]; case vec_promote_demote: return fp ? common_costs->fp_stmt_cost : common_costs->int_stmt_cost; -- 2.43.0 From yjn@yjn-systems.com Tue Nov 3 02:56:39 2026 From: yjn@yjn-systems.com (Jasper Niebuhr) Date: Tue, 3 Nov 2026 03:56:39 +0100 Subject: [PATCH 2/2] bpf: CO-RE consumer of deferred constants In-Reply-To: <9d858e82-a769-4fcb-af3e-3b90e508b0dc@oss.qualcomm.com> References: <20261101025158.271216-1-yjn@yjn-systems.com> <20261101025438.271424-1-yjn@yjn-systems.com> <9d858e82-a769-4fcb-af3e-3b90e508b0dc@oss.qualcomm.com> Message-ID: Hi David, first of all, thanks for your review! On Tue, Nov 3, 2026 at 3:09?AM David Faust wrote: > > > > On 10/31/26 7:54 PM, York Jasper Niebuhr wrote: > > Use deferred constants to preserve semantic information required for BPF > > CO-RE relocations. > > > > Mark enum types for deferred enum values and record types carrying > > "preserve_access_index" for deferred field offsets. Deferred constants > > encountered during BPF lowering are either turned into CO-RE relocations > > or resolved to their ordinary compile-time values when no relocation is > > requested. > > > > Add a "preserve_enum_values" attribute for enum types. Enumerators of a > > type carrying this attribute automatically generate > > BPF_RELO_ENUMVAL_VALUE relocations. > > > > Remove the bpf_enum_mappings workaround in favor of direct enum identity > > recovery from deferred cst arguments to __builtin_preserve_enum_value. > > > > For record types carrying "preserve_access_index", deferred field > > offsets originating from offsetof expressions are converted into > > BPF_RELO_FIELD_BYTE_OFFSET relocations. > > > > BPF CO-RE relocations can not currently be emitted for static data. Add > > an IPA pass which resolves deferred constants in static initializers > > before the generic deferred-constant barrier. Initializers which would > > require CO-RE relocations are diagnosed. Support for such initializers > > could be added in the future by generating relocated runtime > > initialization code, for cases such as: > > > > struct task_struct { > > ... > > int x; > > ... > > } __attribute__((preserve_access_index)); > > > > static size_t OFF_X = offsetof (struct task_struct, x); > > > So I gave this a try to see if the above static initializer thing > is an issue for the kernel selftests. > > Instead I encountered another problem when using an enumerator to index > into an array, e.g.: > > enum bpf_map_type { > BPF_MAP_TYPE_START, > BPF_MAP_TYPE_RINGBUF, > __BPF_MAP_TYPE_MAX > }; > int a[BPF_MAP_TYPE_RINGBUF]; > > $ ./xgcc -B. ~/playpen/bpf/defer.c -c > /home/dfaust/playpen/bpf/defer.c:8:5: error: variably modified ?a? at file scope > 8 | int a[BPF_MAP_TYPE_RINGBUF]; > | ^ > > It's coming from this spot in c-decl.cc grokdeclarator:7444 > > else if ((decl_context == NORMAL || decl_context == FIELD) > && current_scope == file_scope) > { > error_at (loc, "variably modified %qE at file scope", name); > size = integer_one_node; > } > > Not sure whether this indicates a bug in the C/middle-end portion, > or due to how it is being used from the BPF backend, e.g. if the > plugin_finish_type hook needs to take more care rather than just > marking any enumeral type. > The deferred constants work specifically in contexts that do not determine the "shape" of the program. That means the usual runtime expressions are fine, but e.g. type formation can not be deferred, because that would fundamentally change what code has to be generated, instead of what value goes into the code. The issue you ran into is precisely this. Having int a[BPF_MAP_TYPE_RINGBUF]; fail to compile is expected IF BPF_MAP_TYPE_RINGBUF can change later, because how much space would you allocate for this array? This is only an actual problem though if BPF_MAP_TYPE_RINGBUF should not actually be deferred. So, as you guessed, the real problem here is that the plugin_finish_type callback unconditionally marks all enums. For the preserve_enum_value attribute it would suffice to mark just the ones that actually have the attribute. At the moment, it marks the others too such that the enum values handed to __builtin_preserve_enum_value are also deferred, regardless of whether they come from enums that actually have the attribute. Since my 4 a.m. self forgot to allow deferred constants in "CASE X" labels (which is slightly inconvenient for enums), I am currently putting together v2 anyways. To solve the "mark all, even if they aren't actually deferred" problem, I intend to add a hook that allows a consumer to resolve deferred constants in illegal contexts (such as the array bounds) back to compile- time values if they are not actually intended to be deferred. This is basically what the BPF lowering pass currently does at a later point, so the hook can mostly just reuse that code. With that, this issue should hopefully be fixed :) Regarding the static initializers... Normally, stuff like static size_t OFF_X = bpf_core_field_offset (...); simply wouldn't compile. With deferred constants, static size_t OFF_X = __builtin_offsetof (...); is however allowed by the frontend, but should refer to the relocated offset if the type is marked with preserve_access_index. So a BPF backend transformation could inspect such static initializers and automatically generate equivalent runtime initializers. This is also what I did for Selfpatch-SLR, to allow static data that depends on randomized field offsets. Conceptually, the code is turned into: static size_t OFF_X = some initial value (e.g. the original offset); void refresh_OFF_X () { OFF_X = relocated offset; } and the refresh is executed before any other code runs. In the case of BPF though, it would probably make more sense to just relocate OFF_X directly somehow. Anyways, I wouldn't expect this to break any existing code, because that code would need to already be using non-relocated expressions for values that are actually supposed to be chosen at load-time. I only suggested this as a possible future quality of life improvement, which would just take considerably more effort to implement. From avinashd@linux.ibm.com Tue Nov 3 03:55:46 2026 From: avinashd@linux.ibm.com (Avinash Jayakar) Date: Tue, 3 Nov 2026 09:25:46 +0530 Subject: [PATCH] rs6000: Use signed integers when resolving __builtin_ppc_atomic_cas_local Message-ID: <20261103035546.566548-1-avinashd@linux.ibm.com> The __builtin_ppc_atomic_cas_local builtin was incorrectly casting pointer arguments to unsigned integer types in the overload resolution handler, while the actual builtin definitions expected signed types. This caused C++ compilation to fail with "invalid conversion" errors due to C++'s stricter type checking, while C compilation succeeded due to its more permissive pointer conversion rules. The fix changes the intermediate casting types in rs6000-c.cc to use signed types that match the builtin signatures in rs6000-builtins.def. This patch also adds cc and cpp extensions to powerpc.exp to accept c++ tests. Bootstrapped and regtested on powerpc64le-linux-gnu. Ok for trunk? Also since this is an error on valid code in C++, can we backport it for branches 16 and 15? 2026-11-02 Avinash Jayakar gcc/ChangeLog: * config/rs6000/rs6000-c.cc (altivec_resolve_overloaded_builtin): Use signed types intead of unsigned for atomic_cas_local builtin casts. gcc/testsuite/ChangeLog: * gcc.target/powerpc/acmp-tst.cc: New test. * gcc.target/powerpc/acmp-tst-32bit.cc: New test. * gcc.target/powerpc/acmp-tst-indexed.cc: New test * gcc.target/powerpc/powerpc.exp: Accept c++ tests. --- gcc/config/rs6000/rs6000-c.cc | 10 +- .../gcc.target/powerpc/acmp-tst-32bit.cc | 61 ++++++ .../gcc.target/powerpc/acmp-tst-indexed.cc | 165 ++++++++++++++++ gcc/testsuite/gcc.target/powerpc/acmp-tst.cc | 176 ++++++++++++++++++ gcc/testsuite/gcc.target/powerpc/powerpc.exp | 2 +- 5 files changed, 408 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/acmp-tst-32bit.cc create mode 100644 gcc/testsuite/gcc.target/powerpc/acmp-tst-indexed.cc create mode 100644 gcc/testsuite/gcc.target/powerpc/acmp-tst.cc diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc index f51593e0455..1e5988e1f06 100644 --- a/gcc/config/rs6000/rs6000-c.cc +++ b/gcc/config/rs6000/rs6000-c.cc @@ -1792,19 +1792,19 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, { case 1: target_fcode = RS6000_BIF_PPC_ATOMIC_CAS_QI; - int_type = unsigned_char_type_node; + int_type = signed_char_type_node; break; case 2: target_fcode = RS6000_BIF_PPC_ATOMIC_CAS_HI; - int_type = short_unsigned_type_node; + int_type = short_integer_type_node; break; case 4: target_fcode = RS6000_BIF_PPC_ATOMIC_CAS_SI; - int_type = unsigned_intSI_type_node; + int_type = intSI_type_node; break; case 8: target_fcode = RS6000_BIF_PPC_ATOMIC_CAS_DI; - int_type = long_long_unsigned_type_node; + int_type = long_long_integer_type_node; break; case 16: if (!TARGET_QUAD_MEMORY_ATOMIC) @@ -1815,7 +1815,7 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, return error_mark_node; } target_fcode = RS6000_BIF_PPC_ATOMIC_CAS_TI; - int_type = unsigned_intTI_type_node; + int_type = intTI_type_node; break; default: if (complain) diff --git a/gcc/testsuite/gcc.target/powerpc/acmp-tst-32bit.cc b/gcc/testsuite/gcc.target/powerpc/acmp-tst-32bit.cc new file mode 100644 index 00000000000..79f646a4f27 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/acmp-tst-32bit.cc @@ -0,0 +1,61 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target ilp32 } */ + +/* { dg-options "-O2 -mdejagnu-cpu=power8" } */ + +bool +word_exchange_qi (signed char *ptr, signed char *expected, signed char *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_uqi (unsigned char *ptr, unsigned char *expected, + unsigned char *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_hi (short *ptr, short *expected, short *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_shi (signed short *ptr, signed short *expected, + signed short *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_uhi (unsigned short *ptr, unsigned short *expected, + unsigned short *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_si (int *ptr, int *expected, int *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_ssi (signed int *ptr, signed int *expected, signed int *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_usi (unsigned int *ptr, unsigned int *expected, + unsigned int *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} + +/* { dg-final { scan-assembler-times {\mlbarx +[0-9]+,[0-9]+,[0-9]+,1} 2 } } */ +/* { dg-final { scan-assembler-times {\mlharx +[0-9]+,[0-9]+,[0-9]+,1} 3 } } */ +/* { dg-final { scan-assembler-times {\mlwarx +[0-9]+,[0-9]+,[0-9]+,1} 3 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/acmp-tst-indexed.cc b/gcc/testsuite/gcc.target/powerpc/acmp-tst-indexed.cc new file mode 100644 index 00000000000..c0d2bf3dcb3 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/acmp-tst-indexed.cc @@ -0,0 +1,165 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target lp64 } */ + +// Need power8 for larx +/* { dg-options "-O2 -mdejagnu-cpu=power8" } */ + +typedef struct udt_1 +{ + char *a; +} udt_1t; +typedef struct udt_2 +{ + char a; + char b; +} udt_2t; +typedef struct udt_4 +{ + short a; + short b; +} udt_4t; +typedef struct udt_8 +{ + int a; + int b; +} udt_8t; +bool +word_exchange_nqi (char *ptr, char *expected, char *desired, + unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_qi (signed char *ptr, signed char *expected, signed char *desired, + unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_uqi (unsigned char *ptr, unsigned char *expected, + unsigned char *desired, unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_hi (short *ptr, short *expected, short *desired, + unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_shi (signed short *ptr, signed short *expected, + signed short *desired, unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_uhi (unsigned short *ptr, unsigned short *expected, + unsigned short *desired, unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_si (int *ptr, int *expected, int *desired, unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_ssi (signed int *ptr, signed int *expected, signed int *desired, + unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_usi (unsigned int *ptr, unsigned int *expected, + unsigned int *desired, unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_di (long long *ptr, long long *expected, long long *desired, + unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_sdi (signed long long *ptr, signed long long *expected, + signed long long *desired, unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_udi (unsigned long long *ptr, unsigned long long *expected, + unsigned long long *desired, unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_f32 (float *ptr, float *expected, float *desired, + unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_f64 (double *ptr, double *expected, double *desired, + unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_udt_1 (udt_1t *ptr, udt_1t *expected, udt_1t *desired, + unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_udt_2 (udt_2t *ptr, udt_2t *expected, udt_2t *desired, + unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_udt_4 (udt_4t *ptr, udt_4t *expected, udt_4t *desired, + unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_udt_8 (udt_8t *ptr, udt_8t *expected, udt_8t *desired, + unsigned long long n) +{ + return __builtin_ppc_atomic_cas_local (ptr+n, expected+n, desired+n, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} + +/* Test if indexed mode addresses are used, r6 must be used which corresponds + to the argument n in all functions. */ + +/* { dg-final { scan-assembler-times {\mlbarx +[0-9]+,[0-9]+,6,1} 3 } } */ +/* { dg-final { scan-assembler-times {\mstbcx. +[0-9]+,[0-9]+,6} 3 } } */ + +/* { dg-final { scan-assembler-times {\mlharx +[0-9]+,[0-9]+,6,1} 4 } } */ +/* { dg-final { scan-assembler-times {\msthcx. +[0-9]+,[0-9]+,6} 4 } } */ + +/* { dg-final { scan-assembler-times {\mlwarx +[0-9]+,[0-9]+,6,1} 5 } } */ +/* { dg-final { scan-assembler-times {\mstwcx. +[0-9]+,[0-9]+,6} 5 } } */ + +/* { dg-final { scan-assembler-times {\mldarx +[0-9]+,[0-9]+,6,1} 6 } } */ +/* { dg-final { scan-assembler-times {\mstdcx. +[0-9]+,[0-9]+,6} 6 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/acmp-tst.cc b/gcc/testsuite/gcc.target/powerpc/acmp-tst.cc new file mode 100644 index 00000000000..bb15805819f --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/acmp-tst.cc @@ -0,0 +1,176 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target lp64 } */ + +// Need power8 for larx +/* { dg-options "-O2 -mdejagnu-cpu=power8" } */ + +typedef struct udt_1 +{ + char *a; +} udt_1t; +typedef struct udt_2 +{ + char a; + char b; +} udt_2t; +typedef struct udt_4 +{ + short a; + short b; +} udt_4t; +typedef struct udt_8 +{ + int a; + int b; +} udt_8t; +typedef struct udt_16 +{ + long long a; + long long b; +} udt_16t; +bool +word_exchange_nqi (char *ptr, char *expected, char *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_qi (signed char *ptr, signed char *expected, signed char *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_uqi (unsigned char *ptr, unsigned char *expected, + unsigned char *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_hi (short *ptr, short *expected, short *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_shi (signed short *ptr, signed short *expected, + signed short *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_uhi (unsigned short *ptr, unsigned short *expected, + unsigned short *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_si (int *ptr, int *expected, int *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_ssi (signed int *ptr, signed int *expected, signed int *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_usi (unsigned int *ptr, unsigned int *expected, + unsigned int *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_di (long long *ptr, long long *expected, long long *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_sdi (signed long long *ptr, signed long long *expected, + signed long long *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_udi (unsigned long long *ptr, unsigned long long *expected, + unsigned long long *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_sti (signed __int128 *ptr, signed __int128 *expected, + signed __int128 *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_uti (unsigned __int128 *ptr, unsigned __int128 *expected, + unsigned __int128 *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_f32 (float *ptr, float *expected, float *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_f64 (double *ptr, double *expected, double *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_f128 (__ieee128 *ptr, __ieee128 *expected, __ieee128 *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_udt_1 (udt_1t *ptr, udt_1t *expected, udt_1t *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_udt_2 (udt_2t *ptr, udt_2t *expected, udt_2t *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_udt_4 (udt_4t *ptr, udt_4t *expected, udt_4t *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_udt_8 (udt_8t *ptr, udt_8t *expected, udt_8t *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} +bool +word_exchange_udt_16 (udt_16t *ptr, udt_16t *expected, udt_16t *desired) +{ + return __builtin_ppc_atomic_cas_local (ptr, expected, desired, 0, + __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE); +} + +/* { dg-final { scan-assembler-times {\mlbarx +[0-9]+,[0-9]+,[0-9]+,1} 3 } } */ +/* { dg-final { scan-assembler-times {\mlharx +[0-9]+,[0-9]+,[0-9]+,1} 4 } } */ +/* { dg-final { scan-assembler-times {\mlwarx +[0-9]+,[0-9]+,[0-9]+,1} 5 } } */ +/* { dg-final { scan-assembler-times {\mldarx +[0-9]+,[0-9]+,[0-9]+,1} 6 } } */ +/* { dg-final { scan-assembler-times {\mlqarx +[0-9]+,[0-9]+,[0-9]+,1} 4 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/powerpc.exp b/gcc/testsuite/gcc.target/powerpc/powerpc.exp index 245df49f243..d96182f69e3 100644 --- a/gcc/testsuite/gcc.target/powerpc/powerpc.exp +++ b/gcc/testsuite/gcc.target/powerpc/powerpc.exp @@ -35,7 +35,7 @@ if ![info exists DEFAULT_CFLAGS] then { dg-init # Main loop. -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \ +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{\[cS\],cc,cpp}]] \ "" $DEFAULT_CFLAGS set SAVRES_TEST_OPTS [list -Os -O2 {-Os -mno-multiple} {-O2 -mno-multiple}] -- 2.54.0 From garthlei@linux.alibaba.com Tue Nov 3 04:45:14 2026 From: garthlei@linux.alibaba.com (Bohan Lei) Date: Tue, 03 Nov 2026 12:45:14 +0800 Subject: =?UTF-8?B?UmU6IFtQQVRDSCB2Ml0gUklTQy1WOiBTdXBwb3J0IHBlci1MTVVMIHZlY3RvciBwZXJtdXRl?= =?UTF-8?B?IGNvc3Q=?= In-Reply-To: <20261103024613.2727-1-chen.zhongyao@zte.com.cn> References: <20261103024613.2727-1-chen.zhongyao@zte.com.cn> Message-ID: Hi Zhongyao, > To Bohan: please check if the updated xt_c9501_vls_vector_cost numbers > look reasonable to you. Yes, they look reasonable, though we may want to reduce the base cost to 3 in a later patch after filing more xxtvarith-related optimizations. Good for now. Regards, Bohan From fkastl@suse.cz Tue Nov 3 06:36:15 2026 From: fkastl@suse.cz (Filip Kastl) Date: Tue, 3 Nov 2026 07:36:15 +0100 Subject: [PATCH] Call symtab_node::get_create when it is suitable In-Reply-To: <20261102155252.2392802-1-giuliano.belinassi@suse.com> References: <20261102155252.2392802-1-giuliano.belinassi@suse.com> Message-ID: Looks very straightforward and ok to me. I cannot give the official approval, though. Filip On Mon 2026-11-02 16:52:52, Giuliano Belinassi wrote: > In many cases the original code checked if the decl is a variable or a > function and forward the call to either varpool_node::get_create or > cgraph_node::get_create. However, there is an API already for > checking that: symtab_node::get_create. Hence, modify the code for > the cases where this is suitable. > > gcc/ChangeLog: > > * cgraphunit.cc (symbol_table::process_same_body_aliases): Call > symtab_node::get_create. > * tree.cc (set_decl_section_name): Likewise. > (decl_init_priority_insert): Likewise. > * varasm.cc (assemble_alias): Likewise. > (make_decl_one_only): Likewise. > > gcc/cp/ChangeLog: > > * decl.cc (duplicate_decls): Call symtab_node::get_create. > > Signed-off-by: Giuliano Belinassi > --- > gcc/cgraphunit.cc | 5 +---- > gcc/cp/decl.cc | 5 +---- > gcc/tree.cc | 14 +++----------- > gcc/varasm.cc | 10 ++-------- > 4 files changed, 7 insertions(+), 27 deletions(-) > > diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc > index b77f082757b..61944a9d661 100644 > --- a/gcc/cgraphunit.cc > +++ b/gcc/cgraphunit.cc > @@ -727,10 +727,7 @@ symbol_table::process_same_body_aliases (void) > symtab_node *node; > FOR_EACH_SYMBOL (node) > if (node->cpp_implicit_alias && !node->analyzed) > - node->resolve_alias > - (VAR_P (node->alias_target) > - ? (symtab_node *)varpool_node::get_create (node->alias_target) > - : (symtab_node *)cgraph_node::get_create (node->alias_target)); > + node->resolve_alias (symtab_node::get_create (node->alias_target)); > cpp_implicit_aliases_done = true; > } > > diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc > index 16ce7cd36b0..7243c8a3caa 100644 > --- a/gcc/cp/decl.cc > +++ b/gcc/cp/decl.cc > @@ -3573,10 +3573,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) > if (DECL_ONE_ONLY (newdecl)) > { > struct symtab_node *oldsym, *newsym; > - if (TREE_CODE (olddecl) == FUNCTION_DECL) > - oldsym = cgraph_node::get_create (olddecl); > - else > - oldsym = varpool_node::get_create (olddecl); > + oldsym = symtab_node::get_create (olddecl); > newsym = symtab_node::get (newdecl); > oldsym->set_comdat_group (newsym->get_comdat_group ()); > } > diff --git a/gcc/tree.cc b/gcc/tree.cc > index 7e5a53234ba..2e46b4bcdaa 100644 > --- a/gcc/tree.cc > +++ b/gcc/tree.cc > @@ -1024,10 +1024,8 @@ set_decl_section_name (tree node, const char *value) > if (!snode) > return; > } > - else if (VAR_P (node)) > - snode = varpool_node::get_create (node); > else > - snode = cgraph_node::get_create (node); > + snode = symtab_node::get_create (node); > snode->set_section (value); > } > > @@ -1042,11 +1040,7 @@ set_decl_section_name (tree decl, const_tree other) > struct symtab_node *other_node = symtab_node::get (other); > if (other_node) > { > - struct symtab_node *decl_node; > - if (VAR_P (decl)) > - decl_node = varpool_node::get_create (decl); > - else > - decl_node = cgraph_node::get_create (decl); > + struct symtab_node *decl_node = symtab_node::get_create (decl); > decl_node->set_section (*other_node); > } > else > @@ -6077,10 +6071,8 @@ decl_init_priority_insert (tree decl, priority_type priority) > if (!snode) > return; > } > - else if (VAR_P (decl)) > - snode = varpool_node::get_create (decl); > else > - snode = cgraph_node::get_create (decl); > + snode = symtab_node::get_create (decl); > snode->set_init_priority (priority); > } > > diff --git a/gcc/varasm.cc b/gcc/varasm.cc > index 7ce5032a6cb..0c5f80165e9 100644 > --- a/gcc/varasm.cc > +++ b/gcc/varasm.cc > @@ -6687,10 +6687,7 @@ assemble_alias (tree decl, tree target) > TREE_USED (decl) = 1; > > /* Allow aliases to aliases. */ > - if (TREE_CODE (decl) == FUNCTION_DECL) > - cgraph_node::get_create (decl)->alias = true; > - else > - varpool_node::get_create (decl)->alias = true; > + symtab_node::get_create (decl)->alias = true; > > /* If the target has already been emitted, we don't have to queue the > alias. This saves a tad of memory. */ > @@ -6938,10 +6935,7 @@ make_decl_one_only (tree decl, tree comdat_group) > > TREE_PUBLIC (decl) = 1; > > - if (VAR_P (decl)) > - symbol = varpool_node::get_create (decl); > - else > - symbol = cgraph_node::get_create (decl); > + symbol = symtab_node::get_create (decl); > > if (SUPPORTS_ONE_ONLY) > { > -- > 2.56.0 > From fkastl@suse.cz Tue Nov 3 06:43:31 2026 From: fkastl@suse.cz (Filip Kastl) Date: Tue, 3 Nov 2026 07:43:31 +0100 Subject: [PATCH] Remove null from pt_solution In-Reply-To: References: Message-ID: Hi Andrew. Beware that your patch is broken. Lines got wrapped. Like... On Mon 2026-11-02 12:52:25, Andrew MacLeod wrote: > diff --git a/gcc/gimple-pretty-print.cc b/gcc/gimple-pretty-print.cc > index 69148dd5cbd..1af0910f148 100644 > --- a/gcc/gimple-pretty-print.cc > +++ b/gcc/gimple-pretty-print.cc > @@ -822,8 +822,6 @@ pp_points_to_solution (pretty_printer *pp, const > pt_solution *pt) ... here ^ ... > pp_string (pp, "escaped "); > if (pt->ipa_escaped) > pp_string (pp, "unit-escaped "); > - if (pt->null) > - pp_string (pp, "null "); > if (pt->const_pool) > pp_string (pp, "const-pool "); > if (pt->vars > diff --git a/gcc/testsuite/gcc.dg/torture/pr39074-2.c > b/gcc/testsuite/gcc.dg/torture/pr39074-2.c ... and here ^. And likely at many other places. Filip Kastl From Venkataramanan.Kumar@amd.com Tue Nov 3 06:44:08 2026 From: Venkataramanan.Kumar@amd.com (Kumar, Venkataramanan) Date: Tue, 3 Nov 2026 06:44:08 +0000 Subject: [PATCH v3 0/4][X86] Add support for AVX10V1AUX. In-Reply-To: References: <20261101134756.351245-1-Dipesh.Sharma@amd.com> Message-ID: AMD General Hi > -----Original Message----- > From: Hongtao Liu > Sent: Monday, November 2, 2026 1:13 PM > To: Sharma, Dipesh ; gcc-patches@gcc.gnu.org > Cc: haochen.jiang@intel.com; ubizjak@gmail.com; hongtao.liu@intel.com; > honza.hubicka@gmail.com > Subject: Re: [PATCH v3 0/4][X86] Add support for AVX10V1AUX. > > Caution: This message originated from an External Source. Use proper caution > when opening attachments, clicking links, or responding. > > > On Sun Nov 1, 2026 at 5:47 AM PST, Dipesh Sharma wrote: > > This patch series adds support for AVX10V1AUX. > > > > > > This revision addresses the comments on the > > previous(V2) revision: > > https://gcc.gnu.org/pipermail/gcc-patches/2026-October/736257.html > Ok for the series after addressing haocheng's comments. Thank you Hongtao and Haochen. Committed the patches. https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d6e9cbe7594f576fc238c2d602d1825d91a72b22 <== link for last one of the series. Regards, Venkat. > > > > > > > Dipesh Sharma (4): > > [X86]: Initial support for AVX10V1AUX > > [X86]: Move shared AVX10.2 convert intrinsics to AVX10V1AUX. > > [X86]: Move shared AVX10.2 and VNNI byte and word intrinsics to > > AVX10V1AUX. > > [X86]: Add AVX10V1AUX tests for VNNIINT8/16. > > > > gcc/common/config/i386/cpuinfo.h | 15 +- > > gcc/common/config/i386/i386-common.cc | 27 +- > > gcc/common/config/i386/i386-cpuinfo.h | 1 + > > gcc/common/config/i386/i386-isas.h | 2 + > > gcc/config.gcc | 2 +- > > gcc/config/i386/avx10_2convertintrin.h | 1376 --------- > > gcc/config/i386/avx10_2mediaintrin.h | 1032 ------- > > gcc/config/i386/avx10v1auxintrin.h | 2459 +++++++++++++++++ > > gcc/config/i386/cpuid.h | 1 + > > gcc/config/i386/i386-builtin.def | 308 +-- > > gcc/config/i386/i386-c.cc | 2 + > > gcc/config/i386/i386-expand.cc | 8 +- > > gcc/config/i386/i386-isa.def | 1 + > > gcc/config/i386/i386-options.cc | 4 +- > > gcc/config/i386/i386.cc | 4 +- > > gcc/config/i386/i386.h | 5 +- > > gcc/config/i386/i386.md | 4 +- > > gcc/config/i386/i386.opt | 5 + > > gcc/config/i386/i386.opt.urls | 3 + > > gcc/config/i386/immintrin.h | 2 + > > gcc/config/i386/sse.md | 162 +- > > gcc/doc/extend.texi | 5 + > > gcc/doc/invoke.texi | 8 +- > > gcc/doc/sourcebuild.texi | 3 + > > gcc/testsuite/gcc.target/i386/avx-1.c | 2 +- > > .../gcc.target/i386/avx10_2-builtin-1.c | 2 +- > > .../gcc.target/i386/avx10_2-builtin-2.c | 2 +- > > gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c | 375 +++ > > gcc/testsuite/gcc.target/i386/avx10v1aux-1b.c | 267 ++ > > gcc/testsuite/gcc.target/i386/funcspec-56.inc | 2 + > > gcc/testsuite/gcc.target/i386/sse-13.c | 2 +- > > gcc/testsuite/gcc.target/i386/sse-14.c | 2 +- > > gcc/testsuite/gcc.target/i386/sse-22.c | 2 +- > > gcc/testsuite/gcc.target/i386/sse-23.c | 2 +- > > gcc/testsuite/lib/target-supports.exp | 13 + > > 35 files changed, 3441 insertions(+), 2669 deletions(-) create mode > > 100644 gcc/config/i386/avx10v1auxintrin.h > > create mode 100644 gcc/testsuite/gcc.target/i386/avx10v1aux-1a.c > > create mode 100644 gcc/testsuite/gcc.target/i386/avx10v1aux-1b.c > > > > -- > > 2.34.1 From fkastl@suse.cz Tue Nov 3 07:35:43 2026 From: fkastl@suse.cz (Filip Kastl) Date: Tue, 3 Nov 2026 08:35:43 +0100 Subject: [PATCH] Remove null from pt_solution In-Reply-To: References: Message-ID: On Mon 2026-11-02 12:52:25, Andrew MacLeod wrote: > Thre is only one place (!!!!) that actually sets pt.null to 0 (meaning the > range is nonnull) It is in tree-ssa-structalias.cc find_what_p_points_to() > and it determines nonnullness based on : > > get_range_query (DECL_STRUCT_FUNCTION (fndecl))->range_of_expr (vr, p); > bool nonnull = !vr.contains_zero_p (); > <..> > if (nonnull) > set_ptr_nonnull (p); It's actually not true, that this is the only place that sets pt.null to 0 -- find_what_var_points_to() can also produce pt_solution pt with pt.null = 0 (when it creates the structure, it zero-initializes it by memset). Yes, in find_what_pt_points_to() that gets overriden to whatever ranger thinks about null-ness of a pointer. But that's not the only place find_what_var_points_to() is called. On the other hand, when you look at the other calls to find_what_var_points_to(), you see that those are only used to compute the (IPA) escaped, escaped_return, IPA clobbers and IPA uses. I didn't check as thoroughly as I'd like to, but I don't think that GCC ever makes use of pt_solution.null for those PT sets. In case it really doesn't, I think we could not only remove pt_solution.null, but also remove the NULL artificial variable from the PT constraints. That would save a little bit of solving time. For my Steensgaard solver, that could also be a significant boon in terms of precision. Cheers, Filip Kastl From crazylht@gmail.com Tue Nov 3 07:37:25 2026 From: crazylht@gmail.com (Hongtao Liu) Date: Mon, 02 Nov 2026 23:37:25 -0800 Subject: [PATCH] i386: Cost scalar division by a constant as its expansion In-Reply-To: <20261030055911.2471667-1-hongtao.liu@intel.com> References: <20261030055911.2471667-1-hongtao.liu@intel.com> Message-ID: On Thu Oct 29, 2026 at 10:59 PM PDT, liuhongt wrote: > ix86_vector_costs::add_stmt_cost costed every scalar integer division > and modulo by the divide instruction, also when the divisor is a > constant and the operation is expanded to shifts or a multiplication. > This made the scalar cost of division by a constant inaccurate during > vectorization costing; for example, an exact division by a power of two > such as a pointer difference is a single scalar arithmetic shift, but > charging the divide instruction cost made basic-block SLP vectorization > into an emulated 64-bit vector shift look profitable. > > Return a rough cost of the scalar integer TRUNC_DIV_EXPR, TRUNC_MOD_EXPR > or EXACT_DIV_EXPR by the nonzero constant divisor, approximating > expand_divmod in expmed.cc. > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > Ok for trunk? Any comments? > > gcc/ChangeLog: > > * config/i386/i386.cc (ix86_const_divmod_cost): New function. > (ix86_vector_costs::add_stmt_cost): Use it for scalar > TRUNC_DIV_EXPR, TRUNC_MOD_EXPR and EXACT_DIV_EXPR by a nonzero > constant. > > gcc/testsuite/ChangeLog: > > * gcc.target/i386/slp-exact-div-cost.c: New test. > --- > gcc/config/i386/i386.cc | 56 ++++++++++++++++++- > .../gcc.target/i386/slp-exact-div-cost.c | 18 ++++++ > 2 files changed, 72 insertions(+), 2 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/i386/slp-exact-div-cost.c > > diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc > index 3f23c9a3aea..ac8ce496c81 100644 > --- a/gcc/config/i386/i386.cc > +++ b/gcc/config/i386/i386.cc > @@ -22898,6 +22898,43 @@ ix86_division_cost (const struct processor_costs *cost, > return cost->divide[MODE_INDEX (mode)]; > } > > +/* Return a rough cost of the scalar integer TRUNC_DIV_EXPR, TRUNC_MOD_EXPR > + or EXACT_DIV_EXPR CODE in MODE by the nonzero constant DIVISOR, > + approximating expand_divmod in expmed.cc. UNS is true for unsigned > + operations. */ > + > +static int > +ix86_const_divmod_cost (const struct processor_costs *cost, > + enum tree_code code, machine_mode mode, > + tree divisor, bool uns) > +{ > + bool mod_p = code == TRUNC_MOD_EXPR; > + if (tree_int_cst_sgn (divisor) == 1 && integer_pow2p (divisor)) > + { > + /* Unsigned or exact division/modulo is a single shift or mask. */ > + if (uns || code == EXACT_DIV_EXPR) > + return mod_p ? cost->add : cost->shift_const; > + > + /* Signed division/modulo adjusts negative dividends first. */ > + return cost->shift_const + 2 * cost->add + (mod_p ? cost->add : 0); > + } > + > + int mult = ix86_multiplication_cost (cost, mode); > + > + /* Exact division multiplies by the modular inverse. */ > + if (code == EXACT_DIV_EXPR) > + return mult; > + > + /* Truncating division uses high-part multiply, shift and add. */ > + int c = mult + cost->shift_const + cost->add; > + > + /* Modulo computes X - (X / D) * D. */ > + if (mod_p) > + c += mult + cost->add; > + > + return c; > +} > + > /* Return cost of shift in MODE. > If CONSTANT_OP1 is true, the op1 value is known and set in OP1_VAL. > AND_IN_OP1 specify in op1 is result of AND and SHIFT_AND_TRUNCATE > @@ -27025,15 +27062,30 @@ ix86_vector_costs::add_stmt_cost (int count, vect_cost_for_stmt kind, > stmt_cost = ix86_cost->add; > break; > case TRUNC_DIV_EXPR: > + case TRUNC_MOD_EXPR: > + case EXACT_DIV_EXPR: > + { > + tree op2 = gimple_assign_rhs2 (stmt_info->stmt); > + if (kind == scalar_stmt > + && SCALAR_INT_MODE_P (mode) > + && GET_MODE_SIZE (mode) <= UNITS_PER_WORD > + && TREE_CODE (op2) == INTEGER_CST > + && !integer_zerop (op2)) > + { > + stmt_cost = ix86_const_divmod_cost > + (ix86_cost, subcode, mode, op2, > + TYPE_UNSIGNED (TREE_TYPE (op2))); > + break; > + } > + } > + /* FALLTHRU */ > case CEIL_DIV_EXPR: > case FLOOR_DIV_EXPR: > case ROUND_DIV_EXPR: > - case TRUNC_MOD_EXPR: > case CEIL_MOD_EXPR: > case FLOOR_MOD_EXPR: > case RDIV_EXPR: > case ROUND_MOD_EXPR: > - case EXACT_DIV_EXPR: > stmt_cost = ix86_division_cost (ix86_cost, mode); > break; > > diff --git a/gcc/testsuite/gcc.target/i386/slp-exact-div-cost.c b/gcc/testsuite/gcc.target/i386/slp-exact-div-cost.c > new file mode 100644 > index 00000000000..12356eec8ab > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/slp-exact-div-cost.c > @@ -0,0 +1,18 @@ > +/* { dg-do compile { target { ! ia32 } } } */ > +/* { dg-options "-O2 -ftree-slp-vectorize -march=x86-64-v3" } */ > + > +/* The scalar cost of an exact division by a power of two is a shift, so > + the two pointer differences of the std::deque size computation are not > + worth vectorizing. */ > + > +struct it { void **cur, **first, **last, ***node; }; > +struct dq { void ***map; unsigned long map_size; struct it start, finish; }; > + > +long > +size (const struct dq *d) > +{ > + return 64 * (d->finish.node - d->start.node - (d->finish.node != 0)) > + + (d->finish.cur - d->finish.first) + (d->start.last - d->start.cur); > +} > + > +/* { dg-final { scan-assembler-not "vpsubq" } } */ > -- > 2.34.1 From richard.guenther@gmail.com Tue Nov 3 07:48:21 2026 From: richard.guenther@gmail.com (Richard Biener) Date: Tue, 3 Nov 2026 08:48:21 +0100 Subject: [PATCH] tree-optimization/128365 - fix leak in predicate::simplify_2 In-Reply-To: <20261102153311.1047076-1-yansendao@126.com> References: <20261102153311.1047076-1-yansendao@126.com> Message-ID: On Mon, Nov 2, 2026 at 4:34?PM Sendao Yan wrote: > > predicate::simplify_2 removes b_chain from m_preds via ordered_remove > without first releasing its heap-allocated storage, leaking it on each > successful simplification. > > Bootstrapped and regression tested on x86_64-pc-linux-gnu. OK. Thanks, Richard. > gcc/ChangeLog: > > * gimple-predicate-analysis.cc (predicate::simplify_2): Release > b_chain before removing it from m_preds. > --- > gcc/gimple-predicate-analysis.cc | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc > index 6ecb1bc0387..2ef62f9cf22 100644 > --- a/gcc/gimple-predicate-analysis.cc > +++ b/gcc/gimple-predicate-analysis.cc > @@ -1394,6 +1394,7 @@ predicate::simplify_2 () > if (neg_idx != -1U) > { > a_chain.ordered_remove (neg_idx); > + b_chain.release (); > m_preds.ordered_remove (j); > simplified = true; > if (a_chain.is_empty ()) > From rguenther@suse.de Tue Nov 3 07:49:25 2026 From: rguenther@suse.de (Richard Biener) Date: Tue, 3 Nov 2026 08:49:25 +0100 (CET) Subject: [PATCH] testsuite: Change 4 bitint tests to dg-do run In-Reply-To: References: Message-ID: On Mon, 2 Nov 2026, Jakub Jelinek wrote: > Hi! > > When working on the C++ _BitInt support (just posted), I've noticed that > 4 recentish bitint tests are just dg-do compile instead of dg-do run > as I've meant. 3 of those work without any changes, the 4th runs into > some problems. Three of them are problems in the testcase, for > signed _BitInt(1) -1 * -1 and -1 % -1 invoke UB and the check for > return value of large negative bit-precise int times 0, and there is > a question what -- and ++ operators should do on signed _BitInt(1), because > they are defined as E-=1 or E+=1 where 1 is of the appropriate type, > but signed _BitInt(1) doesn't have value 1, so we need E+=-1 and E-=-1 > instead. > Given > int > main () > { > signed _BitInt(3) a; > a = 3wb; > ++a; > a = -3wb - 1; > --a; > signed char b; > b = __SCHAR_MAX__; > ++b; > b = -__SCHAR_MAX__ - 1; > --b; > } > with -fsanitize=undefined, I think we already implement the > signed _BitInt --/++ as C23/C2Y says so right now, i.e. for > bit-precise integers it uses 1 of the appropriate type, for other > types too, but given E+=1 and E-=1 promotion rules for signed > char/char/signed short or extended signed integer types with precision > smaller than int do promote. > So it is just the weird signed _BitInt(1) case. > For C++ with the patch I've posted it behaves similarly despite the > current wording of the proposal, which I hope will be changed. > > Anyway, is this patch ok for trunk? OK. Richard. > 2026-11-02 Jakub Jelinek > > * gcc.dg/torture/bitint-96.c: Change dg-do compile to dg-do run. > (bar): Avoid signed _BitInt(1) -1 * -1 and -1 % -1 as that is UB. > Don't do predecrement and postincrement for now at runtime. > (main): Fix expected result of -large * 0 multiplication. > * gcc.dg/torture/bitint-97.c: Change dg-do compile to dg-do run. > * gcc.dg/torture/bitint-98.c: Likewise. > * gcc.dg/torture/bitint-99.c: Likewise. > > --- a/gcc/testsuite/gcc.dg/torture/bitint-96.c 2026-04-28 08:54:25.379972942 +0200 > +++ b/gcc/testsuite/gcc.dg/torture/bitint-96.c 2026-11-02 14:57:32.415742429 +0100 > @@ -1,5 +1,5 @@ > /* C2Y N3747 - Integer Sets, v5 */ > -/* { dg-do compile { target bitint } } */ > +/* { dg-do run { target bitint } } */ > /* { dg-options "-std=c2y -pedantic-errors" } */ > > #define expr_has_type(e, t) _Generic (e, default : 0, t : 1) > @@ -39,11 +39,11 @@ bar (_BitInt(1) a[21], signed _BitInt(1) > a[4] = b[4] - c[4]; > a[5] = b[5] - c[5]; > a[6] = b[6] * c[6]; > - a[7] = b[7] * c[8]; > + a[7] = b[7] * c[7]; > a[8] = b[8] * c[8]; > a[9] = b[9] / c[9]; > a[10] = b[10] % c[10]; > - a[11] = b[11] % c[11]; > + a[11] = b[10] % c[11]; > a[12] = b[12] & c[12]; > a[13] = b[13] & c[13]; > a[14] = b[14] & c[14]; > @@ -87,8 +87,16 @@ main () > { > if (b != 0 || c != -1) > __builtin_abort (); > - --b; > - ++c; > + if (0) > + { > + --b; > + ++c; > + } > + else > + { > + b += (_BitInt(1)) -1wb; > + c -= (_BitInt(1)) -1wb; > + } > if (b != -1 || c != 0) > __builtin_abort (); > b = ~b; > @@ -118,7 +126,7 @@ main () > 0, 0, -1, > 0, -1, -1, > 0, 0, -1 > - }; > + }; > bar (e, f, g); > _BitInt(1) h[21] = { > 0, -1, -1, > @@ -139,8 +147,7 @@ main () > __builtin_abort (); > if (baz (24807048826655379640613156875228202584070386120119745959437529938064756141700wb, 0wb) != 0wb) > __builtin_abort (); > - if (baz (-24807048826655379640613156875228202584070386120119745959437529938064756141700wb, 0wb) > - != 24807048826655379640613156875228202584070386120119745959437529938064756141700wb) > + if (baz (-24807048826655379640613156875228202584070386120119745959437529938064756141700wb, 0wb) != 0wb) > __builtin_abort (); > if (baz (0wb, ~0wb) != 0wb) > __builtin_abort (); > --- a/gcc/testsuite/gcc.dg/torture/bitint-97.c 2026-04-28 08:54:25.380071489 +0200 > +++ b/gcc/testsuite/gcc.dg/torture/bitint-97.c 2026-11-02 14:15:53.120759171 +0100 > @@ -1,5 +1,5 @@ > /* C2Y N3747 - Integer Sets, v5 */ > -/* { dg-do compile { target bitint } } */ > +/* { dg-do run { target bitint } } */ > /* { dg-options "-std=c2y -pedantic-errors -fwrapv" } */ > > [[gnu::noipa]] void > @@ -24,7 +24,7 @@ main () > }; > signed _BitInt(1) g[8] = { > -1, -1, -1, -1, -1, 0, 0, -1, > - }; > + }; > bar (e, f, g); > _BitInt(1) h[8] = { > 0, -1, -1, -1, 0, 0, -1, -1 > --- a/gcc/testsuite/gcc.dg/torture/bitint-98.c 2026-04-28 08:54:25.380165117 +0200 > +++ b/gcc/testsuite/gcc.dg/torture/bitint-98.c 2026-11-02 14:16:08.734552857 +0100 > @@ -1,5 +1,5 @@ > /* C2Y N3747 - Integer Sets, v5 */ > -/* { dg-do compile { target bitint } } */ > +/* { dg-do run { target bitint } } */ > /* { dg-options "-std=c2y -pedantic-errors" } */ > /* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ > /* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ > @@ -22,7 +22,6 @@ baz (_BitInt(256) x, _BitInt(256) y, _Bi > { > return __builtin_mul_overflow (x, y, z); > } > - > #endif > > int > --- a/gcc/testsuite/gcc.dg/torture/bitint-99.c 2026-05-30 09:46:04.466953334 +0200 > +++ b/gcc/testsuite/gcc.dg/torture/bitint-99.c 2026-11-02 14:16:14.882471619 +0100 > @@ -1,5 +1,5 @@ > /* C2Y N3705: bit-precise enum. */ > -/* { dg-do compile { target bitint } } */ > +/* { dg-do run { target bitint } } */ > /* { dg-options "-std=c2y -pedantic-errors" } */ > /* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ > /* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From rguenther@suse.de Tue Nov 3 07:51:22 2026 From: rguenther@suse.de (Richard Biener) Date: Tue, 3 Nov 2026 08:51:22 +0100 (CET) Subject: [PATCH] tree-optimization/127475 - avoid get_same_sized_vectype In-Reply-To: <2431365.ElGaqSPkdT@fomalhaut> References: <2431365.ElGaqSPkdT@fomalhaut> Message-ID: On Mon, 2 Nov 2026, Eric Botcazou wrote: > > This avoids using get_same_sized_vectype in vectorizable_induction > > where we only want a signed/unsigned variant of vectype. This > > avoids the oddball scalar boolean type handling in that function. > > > > Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. > > > > PR tree-optimization/127475 > > * tree-vect-loop.cc (vectorizable_induction): Use > > signed_or_unsigned_type_for to get the step vectype. > > May I backport this onto the 16 branch? I have attached an Ada testcase that > triggers the same ICE in const_vector_mask_from_tree as reported in the PR > when compiled for Aarch64 at -O2 with a 16.x compiler, which is a regression > from the 15.x compiler. Yes, it's OK to backport. Richard. > > * gnat.dg/specs/vect1.ads: New test. > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From stefansf@linux.ibm.com Tue Nov 3 07:55:17 2026 From: stefansf@linux.ibm.com (Stefan Schulze Frielinghaus) Date: Tue, 3 Nov 2026 08:55:17 +0100 Subject: [PATCH] s390: Properly set up operands in expand_perm_as_a_vlbr_vstbr_candidate Message-ID: <20261103075517.1581651-1-stefansf@linux.ibm.com> From: Stefan Schulze Frielinghaus Sashiko pointed out that in expand_perm_as_a_vlbr_vstbr_candidate, d.target and d.op0 were wrapped with gen_rtx_SUBREG before emitting bswap / rotate insn. Since targetm.vectorize.vec_perm_const is invoked in expand_vec_perm_const before operands are forced into registers, d.op0 is not guaranteed to be a REG. Blindly wrapping d.op0 with gen_rtx_SUBREG creates invalid RTL (such as nested subregs, subregs of constant vectors, or subregs of memory). Furthermore, wrapping d.target in a subreg generates ill-formed RTL. Fixed by simplifying subregs with simplify_gen_subreg, falling back to force_reg on d.op0 if necessary, and expanding the instruction via expand_insn with create_output_operand and create_input_operand to properly legitimize operands matching predicates. Similarly for expand_perm_with_merge ensure that simplify_gen_subreg cannot fail by forcing operands into registers. Committing this without tests since I couldn't come up with one which would expose those findings. Nonetheless, they should be fixed. gcc/ChangeLog: * config/s390/s390.cc (expand_perm_as_a_vlbr_vstbr_candidate): Use simplify_gen_subreg and expand_insn instead of gen_rtx_SUBREG. (expand_perm_with_merge): Force operands into registers. --- Bootstrap and regtest are still running. Will commit afterwards and wait for Sashikos results. gcc/config/s390/s390.cc | 72 ++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 507c53734e6..e902c97599b 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -18044,6 +18044,10 @@ expand_perm_with_merge (const struct expand_vec_perm_d &d) op0 = d.op0; op1 = d.op1; } + + op0 = force_reg (d.vmode, op0); + op1 = force_reg (d.vmode, op1); + if (mergemode != d.vmode) { target = simplify_gen_subreg (mergemode, target, d.vmode, 0); @@ -18239,56 +18243,52 @@ expand_perm_as_a_vlbr_vstbr_candidate (const struct expand_vec_perm_d &d) if (d.vmode != V16QImode || d.op0 != d.op1) return false; + insn_code icode; + machine_mode mode; + /* For halfwords a byte-swap is a rotate by 8 bits (verllh), which does not require VXE2. */ if (memcmp (d.perm, perm[0], MAX_VECT_LEN) == 0) { - if (!d.testing_p) - { - rtx target = gen_rtx_SUBREG (V8HImode, d.target, 0); - rtx op0 = gen_rtx_SUBREG (V8HImode, d.op0, 0); - emit_insn (gen_bswapv8hi (target, op0)); - } - return true; + mode = V8HImode; + icode = CODE_FOR_bswapv8hi; } - - if (!TARGET_VXE2) + /* All remaining operations require VXE2. */ + else if (!TARGET_VXE2) return false; - - if (memcmp (d.perm, perm[1], MAX_VECT_LEN) == 0) + else if (memcmp (d.perm, perm[1], MAX_VECT_LEN) == 0) { - if (!d.testing_p) - { - rtx target = gen_rtx_SUBREG (V4SImode, d.target, 0); - rtx op0 = gen_rtx_SUBREG (V4SImode, d.op0, 0); - emit_insn (gen_bswapv4si (target, op0)); - } - return true; + mode = V4SImode; + icode = CODE_FOR_bswapv4si; } - - if (memcmp (d.perm, perm[2], MAX_VECT_LEN) == 0) + else if (memcmp (d.perm, perm[2], MAX_VECT_LEN) == 0) { - if (!d.testing_p) - { - rtx target = gen_rtx_SUBREG (V2DImode, d.target, 0); - rtx op0 = gen_rtx_SUBREG (V2DImode, d.op0, 0); - emit_insn (gen_bswapv2di (target, op0)); - } - return true; + mode = V2DImode; + icode = CODE_FOR_bswapv2di; + } + else if (memcmp (d.perm, perm[3], MAX_VECT_LEN) == 0) + { + mode = V1TImode; + icode = CODE_FOR_bswapv1ti; } + else + return false; - if (memcmp (d.perm, perm[3], MAX_VECT_LEN) == 0) + if (!d.testing_p) { - if (!d.testing_p) - { - rtx target = gen_rtx_SUBREG (V1TImode, d.target, 0); - rtx op0 = gen_rtx_SUBREG (V1TImode, d.op0, 0); - emit_insn (gen_bswapv1ti (target, op0)); - } - return true; + rtx target = simplify_gen_subreg (mode, d.target, d.vmode, 0); + rtx op0 = simplify_gen_subreg (mode, d.op0, d.vmode, 0); + if (op0 == NULL_RTX) + op0 + = simplify_gen_subreg (mode, force_reg (d.vmode, d.op0), d.vmode, 0); + + class expand_operand ops[2]; + create_output_operand (&ops[0], target, mode); + create_input_operand (&ops[1], op0, mode); + expand_insn (icode, 2, ops); } - return false; + return true; } static bool -- 2.55.0 From rguenther@suse.de Tue Nov 3 07:59:03 2026 From: rguenther@suse.de (Richard Biener) Date: Tue, 3 Nov 2026 08:59:03 +0100 (CET) Subject: [PATCH] Remove null from pt_solution In-Reply-To: References: Message-ID: On Tue, 3 Nov 2026, Filip Kastl wrote: > On Mon 2026-11-02 12:52:25, Andrew MacLeod wrote: > > Thre is only one place (!!!!) that actually sets pt.null to 0 (meaning the > > range is nonnull) It is in tree-ssa-structalias.cc find_what_p_points_to() > > and it determines nonnullness based on : > > > > get_range_query (DECL_STRUCT_FUNCTION (fndecl))->range_of_expr (vr, p); > > bool nonnull = !vr.contains_zero_p (); > > <..> > > if (nonnull) > > set_ptr_nonnull (p); > > It's actually not true, that this is the only place that sets pt.null to 0 -- > find_what_var_points_to() can also produce pt_solution pt with pt.null = 0 > (when it creates the structure, it zero-initializes it by memset). Yes, in > find_what_pt_points_to() that gets overriden to whatever ranger thinks about > null-ness of a pointer. But that's not the only place > find_what_var_points_to() is called. > > On the other hand, when you look at the other calls to > find_what_var_points_to(), you see that those are only used to compute the > (IPA) escaped, escaped_return, IPA clobbers and IPA uses. I didn't check > as thoroughly as I'd like to, but I don't think that GCC ever makes use of > pt_solution.null for those PT sets. > > In case it really doesn't, I think we could not only remove pt_solution.null, > but also remove the NULL artificial variable from the PT constraints. That > would save a little bit of solving time. For my Steensgaard solver, that > could also be a significant boon in terms of precision. The PTA solver does not conservatively enough track NULL-ness (it's a bit of a misfit to try to track a NULL "object" and keep that distinct from an empty points-to set), and as we now make use of pt->null as "range" from the middle-end (see for example ptrs_compare_unequal), what PTA computes is thrown away and replaced with what we get from range-info. So pt_solution.null was only "limited range storage for pointers" (as SSA_NAME_RANGE_INFO was integer type only). So - removing pt_solution.null is good and will clean up this odd thing from PTA. Yay. (no longer need to track 'NULL', aka nothing_id, but simply use an empty set!) Richard. > Cheers, > Filip Kastl > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From rguenther@suse.de Tue Nov 3 08:04:33 2026 From: rguenther@suse.de (Richard Biener) Date: Tue, 3 Nov 2026 09:04:33 +0100 (CET) Subject: [PATCH] i386: Cost scalar division by a constant as its expansion In-Reply-To: References: <20261030055911.2471667-1-hongtao.liu@intel.com> Message-ID: <7sp715o5-7874-o734-2oqp-6nqsn69o980q@fhfr.qr> On Mon, 2 Nov 2026, Hongtao Liu wrote: > On Thu Oct 29, 2026 at 10:59 PM PDT, liuhongt wrote: > > ix86_vector_costs::add_stmt_cost costed every scalar integer division > > and modulo by the divide instruction, also when the divisor is a > > constant and the operation is expanded to shifts or a multiplication. > > This made the scalar cost of division by a constant inaccurate during > > vectorization costing; for example, an exact division by a power of two > > such as a pointer difference is a single scalar arithmetic shift, but > > charging the divide instruction cost made basic-block SLP vectorization > > into an emulated 64-bit vector shift look profitable. > > > > Return a rough cost of the scalar integer TRUNC_DIV_EXPR, TRUNC_MOD_EXPR > > or EXACT_DIV_EXPR by the nonzero constant divisor, approximating > > expand_divmod in expmed.cc. > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > > Ok for trunk? > Any comments? Looks reasonable to me. Richard. > > > > > gcc/ChangeLog: > > > > * config/i386/i386.cc (ix86_const_divmod_cost): New function. > > (ix86_vector_costs::add_stmt_cost): Use it for scalar > > TRUNC_DIV_EXPR, TRUNC_MOD_EXPR and EXACT_DIV_EXPR by a nonzero > > constant. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.target/i386/slp-exact-div-cost.c: New test. > > --- > > gcc/config/i386/i386.cc | 56 ++++++++++++++++++- > > .../gcc.target/i386/slp-exact-div-cost.c | 18 ++++++ > > 2 files changed, 72 insertions(+), 2 deletions(-) > > create mode 100644 gcc/testsuite/gcc.target/i386/slp-exact-div-cost.c > > > > diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc > > index 3f23c9a3aea..ac8ce496c81 100644 > > --- a/gcc/config/i386/i386.cc > > +++ b/gcc/config/i386/i386.cc > > @@ -22898,6 +22898,43 @@ ix86_division_cost (const struct processor_costs *cost, > > return cost->divide[MODE_INDEX (mode)]; > > } > > > > +/* Return a rough cost of the scalar integer TRUNC_DIV_EXPR, TRUNC_MOD_EXPR > > + or EXACT_DIV_EXPR CODE in MODE by the nonzero constant DIVISOR, > > + approximating expand_divmod in expmed.cc. UNS is true for unsigned > > + operations. */ > > + > > +static int > > +ix86_const_divmod_cost (const struct processor_costs *cost, > > + enum tree_code code, machine_mode mode, > > + tree divisor, bool uns) > > +{ > > + bool mod_p = code == TRUNC_MOD_EXPR; > > + if (tree_int_cst_sgn (divisor) == 1 && integer_pow2p (divisor)) > > + { > > + /* Unsigned or exact division/modulo is a single shift or mask. */ > > + if (uns || code == EXACT_DIV_EXPR) > > + return mod_p ? cost->add : cost->shift_const; > > + > > + /* Signed division/modulo adjusts negative dividends first. */ > > + return cost->shift_const + 2 * cost->add + (mod_p ? cost->add : 0); > > + } > > + > > + int mult = ix86_multiplication_cost (cost, mode); > > + > > + /* Exact division multiplies by the modular inverse. */ > > + if (code == EXACT_DIV_EXPR) > > + return mult; > > + > > + /* Truncating division uses high-part multiply, shift and add. */ > > + int c = mult + cost->shift_const + cost->add; > > + > > + /* Modulo computes X - (X / D) * D. */ > > + if (mod_p) > > + c += mult + cost->add; > > + > > + return c; > > +} > > + > > /* Return cost of shift in MODE. > > If CONSTANT_OP1 is true, the op1 value is known and set in OP1_VAL. > > AND_IN_OP1 specify in op1 is result of AND and SHIFT_AND_TRUNCATE > > @@ -27025,15 +27062,30 @@ ix86_vector_costs::add_stmt_cost (int count, vect_cost_for_stmt kind, > > stmt_cost = ix86_cost->add; > > break; > > case TRUNC_DIV_EXPR: > > + case TRUNC_MOD_EXPR: > > + case EXACT_DIV_EXPR: > > + { > > + tree op2 = gimple_assign_rhs2 (stmt_info->stmt); > > + if (kind == scalar_stmt > > + && SCALAR_INT_MODE_P (mode) > > + && GET_MODE_SIZE (mode) <= UNITS_PER_WORD > > + && TREE_CODE (op2) == INTEGER_CST > > + && !integer_zerop (op2)) > > + { > > + stmt_cost = ix86_const_divmod_cost > > + (ix86_cost, subcode, mode, op2, > > + TYPE_UNSIGNED (TREE_TYPE (op2))); > > + break; > > + } > > + } > > + /* FALLTHRU */ > > case CEIL_DIV_EXPR: > > case FLOOR_DIV_EXPR: > > case ROUND_DIV_EXPR: > > - case TRUNC_MOD_EXPR: > > case CEIL_MOD_EXPR: > > case FLOOR_MOD_EXPR: > > case RDIV_EXPR: > > case ROUND_MOD_EXPR: > > - case EXACT_DIV_EXPR: > > stmt_cost = ix86_division_cost (ix86_cost, mode); > > break; > > > > diff --git a/gcc/testsuite/gcc.target/i386/slp-exact-div-cost.c b/gcc/testsuite/gcc.target/i386/slp-exact-div-cost.c > > new file mode 100644 > > index 00000000000..12356eec8ab > > --- /dev/null > > +++ b/gcc/testsuite/gcc.target/i386/slp-exact-div-cost.c > > @@ -0,0 +1,18 @@ > > +/* { dg-do compile { target { ! ia32 } } } */ > > +/* { dg-options "-O2 -ftree-slp-vectorize -march=x86-64-v3" } */ > > + > > +/* The scalar cost of an exact division by a power of two is a shift, so > > + the two pointer differences of the std::deque size computation are not > > + worth vectorizing. */ > > + > > +struct it { void **cur, **first, **last, ***node; }; > > +struct dq { void ***map; unsigned long map_size; struct it start, finish; }; > > + > > +long > > +size (const struct dq *d) > > +{ > > + return 64 * (d->finish.node - d->start.node - (d->finish.node != 0)) > > + + (d->finish.cur - d->finish.first) + (d->start.last - d->start.cur); > > +} > > + > > +/* { dg-final { scan-assembler-not "vpsubq" } } */ > > -- > > 2.34.1 > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From richard.guenther@gmail.com Tue Nov 3 08:06:14 2026 From: richard.guenther@gmail.com (Richard Biener) Date: Tue, 3 Nov 2026 09:06:14 +0100 Subject: [PATCH] Remove alignment fields In-Reply-To: <7661b573-2422-4f77-9160-cd34e3131f80@redhat.com> References: <7661b573-2422-4f77-9160-cd34e3131f80@redhat.com> Message-ID: On Mon, Nov 2, 2026 at 6:55?PM Andrew MacLeod wrote: > > The alignment fields are in a prange_storage object just for > verification that the bitmasks ae returning the same values. > > At some point we'll want to remove the fields and just leave the bitmask > calculations I'm OK to do it now, or we can hold of and let things run > in the wild for a bit longer. > > bootstraps on x86_64-pc-linux-gnu with no regressions. OK for trunk > now? or hold off or a bit? OK early next week. Richard. > Andrew > > > Alignment is now tracked in prange's bitfields. There is no longer > a need to keep seperate align and misalign fields as the bitmask can > answer the same question. > > * tree-ssanames.cc (range_info_set_range): Do not save and > restore alignment fields when storage changes. > (get_ptr_info_alignment): Do not use alignment fields. > (mark_ptr_info_alignment_unknown): Ditto. > (set_ptr_info_alignment): Ditto. > (duplicate_ssa_name_range_info): Ditto. > * value-range-storage.cc (prange_storage::prange_storage): Ditto. > * value-range-storage.h (prange_storage::align): Remove. > (prange_storage::misalign): Remove. > --- > gcc/tree-ssanames.cc | 42 +++++--------------------------------- > gcc/value-range-storage.cc | 2 -- > gcc/value-range-storage.h | 6 ------ > 3 files changed, 5 insertions(+), 45 deletions(-) > > diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc > index 827aed0ab80..8f6e922e007 100644 > --- a/gcc/tree-ssanames.cc > +++ b/gcc/tree-ssanames.cc > @@ -173,27 +173,20 @@ range_info_set_range (tree name, const vrange &r) > { > if (!SSA_NAME_RANGE_INFO (name) || !range_info_fits_p (name, r)) > { > - // Preserve SSA-owned points-to and alignment information when the > + // Preserve SSA-owned points-to information when the > // variable-sized range storage must grow. > pt_solution *pt = NULL; > - unsigned int align = 0, misalign = 0; > if (prange_storage *old = ssa_name_prange_storage (name)) > - { > - pt = old->pt; > - align = old->align; > - misalign = old->misalign; > - } > + pt = old->pt; > if (SSA_NAME_RANGE_INFO (name)) > range_info_free (name); > vrange_storage *mem = range_info_alloc (name, r); > - if (mem && (pt || align)) > + if (mem && pt) > { > gcc_checking_assert (mem->m_discriminator == VR_PRANGE); > prange_storage *s = static_cast (mem); > s->pt = pt; > - s->align = align; > - s->misalign = misalign; > } > return mem != NULL; > } > @@ -852,18 +845,11 @@ get_ptr_info_alignment (const_tree name, unsigned > int *alignp, > return false; > prange_storage *s = ssa_name_prange_storage (name); > - > if (!s) > return false; > - bool known = bitmask_to_alignment (s->get_bitmask (TREE_TYPE (name)), > - alignp, misalignp); > - > - gcc_checking_assert (s->align <= 1 > - || (known && *alignp >= s->align > - && (*misalignp & (s->align - 1)) == s->misalign)); > - > - return known; > + return bitmask_to_alignment (s->get_bitmask (TREE_TYPE (name)), > + alignp, misalignp); > } > /* Clear NAME's known bits independently of the legacy alignment > fields. */ > @@ -871,14 +857,6 @@ get_ptr_info_alignment (const_tree name, unsigned > int *alignp, > void > mark_ptr_info_alignment_unknown (tree name) > { > - prange_storage *pi = ssa_name_prange_storage (name); > - > - if (pi) > - { > - pi->align = 0; > - pi->misalign = 0; > - } > - > if (!SSA_NAME_RANGE_INFO (name)) > return; > @@ -922,12 +900,6 @@ set_ptr_info_alignment (tree name, unsigned int > align, unsigned int misalign) > r.update_bitmask (cur); > if (r.undefined_p () || !range_info_set_range (name, r)) > return; > - > - /* Transitional fields are updated only after the range accepts the > - refinement. Reacquire storage since the update may reallocate it. */ > - prange_storage *s = ssa_name_prange_storage (name); > - s->align = align; > - s->misalign = misalign; > } > @@ -999,10 +971,6 @@ duplicate_ssa_name_range_info (tree name, tree src) > so it has to be copied as part of the same operation. */ > if (POINTER_TYPE_P (TREE_TYPE (src))) > duplicate_ssa_name_ptr_info (name, src); > - > - unsigned align, misalign; > - if (get_ptr_info_alignment (src, &align, &misalign)) > - set_ptr_info_alignment (name, align, misalign); > } > /* For a SSA copy DEST = SRC duplicate SSA info present on DEST to SRC > diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc > index bb2a58788b3..b7b23e380e4 100644 > --- a/gcc/value-range-storage.cc > +++ b/gcc/value-range-storage.cc > @@ -642,8 +642,6 @@ prange_storage::prange_storage (const prange &r) : > vrange_storage (VR_PRANGE) > // Only the accessors in tree-ssanames.cc ever make them non-zero, and > // range_info_set_range carries them across a reallocation. > pt = NULL; > - align = 0; > - misalign = 0; > unsigned num_words; > enum prange_kind kind = prange_format (r, num_words); > diff --git a/gcc/value-range-storage.h b/gcc/value-range-storage.h > index b58a2f23bd3..d721961c6c2 100644 > --- a/gcc/value-range-storage.h > +++ b/gcc/value-range-storage.h > @@ -140,12 +140,6 @@ public: > // reached only through ssa_name_pt_solution. > struct pt_solution *pt; > - // Alignment and misalignment of the pointer in bytes. Together > - // align and misalign specify low known bits of the pointer. > - // ptr & (align - 1) == misalign. > - unsigned int align; > - unsigned int misalign; > - > private: > DISABLE_COPY_AND_ASSIGN (prange_storage); > prange_storage (const prange &r); > -- > 2.56.0 > From tkaminsk@redhat.com Tue Nov 3 08:09:45 2026 From: tkaminsk@redhat.com (=?UTF-8?q?Tomasz=20Kami=C5=84ski?=) Date: Tue, 3 Nov 2026 09:09:45 +0100 Subject: [PATCH v2 3/3] libstdc++: Implement apply_result, is_applicable, and is_nothrow_applicable from P1317R2 In-Reply-To: <20261029171541.923427-4-tkaminsk@redhat.com> References: <20261029171541.923427-4-tkaminsk@redhat.com> Message-ID: <20261103081035.145488-1-tkaminsk@redhat.com> This implements C++26 paper: P1317R2, "Remove return type deduction in std::apply". The traits are implemented in terms of __(noexcept_)?unpack_tuple_like_v machinery, in consequence the definitions of corresponding primary templates are moved to . Partial specializations remain defined in bits/stl_pair.h and bits/range_utils.h, i.e. with of before definitions of corresponding types, which guarantees that they are visible at point of instantiation depending on them. While query trait is_applicable, is_nothrow_applicable could be expressed in terms of __(noexcept_)?unpack_tuple_like_v that produces boolean value, apply_result requires unpacking tuple to invoke_result. To handle above, __unpack_tuple_like_impl is introduced, whose value is object of trait type (false_type for non tuple like), and thus does not require presence of value member. libstdc++-v3/ChangeLog: * include/bits/version.def (apply): Bump to 202506. * include/bits/version.h: Regenerate. * include/std/type_traits (__cpp_lib_apply): Define. (std::__unpack_tuple_like_impl, std::__unpack_tuple_like): Define primary template. (std::__unpack_tuple_like_v): Move from bits/stl_pair.h and define in terms of __unpack_tuple_like. (std::apply_result, std::apply_result_t, std::is_applicable) (std::is_applicable_v, std::is_nothrow_applicable) (std::is_nothrow_applicable_v): Define. * include/bits/stl_pair.h (std::__noexcept_unpack_tuple_like_v): Move to std/type_traits. (std::__unpack_tuple_like_v): Move to std/type_traits, replace partial specialization with... (std::__unpack_tuple_like_impl): Define partial specializations. include/bits/ranges_util.h (std::__unpack_tuple_like_v): Replace partial specializations with... (std::__unpack_tuple_like_impl): Define partial specializations. * include/std/tuple (std::apply) [__glibcxx_apply >= 202506L]: Use apply_result_t as return tyep. * testsuite/std/ranges/subrange/tuple_like2.cc: Expand test for apply. * src/c++23/std.cc.in (std::apply_result, std::apply_result_t) (std::is_applicable, std::is_applicable_v) (std::is_nothrow_applicable, std::is_nothrow_applicable_v): Export. * testsuite/20_util/is_applicable/1.cc: New test. --- v2 adds export declarations for newly defined traits, as suggested by Jakub. *is_applicable* tested in all standard modes and modules this time. OK for trunk? libstdc++-v3/include/bits/ranges_util.h | 18 +- libstdc++-v3/include/bits/stl_pair.h | 69 +++--- libstdc++-v3/include/bits/version.def | 9 +- libstdc++-v3/include/bits/version.h | 7 +- libstdc++-v3/include/std/tuple | 7 +- libstdc++-v3/include/std/type_traits | 50 ++++ libstdc++-v3/src/c++23/std.cc.in | 8 + .../testsuite/20_util/is_applicable/1.cc | 221 ++++++++++++++++++ .../std/ranges/subrange/tuple_like2.cc | 48 ++++ 9 files changed, 386 insertions(+), 51 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/is_applicable/1.cc diff --git a/libstdc++-v3/include/bits/ranges_util.h b/libstdc++-v3/include/bits/ranges_util.h index 03335335454..c22febf7ed2 100644 --- a/libstdc++-v3/include/bits/ranges_util.h +++ b/libstdc++-v3/include/bits/ranges_util.h @@ -487,22 +487,22 @@ namespace ranges // Unpack a std::pair into a type trait and use its value. We also verify that // get is supported, i.e. iterator is copyable. template class _Trait, typename _Tp, typename _It, typename _St> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, ranges::subrange<_It, _St>> - = _Trait<_Tp, _It, _St>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, ranges::subrange<_It, _St>> + = _Trait<_Tp, _It, _St>{}; template class _Trait, typename _Tp, copyable _It, typename _St> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, ranges::subrange<_It, _St>&> - = _Trait<_Tp, _It, _St>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, ranges::subrange<_It, _St>&> + = _Trait<_Tp, _It, _St>{}; template class _Trait, typename _Tp, copyable _It, typename _St> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const ranges::subrange<_It, _St>> - = _Trait<_Tp, _It, _St>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, const ranges::subrange<_It, _St>> + = _Trait<_Tp, _It, _St>{}; template class _Trait, typename _Tp, copyable _It, typename _St> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const ranges::subrange<_It, _St>&> - = _Trait<_Tp, _It, _St>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, const ranges::subrange<_It, _St>&> + = _Trait<_Tp, _It, _St>{}; - // Subrange get are not marked noexcept + // Subrange get are not marked noexcept, so this is always false. template class _Trait, typename _Tp, typename _It, typename _St> constexpr bool __noexcept_unpack_tuple_like_v<_Trait, _Tp, ranges::subrange<_It, _St>> = false; diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index abe1ddc35b0..f93473cf415 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -235,72 +235,63 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif // lib concepts #if defined(__glibcxx_apply) || defined(__glibcxx_make_from_tuple) // C++ >= 17 - // Unpack tuple_like into a type trait and use its value. - template class _Trait, typename _Tp, typename _Tuple> - constexpr bool __unpack_tuple_like_v = false; - - // The version of above that check if calls to get are noexcept. - // Assume it is by default. - template class _Trait, typename _Tp, typename _Tuple> - constexpr bool __noexcept_unpack_tuple_like_v = __unpack_tuple_like_v<_Trait, _Tp, _Tuple>; - // Unpack a std::tuple into a type trait and use its value. template class _Trait, typename _Tp, typename... _Up> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, tuple<_Up...>> - = _Trait<_Tp, _Up...>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, tuple<_Up...>> + = _Trait<_Tp, _Up...>{}; template class _Trait, typename _Tp, typename... _Up> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, tuple<_Up...>&> - = _Trait<_Tp, _Up&...>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, tuple<_Up...>&> + = _Trait<_Tp, _Up&...>{}; template class _Trait, typename _Tp, typename... _Up> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const tuple<_Up...>> - = _Trait<_Tp, const _Up...>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, const tuple<_Up...>> + = _Trait<_Tp, const _Up...>{}; template class _Trait, typename _Tp, typename... _Up> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const tuple<_Up...>&> - = _Trait<_Tp, const _Up&...>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, const tuple<_Up...>&> + = _Trait<_Tp, const _Up&...>{}; // Unpack a std::pair into a type trait and use its value. template class _Trait, typename _Tp, typename _Fp, typename _Sp> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, pair<_Fp, _Sp>> - = _Trait<_Tp, _Fp, _Sp>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, pair<_Fp, _Sp>> + = _Trait<_Tp, _Fp, _Sp>{}; template class _Trait, typename _Tp, typename _Fp, typename _Sp> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, pair<_Fp, _Sp>&> - = _Trait<_Tp, _Fp&, _Sp&>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, pair<_Fp, _Sp>&> + = _Trait<_Tp, _Fp&, _Sp&>{}; template class _Trait, typename _Tp, typename _Fp, typename _Sp> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const pair<_Fp, _Sp>> - = _Trait<_Tp, const _Fp, const _Sp>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, const pair<_Fp, _Sp>> + = _Trait<_Tp, const _Fp, const _Sp>{}; template class _Trait, typename _Tp, typename _Fp, typename _Sp> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const pair<_Fp, _Sp>&> - = _Trait<_Tp, const _Fp&, const _Sp&>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, const pair<_Fp, _Sp>&> + = _Trait<_Tp, const _Fp&, const _Sp&>{}; namespace __detail { template class _Trait, typename _Tp, typename _Up, size_t... _Ids> - constexpr bool + constexpr auto __apply_repeated_arg(index_sequence<_Ids...>) - { return _Trait<_Tp, decltype(((void)_Ids, std::declval<_Up>()))...>::value; } + { return _Trait<_Tp, decltype(((void)_Ids, std::declval<_Up>()))...>{}; } } // Unpack a std::array into a type trait and use its value. template class _Trait, typename _Tp, typename _Up, size_t _Nm> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, array<_Up, _Nm>> + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, array<_Up, _Nm>> = __detail::__apply_repeated_arg<_Trait, _Tp, _Up>(make_index_sequence<_Nm>{}); template class _Trait, typename _Tp, typename _Up, size_t _Nm> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, array<_Up, _Nm>&> + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, array<_Up, _Nm>&> = __detail::__apply_repeated_arg<_Trait, _Tp, _Up&>(make_index_sequence<_Nm>{}); template class _Trait, typename _Tp, typename _Up, size_t _Nm> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const array<_Up, _Nm>> + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, const array<_Up, _Nm>> = __detail::__apply_repeated_arg<_Trait, _Tp, const _Up>(make_index_sequence<_Nm>{}); template class _Trait, typename _Tp, typename _Up, size_t _Nm> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const array<_Up, _Nm>&> + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, const array<_Up, _Nm>&> = __detail::__apply_repeated_arg<_Trait, _Tp, const _Up&>(make_index_sequence<_Nm>{}); #endif @@ -308,20 +299,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Unpack a std::complex into type trait and use it value. // Assume that real()/imag() does not throw. template class _Trait, typename _Tp, typename _Up> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, complex<_Up>> - = _Trait<_Tp, _Up, _Up>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, complex<_Up>> + = _Trait<_Tp, _Up, _Up>{}; template class _Trait, typename _Tp, typename _Up> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, complex<_Up>&> - = _Trait<_Tp, _Up&, _Up&>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, complex<_Up>&> + = _Trait<_Tp, _Up&, _Up&>{}; template class _Trait, typename _Tp, typename _Up> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const complex<_Up>> - = _Trait<_Tp, const _Up, const _Up>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, const complex<_Up>> + = _Trait<_Tp, const _Up, const _Up>{}; template class _Trait, typename _Tp, typename _Up> - constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const complex<_Up>&> - = _Trait<_Tp, const _Up&, const _Up&>::value; + constexpr auto __unpack_tuple_like_impl<_Trait, _Tp, const complex<_Up>&> + = _Trait<_Tp, const _Up&, const _Up&>{}; #endif // __is_tuple_like is defined in . diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index 340ef4203e1..3793efdfe35 100644 --- a/libstdc++-v3/include/bits/version.def +++ b/libstdc++-v3/include/bits/version.def @@ -91,7 +91,7 @@ ftms = { ftms = { // 202106 P0401R6 Providing size feedback in the Allocator interface // 202302 P2652R2 Disallow user specialization of allocator_traits - // LWG3887 Version macro for allocate_at_least + // LWG3887 Version macro for allocate_at_least name = allocate_at_least; values = { v = 202302; @@ -371,6 +371,13 @@ ftms = { ftms = { name = apply; + // 202506 P1317R2 Remove return type deduction in std::apply + // 202603 P3795R2 Miscellaneous Reflection Cleanup + // LWG4567 Feature test macro value for apply_result, is_applicable + values = { + v = 202506; + cxxmin = 26; + }; values = { v = 201603; cxxmin = 17; diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h index 3175bc1b65b..8651e2c56c5 100644 --- a/libstdc++-v3/include/bits/version.h +++ b/libstdc++-v3/include/bits/version.h @@ -396,7 +396,12 @@ #undef __glibcxx_want_any #if !defined(__cpp_lib_apply) -# if (__cplusplus >= 201703L) +# if (__cplusplus > 202302L) +# define __glibcxx_apply 202506L +# if defined(__glibcxx_want_all) || defined(__glibcxx_want_apply) +# define __cpp_lib_apply 202506L +# endif +# elif (__cplusplus >= 201703L) # define __glibcxx_apply 201603L # if defined(__glibcxx_want_all) || defined(__glibcxx_want_apply) # define __cpp_lib_apply 201603L diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index fd89f6d2540..e273ed0a817 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -2926,9 +2926,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #else template #endif - constexpr decltype(auto) + constexpr auto apply(_Fn&& __f, _Tuple&& __t) noexcept(__noexcept_unpack_tuple_like_v) +#if __glibcxx_apply >= 202506L // >= C++26 + -> apply_result_t<_Fn, _Tuple> +#else + -> decltype(auto) +#endif { using _Indices = make_index_sequence>>; diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 83dbad17ade..44e119adc81 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -39,6 +39,7 @@ #include +#define __glibcxx_want_apply #define __glibcxx_want_bool_constant #define __glibcxx_want_bounded_array_traits #define __glibcxx_want_common_reference @@ -3074,6 +3075,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __is_tuple_like : public __is_tuple_like_impl<__remove_cvref_t<_Tp>>::type { }; + +#if defined(__glibcxx_apply) || defined(__glibcxx_make_from_tuple) // C++ >= 17 + // Unpack tuple_like into a type trait and use its value. + template class _Trait, typename _Tp, typename _Tuple> + constexpr auto __unpack_tuple_like_impl = false_type{}; + + template class _Trait, typename _Tp, typename _Tuple> + using __unpack_tuple_like = remove_cv_t)>; + + template class _Trait, typename _Tp, typename _Tuple> + constexpr bool __unpack_tuple_like_v = __unpack_tuple_like<_Trait, _Tp, _Tuple>::value; + + // The version of above that check if calls to get are noexcept. Assume it is by default. + template class _Trait, typename _Tp, typename _Tuple> + constexpr bool __noexcept_unpack_tuple_like_v = __unpack_tuple_like<_Trait, _Tp, _Tuple>::value; +#endif /// @endcond template @@ -4412,6 +4429,39 @@ template } #endif +#if __glibcxx_apply >= 202506L // C++26 + template + struct apply_result + { }; + + template + requires (!is_same_v<__unpack_tuple_like<__invoke_result, _Fn, _Tuple>, false_type>) + struct apply_result<_Fn, _Tuple> + : __unpack_tuple_like<__invoke_result, _Fn, _Tuple> + { }; + + template + using apply_result_t = typename apply_result<_Fn, _Tuple>::type; + + template + struct is_applicable + : __unpack_tuple_like + { }; + + template + struct is_nothrow_applicable + : bool_constant<__noexcept_unpack_tuple_like_v> + { }; + + template + constexpr bool is_applicable_v + = __unpack_tuple_like_v; + + template + constexpr bool is_nothrow_applicable_v + = __noexcept_unpack_tuple_like_v; +#endif + /// @} group metaprogramming _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/src/c++23/std.cc.in b/libstdc++-v3/src/c++23/std.cc.in index d05902466d9..51286d4c7a3 100644 --- a/libstdc++-v3/src/c++23/std.cc.in +++ b/libstdc++-v3/src/c++23/std.cc.in @@ -3626,6 +3626,14 @@ export namespace std #if __cpp_lib_within_lifetime >= 202306L using std::is_within_lifetime; #endif +#if __cpp_lib_apply >= 202506L + using std::apply_result; + using std::apply_result_t; + using std::is_applicable; + using std::is_applicable_v; + using std::is_nothrow_applicable; + using std::is_nothrow_applicable_v; +#endif } // diff --git a/libstdc++-v3/testsuite/20_util/is_applicable/1.cc b/libstdc++-v3/testsuite/20_util/is_applicable/1.cc new file mode 100644 index 00000000000..0a1073dad3b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_applicable/1.cc @@ -0,0 +1,221 @@ +// { dg-do compile { target c++26 } } + +#include + +#ifndef __cpp_lib_apply +# error "Feature-test macro for is_applicable missing in " +#elif __cpp_lib_apply < 202506L +# error "Feature-test macro for is_applicable has wrong value in " +#endif + +#include +#include +#include +#include + +template +concept can_apply = requires (Fn f, Tuple t) +{ std::apply(std::forward(f), std::forward(t)); }; + +template +constexpr void +check_apply() +{ + constexpr bool callable = (V > 0); + constexpr bool noex = (V > 1); + + static_assert(can_apply == callable); + + static_assert(std::is_applicable::value == callable); + static_assert(std::is_applicable_v == callable); + + static_assert(std::is_nothrow_applicable::value == noex); + static_assert(std::is_nothrow_applicable_v == noex); + + if constexpr (callable) + { + static_assert(std::is_same_v::type>); + static_assert(std::is_same_v>); + } + else + { + static_assert(!requires { typename std::apply_result::type; }); + static_assert(!requires { typename std::apply_result_t; }); + } +} + +struct Throw +{ + Throw(float) {} +}; + +template +T f(T t, U) noexcept(Noex) +{ return t; } + +template typename SamePair> +void +test_val() +{ + check_apply<2, float, decltype(&f), SamePair>(); + check_apply<2, float, decltype(&f), SamePair>(); + check_apply<1, Throw, decltype(&f), SamePair>(); + + check_apply<1, float, decltype(&f), SamePair>(); + check_apply<1, Throw, decltype(&f), SamePair>(); + + check_apply<0, float, decltype(&f), SamePair()>(); +} + +template typename SamePair> +void +test_ref() +{ + check_apply<2, float&&, decltype(&f), SamePair>(); + check_apply<0, float&&, decltype(&f), SamePair&>(); + check_apply<0, float&&, decltype(&f), const SamePair>(); + check_apply<0, float&&, decltype(&f), const SamePair&>(); + + check_apply<0, float&, decltype(&f), SamePair>(); + check_apply<2, float&, decltype(&f), SamePair&>(); + check_apply<0, float&, decltype(&f), const SamePair>(); + check_apply<0, float&, decltype(&f), const SamePair&>(); + + check_apply<2, const float&, decltype(&f), SamePair>(); + check_apply<2, const float&, decltype(&f), SamePair&>(); + check_apply<2, const float&, decltype(&f), const SamePair>(); + check_apply<2, const float&, decltype(&f), const SamePair&>(); +} + +struct Func +{ + int f(Func) noexcept { return 1; } + int cf(Func) const noexcept { return 2; } + + int rq(Func) && noexcept { return 1; } + int lq(Func) & noexcept { return 1; } + int crq(Func) const&& noexcept { return 1; } + int clq(Func) const& noexcept { return 1; } +}; + +template typename SamePair> +void +test_member() +{ + check_apply<2, int, decltype(&Func::f), SamePair>(); + check_apply<2, int, decltype(&Func::f), SamePair&>(); + check_apply<0, int, decltype(&Func::f), const SamePair>(); + check_apply<0, int, decltype(&Func::f), const SamePair&>(); + + check_apply<2, int, decltype(&Func::cf), SamePair>(); + check_apply<2, int, decltype(&Func::cf), SamePair&>(); + check_apply<2, int, decltype(&Func::cf), const SamePair>(); + check_apply<2, int, decltype(&Func::cf), const SamePair&>(); + + check_apply<2, int, decltype(&Func::rq), SamePair>(); + check_apply<0, int, decltype(&Func::rq), SamePair&>(); + check_apply<0, int, decltype(&Func::rq), const SamePair>(); + check_apply<0, int, decltype(&Func::rq), const SamePair&>(); + + check_apply<2, int, decltype(&Func::crq), SamePair>(); + check_apply<0, int, decltype(&Func::crq), SamePair&>(); + check_apply<2, int, decltype(&Func::crq), const SamePair>(); + check_apply<0, int, decltype(&Func::crq), const SamePair&>(); + + check_apply<0, int, decltype(&Func::lq), SamePair>(); + check_apply<2, int, decltype(&Func::lq), SamePair&>(); + check_apply<0, int, decltype(&Func::lq), const SamePair>(); + check_apply<0, int, decltype(&Func::lq), const SamePair&>(); + + check_apply<2, int, decltype(&Func::clq), SamePair>(); + check_apply<2, int, decltype(&Func::clq), SamePair&>(); + check_apply<2, int, decltype(&Func::clq), const SamePair>(); + check_apply<2, int, decltype(&Func::clq), const SamePair&>(); +} + +template typename SamePair> +void +test_quals() +{ + check_apply<0, float&&, decltype(&f), SamePair>(); + check_apply<0, float&&, decltype(&f), SamePair>(); + + check_apply<0, float&, decltype(&f), SamePair&>(); + check_apply<0, float&, decltype(&f), SamePair&>(); +} + +template typename SamePair> +void +test_ref_args() +{ + check_apply<2, float&&, decltype(&f), SamePair>(); + check_apply<0, float&&, decltype(&f), SamePair&>(); + check_apply<0, float&&, decltype(&f), SamePair>(); + check_apply<0, float&&, decltype(&f), SamePair>(); + + check_apply<2, float&, decltype(&f), SamePair>(); + check_apply<2, float&, decltype(&f), SamePair&>(); + check_apply<0, float&, decltype(&f), SamePair>(); + check_apply<2, float&, decltype(&f), SamePair&>(); + check_apply<0, float&, decltype(&f), SamePair>(); +} + +template typename Pair> +void +test_mixed() +{ + check_apply<2, float, decltype(&f), Pair>(); + check_apply<0, float, decltype(&f), Pair>(); + + check_apply<2, float&, decltype(&f), Pair&>(); + check_apply<0, float&, decltype(&f), Pair&>(); + + check_apply<2, float&, decltype(&f), Pair>(); + check_apply<0, float&, decltype(&f), Pair>(); +} + +template +using TuplePair = std::tuple; + +template +using PairPair = std::pair; + +template +using ArrayPair = std::array; + +template +using ComplexPair = std::complex; + +void +test_by_val() +{ + test_val(); + test_val(); + test_val(); + test_val(); + + test_ref(); + test_ref(); + test_ref(); + test_ref(); + + test_member(); + test_member(); + test_member(); + + test_quals(); + test_quals(); + test_ref_args(); + test_ref_args(); + + test_mixed(); + test_mixed(); + + check_apply<0, float, decltype(&f), std::tuple<>>(); + check_apply<0, float, decltype(&f), std::array>(); + check_apply<0, float, decltype(&f), std::tuple>(); + check_apply<0, float, decltype(&f), std::array>(); + check_apply<0, float, decltype(&f), std::tuple>(); + check_apply<0, float, decltype(&f), std::array>(); +} + diff --git a/libstdc++-v3/testsuite/std/ranges/subrange/tuple_like2.cc b/libstdc++-v3/testsuite/std/ranges/subrange/tuple_like2.cc index 614e690d0e5..0f9c29609e4 100644 --- a/libstdc++-v3/testsuite/std/ranges/subrange/tuple_like2.cc +++ b/libstdc++-v3/testsuite/std/ranges/subrange/tuple_like2.cc @@ -85,10 +85,45 @@ test_tuple_cat() VERIFY( std::get<3>(r) == "hello" ); } +template +concept can_apply = requires (Fn f, Tuple t) +{ std::apply(std::forward(f), std::forward(t)); }; + template concept can_make_from_tuple = requires (Tuple t) { std::make_from_tuple(std::forward(t)); }; +template +constexpr void +check_apply() +{ +#if __cpp_lib_apply >= 202506L + constexpr bool callable = (V > 0); + constexpr bool noex = (V > 1); + + static_assert(can_apply == callable); + + static_assert(std::is_applicable::value == callable); + static_assert(std::is_applicable_v == callable); + + static_assert(std::is_nothrow_applicable::value == noex); + static_assert(std::is_nothrow_applicable_v == noex); + + if constexpr (callable) + { + static_assert(std::is_same_v::type>); + static_assert(std::is_same_v>); + } + else + { + static_assert(!requires { typename std::apply_result::type; }); + static_assert(!requires { typename std::apply_result_t; }); + } +#else + static_assert(can_apply); +#endif +} + struct Cont { template @@ -115,15 +150,28 @@ test_apply() auto r1 = std::apply(f, rng); VERIFY( r1 ); static_assert( noexcept(std::apply(f, rng)) == noexcept_get ); + check_apply<1, bool, decltype((f)), R&>(); auto r2 = std::apply(f, crng); VERIFY( r2 ); static_assert( noexcept(std::apply(f, crng)) == noexcept_get ); + check_apply<1, bool, decltype((f)), const R&>(); } + else + { + check_apply<0, bool, decltype((f)), R&>(); + check_apply<0, bool, decltype((f)), const R&>(); + } + + auto g = [](int, int) noexcept { }; + check_apply<0, void, decltype((g)), R>(); + check_apply<0, void, decltype((g)), R&>(); + check_apply<0, void, decltype((g)), const R&>(); auto r = std::apply(f, std::move(rng)); VERIFY( r ); static_assert( noexcept(std::apply(f, std::move(rng))) == noexcept_get ); + check_apply<1, bool, decltype((f)), R>(); if constexpr (std::copyable) { -- 2.56.0 From tkaminsk@redhat.com Tue Nov 3 08:11:24 2026 From: tkaminsk@redhat.com (Tomasz Kaminski) Date: Tue, 3 Nov 2026 09:11:24 +0100 Subject: [PATCH] libstdc++: Export apply_result, is_applicable, and is_nothrow_applicable from std module In-Reply-To: References: <20261029171541.923427-1-tkaminsk@redhat.com> <20261029171541.923427-4-tkaminsk@redhat.com> Message-ID: On Mon, Nov 2, 2026 at 11:13?PM Jakub Jelinek wrote: > On Mon, Nov 02, 2026 at 06:47:49PM +0100, Tomasz Kaminski wrote: > > > > Here is an incremental fix for that, tested on x86_64-linux, > > > > ok for trunk if this series is approved? > > > > > I will include that in the patch v2, if you do not mind. > > Ok, thanks. > Done: https://gcc.gnu.org/pipermail/libstdc++/2026-November/068183.html > > Jakub > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hongtao.liu@intel.com Tue Nov 3 08:12:42 2026 From: hongtao.liu@intel.com (Liu, Hongtao) Date: Tue, 3 Nov 2026 08:12:42 +0000 Subject: [PATCH] i386: Fix REX2 register check for CS-prefixed indirect calls [PR128388] In-Reply-To: <20261103081146.1881468-1-hongyu.wang@intel.com> References: <20261103081146.1881468-1-hongyu.wang@intel.com> Message-ID: > -----Original Message----- > From: Wang, Hongyu > Sent: Tuesday, November 3, 2026 4:12 PM > To: gcc-patches@gcc.gnu.org > Cc: Liu, Hongtao ; ubizjak@gmail.com > Subject: [PATCH] i386: Fix REX2 register check for CS-prefixed indirect calls > [PR128388] > > Hi, > > The indirect call path of ix86_output_indirect_branch_via_reg tested > REX_INT_REGNO_P twice. Fix it to test REX2_INT_REGNO_P so -mindirect- > branch-cs-prefix also adds CS for calls via r16-r31 thunks. > > Bootstrapped/regtested on x86_64-pc-linux-gnu{-m32,}. Ok for trunk and > backport down to gcc-14? Ok. > > gcc/ChangeLog: > > PR target/128388 > * config/i386/i386.cc (ix86_output_indirect_branch_via_reg): > Check REX2_INT_REGNO_P instead of REX_INT_REGNO_P twice. > > gcc/testsuite/ChangeLog: > > PR target/128388 > * gcc.target/i386/pr128388.c: New test. > --- > gcc/config/i386/i386.cc | 2 +- > gcc/testsuite/gcc.target/i386/pr128388.c | 22 ++++++++++++++++++++++ > 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 > gcc/testsuite/gcc.target/i386/pr128388.c > > diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index > 25d7e813446..9c8efc25ef2 100644 > --- a/gcc/config/i386/i386.cc > +++ b/gcc/config/i386/i386.cc > @@ -17526,7 +17526,7 @@ ix86_output_indirect_branch_via_reg (rtx > call_op, bool sibcall_p) > { > if (thunk_name != NULL) > { > - if ((REX_INT_REGNO_P (regno) || REX_INT_REGNO_P (regno)) > + if ((REX_INT_REGNO_P (regno) || REX2_INT_REGNO_P (regno)) > && ix86_indirect_branch_cs_prefix) > fprintf (asm_out_file, "\tcs\n"); > fprintf (asm_out_file, "\tcall\t"); > diff --git a/gcc/testsuite/gcc.target/i386/pr128388.c > b/gcc/testsuite/gcc.target/i386/pr128388.c > new file mode 100644 > index 00000000000..fde34a0f8ed > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/pr128388.c > @@ -0,0 +1,22 @@ > +/* PR target/128388 */ > +/* { dg-do compile { target { ! ia32 } } } */ > +/* { dg-options "-O2 -mapxf -mindirect-branch-cs-prefix > +-mindirect-branch=thunk-extern -ffixed-rax -ffixed-rbx -ffixed-rcx > +-ffixed-rdx -ffixed-rsi -ffixed-rdi -ffixed-rbp -ffixed-r8 -ffixed-r9 > +-ffixed-r10 -ffixed-r11 -ffixed-r12 -ffixed-r13 -ffixed-r14 > +-ffixed-r15" } */ > +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ > + > +extern void (*fptr) (void); > + > +void > +foo (void) > +{ > + fptr (); > +} > + > +int > +bar (void) > +{ > + fptr (); > + return 0; > +} > + > +/* { dg-final { scan-assembler-times "\tcs\n\tjmp\[ > +\t\]+_?__x86_indirect_thunk_r16" 1 } } */ > +/* { dg-final { scan-assembler-times "\tcs\n\tcall\[ > +\t\]+_?__x86_indirect_thunk_r16" 1 } } */ > -- > 2.31.1 From hongyu.wang@intel.com Tue Nov 3 08:11:46 2026 From: hongyu.wang@intel.com (Hongyu Wang) Date: Tue, 3 Nov 2026 16:11:46 +0800 Subject: [PATCH] i386: Fix REX2 register check for CS-prefixed indirect calls [PR128388] Message-ID: <20261103081146.1881468-1-hongyu.wang@intel.com> Hi, The indirect call path of ix86_output_indirect_branch_via_reg tested REX_INT_REGNO_P twice. Fix it to test REX2_INT_REGNO_P so -mindirect-branch-cs-prefix also adds CS for calls via r16-r31 thunks. Bootstrapped/regtested on x86_64-pc-linux-gnu{-m32,}. Ok for trunk and backport down to gcc-14? gcc/ChangeLog: PR target/128388 * config/i386/i386.cc (ix86_output_indirect_branch_via_reg): Check REX2_INT_REGNO_P instead of REX_INT_REGNO_P twice. gcc/testsuite/ChangeLog: PR target/128388 * gcc.target/i386/pr128388.c: New test. --- gcc/config/i386/i386.cc | 2 +- gcc/testsuite/gcc.target/i386/pr128388.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr128388.c diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 25d7e813446..9c8efc25ef2 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -17526,7 +17526,7 @@ ix86_output_indirect_branch_via_reg (rtx call_op, bool sibcall_p) { if (thunk_name != NULL) { - if ((REX_INT_REGNO_P (regno) || REX_INT_REGNO_P (regno)) + if ((REX_INT_REGNO_P (regno) || REX2_INT_REGNO_P (regno)) && ix86_indirect_branch_cs_prefix) fprintf (asm_out_file, "\tcs\n"); fprintf (asm_out_file, "\tcall\t"); diff --git a/gcc/testsuite/gcc.target/i386/pr128388.c b/gcc/testsuite/gcc.target/i386/pr128388.c new file mode 100644 index 00000000000..fde34a0f8ed --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr128388.c @@ -0,0 +1,22 @@ +/* PR target/128388 */ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mapxf -mindirect-branch-cs-prefix -mindirect-branch=thunk-extern -ffixed-rax -ffixed-rbx -ffixed-rcx -ffixed-rdx -ffixed-rsi -ffixed-rdi -ffixed-rbp -ffixed-r8 -ffixed-r9 -ffixed-r10 -ffixed-r11 -ffixed-r12 -ffixed-r13 -ffixed-r14 -ffixed-r15" } */ +/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */ + +extern void (*fptr) (void); + +void +foo (void) +{ + fptr (); +} + +int +bar (void) +{ + fptr (); + return 0; +} + +/* { dg-final { scan-assembler-times "\tcs\n\tjmp\[ \t\]+_?__x86_indirect_thunk_r16" 1 } } */ +/* { dg-final { scan-assembler-times "\tcs\n\tcall\[ \t\]+_?__x86_indirect_thunk_r16" 1 } } */ -- 2.31.1 From richard.guenther@gmail.com Tue Nov 3 08:16:09 2026 From: richard.guenther@gmail.com (Richard Biener) Date: Tue, 3 Nov 2026 09:16:09 +0100 Subject: [RFC PATCH] c/c++: no_implicit_truncation attribute [PR96570] In-Reply-To: <0d61e1c8-82f6-5e6a-ac0b-6cae6b6ebbaf@redhat.com> References: <0d61e1c8-82f6-5e6a-ac0b-6cae6b6ebbaf@redhat.com> Message-ID: On Fri, Oct 30, 2026 at 9:46?PM Joseph Myers wrote: > > Bug 96570 requests warnings for truncation of time_t values to > narrower integer types, to detect code that uses int as an > intermediate type for storing values originally obtained from the > system as time_t. This was extended in subsequent comments in that > bug to include a request for such warnings also for widening a > narrower integer type to time_t, to detect code that obtains a time > using interfaces such as atoi (from text in a file, over the network, > etc.) and then stores it in a time_t, since the interfaces used to > obtain the time in that case would also not work with times after > Y2038. > > Richard prototyped such warnings specifically for time_t in > , and > I noted in discussions of that patch that it should be based on an > attribute rather than specifically the time_t name; such warnings > might well make sense for some other types such as off_t where there > is also a risk of code using int inappropriately to store values of > such a type. (Actual addition of the attribute to any specific > standard library type would probably require distribution build > testing to see how large the impact is, and what the true / false > positive numbers are.) > > This patch implements the warnings based on an attribute > no_implicit_truncation (only for non-boolean integer types), as > previously suggested, with the attribute being preserved by the usual > arithmetic conversions (and by the integer promotions, in the unlikely > case of being applied to a type narrower than int). For narrowing > conversions, the warnings are handled as a variant of -Wconversion > warnings (but enabled by default), thus using existing logic for such > warnings (and if smarts are added to know that certain conversions > cannot change a value, they would apply to both -Wconversion and the > new -Wconversion-attribute). For widening conversions, there is new > logic to check, which tries to avoid cases that are unlikely to be > problematic: widening conversions of constants to types with the new > attribute do not warn, and nor do conversions in arithmetic ("time += > int_offset;" is presumed to be OK), but implicit widening conversions > in other contexts (comparisons, conditional expressions, "time = > int_value;") do warn. > > The feature applies for both C and C++. Preservation of the attribute > in the usual arithmetic conversions is automatic for C++, where the > usual arithmetic conversions are already implemented to merge > attributes from the operands, but requires specific implementation for > C. This leads to a question for C++: should the attribute merging be > changed to *remove* the no_implicit_truncation attribute when either > type is not an integer type, to avoid it otherwise being applied > (meaninglessly) to floating types? Other questions to consider: what > further cases (that may already work) should be added to the > testcases? Should the initial implementation add smarts to avoid > warning for more cases such as "int secs = time % 60;" in particular, > or should such things be left to possible followups based on the > extent to which such cases are found to occur in real code? > > Bootstrapped with no regressions for x86_64-pc-linux-gnu. Thanks for working on this. I wonder how one would practically use this to audit code for the time_t issues without patching glibc headers though? We're using a somewhat evolved variant of the original prototype where it is just enabling a new -W flag. I suppose the most practical solution would be to indeed patch glibc headers but gate the attribute with some preprocessor conditional like _TIME_T_NO_IMPLICIT_TRUNCATION and have that set? Thanks, Richard. > PR c/96570 > > gcc/ > * doc/extend.texi (no_implicit_truncation): New attribute. > * doc/invoke.texi (-Wno-conversion-attribute): New option. > > gcc/c-family/ > * c-attribs.cc (handle_no_implicit_truncation_attribute): New > function. > (c_common_gnu_attributes): Add no_implicit_truncation. > * c-warn.cc (conversion_warning): Handle -Wconversion-attribute > warnings for narrowing conversion from type with > no_implicit_truncation attribute. > (warnings_for_convert_and_check): Warn for widening conversion > to type with no_implicit_truncation attribute. > * c.opt (Wconversion-attribute): New option. > > gcc/c/ > * c-typeck.cc (c_maybe_no_implicit_truncation): New function. > (c_common_type): Preserve no_implicit_truncation attribute when > both types are integer types. > (perform_integral_promotions): Preserve no_implicit_truncation > attribute. > (build_binary_op): Warn for widening conversion to > no_implicit_truncation type in comparisons. Disable warning for > such conversion in arithmetic. > > gcc/cp/ > * cvt.cc (type_promotes_to): Preserve no_implicit_truncation > attribute. > * typeck.cc (cp_build_binary_op): Disable -Wconversion-attribute > for conversion in arithmetic. > > gcc/testsuite/ > * c-c++-common/no_implicit_truncation-1.c: > c-c++-common/no_implicit_truncation-2.c, > c-c++-common/no_implicit_truncation-3.c, > gcc.dg/no_implicit_truncation-bitint-1.c: New tests. > > diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc > index aab9f2cb9e3b..cf6fe3fd4210 100644 > --- a/gcc/c-family/c-attribs.cc > +++ b/gcc/c-family/c-attribs.cc > @@ -169,6 +169,8 @@ static tree handle_signed_bool_precision_attribute (tree *, tree, tree, int, > static tree handle_hardbool_attribute (tree *, tree, tree, int, bool *); > static tree handle_fd_arg_attribute (tree *, tree, tree, int, bool *); > static tree handle_flag_enum_attribute (tree *, tree, tree, int, bool *); > +static tree handle_no_implicit_truncation_attribute (tree *, tree, tree, int, > + bool *); > static tree handle_null_terminated_string_arg_attribute (tree *, tree, tree, int, bool *); > > static tree handle_btf_decl_tag_attribute (tree *, tree, tree, int, bool *); > @@ -579,7 +581,9 @@ const struct attribute_spec c_common_gnu_attributes[] = > { "btf_type_tag", 1, 1, false, true, false, false, > handle_btf_type_tag_attribute, NULL}, > { "btf_decl_tag", 1, 1, true, false, false, false, > - handle_btf_decl_tag_attribute, NULL} > + handle_btf_decl_tag_attribute, NULL}, > + { "no_implicit_truncation", 0, 0, false, true, false, false, > + handle_no_implicit_truncation_attribute, NULL } > }; > > const struct scoped_attribute_specs c_common_gnu_attribute_table = > @@ -4601,6 +4605,32 @@ handle_null_terminated_string_arg_attribute (tree *node, tree name, tree args, > return NULL_TREE; > } > > +/* Handle the "no_implicit_truncation" attribute. */ > + > +static tree > +handle_no_implicit_truncation_attribute (tree *node, tree name, > + tree ARG_UNUSED (args), > + int ARG_UNUSED (flags), > + bool *no_add_attrs) > +{ > + if (!INTEGRAL_TYPE_P (*node)) > + { > + warning (OPT_Wattributes, "%qE attribute ignored on non-integer type", > + name); > + *no_add_attrs = true; > + } > + else if (TREE_CODE (*node) == BOOLEAN_TYPE > + || (TREE_CODE (*node) == ENUMERAL_TYPE > + && TREE_CODE (ENUM_UNDERLYING_TYPE (*node)) == BOOLEAN_TYPE)) > + { > + warning (OPT_Wattributes, "%qE attribute ignored on boolean type", > + name); > + *no_add_attrs = true; > + } > + > + return NULL_TREE; > +} > + > /* Common argument checking for btf_type_tag and btf_decl_tag. > Return true if the ARGS are valid, otherwise emit an error and > return false. */ > diff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc > index a27dda88e128..f6b9abcee2d1 100644 > --- a/gcc/c-family/c-warn.cc > +++ b/gcc/c-family/c-warn.cc > @@ -1187,8 +1187,18 @@ conversion_warning (location_t loc, tree type, tree expr, tree result) > tree expr_type = TREE_TYPE (expr); > enum conversion_safety conversion_kind; > int arith_ops = 0; > - > - if (!warn_conversion && !warn_sign_conversion && !warn_float_conversion) > + bool attr_expr = lookup_attribute ("no_implicit_truncation", > + TYPE_ATTRIBUTES (TREE_TYPE (expr))); > + bool warn_for_attr = (warn_conversion_attribute > + && attr_expr > + && INTEGRAL_TYPE_P (type) > + && (TYPE_PRECISION (type) > + < TYPE_PRECISION (TREE_TYPE (expr)))); > + > + if (!warn_conversion > + && !warn_sign_conversion > + && !warn_float_conversion > + && !warn_for_attr) > return false; > > /* This may happen, because for LHS op= RHS we preevaluate > @@ -1356,7 +1366,9 @@ conversion_warning (location_t loc, tree type, tree expr, tree result) > else if (conversion_kind == UNSAFE_SIGN) > warnopt = OPT_Wsign_conversion; > else if (conversion_kind) > - warnopt = OPT_Wconversion; > + warnopt = (warn_for_attr > + ? OPT_Wconversion_attribute > + : OPT_Wconversion); > else > break; > > @@ -1512,7 +1524,21 @@ warnings_for_convert_and_check (location_t loc, tree type, tree expr, > exprtype, type, expr); > } > else > - conversion_warning (loc, type, expr, result); > + { > + if (conversion_warning (loc, type, expr, result)) > + return; > + /* Warn for widening conversions to types with no_implicit_truncation > + attribute. This is intended for cases such as code that obtains a > + time_t value using atoi and so is unable to handle the full range of > + such values. */ > + if (lookup_attribute ("no_implicit_truncation", TYPE_ATTRIBUTES (type)) > + && INTEGRAL_TYPE_P (TREE_TYPE (expr)) > + && TREE_CODE (expr) != INTEGER_CST > + && TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (expr))) > + warning_at (loc, OPT_Wconversion_attribute, > + "conversion to %qT from narrower integer type", > + type); > + } > } > > /* Subroutines of c_do_switch_warnings, called via splay_tree_foreach. > diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt > index d5b973baa855..d228206b54c1 100644 > --- a/gcc/c-family/c.opt > +++ b/gcc/c-family/c.opt > @@ -607,6 +607,10 @@ Wconversion > C ObjC C++ ObjC++ Var(warn_conversion) Warning > Warn for implicit type conversions that may change a value. > > +Wconversion-attribute > +C ObjC C++ ObjC++ Var(warn_conversion_attribute) Init(1) Warning > +Warn for implicit type conversions between types with the no_implicit_truncation attribute and narrower integer types. > + > Wconversion-null > C++ ObjC++ Var(warn_conversion_null) Init(1) Warning > Warn for converting NULL from/to a non-pointer type. > diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc > index 2d0200858331..ea0731ccf872 100644 > --- a/gcc/c/c-typeck.cc > +++ b/gcc/c/c-typeck.cc > @@ -1189,10 +1189,29 @@ common_pointer_type (tree t1, tree t2, tree cond) > return c_build_type_attribute_variant (t1, attributes); > } > > +/* Return TYPE, with the no_implicit_truncation attribute added if > + NO_IMPLICIT_TRUNCATION. */ > + > +static tree > +c_maybe_no_implicit_truncation (tree type, bool no_implicit_truncation) > +{ > + if (no_implicit_truncation) > + { > + tree attrs = tree_cons (get_identifier ("no_implicit_truncation"), > + NULL_TREE, > + TYPE_ATTRIBUTES (type)); > + return c_build_type_attribute_variant (type, attrs); > + } > + else > + return type; > +} > + > /* Return the common type for two arithmetic types under the usual > arithmetic conversions. The default conversions have already been > applied, and enumerated types converted to their compatible integer > - types. The resulting type is unqualified and has no attributes. > + types. The resulting type is unqualified and has no attributes, > + except for no_implicit_truncation if both types are integer types and at > + least one has that attribute. > > This is the type for the result of most arithmetic operations > if the operands have the given two types. */ > @@ -1202,6 +1221,12 @@ c_common_type (tree t1, tree t2) > { > enum tree_code code1; > enum tree_code code2; > + bool no_implicit_truncation > + = (INTEGRAL_TYPE_P (t1) > + && INTEGRAL_TYPE_P (t2) > + && (lookup_attribute ("no_implicit_truncation", TYPE_ATTRIBUTES (t1)) > + || lookup_attribute ("no_implicit_truncation", > + TYPE_ATTRIBUTES (t2)))); > > /* If one type is nonsense, use the other. */ > if (t1 == error_mark_node) > @@ -1229,7 +1254,8 @@ c_common_type (tree t1, tree t2) > > /* Save time if the two types are the same. */ > > - if (t1 == t2) return t1; > + if (t1 == t2) > + return c_maybe_no_implicit_truncation (t1, no_implicit_truncation); > > code1 = TREE_CODE (t1); > code2 = TREE_CODE (t2); > @@ -1416,9 +1442,9 @@ c_common_type (tree t1, tree t2) > /* Both real or both integers; use the one with greater precision. */ > > if (TYPE_PRECISION (t1) > TYPE_PRECISION (t2)) > - return t1; > + return c_maybe_no_implicit_truncation (t1, no_implicit_truncation); > else if (TYPE_PRECISION (t2) > TYPE_PRECISION (t1)) > - return t2; > + return c_maybe_no_implicit_truncation (t2, no_implicit_truncation); > > /* Same precision. Prefer long longs to longs to ints when the > same precision, following the C99 rules on integer type rank > @@ -1426,20 +1452,24 @@ c_common_type (tree t1, tree t2) > > if (TYPE_MAIN_VARIANT (t1) == long_long_unsigned_type_node > || TYPE_MAIN_VARIANT (t2) == long_long_unsigned_type_node) > - return long_long_unsigned_type_node; > + return c_maybe_no_implicit_truncation (long_long_unsigned_type_node, > + no_implicit_truncation); > > if (TYPE_MAIN_VARIANT (t1) == long_long_integer_type_node > || TYPE_MAIN_VARIANT (t2) == long_long_integer_type_node) > { > if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2)) > - return long_long_unsigned_type_node; > + return c_maybe_no_implicit_truncation (long_long_unsigned_type_node, > + no_implicit_truncation); > else > - return long_long_integer_type_node; > + return c_maybe_no_implicit_truncation (long_long_integer_type_node, > + no_implicit_truncation); > } > > if (TYPE_MAIN_VARIANT (t1) == long_unsigned_type_node > || TYPE_MAIN_VARIANT (t2) == long_unsigned_type_node) > - return long_unsigned_type_node; > + return c_maybe_no_implicit_truncation (long_unsigned_type_node, > + no_implicit_truncation); > > if (TYPE_MAIN_VARIANT (t1) == long_integer_type_node > || TYPE_MAIN_VARIANT (t2) == long_integer_type_node) > @@ -1447,9 +1477,11 @@ c_common_type (tree t1, tree t2) > /* But preserve unsignedness from the other type, > since long cannot hold all the values of an unsigned int. */ > if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2)) > - return long_unsigned_type_node; > + return c_maybe_no_implicit_truncation (long_unsigned_type_node, > + no_implicit_truncation); > else > - return long_integer_type_node; > + return c_maybe_no_implicit_truncation (long_integer_type_node, > + no_implicit_truncation); > } > > /* For floating types of the same TYPE_PRECISION (which we here > @@ -1491,22 +1523,26 @@ c_common_type (tree t1, tree t2) > { > /* Prefer any other integral types over bit-precise integer types. */ > if (TYPE_UNSIGNED (t1) == TYPE_UNSIGNED (t2)) > - return code1 == BITINT_TYPE ? t2 : t1; > + return c_maybe_no_implicit_truncation (code1 == BITINT_TYPE ? t2 : t1, > + no_implicit_truncation); > /* If BITINT_TYPE is unsigned and the other type is signed > non-BITINT_TYPE with the same precision, the latter has higher rank. > In that case: > Otherwise, both operands are converted to the unsigned integer type > corresponding to the type of the operand with signed integer type. */ > if (TYPE_UNSIGNED (code1 == BITINT_TYPE ? t1 : t2)) > - return c_common_unsigned_type (code1 == BITINT_TYPE ? t2 : t1); > + { > + tree ret = c_common_unsigned_type (code1 == BITINT_TYPE ? t2 : t1); > + return c_maybe_no_implicit_truncation (ret, no_implicit_truncation); > + } > } > > /* Otherwise prefer the unsigned one. */ > > if (TYPE_UNSIGNED (t1)) > - return t1; > + return c_maybe_no_implicit_truncation (t1, no_implicit_truncation); > else > - return t2; > + return c_maybe_no_implicit_truncation (t2, no_implicit_truncation); > } > > /* Wrapper around c_common_type that is used by c-common.cc and other > @@ -2804,6 +2840,9 @@ perform_integral_promotions (tree exp) > { > tree type = TREE_TYPE (exp); > enum tree_code code = TREE_CODE (type); > + bool no_implicit_truncation = lookup_attribute ("no_implicit_truncation", > + TYPE_ATTRIBUTES (type)); > + tree conv_type = NULL_TREE; > > gcc_assert (INTEGRAL_TYPE_P (type)); > > @@ -2811,49 +2850,50 @@ perform_integral_promotions (tree exp) > their underlying type. */ > if (code == ENUMERAL_TYPE) > { > - type = ENUM_UNDERLYING_TYPE (type); > + conv_type = type = ENUM_UNDERLYING_TYPE (type); > if (c_promoting_integer_type_p (type)) > { > if (TYPE_UNSIGNED (type) > && TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)) > - type = unsigned_type_node; > + conv_type = unsigned_type_node; > else > - type = integer_type_node; > + conv_type = integer_type_node; > } > - > - return convert (type, exp); > } > - > /* ??? This should no longer be needed now bit-fields have their > proper types. */ > - if (TREE_CODE (exp) == COMPONENT_REF > + else if (TREE_CODE (exp) == COMPONENT_REF > && DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1))) > { > if (BITINT_TYPE_P (DECL_BIT_FIELD_TYPE (TREE_OPERAND (exp, 1)))) > { > tree btype = DECL_BIT_FIELD_TYPE (TREE_OPERAND (exp, 1)); > if (TREE_CODE (btype) == BITINT_TYPE) > - return convert (btype, exp); > + conv_type = btype; > else > - return convert (ENUM_UNDERLYING_TYPE (btype), exp); > + conv_type = ENUM_UNDERLYING_TYPE (btype); > } > /* If it's thinner than an int, promote it like a > c_promoting_integer_type_p, otherwise leave it alone. */ > - if (compare_tree_int (DECL_SIZE (TREE_OPERAND (exp, 1)), > - TYPE_PRECISION (integer_type_node)) < 0) > - return convert (integer_type_node, exp); > + else if (compare_tree_int (DECL_SIZE (TREE_OPERAND (exp, 1)), > + TYPE_PRECISION (integer_type_node)) < 0) > + conv_type = integer_type_node; > } > > - if (c_promoting_integer_type_p (type)) > + if (conv_type == NULL_TREE && c_promoting_integer_type_p (type)) > { > /* Preserve unsignedness if not really getting any wider. */ > if (TYPE_UNSIGNED (type) > && TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)) > - return convert (unsigned_type_node, exp); > - > - return convert (integer_type_node, exp); > + conv_type = unsigned_type_node; > + else > + conv_type = integer_type_node; > } > > + if (conv_type) > + return convert (c_maybe_no_implicit_truncation (conv_type, > + no_implicit_truncation), > + exp); > return exp; > } > > @@ -15369,6 +15409,28 @@ build_binary_op (location_t location, enum tree_code code, > > if (short_compare) > { > + /* These conversions do not go through > + warnings_for_convert_and_check, so warn here for widening > + conversions to types with no_implicit_truncation attribute. */ > + if (INTEGRAL_TYPE_P (TREE_TYPE (op0)) > + && INTEGRAL_TYPE_P (TREE_TYPE (op1)) > + && (TYPE_PRECISION (TREE_TYPE (op0)) > + != TYPE_PRECISION (TREE_TYPE (op1)))) > + { > + tree t0 = op0, t1 = op1; > + if (TYPE_PRECISION (TREE_TYPE (op0)) > + < TYPE_PRECISION (TREE_TYPE (op1))) > + { > + t0 = op1; > + t1 = op0; > + } > + if (TREE_CODE (t1) != INTEGER_CST > + && lookup_attribute ("no_implicit_truncation", > + TYPE_ATTRIBUTES (TREE_TYPE (t0)))) > + warning_at (location, OPT_Wconversion_attribute, > + "conversion to %qT from narrower integer type", > + TREE_TYPE (t0)); > + } > /* Don't write &op0, etc., because that would prevent op0 > from being kept in a register. > Instead, make copies of the our local variables and > @@ -15463,10 +15525,15 @@ build_binary_op (location_t location, enum tree_code code, > > if (!converted) > { > + int save_warn_conversion_attribute = warn_conversion_attribute; > + if ((common || shorten == -1) && !short_compare) > + warn_conversion_attribute = 0; > op0 = ep_convert_and_check (location, result_type, op0, > semantic_result_type); > op1 = ep_convert_and_check (location, result_type, op1, > semantic_result_type); > + if ((common || shorten == -1) && !short_compare) > + warn_conversion_attribute = save_warn_conversion_attribute; > > /* This can happen if one operand has a vector type, and the other > has a different type. */ > diff --git a/gcc/cp/cvt.cc b/gcc/cp/cvt.cc > index 845719c20438..005ef74d670a 100644 > --- a/gcc/cp/cvt.cc > +++ b/gcc/cp/cvt.cc > @@ -2022,6 +2022,8 @@ tree > type_promotes_to (tree type) > { > tree promoted_type; > + bool no_implicit_truncation = lookup_attribute ("no_implicit_truncation", > + TYPE_ATTRIBUTES (type)); > > if (type == error_mark_node) > return error_mark_node; > @@ -2098,6 +2100,14 @@ type_promotes_to (tree type) > else if (type == float_type_node) > type = double_type_node; > > + if (no_implicit_truncation) > + { > + tree attrs = tree_cons (get_identifier ("no_implicit_truncation"), > + NULL_TREE, > + TYPE_ATTRIBUTES (type)); > + type = cp_build_type_attribute_variant (type, attrs); > + } > + > return type; > } > > diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc > index 0b200804fe99..b9e78e1aec68 100644 > --- a/gcc/cp/typeck.cc > +++ b/gcc/cp/typeck.cc > @@ -6955,6 +6955,8 @@ cp_build_binary_op (const op_location_t &location, > if (! converted) > { > warning_sentinel w (warn_sign_conversion, short_compare); > + warning_sentinel w_attr (warn_conversion_attribute, > + (common || shorten == -1) && !short_compare); > if (!same_type_p (TREE_TYPE (op0), result_type)) > op0 = cp_convert_and_check (result_type, op0, complain); > if (!same_type_p (TREE_TYPE (op1), result_type)) > diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi > index 961fa27ba0eb..ba886b738569 100644 > --- a/gcc/doc/extend.texi > +++ b/gcc/doc/extend.texi > @@ -3694,6 +3694,25 @@ This attribute can be applied to functions or variables. > It prevents the entity from being > merged with another semantically equivalent function or variable. > > +@atindex @code{no_implicit_truncation} > +@opindex Wconversion-attribute > +@item no_implicit_truncation > +This attribute applies to integer types. > + > +If @option{-Wconversion-attribute} (enabled by default) is enabled, > +the compiler warns for implicit conversions from a type with this > +attribute to a narrower integer type. It also warns for implicit > +conversions in the other direction (from a narrower integer type to a > +type with this attribute) in (non-compound) assignment, > +initialization, argument passing and function return, but not in > +arithmetic. > + > +This attribute is intended to be applied by standard library headers > +to types such as @code{time_t}, to detect code that stores a value of > +such a type in a narrower type such as @code{int}, or uses such a > +narrower type as intermediate storage for a value to be stored in the > +type with the attribute. > + > @atindex @code{no_instrument_function} > @cindex functions that should not be instrumented > @cindex function instrumentation > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index 60d7163eee35..706bc52a0b67 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -388,7 +388,8 @@ Objective-C and Objective-C++ Dialects}. > -Wclobbered -Wcomment > -Wcompare-distinct-pointer-types > -Wno-complain-wrong-lang -Wconstant-logical-operand > --Wconversion -Wno-coverage-mismatch -Wno-cpp > +-Wconversion -Wno-conversion-attribute > +-Wno-coverage-mismatch -Wno-cpp > -Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n} > -Wdate-time > -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init > @@ -10351,6 +10352,13 @@ unsigned integers are disabled by default in C++ unless > Warnings about conversion from arithmetic on a small type back to that > type are only given with @option{-Warith-conversion}. > > +@opindex Wconversion-attribute > +@opindex Wno-conversion-attribute > +@item -Wno-conversion-attribute > +Do not warn about implicit conversions between a type such as > +@code{time_t} with the @code{no_implicit_truncation} attribute and a > +narrower integer type. These warnings are enabled by default. > + > @opindex Wdangling-else > @opindex Wno-dangling-else > @item -Wdangling-else > diff --git a/gcc/testsuite/c-c++-common/no_implicit_truncation-1.c b/gcc/testsuite/c-c++-common/no_implicit_truncation-1.c > new file mode 100644 > index 000000000000..5647b2314d2e > --- /dev/null > +++ b/gcc/testsuite/c-c++-common/no_implicit_truncation-1.c > @@ -0,0 +1,188 @@ > +/* Test warnings for implicit conversions involving > + no_implicit_truncation types. */ > +/* { dg-do compile } */ > +/* { dg-options "" { target c } } */ > +/* { dg-options "-std=c++23" { target c++ } } */ > + > +typedef long long time_ll_t __attribute__ ((no_implicit_truncation)); > +typedef unsigned long long time_ull_t __attribute__ ((no_implicit_truncation)); > +typedef long time_l_t __attribute__ ((no_implicit_truncation)); > +typedef unsigned long time_ul_t __attribute__ ((no_implicit_truncation)); > +typedef int time_i_t __attribute__ ((no_implicit_truncation)); > +typedef unsigned int time_ui_t __attribute__ ((no_implicit_truncation)); > +typedef short time_ss_t __attribute__ ((no_implicit_truncation)); > + > +time_ll_t tll; > +time_ull_t tull; > +volatile time_ll_t vtll; > +volatile time_ull_t vtull; > +time_l_t tl; > +time_ul_t tul; > +time_i_t ti; > +time_ui_t tui; > +time_ss_t tss; > +signed char sc; > +int i; > +unsigned int ui; > +long l; > +unsigned long ul; > +long long ll; > +unsigned long long ull; > +float f; > +double d; > + > +void fi (int); > +void fui (unsigned int); > +void ftll (time_ll_t); > + > +void > +t0 () > +{ > + i = tll; /* { dg-warning "conversion" } */ > + i = tull; /* { dg-warning "conversion" } */ > + ui = tll; /* { dg-warning "conversion" } */ > + ui = tull; /* { dg-warning "conversion" } */ > + i = vtll; /* { dg-warning "conversion" } */ > + i = vtull; /* { dg-warning "conversion" } */ > + ui = vtll; /* { dg-warning "conversion" } */ > + ui = vtull; /* { dg-warning "conversion" } */ > + i = tll + 1LL; /* { dg-warning "conversion" } */ > + i = tull + 1LL; /* { dg-warning "conversion" } */ > + ui = tll + 1LL; /* { dg-warning "conversion" } */ > + ui = tull + 1LL; /* { dg-warning "conversion" } */ > + i = vtll + 1LL; /* { dg-warning "conversion" } */ > + i = vtull + 1LL; /* { dg-warning "conversion" } */ > + ui = vtll + 1LL; /* { dg-warning "conversion" } */ > + ui = vtull + 1LL; /* { dg-warning "conversion" } */ > + i = 1LL + tll; /* { dg-warning "conversion" } */ > + i = 1LL + tull; /* { dg-warning "conversion" } */ > + ui = 1LL + tll; /* { dg-warning "conversion" } */ > + ui = 1LL + tull; /* { dg-warning "conversion" } */ > + fi (tll); /* { dg-warning "conversion" } */ > + fi (tull); /* { dg-warning "conversion" } */ > + fui (tll); /* { dg-warning "conversion" } */ > + fui (tull); /* { dg-warning "conversion" } */ > + fi (vtll); /* { dg-warning "conversion" } */ > + fi (vtull); /* { dg-warning "conversion" } */ > + fui (vtll); /* { dg-warning "conversion" } */ > + fui (vtull); /* { dg-warning "conversion" } */ > + int j0 = tll; /* { dg-warning "conversion" } */ > + int j1 = tull; /* { dg-warning "conversion" } */ > + unsigned int j2 = tll; /* { dg-warning "conversion" } */ > + unsigned int j3 = tull; /* { dg-warning "conversion" } */ > + int d = tll - vtll; /* { dg-warning "conversion" } */ > + /* Warnings for widening conversions from non-constants. */ > + tll = i; /* { dg-warning "from narrower" } */ > + tll = ui; /* { dg-warning "from narrower" } */ > + tull = i; /* { dg-warning "from narrower" } */ > + tull = ui; /* { dg-warning "from narrower" } */ > + vtll = i; /* { dg-warning "from narrower" } */ > + vtll = ui; /* { dg-warning "from narrower" } */ > + vtull = i; /* { dg-warning "from narrower" } */ > + vtull = ui; /* { dg-warning "from narrower" } */ > + ftll (i); /* { dg-warning "from narrower" } */ > + ftll (ui); /* { dg-warning "from narrower" } */ > + /* Do not warn for widening conversions of one operand to arithmetic > + (for example, it is presumed OK to add an interval in seconds to > + a time, where the interval may be known to be small enough to be > + representable even though the time may not). */ > + tll = tll + i; > + tull -= i; > + vtll *= i; > + vtull = tull / i; > + tll &= ui; > + tll |= ui; > + tll ^= i; > + /* Do warn for widening conversions in comparisons or conditional > + expressions (where the narrower type is being implicitly used for > + a time, for example). */ > + tll = i ? tll : i; /* { dg-warning "from narrower" } */ > + tull = i ? tull : ui; /* { dg-warning "from narrower" } */ > + tll = i ? i : tll; /* { dg-warning "from narrower" } */ > + tull = i ? ui : tull; /* { dg-warning "from narrower" } */ > + i = tll < i; /* { dg-warning "from narrower" } */ > + i = i < tll; /* { dg-warning "from narrower" } */ > + i = tll <= ui; /* { dg-warning "from narrower" } */ > + i = ui <= tll; /* { dg-warning "from narrower" } */ > + i = tull > i; /* { dg-warning "from narrower" } */ > + i = i > tull; /* { dg-warning "from narrower" } */ > + i = tull >= ui; /* { dg-warning "from narrower" } */ > + i = ui >= tull; /* { dg-warning "from narrower" } */ > + i = tll == i; /* { dg-warning "from narrower" } */ > + i = i == tll; /* { dg-warning "from narrower" } */ > + i = tll != ui; /* { dg-warning "from narrower" } */ > + i = ui != tll; /* { dg-warning "from narrower" } */ > +} > + > +int t1 () { return tll; } /* { dg-warning "conversion" } */ > +int t2 () { return tull; } /* { dg-warning "conversion" } */ > +unsigned int t3 () { return tll; } /* { dg-warning "conversion" } */ > +unsigned int t4 () { return tull; } /* { dg-warning "conversion" } */ > + > +void > +t5 () > +{ > + /* No warning for converting in-range constants. */ > + i = (time_ll_t) 12345; > + tll = 12345; > + tull = 12345; > + vtll = 12345; > + vtull = 12345; > + tll = i ? tll : 6; > + tull = i ? tull : 5u; > + tll = i ? 4 : tll; > + tull = i ? 3u : tull; > + i = tll < 7; > + i = 7 < ll; > + i = tll <= 50u; > + i = 50u <= tll; > + i = tull > 30; > + i = 30 > tull; > + i = tull >= 10u; > + i = 10u >= tull; > + i = tll == 123; > + i = 123 == tll; > + i = tll != 234u; > + i = 234u != tll; > +} > + > +void > +t6 () > +{ > + /* The attribute is preserved by integer promotions. */ > + sc = tss + tss; /* { dg-warning "conversion" } */ > + /* The attribute is preserved by usual arithmetic conversions. */ > + i = ti + (1LL << 32); /* { dg-warning "conversion" } */ > + i = (1LL << 32) + ti; /* { dg-warning "conversion" } */ > + sc = tl + l; /* { dg-warning "conversion" } */ > + sc = tl + ul; /* { dg-warning "conversion" } */ > + sc = tul + l; /* { dg-warning "conversion" } */ > + sc = tul + ul; /* { dg-warning "conversion" } */ > + sc = l + tl; /* { dg-warning "conversion" } */ > + sc = ul + tl; /* { dg-warning "conversion" } */ > + sc = l + tul; /* { dg-warning "conversion" } */ > + sc = ul + tul; /* { dg-warning "conversion" } */ > + sc = tl + i; /* { dg-warning "conversion" } */ > + sc = tl + ui; /* { dg-warning "conversion" } */ > + sc = tul + i; /* { dg-warning "conversion" } */ > + sc = tul + ui; /* { dg-warning "conversion" } */ > + sc = i + tl; /* { dg-warning "conversion" } */ > + sc = ui + tl; /* { dg-warning "conversion" } */ > + sc = i + tul; /* { dg-warning "conversion" } */ > + sc = ui + tul; /* { dg-warning "conversion" } */ > + sc = ti + i; /* { dg-warning "conversion" } */ > + sc = ti + ui; /* { dg-warning "conversion" } */ > + sc = tui + i; /* { dg-warning "conversion" } */ > + sc = tui + ui; /* { dg-warning "conversion" } */ > + sc = i + ti; /* { dg-warning "conversion" } */ > + sc = ui + ti; /* { dg-warning "conversion" } */ > + sc = i + tui; /* { dg-warning "conversion" } */ > + sc = ui + tui; /* { dg-warning "conversion" } */ > +} > + > +void > +t7 () > +{ > + /* The attribute is lost in mixed integer / floating-point arithmetic. */ > + float f = tll + d; > +} > diff --git a/gcc/testsuite/c-c++-common/no_implicit_truncation-2.c b/gcc/testsuite/c-c++-common/no_implicit_truncation-2.c > new file mode 100644 > index 000000000000..14accfd65fb0 > --- /dev/null > +++ b/gcc/testsuite/c-c++-common/no_implicit_truncation-2.c > @@ -0,0 +1,19 @@ > +/* Test bad uses of no_implicit_truncation attribute. */ > +/* { dg-do compile } */ > +/* { dg-options "" { target c } } */ > +/* { dg-options "-std=c++23" { target c++ } } */ > + > +#include > + > +double d __attribute__ ((no_implicit_truncation)); /* { dg-warning "non-integer" } */ > +struct s { int a; }; > +struct s __attribute__ ((no_implicit_truncation)) x; /* { dg-warning "non-integer" } */ > +union u { int a; }; > +union u __attribute__ ((no_implicit_truncation)) y; /* { dg-warning "non-integer" } */ > +nullptr_t __attribute__ ((no_implicit_truncation)) n; /* { dg-warning "non-integer" } */ > +typedef void *p __attribute__ ((no_implicit_truncation)); /* { dg-warning "non-integer" } */ > +typedef void v __attribute__ ((no_implicit_truncation)); /* { dg-warning "non-integer" } */ > +typedef int f () __attribute__ ((no_implicit_truncation)); /* { dg-warning "non-integer" } */ > +typedef bool __attribute__ ((no_implicit_truncation)) b; /* { dg-warning "boolean" } */ > +enum e : bool; > +typedef enum e __attribute__ ((no_implicit_truncation)) be; /* { dg-warning "boolean" } */ > diff --git a/gcc/testsuite/c-c++-common/no_implicit_truncation-3.c b/gcc/testsuite/c-c++-common/no_implicit_truncation-3.c > new file mode 100644 > index 000000000000..8d56a9a7c084 > --- /dev/null > +++ b/gcc/testsuite/c-c++-common/no_implicit_truncation-3.c > @@ -0,0 +1,7 @@ > +/* Test warnings for implicit conversions involving > + no_implicit_truncation types are disabled by > + -Wno-conversion-attribute. */ > +/* { dg-do compile } */ > +/* { dg-options "-Wno-conversion-attribute" } */ > + > +#include "no_implicit_truncation-1.c" > diff --git a/gcc/testsuite/gcc.dg/no_implicit_truncation-bitint-1.c b/gcc/testsuite/gcc.dg/no_implicit_truncation-bitint-1.c > new file mode 100644 > index 000000000000..6417d53dff60 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/no_implicit_truncation-bitint-1.c > @@ -0,0 +1,50 @@ > +/* Test warnings for implicit conversions involving > + no_implicit_truncation types: _BitInt tests. */ > +/* { dg-do compile { target bitint } } */ > +/* { dg-options "" } */ > + > +typedef _BitInt (63) time_63_t __attribute__ ((no_implicit_truncation)); > +typedef unsigned _BitInt (63) time_u63_t __attribute__ ((no_implicit_truncation)); > +typedef _BitInt (64) time_64_t __attribute__ ((no_implicit_truncation)); > +typedef unsigned _BitInt (64) time_u64_t __attribute__ ((no_implicit_truncation)); > + > +time_63_t t63; > +time_u64_t tu63; > +time_64_t t64; > +time_u64_t tu64; > + > +_BitInt (62) b62; > +_BitInt (63) b63; > +unsigned _BitInt (63) ub63; > +_BitInt (64) b64; > +unsigned _BitInt (64) ub64; > + > +void > +tb () > +{ > + /* The attribute is preserved by usual arithmetic conversions. */ > + b62 = t64 + b64; /* { dg-warning "conversion" } */ > + b62 = t64 + ub64; /* { dg-warning "conversion" } */ > + b62 = tu64 + b64; /* { dg-warning "conversion" } */ > + b62 = tu64 + ub64; /* { dg-warning "conversion" } */ > + b62 = b64 + t64; /* { dg-warning "conversion" } */ > + b62 = ub64 + t64; /* { dg-warning "conversion" } */ > + b62 = b64 + tu64; /* { dg-warning "conversion" } */ > + b62 = ub64 + tu64; /* { dg-warning "conversion" } */ > + b62 = t64 + b63; /* { dg-warning "conversion" } */ > + b62 = t64 + ub63; /* { dg-warning "conversion" } */ > + b62 = tu64 + b63; /* { dg-warning "conversion" } */ > + b62 = tu64 + ub63; /* { dg-warning "conversion" } */ > + b62 = b63 + t64; /* { dg-warning "conversion" } */ > + b62 = ub63 + t64; /* { dg-warning "conversion" } */ > + b62 = b63 + tu64; /* { dg-warning "conversion" } */ > + b62 = ub63 + tu64; /* { dg-warning "conversion" } */ > + b62 = t63 + b63; /* { dg-warning "conversion" } */ > + b62 = t63 + ub63; /* { dg-warning "conversion" } */ > + b62 = tu63 + b63; /* { dg-warning "conversion" } */ > + b62 = tu63 + ub63; /* { dg-warning "conversion" } */ > + b62 = b63 + t63; /* { dg-warning "conversion" } */ > + b62 = ub63 + t63; /* { dg-warning "conversion" } */ > + b62 = b63 + tu63; /* { dg-warning "conversion" } */ > + b62 = ub63 + tu63; /* { dg-warning "conversion" } */ > +} > > -- > Joseph S. Myers > josmyers@redhat.com > From fkastl@suse.cz Tue Nov 3 08:27:48 2026 From: fkastl@suse.cz (Filip Kastl) Date: Tue, 3 Nov 2026 09:27:48 +0100 Subject: [PATCH] Remove null from pt_solution In-Reply-To: References: Message-ID: On Tue 2026-11-03 08:59:03, Richard Biener wrote: > On Tue, 3 Nov 2026, Filip Kastl wrote: > > > On Mon 2026-11-02 12:52:25, Andrew MacLeod wrote: > > > Thre is only one place (!!!!) that actually sets pt.null to 0 (meaning the > > > range is nonnull) It is in tree-ssa-structalias.cc find_what_p_points_to() > > > and it determines nonnullness based on : > > > > > > get_range_query (DECL_STRUCT_FUNCTION (fndecl))->range_of_expr (vr, p); > > > bool nonnull = !vr.contains_zero_p (); > > > <..> > > > if (nonnull) > > > set_ptr_nonnull (p); > > > > It's actually not true, that this is the only place that sets pt.null to 0 -- > > find_what_var_points_to() can also produce pt_solution pt with pt.null = 0 > > (when it creates the structure, it zero-initializes it by memset). Yes, in > > find_what_pt_points_to() that gets overriden to whatever ranger thinks about > > null-ness of a pointer. But that's not the only place > > find_what_var_points_to() is called. > > > > On the other hand, when you look at the other calls to > > find_what_var_points_to(), you see that those are only used to compute the > > (IPA) escaped, escaped_return, IPA clobbers and IPA uses. I didn't check > > as thoroughly as I'd like to, but I don't think that GCC ever makes use of > > pt_solution.null for those PT sets. > > > > In case it really doesn't, I think we could not only remove pt_solution.null, > > but also remove the NULL artificial variable from the PT constraints. That > > would save a little bit of solving time. For my Steensgaard solver, that > > could also be a significant boon in terms of precision. > > The PTA solver does not conservatively enough track NULL-ness (it's a bit > of a misfit to try to track a NULL "object" and keep that distinct from > an empty points-to set), and as we now make use of pt->null as "range" > from the middle-end (see for example ptrs_compare_unequal), what PTA > computes is thrown away and replaced with what we get from range-info. > So pt_solution.null was only "limited range storage for pointers" > (as SSA_NAME_RANGE_INFO was integer type only). > > So - removing pt_solution.null is good and will clean up this odd thing > from PTA. Yay. (no longer need to track 'NULL', aka nothing_id, but > simply use an empty set!) Ah, ok. Glad to hear that we can indeed get rid of pt_solution.null. Filip From stian@itx.no Tue Nov 3 08:36:06 2026 From: stian@itx.no (Stian Halseth) Date: Tue, 3 Nov 2026 09:36:06 +0100 Subject: [PATCH] sparc: Do not load from the frame in the delay slot of return Message-ID: <20261103083606.582600-1-stian@itx.no> The delay slot of the V9 return instruction is executed after the register window has been restored, so a load from the function's own frame placed there reads below the stack pointer, and a trap or a signal taken on that instruction overwrites what it reads. Only accept a memory reference in that slot when its address uses nothing but incoming argument registers that the function does not modify. gcc/ChangeLog: PR target/128395 * config/sparc/sparc.cc (mem_in_return_delay_safe_p): New function. (eligible_for_restore_insn): Use it to reject a memory reference in the delay slot of return that may address the frame. gcc/testsuite/ChangeLog: PR target/128395 * gcc.target/sparc/return-delay-mem.c: New test. Signed-off-by: Stian Halseth --- gcc/config/sparc/sparc.cc | 38 ++++++++++++++++- .../gcc.target/sparc/return-delay-mem.c | 42 +++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/sparc/return-delay-mem.c diff --git a/gcc/config/sparc/sparc.cc b/gcc/config/sparc/sparc.cc index 47783fdee..bd101c1b5 100644 --- a/gcc/config/sparc/sparc.cc +++ b/gcc/config/sparc/sparc.cc @@ -57,6 +57,7 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" #include "reload.h" #include "tree-pass.h" +#include "rtl-iter.h" #include "context.h" #include "builtins.h" #include "tree-vector-builder.h" @@ -4027,6 +4028,36 @@ emit_cbcond_nop (rtx_insn *insn) return 1; } +/* Return true if the memory references in TRIAL, a candidate for the + delay slot of a return insn, cannot address the function's frame. */ + +static bool +mem_in_return_delay_safe_p (rtx_insn *trial) +{ + subrtx_iterator::array_type array; + FOR_EACH_SUBRTX (iter, array, PATTERN (trial), ALL) + { + const_rtx x = *iter; + if (!MEM_P (x)) + continue; + subrtx_iterator::array_type array2; + FOR_EACH_SUBRTX (iter2, array2, XEXP (x, 0), ALL) + { + const_rtx y = *iter2; + if (REG_P (y)) + { + if (REGNO (y) < SPARC_INCOMING_INT_ARG_FIRST + || REGNO (y) >= SPARC_INCOMING_INT_ARG_FIRST + 6 + || reg_set_between_p (y, get_insns (), trial)) + return false; + } + else if (!CONST_INT_P (y) && GET_CODE (y) != PLUS) + return false; + } + } + return true; +} + /* Return nonzero if TRIAL, an insn, can be combined with a 'restore' instruction. RETURN_P is true if the v9 variant 'return' is to be considered in the test too. @@ -4079,9 +4110,12 @@ eligible_for_restore_insn (rtx trial, bool return_p) return 1; /* If we have the 'return' instruction, anything that does not use - local or output registers and can go into a delay slot wins. */ + local or output registers and can go into a delay slot wins, but a + memory reference must not address the frame, which is already below + the stack pointer when the slot is executed. */ else if (return_p && TARGET_V9 && !epilogue_renumber (&pat, 1)) - return 1; + return (!contains_mem_rtx_p (pat) + || mem_in_return_delay_safe_p (as_a (trial))); /* The 'restore src1,src2,dest' pattern for SImode. */ else if (GET_CODE (src) == PLUS diff --git a/gcc/testsuite/gcc.target/sparc/return-delay-mem.c b/gcc/testsuite/gcc.target/sparc/return-delay-mem.c new file mode 100644 index 000000000..99a75ebd7 --- /dev/null +++ b/gcc/testsuite/gcc.target/sparc/return-delay-mem.c @@ -0,0 +1,42 @@ +/* PR target/128395 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-stack-protector" } */ + +typedef unsigned long long u64; +struct cputimer { u64 utime, stime, sum_exec; }; +struct pct { int timers_active; }; +struct sig { struct cputimer cputimer; struct pct pct; }; +struct task { struct sig *signal; }; + +void start_sample (struct task *, u64 *); +void group_sample (struct task *, u64 *); + +static inline void +proc_sample (struct cputimer *c, u64 *samples) +{ + samples[0] = c->utime + c->stime; + samples[1] = c->utime; + samples[2] = c->sum_exec; +} + +u64 +sample_group (const int clkid, struct task *p, _Bool start) +{ + struct cputimer *cputimer = &p->signal->cputimer; + struct pct *pct = &p->signal->pct; + u64 samples[3]; + + if (!*(volatile int *) &pct->timers_active) + { + if (start) + start_sample (p, samples); + else + group_sample (p, samples); + } + else + proc_sample (cputimer, samples); + + return samples[clkid]; +} + +/* { dg-final { scan-assembler-not "return\[ \t\]+%i7\\+8\[ \t\]*\n\[ \t\]+ld" } } */ -- 2.43.0 From mjambor@suse.com Tue Nov 3 09:15:49 2026 From: mjambor@suse.com (Martin Jambor) Date: Tue, 03 Nov 2026 10:15:49 +0100 Subject: [PATCH] Call symtab_node::get_create when it is suitable In-Reply-To: <20261102155252.2392802-1-giuliano.belinassi@suse.com> References: <20261102155252.2392802-1-giuliano.belinassi@suse.com> Message-ID: Hi, On Mon, Nov 02 2026, Giuliano Belinassi wrote: > In many cases the original code checked if the decl is a variable or a > function and forward the call to either varpool_node::get_create or > cgraph_node::get_create. However, there is an API already for > checking that: symtab_node::get_create. Hence, modify the code for > the cases where this is suitable. > > gcc/ChangeLog: > > * cgraphunit.cc (symbol_table::process_same_body_aliases): Call > symtab_node::get_create. > * tree.cc (set_decl_section_name): Likewise. > (decl_init_priority_insert): Likewise. > * varasm.cc (assemble_alias): Likewise. > (make_decl_one_only): Likewise. > > gcc/cp/ChangeLog: > > * decl.cc (duplicate_decls): Call symtab_node::get_create. OK, thanks, Martin From rdapp.gcc@gmail.com Tue Nov 3 09:37:40 2026 From: rdapp.gcc@gmail.com (Robin Dapp) Date: Tue, 03 Nov 2026 10:37:40 +0100 Subject: [PATCH v2] RISC-V: Support per-LMUL vector permute cost In-Reply-To: <20261103024613.2727-1-chen.zhongyao@zte.com.cn> References: <20261103024613.2727-1-chen.zhongyao@zte.com.cn> Message-ID: > - /* Cost of a permute operation. */ > - const int permute_cost; > + /* Cost of a permute operation for LMUL 1, 2, 4, 8. */ > + const int permute_cost[4]; > > /* Cost of an aligned vector load. */ > const int align_load_cost; > diff --git a/gcc/config/riscv/riscv-vector-costs.cc b/gcc/config/riscv/riscv-vector-costs.cc > index 924a0330103..9eeeaff05c0 100644 > --- a/gcc/config/riscv/riscv-vector-costs.cc > +++ b/gcc/config/riscv/riscv-vector-costs.cc > @@ -1523,8 +1523,10 @@ costs::adjust_stmt_cost (enum vect_cost_for_stmt kind, loop_vec_info loop, > > /* Apply LMUL cost scaling uniformly to all vector operations. > Larger LMUL values have higher latency and register pressure, > - which affects performance regardless of loop structure. */ > - if (VECTOR_TYPE_P (vectype)) > + which affects performance regardless of loop structure. > + Permutes have already looked up their per-LMUL cost table in > + builtin_vectorization_cost. */ > + if (VECTOR_TYPE_P (vectype) && kind != vec_perm) > { > unsigned lmul_factor = get_lmul_cost_scaling (TYPE_MODE (vectype)); I would prefer to extend get_lmul_cost_scaling and add a 'kind' param. Then maybe if (kind != vec_perm) existing code (linear scaling); else lookup perm scaling; and... > case vec_perm: > - return common_costs->permute_cost; > + return is_frac_vlmul_p (TYPE_MODE (vectype)) > + ? common_costs->permute_cost[LMUL_1] > + : common_costs->permute_cost[get_vlmul (TYPE_MODE (vectype))]; ... here maybe just always use permute_cost[LMUL1]? -- Regards Robin From rdapp.gcc@gmail.com Tue Nov 3 09:37:47 2026 From: rdapp.gcc@gmail.com (Robin Dapp) Date: Tue, 03 Nov 2026 10:37:47 +0100 Subject: [PATCH v1 0/4] RISC-V: Allow RVV register overlap for vfwredosum/vfwredusum.vs In-Reply-To: <20261103021109.3293351-1-pan2.li@intel.com> References: <20261103021109.3293351-1-pan2.li@intel.com> Message-ID: > From: Pan Li > > Like v[sz]ext.vf8, we continue the support for vfwredosum/vfwredusum.vs. > > The below test suites are passed for this patch: > 1. The rv64gcv fully regression tests. > LGTM. -- Regards Robin From fkastl@suse.cz Tue Nov 3 09:43:33 2026 From: fkastl@suse.cz (Filip Kastl) Date: Tue, 3 Nov 2026 10:43:33 +0100 Subject: [PATCH] Call symtab_node::get_create when it is suitable In-Reply-To: References: <20261102155252.2392802-1-giuliano.belinassi@suse.com> Message-ID: On Tue 2026-11-03 10:15:49, Martin Jambor wrote: > Hi, > > On Mon, Nov 02 2026, Giuliano Belinassi wrote: > > In many cases the original code checked if the decl is a variable or a > > function and forward the call to either varpool_node::get_create or > > cgraph_node::get_create. However, there is an API already for > > checking that: symtab_node::get_create. Hence, modify the code for > > the cases where this is suitable. > > > > gcc/ChangeLog: > > > > * cgraphunit.cc (symbol_table::process_same_body_aliases): Call > > symtab_node::get_create. > > * tree.cc (set_decl_section_name): Likewise. > > (decl_init_priority_insert): Likewise. > > * varasm.cc (assemble_alias): Likewise. > > (make_decl_one_only): Likewise. > > > > gcc/cp/ChangeLog: > > > > * decl.cc (duplicate_decls): Call symtab_node::get_create. > > OK, thanks, > > Martin > Ok, I committed it for Giuliano. Thanks, Filip From ktkachov@nvidia.com Tue Nov 3 09:43:29 2026 From: ktkachov@nvidia.com (ktkachov@nvidia.com) Date: Tue, 3 Nov 2026 10:43:29 +0100 Subject: [PATCH v3 3/8] vect: Select the C[LT]Z value at zero in the bit count pattern In-Reply-To: <20261103094334.43363-1-ktkachov@nvidia.com> References: <20261103094334.43363-1-ktkachov@nvidia.com> Message-ID: <20261103094334.43363-3-ktkachov@nvidia.com> From: Kyrylo Tkachov vect_recog_popcount_clz_ctz_ffs_pattern punts if a two-argument .CLZ or .CTZ has a value at zero that is not the value of the target for the vector mode, plus the addend of a widened CLZ. vect_recog_ctz_ffs_pattern already handles such a difference with a select. Do the same here: count with the value of the target, then select the value at zero of the call for zero lanes. If the count needs vect_recog_ctz_ffs_pattern, give it the value at zero of the call, so that it adds the select. On AArch64 _5 = .CTZ (_1, 5); _9 = (unsigned int) _5; now vectorizes to vect_patt_18.27_32 = .CTZ (vect__1.25_30, 32); mask_patt_19.26_31 = vect__1.25_30 != { 0, 0, 0, 0 }; vect_patt_20.28_33 = .VCOND_MASK (mask_patt_19.26_31, vect_patt_18.27_32, { 5, 5, 5, 5 }); Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux. gcc/ChangeLog: * tree-vect-patterns.cc (vect_recog_popcount_clz_ctz_ffs_pattern): Select the value at zero of a two-argument .CLZ or .CTZ if it is not the value of the target for the vector mode. gcc/testsuite/ChangeLog: * gcc.dg/vect/bb-slp-clz-ctz-value-at-zero-1.c: Expect vector counts with a select on aarch64. Signed-off-by: Kyrylo Tkachov --- New in v3. Richard Biener asked for this in his review of v1 07/14 (v3 2/8): https://gcc.gnu.org/pipermail/gcc-patches/2026-October/734819.html --- .../vect/bb-slp-clz-ctz-value-at-zero-1.c | 8 +++--- gcc/tree-vect-patterns.cc | 26 +++++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-clz-ctz-value-at-zero-1.c b/gcc/testsuite/gcc.dg/vect/bb-slp-clz-ctz-value-at-zero-1.c index 23b5c428bbe..94e63a4a9c4 100644 --- a/gcc/testsuite/gcc.dg/vect/bb-slp-clz-ctz-value-at-zero-1.c +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-clz-ctz-value-at-zero-1.c @@ -39,7 +39,8 @@ clz5 (void) return; } -/* The conversion makes the call part of a vectorizer pattern. */ +/* The conversion makes the call part of a vectorizer pattern, which + selects 5 for zero lanes. */ void __GIMPLE (ssa,startwith ("fix_loops")) __attribute__((noipa)) clz5u (void) @@ -178,5 +179,6 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times {\.CLZ \(vect_} 1 "optimized" { target aarch64*-*-* } } } */ -/* { dg-final { scan-tree-dump-not {\.CTZ \(vect_} "optimized" { target aarch64*-*-* } } } */ +/* { dg-final { scan-tree-dump-times {\.CLZ \(vect_} 2 "optimized" { target aarch64*-*-* } } } */ +/* { dg-final { scan-tree-dump-times {\.CTZ \(vect_} 1 "optimized" { target aarch64*-*-* } } } */ +/* { dg-final { scan-tree-dump-times {\.VCOND_MASK \(} 2 "optimized" { target aarch64*-*-* } } } */ diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index c706dafd611..a69b998e644 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -2278,7 +2278,8 @@ vect_recog_popcount_clz_ctz_ffs_pattern (vec_info *vinfo, } /* For zero the pattern gives the value of the target for VEC_TYPE plus - ADDEND. Punt if the call has another value at zero. */ + ADDEND. If the call has another value at zero, select it. */ + tree zero_val = NULL_TREE; if ((ifn == IFN_CLZ || ifn == IFN_CTZ) && gimple_call_internal_p (call_stmt) && gimple_call_num_args (call_stmt) == 2) @@ -2289,7 +2290,7 @@ vect_recog_popcount_clz_ctz_ffs_pattern (vec_info *vinfo, : CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (vec_type), val)); if (d != 2 || tree_to_shwi (gimple_call_arg (call_stmt, 1)) != val + addend) - return NULL; + zero_val = gimple_call_arg (call_stmt, 1); } /* Do it only if the backend has popcount2 etc. pattern. */ @@ -2352,6 +2353,12 @@ vect_recog_popcount_clz_ctz_ffs_pattern (vec_info *vinfo, && CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (vec_type), val) == 2) arg2 = build_int_cst (integer_type_node, val); + /* vect_recog_ctz_ffs_pattern selects the value at zero itself. */ + if (zero_val && !supported) + { + arg2 = zero_val; + zero_val = NULL_TREE; + } if (arg2) pattern_stmt = gimple_build_call_internal (ifn, 2, unprom_diff.op, arg2); else @@ -2391,6 +2398,21 @@ vect_recog_popcount_clz_ctz_ffs_pattern (vec_info *vinfo, else if (cast_stmt) append_pattern_def_seq (vinfo, stmt_vinfo, cast_stmt, vec_type); + if (zero_val) + { + append_pattern_def_seq (vinfo, stmt_vinfo, pattern_stmt, vec_type); + tree op = unprom_diff.op; + tree cmp = vect_recog_temp_ssa_var (boolean_type_node, NULL); + gimple *cmp_stmt = gimple_build_assign (cmp, NE_EXPR, op, + build_zero_cst (TREE_TYPE (op))); + append_pattern_def_seq (vinfo, stmt_vinfo, cmp_stmt, + truth_type_for (vec_type), TREE_TYPE (op)); + tree ret_var = vect_recog_temp_ssa_var (lhs_type, NULL); + pattern_stmt = gimple_build_assign (ret_var, COND_EXPR, cmp, + gimple_get_lhs (pattern_stmt), + fold_convert (lhs_type, zero_val)); + } + if (cast_stmt) { append_pattern_def_seq (vinfo, stmt_vinfo, pattern_stmt, vec_type); -- 2.34.1 From ktkachov@nvidia.com Tue Nov 3 09:43:27 2026 From: ktkachov@nvidia.com (ktkachov@nvidia.com) Date: Tue, 3 Nov 2026 10:43:27 +0100 Subject: [PATCH v3 1/8] ranger: Fix the CLZ and CTZ ranges for signed arguments Message-ID: <20261103094334.43363-1-ktkachov@nvidia.com> From: Kyrylo Tkachov cfn_clz::fold_range computes the minimum of the result from the upper bound of the argument, and cfn_ctz::fold_range computes the maximum of the result from it. This is wrong for a signed argument with negative values, because a negative value has the sign bit set. For _1 = .CLZ (x_4(D)); _2 = _1 > 0; with int x_4(D), evrp computes Global Exported: _1 = [irange] int [1, 31] and folds _2 to 1, but .CLZ (-5) is 0. For an argument in [-8, 4], .CTZ gets [0, 2], but .CTZ (-8) is 3. For an argument in [-8, 0], the upper bound 0 makes .CLZ (x, 32) and .CTZ (x, 32) fold to 32. Internal functions have no prototype, so .CLZ and .CTZ with a signed argument are valid GIMPLE. From C, only a redeclared builtin with a signed argument triggers the bug, as in PR112949, which was closed as invalid because that C code is undefined. cfn_ffs casts the argument to unsigned for the same reason (PR97325). Use the nonzero bits of the argument instead of its upper bound. Every value of the argument is a submask of the nonzero bits, and the nonzero bits are 0 only for [0, 0]. After the patch evrp computes Global Exported: _1 = [irange] int [0, 31] and keeps the comparison. The ranges of unsigned arguments do not change. Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux. Ok for trunk? Thanks, Kyrill Cc: Aldy Hernandez Cc: Andrew MacLeod gcc/ChangeLog: * gimple-range-op.cc (cfn_clz::fold_range): Use the nonzero bits of the argument instead of its upper bound. (cfn_ctz::fold_range): Likewise. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/clz-ctz-signed-1.c: New test. * gcc.target/aarch64/clz-ctz-signed-1.c: New test. Signed-off-by: Kyrylo Tkachov --- v2 (patch 1/9): https://gcc.gnu.org/pipermail/gcc-patches/2026-October/735342.html No changes from v2. v1 (patch 02/14): https://gcc.gnu.org/pipermail/gcc-patches/2026-October/734432.html Changes from v1: - Use the clzsi and ctzsi effective targets. --- gcc/gimple-range-op.cc | 7 +- .../gcc.dg/tree-ssa/clz-ctz-signed-1.c | 51 +++++++++++++ .../gcc.target/aarch64/clz-ctz-signed-1.c | 71 +++++++++++++++++++ 3 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/clz-ctz-signed-1.c create mode 100644 gcc/testsuite/gcc.target/aarch64/clz-ctz-signed-1.c diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index 20666ff0356..6c2d035ccc9 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -1027,8 +1027,9 @@ cfn_clz::fold_range (irange &r, tree type, const irange &lh, } if (mini == -2) return false; - // From clz of maximum we can compute result minimum. - wide_int max = lh.upper_bound (); + // Every value of the argument is a submask of the nonzero bits, so + // the clz of the nonzero bits is the minimum of the result. + wide_int max = lh.get_nonzero_bits (); int newmini = prec - 1 - wi::floor_log2 (max); if (max == 0) { @@ -1091,7 +1092,7 @@ cfn_ctz::fold_range (irange &r, tree type, const irange &lh, } // If some high bits are known to be zero, we can decrease // the maximum. - wide_int max = lh.upper_bound (); + wide_int max = lh.get_nonzero_bits (); if (max == 0) { // Argument is [0, 0]. If CTZ_DEFINED_VALUE_AT_ZERO diff --git a/gcc/testsuite/gcc.dg/tree-ssa/clz-ctz-signed-1.c b/gcc/testsuite/gcc.dg/tree-ssa/clz-ctz-signed-1.c new file mode 100644 index 00000000000..b840412d9d8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/clz-ctz-signed-1.c @@ -0,0 +1,51 @@ +/* Ranges of .CLZ and .CTZ of a signed argument with negative values. */ +/* { dg-do run } */ +/* { dg-require-effective-target clzsi } */ +/* { dg-require-effective-target ctzsi } */ +/* { dg-options "-O2 -fgimple" } */ + +/* .CLZ (X) is 0 for a negative X. */ + +int __attribute__((noipa)) __GIMPLE (ssa,startwith("evrp")) +clz1 (int x) +{ + int _1; + _Bool _2; + int _3; + + __BB(2): + _1 = .CLZ (x_4(D)); + _2 = _1 > 0; + _3 = _2 ? 100 : 7; + return _3; +} + +/* .CTZ (-8) is 3, more than the floor_log2 of the maximum 4. */ + +int __attribute__((noipa)) __GIMPLE (ssa,startwith("evrp")) +ctz1 (int x) +{ + int _1; + _Bool _2; + int _3; + int _5; + int _6; + + __BB(2): + _5 = __MAX (x_4(D), _Literal (int) -8); + _6 = __MIN (_5, 4); + _1 = .CTZ (_6); + _2 = _1 <= 2; + _3 = _2 ? 100 : 7; + return _3; +} + +int +main (void) +{ + if (clz1 (-5) != 7) + __builtin_abort (); + if (ctz1 (-8) != 7) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.target/aarch64/clz-ctz-signed-1.c b/gcc/testsuite/gcc.target/aarch64/clz-ctz-signed-1.c new file mode 100644 index 00000000000..16b2a9b7b2e --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/clz-ctz-signed-1.c @@ -0,0 +1,71 @@ +/* Ranges of .CLZ and .CTZ of a signed argument with negative values, with + the value at zero in the second argument. 32 is the value that AArch64 + defines for SImode. */ +/* { dg-do run } */ +/* { dg-options "-O2 -fgimple" } */ + +/* .CLZ (X, 32) is 0 for a negative X. */ + +int __attribute__((noipa)) __GIMPLE (ssa,startwith("evrp")) +clz1 (int x) +{ + int _1; + _Bool _2; + int _3; + + __BB(2): + _1 = .CLZ (x_4(D), 32); + _2 = _1 > 0; + _3 = _2 ? 100 : 7; + return _3; +} + +/* X >> 31 is -1 or 0, and .CLZ (-1, 32) is 0. */ + +int __attribute__((noipa)) __GIMPLE (ssa,startwith("evrp")) +clz2 (int x) +{ + int _1; + _Bool _2; + int _3; + int _5; + + __BB(2): + _5 = x_4(D) >> 31; + _1 = .CLZ (_5, 32); + _2 = _1 == 32; + _3 = _2 ? 100 : 7; + return _3; +} + +/* .CTZ (-8, 32) is 3. */ + +int __attribute__((noipa)) __GIMPLE (ssa,startwith("evrp")) +ctz1 (int x) +{ + int _1; + _Bool _2; + int _3; + int _5; + int _6; + + __BB(2): + _5 = __MAX (x_4(D), _Literal (int) -8); + _6 = __MIN (_5, 0); + _1 = .CTZ (_6, 32); + _2 = _1 == 32; + _3 = _2 ? 100 : 7; + return _3; +} + +int +main (void) +{ + if (clz1 (-5) != 7) + __builtin_abort (); + if (clz2 (-5) != 7) + __builtin_abort (); + if (ctz1 (-8) != 7) + __builtin_abort (); + return 0; +} -- 2.34.1 From ktkachov@nvidia.com Tue Nov 3 09:43:30 2026 From: ktkachov@nvidia.com (ktkachov@nvidia.com) Date: Tue, 3 Nov 2026 10:43:30 +0100 Subject: [PATCH v3 4/8] phiopt: Emit conditional debug binds for removed middle blocks In-Reply-To: <20261103094334.43363-1-ktkachov@nvidia.com> References: <20261103094334.43363-1-ktkachov@nvidia.com> Message-ID: <20261103094334.43363-4-ktkachov@nvidia.com> From: Kyrylo Tkachov replace_phi_edge_with_variable deletes the middle blocks of a diamond or triangle together with their debug binds. A variable that a removed block binds then keeps its earlier value after the condition, also on the path through the removed block, and a debugger shows a wrong value. For unsigned f (unsigned m, unsigned a, unsigned b, _Bool c) { unsigned w = a; unsigned r = m; if (c) { w = b; r = m | w; } return r; } phiopt2 removes the branch, and at the return w has the value of a also when c is true. Before the condition is removed, emit a debug bind for each variable that the removed blocks bind. The condition selects the value of the variable after the removed blocks on each path, as value_replacement and spaceship_replacement do for their debug binds. On a path without a bind of the variable, the value is the one of its last bind in the condition block. The variable is reset if a value is unknown, or is not a constant or an SSA name from outside the removed blocks. The binds go to the end of the condition block, so they do not apply to other paths into the merge block. phiopt2 now emits # DEBUG w => c_4(D) != 0 ? b_5(D) : a_2(D) Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux. gcc/ChangeLog: * tree-ssa-phiopt.cc (emit_removed_debug_binds): New function. (replace_phi_edge_with_variable): Call it for removed blocks. gcc/testsuite/ChangeLog: * gcc.dg/guality/phiopt-1.c: New test. * gcc.dg/tree-ssa/phi-opt-62.c: New test. Signed-off-by: Kyrylo Tkachov --- v2 (patch 5/9): https://gcc.gnu.org/pipermail/gcc-patches/2026-October/735344.html v1 (patch 10/14) did not reach the list. Changes from v2: - Instead of resetting the binds of the removed blocks in the merge block, emit binds whose value the condition selects (Andrea Pinski). - The binds go to the end of the condition block, so they do not apply to other paths into the merge block. - New test gcc.dg/guality/phiopt-1.c. --- gcc/testsuite/gcc.dg/guality/phiopt-1.c | 31 +++++++ gcc/testsuite/gcc.dg/tree-ssa/phi-opt-62.c | 20 ++++ gcc/tree-ssa-phiopt.cc | 102 ++++++++++++++++++++- 3 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/guality/phiopt-1.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/phi-opt-62.c diff --git a/gcc/testsuite/gcc.dg/guality/phiopt-1.c b/gcc/testsuite/gcc.dg/guality/phiopt-1.c new file mode 100644 index 00000000000..bb898da42cc --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/phiopt-1.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-options "-g" } */ +/* { dg-skip-if "phiopt does not run" { *-*-* } { "-Og" } { "" } } */ + +#include "../nop.h" + +__attribute__((noipa)) unsigned +f (unsigned m, unsigned a, unsigned b, _Bool c) +{ + unsigned w = a; + unsigned r = m; + if (c) + { + w = b; + r = m | w; + } + asm volatile (NOP : : "r" (r), "r" (a), "r" (b), "r" (c)); + return r; +} + +int +main (void) +{ + volatile unsigned m = 1, a = 2, b = 4; + volatile _Bool c = 1; + f (m, a, b, c); + return 0; +} + +/* phiopt removes the branch. W is B after it, as C is true. */ +/* { dg-final { gdb-test 17 "w" "4" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-62.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-62.c new file mode 100644 index 00000000000..28d25867e19 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-62.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -fdump-tree-phiopt2" } */ + +/* phiopt removes the conditional block, which binds W. W gets B or A + after the condition, depending on C. */ + +unsigned +f (unsigned m, unsigned a, unsigned b, _Bool c) +{ + unsigned w = a; + unsigned r = m; + if (c) + { + w = b; + r = m | w; + } + return r; +} + +/* { dg-final { scan-tree-dump {DEBUG w => c_\d+\(D\) != 0 \? b_\d+\(D\) : a_\d+\(D\)} "phiopt2" } } */ diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 875f8e4af34..0daddb4ee2f 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -86,6 +86,97 @@ single_non_singleton_phi_for_edges (gimple_seq seq, edge e0, edge e1) return phi; } +/* COND_BB ends in a condition that is about to be removed together with + BB_TRUE and BB_FALSE, the blocks on its true and false edges, or NULL if + the edge goes directly to the merge block. For each variable that the + debug binds of BB_TRUE or BB_FALSE bind, emit before the condition a + bind to the value that the variable has after the removed block on each + path, selected by the condition. The value on a path without a bind of + the variable is the one of its last bind in COND_BB. Reset the variable + if a value is unknown or is not a constant or an SSA name from outside + the removed blocks. */ + +static void +emit_removed_debug_binds (basic_block cond_bb, basic_block bb_true, + basic_block bb_false) +{ + if (!MAY_HAVE_DEBUG_BIND_STMTS) + return; + + /* The values of the variables on the true and false paths, in the order + of their first bind. error_mark_node stands for no bind. */ + hash_map > vals; + auto_vec vars; + basic_block arms[2] = { bb_true, bb_false }; + for (int i = 0; i < 2; i++) + if (arms[i]) + for (gimple_stmt_iterator gsi = gsi_start_bb (arms[i]); + !gsi_end_p (gsi); gsi_next (&gsi)) + { + gimple *stmt = gsi_stmt (gsi); + if (!gimple_debug_bind_p (stmt)) + continue; + tree var = gimple_debug_bind_get_var (stmt); + if (TREE_CODE (var) == DEBUG_EXPR_DECL) + continue; + bool existed; + std::pair &v = vals.get_or_insert (var, &existed); + if (!existed) + { + v = std::make_pair (error_mark_node, error_mark_node); + vars.safe_push (var); + } + tree val = gimple_debug_bind_get_value (stmt); + if (val + && !is_gimple_min_invariant (val) + && (TREE_CODE (val) != SSA_NAME + || gimple_bb (SSA_NAME_DEF_STMT (val)) == arms[i])) + val = NULL_TREE; + if (i == 0) + v.first = val; + else + v.second = val; + } + if (vars.is_empty ()) + return; + + for (gimple_stmt_iterator gsi = gsi_last_bb (cond_bb); !gsi_end_p (gsi); + gsi_prev (&gsi)) + if (gimple_debug_bind_p (gsi_stmt (gsi))) + if (std::pair *v + = vals.get (gimple_debug_bind_get_var (gsi_stmt (gsi)))) + { + tree val = gimple_debug_bind_get_value (gsi_stmt (gsi)); + if (v->first == error_mark_node) + v->first = val; + if (v->second == error_mark_node) + v->second = val; + } + + gimple_stmt_iterator gsi = gsi_last_bb (cond_bb); + gcond *cond = as_a (gsi_stmt (gsi)); + for (tree var : vars) + { + std::pair v = *vals.get (var); + tree val = NULL_TREE; + if (v.first && v.second + && v.first != error_mark_node && v.second != error_mark_node) + { + if (operand_equal_p (v.first, v.second)) + val = unshare_expr (v.first); + else if (useless_type_conversion_p (TREE_TYPE (v.first), + TREE_TYPE (v.second))) + val = build3 (COND_EXPR, TREE_TYPE (v.first), + build2 (gimple_cond_code (cond), boolean_type_node, + gimple_cond_lhs (cond), + gimple_cond_rhs (cond)), + unshare_expr (v.first), unshare_expr (v.second)); + } + gsi_insert_before (&gsi, gimple_build_debug_bind (var, val, cond), + GSI_SAME_STMT); + } +} + /* Replace PHI node element whose edge is E in block BB with variable NEW. Remove the edge from COND_BLOCK which does not lead to BB (COND_BLOCK is known to have two edges, one of which must reach BB). */ @@ -174,7 +265,12 @@ replace_phi_edge_with_variable (basic_block cond_block, e->flags |= EDGE_FALLTHRU; e->flags &= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE); e->probability = profile_probability::always (); - delete_basic_block (edge_to_remove->dest); + basic_block middle_bb = edge_to_remove->dest; + if (edge_to_remove->flags & EDGE_TRUE_VALUE) + emit_removed_debug_binds (cond_block, middle_bb, NULL); + else + emit_removed_debug_binds (cond_block, NULL, middle_bb); + delete_basic_block (middle_bb); /* Eliminate the COND_EXPR at the end of COND_BLOCK. */ gsi = gsi_last_bb (cond_block); @@ -184,6 +280,10 @@ replace_phi_edge_with_variable (basic_block cond_block, { basic_block bb1 = EDGE_SUCC (cond_block, 0)->dest; basic_block bb2 = EDGE_SUCC (cond_block, 1)->dest; + if (EDGE_SUCC (cond_block, 0)->flags & EDGE_TRUE_VALUE) + emit_removed_debug_binds (cond_block, bb1, bb2); + else + emit_removed_debug_binds (cond_block, bb2, bb1); edge newedge = redirect_edge_and_branch (keep_edge, bb); -- 2.34.1 From ktkachov@nvidia.com Tue Nov 3 09:43:28 2026 From: ktkachov@nvidia.com (ktkachov@nvidia.com) Date: Tue, 3 Nov 2026 10:43:28 +0100 Subject: [PATCH v3 2/8] vect: Check the C[LT]Z value at zero for all precisions In-Reply-To: <20261103094334.43363-1-ktkachov@nvidia.com> References: <20261103094334.43363-1-ktkachov@nvidia.com> Message-ID: <20261103094334.43363-2-ktkachov@nvidia.com> From: Kyrylo Tkachov vect_recog_popcount_clz_ctz_ffs_pattern checks the second argument of a two-argument .CLZ or .CTZ against the value of the target. It does this only when the precisions of the argument and the result differ. For equal precisions it builds the pattern call with the value of the target. On AArch64 _5 = .CLZ (_1, 5); _9 = (unsigned int) _5; becomes vect_patt_18.11_23 = .CLZ (vect__1.10_22, 32); and zero lanes give 32 instead of 5. The expansion implements any value at zero of a scalar call, so such scalar calls are valid. Do the check after the switch, for all precisions. The calls of the example then stay scalar. Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux. gcc/ChangeLog: * tree-vect-patterns.cc (vect_recog_popcount_clz_ctz_ffs_pattern): Check the value at zero of a two-argument .CLZ or .CTZ for all precisions. gcc/testsuite/ChangeLog: * gcc.dg/vect/bb-slp-clz-ctz-value-at-zero-1.c: New test. Signed-off-by: Kyrylo Tkachov Reviewed-by: Richard Biener --- v2 (patch 4/9): https://gcc.gnu.org/pipermail/gcc-patches/2026-October/735343.html No changes from v2. Will push soon as per Richard's approval. v1 (patch 07/14): https://gcc.gnu.org/pipermail/gcc-patches/2026-October/734441.html Changes from v1: - Use the clzsi and ctzsi effective targets. --- .../vect/bb-slp-clz-ctz-value-at-zero-1.c | 182 ++++++++++++++++++ gcc/tree-vect-patterns.cc | 43 ++--- 2 files changed, 199 insertions(+), 26 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-clz-ctz-value-at-zero-1.c diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-clz-ctz-value-at-zero-1.c b/gcc/testsuite/gcc.dg/vect/bb-slp-clz-ctz-value-at-zero-1.c new file mode 100644 index 00000000000..23b5c428bbe --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-clz-ctz-value-at-zero-1.c @@ -0,0 +1,182 @@ +/* Lanes of .CLZ and .CTZ whose value at zero is not the value of the + target must keep that value. */ +/* { dg-require-effective-target int32 } */ +/* { dg-require-effective-target clzsi } */ +/* { dg-require-effective-target ctzsi } */ +/* { dg-additional-options "-fgimple -fdump-tree-optimized" } */ + +#include "tree-vect.h" + +unsigned int a[4]; +int r[4]; +unsigned int u[4]; + +void __GIMPLE (ssa,startwith ("fix_loops")) __attribute__((noipa)) +clz5 (void) +{ + unsigned int _1; + unsigned int _2; + unsigned int _3; + unsigned int _4; + int _5; + int _6; + int _7; + int _8; + + __BB(2): + _1 = a[0]; + _2 = a[1]; + _3 = a[2]; + _4 = a[3]; + _5 = .CLZ (_1, 5); + _6 = .CLZ (_2, 5); + _7 = .CLZ (_3, 5); + _8 = .CLZ (_4, 5); + r[0] = _5; + r[1] = _6; + r[2] = _7; + r[3] = _8; + return; +} + +/* The conversion makes the call part of a vectorizer pattern. */ + +void __GIMPLE (ssa,startwith ("fix_loops")) __attribute__((noipa)) +clz5u (void) +{ + unsigned int _1; + unsigned int _2; + unsigned int _3; + unsigned int _4; + int _5; + int _6; + int _7; + int _8; + unsigned int _9; + unsigned int _10; + unsigned int _11; + unsigned int _12; + + __BB(2): + _1 = a[0]; + _2 = a[1]; + _3 = a[2]; + _4 = a[3]; + _5 = .CLZ (_1, 5); + _6 = .CLZ (_2, 5); + _7 = .CLZ (_3, 5); + _8 = .CLZ (_4, 5); + _9 = (unsigned int) _5; + _10 = (unsigned int) _6; + _11 = (unsigned int) _7; + _12 = (unsigned int) _8; + u[0] = _9; + u[1] = _10; + u[2] = _11; + u[3] = _12; + return; +} + +void __GIMPLE (ssa,startwith ("fix_loops")) __attribute__((noipa)) +ctz5u (void) +{ + unsigned int _1; + unsigned int _2; + unsigned int _3; + unsigned int _4; + int _5; + int _6; + int _7; + int _8; + unsigned int _9; + unsigned int _10; + unsigned int _11; + unsigned int _12; + + __BB(2): + _1 = a[0]; + _2 = a[1]; + _3 = a[2]; + _4 = a[3]; + _5 = .CTZ (_1, 5); + _6 = .CTZ (_2, 5); + _7 = .CTZ (_3, 5); + _8 = .CTZ (_4, 5); + _9 = (unsigned int) _5; + _10 = (unsigned int) _6; + _11 = (unsigned int) _7; + _12 = (unsigned int) _8; + u[0] = _9; + u[1] = _10; + u[2] = _11; + u[3] = _12; + return; +} + +/* 32 is the value of the target on AArch64, so this vectorizes there. */ + +void __GIMPLE (ssa,startwith ("fix_loops")) __attribute__((noipa)) +clz32u (void) +{ + unsigned int _1; + unsigned int _2; + unsigned int _3; + unsigned int _4; + int _5; + int _6; + int _7; + int _8; + unsigned int _9; + unsigned int _10; + unsigned int _11; + unsigned int _12; + + __BB(2): + _1 = a[0]; + _2 = a[1]; + _3 = a[2]; + _4 = a[3]; + _5 = .CLZ (_1, 32); + _6 = .CLZ (_2, 32); + _7 = .CLZ (_3, 32); + _8 = .CLZ (_4, 32); + _9 = (unsigned int) _5; + _10 = (unsigned int) _6; + _11 = (unsigned int) _7; + _12 = (unsigned int) _8; + u[0] = _9; + u[1] = _10; + u[2] = _11; + u[3] = _12; + return; +} + +static void __attribute__((noipa)) +check (const unsigned int *p, unsigned int e0, unsigned int e1, + unsigned int e2, unsigned int e3) +{ + if (p[0] != e0 || p[1] != e1 || p[2] != e2 || p[3] != e3) + __builtin_abort (); +} + +int +main (void) +{ + check_vect (); + + /* Write A at run time, so that LTO cannot fold the loads. */ + a[1] = 1; + a[3] = 0x80000000u; + clz5 (); + check ((const unsigned int *) r, 5, 31, 5, 0); + clz5u (); + check (u, 5, 31, 5, 0); + ctz5u (); + check (u, 5, 0, 5, 31); + clz32u (); + check (u, 32, 31, 32, 0); + return 0; +} + +/* { dg-final { scan-tree-dump-times {\.CLZ \(vect_} 1 "optimized" { target aarch64*-*-* } } } */ +/* { dg-final { scan-tree-dump-not {\.CTZ \(vect_} "optimized" { target aarch64*-*-* } } } */ diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index d79f625280a..c706dafd611 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -2258,9 +2258,7 @@ vect_recog_popcount_clz_ctz_ffs_pattern (vec_info *vinfo, return NULL; break; case IFN_CLZ: - /* clzll (x) == clz (x) + 32 for unsigned x != 0, so ok - if it is undefined at zero or if it matches also for the - defined value there. */ + /* clzll (x) == clz (x) + 32 for unsigned x != 0. */ if (!TYPE_UNSIGNED (unprom_diff.type)) return NULL; if (!type_has_mode_precision_p (lhs_type) @@ -2268,31 +2266,9 @@ vect_recog_popcount_clz_ctz_ffs_pattern (vec_info *vinfo, return NULL; addend = (TYPE_PRECISION (TREE_TYPE (rhs_oprnd)) - TYPE_PRECISION (lhs_type)); - if (gimple_call_internal_p (call_stmt) - && gimple_call_num_args (call_stmt) == 2) - { - int val1, val2; - val1 = tree_to_shwi (gimple_call_arg (call_stmt, 1)); - int d2 - = CLZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (vec_type), val2); - if (d2 != 2 || val1 != val2 + addend) - return NULL; - } break; case IFN_CTZ: - /* ctzll (x) == ctz (x) for unsigned or signed x != 0, so ok - if it is undefined at zero or if it matches also for the - defined value there. */ - if (gimple_call_internal_p (call_stmt) - && gimple_call_num_args (call_stmt) == 2) - { - int val1, val2; - val1 = tree_to_shwi (gimple_call_arg (call_stmt, 1)); - int d2 - = CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (vec_type), val2); - if (d2 != 2 || val1 != val2) - return NULL; - } + /* ctzll (x) == ctz (x) for unsigned or signed x != 0. */ break; case IFN_FFS: /* ffsll (x) == ffs (x) for unsigned or signed x. */ @@ -2301,6 +2277,21 @@ vect_recog_popcount_clz_ctz_ffs_pattern (vec_info *vinfo, gcc_unreachable (); } + /* For zero the pattern gives the value of the target for VEC_TYPE plus + ADDEND. Punt if the call has another value at zero. */ + if ((ifn == IFN_CLZ || ifn == IFN_CTZ) + && gimple_call_internal_p (call_stmt) + && gimple_call_num_args (call_stmt) == 2) + { + int val; + int d = (ifn == IFN_CLZ + ? CLZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (vec_type), val) + : CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (vec_type), val)); + if (d != 2 + || tree_to_shwi (gimple_call_arg (call_stmt, 1)) != val + addend) + return NULL; + } + /* Do it only if the backend has popcount2 etc. pattern. */ bool supported = direct_internal_fn_supported_p (ifn, vec_type, OPTIMIZE_FOR_SPEED); -- 2.34.1 From ktkachov@nvidia.com Tue Nov 3 09:43:32 2026 From: ktkachov@nvidia.com (ktkachov@nvidia.com) Date: Tue, 3 Nov 2026 10:43:32 +0100 Subject: [PATCH v3 6/8] phiopt: Remove cond_removal_in_builtin_zero_pattern In-Reply-To: <20261103094334.43363-1-ktkachov@nvidia.com> References: <20261103094334.43363-1-ktkachov@nvidia.com> Message-ID: <20261103094334.43363-6-ktkachov@nvidia.com> From: Kyrylo Tkachov cond_removal_in_builtin_zero_pattern removes the branch in r = 0; if (x != 0) r = __builtin_popcount (x); and in the same form with bswap, bitreverse, ffs, parity, clrsb, clz and ctz, when the call gives the other PHI argument for a zero argument. It moves the call and an optional conversion of x before the condition. match.pd has these folds since r14-362 and r14-414, except for bitreverse, and match_simplify_replacement can now move the conversion and the call, so the function is not needed. Add bitreverse to the match.pd fold. The function did not check for maybe undefined operands, but match_simplify_replacement does. To keep the x != 0 case, allow a maybe undefined operand in a moved statement if the condition uses that operand. A widening conversion to a _BitInt wider than any integer mode, which bitint lowering turns into a loop, is not moved with the call any more, so such a branch stays. The folds now happen in early phiopt when the result is the existing call. This is the second part of the patch by Andrea Pinski at https://gcc.gnu.org/pipermail/gcc-patches/2026-July/723433.html Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux. gcc/ChangeLog: * match.pd (a != 0 ? FUN(a) : 0 -> Fun(a)): Also for BITREVERSE. * tree-ssa-phiopt.cc (feeding_bb_info): Allow a maybe undefined operand that the condition uses. (cond_removal_in_builtin_zero_pattern): Remove. (pass_phiopt::execute): Do not call it. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/phi-opt-60.c: New test. * gcc.dg/tree-ssa/phi-opt-61.c: New test. * gcc.dg/tree-ssa/phi-opt-63.c: New test. Co-authored-by: Andrea Pinski Signed-off-by: Andrea Pinski Signed-off-by: Kyrylo Tkachov Reviewed-by: Jeff Law --- APPROVED (v2) by Jeff Law: https://inbox.sourceware.org/gcc-patches/0415e764-267a-461c-af3d-9786cf53ad9f@oss.qualcomm.com/ v2 (patch 7/9): https://gcc.gnu.org/pipermail/gcc-patches/2026-October/735348.html v1 (patch 12/14): https://gcc.gnu.org/pipermail/gcc-patches/2026-October/734442.html This needs 5/8, Andrea Pinski's phiopt patch: https://gcc.gnu.org/pipermail/gcc-patches/2026-October/736039.html Changes from v2: - On top of Andrea Pinski's phiopt patch instead of v2 6/9. The change for maybe undefined operands is in feeding_bb_info. --- gcc/match.pd | 2 +- gcc/testsuite/gcc.dg/tree-ssa/phi-opt-60.c | 25 ++ gcc/testsuite/gcc.dg/tree-ssa/phi-opt-61.c | 40 +++ gcc/testsuite/gcc.dg/tree-ssa/phi-opt-63.c | 25 ++ gcc/tree-ssa-phiopt.cc | 283 +-------------------- 5 files changed, 97 insertions(+), 278 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/phi-opt-60.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/phi-opt-61.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/phi-opt-63.c diff --git a/gcc/match.pd b/gcc/match.pd index d1eeb283bcb..46ad2a2e174 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -11830,7 +11830,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) #endif /* a != 0 ? FUN(a) : 0 -> Fun(a) for some builtin functions. */ -(for func (POPCOUNT BSWAP FFS PARITY) +(for func (POPCOUNT BSWAP FFS PARITY BITREVERSE) (simplify (cond (ne @0 integer_zerop@1) (func@3 (convert? @0)) integer_zerop@2) @3)) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-60.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-60.c new file mode 100644 index 00000000000..1ba8dc53dca --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-60.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt1-details" } */ + +/* match.pd folds x != 0 ? FUN (x) : 0 to FUN (x), and phiopt moves the + call and the conversion before the condition. */ + +unsigned +f1 (unsigned x) +{ + unsigned r = 0; + if (x) + r = __builtin_bitreverse32 (x); + return r; +} + +int +f2 (int x) +{ + int r = 0; + if (x) + r = __builtin_popcountl ((unsigned long) x); + return r; +} + +/* { dg-final { scan-tree-dump-times "to straightline code" 2 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-61.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-61.c new file mode 100644 index 00000000000..7d262307233 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-61.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgimple -fdump-tree-phiopt2-details" } */ + +/* X_2 may be undefined, but the condition already uses it, so phiopt can + move the count before the condition. */ + +int __GIMPLE (ssa,startwith("phiopt2")) +f (int c, unsigned int y) +{ + unsigned int x; + int t; + int r; + + __BB(2): + if (c_1(D) != 0) + goto __BB3; + else + goto __BB4; + + __BB(3): + goto __BB4; + + __BB(4): + x_2 = __PHI (__BB2: x_3(D), __BB3: y_4(D)); + if (x_2 != 0u) + goto __BB5; + else + goto __BB6; + + __BB(5): + t_5 = __builtin_popcount (x_2); + goto __BB6; + + __BB(6): + r_6 = __PHI (__BB4: 0, __BB5: t_5); + return r_6; +} + +/* { dg-final { scan-tree-dump-times "to straightline code" 1 "phiopt2" } } */ +/* { dg-final { scan-tree-dump-times "if \\(" 1 "phiopt2" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-63.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-63.c new file mode 100644 index 00000000000..e0f7facaa7f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-63.c @@ -0,0 +1,25 @@ +/* { dg-do compile { target bitint575 } } */ +/* { dg-options "-O2 -std=c23 -fdump-tree-phiopt-details" } */ + +/* The nop conversion to a wide _BitInt type is moved with the count. */ + +int +f (signed _BitInt(256) x) +{ + int r = 0; + if (x != 0) + r = __builtin_popcountg ((unsigned _BitInt(256)) x); + return r; +} + +int +g (signed _BitInt(192) x) +{ + int r = 77; + if (x != 0) + r = __builtin_ctzg ((unsigned _BitInt(192)) x); + return r; +} + +/* { dg-final { scan-tree-dump-times "to straightline code" 1 "phiopt1" } } */ +/* { dg-final { scan-tree-dump-times "to straightline code" 1 "phiopt2" } } */ diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index acc8faea635..ccb67ab5d2a 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -1069,10 +1069,15 @@ feeding_bb_info (basic_block bb, gimple *phi, gimple *&stmt) if (gimple_could_trap_p (s) || gimple_has_side_effects (s)) return invalid_bb; + /* A maybe undefined value that the condition uses is defined + when the statement executes. */ + gcond *cond = as_a (*gsi_last_bb (single_pred (bb))); ssa_op_iter it; tree use; FOR_EACH_SSA_TREE_OPERAND (use, s, it, SSA_OP_USE) - if (ssa_name_maybe_undef_p (use)) + if (ssa_name_maybe_undef_p (use) + && use != gimple_cond_lhs (cond) + && use != gimple_cond_rhs (cond)) return invalid_bb; /* Allow some assignments but allow some builtin/internal calls. @@ -3115,276 +3120,6 @@ spaceship_replacement (basic_block cond_bb, basic_block middle_bb, return true; } -/* Optimize x ? __builtin_fun (x) : C, where C is __builtin_fun (0). - Convert - - - if (b_4(D) != 0) - goto - else - goto - - - _2 = (unsigned long) b_4(D); - _9 = __builtin_popcountl (_2); - OR - _9 = __builtin_popcountl (b_4(D)); - - - c_12 = PHI <0(2), _9(3)> - - Into - - _2 = (unsigned long) b_4(D); - _9 = __builtin_popcountl (_2); - OR - _9 = __builtin_popcountl (b_4(D)); - - - c_12 = PHI <_9(2)> - - Similarly for __builtin_clz or __builtin_ctz if - C?Z_DEFINED_VALUE_AT_ZERO is 2, optab is present and - instead of 0 above it uses the value from that macro. */ - -static bool -cond_removal_in_builtin_zero_pattern (basic_block cond_bb, - basic_block middle_bb, - edge e1, edge e2, gphi *phi, - tree arg0, tree arg1) -{ - gimple_stmt_iterator gsi, gsi_from; - gimple *call; - gimple *cast = NULL; - tree lhs, arg; - - /* Check that - _2 = (unsigned long) b_4(D); - _9 = __builtin_popcountl (_2); - OR - _9 = __builtin_popcountl (b_4(D)); - are the only stmts in the middle_bb. */ - - gsi = gsi_start_nondebug_after_labels_bb (middle_bb); - if (gsi_end_p (gsi)) - return false; - cast = gsi_stmt (gsi); - gsi_next_nondebug (&gsi); - if (!gsi_end_p (gsi)) - { - call = gsi_stmt (gsi); - gsi_next_nondebug (&gsi); - if (!gsi_end_p (gsi)) - return false; - } - else - { - call = cast; - cast = NULL; - } - - /* Check that we have a popcount/clz/ctz builtin. */ - if (!is_gimple_call (call)) - return false; - - lhs = gimple_get_lhs (call); - - if (lhs == NULL_TREE) - return false; - - combined_fn cfn = gimple_call_combined_fn (call); - if (gimple_call_num_args (call) != 1 - && (gimple_call_num_args (call) != 2 - || cfn == CFN_CLZ - || cfn == CFN_CTZ)) - return false; - - arg = gimple_call_arg (call, 0); - - internal_fn ifn = IFN_LAST; - int val = 0; - bool any_val = false; - switch (cfn) - { - CASE_CFN_BSWAP: - CASE_CFN_BITREVERSE: - CASE_CFN_FFS: - CASE_CFN_PARITY: - CASE_CFN_POPCOUNT: - break; - CASE_CFN_CLZ: - if (INTEGRAL_TYPE_P (TREE_TYPE (arg))) - { - tree type = TREE_TYPE (arg); - if (BITINT_TYPE_P (type)) - { - if (gimple_call_num_args (call) == 1) - { - any_val = true; - ifn = IFN_CLZ; - break; - } - if (!tree_fits_shwi_p (gimple_call_arg (call, 1))) - return false; - HOST_WIDE_INT at_zero = tree_to_shwi (gimple_call_arg (call, 1)); - if ((int) at_zero != at_zero) - return false; - ifn = IFN_CLZ; - val = at_zero; - break; - } - if (direct_internal_fn_supported_p (IFN_CLZ, type, OPTIMIZE_FOR_BOTH) - && CLZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (type), - val) == 2) - { - ifn = IFN_CLZ; - break; - } - } - return false; - CASE_CFN_CTZ: - if (INTEGRAL_TYPE_P (TREE_TYPE (arg))) - { - tree type = TREE_TYPE (arg); - if (BITINT_TYPE_P (type)) - { - if (gimple_call_num_args (call) == 1) - { - any_val = true; - ifn = IFN_CTZ; - break; - } - if (!tree_fits_shwi_p (gimple_call_arg (call, 1))) - return false; - HOST_WIDE_INT at_zero = tree_to_shwi (gimple_call_arg (call, 1)); - if ((int) at_zero != at_zero) - return false; - ifn = IFN_CTZ; - val = at_zero; - break; - } - if (direct_internal_fn_supported_p (IFN_CTZ, type, OPTIMIZE_FOR_BOTH) - && CTZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (type), - val) == 2) - { - ifn = IFN_CTZ; - break; - } - } - return false; - case CFN_BUILT_IN_CLRSB: - val = TYPE_PRECISION (integer_type_node) - 1; - break; - case CFN_BUILT_IN_CLRSBL: - val = TYPE_PRECISION (long_integer_type_node) - 1; - break; - case CFN_BUILT_IN_CLRSBLL: - val = TYPE_PRECISION (long_long_integer_type_node) - 1; - break; - default: - return false; - } - - if (cast) - { - /* We have a cast stmt feeding popcount/clz/ctz builtin. */ - /* Check that we have a cast prior to that. */ - if (gimple_code (cast) != GIMPLE_ASSIGN - || !CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (cast))) - return false; - /* Result of the cast stmt is the argument to the builtin. */ - if (arg != gimple_assign_lhs (cast)) - return false; - arg = gimple_assign_rhs1 (cast); - } - - gcond *cond = dyn_cast (*gsi_last_bb (cond_bb)); - - /* Cond_bb has a check for b_4 [!=|==] 0 before calling the popcount/clz/ctz - builtin. */ - if (!cond - || (gimple_cond_code (cond) != NE_EXPR - && gimple_cond_code (cond) != EQ_EXPR) - || !integer_zerop (gimple_cond_rhs (cond)) - || arg != gimple_cond_lhs (cond)) - return false; - - edge true_edge, false_edge; - /* We need to know which is the true edge and which is the false - edge so that we know when to invert the condition below. */ - extract_true_false_edges_from_block (cond_bb, &true_edge, &false_edge); - - /* Forward the edges over the middle basic block. */ - if (true_edge->dest == middle_bb) - true_edge = EDGE_SUCC (true_edge->dest, 0); - if (false_edge->dest == middle_bb) - false_edge = EDGE_SUCC (false_edge->dest, 0); - - /* Canonicalize the args with respect to the edges, - arg0 is from the true edge and arg1 is from the - false edge. - That is `cond ? arg0 : arg1`.*/ - if (true_edge == e1) - gcc_assert (false_edge == e2); - else - { - gcc_assert (false_edge == e1); - gcc_assert (true_edge == e2); - std::swap (arg0, arg1); - } - - /* Canonicalize the args such that we get: - `arg != 0 ? arg0 : arg1`. So swap arg0/arg1 - around if cond was an equals. */ - if (gimple_cond_code (cond) == EQ_EXPR) - std::swap (arg0, arg1); - - /* Check PHI arguments. */ - if (lhs != arg0 - || TREE_CODE (arg1) != INTEGER_CST) - return false; - if (any_val) - { - if (!tree_fits_shwi_p (arg1)) - return false; - HOST_WIDE_INT at_zero = tree_to_shwi (arg1); - if ((int) at_zero != at_zero) - return false; - val = at_zero; - } - else if (wi::to_wide (arg1) != val) - return false; - - /* And insert the popcount/clz/ctz builtin and cast stmt before the - cond_bb. */ - gsi = gsi_last_bb (cond_bb); - if (cast) - { - gsi_from = gsi_for_stmt (cast); - gsi_move_before (&gsi_from, &gsi); - reset_flow_sensitive_info (gimple_get_lhs (cast)); - } - gsi_from = gsi_for_stmt (call); - if (ifn == IFN_LAST - || (gimple_call_internal_p (call) && gimple_call_num_args (call) == 2)) - gsi_move_before (&gsi_from, &gsi); - else - { - /* For __builtin_c[lt]z* force .C[LT]Z ifn, because only - the latter is well defined at zero. */ - call = gimple_build_call_internal (ifn, 2, gimple_call_arg (call, 0), - build_int_cst (integer_type_node, val)); - gimple_call_set_lhs (call, lhs); - gsi_insert_before (&gsi, call, GSI_SAME_STMT); - gsi_remove (&gsi_from, true); - } - reset_flow_sensitive_info (lhs); - - /* Now update the PHI and remove unneeded bbs. */ - replace_phi_edge_with_variable (cond_bb, e2, phi, lhs); - return true; -} - /* Auxiliary functions to determine the set of memory accesses which can't trap because they are preceded by accesses to the same memory portion. We do that for MEM_REFs, so we only need to track @@ -5536,12 +5271,6 @@ pass_phiopt::execute (function *) else if (comparison_combine (bb, bb1, bb2, e1, e2, phi, arg0, arg1, diamond_p)) cfgchanged = true; - else if (!early_p - && !diamond_p - && single_pred_p (bb1) - && cond_removal_in_builtin_zero_pattern (bb, bb1, e1, e2, - phi, arg0, arg1)) - cfgchanged = true; else if (single_pred_p (bb1) && !diamond_p && spaceship_replacement (bb, bb1, e1, e2, phi, arg0, arg1)) -- 2.34.1 From ktkachov@nvidia.com Tue Nov 3 09:43:31 2026 From: ktkachov@nvidia.com (ktkachov@nvidia.com) Date: Tue, 3 Nov 2026 10:43:31 +0100 Subject: [PATCH v3 5/8] phiopt: Support more than moving 1 statement for match In-Reply-To: <20261103094334.43363-1-ktkachov@nvidia.com> References: <20261103094334.43363-1-ktkachov@nvidia.com> Message-ID: <20261103094334.43363-5-ktkachov@nvidia.com> From: Andrea Pinski [This is a repost of Andrea's patch that supersedes mine. I'm posting it here just for completeness of the series] This adds support to match_simplify_replacement to allowing of the middle-bbs to have more than 1 statement in a few cases. If we are replacing the both middle bbs with a fully independent sequence we can handle that. If we are replacing with a sequence that depends on the first statement of either (or both) blocks, this allows that. If the result is defined by part or fully of one of the middle bbs. Then make the whole bb unconditional. Note the middle bbs still need to have statements that can't trap nor have side effects. And each of the statements need to feed into the next instruction and including into the phi. And there is a limited number of stmts is allowed. Also have an allow list of expressions type to be used after the first few stmts. This allows removal of the manual matching done in cond_removal_in_builtin_zero_pattern as those have been moved to match patterns back in r14-362-gc53237cefbad0c and r14-414-g078339fc04f5de. Changes since v1: * v2: Add allow list to feeding_bb_info and add a limit to the number of stmts to consider. Adds 2 testcases based on 2 pre-existing match patterns to show what can be done. * v3: Use walk_gimple_op instead of gimple_op walk. Add check for some possible undefined code when becoming unconditional (shifts, rotates, clz/ctz); add testcases for that too. Fix allow expressions detection and calls to be better. * v4: Fix up shift undefined behavior slightly more. Note Sashiko LLM analysis is not clean because the cases it is complaining about will be rejected later on or won't show up (e.g. CLZ with a one bit argument is folded aways or a shift for one bit will also be simplified away). The code left behind in one of the middle bb is dead; the patch which was posted earlier today will fix up those dead stmts; the ICE it mentions also will never show up because simple_dce will not delete stmts that are in use still and the phi will have been changed to reference only the ones from the condition (and dominating bb) and the dominator is not updated until cfgcleanup even so messes up that analysis too. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * tree-ssa-phiopt.cc (gsi_next_nondebug_nonnop_non_predict): New function. (enum bbfeeding_info): New enum. (empty_bb_or_one_feeding_into_p): Rename to ... (feeding_bb_info): This and support few different other cases. (auto_flow_sensitive): Increase the vect base size to 4. (auto_flow_sensitive::auto_flow_sensitive(gimple*)): Split out into ... (auto_flow_sensitive::save_stmt): This. (auto_flow_sensitive::auto_flow_sensitive(basic_block)): New constructor. (match_simplify_replacement): Support More than one statement in the middle BB. * params.opt (-param=phiopt-max-feeding-stmts=): New option. * doc/params.texi (phiopt-max-feeding-stmts): Document. PR tree-optimization/127166 gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/ssa-dom-thread-16.c: Disable phiopt. * gcc.dg/tree-ssa/clamp-1.c: New test. * gcc.dg/tree-ssa/umax-sub-1.c: New test. * gcc.dg/tree-ssa/and-ctz-1.c: New test. * gcc.dg/tree-ssa/and-shift-1.c: New test. Signed-off-by: Andrea Pinski --- SUPERSEDED: this replaces v2 6/9: https://gcc.gnu.org/pipermail/gcc-patches/2026-October/735349.html It is Andrea Pinski's "[PATCH v4] phiopt: Support more than moving 1 statement for match" without changes: https://gcc.gnu.org/pipermail/gcc-patches/2026-October/736039.html 6/8 to 8/8 need it. --- gcc/doc/params.texi | 5 + gcc/params.opt | 4 + gcc/testsuite/gcc.dg/tree-ssa/and-ctz-1.c | 21 + gcc/testsuite/gcc.dg/tree-ssa/and-shift-1.c | 14 + gcc/testsuite/gcc.dg/tree-ssa/clamp-1.c | 25 ++ .../gcc.dg/tree-ssa/ssa-dom-thread-16.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/umax-sub-1.c | 14 + gcc/tree-ssa-phiopt.cc | 421 ++++++++++++++---- 8 files changed, 415 insertions(+), 91 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/and-ctz-1.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/and-shift-1.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/clamp-1.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/umax-sub-1.c diff --git a/gcc/doc/params.texi b/gcc/doc/params.texi index 090af64a7e7..b26513a7ea1 100644 --- a/gcc/doc/params.texi +++ b/gcc/doc/params.texi @@ -57,6 +57,11 @@ When factoring statements out of if/then/else, this is the maximum number of statements after the defining statement to be allowed to extend the lifetime of a name. +@paindex phiopt-max-feeding-stmts +@item phiopt-max-feeding-stmts +When deciding if a basic block is too big to phiopt, this decides the maximum +number of statements that feed into one another is too many. This excludes converts. + @paindex predictable-branch-outcome @item predictable-branch-outcome When branch is predicted to be taken with probability lower than this threshold diff --git a/gcc/params.opt b/gcc/params.opt index 29a5c7018a8..f0702f97625 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -958,6 +958,10 @@ Maximum probability of the entry BB of split region (as a percentage relative to Common Joined UInteger Var(param_phiopt_factor_max_stmts_live) Init(5) Optimization IntegerRange(0, 100) Param Maximum number of statements allowed between a defining statement and the end of the basic block before extending the live range is considered profitable. +-param=phiopt-max-feeding-stmts= +Common Joined UInteger Var(param_phiopt_max_feeding_stmts) Init(4) Optimization IntegerRange(1, 100) Param +Maximum number of statements can considered for each basic block excluding converts. + -param=predictable-branch-outcome= Common Joined UInteger Var(param_predictable_branch_outcome) Init(2) IntegerRange(0, 50) Param Optimization Maximal estimated outcome of branch considered predictable. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/and-ctz-1.c b/gcc/testsuite/gcc.dg/tree-ssa/and-ctz-1.c new file mode 100644 index 00000000000..4408addfe3a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/and-ctz-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2-details -fdump-tree-optimized" } */ + +int f(int a, int b) +{ + if (a == 0) + return 0; + return a & __builtin_ctz(b); +} + +int f1(int a, int b) +{ + if (a == 0) + return 0; + return a & __builtin_clz(b); +} + +/* Here we can't make the call to ctz/clz unconditional without undefined behavior. */ + +/* { dg-final { scan-tree-dump-not "converted to straightline code" "phiopt2" } } */ +/* { dg-final { scan-tree-dump-times "if " 2 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/and-shift-1.c b/gcc/testsuite/gcc.dg/tree-ssa/and-shift-1.c new file mode 100644 index 00000000000..f0e96e0b0d6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/and-shift-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2-details -fdump-tree-optimized" } */ + +int f(int a, int b, int c) +{ + if (a == 0) + return 0; + return a & (b >> c); +} + +/* Here we can't make the shift unconditional without undefined behavior. */ + +/* { dg-final { scan-tree-dump-not "converted to straightline code" "phiopt2" } } */ +/* { dg-final { scan-tree-dump "if " "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/clamp-1.c b/gcc/testsuite/gcc.dg/tree-ssa/clamp-1.c new file mode 100644 index 00000000000..43239772ca0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/clamp-1.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2-details -fdump-tree-optimized" } */ + +/* PR tree-optimization/127166 */ + +unsigned char clip(int x) +{ + unsigned u; + unsigned char r; + u = x; + r = x; + if (u > 255) + { + int n = -x; + int s = n >> (sizeof(int)*8 - 1); + r = s; + } + return r; +} + + +/* { dg-final { scan-tree-dump "converted to straightline code" "phiopt2" } } */ +/* { dg-final { scan-tree-dump "MAX_EXPR" "phiopt2" } } */ +/* { dg-final { scan-tree-dump "MIN_EXPR" "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not "if " "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-16.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-16.c index e8555f2d963..51b686b1de8 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-16.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-16.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-dom2-details -w --param logical-op-non-short-circuit=1 -fdisable-tree-threadfull1" } */ +/* { dg-options "-O2 -fdump-tree-dom2-details -w --param logical-op-non-short-circuit=1 -fdisable-tree-threadfull1 -fno-ssa-phiopt" } */ unsigned char validate_subreg (unsigned int offset, unsigned int isize, unsigned int osize, int zz, int qq) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/umax-sub-1.c b/gcc/testsuite/gcc.dg/tree-ssa/umax-sub-1.c new file mode 100644 index 00000000000..c07eb4154d6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/umax-sub-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2-details -fdump-tree-optimized" } */ + +signed f1 (signed x) +{ + if (x == 0) return 0; + unsigned y = x; + y -= 1; + x = y; + return x; +} + +/* { dg-final { scan-tree-dump "converted to straightline code" "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not "if " "optimized" } } */ diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 0daddb4ee2f..acc8faea635 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -56,6 +56,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-predict.h" #include "alias.h" #include "tree-ssa-threadedge.h" +#include "gimple-walk.h" /* Return the singleton PHI in the SEQ of PHIs for edges E0 and E1. */ @@ -932,6 +933,19 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt, return NULL; } +/* Like gsi_next_nondebug but also skips over NOPs and predicats. */ +static void +gsi_next_nondebug_nonnop_nonpredict (gimple_stmt_iterator *i) +{ + do + { + gsi_next_nondebug (i); + } + while (!gsi_end_p (*i) + && (gimple_code (**i) == GIMPLE_PREDICT + || gimple_code (**i) == GIMPLE_NOP)); +} + /* one_feeding_comparison_into_p returns true if BB has one comparison statement and it sets STMT to that statement. Note the comparison can be trapping too. */ @@ -996,110 +1010,191 @@ one_feeding_comparison_into_p (basic_block bb, return true; } -/* empty_bb_or_one_feeding_into_p returns true if bb was empty basic block - or it has one cheap preparation statement that feeds into the PHI - statement and it sets STMT to that statement. */ -static bool -empty_bb_or_one_feeding_into_p (basic_block bb, - gimple *phi, - gimple *&stmt) + +enum bbfeeding_info +{ + invalid_bb, + empty_bb, + one_stmt_bb, + feeding_bb +}; + +/* This returns empty_bb if bb was empty basic block. + or returns one_stmt_bb if it has one cheap preparation + statement that feeds into the PHI statement and it sets + STMT to that statement. Returns feeding_bb if the + basic block is not empty but has a sequence of statements + feeding into the phi that has no side effects. */ +static bbfeeding_info +feeding_bb_info (basic_block bb, gimple *phi, gimple *&stmt) { stmt = nullptr; gimple *stmt_to_move = nullptr; tree lhs; if (empty_block_p (bb)) - return true; + return empty_bb; if (!single_pred_p (bb)) - return false; + return invalid_bb; /* The middle bb cannot have phi nodes as we don't move those assignments yet. */ if (!gimple_seq_empty_p (phi_nodes (bb))) - return false; + return invalid_bb; gimple_stmt_iterator gsi; gsi = gsi_start_nondebug_after_labels_bb (bb); + int stmts = 0; + int stmts_minus_convert = 0; + bool non_allowed_stmt = false; + bool had_undefined_stmt = false; + bool has_call = false; while (!gsi_end_p (gsi)) { - gimple *s = gsi_stmt (gsi); - gsi_next_nondebug (&gsi); - /* Skip over Predict and nop statements. */ + gimple *s = *gsi; + gsi_next_nondebug_nonnop_nonpredict (&gsi); + // Skip over predict and nop statements which could happen + // if they are at the beginging. if (gimple_code (s) == GIMPLE_PREDICT || gimple_code (s) == GIMPLE_NOP) continue; - /* If there is more one statement return false. */ - if (stmt_to_move) - return false; - stmt_to_move = s; - } - - /* The only statement here was a Predict or a nop statement - so return true. */ - if (!stmt_to_move) - return true; - - if (gimple_vuse (stmt_to_move)) - return false; - - if (gimple_could_trap_p (stmt_to_move) - || gimple_has_side_effects (stmt_to_move)) - return false; - - ssa_op_iter it; - tree use; - FOR_EACH_SSA_TREE_OPERAND (use, stmt_to_move, it, SSA_OP_USE) - if (ssa_name_maybe_undef_p (use)) - return false; - - /* Allow assignments but allow some builtin/internal calls. - As const calls don't match any of the above, yet they could - still have some side-effects - they could contain - gimple_could_trap_p statements, like floating point - exceptions or integer division by zero. See PR70586. - FIXME: perhaps gimple_has_side_effects or gimple_could_trap_p - should handle this. - Allow some known builtin/internal calls that are known not to - trap: logical functions (e.g. bswap and bit counting). */ - if (!is_gimple_assign (stmt_to_move)) - { - if (!is_gimple_call (stmt_to_move)) - return false; - combined_fn cfn = gimple_call_combined_fn (stmt_to_move); - switch (cfn) + stmts++; + stmts_minus_convert++; + if (stmts_minus_convert > param_phiopt_max_feeding_stmts) + return invalid_bb; + if (gimple_vuse (s)) + return invalid_bb; + if (gimple_could_trap_p (s) + || gimple_has_side_effects (s)) + return invalid_bb; + ssa_op_iter it; + tree use; + FOR_EACH_SSA_TREE_OPERAND (use, s, it, SSA_OP_USE) + if (ssa_name_maybe_undef_p (use)) + return invalid_bb; + + /* Allow some assignments but allow some builtin/internal calls. + As const calls don't match any of the above, yet they could + still have some side-effects - they could contain + gimple_could_trap_p statements, like floating point + exceptions or integer division by zero. See PR70586. + FIXME: perhaps gimple_has_side_effects or gimple_could_trap_p + should handle this. + Allow some known builtin/internal calls that are known not to + trap: logical functions (e.g. bswap and bit counting). */ + if (!is_gimple_assign (s)) { - default: - return false; - CASE_CFN_BSWAP: - CASE_CFN_BITREVERSE: - CASE_CFN_FFS: - CASE_CFN_PARITY: - CASE_CFN_POPCOUNT: - CASE_CFN_CLZ: - CASE_CFN_CTZ: - case CFN_BUILT_IN_CLRSB: - case CFN_BUILT_IN_CLRSBL: - case CFN_BUILT_IN_CLRSBLL: - lhs = gimple_call_lhs (stmt_to_move); - break; + if (!is_gimple_call (s)) + return invalid_bb; + combined_fn cfn = gimple_call_combined_fn (s); + switch (cfn) + { + default: + return invalid_bb; + CASE_CFN_CLZ: + CASE_CFN_CTZ: + if (gimple_call_num_args (s) != 2) + had_undefined_stmt = true; + // FALLTHRU + case CFN_BUILT_IN_CLRSB: + case CFN_BUILT_IN_CLRSBL: + case CFN_BUILT_IN_CLRSBLL: + CASE_CFN_BSWAP: + CASE_CFN_BITREVERSE: + CASE_CFN_FFS: + CASE_CFN_PARITY: + CASE_CFN_POPCOUNT: + lhs = gimple_call_lhs (s); + // A call can after some stmts but not with a non allowed one + // or another call. + if (non_allowed_stmt || has_call) + return invalid_bb; + has_call = true; + break; + } } + else + { + lhs = gimple_assign_lhs (s); + // Only allow a few different for the feeding list. + switch (gimple_assign_rhs_code (s)) + { + // Always allow a convert. + CASE_CONVERT: + stmts_minus_convert --; + break; + case PLUS_EXPR: + case MINUS_EXPR: + case ABS_EXPR: + case ABSU_EXPR: + case BIT_IOR_EXPR: + case BIT_XOR_EXPR: + case BIT_AND_EXPR: + case MIN_EXPR: + case MAX_EXPR: + case NEGATE_EXPR: + break; + // Shifts with a (positive) constant shifter are on the allow list. + // Shifters which are above the precision are not well defined, so + // that is undefined stmt. + case LSHIFT_EXPR: + case RSHIFT_EXPR: + if (TREE_CODE (gimple_assign_rhs2 (s)) == INTEGER_CST + && wi::ltu_p (wi::to_wide (gimple_assign_rhs2 (s)), + element_precision (TREE_TYPE (lhs)))) + break; + // Don't allow non-const shifters as they will cause + // undefined behavior + had_undefined_stmt = true; + break; + case LROTATE_EXPR: + case RROTATE_EXPR: + had_undefined_stmt = true; + // FALLTHRU + default: + // Allow all kind of expressions after the first + // convert but not with other stmts before hand. + if (stmts_minus_convert > 1 && non_allowed_stmt) + return invalid_bb; + if (has_call) + return invalid_bb; + non_allowed_stmt = true; + break; + } + } + + gimple *use_stmt; + use_operand_p use_p; + + /* Allow only a statement which feeds into the next stmt + or the phi (when last statement). */ + if (!lhs || TREE_CODE (lhs) != SSA_NAME + || !single_imm_use (lhs, &use_p, &use_stmt) + || use_stmt != (gsi_end_p (gsi) ? phi : *gsi )) + return invalid_bb; + if (!stmt_to_move) + stmt_to_move = s; } - else - lhs = gimple_assign_lhs (stmt_to_move); - gimple *use_stmt; - use_operand_p use_p; + // CLZ/CTZ is undefined at 0 (or a shift with a non constant) + // so if other stmts besides converts moving it will cause + // undefined behavior. + if (had_undefined_stmt && stmts_minus_convert != 1) + return invalid_bb; - /* Allow only a statement which feeds into the other stmt. */ - if (!lhs || TREE_CODE (lhs) != SSA_NAME - || !single_imm_use (lhs, &use_p, &use_stmt) - || use_stmt != phi) - return false; + // If there are any questionable stmts, make sure there are only + // that one (and possible converts). + if (stmts_minus_convert != 1 && non_allowed_stmt) + return invalid_bb; + /* The only statement here was a Predict or a nop statement + so return 1. */ + if (stmts == 0) + return empty_bb; stmt = stmt_to_move; - return true; + return stmts > 1 ? feeding_bb : one_stmt_bb; } /* Move STMT to before GSI and insert its defining @@ -1131,14 +1226,17 @@ move_stmt (gimple *stmt, gimple_stmt_iterator *gsi, auto_bitmap &inserted_exprs) } /* RAII style class to temporarily remove flow sensitive - from ssa names defined by a gimple statement. */ + from ssa names defined by a gimple statement or + a whole Basic block. */ class auto_flow_sensitive { public: auto_flow_sensitive (gimple *s); + auto_flow_sensitive (basic_block bb); ~auto_flow_sensitive (); private: - auto_vec, 2> stack; + auto_vec, 4> stack; + void save_stmt (gimple *s); }; /* Constructor for auto_flow_sensitive. Saves @@ -1150,6 +1248,15 @@ auto_flow_sensitive::auto_flow_sensitive (gimple *s) { if (!s) return; + save_stmt (s); +} + +/* Saves off the ssa names' flow sensitive information + that was defined by gimple statement S and + resets it to be non-flow based ones. */ +void +auto_flow_sensitive::save_stmt (gimple *s) +{ ssa_op_iter it; tree def; FOR_EACH_SSA_TREE_OPERAND (def, s, it, SSA_OP_DEF) @@ -1160,6 +1267,21 @@ auto_flow_sensitive::auto_flow_sensitive (gimple *s) } } +/* Constructor for auto_flow_sensitive. Saves + off the ssa names' flow sensitive information + that was defined in the BB and + resets it to be non-flow based ones. */ + +auto_flow_sensitive::auto_flow_sensitive (basic_block bb) +{ + if (!bb) + return; + gimple_stmt_iterator gsi; + gsi = gsi_start_nondebug_after_labels_bb (bb); + for (; !gsi_end_p (gsi); gsi_next_nondebug (&gsi)) + save_stmt (*gsi); +} + /* Deconstructor, restores the flow sensitive information for the SSA names that had been saved off. */ @@ -1218,14 +1340,20 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, /* If the basic block only has a cheap preparation statement, allow it and move it once the transformation is done. */ - if (!empty_bb_or_one_feeding_into_p (middle_bb, phi, stmt_to_move)) + bbfeeding_info middle_bb_info = feeding_bb_info (middle_bb, + phi, stmt_to_move); + if (middle_bb_info == invalid_bb) return false; + bbfeeding_info middle_bb_alt_info = invalid_bb; if (threeway_p - && middle_bb != middle_bb_alt - && !empty_bb_or_one_feeding_into_p (middle_bb_alt, phi, - stmt_to_move_alt)) - return false; + && middle_bb != middle_bb_alt) + { + middle_bb_alt_info = feeding_bb_info (middle_bb_alt, phi, + stmt_to_move_alt); + if (middle_bb_alt_info == invalid_bb) + return false; + } /* Do not make conditional undefs unconditional. */ if ((TREE_CODE (arg0) == SSA_NAME @@ -1275,12 +1403,15 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, tree type = TREE_TYPE (gimple_phi_result (phi)); { - auto_flow_sensitive s1(stmt_to_move); - auto_flow_sensitive s_alt(stmt_to_move_alt); + auto_flow_sensitive s1(middle_bb); + basic_block other_bb = nullptr; + if (middle_bb_alt_info >= one_stmt_bb) + other_bb = middle_bb_alt; + auto_flow_sensitive s_alt(other_bb); result = gimple_simplify_phiopt (early_p, type, stmt, arg_true, arg_false, - &seq); + &seq); } /* For early phiopt, we don't want to lose user generated predictors @@ -1320,7 +1451,8 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, semantics (that's not IEEE max semantics). */ if (!HONOR_NANS (type) && !HONOR_SIGNED_ZEROS (type)) return false; - if (stmt_to_move || stmt_to_move_alt) + if (middle_bb_info >= one_stmt_bb + || middle_bb_alt_info >= one_stmt_bb) return false; tree_code cmp = gimple_cond_code (stmt); if (cmp != LT_EXPR && cmp != LE_EXPR @@ -1342,11 +1474,120 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, statistics_counter_event (cfun, "Non-IEEE FP MIN/MAX PHI replacement", 1); } - if (dump_file && (dump_flags & TDF_FOLDING)) - fprintf (dump_file, "accepted the phiopt match-simplify.\n"); auto_bitmap exprs_maybe_dce; + /* One of the middle BBs had more than one statements. */ + if (middle_bb_info == feeding_bb + || middle_bb_alt_info == feeding_bb) + { + gimple_stmt_iterator gsi = gsi_start (seq); + bool ok = true; + walk_stmt_info wi = {}; + struct op_info { + gimple *stmt_to_move; + gimple *stmt_to_move_alt; + basic_block middle_bb; + basic_block middle_bb_alt; + bbfeeding_info middle_bb_info; + bbfeeding_info middle_bb_alt_info; + } info = { stmt_to_move, stmt_to_move_alt, + middle_bb, middle_bb_alt, + middle_bb_info, middle_bb_alt_info }; + wi.info = &info; + /* Check to see if any of the new sequence uses the definitions + from the middle bbs. */ + for (gsi = gsi_start (seq); !gsi_end_p (gsi); gsi_next (&gsi)) + { + tree use; + use = walk_gimple_op (*gsi, + [](tree *tp, int *, void *data) -> tree + { + walk_stmt_info *wi = (walk_stmt_info*)data; + op_info *info = (op_info *)wi->info; + tree use = *tp; + if (!use || TREE_CODE (use) != SSA_NAME) + return NULL_TREE; + gimple *us = SSA_NAME_DEF_STMT (use); + if (!us) + return NULL_TREE; + if (us == info->stmt_to_move + || us == info->stmt_to_move_alt) + return NULL_TREE; + basic_block use_bb = gimple_bb (us); + // If an operand is defined from the middle bb + // where there was more one statement, reject it. + if ((info->middle_bb_info == feeding_bb + && use_bb == info->middle_bb) + || (info->middle_bb_alt_info == feeding_bb + && use_bb == info->middle_bb_alt)) + return use; + return NULL_TREE; + }, &wi); + if (use) + { + ok = false; + break; + } + } + if (!ok) + { + gimple_seq_discard (seq); + if (dump_file && (dump_flags & TDF_FOLDING)) + fprintf (dump_file, "rejected the phiopt match-simplify for having more stmts.\n"); + return false; + } + statistics_counter_event (cfun, "unconditionalized one middle bb phiopt", + 1); + // If the result is the one of the arguments or a partial + // defined in the middle bb, then make those statements unconditional. + if (TREE_CODE (result) == SSA_NAME + && (middle_bb_info == feeding_bb + || middle_bb_alt_info == feeding_bb)) + { + gimple *us = SSA_NAME_DEF_STMT (result); + if (us && ((middle_bb_info == feeding_bb + && gimple_bb (us) == middle_bb) + || (middle_bb_alt_info == feeding_bb + && gimple_bb (us) == middle_bb_alt))) + { + gimple_stmt_iterator middle_gsi; + basic_block use_bb = gimple_bb (us); + middle_gsi = gsi_start_nondebug_after_labels_bb (use_bb); + + // Move the statements one at a time until reach the last + // statement or the statement that is referenced from the result. + while (!gsi_end_p (middle_gsi)) + { + // Skip over nop or predicates + // Also don't move debug statements + if (gimple_code (*middle_gsi) == GIMPLE_NOP + || gimple_code (*middle_gsi) == GIMPLE_PREDICT) + { + gsi_next_nondebug_nonnop_nonpredict (&middle_gsi); + continue; + } + gsi = gsi_last_bb (cond_bb); + gimple *s = *middle_gsi; + move_stmt (s, &gsi, exprs_maybe_dce); + + // Reached the last statement that is refenced, + // all the rest would be DCEd anyways. + if (s == us) + break; + middle_gsi = gsi_start_nondebug_after_labels_bb (use_bb); + } + stmt_to_move = nullptr; + stmt_to_move_alt = nullptr; + statistics_counter_event (cfun, "unconditionalized partial middle bb phiopt", + 1); + } + } + } + + if (dump_file && (dump_flags & TDF_FOLDING)) + fprintf (dump_file, "accepted the phiopt match-simplify.\n"); + /* Mark the cond statements' lhs/rhs as maybe dce. */ if (TREE_CODE (gimple_cond_lhs (stmt)) == SSA_NAME && !SSA_NAME_IS_DEFAULT_DEF (gimple_cond_lhs (stmt))) @@ -1372,7 +1613,7 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, gsi_insert_seq_before (&gsi, seq, GSI_CONTINUE_LINKING); } - /* If there was a statement to move, move it to right before + /* If there was one statement to move, move it to right before the original conditional. */ move_stmt (stmt_to_move, &gsi, exprs_maybe_dce); move_stmt (stmt_to_move_alt, &gsi, exprs_maybe_dce); -- 2.34.1 From ktkachov@nvidia.com Tue Nov 3 09:43:33 2026 From: ktkachov@nvidia.com (ktkachov@nvidia.com) Date: Tue, 3 Nov 2026 10:43:33 +0100 Subject: [PATCH v3 7/8] match.pd: Combine split double-word clz and ctz [PR126035] In-Reply-To: <20261103094334.43363-1-ktkachov@nvidia.com> References: <20261103094334.43363-1-ktkachov@nvidia.com> Message-ID: <20261103094334.43363-7-ktkachov@nvidia.com> From: Kyrylo Tkachov Counts of trailing and leading zeros of a double-word X are often computed from its halves LO and HI: LO != 0 ? ctz (LO) : 32 + ctz (HI) HI != 0 ? clz (HI) : 32 + clz (LO) GCC keeps the branch and the two narrow counts, although one count of X gives the same result for a nonzero X. On aarch64 unsigned ctz64_split (uint64_t val) { uint32_t hi = val >> 32, lo = val; return lo ? __builtin_ctz (lo) : 32u + __builtin_ctz (hi); } compiles to eight instructions with two rbit and clz pairs and a csel. Add a match.pd pattern for the COND_EXPR that phiopt builds for the PHI. The halves are (N) X and (N) (X >> W), the test can also be X & (2^W - 1) or X >> W, and the counts can be converted. The counts of the halves are undefined at zero, so a one-argument .CTZ or .CLZ of X replaces them. phiopt removes both arms, although they have several statements: _1 = val_6(D) >> 32; hi_7 = (uint32_t) _1; lo_8 = (uint32_t) val_6(D); if (lo_8 != 0) goto ; else goto ; : _2 = __builtin_ctz (lo_8); _10 = (unsigned int) _2; goto ; : _3 = __builtin_ctz (hi_7); _4 = (unsigned int) _3; _9 = _4 + 32; : # _5 = PHI <_9(4), _10(3)> becomes _12 = .CTZ (val_6(D)); _13 = (unsigned int) _12; which is rbit and clz on aarch64. Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux. Cc: Andrea Pinski gcc/ChangeLog: PR tree-optimization/126035 * match.pd (double_word_low, double_word_high) (double_word_low_test, double_word_high_test, ctz_count) (clz_count): New predicates. (LO != 0 ? ctz (LO) : W + ctz (HI) -> ctz (X)): New pattern. (HI != 0 ? clz (HI) : W + clz (LO) -> clz (X)): Likewise. gcc/testsuite/ChangeLog: PR tree-optimization/126035 * gcc.dg/torture/pr126035-1.c: New test. * gcc.dg/torture/pr126035-2.c: New test. * gcc.dg/tree-ssa/pr126035-1.c: New test. * gcc.dg/tree-ssa/pr126035-2.c: New test. * gcc.dg/tree-ssa/pr126035-4.c: New test. * gcc.target/aarch64/pr126035-1.c: New test. Signed-off-by: Kyrylo Tkachov --- v2 (patch 8/9): https://gcc.gnu.org/pipermail/gcc-patches/2026-October/735350.html v1 (patch 13/14): https://gcc.gnu.org/pipermail/gcc-patches/2026-October/734428.html This needs 5/8, Andrea Pinski's phiopt patch: https://gcc.gnu.org/pipermail/gcc-patches/2026-October/736039.html Changes from v2 (Andrea Pinski): - Do not change phiopt_early_allow. Remove gcc.dg/tree-ssa/pr126035-3.c, which needs it, and scan phiopt2 in gcc.dg/tree-ssa/pr126035-4.c. - Use wi::to_wide, unsigned_type_for and the precision of X in the conditions. - Rename ctz_nonzero and clz_nonzero to ctz_count and clz_count. --- gcc/match.pd | 63 ++++++++ gcc/testsuite/gcc.dg/torture/pr126035-1.c | 142 ++++++++++++++++++ gcc/testsuite/gcc.dg/torture/pr126035-2.c | 12 ++ gcc/testsuite/gcc.dg/tree-ssa/pr126035-1.c | 89 +++++++++++ gcc/testsuite/gcc.dg/tree-ssa/pr126035-2.c | 69 +++++++++ gcc/testsuite/gcc.dg/tree-ssa/pr126035-4.c | 31 ++++ gcc/testsuite/gcc.target/aarch64/pr126035-1.c | 48 ++++++ 7 files changed, 454 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr126035-1.c create mode 100644 gcc/testsuite/gcc.dg/torture/pr126035-2.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr126035-1.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr126035-2.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr126035-4.c create mode 100644 gcc/testsuite/gcc.target/aarch64/pr126035-1.c diff --git a/gcc/match.pd b/gcc/match.pd index 46ad2a2e174..51cea4f6377 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -11923,6 +11923,69 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) } (if (ifn == IFN_CTZ && tree_int_cst_equal (@2, uniform_integer_cst_p (@4))) (IFN_CTZ @3 @2))))) + +/* The low half (N) @0 and the high half (N) (@0 >> W) of a double-word + integer @0, where N has precision W, half the precision of @0. */ +(match (double_word_low @0) + (convert @0) + (if (INTEGRAL_TYPE_P (type) + && INTEGRAL_TYPE_P (TREE_TYPE (@0)) + && TYPE_PRECISION (TREE_TYPE (@0)) == 2 * TYPE_PRECISION (type)))) +(match (double_word_high @0) + (convert (rshift (nop_convert? @0) INTEGER_CST@1)) + (if (INTEGRAL_TYPE_P (type) + && INTEGRAL_TYPE_P (TREE_TYPE (@0)) + && TYPE_PRECISION (TREE_TYPE (@0)) == 2 * TYPE_PRECISION (type) + && wi::to_wide (@1) == TYPE_PRECISION (type)))) + +/* A value that is zero exactly when the low half of the double-word + integer @0 is zero: the low half or @0 & (2^W - 1). */ +(match (double_word_low_test @0) + (convert @0) + (if (INTEGRAL_TYPE_P (type) + && INTEGRAL_TYPE_P (TREE_TYPE (@0)) + && TYPE_PRECISION (TREE_TYPE (@0)) == 2 * TYPE_PRECISION (type)))) +(match (double_word_low_test @0) + (bit_and @0 INTEGER_CST@1) + (if (INTEGRAL_TYPE_P (type) + && wi::to_wide (@1) == wi::mask (TYPE_PRECISION (type) / 2, false, + TYPE_PRECISION (type))))) + +/* A value that is zero exactly when the high half of the double-word + integer @0 is zero: @0 >> W, possibly converted to W or more bits. */ +(match (double_word_high_test @0) + (convert1? (rshift (nop_convert? @0) INTEGER_CST@1)) + (if (INTEGRAL_TYPE_P (type) + && INTEGRAL_TYPE_P (TREE_TYPE (@0)) + && wi::to_wide (@1) == TYPE_PRECISION (TREE_TYPE (@0)) / 2 + && 2 * TYPE_PRECISION (type) >= TYPE_PRECISION (TREE_TYPE (@0))))) + +/* Counts of the trailing and leading zeros of @0, with any value for a + zero @0. */ +(match (ctz_count @0) + (CTZ @0)) +(match (clz_count @0) + (CLZ @0)) + +/* LO != 0 ? ctz (LO) : W + ctz (HI) is ctz (X) for a nonzero X, where LO + and HI are the low and high halves of the double-word integer X and W + is their precision. Likewise HI != 0 ? clz (HI) : W + clz (LO) is + clz (X). */ +(for cnt (ctz_count clz_count) + tst (double_word_low_test double_word_high_test) + nzh (double_word_low double_word_high) + zh (double_word_high double_word_low) + ifn (IFN_CTZ IFN_CLZ) + (simplify + (cond (ne (tst @0) integer_zerop) + (convert1? (cnt (nzh @0))) + (plus (convert? (cnt (zh @0))) INTEGER_CST@2)) + (with { tree utype = unsigned_type_for (TREE_TYPE (@0)); } + (if (type_has_mode_precision_p (utype) + && wi::to_wide (@2) == TYPE_PRECISION (utype) / 2 + && direct_internal_fn_supported_p (as_internal_fn (ifn), utype, + OPTIMIZE_FOR_BOTH)) + (convert (ifn:integer_type_node (convert:utype @0))))))) #endif /* Common POPCOUNT/PARITY simplifications. */ diff --git a/gcc/testsuite/gcc.dg/torture/pr126035-1.c b/gcc/testsuite/gcc.dg/torture/pr126035-1.c new file mode 100644 index 00000000000..378403e9bfb --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr126035-1.c @@ -0,0 +1,142 @@ +/* PR tree-optimization/126035 */ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +/* Check the combined counts of a double-word value against the + double-word builtins, and that near misses keep their own value. */ + +typedef __UINT64_TYPE__ U64; +typedef __UINT32_TYPE__ U32; +typedef __INT64_TYPE__ S64; + +#define N __attribute__((noipa)) + +N unsigned +ctz1 (U64 x) +{ + U32 lo = x, hi = x >> 32; + return lo ? __builtin_ctz (lo) : 32 + __builtin_ctz (hi); +} + +N int +ctz2 (S64 x) +{ + int lo = x, hi = (U64) x >> 32; + return lo ? __builtin_ctz (lo) : 32 | __builtin_ctz (hi); +} + +N unsigned char +ctz3 (U64 x) +{ + return ((x & 0xffffffff) ? (unsigned char) __builtin_ctz ((U32) x) + : (unsigned char) (32 + __builtin_ctz ((U32) (x >> 32)))); +} + +/* A named intermediate: with -g its debug bind is at the merge. */ +N unsigned +ctz4 (U64 x) +{ + U32 lo = x, hi = x >> 32; + unsigned r; + if (lo) + r = __builtin_ctz (lo); + else + r = 32 + __builtin_ctz (hi); + return r; +} + +N unsigned +clz1 (U64 x) +{ + U32 lo = x, hi = x >> 32; + return hi ? __builtin_clz (hi) : 32 + __builtin_clz (lo); +} + +N long +clz2 (S64 x) +{ + if ((x >> 32) == 0) + return 32 + __builtin_clz ((U32) x); + return __builtin_clz ((U32) (x >> 32)); +} + +/* A third path into the merge keeps its value. */ +N unsigned +extra (U64 x, int c, unsigned other) +{ + unsigned r; + U32 lo = x, hi = x >> 32; + if (c) + { + r = other; + goto out; + } + if (lo) + r = __builtin_ctz (lo); + else + r = 32 + __builtin_ctz (hi); + out: + return r; +} + +/* The count of the high half is truncated by a narrow signed + intermediate before the offset is added. */ +struct S { signed int c : 4; }; + +N unsigned +narrow (U64 x) +{ + struct S s; + U32 lo = x, hi = x >> 32; + unsigned r; + if (lo) + r = __builtin_ctz (lo); + else + { + s.c = __builtin_ctz (hi); + r = s.c + 32; + } + return r; +} + +/* Wrong offset. */ +N unsigned +wrong (U64 x) +{ + U32 lo = x, hi = x >> 32; + return lo ? __builtin_ctz (lo) : 31 + __builtin_ctz (hi); +} + +int +main (void) +{ + U64 v = 0x9E3779B97F4A7C15ULL; + for (int i = 0; i < 100000; i++) + { + v = v * 6364136223846793005ULL + 1442695040888963407ULL; + U64 x = v; + switch (i & 7) + { + case 0: x = 1ULL << (v % 64); break; + case 1: x = (U32) v; break; + case 2: x = ((U64) (U32) v) << 32; break; + case 3: x = ~0ULL; break; + default: break; + } + if (x == 0) + x = 1; + unsigned t = __builtin_ctzll (x), l = __builtin_clzll (x); + if (ctz1 (x) != t || ctz2 (x) != (int) t || ctz3 (x) != t + || ctz4 (x) != t || clz1 (x) != l || clz2 (x) != l + || extra (x, 0, 77) != t) + __builtin_abort (); + if ((U32) x == 0 && wrong (x) != t - 1) + __builtin_abort (); + } + if (extra (4, 1, 77) != 77) + __builtin_abort (); + /* ctz (hi) == 20 is truncated to 4 in the 4-bit field: 36, not 52. */ + if (narrow (1ULL << 52) != 36) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr126035-2.c b/gcc/testsuite/gcc.dg/torture/pr126035-2.c new file mode 100644 index 00000000000..1e0d34d3655 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr126035-2.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/126035 */ +/* { dg-do compile { target bitint65535 } } */ +/* { dg-options "-std=c23" } */ + +/* The double-word value is wider than any mode with a count. */ + +int +f (unsigned _BitInt(1024) x) +{ + unsigned _BitInt(512) lo = x, hi = x >> 512; + return lo ? __builtin_ctzg (lo) : 512 + __builtin_ctzg (hi); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr126035-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr126035-1.c new file mode 100644 index 00000000000..0177e57089f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr126035-1.c @@ -0,0 +1,89 @@ +/* PR tree-optimization/126035 */ +/* { dg-do compile { target aarch64*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +/* Counts of trailing and leading zeros of a double-word value that are + computed from its halves are combined into one count. */ + +typedef __UINT64_TYPE__ U64; +typedef __UINT32_TYPE__ U32; +typedef __INT64_TYPE__ S64; + +unsigned +ctz1 (U64 x) +{ + U32 lo = x, hi = x >> 32; + return lo ? __builtin_ctz (lo) : 32 + __builtin_ctz (hi); +} + +unsigned +ctz2 (U64 x) +{ + U32 lo = x, hi = x >> 32; + if (lo == 0) + return 32 + __builtin_ctz (hi); + return __builtin_ctz (lo); +} + +unsigned +ctz3 (U64 x) +{ + return ((x & 0xffffffff) ? __builtin_ctz ((U32) x) + : 32 + __builtin_ctz ((U32) (x >> 32))); +} + +int +ctz4 (S64 x) +{ + int lo = x, hi = x >> 32; + return lo ? __builtin_ctz (lo) : 32 + __builtin_ctz (hi); +} + +unsigned long long +ctz5 (U64 x) +{ + U32 lo = x, hi = x >> 32; + return (lo ? (unsigned long long) __builtin_ctz (lo) + : 32 + (unsigned long long) __builtin_ctz (hi)); +} + +int +ctz6 (S64 x) +{ + U32 lo = x, hi = (U64) x >> 32; + return lo ? __builtin_ctz (lo) : 32 + __builtin_ctz (hi); +} + +unsigned +clz1 (U64 x) +{ + U32 lo = x, hi = x >> 32; + return hi ? __builtin_clz (hi) : 32 + __builtin_clz (lo); +} + +unsigned +clz2 (U64 x) +{ + if ((x >> 32) == 0) + return 32 + __builtin_clz ((U32) x); + return __builtin_clz ((U32) (x >> 32)); +} + +int +clz3 (S64 x) +{ + int lo = x, hi = x >> 32; + return hi ? __builtin_clz (hi) : 32 + __builtin_clz (lo); +} + +int +clz4 (S64 x) +{ + U32 lo = x, hi = (U64) x >> 32; + return hi ? __builtin_clz (hi) : 32 + __builtin_clz (lo); +} + +/* { dg-final { scan-tree-dump-not "__builtin_c\[lt\]z " "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\\.CTZ \\(" 6 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\\.CLZ \\(" 4 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr126035-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr126035-2.c new file mode 100644 index 00000000000..f76342cfbbc --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr126035-2.c @@ -0,0 +1,69 @@ +/* PR tree-optimization/126035 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +/* Forms that do not compute the count of a double-word value must not be + combined. */ + +typedef __UINT64_TYPE__ U64; +typedef __UINT32_TYPE__ U32; + +/* Wrong offset. */ +unsigned +f1 (U64 x) +{ + U32 lo = x, hi = x >> 32; + return lo ? __builtin_ctz (lo) : 31 + __builtin_ctz (hi); +} + +/* The condition tests the wrong half. */ +unsigned +f2 (U64 x) +{ + U32 lo = x, hi = x >> 32; + return hi ? __builtin_ctz (lo) : 32 + __builtin_ctz (hi); +} + +/* The condition tests only part of the high half. */ +unsigned +f3 (U64 x) +{ + unsigned char t = x >> 32; + return t ? __builtin_clz ((U32) (x >> 32)) : 32 + __builtin_clz ((U32) x); +} + +/* The count of the high half wraps around. */ +unsigned +f4 (U64 x) +{ + U32 lo = x, hi = x >> 32; + return lo ? __builtin_ctz (lo) : (32 + __builtin_ctz (hi)) & 31; +} + +/* The IOR overlaps the count. */ +unsigned +f5 (U64 x) +{ + U32 lo = x, hi = x >> 32; + return lo ? __builtin_ctz (lo) : 16 | __builtin_ctz (hi); +} + +/* The high half is narrower than half of X. */ +unsigned +f6 (U64 x) +{ + U32 lo = x; + unsigned short hi = x >> 32; + return lo ? __builtin_ctz (lo) : 32 + __builtin_ctz (hi); +} + +/* Counts of leading zeros of the halves in the order of ctz. */ +unsigned +f7 (U64 x) +{ + U32 lo = x, hi = x >> 32; + return lo ? __builtin_clz (lo) : 32 + __builtin_clz (hi); +} + +/* { dg-final { scan-tree-dump-not "\\.CTZ \\(" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "\\.CLZ \\(" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr126035-4.c b/gcc/testsuite/gcc.dg/tree-ssa/pr126035-4.c new file mode 100644 index 00000000000..1309f9e06a2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr126035-4.c @@ -0,0 +1,31 @@ +/* PR tree-optimization/126035 */ +/* { dg-do compile { target aarch64*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -g -fdump-tree-phiopt2" } */ + +/* Both arms of the diamond are removed. WHICH gets 111 or HI after the + condition, depending on LO. */ + +typedef __UINT64_TYPE__ U64; +typedef __UINT32_TYPE__ U32; + +unsigned +f (U64 x) +{ + U32 lo = x, hi = x >> 32; + unsigned which, r; + if (lo != 0) + { + which = 111; + r = __builtin_ctz (lo); + } + else + { + which = hi; + r = 32 + __builtin_ctz (hi); + } + return r; +} + +/* { dg-final { scan-tree-dump "\\.CTZ \\(" "phiopt2" } } */ +/* { dg-final { scan-tree-dump {which => [^\n]* != 0 \? 111 : } "phiopt2" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/pr126035-1.c b/gcc/testsuite/gcc.target/aarch64/pr126035-1.c new file mode 100644 index 00000000000..c138d554df3 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr126035-1.c @@ -0,0 +1,48 @@ +/* PR tree-optimization/126035 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#pragma GCC target "+nocssc" + +typedef __UINT64_TYPE__ uint64_t; +typedef __UINT32_TYPE__ uint32_t; + +static inline unsigned +ctz32 (uint32_t v) +{ + return __builtin_ctz (v); +} + +static inline unsigned +clz32 (uint32_t v) +{ + return __builtin_clz (v); +} + +unsigned +ctz64_split (uint64_t val) +{ + uint32_t hi = (uint32_t) (val >> 32); + uint32_t lo = (uint32_t) val; + return lo ? ctz32 (lo) : 32u + ctz32 (hi); +} + +unsigned +clz64_split (uint64_t val) +{ + uint32_t hi = (uint32_t) (val >> 32); + uint32_t lo = (uint32_t) val; + return hi ? clz32 (hi) : 32u + clz32 (lo); +} + +const unsigned char * +match_extend (const unsigned char *p, uint64_t x) +{ + return p + (ctz64_split (x) >> 3); +} + +/* One double-word rbit + clz for each ctz and one clz for the clz, with + no conditional select. */ +/* { dg-final { scan-assembler-not {\tcsel\t} } } */ +/* { dg-final { scan-assembler-times {\trbit\tx[0-9]+, x[0-9]+} 2 } } */ +/* { dg-final { scan-assembler-times {\tclz\tx[0-9]+, x[0-9]+} 3 } } */ -- 2.34.1 From ktkachov@nvidia.com Tue Nov 3 09:43:34 2026 From: ktkachov@nvidia.com (ktkachov@nvidia.com) Date: Tue, 3 Nov 2026 10:43:34 +0100 Subject: [PATCH v3 8/8] match.pd: Combine split clz and ctz that are defined at zero [PR126035] In-Reply-To: <20261103094334.43363-1-ktkachov@nvidia.com> References: <20261103094334.43363-1-ktkachov@nvidia.com> Message-ID: <20261103094334.43363-8-ktkachov@nvidia.com> From: Kyrylo Tkachov The zstd sources in SPEC2026 compute 64-bit counts with the split idiom on top of 32-bit table based counts: unsigned ZSTD_countTrailingZeros64 (U64 val) { U32 msw = val >> 32, lsw = val; if (lsw == 0) return 32 + ZSTD_countTrailingZeros32 (msw); return ZSTD_countTrailingZeros32 (lsw); } forwprop turns each table lookup into a count that is defined at zero: a two-argument .CTZ or .CLZ, followed by a mask or a select when the table value for zero differs from the value of the target. If the target does not define a value at zero, the select is on a one-argument count, after the fix for PR127853. On aarch64 phiopt sees _1 = val_5(D) >> 32; msw_6 = (U32) _1; lsw_7 = (U32) val_5(D); if (lsw_7 == 0) goto ; else goto ; : _9 = .CTZ (msw_6, 32); _11 = _9 & 31; _13 = (unsigned int) _11; _12 = _13 + 32; goto ; : _14 = .CTZ (lsw_7, 32); _16 = (unsigned int) _14; : # _3 = PHI <_12(3), _16(4)> Accept these forms of the counts. The select can also test X >> W, which is what match.pd makes of a test of the high half. For a zero X the idiom gives W plus the value at zero of the count in the second arm, so keep that value with a select: _15 = val_5(D) != 0; _4 = .CTZ (val_5(D)); _10 = _15 ? _4 : 32; _18 = (unsigned int) _10; match.pd turns the select into a two-argument count when the target defines that value at zero. In callers that test X, as zstd does, the select folds away. On aarch64 ZSTD_countTrailingZeros64 becomes rbit, clz, cmp, mov and csel instead of nine instructions with two counts. This gives ~3% on the zstd benchmark in SPEC2026 on my aarch64 system. Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux. gcc/ChangeLog: PR tree-optimization/126035 * gimple-match-head.cc (gimple_count_value_at_zero): New function. * match.pd (ctz_count, clz_count): Also match counts that are defined at zero, possibly masked or selected. (LO != 0 ? ctz (LO) : W + ctz (HI) -> ctz (X)): Keep the value at zero if it is defined. (HI != 0 ? clz (HI) : W + clz (LO) -> clz (X)): Likewise. gcc/testsuite/ChangeLog: PR tree-optimization/126035 * gcc.dg/torture/pr126035-3.c: New test. * gcc.dg/tree-ssa/pr126035-5.c: New test. * gcc.target/aarch64/pr126035-2.c: New test. * gcc.target/aarch64/pr126035-3.c: New test. Signed-off-by: Kyrylo Tkachov --- v2 (patch 9/9): https://gcc.gnu.org/pipermail/gcc-patches/2026-October/735347.html v1 (patch 14/14): https://gcc.gnu.org/pipermail/gcc-patches/2026-October/734443.html Changes from v2: - Do not change phiopt_early_allow (Andrea Pinski). Remove gcc.dg/tree-ssa/pr126035-6.c, which needs it. - Follow the changes of the previous patch. --- gcc/gimple-match-head.cc | 31 +++++ gcc/match.pd | 55 +++++++- gcc/testsuite/gcc.dg/torture/pr126035-3.c | 131 ++++++++++++++++++ gcc/testsuite/gcc.dg/tree-ssa/pr126035-5.c | 55 ++++++++ gcc/testsuite/gcc.target/aarch64/pr126035-2.c | 67 +++++++++ gcc/testsuite/gcc.target/aarch64/pr126035-3.c | 69 +++++++++ 6 files changed, 401 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr126035-3.c create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr126035-5.c create mode 100644 gcc/testsuite/gcc.target/aarch64/pr126035-2.c create mode 100644 gcc/testsuite/gcc.target/aarch64/pr126035-3.c diff --git a/gcc/gimple-match-head.cc b/gcc/gimple-match-head.cc index c6a0c74eabb..9367e3eb702 100644 --- a/gcc/gimple-match-head.cc +++ b/gcc/gimple-match-head.cc @@ -552,3 +552,34 @@ gimple_match_no_overflow_p (tree_code code, tree type, tree op0, tree op1, && gimple_match_range_of_expr (vr1, op1, ctx) && range_op_handler (code).overflow_free_p (vr0, vr1)); } + +/* Return the value for a zero argument of COUNT, a count of trailing or + leading zeros that the ctz_count or clz_count predicate matched + with VALUEIZE, or NULL_TREE if it is undefined. */ + +static inline tree +gimple_count_value_at_zero (tree count, tree (*valueize)(tree)) +{ + gimple *def = get_def (valueize, count); + tree zero; + if (gcall *call = dyn_cast (def)) + { + if (gimple_call_num_args (call) == 1) + return NULL_TREE; + zero = do_valueize (valueize, gimple_call_arg (call, 1)); + } + else if (gimple_assign_rhs_code (def) == COND_EXPR) + zero = do_valueize (valueize, gimple_assign_rhs2 (def)); + else + { + gcc_checking_assert (gimple_assign_rhs_code (def) == BIT_AND_EXPR); + tree arg = do_valueize (valueize, gimple_assign_rhs1 (def)); + tree mask = do_valueize (valueize, gimple_assign_rhs2 (def)); + if (tree_swap_operands_p (arg, mask)) + std::swap (arg, mask); + zero = int_const_binop (BIT_AND_EXPR, + gimple_count_value_at_zero (arg, valueize), mask); + } + gcc_checking_assert (TREE_CODE (zero) == INTEGER_CST); + return zero; +} diff --git a/gcc/match.pd b/gcc/match.pd index 51cea4f6377..b64057c8688 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -11961,16 +11961,48 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && 2 * TYPE_PRECISION (type) >= TYPE_PRECISION (TREE_TYPE (@0))))) /* Counts of the trailing and leading zeros of @0, with any value for a - zero @0. */ + zero @0. forwprop emits table based counts as counts that are + defined at zero, possibly masked or selected for a zero @0. The select + can also test a right shift S if @0 is S converted and S has no more + significant bits than @0. */ (match (ctz_count @0) (CTZ @0)) +(match (ctz_count @0) + (IFN_CTZ @0 INTEGER_CST)) +(match (ctz_count @0) + (bit_and (IFN_CTZ @0 INTEGER_CST) INTEGER_CST@1) + (if (wi::ctz (~wi::to_wide (@1)) + >= ceil_log2 (TYPE_PRECISION (TREE_TYPE (@0)))))) +(match (ctz_count @0) + (cond (eq @0 integer_zerop) INTEGER_CST (ctz_count @0))) +(match (ctz_count @0) + (cond (eq (rshift@1 @2 INTEGER_CST@3) integer_zerop) INTEGER_CST + (ctz_count (convert@0 @1))) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@2)) + && wi::geu_p (wi::to_wide (@3), (TYPE_PRECISION (TREE_TYPE (@2)) + - TYPE_PRECISION (TREE_TYPE (@0))))))) (match (clz_count @0) (CLZ @0)) +(match (clz_count @0) + (IFN_CLZ @0 INTEGER_CST)) +(match (clz_count @0) + (bit_and (IFN_CLZ @0 INTEGER_CST) INTEGER_CST@1) + (if (wi::ctz (~wi::to_wide (@1)) + >= ceil_log2 (TYPE_PRECISION (TREE_TYPE (@0)))))) +(match (clz_count @0) + (cond (eq @0 integer_zerop) INTEGER_CST (clz_count @0))) +(match (clz_count @0) + (cond (eq (rshift@1 @2 INTEGER_CST@3) integer_zerop) INTEGER_CST + (clz_count (convert@0 @1))) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@2)) + && wi::geu_p (wi::to_wide (@3), (TYPE_PRECISION (TREE_TYPE (@2)) + - TYPE_PRECISION (TREE_TYPE (@0))))))) /* LO != 0 ? ctz (LO) : W + ctz (HI) is ctz (X) for a nonzero X, where LO and HI are the low and high halves of the double-word integer X and W is their precision. Likewise HI != 0 ? clz (HI) : W + clz (LO) is - clz (X). */ + clz (X). If the count in the second arm is defined at zero, so is the + result, and a select keeps its value. */ (for cnt (ctz_count clz_count) tst (double_word_low_test double_word_high_test) nzh (double_word_low double_word_high) @@ -11979,13 +12011,22 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (simplify (cond (ne (tst @0) integer_zerop) (convert1? (cnt (nzh @0))) - (plus (convert? (cnt (zh @0))) INTEGER_CST@2)) - (with { tree utype = unsigned_type_for (TREE_TYPE (@0)); } + (plus (convert? (cnt@3 (zh @0))) INTEGER_CST@2)) + (with { tree utype = unsigned_type_for (TREE_TYPE (@0)); + int w = TYPE_PRECISION (utype) / 2; + /* The result for a zero X, if defined. */ + tree zero = gimple_count_value_at_zero (@3, valueize); + widest_int zw = zero ? wi::to_widest (zero) + w : 0; } (if (type_has_mode_precision_p (utype) - && wi::to_wide (@2) == TYPE_PRECISION (utype) / 2 + && wi::to_wide (@2) == w && direct_internal_fn_supported_p (as_internal_fn (ifn), utype, - OPTIMIZE_FOR_BOTH)) - (convert (ifn:integer_type_node (convert:utype @0))))))) + OPTIMIZE_FOR_BOTH) + && wi::fits_to_tree_p (zw, integer_type_node)) + (if (zero) + (convert (cond (ne (convert:utype @0) { build_zero_cst (utype); }) + (ifn:integer_type_node (convert:utype @0)) + { wide_int_to_tree (integer_type_node, zw); })) + (convert (ifn:integer_type_node (convert:utype @0)))))))) #endif /* Common POPCOUNT/PARITY simplifications. */ diff --git a/gcc/testsuite/gcc.dg/torture/pr126035-3.c b/gcc/testsuite/gcc.dg/torture/pr126035-3.c new file mode 100644 index 00000000000..4a17e67c312 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr126035-3.c @@ -0,0 +1,131 @@ +/* PR tree-optimization/126035 */ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +/* Check the combined counts of a double-word value that are defined at + zero, including the value at zero. */ + +typedef __UINT64_TYPE__ U64; +typedef __UINT32_TYPE__ U32; + +#define N __attribute__((noipa)) + +static inline unsigned +ctz32 (U32 val) +{ + static const U32 tab[32] = { + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; + return tab[((U32) ((val & -val) * 0x077CB531U)) >> 27]; +} + +static inline unsigned +clz32 (U32 val) +{ + static const U32 tab[32] = { + 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, + 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 }; + val |= val >> 1; + val |= val >> 2; + val |= val >> 4; + val |= val >> 8; + val |= val >> 16; + return 31 - tab[(val * 0x07C4ACDDU) >> 27]; +} + +/* ctz32 (0) is 0 and clz32 (0) is 31. */ +N unsigned +ctz64 (U64 val) +{ + U32 msw = val >> 32, lsw = val; + return lsw == 0 ? 32 + ctz32 (msw) : ctz32 (lsw); +} + +N unsigned +clz64 (U64 val) +{ + U32 msw = val >> 32, lsw = val; + return msw == 0 ? 32 + clz32 (lsw) : clz32 (msw); +} + +/* A named intermediate: with -g its debug bind is at the merge. */ +N unsigned +ctz64_named (U64 val) +{ + U32 msw = val >> 32, lsw = val; + unsigned r; + if (lsw == 0) + r = 32 + ctz32 (msw); + else + r = ctz32 (lsw); + return r; +} + +N unsigned +ctzg64 (U64 val) +{ + U32 msw = val >> 32, lsw = val; + return lsw == 0 ? 32 + __builtin_ctzg (msw, 32) : __builtin_ctzg (lsw, 32); +} + +N unsigned +clzg64 (U64 val) +{ + U32 msw = val >> 32, lsw = val; + unsigned r = __builtin_clzg (msw, 32); + if (msw == 0) + r = 32 + __builtin_clzg (lsw, 32); + return r; +} + +N unsigned +mixed (U64 val) +{ + U32 msw = val >> 32, lsw = val; + return lsw ? __builtin_ctz (lsw) : 32 + __builtin_ctzg (msw, 32); +} + +/* The value at zero does not fit a signed 7-bit field. */ +struct S { signed int c : 7; }; + +N int +narrow (U64 val) +{ + struct S s; + U32 msw = val >> 32, lsw = val; + if (lsw) + return __builtin_ctzg (lsw, 32); + s.c = 32 + __builtin_ctzg (msw, 32); + return s.c; +} + +int +main (void) +{ + if (ctz64 (0) != 32 || clz64 (0) != 63 || ctz64_named (0) != 32 + || ctzg64 (0) != 64 || clzg64 (0) != 64 || mixed (0) != 64 + || narrow (0) != -64) + __builtin_abort (); + U64 v = 0x9E3779B97F4A7C15ULL; + for (int i = 0; i < 100000; i++) + { + v = v * 6364136223846793005ULL + 1442695040888963407ULL; + U64 x = v; + switch (i & 7) + { + case 0: x = 1ULL << (v % 64); break; + case 1: x = (U32) v; break; + case 2: x = ((U64) (U32) v) << 32; break; + case 3: x = ~0ULL; break; + default: break; + } + if (x == 0) + x = 1; + unsigned t = __builtin_ctzll (x), l = __builtin_clzll (x); + if (ctz64 (x) != t || clz64 (x) != l || ctz64_named (x) != t + || ctzg64 (x) != t || clzg64 (x) != l || mixed (x) != t + || narrow (x) != (int) t) + __builtin_abort (); + } + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr126035-5.c b/gcc/testsuite/gcc.dg/tree-ssa/pr126035-5.c new file mode 100644 index 00000000000..4aaca5e22ce --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr126035-5.c @@ -0,0 +1,55 @@ +/* PR tree-optimization/126035 */ +/* { dg-do compile { target aarch64*-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-additional-options "-mbmi" { target i?86-*-* x86_64-*-* } } */ + +/* The table based counts of the halves are recognized as counts that are + defined at zero. The split double-word ctz is still combined into one + count of the double-word value. The clz table selects its value for + zero around the count, so the arms of clz64 are not chains and phiopt + keeps the branch. The same holds for the ctz table on a target that + does not define CTZ at zero, so x86 needs BMI. */ + +typedef __UINT64_TYPE__ U64; +typedef __UINT32_TYPE__ U32; + +static inline unsigned +ctz32 (U32 val) +{ + static const U32 tab[32] = { + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; + return tab[((U32) ((val & -val) * 0x077CB531U)) >> 27]; +} + +static inline unsigned +clz32 (U32 val) +{ + static const U32 tab[32] = { + 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, + 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 }; + val |= val >> 1; + val |= val >> 2; + val |= val >> 4; + val |= val >> 8; + val |= val >> 16; + return 31 - tab[(val * 0x07C4ACDDU) >> 27]; +} + +unsigned +ctz64 (U64 val) +{ + U32 msw = val >> 32, lsw = val; + return lsw == 0 ? 32 + ctz32 (msw) : ctz32 (lsw); +} + +unsigned +clz64 (U64 val) +{ + U32 msw = val >> 32, lsw = val; + return msw == 0 ? 32 + clz32 (lsw) : clz32 (msw); +} + +/* { dg-final { scan-tree-dump-times "\\.CTZ \\(" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\\.CLZ \\(" 2 "optimized" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/pr126035-2.c b/gcc/testsuite/gcc.target/aarch64/pr126035-2.c new file mode 100644 index 00000000000..9300c2badbe --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr126035-2.c @@ -0,0 +1,67 @@ +/* PR tree-optimization/126035 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#pragma GCC target "+nocssc" + +/* Split counts on top of table based counts. The double-word ctz is + defined at zero as 32, which needs a select. The arms of the clz form + are not chains, so clz64 keeps two counts. */ + +typedef __UINT64_TYPE__ U64; +typedef __UINT32_TYPE__ U32; + +static inline unsigned +ctz32 (U32 val) +{ + static const U32 tab[32] = { + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; + return tab[((U32) ((val & ((~val) + 1)) * 0x077CB531U)) >> 27]; +} + +static inline unsigned +clz32 (U32 val) +{ + static const U32 tab[32] = { + 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, + 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 }; + val |= val >> 1; + val |= val >> 2; + val |= val >> 4; + val |= val >> 8; + val |= val >> 16; + return 31 - tab[(val * 0x07C4ACDDU) >> 27]; +} + +unsigned +ctz64 (U64 val) +{ + U32 msw = val >> 32, lsw = val; + if (lsw == 0) + return 32 + ctz32 (msw); + return ctz32 (lsw); +} + +unsigned +clz64 (U64 val) +{ + U32 msw = val >> 32, lsw = val; + if (msw == 0) + return 32 + clz32 (lsw); + return clz32 (msw); +} + +/* With a value of 64 at zero no select is needed. */ +unsigned +ctzg64 (U64 val) +{ + U32 msw = val >> 32, lsw = val; + return lsw == 0 ? 32 + __builtin_ctzg (msw, 32) : __builtin_ctzg (lsw, 32); +} + +/* { dg-final { scan-assembler-times {\trbit\tx[0-9]+, x[0-9]+} 2 } } */ +/* { dg-final { scan-assembler-times {\tclz\tx[0-9]+, x[0-9]+} 2 } } */ +/* { dg-final { scan-assembler-times {\tclz\tw[0-9]+, w[0-9]+} 2 } } */ +/* { dg-final { scan-assembler-times {\tcsel\t} 2 } } */ +/* { dg-final { scan-assembler-not {\tldr} } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/pr126035-3.c b/gcc/testsuite/gcc.target/aarch64/pr126035-3.c new file mode 100644 index 00000000000..733d4d43e4e --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr126035-3.c @@ -0,0 +1,69 @@ +/* PR tree-optimization/126035 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fgimple -fdump-tree-optimized" } */ + +/* FRE simplifies the select of the split counts. It looks through the + copy in f1 and matches the mask with the constant first in f2. */ + +typedef __UINT64_TYPE__ U64; +typedef __UINT32_TYPE__ U32; + +unsigned int __GIMPLE (ssa,startwith("fre1")) +f1 (U64 x) +{ + U32 lo; + U32 hi; + U64 t; + int c1; + int c2; + int c3; + int c4; + int c5; + _Bool b; + int r2; + unsigned int r; + + __BB(2): + lo_2 = (U32) x_1(D); + t_3 = x_1(D) >> 32; + hi_4 = (U32) t_3; + c1_5 = .CTZ (lo_2, 32); + c2_6 = .CTZ (hi_4, 32); + c3_7 = c2_6; + c4_8 = c3_7 & 31; + c5_9 = c4_8 + 32; + b_10 = lo_2 != 0u; + r2_11 = b_10 ? c1_5 : c5_9; + r_12 = (unsigned int) r2_11; + return r_12; +} + +unsigned int __GIMPLE (ssa,startwith("fre1")) +f2 (U64 x) +{ + U32 lo; + U32 hi; + U64 t; + int c1; + int c2; + int c4; + int c5; + _Bool b; + int r2; + unsigned int r; + + __BB(2): + lo_2 = (U32) x_1(D); + t_3 = x_1(D) >> 32; + hi_4 = (U32) t_3; + c1_5 = .CTZ (lo_2, 32); + c2_6 = .CTZ (hi_4, 32); + c4_8 = 31 & c2_6; + c5_9 = c4_8 + 32; + b_10 = lo_2 != 0u; + r2_11 = b_10 ? c1_5 : c5_9; + r_12 = (unsigned int) r2_11; + return r_12; +} + +/* { dg-final { scan-tree-dump-times {\.CTZ \(x_\d+\(D\)\)} 2 "optimized" } } */ -- 2.34.1 From rdapp.gcc@gmail.com Tue Nov 3 10:00:59 2026 From: rdapp.gcc@gmail.com (Robin Dapp) Date: Tue, 03 Nov 2026 11:00:59 +0100 Subject: [PATCH 1/3] expmed: Extract subvectors via vec_perm_const. In-Reply-To: References: <20261030151204.95945-1-rdapp.gcc@gmail.com> <20261030151204.95945-2-rdapp.gcc@gmail.com> Message-ID: > OK with the above changes if changing to a single-input permute is > correct. Yes it works, thanks. Going to commit with the fixes and also with 0 instead of GET_MODE_NUNITS in 2/3. I figured a less permissive check is safer because the 0 lowpart is always valid but that shouldn't matter. -- Regards Robin From ams@baylibre.com Tue Nov 3 10:03:00 2026 From: ams@baylibre.com (Andrew Stubbs) Date: Tue, 3 Nov 2026 10:03:00 +0000 Subject: [PATCH v2 1/9] Add --param offload-gpu-mode In-Reply-To: References: <20260929144300.1562781-1-ams@baylibre.com> <20260929144300.1562781-2-ams@baylibre.com> Message-ID: <370ad351-ffa9-4407-8c9a-5e628cf2cb5d@baylibre.com> Ping. On 26/10/2026 12:19, Andrew Stubbs wrote: > Ping. > > On 14/10/2026 16:27, Andrew Stubbs wrote: >> Ping. >> >> On 29/09/2026 15:42, Andrew Stubbs wrote: >>> This new option will be used to enable a new experimental SIMT >>> implementation >>> for AMD GCN, alongside the existing SIMD implementation.? I'm adding >>> it as a >>> "param" because I don't intend that users will need to know about it, >>> but may >>> want to try it during the experimental phase.? If the experiment is >>> successful >>> the "auto" mode will be changed, and users will continue to not need >>> to know >>> about it.? It's possible that some use cases will perform better with a >>> different mode, so the option will remain usable, but will always be a >>> low-level "tweakable". >>> >>> gcc/ChangeLog: >>> >>> ????* doc/params.texi: Document --param=offload-gpu-mode. >>> ????* flag-types.h (enum offload_gpu_modes): New type. >>> ????* omp-general.cc (omp_max_simt_vf): Do SIMT for amdgcn, optionally. >>> ????* params.opt: Add --param=offload-gpu-mode and the enum. >>> --- >>> ? gcc/doc/params.texi | 24 ++++++++++++++++++++++++ >>> ? gcc/flag-types.h??? |? 9 +++++++++ >>> ? gcc/omp-general.cc? | 15 ++++++++++++++- >>> ? gcc/params.opt????? | 19 +++++++++++++++++++ >>> ? 4 files changed, 66 insertions(+), 1 deletion(-) >>> >>> diff --git a/gcc/doc/params.texi b/gcc/doc/params.texi >>> index e69be2d2923..e7ca0638d35 100644 >>> --- a/gcc/doc/params.texi >>> +++ b/gcc/doc/params.texi >>> @@ -1967,6 +1967,30 @@ bubbles.? This is the current default.? Zero >>> means the scheduling description >>> ? might not be available/accurate or perhaps not applicable at all, >>> such as for >>> ? modern out-of-order processors. >>> +@item offload-gpu-mode >>> +Controls how vector parallel code is generated for OpenMP and >>> OpenACC offload >>> +kernels.? Different modes may suit different use cases, and may be >>> implemented >>> +to differing levels of completion.?? Not all GPUs support all the >>> modes. >>> +@option{--param=offload-gpu-mode=auto} selects the recommended mode >>> for each >>> +GPU architecture. >>> +@option{--param=offload-gpu-mode=simd} uses the autovectorizer for >>> all kernel >>> +code (default on AMD GCN, not available for NVPTX).? In general, >>> SIMD mode may >>> +produce tighter loops, but performs very badly if the vectorizer >>> fails (due to >>> +function calls, pattern mismatches, or complex logic).? The >>> vectorizer is >>> +active for all GPU code, at @option{-O2} or above; the OpenMP and >>> OpenACC >>> +directives are treated as optimization hints. >>> +@option{--param=offload-gpu-mode=simt-directed} (default on NVPTX, >>> experimental >>> +on AMD GCN) uses SIMT code-generation for loops with an OpenMP >>> @samp{simd} >>> +directive, or an OpenACC @samp{loop vector} directive.? Code that >>> does not use >>> +these directives will not make use of the vector hardware at all. >>> +@samp{omp_get_num_threads} reports the wavefront/warp count. >>> +@option{--param=offload-gpu-mode=simt} (experimental) uses SIMT for >>> all code >>> +parallelized with OpenMP threads (OpenACC behavior is unchanged from >>> +@option{simt-directed} mode).? The OpenMP @samp{simd} directive may >>> be a no-op. >>> +@samp{omp_get_num_threads} reports the total number of work-items/ >>> threads >>> +across all wavefronts/warps.? This mode most-closely imitates the LLVM >>> +behavior. >>> + >>> ? @end table >>> ? @node Target-Specific Parameters >>> diff --git a/gcc/flag-types.h b/gcc/flag-types.h >>> index e14dd36707a..16db1661195 100644 >>> --- a/gcc/flag-types.h >>> +++ b/gcc/flag-types.h >>> @@ -593,6 +593,15 @@ enum omp_ompt_level >>> ??? OMP_OMPT_LEVEL_EXTENDED = 2 >>> ? }; >>> +/* Modes for -param=offload-gpu-mode.? */ >>> +enum offload_gpu_modes >>> +{ >>> +? OFFLOAD_GPU_MODE_AUTO, >>> +? OFFLOAD_GPU_MODE_SIMD, >>> +? OFFLOAD_GPU_MODE_SIMT_DIRECTED, >>> +? OFFLOAD_GPU_MODE_SIMT >>> +}; >>> + >>> ? #endif >>> ? #endif /* ! GCC_FLAG_TYPES_H */ >>> diff --git a/gcc/omp-general.cc b/gcc/omp-general.cc >>> index 564fe858cdd..4f03459a49a 100644 >>> --- a/gcc/omp-general.cc >>> +++ b/gcc/omp-general.cc >>> @@ -1042,7 +1042,20 @@ omp_max_simt_vf (void) >>> ??? if (ENABLE_OFFLOADING) >>> ????? for (const char *c = getenv ("OFFLOAD_TARGET_NAMES"); c;) >>> ??????? { >>> -??? if (startswith (c, "nvptx")) >>> +??? if (startswith (c, "amdgcn")) >>> +????? { >>> +??????? switch (param_offload_gpu_mode) >>> +????????? { >>> +????????? case OFFLOAD_GPU_MODE_SIMT: /* For now.? */ >>> +????????? case OFFLOAD_GPU_MODE_SIMT_DIRECTED: >>> +??????? return 64; >>> +????????? case OFFLOAD_GPU_MODE_AUTO: >>> +????????? case OFFLOAD_GPU_MODE_SIMD: >>> +??????? return 0; >>> +????????? } >>> +??????? gcc_unreachable (); >>> +????? } >>> +??? else if (startswith (c, "nvptx")) >>> ??????? return 32; >>> ????? else if ((c = strchr (c, ':'))) >>> ??????? c++; >>> diff --git a/gcc/params.opt b/gcc/params.opt >>> index 0c6a3e51457..cb38eedb6b5 100644 >>> --- a/gcc/params.opt >>> +++ b/gcc/params.opt >>> @@ -890,6 +890,25 @@ The minimum probability of reaching a source >>> block for interblock speculative sc >>> ? Common Joined UInteger Var(param_min_vect_loop_bound) Param >>> Optimization >>> ? If -ftree-vectorize is used, the minimal loop bound of a loop to be >>> considered for vectorization. >>> +Enum >>> +Name(offload_gpu_modes) Type(enum offload_gpu_modes) >>> + >>> +EnumValue >>> +Enum(offload_gpu_modes) String(auto) Value(OFFLOAD_GPU_MODE_AUTO) >>> + >>> +EnumValue >>> +Enum(offload_gpu_modes) String(simd) Value(OFFLOAD_GPU_MODE_SIMD) >>> + >>> +EnumValue >>> +Enum(offload_gpu_modes) String(simt-directed) >>> Value(OFFLOAD_GPU_MODE_SIMT_DIRECTED) >>> + >>> +EnumValue >>> +Enum(offload_gpu_modes) String(simt) Value(OFFLOAD_GPU_MODE_SIMT) >>> + >>> +-param=offload-gpu-mode= >>> +Common Joined Enum(offload_gpu_modes) Var(param_offload_gpu_mode) >>> Init(OFFLOAD_GPU_MODE_AUTO) Param Optimization >>> +--param=offload-gpu-mode=[auto|simd|simt-directed|simt]??? Specify >>> what vector parallelization mode to use for GPU offload kernels. >>> + >>> ? -param=openacc-kernels= >>> ? Common Joined Enum(openacc_kernels) Var(param_openacc_kernels) >>> Init(OPENACC_KERNELS_PARLOOPS) Param >>> ? --param=openacc-kernels=[decompose|parloops]??? Specify mode of >>> OpenACC 'kernels' constructs handling. >> > From rdapp.gcc@gmail.com Tue Nov 3 10:29:41 2026 From: rdapp.gcc@gmail.com (Robin Dapp) Date: Tue, 03 Nov 2026 11:29:41 +0100 Subject: [PATCH 1/3] expmed: Extract subvectors via vec_perm_const. In-Reply-To: References: <20261030151204.95945-1-rdapp.gcc@gmail.com> <20261030151204.95945-2-rdapp.gcc@gmail.com> Message-ID: Ah, forgot this one: > Why not? I think the comment should say, rather than leave the reader > to guess :) Yes, that sounds a bit mysterious :) The whole point was that we leave element inserts to the optab, even if they come in vector shape. I guess we could relax this but it would blur the boundary a bit. -- Regards Robin From ams@baylibre.com Tue Nov 3 10:35:15 2026 From: ams@baylibre.com (Andrew Stubbs) Date: Tue, 3 Nov 2026 10:35:15 +0000 Subject: [committed] amdgcn: Fix stack size calculation overflow [PR128366] Message-ID: <20261103103515.346888-1-ams@baylibre.com> The stack sizes and/or offsets were all written assuming they wouldn't exceed UINT_MAX, which is not safe. This patch fixes the libgomp plugin that creates the stack space, the kernel prologue that initializes the stack pointers in each thread, and the builtin that Newlib uses to locate the reent structs. gcc/ChangeLog: PR target/128366 * config/gcn/gcn.cc (gcn_expand_prologue): Use 64-bit to calculate wave_offset and fp_hi. (gcn_expand_builtin_1): Use 64-bit to calculate stack_limit_offset_di. libgomp/ChangeLog: PR target/128366 * config/gcn/team.c (gomp_gcn_enter_kernel): Use size_t to find the start of the team_arena. * plugin/plugin-gcn.c (configure_ephemeral_memories): Use size_t for actual_arena_total_size. --- gcc/config/gcn/gcn.cc | 23 ++++++++++++----------- libgomp/config/gcn/team.c | 2 +- libgomp/plugin/plugin-gcn.c | 4 ++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc index 9628d8f7282..a8c3e6cb8c5 100644 --- a/gcc/config/gcn/gcn.cc +++ b/gcc/config/gcn/gcn.cc @@ -3559,6 +3559,11 @@ gcn_expand_prologue () set_mem_addr_space (stack_size_mem, ADDR_SPACE_SCALAR_FLAT); emit_move_insn (wave_offset, stack_size_mem); + /* The total stack size may exceed 4 GiB, so the wave offset needs + 64 bits. NUM_WAVES is dead now, so reuse it for the high part. */ + rtx wave_offset_hi = num_waves; + emit_insn (gen_umulsi3_highpart_reg (wave_offset_hi, wave_offset, + thread_id)); emit_insn (gen_mulsi3 (wave_offset, wave_offset, thread_id)); /* The FLAT_SCRATCH_INIT is not usually needed, but can be enabled @@ -3607,7 +3612,7 @@ gcn_expand_prologue () emit_move_insn (fp, stack_addr_mem); rtx scc = gen_rtx_REG (BImode, SCC_REG); emit_insn (gen_addsi3_scalar_carry (fp_lo, fp_lo, wave_offset, scc)); - emit_insn (gen_addcsi3_scalar_zero (fp_hi, fp_hi, scc)); + emit_insn (gen_addcsi3_scalar (fp_hi, fp_hi, wave_offset_hi, scc, scc)); /* Adding RTX_FRAME_RELATED_P effectively disables splitting, so we use split add explicitly, and specify the DImode add in the note. @@ -5030,18 +5035,14 @@ gcn_expand_builtin_1 (tree exp, rtx target, rtx /*subtarget */ , rtx stack_size = gen_reg_rtx (SImode); emit_move_insn (stack_size, stack_size_mem); - rtx wave_offset = gen_reg_rtx (SImode); - emit_insn (gen_mulsi3 (wave_offset, stack_size, thread_id)); - - rtx stack_limit_offset = gen_reg_rtx (SImode); - emit_insn (gen_addsi3 (stack_limit_offset, wave_offset, - stack_size)); + /* The stack limit is at the end of this wave's stack, at + (thread_id + 1) * stack_size, which may exceed 4 GiB. */ + rtx next_thread_id = gen_reg_rtx (SImode); + emit_insn (gen_addsi3 (next_thread_id, thread_id, const1_rtx)); rtx stack_limit_offset_di = gen_reg_rtx (DImode); - emit_move_insn (gen_rtx_SUBREG (SImode, stack_limit_offset_di, 4), - const0_rtx); - emit_move_insn (gen_rtx_SUBREG (SImode, stack_limit_offset_di, 0), - stack_limit_offset); + emit_insn (gen_umulsidi3 (stack_limit_offset_di, stack_size, + next_thread_id)); rtx stack_addr_mem = gen_rtx_MEM (DImode, gen_rtx_PLUS (DImode, diff --git a/libgomp/config/gcn/team.c b/libgomp/config/gcn/team.c index be148c3f8bf..83cc0f8f73c 100644 --- a/libgomp/config/gcn/team.c +++ b/libgomp/config/gcn/team.c @@ -80,7 +80,7 @@ gomp_gcn_enter_kernel (void) struct kernargs_abi *kernargs = (struct kernargs_abi*) __builtin_gcn_kernarg_ptr (); void *team_arena = ((void*)kernargs->arena_ptr - + kernargs->arena_size_per_team * teamid); + + (size_t) kernargs->arena_size_per_team * teamid); void * __lds *arena_start = (void * __lds *)TEAM_ARENA_START; void * __lds *arena_free = (void * __lds *)TEAM_ARENA_FREE; void * __lds *arena_end = (void * __lds *)TEAM_ARENA_END; diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c index 61280336736..bfce10ef042 100644 --- a/libgomp/plugin/plugin-gcn.c +++ b/libgomp/plugin/plugin-gcn.c @@ -1991,9 +1991,9 @@ configure_ephemeral_memories (struct kernel_info *kernel, int actual_arena_size = (kernel->kind == KIND_OPENMP ? team_arena_size : 0); - int actual_arena_total_size = actual_arena_size * num_teams; + size_t actual_arena_total_size = (size_t) actual_arena_size * num_teams; size_t size = (actual_arena_total_size - + num_teams * num_threads * stack_size); + + (size_t) num_teams * num_threads * stack_size); for (item = *next_ptr; item; next_ptr = &item->next, item = item->next) { -- 2.54.0 From tkaminsk@redhat.com Tue Nov 3 10:42:33 2026 From: tkaminsk@redhat.com (Tomasz Kaminski) Date: Tue, 3 Nov 2026 11:42:33 +0100 Subject: [PATCH 1/3] libstdc++: Expand __unpack_std_tuple to support pair, array and complex. In-Reply-To: <20261029171541.923427-2-tkaminsk@redhat.com> References: <20261029171541.923427-1-tkaminsk@redhat.com> <20261029171541.923427-2-tkaminsk@redhat.com> Message-ID: On Thu, Oct 29, 2026 at 6:18?PM Tomasz Kami?ski wrote: > The __unpack_std_tuple is used in the noexcept specification std::apply > and std::make_from_t, to determine if function is nothrow invocable or > type is nothrow constructible respectively. This trait however was > specialized only for tuple, and such functions were other consider > potentially throwing from remaining tuple-like types. The above should be replaced with: This trait however was specialized only for tuple, and in consequence above functions were considered potentially throwing from remaining tuple-like types (pair, array, ...). > As the standard > defines noexcept specification for std::apply this is non-conformance. > > This patch provides additional partial specializations for above trait > for std::pair, std::array and std::complex, for which get is always > noexcept. To reflect that the strait is renamed to __unpack_tuple_like_v. > > libstdc++-v3/ChangeLog: > > * include/bits/stl_pair.h (std::__unpack_tuple_like_v): Moved > from and renamed to std::__unpack_std_tuple. Additional > specialization defined for pair, array and complex. > * include/std/tuple (std::__unpack_tuple_like): Moved to > bits/stl_pair.h. > (std::apply, std::make_from_tuple): Update noexcept specification. > * testsuite/20_util/tuple/apply/1.cc: Add test for pair and array. > * testsuite/20_util/tuple/apply/2.cc: Likewise. > * testsuite/20_util/tuple/make_from_tuple/tuple_like.cc: Test > noexcept and constrains. > * testsuite/26_numerics/complex/tuple_like.cc: Likewise. > --- > libstdc++-v3/include/bits/stl_pair.h | 89 ++++++++++++++++++- > libstdc++-v3/include/std/tuple | 29 +----- > .../testsuite/20_util/tuple/apply/1.cc | 31 +++++++ > .../testsuite/20_util/tuple/apply/2.cc | 12 +++ > .../tuple/make_from_tuple/tuple_like.cc | 39 ++++++-- > .../26_numerics/complex/tuple_like.cc | 14 ++- > 6 files changed, 178 insertions(+), 36 deletions(-) > > diff --git a/libstdc++-v3/include/bits/stl_pair.h > b/libstdc++-v3/include/bits/stl_pair.h > index ccff8691206..b18e1b74b77 100644 > --- a/libstdc++-v3/include/bits/stl_pair.h > +++ b/libstdc++-v3/include/bits/stl_pair.h > @@ -233,7 +233,94 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > } > }; > #endif // lib concepts > - /// @endcond > + > +#if defined(__glibcxx_apply) || defined(__glibcxx_make_from_tuple) // C++ > >= 17 > + // Unpack tuple_like into a type trait and use its value. > + template class _Trait, typename _Tp, typename > _Tuple> > + constexpr bool __unpack_tuple_like_v = false; > + > + // Unpack a std::tuple into a type trait and use its value. > + template class _Trait, typename _Tp, typename... > _Up> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, tuple<_Up...>> > + = _Trait<_Tp, _Up...>::value; > + > + template class _Trait, typename _Tp, typename... > _Up> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, tuple<_Up...>&> > + = _Trait<_Tp, _Up&...>::value; > + > + template class _Trait, typename _Tp, typename... > _Up> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const tuple<_Up...>> > + = _Trait<_Tp, const _Up...>::value; > + > + template class _Trait, typename _Tp, typename... > _Up> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const > tuple<_Up...>&> > + = _Trait<_Tp, const _Up&...>::value; > + > + // Unpack a std::pair into a type trait and use its value. > + template class _Trait, typename _Tp, typename > _Fp, typename _Sp> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, pair<_Fp, _Sp>> > + = _Trait<_Tp, _Fp, _Sp>::value; > + > + template class _Trait, typename _Tp, typename > _Fp, typename _Sp> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, pair<_Fp, _Sp>&> > + = _Trait<_Tp, _Fp&, _Sp&>::value; > + > + template class _Trait, typename _Tp, typename > _Fp, typename _Sp> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const pair<_Fp, > _Sp>> > + = _Trait<_Tp, const _Fp, const _Sp>::value; > + > + template class _Trait, typename _Tp, typename > _Fp, typename _Sp> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const pair<_Fp, > _Sp>&> > + = _Trait<_Tp, const _Fp&, const _Sp&>::value; > + > + namespace __detail > + { > + template class _Trait, typename _Tp, typename > _Up, size_t... _Ids> > + constexpr bool > + __apply_repeated_arg(index_sequence<_Ids...>) > + { return _Trait<_Tp, decltype(((void)_Ids, > std::declval<_Up>()))...>::value; } > + } > + > + // Unpack a std::array into a type trait and use its value. > + template class _Trait, typename _Tp, typename > _Up, size_t _Nm> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, array<_Up, _Nm>> > + = __detail::__apply_repeated_arg<_Trait, _Tp, > _Up>(make_index_sequence<_Nm>{}); > + > + template class _Trait, typename _Tp, typename > _Up, size_t _Nm> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, array<_Up, _Nm>&> > + = __detail::__apply_repeated_arg<_Trait, _Tp, > _Up&>(make_index_sequence<_Nm>{}); > + > + template class _Trait, typename _Tp, typename > _Up, size_t _Nm> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const array<_Up, > _Nm>> > + = __detail::__apply_repeated_arg<_Trait, _Tp, const > _Up>(make_index_sequence<_Nm>{}); > + > + template class _Trait, typename _Tp, typename > _Up, size_t _Nm> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const array<_Up, > _Nm>&> > + = __detail::__apply_repeated_arg<_Trait, _Tp, const > _Up&>(make_index_sequence<_Nm>{}); > +#endif > + > +#if __glibcxx_tuple_like >= 202311 // >= C++26 > + // Unpack a std::complex into type trait and use it value. > + // Assume that real()/imag() does not throw. > + template class _Trait, typename _Tp, typename _Up> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, complex<_Up>> > + = _Trait<_Tp, _Up, _Up>::value; > + > + template class _Trait, typename _Tp, typename _Up> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, complex<_Up>&> > + = _Trait<_Tp, _Up&, _Up&>::value; > + > + template class _Trait, typename _Tp, typename _Up> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const complex<_Up>> > + = _Trait<_Tp, const _Up, const _Up>::value; > + > + template class _Trait, typename _Tp, typename _Up> > + constexpr bool __unpack_tuple_like_v<_Trait, _Tp, const complex<_Up>&> > + = _Trait<_Tp, const _Up&, const _Up&>::value; > +#endif > + > + // __is_tuple_like is defined in . > +/// @endcond > #endif // C++11 > > /// @cond undocumented > diff --git a/libstdc++-v3/include/std/tuple > b/libstdc++-v3/include/std/tuple > index d73cefcbca8..7d6039ceb38 100644 > --- a/libstdc++-v3/include/std/tuple > +++ b/libstdc++-v3/include/std/tuple > @@ -2912,31 +2912,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...) > { } > > -#if defined(__cpp_lib_apply) || defined(__cpp_lib_make_from_tuple) // C++ > >= 17 > - // Unpack a std::tuple into a type trait and use its value. > - // For cv std::tuple<_Up> the result is _Trait<_Tp, cv _Up...>::value. > - // For cv std::tuple<_Up>& the result is _Trait<_Tp, cv _Up&...>::value. > - // Otherwise the result is false (because we don't know if std::get > throws). > - template class _Trait, typename _Tp, typename > _Tuple> > - inline constexpr bool __unpack_std_tuple = false; > - > - template class _Trait, typename _Tp, typename... > _Up> > - inline constexpr bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>> > - = _Trait<_Tp, _Up...>::value; > - > - template class _Trait, typename _Tp, typename... > _Up> > - inline constexpr bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>&> > - = _Trait<_Tp, _Up&...>::value; > - > - template class _Trait, typename _Tp, typename... > _Up> > - inline constexpr bool __unpack_std_tuple<_Trait, _Tp, const > tuple<_Up...>> > - = _Trait<_Tp, const _Up...>::value; > - > - template class _Trait, typename _Tp, typename... > _Up> > - inline constexpr bool __unpack_std_tuple<_Trait, _Tp, const > tuple<_Up...>&> > - = _Trait<_Tp, const _Up&...>::value; > -#endif > - > #ifdef __cpp_lib_apply // C++ >= 17 > template > constexpr decltype(auto) > @@ -2953,7 +2928,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > #endif > constexpr decltype(auto) > apply(_Fn&& __f, _Tuple&& __t) > - noexcept(__unpack_std_tuple) > + noexcept(__unpack_tuple_like_v) > { > using _Indices > = make_index_sequence>>; > @@ -2990,7 +2965,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > #endif > constexpr auto > make_from_tuple(_Tuple&& __t) > - noexcept(__unpack_std_tuple) > + noexcept(__unpack_tuple_like_v) > #ifdef __cpp_concepts // >= C++20 > -> _Tp > requires __can_make_from_tuple<_Tp, _Tuple> > diff --git a/libstdc++-v3/testsuite/20_util/tuple/apply/1.cc > b/libstdc++-v3/testsuite/20_util/tuple/apply/1.cc > index 05d552f7ebf..a64a5eeea8b 100644 > --- a/libstdc++-v3/testsuite/20_util/tuple/apply/1.cc > +++ b/libstdc++-v3/testsuite/20_util/tuple/apply/1.cc > @@ -19,6 +19,7 @@ > // { dg-add-options no_pch } > > #include > +#include > > #if __cpp_lib_apply < 201603 > # error "__cpp_lib_apply < 201603" > @@ -35,6 +36,18 @@ test01() > VERIFY(&c == &std::get(t)); > VERIFY(&d == &std::get(t)); > }, t); > + > + auto p = std::make_pair(1, '2'); > + std::apply( [&](int& i, char& c) { > + VERIFY(&i == &p.first); > + VERIFY(&c == &p.second); > + }, p); > + > + auto a = std::array{1, 2}; > + std::apply( [&](int& i, int& j) { > + VERIFY(&i == &a[0]); > + VERIFY(&j == &a[1]); > + }, a); > } > > constexpr int func(int i, int j) { return i + j; } > @@ -45,11 +58,21 @@ test02() > constexpr auto t = std::make_tuple(1, 2); > constexpr int i = std::apply(func, t); > VERIFY( i == 3 ); > + > + constexpr auto p = std::make_pair(2, 4); > + constexpr int j = std::apply(func, p); > + VERIFY( j == 6 ); > + > + constexpr auto a = std::array{3, 5}; > + constexpr int k = std::apply(func, a); > + VERIFY( k == 8 ); > } > > struct F > { > int f(int i, int j) const { return i + j; } > + int g(int i) const { return i + 2; } > + int h() const { return 3; } > }; > > void > @@ -58,6 +81,14 @@ test03() > auto t = std::make_tuple(F{}, 1, 2); > int r = std::apply(&F::f, t); > VERIFY( r == 3 ); > + > + auto p = std::make_pair(F{}, 4); > + int j = std::apply(&F::g, p); > + VERIFY( j == 6 ); > + > + auto a = std::array{}; > + int k = std::apply(&F::h, a); > + VERIFY( k == 3 ); > } > > int > diff --git a/libstdc++-v3/testsuite/20_util/tuple/apply/2.cc > b/libstdc++-v3/testsuite/20_util/tuple/apply/2.cc > index 0f2e1620b9f..552b1b97112 100644 > --- a/libstdc++-v3/testsuite/20_util/tuple/apply/2.cc > +++ b/libstdc++-v3/testsuite/20_util/tuple/apply/2.cc > @@ -20,8 +20,11 @@ > // Test noexcept-specifier on std::apply > > #include > +#include > > using std::tuple; > +using std::pair; > +using std::array; > using std::declval; > > void f1(); > @@ -59,3 +62,12 @@ static_assert( noexcept(apply(f4, declval int>>())) ); > static_assert( !noexcept(apply(f4, declval&>())) ); > static_assert( !noexcept(apply(f4, declval>())) ); > static_assert( !noexcept(apply(f4, declval&>())) ); > + > +static_assert( noexcept(apply(f4, declval>())) ); > +static_assert( !noexcept(apply(f4, declval&>())) ); > +static_assert( !noexcept(apply(f4, declval>())) ); > +static_assert( !noexcept(apply(f4, declval&>())) ); > + > +static_assert( noexcept(apply(f4, declval>())) ); > +static_assert( !noexcept(apply(f4, declval&>())) ); > + > diff --git > a/libstdc++-v3/testsuite/20_util/tuple/make_from_tuple/tuple_like.cc > b/libstdc++-v3/testsuite/20_util/tuple/make_from_tuple/tuple_like.cc > index de694554d86..91adea29fd9 100644 > --- a/libstdc++-v3/testsuite/20_util/tuple/make_from_tuple/tuple_like.cc > +++ b/libstdc++-v3/testsuite/20_util/tuple/make_from_tuple/tuple_like.cc > @@ -2,42 +2,69 @@ > > #include > #include > +#include > + > +template > +constexpr bool can_make_from_tuple = false; > + > +template > +constexpr bool can_make_from_tuple decltype(void(std::make_from_tuple(std::declval())))> = true; > > struct Two > { > - Two(const char*, int); > + Two(const char*, int) noexcept; > }; > > void > test_pair() > { > - auto two = std::make_from_tuple(std::pair("one", 2)); > + std::pair p("one", 2); > + auto two = std::make_from_tuple(p); > static_assert(std::is_same_v, "make from pair"); > + static_assert(noexcept(std::make_from_tuple(p)), "noexcept for > pair"); > + static_assert(!can_make_from_tuple>); > } > > -#include > > struct Three > { > - Three(int, int, int); > + Three(int, int, int) noexcept; > }; > > void > test_array() > { > - Three three = std::make_from_tuple(std::array{{1, 2, > 3}}); > + std::array a{{1, 2, 3}}; > + auto three = std::make_from_tuple(a); > static_assert(std::is_same_v, "make from > array"); > + static_assert(noexcept(std::make_from_tuple(a)), "noexcept for > array"); > + static_assert(!can_make_from_tuple>); > + static_assert(!can_make_from_tuple>); > } > > #if __cplusplus >= 202002L > #include > #include > > +struct Cont > +{ > + template > + Cont(Iter, Iter) noexcept > + { }; > +}; > + > void > test_subrange() // PR libstdc++/102301 > { > auto r = std::views::iota(0, 5); > - auto v = > std::make_from_tuple>(std::ranges::subrange(r)); > + std::ranges::subrange sr(r); > + auto v = std::make_from_tuple>(sr); > static_assert(std::is_same_v>, "from > subrange"); > + > + auto cont = std::make_from_tuple(sr); > + static_assert(std::is_same_v, "from subrange"); > + // TODO fix > + static_assert(!noexcept(std::make_from_tuple(sr)), "noexcept for > subrange"); > + static_assert(!can_make_from_tuple std::ranges::subrange>>); > } > #endif > diff --git a/libstdc++-v3/testsuite/26_numerics/complex/tuple_like.cc > b/libstdc++-v3/testsuite/26_numerics/complex/tuple_like.cc > index 1150861ae0a..1dcabd0b779 100644 > --- a/libstdc++-v3/testsuite/26_numerics/complex/tuple_like.cc > +++ b/libstdc++-v3/testsuite/26_numerics/complex/tuple_like.cc > @@ -116,6 +116,10 @@ test_element_view() > VERIFY(imag_reduction == T(25)); > } > > +template > +concept can_make_from_tuple = requires (Tuple t) > +{ std::make_from_tuple(std::forward(t)); }; > + > template > constexpr > void > @@ -123,10 +127,16 @@ test_apply() > { > std::complex cpx(T(1), T(2)); > > - auto f = [](T a, T b) { return a + b; }; > + auto f = [](T a, T b) noexcept { return a + b; }; > auto result = std::apply(f, cpx); > - > VERIFY(result == T(3)); > + static_assert(noexcept(std::apply(f, cpx))); > + > + auto p = std::make_from_tuple>(cpx); > + VERIFY( p.first == T(1) ); > + VERIFY( p.second == T(2) ); > + static_assert(noexcept(std::make_from_tuple>(cpx))); > + static_assert(!can_make_from_tuple, > std::complex>); > } > > template > -- > 2.56.0 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dhruvc@nvidia.com Tue Nov 3 10:47:01 2026 From: dhruvc@nvidia.com (Dhruv Chawla) Date: Tue, 3 Nov 2026 16:17:01 +0530 Subject: [PING^2][PATCH v3] aarch64: Compute 8 and 16-bit saturating arithmetic in GPRs In-Reply-To: <9cb86bc7-45d5-4aa3-9218-06a203b7340e@nvidia.com> References: <20261013103940.88758-1-dhruvc@nvidia.com> <9cb86bc7-45d5-4aa3-9218-06a203b7340e@nvidia.com> Message-ID: On 22/10/26 10:26, Dhruv Chawla wrote: > External email: Use caution opening links or attachments > > > On 13/10/26 16:09, dhruvc@nvidia.com wrote: >> External email: Use caution opening links or attachments >> >> >> From: Dhruv Chawla >> >> Saturating addition and subtraction in SI and DI modes are already computed >> in general registers to avoid the transfers to and from the FP registers >> that [SU]QADD and [SU]QSUB require. The QI and HI modes were left out, so >> vqaddb_u8(a, b) on values held in W registers becomes for example: >> >> ???????? dup???? v30.8b, w0 >> ???????? dup???? v31.8b, w1 >> ???????? uqadd?? b31, b31, b30 >> ???????? umov??? w0, v31.b[0] >> >> where three of the four instructions only move the data into and back out >> of the vector register file. >> >> The trick used for the SI and DI modes does not carry over directly (as the >> comment above the existing patterns notes): the flags set by a 32-bit ADDS >> say nothing about overflow of an 8 or 16-bit value, which cannot overflow >> a W register at all. Shifting the operands up to the top of the register >> first fixes that. The carry and overflow flags then describe the narrow >> operation exactly (so the same sequence applies), and the shift doubles as >> the extension of the operand. The bits above the mode are also discarded >> and don't have to be masked or sign-extended separately. Only the first >> operand needs a shift of its own, as ADDS and SUBS can shift their second >> source operand themselves: >> >> ???????? lsl???? w2, w0, 24 >> ???????? adds??? w0, w2, w1, lsl 24 >> ???????? csinv?? w0, w0, wzr, cc >> ???????? lsr???? w0, w0, 24 >> >> Both alternatives are kept, so operands that are already in vector >> registers still use the single instruction with no transfers. >> >> Bootstrapped and regtested on aarch64-linux-gnu. >> >> Signed-off-by: Dhruv Chawla >> >> gcc/ChangeLog: >> >> ???????? * config/aarch64/aarch64-protos.h (aarch64_split_saturating_arith): >> ???????? New declaration. >> ???????? * config/aarch64/aarch64.cc (aarch64_split_saturating_arith): New >> ???????? function. >> ???????? * config/aarch64/aarch64.md (add3_compare0): Rename to ... >> ???????? (@add3_compare0): ... this. >> ???????? (*adds_shift_imm_): Rename to ... >> ???????? (@adds__imm_): ... this. >> ???????? (*subs_shift_imm_): Rename to ... >> ???????? (@subs__imm_): ... this. >> ???????? (sub3_compare1): Rename to... >> ???????? (@sub3_compare1): ... this. >> ???????? (sub3_compare1_imm): Rename to ... >> ???????? (@sub3_compare1_imm): ... this. >> ???????? * config/aarch64/aarch64-simd.md >> ???????? (s3): Restrict the vector >> ???????? pattern to VDQ_I, and use aarch64_split_saturating_arith in the >> ???????? GPI one. >> ???????? (aarch64_s3): Use >> ???????? aarch64_split_saturating_arith. >> ???????? (s3): New expanders for SHORT. >> ???????? (aarch64_s3): New patterns for SHORT. >> ???????? * config/aarch64/iterators.md (VSDQ_I_QI_HI): Delete unused >> ???????? iterator. >> >> gcc/testsuite/ChangeLog: >> >> ???????? * gcc.target/aarch64/neon/vqadd.c (test_vqaddb_s8, test_vqaddb_u8, >> ???????? test_vqaddh_s16, test_vqaddh_u16): Update test with new >> ???????? instruction sequence. >> ???????? * gcc.target/aarch64/neon/vqsub.c (test_vqsubb_s8, test_vqsubb_u8, >> ???????? test_vqsubh_s16, test_vqsubh_u16): Likewise. >> ???????? * gcc.target/aarch64/saturating_arithmetic_1.c: Likewise. >> ???????? * gcc.target/aarch64/saturating_arithmetic_2.c: Likewise. Drop >> ???????? xfail on the now-passing usub test. >> ???????? * gcc.target/aarch64/saturating-arithmetic-signed.c (sadd32, ssub32, >> ???????? sadd64, ssub64): Likewise. >> ???????? (sadd8, ssub8, sadd16, ssub16): New functions. >> ???????? * gcc.target/aarch64/scalar_intrinsics.c (test_vqaddh_s16, >> ???????? test_vqaddb_s8, test_vqsubh_s16, test_vqsubb_s8): Modify to take >> ???????? vector arguments to continue generating NEON instructions. >> --- >> ? gcc/config/aarch64/aarch64-protos.h?????????? |?? 2 + >> ? gcc/config/aarch64/aarch64-simd.md??????????? | 219 +++++++----------- >> ? gcc/config/aarch64/aarch64.cc???????????????? | 158 +++++++++++++ >> ? gcc/config/aarch64/aarch64.md???????????????? |? 10 +- >> ? gcc/config/aarch64/iterators.md?????????????? |?? 4 - >> ? gcc/testsuite/gcc.target/aarch64/neon/vqadd.c |? 36 +-- >> ? gcc/testsuite/gcc.target/aarch64/neon/vqsub.c |? 36 +-- >> ? .../aarch64/saturating-arithmetic-signed.c??? | 122 +++++++++- >> ? .../aarch64/saturating_arithmetic_1.c???????? |? 27 ++- >> ? .../aarch64/saturating_arithmetic_2.c???????? |? 28 +-- >> ? .../gcc.target/aarch64/scalar_intrinsics.c??? |? 16 +- >> ? 11 files changed, 439 insertions(+), 219 deletions(-) >> >> diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h >> index 262b3c441057..a5c87df9843c 100644 >> --- a/gcc/config/aarch64/aarch64-protos.h >> +++ b/gcc/config/aarch64/aarch64-protos.h >> @@ -1027,6 +1027,8 @@ bool aarch64_sve_prefetch_operand_p (rtx, machine_mode); >> ? bool aarch64_sve_struct_memory_operand_p (rtx); >> ? bool aarch64_sme_ldr_vnum_offset_p (rtx, rtx); >> ? rtx aarch64_simd_vect_par_cnst_half (machine_mode, int, bool); >> +void aarch64_split_saturating_arith (rtx_code, machine_mode, rtx, rtx, >> +??????????????????????????????????? rtx, rtx, rtx); >> ? rtx aarch64_gen_stepped_int_parallel (unsigned int, int, int); >> ? bool aarch64_stepped_int_parallel_p (rtx, int); >> ? bool aarch64_strided_registers_p (rtx *, unsigned int, unsigned int); >> diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md >> index 1d28c8f68f9a..3807f8e52889 100644 >> --- a/gcc/config/aarch64/aarch64-simd.md >> +++ b/gcc/config/aarch64/aarch64-simd.md >> @@ -6023,10 +6023,10 @@ >> ? ;; q >> >> ? (define_insn "s3" >> -? [(set (match_operand:VSDQ_I_QI_HI 0 "register_operand" "=w") >> -?????? (BINQOPS:VSDQ_I_QI_HI >> -???????? (match_operand:VSDQ_I_QI_HI 1 "register_operand" "w") >> -???????? (match_operand:VSDQ_I_QI_HI 2 "register_operand" "w")))] >> +? [(set (match_operand:VDQ_I 0 "register_operand" "=w") >> +?????? (BINQOPS:VDQ_I >> +???????? (match_operand:VDQ_I 1 "register_operand" "w") >> +???????? (match_operand:VDQ_I 2 "register_operand" "w")))] >> ??? "TARGET_SIMD" >> ??? "q\\t%0, %1, %2" >> ??? [(set_attr "type" "neon_q")] >> @@ -6074,84 +6074,12 @@ >> ?????? [ r?????? , r , JIr , &r ; *??????????????? , *??? , 8????? ] # >> ??? } >> ??? "&& reload_completed && GP_REGNUM_P (REGNO (operands[0]))" >> -? [(set (match_dup 0) >> -?????? (if_then_else:GPI >> -???????? (match_dup 4) >> -???????? (match_dup 5) >> -???????? (match_dup 6)))] >> +? [(const_int 0)] >> ??? { >> -??? if (REG_P (operands[2])) >> -????? { >> -????? rtx shift_constant = gen_int_mode (GET_MODE_BITSIZE (mode) - 1, >> -??????????????????????????????????????? mode); >> -????? auto limit = HOST_WIDE_INT_1U << (GET_MODE_BITSIZE (mode) - 1); >> -????? rtx limit_constant = gen_int_mode (limit, mode); >> -????? emit_insn (gen_ashr3 (operands[3], operands[2], shift_constant)); >> -????? emit_insn (gen_xor3 (operands[3], operands[3], limit_constant)); >> - >> -????? switch () >> -?????? { >> -?????? case SS_MINUS: >> -???????? emit_insn (gen_sub3_compare1 (operands[0], operands[1], >> -???????????????????????????????????????????? operands[2])); >> -?????? break; >> -?????? case SS_PLUS: >> -???????? emit_insn (gen_add3_compare0 (operands[0], operands[1], >> -???????????????????????????????????????????? operands[2])); >> -???????? break; >> -?????? default: >> -???????? gcc_unreachable (); >> -?????? } >> - >> -????? rtx ccin = gen_rtx_REG (E_CC_Vmode, CC_REGNUM); >> -????? switch () >> -?????? { >> -?????? case SS_PLUS: >> -???????? operands[4] = gen_rtx_NE (mode, ccin, const0_rtx); >> -???????? operands[5] = gen_rtx_NOT (mode, operands[3]); >> -???????? operands[6] = operands[0]; >> -???????? break; >> -?????? case SS_MINUS: >> -???????? operands[4] = gen_rtx_EQ (mode, ccin, const0_rtx); >> -???????? operands[5] = operands[0]; >> -???????? operands[6] = operands[3]; >> -???????? break; >> -?????? default: >> -???????? gcc_unreachable (); >> -?????? } >> -????? } >> -??? else >> -????? { >> -?????? auto imm = INTVAL (operands[2]); >> -?????? rtx neg_imm = gen_int_mode (-imm, mode); >> -?????? wide_int limit; >> - >> -?????? switch () >> -???????? { >> -???????? case SS_MINUS: >> -?????????? emit_insn (gen_sub3_compare1_imm (operands[0], operands[1], >> -?????????????????????????????????????????????????? operands[2], neg_imm)); >> -?????????? limit = imm >= 0 ? wi::min_value (mode, SIGNED) >> -??????????????????????????? : wi::max_value (mode, SIGNED); >> -?????????? break; >> -???????? case SS_PLUS: >> -?????????? emit_insn (gen_sub3_compare1_imm (operands[0], operands[1], >> -?????????????????????????????????????????????????? neg_imm, operands[2])); >> -?????????? limit = imm >= 0 ? wi::max_value (mode, SIGNED) >> -??????????????????????????? : wi::min_value (mode, SIGNED); >> -?????????? break; >> -???????? default: >> -?????????? gcc_unreachable (); >> -???????? } >> - >> -????? rtx sat_limit = immed_wide_int_const (limit, mode); >> -????? emit_insn (gen_rtx_SET (operands[3], sat_limit)); >> - >> -????? rtx ccin = gen_rtx_REG (E_CC_Vmode, CC_REGNUM); >> -????? operands[4] = gen_rtx_EQ (mode, ccin, const0_rtx); >> -????? operands[5] = operands[0]; >> -????? operands[6] = operands[3]; >> -????? } >> +??? aarch64_split_saturating_arith (, mode, operands[0], >> +?????????????????????????????????? operands[1], operands[2], operands[3], >> +?????????????????????????????????? NULL_RTX); >> +??? DONE; >> ??? } >> ? ) >> >> @@ -6171,62 +6099,85 @@ >> ?????? [ r?????? , r , JIr ; *??????????????? , *??? , 8????? ] # >> ??? } >> ??? "&& reload_completed && GP_REGNUM_P (REGNO (operands[0]))" >> -? [(set (match_dup 0) >> -?????? (if_then_else:GPI >> -???????? (match_dup 3) >> -???????? (match_dup 0) >> -???????? (match_dup 4)))] >> +? [(const_int 0)] >> ??? { >> +??? aarch64_split_saturating_arith (, mode, operands[0], >> +?????????????????????????????????? operands[1], operands[2], NULL_RTX, >> +?????????????????????????????????? NULL_RTX); >> +??? DONE; >> +? } >> +) >> >> -??? if (REG_P (operands[2])) >> -????? { >> -?????? switch () >> -???????? { >> -???????? case US_MINUS: >> -?????????? emit_insn (gen_sub3_compare1 (operands[0], operands[1], >> -?????????????????????????????????????????????? operands[2])); >> -?????????? break; >> -???????? case US_PLUS: >> -?????????? emit_insn (gen_add3_compare0 (operands[0], operands[1], >> -?????????????????????????????????????????????? operands[2])); >> -?????????? break; >> -???????? default: >> -?????????? gcc_unreachable (); >> -???????? } >> -????? } >> -??? else >> -????? { >> -?????? auto imm = UINTVAL (operands[2]); >> -?????? rtx neg_imm = gen_int_mode (-imm, mode); >> -?????? switch () >> -???????? { >> -???????? case US_MINUS: >> -?????????? emit_insn (gen_sub3_compare1_imm (operands[0], operands[1], >> -?????????????????????????????????????????????????? operands[2], neg_imm)); >> -?????????? break; >> -???????? case US_PLUS: >> -?????????? emit_insn (gen_sub3_compare1_imm (operands[0], operands[1], >> -?????????????????????????????????????????????????? neg_imm, operands[2])); >> -?????????? break; >> -???????? default: >> -?????????? gcc_unreachable (); >> -???????? } >> -????? } >> +;; Saturating arithmetic on 8 and 16-bit GPR operands.? As for SI and DI modes >> +;; above we would rather not pay for transfers to and from the FP registers, >> +;; and compute the result only in GPRs.? This is done through a series of left >> +;; and right shifts (see aarch64_split_saturating_arith in aarch64.cc for a >> +;; complete explanation).? For example, saturating unsigned addition becomes: >> +;; >> +;;?? lsl?????? w2, w0, 24 >> +;;?? adds????? w0, w2, w1, lsl 24 >> +;;?? csinv???? w0, w0, wzr, cc >> +;;?? lsr?????? w0, w0, 24 >> >> -??? rtx ccin = gen_rtx_REG (CCmode, CC_REGNUM); >> -??? switch () >> -????? { >> -????? case US_PLUS: >> -?????? operands[3] = gen_rtx_LTU (mode, ccin, const0_rtx); >> -?????? operands[4] = gen_int_mode (-1, mode); >> -?????? break; >> -????? case US_MINUS: >> -?????? operands[3] = gen_rtx_GEU (mode, ccin, const0_rtx); >> -?????? operands[4] = const0_rtx; >> -?????? break; >> -????? default: >> -?????? gcc_unreachable (); >> -????? } >> +(define_expand "s3" >> +? [(parallel >> +??? [(set (match_operand:SHORT 0 "register_operand") >> +???????? (UBINQOPS:SHORT (match_operand:SHORT 1 "register_operand") >> +???????????????????????? (match_operand:SHORT 2 "register_operand"))) >> +???? (clobber (scratch:SI)) >> +???? (clobber (reg:CC CC_REGNUM))])] >> +) >> + >> +(define_insn_and_split "aarch64_s3" >> +? [(set (match_operand:SHORT 0 "register_operand") >> +?????? (UBINQOPS:SHORT (match_operand:SHORT 1 "register_operand") >> +?????????????????????? (match_operand:SHORT 2 "register_operand"))) >> +?? (clobber (match_scratch:SI 3)) >> +?? (clobber (reg:CC CC_REGNUM))] >> +? "" >> +? {@ [ cons: =0, 1 , 2 , =3 ; attrs: type?????? , arch , length ] >> +???? [ w?????? , w , w , X? ; neon_q , simd , 4????? ] q\t%0, %1, %2 >> +???? [ r?????? , r , r , &r ; *???????????????? , *??? , 16???? ] # >> +? } >> +? "&& reload_completed && GP_REGNUM_P (REGNO (operands[0]))" >> +? [(const_int 0)] >> +? { >> +??? aarch64_split_saturating_arith (, mode, operands[0], >> +?????????????????????????????????? operands[1], operands[2], NULL_RTX, >> +?????????????????????????????????? operands[3]); >> +??? DONE; >> +? } >> +) >> + >> +(define_expand "s3" >> +? [(parallel >> +??? [(set (match_operand:SHORT 0 "register_operand") >> +???????? (SBINQOPS:SHORT (match_operand:SHORT 1 "register_operand") >> +???????????????????????? (match_operand:SHORT 2 "register_operand"))) >> +???? (clobber (scratch:SI)) >> +???? (clobber (scratch:SI)) >> +???? (clobber (reg:CC CC_REGNUM))])] >> +) >> + >> +(define_insn_and_split "aarch64_s3" >> +? [(set (match_operand:SHORT 0 "register_operand") >> +?????? (SBINQOPS:SHORT (match_operand:SHORT 1 "register_operand") >> +?????????????????????? (match_operand:SHORT 2 "register_operand"))) >> +?? (clobber (match_scratch:SI 3)) >> +?? (clobber (match_scratch:SI 4)) >> +?? (clobber (reg:CC CC_REGNUM))] >> +? "" >> +? {@ [ cons: =0, 1 , 2 , =3, =4 ; attrs: type?????? , arch , length ] >> +???? [ w?????? , w , w , X , X? ; neon_q , simd , 4????? ] q\t%0, %1, %2 >> +???? [ r?????? , r , r , &r, &r ; *???????????????? , *??? , 24???? ] # >> +? } >> +? "&& reload_completed && GP_REGNUM_P (REGNO (operands[0]))" >> +? [(const_int 0)] >> +? { >> +??? aarch64_split_saturating_arith (, mode, operands[0], >> +?????????????????????????????????? operands[1], operands[2], operands[4], >> +?????????????????????????????????? operands[3]); >> +??? DONE; >> ??? } >> ? ) >> >> diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc >> index 5f0556fd5169..811708f1bf4f 100644 >> --- a/gcc/config/aarch64/aarch64.cc >> +++ b/gcc/config/aarch64/aarch64.cc >> @@ -25554,6 +25554,164 @@ aarch64_simd_check_vect_par_cnst_half (rtx op, machine_mode mode, >> ??? return true; >> ? } >> >> +/* Split a saturating addition or subtraction into a sequence that computes >> +?? the result in general registers, rather than transferring the operands to >> +?? and from the FP registers to use [SU]QADD or [SU]QSUB. >> + >> +?? CODE is the saturating operation and MODE the mode of its operands.? DST is >> +?? the destination and OP1 and OP2 are the operands.? OP2 may be a constant only >> +?? when MODE is SImode or DImode.? LIMIT is a scratch register used to hold the >> +?? saturating limit (which only signed operations need) and TMP a second >> +?? scratch (which only QI and HI modes need).? Either may be NULL_RTX when the >> +?? operation does not require it. >> + >> +?? For SI and DI modes the flags set by ADDS or SUBS describe the operation >> +?? exactly, so the saturated result can be selected against the limit directly. >> +?? QI and HI mode values cannot overflow a W register, so shifting those up to >> +?? the top of the register first makes the flags describe the narrow >> +?? operation and at the same time discards the bits above the mode.? This saves >> +?? a separate extension.? */ >> + >> +void >> +aarch64_split_saturating_arith (rtx_code code, machine_mode mode, rtx dst, >> +?????????????????????????????? rtx op1, rtx op2, rtx limit, rtx tmp) >> +{ >> +? bool signed_p = (code == SS_PLUS || code == SS_MINUS); >> +? bool minus_p = (code == SS_MINUS || code == US_MINUS); >> + >> +? /* QI/HI modes have to be computed in SI mode.? */ >> +? int shift = 0; >> +? if (mode == QImode || mode == HImode) >> +??? { >> +????? /* The amount to left-shift by to reach the top of the register.? */ >> +????? shift = GET_MODE_BITSIZE ((machine_mode) SImode).to_constant () >> +???????????? - GET_MODE_BITSIZE (mode).to_constant (); >> +????? mode = SImode; >> +??? } >> + >> +? int bits = GET_MODE_BITSIZE (mode).to_constant (); >> + >> +? if (shift > 0) >> +??? { >> +????? gcc_assert (REG_P (op2) && tmp); >> +????? /* Refer to QI or HI mode operands using SI mode (i.e. W) registers.? The >> +??????? scratches are already SImode.? */ >> +????? dst = gen_rtx_REG (mode, REGNO (dst)); >> +????? op1 = gen_rtx_REG (mode, REGNO (op1)); >> +????? op2 = gen_rtx_REG (mode, REGNO (op2)); >> + >> +????? /* Only the first operand is shifted to the top of its register here as >> +??????? the add or subtract can take the shift of the second one as part of the >> +??????? instruction.? The result has to go in TMP rather than DST because DST >> +??????? is not earlyclobber so it may be the same register as OP2.? */ >> +????? emit_insn ( >> +?????? gen_rtx_SET (tmp, gen_rtx_ASHIFT (mode, op1, GEN_INT (shift)))); >> +????? op1 = tmp; >> +??? } >> + >> +? /* Work out the value to use when the operation saturates and emit the >> +???? flag-setting add or subtract.? The unsigned saturating value is 0 for minus >> +???? operations and all-ones for plus.? */ >> +? rtx saturated = minus_p ? const0_rtx : gen_int_mode (-1, mode); >> +? if (REG_P (op2)) >> +??? { >> +????? if (signed_p) >> +?????? { >> +???????? /* Signed operations use LIMIT as a scratch register.? */ >> +???????? gcc_assert (limit != NULL_RTX); >> + >> +???????? /* The signed saturating limit can be computed off the sign of OP1. >> +??????????? An overflowing SS_PLUS has SIGN (OP1) == SIGN (OP2) and an >> +??????????? overflowing SS_MINUS has SIGN (OP1) != SIGN (OP2).? For example, >> +??????????? for SI mode: >> + >> +????????????? OP1 >= 0: 0x00000000 ^ INT_MAX = INT_MAX >> +????????????? OP1 > + >> +??????????? ... and likewise for the other modes.? OP1 is used here to read the >> +??????????? sign bit as it has been shifted for QI/HI mode and the bits above >> +??????????? the mode would be undefined for OP2.? */ >> +???????? rtx sign_shift = GEN_INT (bits - 1); >> +???????? emit_insn ( >> +?????????? gen_rtx_SET (limit, gen_rtx_ASHIFTRT (mode, op1, sign_shift))); >> + >> +???????? /* SS_PLUS selects INT_MIN as CSINV computes ~LIMIT, so ~INT_MIN >> +??????????? becomes INT_MAX.? */ >> +???????? wide_int w = minus_p ? wi::max_value (mode, SIGNED) >> +????????????????????????????? : wi::min_value (mode, SIGNED); >> +???????? rtx mask = immed_wide_int_const (w, mode); >> +???????? emit_insn (gen_rtx_SET (limit, gen_rtx_XOR (mode, limit, mask))); >> + >> +???????? /* Generate ~LIMIT to match the CSINV pattern for SS_PLUS.? */ >> +???????? saturated = minus_p ? limit : gen_rtx_NOT (mode, limit); >> +?????? } >> + >> +????? /* Fold the shift of the second operand into the instruction for QI and HI >> +??????? modes.? */ >> +????? if (minus_p) >> +?????? emit_insn (shift > 0 ? gen_subs_imm (ASHIFT, mode, dst, op1, op2, >> +??????????????????????????????????????????? GEN_INT (shift)) >> +??????????????????????????? : gen_sub3_compare1 (mode, dst, op1, op2)); >> +????? else >> +?????? emit_insn (shift > 0 ? gen_adds_imm (ASHIFT, mode, dst, op2, >> +??????????????????????????????????????????? GEN_INT (shift), op1) >> +??????????????????????????? : gen_add3_compare0 (mode, dst, op1, op2)); >> +??? } >> +? else >> +??? { >> +????? /* A constant second operand.? Only reachable for SI and DI modes due to >> +??????? the QI/HI patterns requiring a register_operand.? */ >> +????? gcc_assert (shift == 0); >> +????? auto imm = INTVAL (op2); >> +????? rtx neg_imm = gen_int_mode (-imm, mode); >> + >> +????? /* Operand 2 sets the flags and operand 3 is added, and the pattern >> +??????? requires them to be negatives of each other.? Which way round they go >> +??????? selects SUBS or ADDS.? */ >> +????? rtx cmp_imm = minus_p ? op2 : neg_imm; >> +????? rtx add_imm = minus_p ? neg_imm : op2; >> +????? emit_insn (gen_sub3_compare1_imm (mode, dst, op1, cmp_imm, add_imm)); >> + >> +????? if (signed_p) >> +?????? { >> +???????? bool want_max = (imm >= 0) ^ minus_p; >> +???????? wide_int lim = want_max ? wi::max_value (mode, SIGNED) >> +???????????????????????????????? : wi::min_value (mode, SIGNED); >> +???????? emit_insn (gen_rtx_SET (limit, immed_wide_int_const (lim, mode))); >> +???????? saturated = limit; >> +?????? } >> +??? } >> + >> +? /* Select between the computed result and the saturating limit.? CSINV only >> +???? matches with the complement in the true arm, so that case tests for >> +???? overflow rather than for its absence.? */ >> +? rtx cc = gen_rtx_REG (signed_p ? E_CC_Vmode : CCmode, CC_REGNUM); >> +? if (GET_CODE (saturated) == NOT) >> +??? { >> +????? gcc_assert (code == SS_PLUS); >> +????? emit_insn (gen_rtx_SET ( >> +?????? dst, gen_rtx_IF_THEN_ELSE (mode, gen_rtx_NE (mode, cc, const0_rtx), >> +????????????????????????????????? saturated, dst))); >> +??? } >> +? else >> +??? { >> +????? rtx no_ovf = (signed_p? ? gen_rtx_EQ (mode, cc, const0_rtx) >> +?????????????????? : minus_p ? gen_rtx_GEU (mode, cc, const0_rtx) >> +???????????????????????????? : gen_rtx_LTU (mode, cc, const0_rtx)); >> +????? emit_insn ( >> +?????? gen_rtx_SET (dst, gen_rtx_IF_THEN_ELSE (mode, no_ovf, dst, saturated))); >> +??? } >> + >> +? /* Bring a narrow result back down.? */ >> +? if (shift > 0) >> +??? { >> +????? rtx amount = GEN_INT (shift); >> +????? rtx back = (signed_p ? gen_rtx_ASHIFTRT (mode, dst, amount) >> +????????????????????????? : gen_rtx_LSHIFTRT (mode, dst, amount)); >> +????? emit_insn (gen_rtx_SET (dst, back)); >> +??? } >> +} >> + >> ? /* Return a PARALLEL containing NELTS elements, with element I equal >> ???? to BASE + I * STEP.? */ >> >> diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md >> index 988b00e55df8..df70d15ae957 100644 >> --- a/gcc/config/aarch64/aarch64.md >> +++ b/gcc/config/aarch64/aarch64.md >> @@ -3023,7 +3023,7 @@ >> ??? DONE; >> ?? }) >> >> -(define_insn "add3_compare0" >> +(define_insn "@add3_compare0" >> ??? [(set (reg:CC_NZ CC_REGNUM) >> ???????? (compare:CC_NZ >> ????????? (plus:GPI (match_operand:GPI 1 "register_operand") >> @@ -3150,7 +3150,7 @@ >> ??? [(set_attr "type" "alus_sreg")] >> ? ) >> >> -(define_insn "*adds_shift_imm_" >> +(define_insn "@adds__imm_" >> ??? [(set (reg:CC_NZ CC_REGNUM) >> ???????? (compare:CC_NZ >> ????????? (plus:GPI (ASHIFT:GPI >> @@ -3166,7 +3166,7 @@ >> ??? [(set_attr "type" "alus_shift_imm")] >> ? ) >> >> -(define_insn "*subs_shift_imm_" >> +(define_insn "@subs__imm_" >> ??? [(set (reg:CC_NZ CC_REGNUM) >> ???????? (compare:CC_NZ >> ????????? (minus:GPI (match_operand:GPI 1 "register_operand" "r") >> @@ -3824,7 +3824,7 @@ >> ??? [(set_attr "type" "alus_sreg")] >> ? ) >> >> -(define_insn "sub3_compare1_imm" >> +(define_insn "@sub3_compare1_imm" >> ??? [(set (reg:CC CC_REGNUM) >> ???????? (compare:CC >> ?????????? (match_operand:GPI 1 "register_operand") >> @@ -3841,7 +3841,7 @@ >> ??? [(set_attr "type" "alus_imm")] >> ? ) >> >> -(define_insn "sub3_compare1" >> +(define_insn "@sub3_compare1" >> ??? [(set (reg:CC CC_REGNUM) >> ???????? (compare:CC >> ?????????? (match_operand:GPI 1 "aarch64_reg_or_zero" "rkZ") >> diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md >> index b788631a2e13..d63ef3450645 100644 >> --- a/gcc/config/aarch64/iterators.md >> +++ b/gcc/config/aarch64/iterators.md >> @@ -102,10 +102,6 @@ >> ? ;; integer modes; 64-bit scalar integer mode. >> ? (define_mode_iterator VSDQ_I_DI [V8QI V16QI V4HI V8HI V2SI V4SI V2DI DI]) >> >> -;; Advanced SIMD and scalar, 64 & 128-bit container; 8 and 16-bit scalar >> -;; integer modes. >> -(define_mode_iterator VSDQ_I_QI_HI [VDQ_I HI QI]) >> - >> ? ;; Double vector modes. >> ? (define_mode_iterator VD [V8QI V4HI V4HF V2SI V2SF V4BF]) >> >> diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vqadd.c b/gcc/testsuite/gcc.target/aarch64/neon/vqadd.c >> index 322f54c5a42f..20a58a1b48f5 100644 >> --- a/gcc/testsuite/gcc.target/aarch64/neon/vqadd.c >> +++ b/gcc/testsuite/gcc.target/aarch64/neon/vqadd.c >> @@ -117,40 +117,44 @@ TEST_UNIFORM_BINARY (vqaddq_s64, int64x2_t) >> >> ? /* >> ? ** test_vqaddb_u8: >> -** dup v([0-9]+)\.8b, w[0-9]+ >> -** dup v([0-9]+)\.8b, w[0-9]+ >> -** uqadd?????? b([0-9]+), (b\2, b\1|b\1, b\2) >> -** umov??????? w0, v\3\.b\[0\] >> +** lsl w([0-9]+), w0, 24 >> +** adds??????? w([0-9]+), w\1, w1, lsl 24 >> +** csinv?????? w([0-9]+), w\2, wzr, cc >> +** lsr w0, w\3, 24 >> ? ** ret >> ? */ >> ? TEST_UNIFORM_BINARY (vqaddb_u8, uint8_t) >> >> ? /* >> ? ** test_vqaddb_s8: >> -** dup v([0-9]+)\.8b, w[0-9]+ >> -** dup v([0-9]+)\.8b, w[0-9]+ >> -** sqadd?????? b([0-9]+), (b\2, b\1|b\1, b\2) >> -** umov??????? w0, v\3\.b\[0\] >> +** lsl w([0-9]+), w[01], 24 >> +** adds??????? w([0-9]+), w\1, w[01], lsl 24 >> +** asr w([0-9]+), w\1, 31 >> +** eor w([0-9]+), w\3, -2147483648 >> +** csinv?????? w([0-9]+), w\2, w\4, vc >> +** asr w0, w\5, 24 >> ? ** ret >> ? */ >> ? TEST_UNIFORM_BINARY (vqaddb_s8, int8_t) >> >> ? /* >> ? ** test_vqaddh_u16: >> -** dup v([0-9]+)\.4h, w[0-9]+ >> -** dup v([0-9]+)\.4h, w[0-9]+ >> -** uqadd?????? h([0-9]+), (h\2, h\1|h\1, h\2) >> -** umov??????? w0, v\3\.h\[0\] >> +** lsl w([0-9]+), w0, 16 >> +** adds??????? w([0-9]+), w\1, w1, lsl 16 >> +** csinv?????? w([0-9]+), w\2, wzr, cc >> +** lsr w0, w\3, 16 >> ? ** ret >> ? */ >> ? TEST_UNIFORM_BINARY (vqaddh_u16, uint16_t) >> >> ? /* >> ? ** test_vqaddh_s16: >> -** dup v([0-9]+)\.4h, w[0-9]+ >> -** dup v([0-9]+)\.4h, w[0-9]+ >> -** sqadd?????? h([0-9]+), (h\2, h\1|h\1, h\2) >> -** umov??????? w0, v\3\.h\[0\] >> +** lsl w([0-9]+), w[01], 16 >> +** adds??????? w([0-9]+), w\1, w[01], lsl 16 >> +** asr w([0-9]+), w\1, 31 >> +** eor w([0-9]+), w\3, -2147483648 >> +** csinv?????? w([0-9]+), w\2, w\4, vc >> +** asr w0, w\5, 16 >> ? ** ret >> ? */ >> ? TEST_UNIFORM_BINARY (vqaddh_s16, int16_t) >> diff --git a/gcc/testsuite/gcc.target/aarch64/neon/vqsub.c b/gcc/testsuite/gcc.target/aarch64/neon/vqsub.c >> index 52ac2f102ebc..48f3dd0a6642 100644 >> --- a/gcc/testsuite/gcc.target/aarch64/neon/vqsub.c >> +++ b/gcc/testsuite/gcc.target/aarch64/neon/vqsub.c >> @@ -117,40 +117,44 @@ TEST_UNIFORM_BINARY (vqsubq_s64, int64x2_t) >> >> ? /* >> ? ** test_vqsubb_u8: >> -** dup v([0-9]+)\.8b, w0 >> -** dup v([0-9]+)\.8b, w1 >> -** uqsub?????? b([0-9]+), b\1, b\2 >> -** umov??????? w0, v\3\.b\[0\] >> +** lsl w([0-9]+), w0, 24 >> +** subs??????? w([0-9]+), w\1, w1, lsl 24 >> +** csel??????? w([0-9]+), w\2, wzr, cs >> +** lsr w0, w\3, 24 >> ? ** ret >> ? */ >> ? TEST_UNIFORM_BINARY (vqsubb_u8, uint8_t) >> >> ? /* >> ? ** test_vqsubb_s8: >> -** dup v([0-9]+)\.8b, w0 >> -** dup v([0-9]+)\.8b, w1 >> -** sqsub?????? b([0-9]+), b\1, b\2 >> -** umov??????? w0, v\3\.b\[0\] >> +** lsl w([0-9]+), w0, 24 >> +** subs??????? w([0-9]+), w\1, w1, lsl 24 >> +** asr w([0-9]+), w\1, 31 >> +** eor w([0-9]+), w\3, 2147483647 >> +** csel??????? w([0-9]+), w\2, w\4, vc >> +** asr w0, w\5, 24 >> ? ** ret >> ? */ >> ? TEST_UNIFORM_BINARY (vqsubb_s8, int8_t) >> >> ? /* >> ? ** test_vqsubh_u16: >> -** dup v([0-9]+)\.4h, w0 >> -** dup v([0-9]+)\.4h, w1 >> -** uqsub?????? h([0-9]+), h\1, h\2 >> -** umov??????? w0, v\3\.h\[0\] >> +** lsl w([0-9]+), w0, 16 >> +** subs??????? w([0-9]+), w\1, w1, lsl 16 >> +** csel??????? w([0-9]+), w\2, wzr, cs >> +** lsr w0, w\3, 16 >> ? ** ret >> ? */ >> ? TEST_UNIFORM_BINARY (vqsubh_u16, uint16_t) >> >> ? /* >> ? ** test_vqsubh_s16: >> -** dup v([0-9]+)\.4h, w0 >> -** dup v([0-9]+)\.4h, w1 >> -** sqsub?????? h([0-9]+), h\1, h\2 >> -** umov??????? w0, v\3\.h\[0\] >> +** lsl w([0-9]+), w0, 16 >> +** subs??????? w([0-9]+), w\1, w1, lsl 16 >> +** asr w([0-9]+), w\1, 31 >> +** eor w([0-9]+), w\3, 2147483647 >> +** csel??????? w([0-9]+), w\2, w\4, vc >> +** asr w0, w\5, 16 >> ? ** ret >> ? */ >> ? TEST_UNIFORM_BINARY (vqsubh_s16, int16_t) >> diff --git a/gcc/testsuite/gcc.target/aarch64/saturating-arithmetic-signed.c b/gcc/testsuite/gcc.target/aarch64/saturating-arithmetic-signed.c >> index de652bf1d9e6..9702068a8a9f 100644 >> --- a/gcc/testsuite/gcc.target/aarch64/saturating-arithmetic-signed.c >> +++ b/gcc/testsuite/gcc.target/aarch64/saturating-arithmetic-signed.c >> @@ -8,7 +8,7 @@ >> >> ? /* >> ? ** sadd32: >> -**???? asr???? w([0-9]+), w1, 31 >> +**???? asr???? w([0-9]+), w0, 31 >> ? **???? eor???? w\1, w\1, -2147483648 >> ? **???? adds??? w([0-9]+), (?:w0, w1|w1, w0) >> ? **???? csinv?? w0, w\2, w\1, vc >> @@ -54,10 +54,10 @@ sadd32_imm2 (int32_t __a) >> >> ? /* >> ? ** ssub32: >> -**???? asr???? w([0-9]+), w1, 31 >> -**???? eor???? w\1, w\1, -2147483648 >> +**???? asr???? w([0-9]+), w0, 31 >> +**???? eor???? w([0-9]+), w\1, 2147483647 >> ? **???? subs??? w([0-9]+), w0, w1 >> -**???? csel??? w0, w\2, w\1, vc >> +**???? csel??? w0, w\3, w\2, vc >> ? **???? ret >> ? */ >> ? int32_t? __attribute__((noipa)) >> @@ -100,10 +100,10 @@ ssub32_imm2 (int32_t __a) >> >> ? /* >> ? ** sadd64: >> -**???? asr???? x([0-9]+), x1, 63 >> -**???? eor???? x\1, x\1, -9223372036854775808 >> +**???? asr???? x([0-9]+), x0, 63 >> +**???? eor???? x([0-9]+), x\1, -9223372036854775808 >> ? **???? adds??? x([0-9]+), (?:x0, x1|x1, x0) >> -**???? csinv?? x0, x\2, x\1, vc >> +**???? csinv?? x0, x\3, x\2, vc >> ? **???? ret >> ? */ >> ? int64_t? __attribute__((noipa)) >> @@ -146,10 +146,10 @@ sadd64_imm2 (int64_t __a) >> >> ? /* >> ? ** ssub64: >> -**???? asr???? x([0-9]+), x1, 63 >> -**???? eor???? x\1, x\1, -9223372036854775808 >> +**???? asr???? x([0-9]+), x0, 63 >> +**???? eor???? x([0-9]+), x\1, 9223372036854775807 >> ? **???? subs??? x([0-9]+), x0, x1 >> -**???? csel??? x0, x\2, x\1, vc >> +**???? csel??? x0, x\3, x\2, vc >> ? **???? ret >> ? */ >> ? int64_t? __attribute__((noipa)) >> @@ -190,6 +190,78 @@ ssub64_imm2 (int64_t __a) >> ??? return !overflow ? result : __a < 0 ? LONG_MIN : LONG_MAX; >> ? } >> >> +/* >> +** sadd8: >> +**???? lsl???? w([0-9]+), w[01], 24 >> +**???? asr???? w([0-9]+), w\1, 31 >> +**???? eor???? w([0-9]+), w\2, -2147483648 >> +**???? adds??? w([0-9]+), w\1, w[01], lsl 24 >> +**???? csinv?? w([0-9]+), w\4, w\3, vc >> +**???? asr???? w0, w\4, 24 >> +**???? ret >> +*/ >> +int8_t __attribute__((noipa)) >> +sadd8 (int8_t __a, int8_t __b) >> +{ >> +? int8_t sum; >> +? bool overflow = __builtin_add_overflow (__a, __b, &sum); >> +? return !overflow ? sum : __a < 0 ? SCHAR_MIN : SCHAR_MAX; >> +} >> + >> +/* >> +** ssub8: >> +**???? lsl???? w([0-9]+), w0, 24 >> +**???? asr???? w([0-9]+), w\1, 31 >> +**???? eor???? w([0-9]+), w\2, 2147483647 >> +**???? subs??? w([0-9]+), w\1, w1, lsl 24 >> +**???? csel??? w([0-9]+), w\4, w\3, vc >> +**???? asr???? w0, w\5, 24 >> +**???? ret >> +*/ >> +int8_t __attribute__((noipa)) >> +ssub8 (int8_t __a, int8_t __b) >> +{ >> +? int8_t result; >> +? bool overflow = __builtin_sub_overflow (__a, __b, &result); >> +? return !overflow ? result : __a < 0 ? SCHAR_MIN : SCHAR_MAX; >> +} >> + >> +/* >> +** sadd16: >> +**???? lsl???? w([0-9]+), w[01], 16 >> +**???? asr???? w([0-9]+), w\1, 31 >> +**???? eor???? w([0-9]+), w\2, -2147483648 >> +**???? adds??? w([0-9]+), w\1, w[01], lsl 16 >> +**???? csinv?? w([0-9]+), w\4, w\3, vc >> +**???? asr???? w0, w\5, 16 >> +**???? ret >> +*/ >> +int16_t __attribute__((noipa)) >> +sadd16 (int16_t __a, int16_t __b) >> +{ >> +? int16_t sum; >> +? bool overflow = __builtin_add_overflow (__a, __b, &sum); >> +? return !overflow ? sum : __a < 0 ? SHRT_MIN : SHRT_MAX; >> +} >> + >> +/* >> +** ssub16: >> +**???? lsl???? w([0-9]+), w0, 16 >> +**???? asr???? w([0-9]+), w\1, 31 >> +**???? eor???? w([0-9]+), w\2, 2147483647 >> +**???? subs??? w([0-9]+), w\1, w1, lsl 16 >> +**???? csel??? w([0-9]+), w\4, w\3, vc >> +**???? asr???? w0, w\5, 16 >> +**???? ret >> +*/ >> +int16_t __attribute__((noipa)) >> +ssub16 (int16_t __a, int16_t __b) >> +{ >> +? int16_t result; >> +? bool overflow = __builtin_sub_overflow (__a, __b, &result); >> +? return !overflow ? result : __a < 0 ? SHRT_MIN : SHRT_MAX; >> +} >> + >> ? int >> ? main (void) >> ? { >> @@ -266,5 +338,33 @@ main (void) >> ??? if (ssub64 (a_64, -b_64) != (a_64 + b_64)) >> ????? __builtin_abort (); >> >> +? int8_t sa = 4, sb = 70; >> +? if (sadd8 (sa, sb) != (int8_t) (sa + sb)) >> +??? __builtin_abort (); >> +? if (sadd8 (sa, SCHAR_MAX) != SCHAR_MAX) >> +??? __builtin_abort (); >> +? if (sadd8 (-sa, SCHAR_MIN) != SCHAR_MIN) >> +??? __builtin_abort (); >> +? if (ssub8 (sa, sb) != (int8_t) (sa - sb)) >> +??? __builtin_abort (); >> +? if (ssub8 (SCHAR_MIN, sb) != SCHAR_MIN) >> +??? __builtin_abort (); >> +? if (ssub8 (SCHAR_MAX, -sb) != SCHAR_MAX) >> +??? __builtin_abort (); >> + >> +? int16_t ha = 4, hb = 70; >> +? if (sadd16 (ha, hb) != (int16_t) (ha + hb)) >> +??? __builtin_abort (); >> +? if (sadd16 (ha, SHRT_MAX) != SHRT_MAX) >> +??? __builtin_abort (); >> +? if (sadd16 (-ha, SHRT_MIN) != SHRT_MIN) >> +??? __builtin_abort (); >> +? if (ssub16 (ha, hb) != (int16_t) (ha - hb)) >> +??? __builtin_abort (); >> +? if (ssub16 (SHRT_MIN, hb) != SHRT_MIN) >> +??? __builtin_abort (); >> +? if (ssub16 (SHRT_MAX, -hb) != SHRT_MAX) >> +??? __builtin_abort (); >> + >> ??? return 0; >> -} >> \ No newline at end of file >> +} >> diff --git a/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_1.c b/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_1.c >> index c73a024edec6..76313e4ef5bc 100644 >> --- a/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_1.c >> +++ b/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_1.c >> @@ -2,28 +2,31 @@ >> ? /* { dg-options "-O2 --save-temps -fno-schedule-insns2" } */ >> ? /* { dg-final { check-function-bodies "**" "" "" } } */ >> >> + >> ? /* >> ? ** uadd: >> -**???? dup???? v([0-9]+).8b, w[01] >> -**???? dup???? v([0-9]+).8b, w[01] >> -**???? uqadd?? b([0-9]+), (?:b\2, b\1|b\1, b\2) >> -**???? umov??? w0, v\3.b\[0\] >> +**???? lsl???? w([0-9]+), w0, 24 >> +**???? adds??? w([0-9]+), w\1, w1, lsl 24 >> +**???? csinv?? w([0-9]+), w\2, wzr, cc >> +**???? lsr???? w0, w\3, 24 >> ? **???? ret >> ? */ >> + >> ? /* >> ? ** uadd2: >> -**???? dup???? v([0-9]+).8b, w[01] >> -**???? dup???? v([0-9]+).8b, w[01] >> -**???? uqadd?? b([0-9]+), (?:b\2, b\1|b\1, b\2) >> -**???? umov??? w0, v\3.b\[0\] >> +**???? lsl???? w([0-9]+), w0, 24 >> +**???? adds??? w([0-9]+), w\1, w1, lsl 24 >> +**???? csinv?? w([0-9]+), w\2, wzr, cc >> +**???? lsr???? w0, w\3, 24 >> ? **???? ret >> ? */ >> + >> ? /* >> ? ** usub: >> -**???? dup???? v([0-9]+).8b, w[01] >> -**???? dup???? v([0-9]+).8b, w[01] >> -**???? uqsub?? b([0-9]+), b\1, b\2 >> -**???? umov??? w0, v\3.b\[0\] >> +**???? lsl???? w([0-9]+), w0, 24 >> +**???? subs??? w([0-9]+), w\1, w1, lsl 24 >> +**???? csel??? w([0-9]+), w\2, wzr, cs >> +**???? lsr???? w0, w\3, 24 >> ? **???? ret >> ? */ >> >> diff --git a/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_2.c b/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_2.c >> index dd0fefac6393..798a016c34dc 100644 >> --- a/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_2.c >> +++ b/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_2.c >> @@ -4,26 +4,28 @@ >> >> ? /* >> ? ** uadd: >> -**???? dup???? v([0-9]+).4h, w[01] >> -**???? dup???? v([0-9]+).4h, w[01] >> -**???? uqadd?? h([0-9]+), (?:h\2, h\1|h\1, h\2) >> -**???? umov??? w0, v\3.h\[0\] >> +**???? lsl???? w([0-9]+), w0, 16 >> +**???? adds??? w([0-9]+), w\1, w1, lsl 16 >> +**???? csinv?? w([0-9]+), w\2, wzr, cc >> +**???? lsr???? w0, w\3, 16 >> ? **???? ret >> ? */ >> + >> ? /* >> ? ** uadd2: >> -**???? dup???? v([0-9]+).4h, w[01] >> -**???? dup???? v([0-9]+).4h, w[01] >> -**???? uqadd?? h([0-9]+), (?:h\2, h\1|h\1, h\2) >> -**???? umov??? w0, v\3.h\[0\] >> +**???? lsl???? w([0-9]+), w0, 16 >> +**???? adds??? w([0-9]+), w\1, w1, lsl 16 >> +**???? csinv?? w([0-9]+), w\2, wzr, cc >> +**???? lsr???? w0, w\3, 16 >> ? **???? ret >> ? */ >> + >> ? /* >> -** usub: { xfail *-*-* } >> -**???? dup???? v([0-9]+).4h, w1 >> -**???? dup???? v([0-9]+).4h, w0 >> -**???? uqsub?? h([0-9]+), h\1, h\2 >> -**???? umov??? w0, v\3.h\[0\] >> +** usub: >> +**???? lsl???? w([0-9]+), w0, 16 >> +**???? subs??? w([0-9]+), w\1, w1, lsl 16 >> +**???? csel??? w([0-9]+), w\2, wzr, cs >> +**???? lsr???? w0, w\3, 16 >> ? **???? ret >> ? */ >> >> diff --git a/gcc/testsuite/gcc.target/aarch64/scalar_intrinsics.c b/gcc/testsuite/gcc.target/aarch64/scalar_intrinsics.c >> index 094aaff7b1c1..0122e7d12c76 100644 >> --- a/gcc/testsuite/gcc.target/aarch64/scalar_intrinsics.c >> +++ b/gcc/testsuite/gcc.target/aarch64/scalar_intrinsics.c >> @@ -366,17 +366,17 @@ test_vqadds_s32 (int32_t a, int32_t b) >> ? /* { dg-final { scan-assembler-times "\\tsqadd\\th\[0-9\]+, h\[0-9\]+" 1 } } */ >> >> ? int16_t >> -test_vqaddh_s16 (int16_t a, int16_t b) >> +test_vqaddh_s16 (int16x8_t a, int16x8_t b) >> ? { >> -? return vqaddh_s16 (a, b); >> +? return vqaddh_s16 (a[0], b[0]); >> ? } >> >> ? /* { dg-final { scan-assembler-times "\\tsqadd\\tb\[0-9\]+, b\[0-9\]+" 1 } } */ >> >> ? int8_t >> -test_vqaddb_s8 (int8_t a, int8_t b) >> +test_vqaddb_s8 (int8x16_t a, int8x16_t b) >> ? { >> -? return vqaddb_s8 (a, b); >> +? return vqaddb_s8 (a[0], b[0]); >> ? } >> >> ? /* { dg-final { scan-assembler-times "\\tsqdmlal\\ts\[0-9\]+, h\[0-9\]+, h\[0-9\]+" 1 } } */ >> @@ -809,17 +809,17 @@ test_vqsubs_s32 (int32_t a, int32_t b) >> ? /* { dg-final { scan-assembler-times "\\tsqsub\\th\[0-9\]+" 1 } } */ >> >> ? int16_t >> -test_vqsubh_s16 (int16_t a, int16_t b) >> +test_vqsubh_s16 (int16x8_t a, int16x8_t b) >> ? { >> -? return vqsubh_s16 (a, b); >> +? return vqsubh_s16 (a[0], b[0]); >> ? } >> >> ? /* { dg-final { scan-assembler-times "\\tsqsub\\tb\[0-9\]+" 1 } } */ >> >> ? int8_t >> -test_vqsubb_s8 (int8_t a, int8_t b) >> +test_vqsubb_s8 (int8x16_t a, int8x16_t b) >> ? { >> -? return vqsubb_s8 (a, b); >> +? return vqsubb_s8 (a[0], b[0]); >> ? } >> >> ? /* { dg-final { scan-assembler-times "\\tsshl\\td\[0-9\]+" 1 } } */ >> -- >> 2.43.0 > > Ping (https://gcc.gnu.org/pipermail/gcc-patches/2026-October/734465.html). > > -- > Regards, > Dhruv Ping (https://gcc.gnu.org/pipermail/gcc-patches/2026-October/734465.html). -- Regards, Dhruv From jakub@redhat.com Tue Nov 3 10:48:47 2026 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 3 Nov 2026 11:48:47 +0100 Subject: [PATCH v3 1/8] ranger: Fix the CLZ and CTZ ranges for signed arguments In-Reply-To: <20261103094334.43363-1-ktkachov@nvidia.com> References: <20261103094334.43363-1-ktkachov@nvidia.com> Message-ID: On Tue, Nov 03, 2026 at 10:43:27AM +0100, ktkachov@nvidia.com wrote: > From: Kyrylo Tkachov > > cfn_clz::fold_range computes the minimum of the result from the upper > bound of the argument, and cfn_ctz::fold_range computes the maximum of > the result from it. This is wrong for a signed argument with negative > values, because a negative value has the sign bit set. For > > _1 = .CLZ (x_4(D)); > _2 = _1 > 0; > > with int x_4(D), evrp computes > > Global Exported: _1 = [irange] int [1, 31] .CLZ/.CTZ is only defined for unsigned types, not for signed ones. The fact that __GIMPLE parsing doesn't reject all kinds of invalid stuff doesn't mean it is valid. else if (!TYPE_UNSIGNED (TREE_TYPE (args[0]))) { if (complain) error_at (ARG_LOCATION (0), "argument 1 in call to function " "%qE has signed type", fndecl); return false; } in c-common.cc rejects signed arguments to __builtin_clzg/__builtin_ctzg etc. (they are allowed (and required) for __builtin_ffsg and __builtin_clrsbg). Jakub From ebotcazou@libertysurf.fr Tue Nov 3 11:08:17 2026 From: ebotcazou@libertysurf.fr (Eric Botcazou) Date: Tue, 03 Nov 2026 12:08:17 +0100 Subject: [PATCH] sparc: Do not load from the frame in the delay slot of return In-Reply-To: <20261103083606.582600-1-stian@itx.no> References: <20261103083606.582600-1-stian@itx.no> Message-ID: <4776708.LvFx2qVVIh@fomalhaut> > The delay slot of the V9 return instruction is executed after the > register window has been restored, so a load from the function's own > frame placed there reads below the stack pointer, and a trap or a > signal taken on that instruction overwrites what it reads. Only > accept a memory reference in that slot when its address uses nothing > but incoming argument registers that the function does not modify. > > gcc/ChangeLog: > > PR target/128395 > * config/sparc/sparc.cc (mem_in_return_delay_safe_p): New function. > (eligible_for_restore_insn): Use it to reject a memory reference in > the delay slot of return that may address the frame. Thanks, but the fix is incomplete, see the two other problematic paths in eligible_for_return_delay. See also epilogue_renumber, where the problem is already partially addressed, so the fix probably belongs in that function. Note also that the explanation for what the code does should be written down in the commentary of the code instead of in the commit message. -- Eric Botcazou From stian@itx.no Tue Nov 3 11:18:40 2026 From: stian@itx.no (Stian Halseth) Date: Tue, 03 Nov 2026 12:18:40 +0100 Subject: [PATCH] sparc: Do not load from the frame in the delay slot of return In-Reply-To: <4776708.LvFx2qVVIh@fomalhaut> References: <20261103083606.582600-1-stian@itx.no> <4776708.LvFx2qVVIh@fomalhaut> Message-ID: <92f1560ebd8496e7342d092d6692f00a408c456c.camel@itx.no> Hi Eric, On Tue, 2026-11-03 at 12:08 +0100, Eric Botcazou wrote: > > The delay slot of the V9 return instruction is executed after the > > register window has been restored, so a load from the function's own > > frame placed there reads below the stack pointer, and a trap or a > > signal taken on that instruction overwrites what it reads.? Only > > accept a memory reference in that slot when its address uses nothing > > but incoming argument registers that the function does not modify. > > > > gcc/ChangeLog: > > > > PR target/128395 > > * config/sparc/sparc.cc (mem_in_return_delay_safe_p): New > > function. > > (eligible_for_restore_insn): Use it to reject a memory reference > > in > > the delay slot of return that may address the frame. > > Thanks, but the fix is incomplete, see the two other problematic paths in > eligible_for_return_delay.? See also epilogue_renumber, where the problem is > already partially addressed, so the fix probably belongs in that function. > Thanks, I'm looking at epilogue_renumber now, and testing a fix there instead. > Note also that the explanation for what the code does should be written down > in the commentary of the code instead of in the commit message. > Noted. /Stian -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 228 bytes Desc: This is a digitally signed message part URL: From chenzhongyao.hit@gmail.com Tue Nov 3 11:20:45 2026 From: chenzhongyao.hit@gmail.com (Zhongyao Chen) Date: Tue, 3 Nov 2026 19:20:45 +0800 Subject: [PATCH v2] RISC-V: Support per-LMUL vector permute cost In-Reply-To: References: <20261103024613.2727-1-chen.zhongyao@zte.com.cn> Message-ID: > > /* Apply LMUL cost scaling uniformly to all vector operations. > > Larger LMUL values have higher latency and register pressure, > > - which affects performance regardless of loop structure. */ > > - if (VECTOR_TYPE_P (vectype)) > > + which affects performance regardless of loop structure. > > + Permutes have already looked up their per-LMUL cost table in > > + builtin_vectorization_cost. */ > > + if (VECTOR_TYPE_P (vectype) && kind != vec_perm) > > { > > unsigned lmul_factor = get_lmul_cost_scaling (TYPE_MODE (vectype)); > > I would prefer to extend get_lmul_cost_scaling and add a 'kind' param. > > Then maybe > if (kind != vec_perm) > existing code (linear scaling); > else > lookup perm scaling; > > and... > > > case vec_perm: > > - return common_costs->permute_cost; > > + return is_frac_vlmul_p (TYPE_MODE (vectype)) > > + ? common_costs->permute_cost[LMUL_1] > > + : common_costs->permute_cost[get_vlmul (TYPE_MODE (vectype))]; > > ... here maybe just always use permute_cost[LMUL1]? I actually had a version like this: /* In riscv_builtin_vectorization_cost: */ case vec_perm: return common_costs->permute_cost[LMUL_1]; /* In adjust_stmt_cost: */ if (VECTOR_TYPE_P (vectype)) { if (kind == vec_perm) stmt_cost = common_costs->permute_cost[vlmul]; else stmt_cost *= get_lmul_cost_scaling (TYPE_MODE (vectype)); } I ended up changing it to the current version because the cost table already gives the full per-LMUL costs, so return permute_cost[LMUL_1] in builtin_vectorization_cost, but in adjust_stmt_cost, we dont use it, and yet lookup permute_cost again and overwrite the stmt_cost. that felt a bit weird. On the other hand, this way put the LMUL scaling adjust in one place, so both ok to me. your call. -- Regards, Zhongyao From stian@itx.no Tue Nov 3 11:54:16 2026 From: stian@itx.no (Stian Halseth) Date: Tue, 3 Nov 2026 12:54:16 +0100 Subject: [PATCH v2] sparc: Do not load from the frame in the delay slot of return In-Reply-To: <20261103083606.582600-1-stian@itx.no> References: <20261103083606.582600-1-stian@itx.no> Message-ID: <20261103115416.783351-1-stian@itx.no> The delay slot of the V9 return instruction is executed after the register window has been restored, so epilogue_renumber must reject any memory reference that may address the frame. gcc/ChangeLog: PR target/128395 * config/sparc/sparc.cc (epilogue_renumber): Reject a memory reference if the function has a frame or calls alloca. gcc/testsuite/ChangeLog: PR target/128395 * gcc.target/sparc/return-delay-mem.c: New test. Signed-off-by: Stian Halseth --- v2: Move the check into epilogue_renumber so that it covers every path in eligible_for_return_delay, and explain it in the code. gcc/config/sparc/sparc.cc | 9 +++- .../gcc.target/sparc/return-delay-mem.c | 53 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/sparc/return-delay-mem.c diff --git a/gcc/config/sparc/sparc.cc b/gcc/config/sparc/sparc.cc index 47783fdee..6de665062 100644 --- a/gcc/config/sparc/sparc.cc +++ b/gcc/config/sparc/sparc.cc @@ -8878,7 +8878,8 @@ output_v9branch (rtx op, rtx dest, int reg, int label, int reversed, return string; } -/* Return 1, if any of the registers of the instruction are %l[0-7] or %o[0-7]. +/* Return 1, if any of the registers of the instruction are %l[0-7] or %o[0-7], + or if it references memory that may be in the frame. Such instructions cannot be used in the delay slot of return insn on v9. If TEST is 0, also rename all %i[0-7] registers to their %o[0-7] counterparts. */ @@ -8940,6 +8941,12 @@ epilogue_renumber (rtx *where, int test) break; case MEM: + /* The delay slot of 'return' is executed after the register window + has been restored, so the frame is then below the stack pointer and + may be overwritten by a trap or a signal. Do not accept a memory + reference if the frame may contain something it can address. */ + if (sparc_apparent_frame_size > 0 || cfun->calls_alloca) + return 1; if (SPARC_STACK_BIAS && GET_CODE (XEXP (*where, 0)) == REG && REGNO (XEXP (*where, 0)) == HARD_FRAME_POINTER_REGNUM) diff --git a/gcc/testsuite/gcc.target/sparc/return-delay-mem.c b/gcc/testsuite/gcc.target/sparc/return-delay-mem.c new file mode 100644 index 000000000..3de34be14 --- /dev/null +++ b/gcc/testsuite/gcc.target/sparc/return-delay-mem.c @@ -0,0 +1,53 @@ +/* PR target/128395 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-stack-protector" } */ + +typedef unsigned long long u64; +struct cputimer { u64 utime, stime, sum_exec; }; +struct pct { int timers_active; }; +struct sig { struct cputimer cputimer; struct pct pct; }; +struct task { struct sig *signal; }; + +void start_sample (struct task *, u64 *); +void group_sample (struct task *, u64 *); + +static inline void +proc_sample (struct cputimer *c, u64 *samples) +{ + samples[0] = c->utime + c->stime; + samples[1] = c->utime; + samples[2] = c->sum_exec; +} + +u64 +sample_group (const int clkid, struct task *p, _Bool start) +{ + struct cputimer *cputimer = &p->signal->cputimer; + struct pct *pct = &p->signal->pct; + u64 samples[3]; + + if (!*(volatile int *) &pct->timers_active) + { + if (start) + start_sample (p, samples); + else + group_sample (p, samples); + } + else + proc_sample (cputimer, samples); + + return samples[clkid]; +} + +double fill (double *); + +double +fp_sample (int i) +{ + double v[3]; + + fill (v); + return v[i]; +} + +/* { dg-final { scan-assembler-not "return\[ \t\]+%i7\\+8\[ \t\]*\n\[ \t\]+ld" } } */ -- 2.43.0 From rdapp.gcc@gmail.com Tue Nov 3 11:58:07 2026 From: rdapp.gcc@gmail.com (Robin Dapp) Date: Tue, 03 Nov 2026 12:58:07 +0100 Subject: [PATCH v2] RISC-V: Support per-LMUL vector permute cost In-Reply-To: References: <20261103024613.2727-1-chen.zhongyao@zte.com.cn> Message-ID: > I actually had a version like this: > > /* In riscv_builtin_vectorization_cost: */ > case vec_perm: > return common_costs->permute_cost[LMUL_1]; > /* In adjust_stmt_cost: */ > if (VECTOR_TYPE_P (vectype)) > { > if (kind == vec_perm) > stmt_cost = common_costs->permute_cost[vlmul]; > else > stmt_cost *= get_lmul_cost_scaling (TYPE_MODE (vectype)); > } > > I ended up changing it to the current version because the cost table > already gives the full per-LMUL costs, so return permute_cost[LMUL_1] in > builtin_vectorization_cost, but in adjust_stmt_cost, we dont use it, > and yet lookup permute_cost again and overwrite the stmt_cost. that > felt a bit weird. > On the other hand, this way put the LMUL scaling adjust in one place, > so both ok to me. your call. Yes, not ideal either with looking up permute_cost twice but I'd prefer get_lmul_cost_scaling to continue to handle the scaling. We already get the lmul in there anyway and it has the linear scaling built in. Therefore it seems most natural to me, for now at least. Then we would always have: stmt_cost *= get_lmul_cost_scaling (kind, TYPE_MODE (vectype)) and have that determine the scaling per 'kind'. But of course not a big deal either way. -- Regards Robin From ktkachov@nvidia.com Tue Nov 3 12:02:24 2026 From: ktkachov@nvidia.com (Kyrylo Tkachov) Date: Tue, 3 Nov 2026 12:02:24 +0000 Subject: [PATCH v3 1/8] ranger: Fix the CLZ and CTZ ranges for signed arguments In-Reply-To: References: <20261103094334.43363-1-ktkachov@nvidia.com> Message-ID: <28A73712-621B-44A6-8184-AE953C8FFB0D@nvidia.com> > On 3 Nov 2026, at 11:48, Jakub Jelinek wrote: > > On Tue, Nov 03, 2026 at 10:43:27AM +0100, ktkachov@nvidia.com wrote: >> From: Kyrylo Tkachov >> >> cfn_clz::fold_range computes the minimum of the result from the upper >> bound of the argument, and cfn_ctz::fold_range computes the maximum of >> the result from it. This is wrong for a signed argument with negative >> values, because a negative value has the sign bit set. For >> >> _1 = .CLZ (x_4(D)); >> _2 = _1 > 0; >> >> with int x_4(D), evrp computes >> >> Global Exported: _1 = [irange] int [1, 31] > > .CLZ/.CTZ is only defined for unsigned types, not for signed ones. > The fact that __GIMPLE parsing doesn't reject all kinds of invalid > stuff doesn't mean it is valid. > else if (!TYPE_UNSIGNED (TREE_TYPE (args[0]))) > { > if (complain) > error_at (ARG_LOCATION (0), > "argument 1 in call to function " > "%qE has signed type", > fndecl); > return false; > } > in c-common.cc rejects signed arguments to __builtin_clzg/__builtin_ctzg > etc. (they are allowed (and required) for __builtin_ffsg and > __builtin_clrsbg). > Ok, in that case I?m fine with dropping this patch. The rest of the series should be unaffected. Thanks, Kyrill > Jakub From rguenther@suse.de Tue Nov 3 12:03:23 2026 From: rguenther@suse.de (Richard Biener) Date: Tue, 3 Nov 2026 13:03:23 +0100 (CET) Subject: [PATCH] libgfortran/103886 - enable 64-bit time_t on 32-bit glibc targets In-Reply-To: References: <4s9r5146-rqnp-057r-916r-86339nnrop71@fhfr.qr> Message-ID: On Mon, 2 Nov 2026, Harald Anlauf wrote: > Hi Richard! > > Am 31.10.26 um 7:57 PM schrieb Richard Biener: > > PR114895 reports that on 32-bit glibc targets with 32-bit time_t, stat() > > fails with EOVERFLOW once file timestamps are past 2038-01-19. > > The LIBGFOR_CHECK_WORKING_STAT configure test then fails, HAVE_WORKING_STAT > > is left undefined, and the build of io/unix.c breaks, since the > > !HAVE_WORKING_STAT code path there is only usable on MinGW. > > This can be reproduced e.g. by building the 32-bit multilib in a VM whose > > clock is set past 2038. > > > > Fix this by building libgfortran with 64-bit time_t where the C library > > supports it as requested by PR103886. A new LIBGFOR_CHECK_TIME_BITS64 > > check, run right after AC_SYS_LARGEFILE, tests whether time_t is already > > 64 bits wide and, if not, whether defining _TIME_BITS to 64 makes it so; > > in that case _TIME_BITS is defined to 64 in config.h. glibc only accepts > > _TIME_BITS=64 together with _FILE_OFFSET_BITS=64, so the check relies on > > the _FILE_OFFSET_BITS setting from AC_SYS_LARGEFILE and does nothing > > when configured with --disable-largefile. > > > > No exported libgfortran interface uses time_t, struct stat or other > > time-related C types; the time_t uses are all in internal helpers, so > > the library ABI does not change. Note that intrinsics returning or > > taking default-kind INTEGER values (e.g. TIME, or STAT with an INTEGER(4) > > array) still truncate to 32 bits; this change only makes the internal > > handling and the 64-bit variants correct past 2038. > > > > Bootstrap and regtest running on x86_64-unknown-linux-gnu. I'll see > > to also somehow test a native i?86 build (the x86_64 32bit multilib > > exercises it though). Meanwhile also tested natively on i?86-linux-gnu. > > Given the toplevel configure.ac --disable-year2038 > > and it's comments I've opted for selectively enabling libgfortran since > > it is one of the target libraries which suffers from issues but switching > > has no effects on its ABI (and it has that build failure recorded in > > PR114895). Also PR114065 reports Ada will fail to build with > > -D_TIME_BITS=64 ... > > > > OK for trunk? > > I am not really an expert in this area, but then nobody has stepped > in so far. > > I think this is OK. There are other (non-standard) intrinsics, like > TIME8(), which allow the user to handle date past the critical one. > Users with legacy codes will have to audit them anyway in the coming > 11 years... We may add a notice to the 17.x release notes with the > above info. > > You may wait for another 24h or so to see if someone else sees a > critical issue. I'll wait a bit longer for input, thanks for your review. Richard. > Thanks, > Harald > > > Thanks, > > Richard. > > > > PR libfortran/103886 > > PR libfortran/114895 > > libgfortran/ > > * acinclude.m4 (LIBGFOR_CHECK_TIME_BITS64): New check for > > 64-bit time_t support. > > * configure.ac: Invoke LIBGFOR_CHECK_TIME_BITS64. > > * configure: Regenerate. > > * config.h.in: Regenerate. > > --- > > libgfortran/acinclude.m4 | 25 ++++++++++++++++ > > libgfortran/config.h.in | 3 ++ > > libgfortran/configure | 62 ++++++++++++++++++++++++++++++++++++++++ > > libgfortran/configure.ac | 1 + > > 4 files changed, 91 insertions(+) > > > > diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4 > > index 118bed2b41b..890516a6aed 100644 > > --- a/libgfortran/acinclude.m4 > > +++ b/libgfortran/acinclude.m4 > > @@ -178,6 +178,31 @@ if test x"$libgfor_cv_have_crlf" = xyes; then > > AC_DEFINE(HAVE_CRLF, 1, [Define if CRLF is line terminator.]) > > fi]) > > > > +dnl Check for 64-bit time_t support on 32-bit platforms (Y2038 safety). > > +dnl glibc only accepts _TIME_BITS=64 together with _FILE_OFFSET_BITS=64, > > +dnl so rely on AC_SYS_LARGEFILE having put the latter into confdefs.h; > > +dnl with --disable-largefile the probe fails and _TIME_BITS is not set. > > +AC_DEFUN([LIBGFOR_CHECK_TIME_BITS64], [ > > + AC_REQUIRE([AC_SYS_LARGEFILE]) > > + AC_CACHE_CHECK([for 64-bit time_t], [libgfor_cv_time_bits64], [ > > + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ > > +#include > > +#include > > +int verify_y2038[(sizeof (time_t) >= 8) ? 1 : -1]; > > +]])], [libgfor_cv_time_bits64="already 64-bit"], [ > > + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ > > +#define _TIME_BITS 64 > > +#include > > +#include > > +int verify_y2038[(sizeof (time_t) >= 8) ? 1 : -1]; > > +]])], [libgfor_cv_time_bits64="yes"], [libgfor_cv_time_bits64="no"]) > > + ]) > > + ]) > > + if test "x$libgfor_cv_time_bits64" = xyes; then > > + AC_DEFINE([_TIME_BITS], [64], [Define to 64 to enable 64-bit time_t on > > 32-bit systems.]) > > + fi > > +]) > > + > > dnl Check whether the st_ino and st_dev stat fields taken together > > uniquely > > dnl identify the file within the system. This is should be true for POSIX > > dnl systems; it is known to be false on mingw32. > > diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in > > index 1d4bbfbb4a9..7a57b9a6208 100644 > > --- a/libgfortran/config.h.in > > +++ b/libgfortran/config.h.in > > @@ -1266,6 +1266,9 @@ > > /* Define to 1 if you need to in order for `stat' and other things to > > work. */ > > #undef _POSIX_SOURCE > > > > +/* Define to 64 to enable 64-bit time_t on 32-bit systems. */ > > +#undef _TIME_BITS > > + > > /* Define to the type of a signed integer type wide enough to hold a > > pointer, > > if such a type exists, and if the system does not define it. */ > > #undef intptr_t > > diff --git a/libgfortran/configure b/libgfortran/configure > > index c7d2c6666bf..6aeba503714 100755 > > --- a/libgfortran/configure > > +++ b/libgfortran/configure > > @@ -16987,6 +16987,68 @@ rm -rf conftest* > > fi > > > > > > + > > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit time_t" >&5 > > +$as_echo_n "checking for 64-bit time_t... " >&6; } > > +if ${libgfor_cv_time_bits64+:} false; then : > > + $as_echo_n "(cached) " >&6 > > +else > > + > > + cat confdefs.h - <<_ACEOF >conftest.$ac_ext > > +/* end confdefs.h. */ > > + > > +#include > > +#include > > +int verify_y2038[(sizeof (time_t) >= 8) ? 1 : -1]; > > + > > +int > > +main () > > +{ > > + > > + ; > > + return 0; > > +} > > +_ACEOF > > +if ac_fn_c_try_compile "$LINENO"; then : > > + libgfor_cv_time_bits64="already 64-bit" > > +else > > + > > + cat confdefs.h - <<_ACEOF >conftest.$ac_ext > > +/* end confdefs.h. */ > > + > > +#define _TIME_BITS 64 > > +#include > > +#include > > +int verify_y2038[(sizeof (time_t) >= 8) ? 1 : -1]; > > + > > +int > > +main () > > +{ > > + > > + ; > > + return 0; > > +} > > +_ACEOF > > +if ac_fn_c_try_compile "$LINENO"; then : > > + libgfor_cv_time_bits64="yes" > > +else > > + libgfor_cv_time_bits64="no" > > +fi > > +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > > + > > +fi > > +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > > + > > +fi > > +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgfor_cv_time_bits64" > > >&5 > > +$as_echo "$libgfor_cv_time_bits64" >&6; } > > + if test "x$libgfor_cv_time_bits64" = xyes; then > > + > > +$as_echo "#define _TIME_BITS 64" >>confdefs.h > > + > > + fi > > + > > + > > # Types > > ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" > > "$ac_includes_default" > > if test "x$ac_cv_type_off_t" = xyes; then : > > diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac > > index c50112df91c..95d986f1308 100644 > > --- a/libgfortran/configure.ac > > +++ b/libgfortran/configure.ac > > @@ -287,6 +287,7 @@ AC_SUBST(extra_ldflags_libgfortran) > > LIBGFOR_WORKING_GFORTRAN > > > > AC_SYS_LARGEFILE > > +LIBGFOR_CHECK_TIME_BITS64 > > > > # Types > > AC_TYPE_OFF_T > > > > base-commit: ada5b8f08739b26bf76558c9d5157cbbdd16c205 > > prerequisite-patch-id: e52d299db98b0892f974152cd9fa5f6859fec5b7 > > prerequisite-patch-id: 39da6ec3264bae454fa504f127cd5b80a0662f04 > > prerequisite-patch-id: 6d6c263a964425334ad8c2edd4dd89dcbff44bfe > > prerequisite-patch-id: 9a12a1706cbdff1edf8959682cd3cf9d900cd8f1 > > prerequisite-patch-id: b24057443c46d6979436cce479836178b19355de > > prerequisite-patch-id: d61bf2c4249ecd3d9da5eeda002d332ed3a8b4fd > > prerequisite-patch-id: 59cbeca60f782f48f945bc532c2235a50de6f0e5 > > prerequisite-patch-id: 8eddd3172e2007d0fc591124a56b372dfe83e683 > > prerequisite-patch-id: 862842dd3742066d039f66ffe9528bc490308c50 > > prerequisite-patch-id: e413d39d9af45f25483eaf229cf883c771444fbb > > prerequisite-patch-id: 2faef186ad1d816bb104d89638bc4cec6d863a46 > > prerequisite-patch-id: b32cceb111f4f57798e4b1d58822281e7bbaf25e > > prerequisite-patch-id: 08ff1c06921c5e253d911128be3a8ebb76137d3c > > prerequisite-patch-id: 72aa7ba47bd81909871a9e1a2e9de14f2cf42174 > > prerequisite-patch-id: 2ce10434bf0a7ab22e27ff177073e10b4b7d0d72 > > prerequisite-patch-id: 68776813e47d3d411bef2f4229a589711887ca6c > > prerequisite-patch-id: e286b2e30887f3f43a3458c7c9b3f8c8b513a91b > > prerequisite-patch-id: dc07b9957107f8b453a87ad64fd8477ae26e370c > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg) From jakub@redhat.com Tue Nov 3 12:03:15 2026 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 3 Nov 2026 13:03:15 +0100 Subject: [PATCH] c++, libstdc++: Implement remaning bits of C++26 P3795R2 Message-ID: Hi! The following patch on top of the https://gcc.gnu.org/pipermail/libstdc++/2026-October/068149.html https://gcc.gnu.org/pipermail/libstdc++/2026-October/068150.html https://gcc.gnu.org/pipermail/libstdc++/2026-November/068183.html patches implements the missing parts of the C++26 P3795R2 - Miscellaneous Reflection Cleanup paper, in particular implements std::meta::{is_{,nothrow_}applicable_type,apply_result} which couldn't be implemented earlier when the corresponding P1317R2 templates weren't implemented. So far lightly tested (on dg.exp=reflect/* plugin.exp), ok for trunk when the above patches are approved and it passes full bootstrap/regtest? 2026-11-03 Jakub Jelinek * metafns.gperf (enum metafn_code): Add METAFN_IS_APPLICABLE_TYPE, METAFN_IS_NOTHROW_APPLICABLE_TYPE and METAFN_APPLY_RESULT. (enum metafn_kind): Add METAFN_KIND_INFO_TINFO_TINFO. (is_applicable_type, is_nothrow_applicable_type, apply_result): New metafunctions. * reflect.cc (eval_is_applicable_type, eval_apply_result): New functions. (process_metafunction): Handle METAFN_IS_APPLICABLE_TYPE, METAFN_IS_NOTHROW_APPLICABLE_TYPE and METAFN_APPLY_RESULT. * metafns.h: Regenerate. * g++.dg/reflect/is_applicable1.C: New test. * g++.dg/reflect/is_applicable2.C: New test. * include/std/meta (std::meta::is_applicable_type, std::meta::is_nothrow_applicable_type, std::meta::apply_result): Declare. * src/c++23/std.cc.in (std::meta::is_applicable_type, std::meta::is_nothrow_applicable_type, std::meta::apply_result): New exports for C++26. --- a/gcc/cp/metafns.gperf 2026-04-09 18:09:10.962020816 +0200 +++ b/gcc/cp/metafns.gperf 2026-11-03 11:18:37.237427775 +0100 @@ -251,6 +251,9 @@ enum metafn_code { METAFN_UNWRAP_REF_DECAY, METAFN_TUPLE_SIZE, METAFN_TUPLE_ELEMENT, + METAFN_IS_APPLICABLE_TYPE, + METAFN_IS_NOTHROW_APPLICABLE_TYPE, + METAFN_APPLY_RESULT, METAFN_VARIANT_SIZE, METAFN_VARIANT_ALTERNATIVE, METAFN_TYPE_ORDER, @@ -377,6 +380,9 @@ enum metafn_kind { = (METAFN_KIND_ARGS_INFO << METAFN_KIND_SHIFT) | METAFN_KIND_RET_INFO, METAFN_KIND_INFO_TINFO = (METAFN_KIND_ARGS_TINFO << METAFN_KIND_SHIFT) | METAFN_KIND_RET_INFO, + METAFN_KIND_INFO_TINFO_TINFO + = (METAFN_KIND_ARGS_TINFO_TINFO << METAFN_KIND_SHIFT) + | METAFN_KIND_RET_INFO, METAFN_KIND_INFO_TINFO_REFLECTION_RANGET = (METAFN_KIND_ARGS_TINFO_REFLECTION_RANGET << METAFN_KIND_SHIFT) | METAFN_KIND_RET_INFO, @@ -699,6 +705,9 @@ unwrap_reference, METAFN_UNWRAP_REFERENC unwrap_ref_decay, METAFN_UNWRAP_REF_DECAY, METAFN_KIND_INFO_TINFO, tuple_size, METAFN_TUPLE_SIZE, METAFN_KIND_SIZE_T_TINFO, tuple_element, METAFN_TUPLE_ELEMENT, METAFN_KIND_INFO_SIZE_T_TINFO, +is_applicable_type, METAFN_IS_APPLICABLE_TYPE, METAFN_KIND_BOOL_TINFO_TINFO, +is_nothrow_applicable_type, METAFN_IS_NOTHROW_APPLICABLE_TYPE, METAFN_KIND_BOOL_TINFO_TINFO, +apply_result, METAFN_APPLY_RESULT, METAFN_KIND_INFO_TINFO_TINFO, variant_size, METAFN_VARIANT_SIZE, METAFN_KIND_SIZE_T_TINFO, variant_alternative, METAFN_VARIANT_ALTERNATIVE, METAFN_KIND_INFO_SIZE_T_TINFO, type_order, METAFN_TYPE_ORDER, METAFN_KIND_STRONG_ORDERING_TINFO_TINFO, --- a/gcc/cp/reflect.cc 2026-11-02 23:30:10.386273214 +0100 +++ b/gcc/cp/reflect.cc 2026-11-03 11:20:07.441220306 +0100 @@ -5810,6 +5810,38 @@ eval_tuple_element (location_t loc, cons fun); } +/* Process std::meta::is_{,nothrow_}applicable_type. */ + +static tree +eval_is_applicable_type (location_t loc, const constexpr_ctx *ctx, + tree fn, tree tuple, tree call, + bool *non_constant_p, tree *jump_target, tree fun, + const char *name) +{ + /* Create std::is_applicable::value. */ + tree args = make_tree_vec (2); + TREE_VEC_ELT (args, 0) = fn; + TREE_VEC_ELT (args, 1) = tuple; + return finish_library_value_trait (loc, ctx, name, args, call, + non_constant_p, jump_target, fun); +} + +/* Process std::meta::apply_result. */ + +static tree +eval_apply_result (location_t loc, const constexpr_ctx *ctx, tree fn, + tree tuple, tree call, bool *non_constant_p, + tree *jump_target, tree fun) +{ + /* Create std::apply_result::type. */ + tree args = make_tree_vec (2); + TREE_VEC_ELT (args, 0) = fn; + TREE_VEC_ELT (args, 1) = tuple; + return finish_library_type_trait (loc, ctx, "apply_result", + args, call, non_constant_p, jump_target, + fun); +} + /* Process std::meta::variant_size. Returns: variant_size_v, where T is the type represented by dealias(type). */ @@ -8725,6 +8757,17 @@ process_metafunction (const constexpr_ct case METAFN_TUPLE_ELEMENT: return eval_tuple_element (loc, ctx, expr, h1, call, non_constant_p, jump_target, fun); + case METAFN_IS_APPLICABLE_TYPE: + return eval_is_applicable_type (loc, ctx, h, h1, call, + non_constant_p, jump_target, fun, + "is_applicable"); + case METAFN_IS_NOTHROW_APPLICABLE_TYPE: + return eval_is_applicable_type (loc, ctx, h, h1, call, + non_constant_p, jump_target, fun, + "is_nothrow_applicable"); + case METAFN_APPLY_RESULT: + return eval_apply_result (loc, ctx, h, h1, call, + non_constant_p, jump_target, fun); case METAFN_VARIANT_SIZE: return eval_variant_size (loc, ctx, h, call, non_constant_p, jump_target, fun); --- a/gcc/testsuite/g++.dg/reflect/is_applicable1.C 2026-11-03 11:59:38.252991791 +0100 +++ b/gcc/testsuite/g++.dg/reflect/is_applicable1.C 2026-11-03 12:29:56.933202842 +0100 @@ -0,0 +1,180 @@ +// { dg-do compile { target c++26 } } +// { dg-additional-options "-freflection" } +// Test std::meta::is_{,nothrow_}applicable_type and std::meta::apply_result. + +#include +#include +#include +#include +#include + +template +constexpr void +check_apply () +{ + constexpr bool callable = (V > 0); + constexpr bool noex = (V > 1); + + static_assert (is_applicable_type (^^Fn, ^^Tuple) == callable); + static_assert (is_nothrow_applicable_type (^^Fn, ^^Tuple) == noex); + if constexpr (callable) + static_assert (is_same_type (^^Res, apply_result (^^Fn, ^^Tuple))); +} + +struct Throw +{ + Throw (float) {} +}; + +template +T f (T t, U) noexcept (Noex) +{ + return t; +} + +template