diff --git a/MAINTAINERS b/MAINTAINERS
index 44367b27b415cb327e17f954fee27c19be16d04a..c423dd6e78743786b5a7f5816fb50da98531df37 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -641,6 +641,7 @@ H.J. Lu                         hjl             <hjl.tools@gmail.com>
 Xiong Hu Luo                    -               <luoxhu@gcc.gnu.org>
 Bin Bin Lv                      shlb            <shlb@linux.ibm.com>
 Christophe Lyon                 clyon           <christophe.lyon@arm.com>
+Jin Ma                          majin           <jinma@linux.alibaba.com>
 Jun Ma                          junma           <junma@linux.alibaba.com>
 Andrew MacLeod                  -               <amacleod@redhat.com>
 Luis Machado                    luisgpm         <luisgpm@br.ibm.com>
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4665edc255981956376441483a4a41cb49ae1981..a73c1a165003283e84e22cb4fdb7e3744ad56a54 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,784 @@
+2025-02-04  Andi Kleen  <ak@gcc.gnu.org>
+
+	* doc/invoke.texi: Document file cache tunables.
+	* params.opt: Move auto tuning description to lines.
+
+2025-02-04  Ilya Leoshkevich  <iii@linux.ibm.com>
+
+	* config/s390/s390.cc (print_operand): Remove the no longer
+	necessary 31-bit and weak symbol handling.
+	* config/s390/s390.md (*movdi_64): Do not use @PLT with larl.
+	(*movsi_larl): Likewise.
+	(main_base_64): Likewise.
+	(reload_base_64): Likewise.
+
+2025-02-04  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/117113
+	* gimple-loop-jam.cc (unroll_jam_possible_p): Detect when
+	we cannot handle virtual SSA update.
+
+2025-02-04  Andrew Pinski  <quic_apinski@quicinc.com>
+
+	PR middle-end/116926
+	* optabs-query.cc (find_widening_optab_handler_and_mode): Fix
+	limit for `vec-mode -> scalar-mode` case.
+
+2025-02-04  Richard Biener  <rguenther@suse.de>
+
+	PR rtl-optimization/117611
+	* combine.cc (simplify_shift_const_1): Bail if not
+	scalar int mode.
+
+2025-02-04  Richard Biener  <rguenther@suse.de>
+
+	PR lto/113207
+	* ipa-free-lang-data.cc (free_lang_data_in_type): First drop
+	const/volatile qualifiers from function argument types,
+	then build a simplified type.
+
+2025-02-03  Uros Bizjak  <ubizjak@gmail.com>
+
+	* config/i386/i386.md (*sibcall_pop_memory):
+	Disable for TARGET_INDIRECT_BRANCH_REGISTER
+	* config/i386/predicates.md (call_insn_operand): Enable when
+	"satisfies_constraint_Bw (op)" is true, instead of open-coding
+	constraint here.
+	(sibcall_insn_operand): Ditto with "satisfies_constraint_Bs (op)"
+
+2025-02-03  Richard Sandiford  <richard.sandiford@arm.com>
+
+	* config/aarch64/aarch64.cc (aarch64_choose_vector_init_constant):
+	New function, split out from...
+	(aarch64_expand_vector_init_fallback): ...here.  Use a bit-
+	reversed increment to find a constant index.  Add support for
+	stepped constants.
+
+2025-02-03  John David Anglin  <danglin@gcc.gnu.org>
+
+	PR rtl-optimization/117248
+	* config/pa/predicates.md (r25_operand): New predicate.
+	(r26_operand): Likewise.
+	* config/pa/pa.md: Use match_operand for r25 and r26 hard
+	register operands in mult, div, udiv, mod and umod millicode
+	patterns.
+
+2025-02-03  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/118717
+	* tree-ssa-phiopt.cc (cond_if_else_store_replacement_1):
+	Do not common stores referencing abnormal SSA names.
+	* tree-ssa-sink.cc (sink_common_stores_to_bb): Likewise.
+
+2025-02-03  Andi Kleen  <ak@gcc.gnu.org>
+
+	* input.cc (check_line): New.
+	(test_replacement): New function to test line caching.
+	(input_cc_tests): Call test_replacement
+
+2025-02-03  Andi Kleen  <ak@gcc.gnu.org>
+
+	PR preprocessor/118168
+	* input.cc (file_cache_slot::get_next_line): Implement
+	dynamic sizing of m_line_record based on input length.
+	* params.opt: (param_file_cache_lines): Set to 0 to size
+	dynamically.
+
+2025-02-03  Andi Kleen  <ak@gcc.gnu.org>
+
+	PR preprocessor/118168
+	* input.cc (total_lines_num): Remove.
+	(file_cache_slot::evict): Ditto.
+	(file_cache_slot::create): Ditto.
+	(file_cache_slot::set_content): Ditto.
+	(file_cache_slot::file_cache_slot): Ditto.
+	(file_cache_slot::dump): Ditto.
+
+2025-02-03  Andi Kleen  <ak@gcc.gnu.org>
+
+	PR preprocessor/118168
+	* input.cc (file_cache_slot::get_next_line): Use new algorithm
+	to maintain
+	(file_cache_slot::read_line_num): Use binary search for lookup.
+
+2025-02-03  Andi Kleen  <ak@gcc.gnu.org>
+
+	PR preprocessor/118168
+	* input.cc (file_cache::tune): New function.
+	* input.h (class file_cache): Make tunables non const.
+	* params.opt: Add new tunables.
+	* toplev.cc (toplev::main): Initialize input buffer context
+	tunables.
+
+2025-02-02  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/117411
+	* doc/gm2.texi (Exception handling): New section.
+	(The ISO system module): Add description of COFF_T.
+	(Assembler language): Tidy up last sentance.
+
+2025-02-02  Lewis Hyatt  <lhyatt@gmail.com>
+
+	PR middle-end/115913
+	* optc-save-gen.awk (cl_optimization_compare): Skip options with
+	CL_WARNING flag.
+
+2025-02-01  H.J. Lu  <hjl.tools@gmail.com>
+
+	PR target/118713
+	* config/i386/i386-expand.cc (ix86_expand_call): Change "if
+	(TARGET_X32 ...)" back to "else if (TARGET_X32 ...)".
+
+2025-02-01  H.J. Lu  <hjl.tools@gmail.com>
+
+	PR target/118713
+	* config/i386/constraints.md (Bs): Always disable if
+	TARGET_INDIRECT_BRANCH_REGISTER is true.
+	(Bw): Likewise.
+	* config/i386/i386-expand.cc (ix86_expand_call): Force indirect
+	call via register for x32 GOT slot call if
+	TARGET_INDIRECT_BRANCH_REGISTER is true.
+	* config/i386/i386-protos.h (ix86_nopic_noplt_attribute_p): New.
+	* config/i386/i386.cc (ix86_nopic_noplt_attribute_p): Make it
+	global.
+	* config/i386/i386.md (*call_got_x32): Disable indirect call via
+	memory for TARGET_INDIRECT_BRANCH_REGISTER.
+	(*call_value_got_x32): Likewise.
+	(*sibcall_value_pop_memory): Likewise.
+	* config/i386/predicates.md (constant_call_address_operand):
+	Return false if both TARGET_INDIRECT_BRANCH_REGISTER and
+	ix86_nopic_noplt_attribute_p are true.
+
+2025-02-01  David Malcolm  <dmalcolm@redhat.com>
+
+	* libsarifreplay.cc (sarif_replayer::handle_run_obj): Pass run to
+	handle_result_obj.
+	(sarif_replayer::handle_result_obj): Add run_obj param and pass it
+	to handle_location_object and handle_thread_flow_object.
+	(sarif_replayer::handle_thread_flow_object): Add run_obj param and
+	pass it to handle_thread_flow_location_object.
+	(sarif_replayer::handle_thread_flow_location_object): Add run_obj
+	param and pass it to handle_location_object.
+	(sarif_replayer::handle_location_object): Add run_obj param and
+	pass it to handle_logical_location_object.
+	(sarif_replayer::handle_logical_location_object): Add run_obj
+	param.  If the run_obj is non-null and has "logicalLocations",
+	then use these "cached" logical locations if we see an "index"
+	property, as per §3.33.3
+
+2025-02-01  Jeff Law  <jlaw@ventanamicro.com>
+
+	PR tree-optimization/114277
+	* match.pd (a * (a || b) -> a): New pattern.
+	(a * !(a || b) -> 0): Likewise.
+
+2025-01-31  Jakub Jelinek  <jakub@redhat.com>
+
+	PR ipa/117432
+	* ipa-icf-gimple.cc (func_checker::compare_asm_inputs_outputs):
+	Also return_false if operands have incompatible types.
+	(func_checker::compare_gimple_call): Check fntype1 vs. fntype2
+	compatibility for all non-internal calls and assume fntype1 and
+	fntype2 are non-NULL for those.  For calls to non-prototyped
+	calls or for stdarg_p functions after the last named argument (if any)
+	check type compatibility of call arguments.
+
+2025-01-31  Vladimir N. Makarov  <vmakarov@redhat.com>
+
+	PR rtl-optimization/116234
+	* lra-constraints.cc (multiple_insn_refs_p): New function.
+	(curr_insn_transform): Use it.
+
+2025-01-31  Richard Biener  <rguenther@suse.de>
+
+	PR debug/100530
+	* dwarf2out.cc (modified_type_die): Do not claim we handle
+	address-space qualification with dwarf_qual_info[].
+
+2025-01-31  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/118689
+	PR modula2/115032
+	* tree-ssa-loop-niter.cc (build_cltz_expr): Return NULL_TREE if fn is
+	NULL and use_ifn is false.
+
+2025-01-31  Richard Biener  <rguenther@suse.de>
+
+	* tree-vect-loop.cc (vect_analyze_loop_operations): Only
+	call vectorizable_lc_phi when not PURE_SLP.
+	(vectorizable_reduction): Do not claim having handled
+	the inner loop LC PHI for outer loop vectorization.
+
+2025-01-30  Georg-Johann Lay  <avr@gjlay.de>
+
+	* config/avr/builtins.def (STRLEN_FLASH, STRLEN_FLASHX)
+	(STRLEN_MEMX): New DEF_BUILTIN's.
+	* config/avr/avr.cc (avr_ftype_strlen): New static function.
+	(avr_builtin_supported_p): New built-ins are not for AVR_TINY.
+	(avr_init_builtins) <strlen_flash_node, strlen_flashx_node,
+	strlen_memx_node>: Provide new fntypes.
+	(avr_fold_builtin) [AVR_BUILTIN_STRLEN_FLASH]
+	[AVR_BUILTIN_STRLEN_FLASHX, AVR_BUILTIN_STRLEN_MEMX]: Fold if
+	possible.
+	* doc/extend.texi (AVR Built-in Functions): Document
+	__builtin_avr_strlen_flash, __builtin_avr_strlen_flashx,
+	__builtin_avr_strlen_memx.
+
+2025-01-30  Georg-Johann Lay  <avr@gjlay.de>
+
+	* config/avr/builtins.def (AVR_FIRST_C_ONLY_BUILTIN_ID): New macro.
+	* config/avr/avr-protos.h (avr_builtin_supported_p): New.
+	* config/avr/avr.cc (avr_builtin_supported_p): New function.
+	(avr_init_builtins): Only provide a built-in when it is supported.
+	* config/avr/avr-c.cc (avr_cpu_cpp_builtins): Only define the
+	__BUILTIN_AVR_<NAME> build-in defines when the associated built-in
+	function is supported.
+	* doc/extend.texi (AVR Built-in Functions): Add a note that
+	following built-ins are supported for only for GNU-C.
+
+2025-01-30  Jakub Jelinek  <jakub@redhat.com>
+	    Stefan Schulze Frielinghaus  <stefansf@gcc.gnu.org>
+
+	PR target/118696
+	* config/s390/vector.md (*vec_cmpgt<mode><mode>_nocc_emu,
+	*vec_cmpgtu<mode><mode>_nocc_emu): Duplicate the first rather than
+	second V2DImode element.
+
+2025-01-30  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/118695
+	* expr.cc (expand_expr_real_1): When expanding a MEM_REF
+	to a non-MEM by committing it to a stack temporary make
+	sure to handle misaligned accesses correctly.
+
+2025-01-30  Tobias Burnus  <tburnus@baylibre.com>
+
+	* gimplify.cc (gimplify_call_expr): For OpenMP's append_args clause
+	processed by 'omp dispatch', update for internal-representation
+	changes; fix handling of hidden arguments, add some comments and
+	handle Fortran's value dummy and optional/pointer/allocatable actual
+	args.
+
+2025-01-30  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/118692
+	* expr.cc (expand_expr_real_1): When expanding a MEM_REF
+	as BIT_FIELD_REF avoid large offsets for accesses not
+	overlapping the base object.
+
+2025-01-30  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/114052
+	* tree-ssa-loop-niter.cc (maybe_lower_iteration_bound): Check
+	for infinite subloops we might not exit.
+
+2025-01-30  Richard Sandiford  <richard.sandiford@arm.com>
+
+	PR rtl-optimization/118320
+	* pair-fusion.cc (pair_fusion_bb_info::fuse_pair): Commonize
+	the merge of input_uses and return early if it fails.
+
+2025-01-29  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/118010
+	PR modula2/118183
+	PR modula2/116073
+	* doc/gm2.texi (-fm2-file-offset-bits=): Change the default size
+	description to CSSIZE_T.
+	Add COFF_T to the list of data types exported by SYSTEM.def.
+
+2025-01-29  Richard Sandiford  <richard.sandiford@arm.com>
+
+	PR rtl-optimization/118429
+	* pair-fusion.cc (latest_hazard_before): Add an extra parameter
+	to say whether the instruction is a load or a store.  If the
+	instruction is not a load or store and has memory side effects,
+	prevent it from being moved earlier.
+	(pair_fusion::find_trailing_add): Update call accordingly.
+	(pair_fusion_bb_info::fuse_pair): If the trailng addition had
+	a memory side-effect, use a tombstone to preserve it.
+
+2025-01-29  Georg-Johann Lay  <avr@gjlay.de>
+
+	* config/avr/avr.md (*negsi2.libgcc): New insn.
+
+2025-01-29  Yoshinori Sato  <ysato@users.sourceforge.jp>
+
+	* config/rx/constraints.md (Q): Also check that the address
+	passes rx_is_restricted_memory-address.
+
+2025-01-29  Andrew Pinski  <quic_apinski@quicinc.com>
+
+	PR tree-optimization/118505
+	* gimple-ssa-split-paths.cc (poor_ifcvt_pred): Return
+	true for trapping statements.
+
+2025-01-29  Andrew Pinski  <quic_apinski@quicinc.com>
+
+	* gimple-ssa-split-paths.cc (poor_ifcvt_candidate_code): Remove CALL_EXPR handling.
+
+2025-01-29  Martin Jambor  <mjambor@suse.cz>
+	    Michal Jireš  <mjires@suse.cz>
+
+	PR tree-optimization/117892
+	* tree-ssa-dse.cc (dse_optimize_call): Leave control-altering
+	noreturn calls alone.
+
+2025-01-29  Pan Li  <pan2.li@intel.com>
+
+	PR target/117688
+	* config/riscv/riscv.cc (riscv_expand_sstrunc): Leverage the helper
+	riscv_extend_to_xmode_reg with SIGN_EXTEND.
+
+2025-01-29  Pan Li  <pan2.li@intel.com>
+
+	PR target/117688
+	* config/riscv/riscv.cc (riscv_expand_sssub): Leverage the helper
+	riscv_extend_to_xmode_reg with SIGN_EXTEND.
+
+2025-01-29  Pan Li  <pan2.li@intel.com>
+
+	PR target/117688
+	* config/riscv/riscv.cc (riscv_expand_ssadd): Leverage the helper
+	riscv_extend_to_xmode_reg with SIGN_EXTEND.
+
+2025-01-29  Pan Li  <pan2.li@intel.com>
+
+	* config/riscv/riscv.cc (riscv_gen_zero_extend_rtx): Rename from ...
+	(riscv_extend_to_xmode_reg): Rename to and add rtx_code for
+	zero/sign extend if non-Xmode.
+	(riscv_expand_usadd): Leverage the renamed function with ZERO_EXTEND.
+	(riscv_expand_ussub): Ditto.
+
+2025-01-29  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/118684
+	* expr.cc (expand_expr_real_1): When creating a stack local
+	during expansion of a handled component, when the base is
+	a SSA_NAME use its type alignment and avoid calling
+	get_object_alignment.
+
+2025-01-28  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/118684
+	* expr.cc (expand_expr_real_1): When expanding a reference
+	based on a register and we end up needing a MEM make sure
+	that's aligned as the original reference required.
+
+2025-01-28  David Malcolm  <dmalcolm@redhat.com>
+
+	* input.cc (file_cache_slot::dump): Show indices within
+	m_line_record when dumping entries.
+
+2025-01-28  David Malcolm  <dmalcolm@redhat.com>
+
+	PR other/118675
+	* diagnostic-format-sarif.cc: Define INCLUDE_STRING.
+	(escape_braces): New.
+	(set_string_property_escaping_braces): New.
+	(sarif_builder::make_message_object): Escape braces in the "text"
+	property.
+	(sarif_builder::make_message_object_for_diagram): Likewise, and
+	for the "markdown" property.
+	(sarif_builder::make_multiformat_message_string): Likewise for the
+	"text" property.
+	(xelftest::test_message_with_braces): New.
+	(selftest::diagnostic_format_sarif_cc_tests): Call it.
+
+2025-01-28  Richard Sandiford  <richard.sandiford@arm.com>
+
+	PR tree-optimization/117270
+	* tree-vect-slp.cc (vectorizable_slp_permutation_1): Make nperms
+	account for the number of times that each permutation will be used
+	during transformation.
+
+2025-01-28  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/112859
+	* tree-loop-distribution.cc
+	(loop_distribution::pg_add_dependence_edges): Add comment.
+
+2025-01-28  Vladimir N. Makarov  <vmakarov@redhat.com>
+
+	PR target/118663
+	* lra-constraints.cc (invalid_mode_reg_p): Check empty
+	reg_class_contents.
+
+2025-01-28  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/117424
+	* tree-eh.cc (tree_could_trap_p): Verify the base is
+	fully contained within a decl.
+
+2025-01-28  Thomas Schwinge  <tschwinge@baylibre.com>
+
+	* tree-pretty-print.cc (dump_omp_clause): Clarify
+	'OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P'.
+
+2025-01-28  Jakub Jelinek  <jakub@redhat.com>
+
+	PR rtl-optimization/118638
+	* combine.cc (make_extraction): Only optimize (mult x 2^n) if len is
+	larger than 1.
+
+2025-01-28  Richard Sandiford  <richard.sandiford@arm.com>
+
+	* tree-vect-slp.cc (vectorizable_slp_permutation_1): Remove
+	extra newline from dump message.
+
+2025-01-28  Jeff Law  <jlaw@ventanamicro.com>
+
+	PR target/114085
+	* config/h8300/constraints.md (U): No longer accept REGs.
+	* config/h8300/logical.md (andqi3_2): Use "rU" rather than "U".
+	(andqi3_2_clobber_flags, andqi3_1, <code>qi3_1): Likewise.
+	* config/h8300/testcompare.md (tst_extzv_1_n): Likewise.
+
+2025-01-27  Robin Dapp  <rdapp@ventanamicro.com>
+
+	PR target/117173
+	* config/riscv/riscv-v.cc (shuffle_generic_patterns): Only
+	support single-source permutes by default.
+	* config/riscv/riscv.opt: New param "riscv-two-source-permutes".
+
+2025-01-27  John David Anglin  <danglin@gcc.gnu.org>
+
+	PR c++/116524
+	* configure.ac: Check for munmap and msync.
+	* configure: Regenerate.
+	* config.in: Regenerate.
+
+2025-01-27  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/118653
+	* tree-vect-loop.cc (vectorizable_live_operation): Also allow
+	out-of-loop debug uses.
+
+2025-01-27  Richard Biener  <rguenther@suse.de>
+
+	PR rtl-optimization/118662
+	* combine.cc (try_combine): When re-materializing a load
+	from an extended reg by a lowpart subreg make sure we're
+	not dealing with vector or complex modes.
+
+2025-01-27  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/118643
+	* expr.cc (expand_expr_real_1): Avoid falling back to BIT_FIELD_REF
+	expansion for negative offset.
+
+2025-01-27  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/112859
+	PR tree-optimization/115347
+	* tree-loop-distribution.cc
+	(loop_distribution::pg_add_dependence_edges): For a zero
+	distance vector still make sure to not have an inner
+	loop with zero distance.
+
+2025-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/118637
+	* match.pd: Canonicalize unsigned division by power of two to
+	right shift.
+
+2025-01-27  Soumya AR  <soumyaa@nvidia.com>
+
+	PR target/118490
+	* match.pd: Added ! to verify that log/exp (CST) can be constant folded.
+
+2025-01-26  Ilya Leoshkevich  <iii@linux.ibm.com>
+
+	* asan.cc (asan_emit_stack_protection): Always zero the flag
+	unless it is cleared by the __asan_stack_free_N() libcall.
+
+2025-01-26  Pan Li  <pan2.li@intel.com>
+
+	PR target/118103
+	* config/riscv/riscv.cc (riscv_conditional_register_usage): Add
+	the FRM as the global_regs.
+
+2025-01-25  Andi Kleen  <ak@gcc.gnu.org>
+
+	PR preprocessor/118168
+	* input.cc (file_cache_slot::m_error): New field.
+	(file_cache_slot::create): Clear m_error.
+	(file_cache_slot::file_cache_slot): Clear m_error.
+	(file_cache_slot::read_data): Set m_error on error.
+	(file_cache_slot::get_next_line): Use m_error instead of ferror.
+
+2025-01-25  Jeff Law  <jlaw@ventanamicro.com>
+
+	PR target/116256
+	* config/riscv/riscv.md (mvconst_internal): Reject single bit
+	constants.
+	* config/riscv/riscv.cc (riscv_gen_zero_extend_rtx): Improve
+	handling constants.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* config/aarch64/aarch64-arches.def (V9_5A): Add CPA.
+	* config/aarch64/aarch64-option-extensions.def (CPA): New.
+	* doc/invoke.texi: Document +cpa.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* doc/invoke.texi: Add +wfxt and +xs to armv9.2-a
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* config/aarch64/aarch64-arches.def (V9_5A): New.
+	* doc/invoke.texi: Document armv9.5-a option.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* common/config/aarch64/aarch64-common.cc: Assert that CRYPTO
+	bit is not set.
+	* config/aarch64/aarch64-feature-deps.h
+	(info<FEAT>.explicit_on): Unset CRYPTO bit.
+	(cpu_##CORE_IDENT): Ditto.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* common/config/aarch64/aarch64-common.cc
+	(aarch64_rewrite_selected_cpu): Refactor and inline into...
+	(aarch64_rewrite_mcpu): this.
+	* config/aarch64/aarch64-protos.h
+	(aarch64_rewrite_selected_cpu): Delete.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* common/config/aarch64/aarch64-common.cc
+	(aarch64_get_arch_string_for_assembler): New.
+	(aarch64_rewrite_march): New.
+	(aarch64_rewrite_selected_cpu): Call new function.
+	* config/aarch64/aarch64-elf.h (ASM_SPEC): Remove identity mapping.
+	* config/aarch64/aarch64-protos.h
+	(aarch64_get_arch_string_for_assembler): New.
+	* config/aarch64/aarch64.cc
+	(aarch64_declare_function_name): Call new function.
+	(aarch64_start_file): Ditto.
+	* config/aarch64/aarch64.h
+	(EXTRA_SPEC_FUNCTIONS): Use new macro name.
+	(MCPU_TO_MARCH_SPEC): Rename to...
+	(MARCH_REWRITE_SPEC): ...this, and extend the spec rule.
+	(aarch64_rewrite_march): New declaration.
+	(MCPU_TO_MARCH_SPEC_FUNCTIONS): Rename to...
+	(AARCH64_BASE_SPEC_FUNCTIONS): ...this, and add new function.
+	(ASM_CPU_SPEC): Use new macro name.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* common/config/aarch64/aarch64-common.cc
+	(aarch64_get_all_extension_candidates): Inline into...
+	(aarch64_print_hint_for_extensions): ...this.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* common/config/aarch64/aarch64-common.cc
+	(aarch64_get_all_extension_candidates): Move within file.
+	(aarch64_print_hint_candidates): Move from aarch64.cc.
+	(aarch64_print_hint_for_extensions): Ditto.
+	(aarch64_print_hint_for_arch): Ditto.
+	(aarch64_print_hint_for_core): Ditto.
+	(enum aarch_parse_opt_result): Ditto.
+	(aarch64_parse_arch): Ditto.
+	(aarch64_parse_cpu): Ditto.
+	(aarch64_parse_tune): Ditto.
+	(aarch64_validate_march): Ditto.
+	(aarch64_validate_mcpu): Ditto.
+	(aarch64_validate_mtune): Ditto.
+	* config/aarch64/aarch64-protos.h
+	(aarch64_rewrite_selected_cpu): Move within file.
+	(aarch64_print_hint_for_extensions): Share function prototype.
+	(aarch64_print_hint_for_arch): Ditto.
+	(aarch64_print_hint_for_core): Ditto.
+	(enum aarch_parse_opt_result): Ditto.
+	(aarch64_validate_march): Ditto.
+	(aarch64_validate_mcpu): Ditto.
+	(aarch64_validate_mtune): Ditto.
+	(aarch64_get_all_extension_candidates): Unshare prototype.
+	* config/aarch64/aarch64.cc
+	(aarch64_parse_arch): Move to aarch64-common.cc.
+	(aarch64_parse_cpu): Ditto.
+	(aarch64_parse_tune): Ditto.
+	(aarch64_print_hint_candidates): Ditto.
+	(aarch64_print_hint_for_core): Ditto.
+	(aarch64_print_hint_for_arch): Ditto.
+	(aarch64_print_hint_for_extensions): Ditto.
+	(aarch64_validate_mcpu): Ditto.
+	(aarch64_validate_march): Ditto.
+	(aarch64_validate_mtune): Ditto.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* config/aarch64/aarch64.cc
+	(aarch64_print_hint_candidates): New helper function.
+	(aarch64_print_hint_for_core_or_arch): Inline into callers.
+	(aarch64_print_hint_for_core): Inline callee and use new helper.
+	(aarch64_print_hint_for_arch): Ditto.
+	(aarch64_print_hint_for_extensions): Use new helper.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* config/aarch64/aarch64.cc
+	(aarch64_print_hint_for_extensions): Receive string as a char *.
+	(aarch64_parse_arch): Don't return a const struct processor *.
+	(aarch64_parse_cpu): Ditto.
+	(aarch64_parse_tune): Ditto.
+	(aarch64_validate_mtune): Ditto.
+	(aarch64_validate_mcpu): Ditto, and use temporary variables for
+	march/mcpu cross-check.
+	(aarch64_validate_march): Ditto.
+	(aarch64_override_options): Adjust for changed parameter types.
+	(aarch64_handle_attr_arch): Ditto.
+	(aarch64_handle_attr_cpu): Ditto.
+	(aarch64_handle_attr_tune): Ditto.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* common/config/aarch64/aarch64-common.cc
+	(struct aarch64_option_extension): Rename to..
+	(struct aarch64_extension_info): ...this.
+	(all_extensions): Update type name.
+	(struct arch_to_arch_name): Rename to...
+	(struct aarch64_arch_info): ...this, and rename name field.
+	(all_architectures): Update type names, and move before...
+	(struct processor_name_to_arch): ...this. Rename to...
+	(struct aarch64_processor_info): ...this, rename name field and
+	add cpu field.
+	(all_cores): Update type name, and set new field.
+	(aarch64_parse_extension): Update names.
+	(aarch64_get_all_extension_candidates): Ditto.
+	(aarch64_rewrite_selected_cpu): Ditto.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* common/config/aarch64/aarch64-common.cc
+	(all_cores): Remove explicit generic entry.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* config/aarch64/aarch64-opts.h
+	(enum aarch64_processor): Rename to...
+	(enum aarch64_cpu): ...this, and rename the entries.
+	* config/aarch64/aarch64.cc
+	(aarch64_type): Rename type and initial value.
+	(struct processor): Rename member types.
+	(all_architectures): Rename enum members.
+	(all_cores): Ditto.
+	(aarch64_get_tune_cpu): Rename type and enum member.
+	* config/aarch64/aarch64.h (enum target_cpus): Remove.
+	(TARGET_CPU_DEFAULT): Rename default value.
+	(aarch64_tune): Rename type.
+	* config/aarch64/aarch64.opt:
+	(selected_tune): Rename type and default value.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* config/aarch64/aarch64.cc (aarch64_override_options): Compare
+	returned feature masks directly.
+
+2025-01-24  Vladimir N. Makarov  <vmakarov@redhat.com>
+
+	PR target/118497
+	* ira-int.h (target_ira_int): Add x_ira_hard_regno_nrefs.
+	(ira_hard_regno_nrefs): New macro.
+	* ira.cc (setup_hard_regno_aclass): Remove unused code.  Modify
+	the comment.
+	(setup_hard_regno_nrefs): New function.
+	(ira): Call it.
+	* ira-color.cc (calculate_saved_nregs): Check
+	ira_hard_regno_nrefs.
+
+2025-01-24  yxj-github-437  <2457369732@qq.com>
+
+	* config/aarch64/aarch64.cc (aarch64_build_builtin_va_list): Mark
+	__builtin_va_list as TREE_PUBLIC.
+	* config/arm/arm.cc (arm_build_builtin_va_list): Likewise.
+
+2025-01-24  David Malcolm  <dmalcolm@redhat.com>
+
+	PR sarif-replay/117670
+	* Makefile.in (SARIF_REPLAY_INSTALL_NAME): New.
+	(install-libgdiagnostics): Use it,and exeext, rather than just
+	sarif-replay.
+
+2025-01-24  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/116010
+	* tree-data-ref.cc (contains_ssa_ref_p_1): New function.
+	(contains_ssa_ref_p): Likewise.
+	(dr_may_alias_p): Avoid treating unanalyzed base parts without
+	SSA reference conservatively.
+
+2025-01-24  Stefan Schulze Frielinghaus  <stefansf@gcc.gnu.org>
+
+	* config/s390/s390.h (S390_TDC_POSITIVE_ZERO): Remove.
+	(S390_TDC_NEGATIVE_ZERO): Remove.
+	(S390_TDC_POSITIVE_NORMALIZED_BFP_NUMBER): Remove.
+	(S390_TDC_NEGATIVE_NORMALIZED_BFP_NUMBER): Remove.
+	(S390_TDC_POSITIVE_DENORMALIZED_BFP_NUMBER): Remove.
+	(S390_TDC_NEGATIVE_DENORMALIZED_BFP_NUMBER): Remove.
+	(S390_TDC_POSITIVE_INFINITY): Remove.
+	(S390_TDC_NEGATIVE_INFINITY): Remove.
+	(S390_TDC_POSITIVE_QUIET_NAN): Remove.
+	(S390_TDC_NEGATIVE_QUIET_NAN): Remove.
+	(S390_TDC_POSITIVE_SIGNALING_NAN): Remove.
+	(S390_TDC_NEGATIVE_SIGNALING_NAN): Remove.
+	(S390_TDC_POSITIVE_DENORMALIZED_DFP_NUMBER): Remove.
+	(S390_TDC_NEGATIVE_DENORMALIZED_DFP_NUMBER): Remove.
+	(S390_TDC_POSITIVE_NORMALIZED_DFP_NUMBER): Remove.
+	(S390_TDC_NEGATIVE_NORMALIZED_DFP_NUMBER): Remove.
+	(S390_TDC_SIGNBIT_SET): Remove.
+	(S390_TDC_INFINITY): Remove.
+	* config/s390/s390.md (signbit<mode>2<tf_fpr>): Merge this one
+	(isinf<mode>2<tf_fpr>): and this one into
+	(<TDC_CLASS:tdc_insn><mode>2<tf_fpr>): new expander.
+	(isnormal<mode>2<tf_fpr>): New BFP expander.
+	(isnormal<mode>2): New DFP expander.
+	* config/s390/vector.md (signbittf2_vr): Merge this one
+	(isinftf2_vr): and this one into
+	(<tdc_insn>tf2_vr): new expander.
+	(signbittf2): Merge this one
+	(isinftf2): and this one into
+	(<tdc_insn>tf2): new expander.
+
+2025-01-24  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/118634
+	* tree-ssa-loop-ivcanon.cc (try_unroll_loop_completely):
+	Dump the number of estimated eliminated insns.
+
+2025-01-24  Saurabh Jha  <saurabh.jha@arm.com>
+
+	* config/aarch64/aarch64-sve2.md:
+	(*aarch64_pred_faminmax_fused): Fix to use the correct flags.
+	* config/aarch64/aarch64.h
+	(TARGET_SVE_FAMINMAX): Remove.
+	* config/aarch64/iterators.md: Fix iterators so that famax and
+	famin use correct flags.
+
+2025-01-24  Alexandre Oliva  <oliva@adacore.com>
+
+	PR tree-optimization/118572
+	* gimple-fold.cc (fold_truth_andor_for_ifcombine): Compare as
+	unsigned the variables whose extension bits are masked out.
+
+2025-01-24  Alexandre Oliva  <oliva@adacore.com>
+
+	* gimple-fold.cc (fold_truth_andor_for_ifcombine): Document
+	reversep's absence of effects on range tests.  Don't reject
+	reversep mismatches before trying compare swapping.
+
+2025-01-24  Alexandre Oliva  <oliva@adacore.com>
+
+	PR tree-optimization/118514
+	* tree-eh.cc (bit_field_ref_in_bounds_p): New.
+	(tree_could_trap_p) <BIT_FIELD_REF>: Call it.
+	* gimple-fold.cc (make_bit_field_load): Check trapping status
+	of replacement load against original load.
+
 2025-01-23  John David Anglin  <danglin@gcc.gnu.org>
 
 	* config/pa/pa32-regs.h (ADDITIONAL_REGISTER_NAMES): Change
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 56a27e9356cad503066ef262fb3ce8f7ebe2044f..e982577834151dec430f9d53ebd9aa15214cf696 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250124
+20250205
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 75fe81dacfc25b016c4e2d65ec8fd634bac22b28..3571362b616bf8e299043f67987bb4ef7cb8f60a 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -4222,9 +4222,10 @@ libgdiagnostics.install-common: installdirs libgdiagnostics.install-headers
 endif
 endif
 
+SARIF_REPLAY_INSTALL_NAME := $(shell echo sarif-replay|sed '$(program_transform_name)')
 install-libgdiagnostics: libgdiagnostics.install-common sarif-replay
-	-rm -f $(DESTDIR)$(bindir)/sarif-replay
-	-$(INSTALL_PROGRAM) sarif-replay $(DESTDIR)$(bindir)/sarif-replay
+	-rm -f $(DESTDIR)$(bindir)/$(SARIF_REPLAY_INSTALL_NAME)$(exeext)
+	-$(INSTALL_PROGRAM) sarif-replay $(DESTDIR)$(bindir)/$(SARIF_REPLAY_INSTALL_NAME)$(exeext)
 
 # Install the info files.
 # $(INSTALL_DATA) might be a relative pathname, so we can't cd into srcdir
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index e81ba687426b944fbacfe4b98730b7d48b823c10..6be8962d195ec9b3f8362fe12463ccee1a2f076c 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,19 @@
+2025-02-04  Eric Botcazou  <ebotcazou@adacore.com>
+
+	PR ada/118731
+	* sem_aggr.adb (Resolve_Iterated_Association): Add missing guard.
+
+2025-02-01  Eric Botcazou  <ebotcazou@adacore.com>
+
+	PR ada/118712
+	* sem_warn.adb (Check_References): Deal with small adjustments of
+	references.
+
+2025-01-31  Eric Botcazou  <ebotcazou@adacore.com>
+
+	* gcc-interface/utils.cc (gnat_pushdecl): Clear TREE_PUBLIC on
+	functions really nested in another function.
+
 2025-01-22  Arsen Arsenović  <arsen@aarsen.me>
 
 	* gcc-interface/lang-specs.h: Replace %{nostdinc*} %{nostdlib*}
diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index 5a90a1b81f72ffd7347dafa6a74d7a001b81bca4..1448716acc5afaea83dabd58632f94fac9aa068f 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -882,16 +882,20 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
   if (!deferred_decl_context && !context)
     context = get_global_context ();
 
-  /* Functions imported in another function are not really nested.
-     For really nested functions mark them initially as needing
-     a static chain for uses of that flag before unnesting;
-     lower_nested_functions will then recompute it.  */
+  /* Mark functions really nested in another function, that is to say defined
+     there as opposed to imported from elsewhere, as initially needing a static
+     chain for the sake of uniformity (lower_nested_functions will recompute it
+     exacly later) and as private to the translation unit (the static chain may
+     be clobbered by calling conventions used across translation units).  */
   if (TREE_CODE (decl) == FUNCTION_DECL
-      && !TREE_PUBLIC (decl)
+      && !DECL_EXTERNAL (decl)
       && context
       && (TREE_CODE (context) == FUNCTION_DECL
 	  || decl_function_context (context)))
-    DECL_STATIC_CHAIN (decl) = 1;
+    {
+      DECL_STATIC_CHAIN (decl) = 1;
+      TREE_PUBLIC (decl) = 0;
+    }
 
   if (!deferred_decl_context)
     DECL_CONTEXT (decl) = context;
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index f6db5cb97a4a39a3f31841fb2ff02ba60d12a2f4..a7ec772823f6bf89670dd4a8c1a3283546625bd1 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -3933,6 +3933,7 @@ package body Sem_Aggr is
 
             if Is_Entity_Name (Choice)
               and then Is_Type (Entity (Choice))
+              and then Present (Key_Type)
               and then Base_Type (Entity (Choice)) = Base_Type (Key_Type)
             then
                null;
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index e460799da1f0d9e03b5346616fa8228d814b80ca..35ef616647234d1492e6cd90d3665302efc7566e 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -1257,6 +1257,10 @@ package body Sem_Warn is
                   UR := Unset_Reference (E1);
                end if;
 
+               --  Protect again small adjustments of reference
+
+               UR := Unqual_Conv (UR);
+
                --  Special processing for access types
 
                if Present (UR) and then Is_Access_Type (E1T) then
diff --git a/gcc/asan.cc b/gcc/asan.cc
index 452a5a333277fae69d2dc54663b51e79148929a1..ebf806cffb64556a10091e492c8723d58584d749 100644
--- a/gcc/asan.cc
+++ b/gcc/asan.cc
@@ -2167,28 +2167,13 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb,
       mem = adjust_address (mem, VOIDmode, base_align_bias);
       emit_move_insn (mem, gen_int_mode (ASAN_STACK_RETIRED_MAGIC, ptr_mode));
       unsigned HOST_WIDE_INT sz = asan_frame_size >> ASAN_SHADOW_SHIFT;
+      bool asan_stack_free_emitted_p = false;
       if (use_after_return_class < 5
 	  && can_store_by_pieces (sz, builtin_memset_read_str, &c,
 				  BITS_PER_UNIT, true))
-	{
-	  /* Emit:
-	       memset(ShadowBase, kAsanStackAfterReturnMagic, ShadowSize);
-	       **SavedFlagPtr(FakeStack, class_id) = 0
-	  */
-	  store_by_pieces (shadow_mem, sz, builtin_memset_read_str, &c,
-			   BITS_PER_UNIT, true, RETURN_BEGIN);
-
-	  unsigned HOST_WIDE_INT offset
-	    = (1 << (use_after_return_class + 6));
-	  offset -= GET_MODE_SIZE (ptr_mode);
-	  mem = gen_rtx_MEM (ptr_mode, base);
-	  mem = adjust_address (mem, ptr_mode, offset);
-	  rtx addr = gen_reg_rtx (ptr_mode);
-	  emit_move_insn (addr, mem);
-	  addr = convert_memory_address (Pmode, addr);
-	  mem = gen_rtx_MEM (QImode, addr);
-	  emit_move_insn (mem, const0_rtx);
-	}
+	/* Emit memset (ShadowBase, kAsanStackAfterReturnMagic, ShadowSize).  */
+	store_by_pieces (shadow_mem, sz, builtin_memset_read_str, &c,
+			 BITS_PER_UNIT, true, RETURN_BEGIN);
       else if (use_after_return_class >= 5
 	       || !set_storage_via_setmem (shadow_mem,
 					   GEN_INT (sz),
@@ -2205,6 +2190,20 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb,
 			     GEN_INT (asan_frame_size + base_align_bias),
 			     TYPE_MODE (pointer_sized_int_node),
 			     orig_addr, ptr_mode);
+	  asan_stack_free_emitted_p = true;
+	}
+      if (!asan_stack_free_emitted_p)
+	{
+	  /* Emit **SavedFlagPtr (FakeStack, class_id) = 0.  */
+	  unsigned HOST_WIDE_INT offset = (1 << (use_after_return_class + 6));
+	  offset -= GET_MODE_SIZE (ptr_mode);
+	  mem = gen_rtx_MEM (ptr_mode, base);
+	  mem = adjust_address (mem, ptr_mode, offset);
+	  rtx addr = gen_reg_rtx (ptr_mode);
+	  emit_move_insn (addr, mem);
+	  addr = convert_memory_address (Pmode, addr);
+	  mem = gen_rtx_MEM (QImode, addr);
+	  emit_move_insn (mem, const0_rtx);
 	}
       lab = gen_label_rtx ();
       emit_jump (lab);
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 50b2b1fd26d077cdd2598017a5dbcef82ad56600..6bb1745254adce218fc49da7ee938e1a5cd79617 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,27 @@
+2025-02-04  Richard Biener  <rguenther@suse.de>
+
+	PR c/118742
+	* gimple-parser.cc (gimple_parser_build_unary_op): New
+	wrapper around build_unary_op.
+	(c_parser_gimple_unary_expression): Use it.
+
+2025-01-30  Tobias Burnus  <tburnus@baylibre.com>
+
+	* c-parser.cc (c_finish_omp_declare_variant): Modify how
+	append_args is saved internally.
+
+2025-01-28  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/116357
+	* c-decl.cc (grokdeclarator): Use c_build_qualified_type with
+	TYPE_UNQUALIFIED instead of TYPE_MAIN_VARIANT.
+
+2025-01-25  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/118639
+	* c-parser.cc (c_parser_omp_variable_list): Remove first variable
+	and emit "expected identifier" error regardless of it.
+
 2025-01-23  Jakub Jelinek  <jakub@redhat.com>
 
 	PR c++/118604
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 68d331b2250325f1298c53536109dd2910da2b40..0dcbae9b26f573630621cdfa54044dcda581179f 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -7058,7 +7058,7 @@ grokdeclarator (const struct c_declarator *declarator,
       && TYPE_QUALS (element_type))
     {
       orig_qual_type = type;
-      type = TYPE_MAIN_VARIANT (type);
+      type = c_build_qualified_type (type, TYPE_UNQUALIFIED);
     }
   type_quals = ((constp ? TYPE_QUAL_CONST : 0)
 		| (restrictp ? TYPE_QUAL_RESTRICT : 0)
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 93da0fbea5008334b48d4d790b0d6bf06f66d71a..aa68ee288a36265082b1c4a7717669370bef8842 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -16307,7 +16307,6 @@ c_parser_omp_variable_list (c_parser *parser,
   auto_vec<c_token> tokens;
   unsigned int tokens_avail = 0;
   c_token *saved_tokens = NULL;
-  bool first = true;
 
   while (1)
     {
@@ -16343,7 +16342,6 @@ c_parser_omp_variable_list (c_parser *parser,
 		break;
 
 	      c_parser_consume_token (parser);
-	      first = false;
 	      continue;
 	    }
 
@@ -16507,8 +16505,7 @@ c_parser_omp_variable_list (c_parser *parser,
 	t = c_parser_predefined_identifier (parser).value;
       else
 	{
-	  if (first)
-	    c_parser_error (parser, "expected identifier");
+	  c_parser_error (parser, "expected identifier");
 	  break;
 	}
 
@@ -16702,7 +16699,6 @@ c_parser_omp_variable_list (c_parser *parser,
 	break;
 
       c_parser_consume_token (parser);
-      first = false;
     }
 
   return list;
@@ -27094,7 +27090,10 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms)
       else if (ccode == append_args)
 	{
 	  if (append_args_tree)
-	    error_at (append_args_loc, "too many %qs clauses", "append_args");
+	    {
+	      error_at (append_args_loc, "too many %qs clauses", "append_args");
+	      append_args_tree = NULL_TREE;
+	    }
 	  do
 	    {
 	      location_t loc = c_parser_peek_token (parser)->location;
@@ -27119,17 +27118,19 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms)
 		  || !c_parser_require (parser, CPP_CLOSE_PAREN,
 					"expected %<)%> or %<,%>"))
 		goto fail;
-	      tree t = build_omp_clause (loc, OMP_CLAUSE_INIT);
+	      tree t = build_tree_list (target ? boolean_true_node
+					       : boolean_false_node,
+					targetsync ? boolean_true_node
+						   : boolean_false_node);
+	      t = build1_loc (loc, NOP_EXPR, void_type_node, t);
+	      t = build_tree_list (t, prefer_type_tree);
 	      if (append_args_tree)
-		OMP_CLAUSE_CHAIN (append_args_last) = t;
+		{
+		  TREE_CHAIN (append_args_last) = t;
+		  append_args_last = t;
+		}
 	      else
 		append_args_tree = append_args_last = t;
-	      if (target)
-		OMP_CLAUSE_INIT_TARGET (t) = 1;
-	      if (targetsync)
-		OMP_CLAUSE_INIT_TARGETSYNC (t) = 1;
-	      if (prefer_type_tree)
-		OMP_CLAUSE_INIT_PREFER_TYPE (t) = prefer_type_tree;
 	      if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
 		break;
 	      if (!c_parser_require (parser, CPP_COMMA, "expected %<)%> or %<,%>"))
@@ -27147,9 +27148,7 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms)
 				    OMP_TRAIT_CONSTRUCT_SIMD))
     {
       bool fail = false;
-      if (append_args_tree
-	  && TYPE_ARG_TYPES (TREE_TYPE (fndecl)) != NULL_TREE
-	  && TYPE_ARG_TYPES (TREE_TYPE (variant)) != NULL_TREE)
+      if (append_args_tree)
 	{
 	  int nappend_args = 0;
 	  int nbase_args = 0;
@@ -27159,6 +27158,11 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms)
 	  for (tree t = append_args_tree; t; t = TREE_CHAIN (t))
 	    nappend_args++;
 
+	  /* Store as purpose = arg number after which to append
+	     and value = list of interop items.  */
+	  append_args_tree = build_tree_list (build_int_cst (integer_type_node,
+							     nbase_args),
+					      append_args_tree);
 	  tree args, arg;
 	  args = arg = TYPE_ARG_TYPES (TREE_TYPE (variant));
 	  for (int j = 0; j < nbase_args && arg; j++, arg = TREE_CHAIN (arg))
@@ -27166,7 +27170,7 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms)
 	  for (int i = 0; i < nappend_args && arg; i++)
 	    arg = TREE_CHAIN (arg);
 	  tree saved_args;
-	  if (nbase_args)
+	  if (nbase_args && args)
 	    {
 	      saved_args = TREE_CHAIN (args);
 	      TREE_CHAIN (args) = arg;
@@ -27175,13 +27179,17 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms)
 	    {
 	      saved_args = args;
 	      TYPE_ARG_TYPES (TREE_TYPE (variant)) = arg;
+	      TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (variant)) = 1;
 	    }
 	  if (!comptypes (TREE_TYPE (fndecl), TREE_TYPE (variant)))
 	    fail = true;
-	  if (nbase_args)
+	  if (nbase_args && args)
 	    TREE_CHAIN (args) = saved_args;
 	  else
-	    TYPE_ARG_TYPES (TREE_TYPE (variant)) = saved_args;
+	    {
+	      TYPE_ARG_TYPES (TREE_TYPE (variant)) = saved_args;
+	      TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (variant)) = 0;
+	    }
 	  arg = saved_args;
 	  if (!fail)
 	    for (int i = 0; i < nappend_args; i++, arg = TREE_CHAIN (arg))
diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc
index 54ecf22151ca37eed82b985d69612ec7e47c3ffc..90b9beb1e9f397ae2f8aa157e56318dde0b2da56 100644
--- a/gcc/c/gimple-parser.cc
+++ b/gcc/c/gimple-parser.cc
@@ -125,6 +125,39 @@ static tree c_parser_gimple_paren_condition (gimple_parser &);
 static void c_parser_gimple_expr_list (gimple_parser &, vec<tree> *);
 
 
+/* Much like parser_build_unary_op, but avoid applying default conversions.  */
+
+static c_expr
+gimple_parser_build_unary_op (location_t loc,
+			      enum tree_code code, struct c_expr arg)
+{
+  struct c_expr result;
+
+  result.original_code = code;
+  result.original_type = NULL;
+  result.m_decimal = 0;
+
+  if (reject_gcc_builtin (arg.value))
+    {
+      result.value = error_mark_node;
+    }
+  else
+    {
+      result.value = build_unary_op (loc, code, arg.value, true);
+
+      if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value))
+	overflow_warning (loc, result.value, arg.value);
+    }
+
+  /* We are typically called when parsing a prefix token at LOC acting on
+     ARG.  Reflect this by updating the source range of the result to
+     start at LOC and end at the end of ARG.  */
+  set_c_expr_source_range (&result,
+			   loc, arg.get_finish ());
+
+  return result;
+}
+
 /* See if VAL is an identifier matching __BB<num> and return <num>
    in *INDEX.  */
 
@@ -1203,7 +1236,7 @@ c_parser_gimple_unary_expression (gimple_parser &parser)
       c_parser_consume_token (parser);
       op = c_parser_gimple_postfix_expression (parser);
       mark_exp_read (op.value);
-      return parser_build_unary_op (op_loc, ADDR_EXPR, op);
+      return gimple_parser_build_unary_op (op_loc, ADDR_EXPR, op);
     case CPP_MULT:
       {
 	c_parser_consume_token (parser);
@@ -1228,15 +1261,15 @@ c_parser_gimple_unary_expression (gimple_parser &parser)
     case CPP_PLUS:
       c_parser_consume_token (parser);
       op = c_parser_gimple_postfix_expression (parser);
-      return parser_build_unary_op (op_loc, CONVERT_EXPR, op);
+      return gimple_parser_build_unary_op (op_loc, CONVERT_EXPR, op);
     case CPP_MINUS:
       c_parser_consume_token (parser);
       op = c_parser_gimple_postfix_expression (parser);
-      return parser_build_unary_op (op_loc, NEGATE_EXPR, op);
+      return gimple_parser_build_unary_op (op_loc, NEGATE_EXPR, op);
     case CPP_COMPL:
       c_parser_consume_token (parser);
       op = c_parser_gimple_postfix_expression (parser);
-      return parser_build_unary_op (op_loc, BIT_NOT_EXPR, op);
+      return gimple_parser_build_unary_op (op_loc, BIT_NOT_EXPR, op);
     case CPP_NOT:
       c_parser_error (parser, "%<!%> not valid in GIMPLE");
       return ret;
@@ -1246,11 +1279,11 @@ c_parser_gimple_unary_expression (gimple_parser &parser)
 	case RID_REALPART:
 	  c_parser_consume_token (parser);
 	  op = c_parser_gimple_postfix_expression (parser);
-	  return parser_build_unary_op (op_loc, REALPART_EXPR, op);
+	  return gimple_parser_build_unary_op (op_loc, REALPART_EXPR, op);
 	case RID_IMAGPART:
 	  c_parser_consume_token (parser);
 	  op = c_parser_gimple_postfix_expression (parser);
-	  return parser_build_unary_op (op_loc, IMAGPART_EXPR, op);
+	  return gimple_parser_build_unary_op (op_loc, IMAGPART_EXPR, op);
 	default:
 	  return c_parser_gimple_postfix_expression (parser);
 	}
@@ -1261,13 +1294,13 @@ c_parser_gimple_unary_expression (gimple_parser &parser)
 	    {
 	      c_parser_consume_token (parser);
 	      op = c_parser_gimple_postfix_expression (parser);
-	      return parser_build_unary_op (op_loc, ABS_EXPR, op);
+	      return gimple_parser_build_unary_op (op_loc, ABS_EXPR, op);
 	    }
 	  else if (strcmp (IDENTIFIER_POINTER (id), "__ABSU") == 0)
 	    {
 	      c_parser_consume_token (parser);
 	      op = c_parser_gimple_postfix_expression (parser);
-	      return parser_build_unary_op (op_loc, ABSU_EXPR, op);
+	      return gimple_parser_build_unary_op (op_loc, ABSU_EXPR, op);
 	    }
 	  else if (strcmp (IDENTIFIER_POINTER (id), "__MIN") == 0)
 	    return c_parser_gimple_parentized_binary_expression (parser,
diff --git a/gcc/combine.cc b/gcc/combine.cc
index a2d4387cebe8d1ac334bf369a84968daeba20f5b..3beeb514b81746404831db00df5e1cd0cfe7a91f 100644
--- a/gcc/combine.cc
+++ b/gcc/combine.cc
@@ -3904,6 +3904,9 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
      copy.  This saves at least one insn, more if register allocation can
      eliminate the copy.
 
+     We cannot do this if the involved modes have more than one elements,
+     like for vector or complex modes.
+
      We cannot do this if the destination of the first assignment is a
      condition code register.  We eliminate this case by making sure
      the SET_DEST and SET_SRC have the same mode.
@@ -3919,6 +3922,8 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
 	   && GET_CODE (SET_SRC (XVECEXP (newpat, 0, 0))) == SIGN_EXTEND
 	   && (GET_MODE (SET_DEST (XVECEXP (newpat, 0, 0)))
 	       == GET_MODE (SET_SRC (XVECEXP (newpat, 0, 0))))
+	   && ! VECTOR_MODE_P (GET_MODE (SET_DEST (XVECEXP (newpat, 0, 0))))
+	   && ! COMPLEX_MODE_P (GET_MODE (SET_DEST (XVECEXP (newpat, 0, 0))))
 	   && GET_CODE (XVECEXP (newpat, 0, 1)) == SET
 	   && rtx_equal_p (SET_SRC (XVECEXP (newpat, 0, 1)),
 			   XEXP (SET_SRC (XVECEXP (newpat, 0, 0)), 0))
@@ -7624,7 +7629,7 @@ make_extraction (machine_mode mode, rtx inner, HOST_WIDE_INT pos,
 	 least significant (LEN - C) bits of X, giving an rtx
 	 whose mode is MODE, then multiply it by 2^C.  */
       const HOST_WIDE_INT shift_amt = exact_log2 (INTVAL (XEXP (inner, 1)));
-      if (IN_RANGE (shift_amt, 1, len - 1))
+      if (len > 1 && IN_RANGE (shift_amt, 1, len - 1))
 	{
 	  new_rtx = make_extraction (mode, XEXP (inner, 0),
 				     0, 0, len - shift_amt,
@@ -10630,8 +10635,10 @@ simplify_shift_const_1 (enum rtx_code code, machine_mode result_mode,
 					     outer_op, outer_const);
 	}
 
-      scalar_int_mode shift_unit_mode
-	= as_a <scalar_int_mode> (GET_MODE_INNER (shift_mode));
+      scalar_int_mode shift_unit_mode;
+      if (!is_a <scalar_int_mode> (GET_MODE_INNER (shift_mode),
+				   &shift_unit_mode))
+	return NULL_RTX;
 
       /* Handle cases where the count is greater than the size of the mode
 	 minus 1.  For ASHIFT, use the size minus one as the count (this can
diff --git a/gcc/common/config/aarch64/aarch64-common.cc b/gcc/common/config/aarch64/aarch64-common.cc
index 92df8b619305ba8b1c9a4b92f0674f02784f1a3a..ef4458fb69308d2bb6785e97be5be85226cf0ebb 100644
--- a/gcc/common/config/aarch64/aarch64-common.cc
+++ b/gcc/common/config/aarch64/aarch64-common.cc
@@ -145,8 +145,9 @@ aarch64_handle_option (struct gcc_options *opts,
     }
 }
 
+
 /* An ISA extension in the co-processor and main instruction set space.  */
-struct aarch64_option_extension
+struct aarch64_extension_info
 {
   /* The extension name to pass on to the assembler.  */
   const char *name;
@@ -159,7 +160,7 @@ struct aarch64_option_extension
 };
 
 /* ISA extensions in AArch64.  */
-static constexpr aarch64_option_extension all_extensions[] =
+static constexpr aarch64_extension_info all_extensions[] =
 {
 #define AARCH64_OPT_EXTENSION(NAME, IDENT, C, D, E, FEATURE_STRING) \
   {NAME, AARCH64_FL_##IDENT, feature_deps::IDENT ().explicit_on, \
@@ -168,39 +169,106 @@ static constexpr aarch64_option_extension all_extensions[] =
   {NULL, 0, 0, 0}
 };
 
-struct processor_name_to_arch
+struct aarch64_arch_info
 {
-  const char *processor_name;
+  const char *name;
   aarch64_arch arch;
   aarch64_feature_flags flags;
 };
 
-struct arch_to_arch_name
+/* Map architecture revisions to their string representation.  */
+static constexpr aarch64_arch_info all_architectures[] =
 {
+#define AARCH64_ARCH(NAME, B, ARCH_IDENT, D, E)	\
+  {NAME, AARCH64_ARCH_##ARCH_IDENT, feature_deps::ARCH_IDENT ().enable},
+#include "config/aarch64/aarch64-arches.def"
+  {NULL, aarch64_no_arch, 0}
+};
+
+struct aarch64_processor_info
+{
+  const char *name;
+  aarch64_cpu processor;
   aarch64_arch arch;
-  const char *arch_name;
   aarch64_feature_flags flags;
 };
 
 /* Map processor names to the architecture revision they implement and
    the default set of architectural feature flags they support.  */
-static constexpr processor_name_to_arch all_cores[] =
+static constexpr aarch64_processor_info all_cores[] =
 {
 #define AARCH64_CORE(NAME, CORE_IDENT, C, ARCH_IDENT, E, F, G, H, I) \
-  {NAME, AARCH64_ARCH_##ARCH_IDENT, feature_deps::cpu_##CORE_IDENT},
+  {NAME, AARCH64_CPU_##CORE_IDENT, AARCH64_ARCH_##ARCH_IDENT, \
+   feature_deps::cpu_##CORE_IDENT},
 #include "config/aarch64/aarch64-cores.def"
-  {"generic", AARCH64_ARCH_V8A, feature_deps::V8A ().enable},
-  {"", aarch64_no_arch, 0}
+  {NULL, aarch64_no_cpu, aarch64_no_arch, 0}
 };
 
-/* Map architecture revisions to their string representation.  */
-static constexpr arch_to_arch_name all_architectures[] =
+
+/* Print a list of CANDIDATES for an argument, and try to suggest a specific
+   close match.  */
+
+inline static void
+aarch64_print_hint_candidates (const char *str,
+			       const auto_vec<const char*> & candidates)
 {
-#define AARCH64_ARCH(NAME, B, ARCH_IDENT, D, E)	\
-  {AARCH64_ARCH_##ARCH_IDENT, NAME, feature_deps::ARCH_IDENT ().enable},
-#include "config/aarch64/aarch64-arches.def"
-  {aarch64_no_arch, "", 0}
-};
+  char *s;
+  const char *hint = candidates_list_and_hint (str, s, candidates);
+  if (hint)
+    inform (input_location, "valid arguments are: %s;"
+			     " did you mean %qs?", s, hint);
+  else
+    inform (input_location, "valid arguments are: %s", s);
+
+  XDELETEVEC (s);
+}
+
+/* Print a hint with a suggestion for an extension name
+   that most closely resembles what the user passed in STR.  */
+
+void
+aarch64_print_hint_for_extensions (const char *str)
+{
+  auto_vec<const char *> candidates;
+  const struct aarch64_extension_info *opt;
+  for (opt = all_extensions; opt->name != NULL; opt++)
+    candidates.safe_push (opt->name);
+
+  aarch64_print_hint_candidates (str, candidates);
+}
+
+/* Print a hint with a suggestion for an architecture name that most closely
+   resembles what the user passed in STR.  */
+
+void
+aarch64_print_hint_for_arch (const char *str)
+{
+  auto_vec<const char *> candidates;
+  const struct aarch64_arch_info *entry = all_architectures;
+  for (; entry->name != NULL; entry++)
+    candidates.safe_push (entry->name);
+
+#ifdef HAVE_LOCAL_CPU_DETECT
+  /* Add also "native" as possible value.  */
+  candidates.safe_push ("native");
+#endif
+
+  aarch64_print_hint_candidates (str, candidates);
+}
+
+/* Print a hint with a suggestion for a core name that most closely resembles
+   what the user passed in STR.  */
+
+void
+aarch64_print_hint_for_core (const char *str)
+{
+  auto_vec<const char *> candidates;
+  const struct aarch64_processor_info *entry = all_cores;
+  for (; entry->name != NULL; entry++)
+    candidates.safe_push (entry->name);
+  aarch64_print_hint_candidates (str, candidates);
+}
+
 
 /* Parse the architecture extension string STR and update ISA_FLAGS
    with the architecture features turned on or off.  Return a
@@ -213,7 +281,7 @@ aarch64_parse_extension (const char *str, aarch64_feature_flags *isa_flags,
                          std::string *invalid_extension)
 {
   /* The extension string is parsed left to right.  */
-  const struct aarch64_option_extension *opt = NULL;
+  const struct aarch64_extension_info *opt = NULL;
 
   /* Flag to say whether we are adding or removing an extension.  */
   int adding_ext = -1;
@@ -272,16 +340,266 @@ aarch64_parse_extension (const char *str, aarch64_feature_flags *isa_flags,
   return AARCH_PARSE_OK;
 }
 
-/* Append all architecture extension candidates to the CANDIDATES vector.  */
+/* Parse the TO_PARSE string and put the architecture that it
+   selects into RES_ARCH and the architectural features into RES_FLAGS.
+   Return an aarch_parse_opt_result describing the parse result.
+   If there is an error parsing, RES_ARCH and RES_FLAGS are left unchanged.
+   When the TO_PARSE string contains an invalid extension,
+   a copy of the string is created and stored to INVALID_EXTENSION.  */
 
-void
-aarch64_get_all_extension_candidates (auto_vec<const char *> *candidates)
+enum aarch_parse_opt_result
+aarch64_parse_arch (const char *to_parse, aarch64_arch *res_arch,
+		    aarch64_feature_flags *res_flags,
+		    std::string *invalid_extension)
 {
-  const struct aarch64_option_extension *opt;
-  for (opt = all_extensions; opt->name != NULL; opt++)
-    candidates->safe_push (opt->name);
+  const char *ext;
+  const struct aarch64_arch_info *arch;
+  size_t len;
+
+  ext = strchr (to_parse, '+');
+
+  if (ext != NULL)
+    len = ext - to_parse;
+  else
+    len = strlen (to_parse);
+
+  if (len == 0)
+    return AARCH_PARSE_MISSING_ARG;
+
+
+  /* Loop through the list of supported ARCHes to find a match.  */
+  for (arch = all_architectures; arch->name != NULL; arch++)
+    {
+      if (strlen (arch->name) == len
+	  && strncmp (arch->name, to_parse, len) == 0)
+	{
+	  auto isa_flags = arch->flags;
+
+	  if (ext != NULL)
+	    {
+	      /* TO_PARSE string contains at least one extension.  */
+	      enum aarch_parse_opt_result ext_res
+		= aarch64_parse_extension (ext, &isa_flags, invalid_extension);
+
+	      if (ext_res != AARCH_PARSE_OK)
+		return ext_res;
+	    }
+	  /* Extension parsing was successful.  Confirm the result
+	     arch and ISA flags.  */
+	  *res_arch = arch->arch;
+	  *res_flags = isa_flags;
+	  return AARCH_PARSE_OK;
+	}
+    }
+
+  /* ARCH name not found in list.  */
+  return AARCH_PARSE_INVALID_ARG;
+}
+
+/* Parse the TO_PARSE string and put the result tuning in RES_CPU and the
+   architecture flags in RES_FLAGS.  Return an aarch_parse_opt_result
+   describing the parse result.  If there is an error parsing, RES_CPU and
+   RES_FLAGS are left unchanged.
+   When the TO_PARSE string contains an invalid extension,
+   a copy of the string is created and stored to INVALID_EXTENSION.  */
+
+enum aarch_parse_opt_result
+aarch64_parse_cpu (const char *to_parse, aarch64_cpu *res_cpu,
+		   aarch64_feature_flags *res_flags,
+		   std::string *invalid_extension)
+{
+  const char *ext;
+  const struct aarch64_processor_info *cpu;
+  size_t len;
+
+  ext = strchr (to_parse, '+');
+
+  if (ext != NULL)
+    len = ext - to_parse;
+  else
+    len = strlen (to_parse);
+
+  if (len == 0)
+    return AARCH_PARSE_MISSING_ARG;
+
+
+  /* Loop through the list of supported CPUs to find a match.  */
+  for (cpu = all_cores; cpu->name != NULL; cpu++)
+    {
+      if (strlen (cpu->name) == len && strncmp (cpu->name, to_parse, len) == 0)
+	{
+	  auto isa_flags = cpu->flags;
+
+	  if (ext != NULL)
+	    {
+	      /* TO_PARSE string contains at least one extension.  */
+	      enum aarch_parse_opt_result ext_res
+		= aarch64_parse_extension (ext, &isa_flags, invalid_extension);
+
+	      if (ext_res != AARCH_PARSE_OK)
+		return ext_res;
+	    }
+	  /* Extension parsing was successfull.  Confirm the result
+	     cpu and ISA flags.  */
+	  *res_cpu = cpu->processor;
+	  *res_flags = isa_flags;
+	  return AARCH_PARSE_OK;
+	}
+    }
+
+  /* CPU name not found in list.  */
+  return AARCH_PARSE_INVALID_ARG;
+}
+
+/* Parse the TO_PARSE string and put the cpu it selects into RES_CPU.
+   Return an aarch_parse_opt_result describing the parse result.
+   If the parsing fails then RES_CPU does not change.  */
+
+enum aarch_parse_opt_result
+aarch64_parse_tune (const char *to_parse, aarch64_cpu *res_cpu)
+{
+  const struct aarch64_processor_info *cpu;
+
+  /* Loop through the list of supported CPUs to find a match.  */
+  for (cpu = all_cores; cpu->name != NULL; cpu++)
+    {
+      if (strcmp (cpu->name, to_parse) == 0)
+	{
+	  *res_cpu = cpu->processor;
+	  return AARCH_PARSE_OK;
+	}
+    }
+
+  /* CPU name not found in list.  */
+  return AARCH_PARSE_INVALID_ARG;
+}
+
+
+/* Validate a command-line -march option.  Parse the arch and extensions
+   (if any) specified in STR and throw errors if appropriate.  Put the
+   results, if they are valid, in RES_ARCH and RES_FLAGS.  Return whether the
+   option is valid.  */
+
+bool
+aarch64_validate_march (const char *str, aarch64_arch *res_arch,
+			aarch64_feature_flags *res_flags)
+{
+  std::string invalid_extension;
+  enum aarch_parse_opt_result parse_res
+    = aarch64_parse_arch (str, res_arch, res_flags, &invalid_extension);
+
+  if (parse_res == AARCH_PARSE_OK)
+    return true;
+
+  switch (parse_res)
+    {
+      case AARCH_PARSE_MISSING_ARG:
+	error ("missing arch name in %<-march=%s%>", str);
+	break;
+      case AARCH_PARSE_INVALID_ARG:
+	{
+	  error ("unknown value %qs for %<-march%>", str);
+	  aarch64_print_hint_for_arch (str);
+	  /* A common user error is confusing -march and -mcpu.
+	     If the -march string matches a known CPU suggest -mcpu.  */
+	  aarch64_cpu temp_cpu;
+	  aarch64_feature_flags temp_flags;
+	  parse_res = aarch64_parse_cpu (str, &temp_cpu, &temp_flags,
+					 &invalid_extension);
+	  if (parse_res == AARCH_PARSE_OK)
+	    inform (input_location, "did you mean %<-mcpu=%s%>?", str);
+	  break;
+	}
+      case AARCH_PARSE_INVALID_FEATURE:
+	error ("invalid feature modifier %qs in %<-march=%s%>",
+	       invalid_extension.c_str (), str);
+	aarch64_print_hint_for_extensions (invalid_extension.c_str ());
+	break;
+      default:
+	gcc_unreachable ();
+    }
+
+  return false;
 }
 
+/* Validate a command-line -mcpu option.  Parse the cpu and extensions (if any)
+   specified in STR and throw errors if appropriate.  Put the results if
+   they are valid in RES_CPU and RES_FLAGS.  Return whether the option is
+   valid.  */
+
+bool
+aarch64_validate_mcpu (const char *str, aarch64_cpu *res_cpu,
+		       aarch64_feature_flags *res_flags)
+{
+  std::string invalid_extension;
+  enum aarch_parse_opt_result parse_res
+    = aarch64_parse_cpu (str, res_cpu, res_flags, &invalid_extension);
+
+  if (parse_res == AARCH_PARSE_OK)
+    return true;
+
+  switch (parse_res)
+    {
+      case AARCH_PARSE_MISSING_ARG:
+	error ("missing cpu name in %<-mcpu=%s%>", str);
+	break;
+      case AARCH_PARSE_INVALID_ARG:
+	{
+	  error ("unknown value %qs for %<-mcpu%>", str);
+	  aarch64_print_hint_for_core (str);
+	  /* A common user error is confusing -march and -mcpu.
+	     If the -mcpu string matches a known architecture then suggest
+	     -march=.  */
+	  aarch64_arch temp_arch;
+	  aarch64_feature_flags temp_flags;
+	  parse_res = aarch64_parse_arch (str, &temp_arch, &temp_flags,
+					  &invalid_extension);
+	  if (parse_res == AARCH_PARSE_OK)
+	    inform (input_location, "did you mean %<-march=%s%>?", str);
+	  break;
+	}
+      case AARCH_PARSE_INVALID_FEATURE:
+	error ("invalid feature modifier %qs in %<-mcpu=%s%>",
+	       invalid_extension.c_str (), str);
+	aarch64_print_hint_for_extensions (invalid_extension.c_str ());
+	break;
+      default:
+	gcc_unreachable ();
+    }
+
+  return false;
+}
+
+/* Validate a command-line -mtune option.  Parse the cpu
+   specified in STR and throw errors if appropriate.  Put the
+   result, if it is valid, in RES_CPU.  Return whether the option is
+   valid.  */
+
+bool
+aarch64_validate_mtune (const char *str, aarch64_cpu *res_cpu)
+{
+  enum aarch_parse_opt_result parse_res
+    = aarch64_parse_tune (str, res_cpu);
+
+  if (parse_res == AARCH_PARSE_OK)
+    return true;
+
+  switch (parse_res)
+    {
+      case AARCH_PARSE_MISSING_ARG:
+	error ("missing cpu name in %<-mtune=%s%>", str);
+	break;
+      case AARCH_PARSE_INVALID_ARG:
+	error ("unknown value %qs for %<-mtune%>", str);
+	aarch64_print_hint_for_core (str);
+	break;
+      default:
+	gcc_unreachable ();
+    }
+  return false;
+}
+
+
 /* Return a string representation of ISA_FLAGS.  DEFAULT_ARCH_FLAGS
    gives the default set of flags which are implied by whatever -march
    we'd put out.  Our job is to figure out the minimal set of "+" and
@@ -295,6 +613,10 @@ aarch64_get_extension_string_for_isa_flags
 {
   std::string outstr = "";
 
+  /* The CRYPTO bit should only be used to support the +crypto alias
+     during option processing, and should be cleared at all other times.
+     Verify this property for the supplied flags bitmask.  */
+  gcc_assert (!(AARCH64_FL_CRYPTO & aarch64_isa_flags));
   aarch64_feature_flags current_flags = default_arch_flags;
 
   /* As a special case, do not assume that the assembler will enable CRC
@@ -372,61 +694,40 @@ aarch64_get_extension_string_for_isa_flags
   return outstr;
 }
 
-/* Attempt to rewrite NAME, which has been passed on the command line
-   as a -mcpu option to an equivalent -march value.  If we can do so,
-   return the new string, otherwise return an error.  */
+/* Generate an arch string to be passed to the assembler.  */
 
-const char *
-aarch64_rewrite_selected_cpu (const char *name)
+std::string
+aarch64_get_arch_string_for_assembler (aarch64_arch arch,
+				       aarch64_feature_flags flags)
 {
-  std::string original_string (name);
-  std::string extension_str;
-  std::string processor;
-  size_t extension_pos = original_string.find_first_of ('+');
+  const struct aarch64_arch_info *entry;
+  for (entry = all_architectures; entry->arch != aarch64_no_arch; entry++)
+    if (entry->arch == arch)
+	break;
 
-  /* Strip and save the extension string.  */
-  if (extension_pos != std::string::npos)
-    {
-      processor = original_string.substr (0, extension_pos);
-      extension_str = original_string.substr (extension_pos,
-					      std::string::npos);
-    }
-  else
-    {
-      /* No extensions.  */
-      processor = original_string;
-    }
+  std::string outstr = entry->name
+	+ aarch64_get_extension_string_for_isa_flags (flags, entry->flags);
 
-  const struct processor_name_to_arch* p_to_a;
-  for (p_to_a = all_cores;
-       p_to_a->arch != aarch64_no_arch;
-       p_to_a++)
-    {
-      if (p_to_a->processor_name == processor)
-	break;
-    }
+  return outstr;
+}
 
-  const struct arch_to_arch_name* a_to_an;
-  for (a_to_an = all_architectures;
-       a_to_an->arch != aarch64_no_arch;
-       a_to_an++)
-    {
-      if (a_to_an->arch == p_to_a->arch)
-	break;
-    }
+/* Called by the driver to rewrite a name passed to the -march
+   argument in preparation to be passed to the assembler.  The
+   names passed from the commend line will be in ARGV, we want
+   to use the right-most argument, which should be in
+   ARGV[ARGC - 1].  ARGC should always be greater than 0.  */
 
-  /* We couldn't find that proceesor name, or the processor name we
-     found does not map to an architecture we understand.  */
-  if (p_to_a->arch == aarch64_no_arch
-      || a_to_an->arch == aarch64_no_arch)
-    fatal_error (input_location, "unknown value %qs for %<-mcpu%>", name);
+const char *
+aarch64_rewrite_march (int argc, const char **argv)
+{
+  gcc_assert (argc);
+  const char *name = argv[argc - 1];
+  aarch64_arch arch;
+  aarch64_feature_flags flags;
 
-  aarch64_feature_flags extensions = p_to_a->flags;
-  aarch64_parse_extension (extension_str.c_str (), &extensions, NULL);
+  aarch64_validate_march (name, &arch, &flags);
 
-  std::string outstr = a_to_an->arch_name
-	+ aarch64_get_extension_string_for_isa_flags (extensions,
-						      a_to_an->flags);
+  std::string outstr = aarch64_get_arch_string_for_assembler (arch, flags);
 
   /* We are going to memory leak here, nobody elsewhere
      in the callchain is going to clean up after us.  The alternative is
@@ -435,8 +736,8 @@ aarch64_rewrite_selected_cpu (const char *name)
   return xstrdup (outstr.c_str ());
 }
 
-/* Called by the driver to rewrite a name passed to the -mcpu
-   argument in preparation to be passed to the assembler.  The
+/* Called by the driver to rewrite a name passed to the -mcpu argument
+   to an equivalent -march value to be passed to the assembler.  The
    names passed from the commend line will be in ARGV, we want
    to use the right-most argument, which should be in
    ARGV[ARGC - 1].  ARGC should always be greater than 0.  */
@@ -445,7 +746,25 @@ const char *
 aarch64_rewrite_mcpu (int argc, const char **argv)
 {
   gcc_assert (argc);
-  return aarch64_rewrite_selected_cpu (argv[argc - 1]);
+  const char *name = argv[argc - 1];
+  aarch64_cpu cpu;
+  aarch64_feature_flags flags;
+
+  aarch64_validate_mcpu (name, &cpu, &flags);
+
+  const struct aarch64_processor_info *entry;
+  for (entry = all_cores; entry->processor != aarch64_no_cpu; entry++)
+    if (entry->processor == cpu)
+      break;
+
+  std::string outstr = aarch64_get_arch_string_for_assembler (entry->arch,
+							      flags);
+
+  /* We are going to memory leak here, nobody elsewhere
+     in the callchain is going to clean up after us.  The alternative is
+     to allocate a static buffer, and assert that it is big enough for our
+     modified string, which seems much worse!  */
+  return xstrdup (outstr.c_str ());
 }
 
 /* Checks to see if the host CPU may not be Cortex-A53 or an unknown Armv8-a
diff --git a/gcc/config.in b/gcc/config.in
index 44de5a546116063274633aaaa595d76bab492a81..3b06533c48290bd4620a546461d1127801380896 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1972,6 +1972,18 @@
 #endif
 
 
+/* Define to 1 if you have the `msync' function. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_MSYNC
+#endif
+
+
+/* Define to 1 if you have the `munmap' function. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_MUNMAP
+#endif
+
+
 /* Define if GCC has been configured with --enable-newlib-nano-formatted-io.
    */
 #ifndef USED_FOR_TARGET
diff --git a/gcc/config/aarch64/aarch64-arches.def b/gcc/config/aarch64/aarch64-arches.def
index fd4881a8ebfbd3446e2995b9dcf1133918665be6..34a792d69510f967e738d233c1e35aed47349971 100644
--- a/gcc/config/aarch64/aarch64-arches.def
+++ b/gcc/config/aarch64/aarch64-arches.def
@@ -46,5 +46,6 @@ AARCH64_ARCH("armv9.1-a",     generic_armv9_a,   V9_1A,     9,  (V8_6A, V9A))
 AARCH64_ARCH("armv9.2-a",     generic_armv9_a,   V9_2A,     9,  (V8_7A, V9_1A))
 AARCH64_ARCH("armv9.3-a",     generic_armv9_a,   V9_3A,     9,  (V8_8A, V9_2A))
 AARCH64_ARCH("armv9.4-a",     generic_armv9_a,   V9_4A,     9,  (V8_9A, V9_3A))
+AARCH64_ARCH("armv9.5-a",     generic_armv9_a,   V9_5A,     9,  (V9_4A, CPA, FAMINMAX, LUT))
 
 #undef AARCH64_ARCH
diff --git a/gcc/config/aarch64/aarch64-elf.h b/gcc/config/aarch64/aarch64-elf.h
index b2f13be2dab5931f19d62fc29febceb98baf6fee..f6ebb723715ad0f092f14f06e733eff2b4fe3a1e 100644
--- a/gcc/config/aarch64/aarch64-elf.h
+++ b/gcc/config/aarch64/aarch64-elf.h
@@ -136,7 +136,6 @@
 #define ASM_SPEC "\
 %{mbig-endian:-EB} \
 %{mlittle-endian:-EL} \
-%{march=*:-march=%*} \
 %(asm_cpu_spec)" \
 ASM_MABI_SPEC
 #endif
diff --git a/gcc/config/aarch64/aarch64-feature-deps.h b/gcc/config/aarch64/aarch64-feature-deps.h
index 67c3a5da8aa3f59607b9eb20fb329c6fdef2d46f..55a0dbfae6107388d97528b637f9120cc6b933a1 100644
--- a/gcc/config/aarch64/aarch64-feature-deps.h
+++ b/gcc/config/aarch64/aarch64-feature-deps.h
@@ -56,7 +56,8 @@ get_enable (T1 i, Ts... args)
 
    - explicit_on: the transitive closure of the features that an
      explicit +FEATURE enables, including FLAG itself.  This is
-     always a superset of ENABLE
+     always a superset of ENABLE, except that the CRYPTO alias bit is
+     explicitly unset for consistency.
 
    Also define a function FEATURE () that returns an info<FEATURE>
    (which is an empty structure, since all members are static).
@@ -69,7 +70,8 @@ template<aarch64_feature> struct info;
   template<> struct info<aarch64_feature::IDENT> {			\
     static constexpr auto flag = AARCH64_FL_##IDENT;			\
     static constexpr auto enable = flag | get_enable REQUIRES;		\
-    static constexpr auto explicit_on = enable | get_enable EXPLICIT_ON; \
+    static constexpr auto explicit_on                                   \
+      = (enable | get_enable EXPLICIT_ON) & ~AARCH64_FL_CRYPTO;         \
   };									\
   constexpr aarch64_feature_flags info<aarch64_feature::IDENT>::flag;	\
   constexpr aarch64_feature_flags info<aarch64_feature::IDENT>::enable;	\
@@ -114,9 +116,11 @@ get_flags_off (aarch64_feature_flags mask)
 #include "config/aarch64/aarch64-option-extensions.def"
 
 /* Define cpu_<NAME> variables for each CPU, giving the transitive
-   closure of all the features that the CPU supports.  */
+   closure of all the features that the CPU supports.  The CRYPTO bit is just
+   an alias, so explicitly unset it for consistency.  */
 #define AARCH64_CORE(A, CORE_IDENT, C, ARCH_IDENT, FEATURES, F, G, H, I) \
-  constexpr auto cpu_##CORE_IDENT = ARCH_IDENT ().enable | get_enable FEATURES;
+  constexpr auto cpu_##CORE_IDENT \
+    = (ARCH_IDENT ().enable | get_enable FEATURES) & ~AARCH64_FL_CRYPTO;
 #include "config/aarch64/aarch64-cores.def"
 
 /* Define fmv_deps_<NAME> variables for each FMV feature, giving the transitive
diff --git a/gcc/config/aarch64/aarch64-option-extensions.def b/gcc/config/aarch64/aarch64-option-extensions.def
index a1133accfce53d227c7ecd8af70f93106c2656c8..cc42bd518dca5e4b947c81f06e543133b4f25440 100644
--- a/gcc/config/aarch64/aarch64-option-extensions.def
+++ b/gcc/config/aarch64/aarch64-option-extensions.def
@@ -275,6 +275,8 @@ AARCH64_OPT_EXTENSION("ssve-fp8dot2", SSVE_FP8DOT2, (SSVE_FP8DOT4), (), (), "sme
 
 AARCH64_OPT_EXTENSION("lut", LUT, (SIMD), (), (), "lut")
 
+AARCH64_OPT_EXTENSION("cpa", CPA, (), (), (), "")
+
 #undef AARCH64_OPT_FMV_EXTENSION
 #undef AARCH64_OPT_EXTENSION
 #undef AARCH64_FMV_FEATURE
diff --git a/gcc/config/aarch64/aarch64-opts.h b/gcc/config/aarch64/aarch64-opts.h
index 3f0b1e9414c32ce5cb0ae808b2bb38bee86b40d5..a6ca5cf016b05982572297a434b53a9f8fc1443b 100644
--- a/gcc/config/aarch64/aarch64-opts.h
+++ b/gcc/config/aarch64/aarch64-opts.h
@@ -38,13 +38,13 @@ typedef bbitmap<2> aarch64_feature_flags;
 #endif
 
 /* The various cores that implement AArch64.  */
-enum aarch64_processor
+enum aarch64_cpu
 {
 #define AARCH64_CORE(NAME, INTERNAL_IDENT, SCHED, ARCH, FLAGS, COSTS, IMP, PART, VARIANT) \
-  INTERNAL_IDENT,
+  AARCH64_CPU_##INTERNAL_IDENT,
 #include "aarch64-cores.def"
   /* Used to mark the end of the processor table.  */
-  aarch64_none
+  aarch64_no_cpu
 };
 
 enum aarch64_arch
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index fa7bc8029be04f6530d2aee2ead4d754ba3b2550..4235f4a0ca51af49c2852a420f1056727b24f345 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -1190,13 +1190,30 @@ void aarch64_set_asm_isa_flags (aarch64_feature_flags);
 void aarch64_set_asm_isa_flags (gcc_options *, aarch64_feature_flags);
 bool aarch64_handle_option (struct gcc_options *, struct gcc_options *,
 			     const struct cl_decoded_option *, location_t);
-const char *aarch64_rewrite_selected_cpu (const char *name);
+void aarch64_print_hint_for_extensions (const char *);
+void aarch64_print_hint_for_arch (const char *);
+void aarch64_print_hint_for_core (const char *);
 enum aarch_parse_opt_result aarch64_parse_extension (const char *,
                                                      aarch64_feature_flags *,
                                                      std::string *);
-void aarch64_get_all_extension_candidates (auto_vec<const char *> *candidates);
+enum aarch_parse_opt_result aarch64_parse_arch (const char *,
+						aarch64_arch *,
+						aarch64_feature_flags *,
+						std::string *);
+enum aarch_parse_opt_result aarch64_parse_cpu (const char *,
+					       aarch64_cpu *,
+					       aarch64_feature_flags *,
+					       std::string *);
+enum aarch_parse_opt_result aarch64_parse_tune (const char *, aarch64_cpu *);
+bool aarch64_validate_march (const char *, aarch64_arch *,
+			     aarch64_feature_flags *);
+bool aarch64_validate_mcpu (const char *, aarch64_cpu *,
+			    aarch64_feature_flags *);
+bool aarch64_validate_mtune (const char *, aarch64_cpu *);
 std::string aarch64_get_extension_string_for_isa_flags (aarch64_feature_flags,
 							aarch64_feature_flags);
+std::string aarch64_get_arch_string_for_assembler (aarch64_arch,
+						   aarch64_feature_flags);
 
 rtl_opt_pass *make_pass_aarch64_early_ra (gcc::context *);
 rtl_opt_pass *make_pass_fma_steering (gcc::context *);
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index a1f5619a615295c45f0f572b20f8e366e8e509b6..c1e40200806a3c0d01b0a05f91d60b64c5a5af05 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -357,7 +357,7 @@ static bool aarch64_print_address_internal (FILE*, machine_mode, rtx,
 					    aarch64_addr_query_type);
 
 /* The processor for which instructions should be scheduled.  */
-enum aarch64_processor aarch64_tune = cortexa53;
+enum aarch64_cpu aarch64_tune = AARCH64_CPU_cortexa53;
 
 /* Global flag for PC relative loads.  */
 bool aarch64_pcrelative_literal_loads;
@@ -451,8 +451,8 @@ aarch64_tuning_override_functions[] =
 struct processor
 {
   const char *name;
-  aarch64_processor ident;
-  aarch64_processor sched_core;
+  aarch64_cpu ident;
+  aarch64_cpu sched_core;
   aarch64_arch arch;
   aarch64_feature_flags flags;
   const tune_params *tune;
@@ -462,20 +462,20 @@ struct processor
 static CONSTEXPR const processor all_architectures[] =
 {
 #define AARCH64_ARCH(NAME, CORE, ARCH_IDENT, D, E) \
-  {NAME, CORE, CORE, AARCH64_ARCH_##ARCH_IDENT, \
+  {NAME, AARCH64_CPU_##CORE, AARCH64_CPU_##CORE, AARCH64_ARCH_##ARCH_IDENT, \
    feature_deps::ARCH_IDENT ().enable, NULL},
 #include "aarch64-arches.def"
-  {NULL, aarch64_none, aarch64_none, aarch64_no_arch, 0, NULL}
+  {NULL, aarch64_no_cpu, aarch64_no_cpu, aarch64_no_arch, 0, NULL}
 };
 
 /* Processor cores implementing AArch64.  */
 static const struct processor all_cores[] =
 {
 #define AARCH64_CORE(NAME, IDENT, SCHED, ARCH, E, COSTS, G, H, I) \
-  {NAME, IDENT, SCHED, AARCH64_ARCH_##ARCH, \
+  {NAME, AARCH64_CPU_##IDENT, AARCH64_CPU_##SCHED, AARCH64_ARCH_##ARCH, \
    feature_deps::cpu_##IDENT, &COSTS##_tunings},
 #include "aarch64-cores.def"
-  {NULL, aarch64_none, aarch64_none, aarch64_no_arch, 0, NULL}
+  {NULL, aarch64_no_cpu, aarch64_no_cpu, aarch64_no_arch, 0, NULL}
 };
 /* Internal representation of system registers.  */
 typedef struct {
@@ -15889,7 +15889,24 @@ aarch64_insn_cost (rtx_insn *insn, bool speed)
 {
   if (rtx set = single_set (insn))
     return set_rtx_cost (set, speed);
-  return pattern_cost (PATTERN (insn), speed);
+
+  /* If the instruction does multiple sets in parallel, use the cost
+     of the most expensive set.  This copes with instructions that set
+     the flags to a useful value as a side effect.  */
+  rtx pat = PATTERN (insn);
+  if (GET_CODE (pat) == PARALLEL)
+    {
+      int max_cost = 0;
+      for (int i = 0; i < XVECLEN (pat, 0); ++i)
+	{
+	  rtx x = XVECEXP (pat, 0, i);
+	  if (GET_CODE (x) == SET)
+	    max_cost = std::max (max_cost, set_rtx_cost (x, speed));
+	}
+      return max_cost;
+    }
+
+  return pattern_cost (pat, speed);
 }
 
 /* Implement TARGET_INIT_BUILTINS.  */
@@ -18224,140 +18241,6 @@ better_main_loop_than_p (const vector_costs *uncast_other) const
 
 static void initialize_aarch64_code_model (struct gcc_options *);
 
-/* Parse the TO_PARSE string and put the architecture struct that it
-   selects into RES and the architectural features into ISA_FLAGS.
-   Return an aarch_parse_opt_result describing the parse result.
-   If there is an error parsing, RES and ISA_FLAGS are left unchanged.
-   When the TO_PARSE string contains an invalid extension,
-   a copy of the string is created and stored to INVALID_EXTENSION.  */
-
-static enum aarch_parse_opt_result
-aarch64_parse_arch (const char *to_parse, const struct processor **res,
-		    aarch64_feature_flags *isa_flags,
-		    std::string *invalid_extension)
-{
-  const char *ext;
-  const struct processor *arch;
-  size_t len;
-
-  ext = strchr (to_parse, '+');
-
-  if (ext != NULL)
-    len = ext - to_parse;
-  else
-    len = strlen (to_parse);
-
-  if (len == 0)
-    return AARCH_PARSE_MISSING_ARG;
-
-
-  /* Loop through the list of supported ARCHes to find a match.  */
-  for (arch = all_architectures; arch->name != NULL; arch++)
-    {
-      if (strlen (arch->name) == len
-	  && strncmp (arch->name, to_parse, len) == 0)
-	{
-	  auto isa_temp = arch->flags;
-
-	  if (ext != NULL)
-	    {
-	      /* TO_PARSE string contains at least one extension.  */
-	      enum aarch_parse_opt_result ext_res
-		= aarch64_parse_extension (ext, &isa_temp, invalid_extension);
-
-	      if (ext_res != AARCH_PARSE_OK)
-		return ext_res;
-	    }
-	  /* Extension parsing was successful.  Confirm the result
-	     arch and ISA flags.  */
-	  *res = arch;
-	  *isa_flags = isa_temp;
-	  return AARCH_PARSE_OK;
-	}
-    }
-
-  /* ARCH name not found in list.  */
-  return AARCH_PARSE_INVALID_ARG;
-}
-
-/* Parse the TO_PARSE string and put the result tuning in RES and the
-   architecture flags in ISA_FLAGS.  Return an aarch_parse_opt_result
-   describing the parse result.  If there is an error parsing, RES and
-   ISA_FLAGS are left unchanged.
-   When the TO_PARSE string contains an invalid extension,
-   a copy of the string is created and stored to INVALID_EXTENSION.  */
-
-static enum aarch_parse_opt_result
-aarch64_parse_cpu (const char *to_parse, const struct processor **res,
-		   aarch64_feature_flags *isa_flags,
-		   std::string *invalid_extension)
-{
-  const char *ext;
-  const struct processor *cpu;
-  size_t len;
-
-  ext = strchr (to_parse, '+');
-
-  if (ext != NULL)
-    len = ext - to_parse;
-  else
-    len = strlen (to_parse);
-
-  if (len == 0)
-    return AARCH_PARSE_MISSING_ARG;
-
-
-  /* Loop through the list of supported CPUs to find a match.  */
-  for (cpu = all_cores; cpu->name != NULL; cpu++)
-    {
-      if (strlen (cpu->name) == len && strncmp (cpu->name, to_parse, len) == 0)
-	{
-	  auto isa_temp = cpu->flags;
-
-	  if (ext != NULL)
-	    {
-	      /* TO_PARSE string contains at least one extension.  */
-	      enum aarch_parse_opt_result ext_res
-		= aarch64_parse_extension (ext, &isa_temp, invalid_extension);
-
-	      if (ext_res != AARCH_PARSE_OK)
-		return ext_res;
-	    }
-	  /* Extension parsing was successfull.  Confirm the result
-	     cpu and ISA flags.  */
-	  *res = cpu;
-	  *isa_flags = isa_temp;
-	  return AARCH_PARSE_OK;
-	}
-    }
-
-  /* CPU name not found in list.  */
-  return AARCH_PARSE_INVALID_ARG;
-}
-
-/* Parse the TO_PARSE string and put the cpu it selects into RES.
-   Return an aarch_parse_opt_result describing the parse result.
-   If the parsing fails the RES does not change.  */
-
-static enum aarch_parse_opt_result
-aarch64_parse_tune (const char *to_parse, const struct processor **res)
-{
-  const struct processor *cpu;
-
-  /* Loop through the list of supported CPUs to find a match.  */
-  for (cpu = all_cores; cpu->name != NULL; cpu++)
-    {
-      if (strcmp (cpu->name, to_parse) == 0)
-	{
-	  *res = cpu;
-	  return AARCH_PARSE_OK;
-	}
-    }
-
-  /* CPU name not found in list.  */
-  return AARCH_PARSE_INVALID_ARG;
-}
-
 /* Parse TOKEN, which has length LENGTH to see if it is an option
    described in FLAG.  If it is, return the index bit for that fusion type.
    If not, error (printing OPTION_NAME) and return zero.  */
@@ -18566,9 +18449,9 @@ initialize_aarch64_tls_size (struct gcc_options *opts)
 /* Return the CPU corresponding to the enum CPU.  */
 
 static const struct processor *
-aarch64_get_tune_cpu (enum aarch64_processor cpu)
+aarch64_get_tune_cpu (enum aarch64_cpu cpu)
 {
-  gcc_assert (cpu != aarch64_none);
+  gcc_assert (cpu != aarch64_no_cpu);
 
   return &all_cores[cpu];
 }
@@ -18891,117 +18774,6 @@ aarch64_override_options_internal (struct gcc_options *opts)
   aarch64_override_options_after_change_1 (opts);
 }
 
-/* Print a hint with a suggestion for a core or architecture name that
-   most closely resembles what the user passed in STR.  ARCH is true if
-   the user is asking for an architecture name.  ARCH is false if the user
-   is asking for a core name.  */
-
-static void
-aarch64_print_hint_for_core_or_arch (const char *str, bool arch)
-{
-  auto_vec<const char *> candidates;
-  const struct processor *entry = arch ? all_architectures : all_cores;
-  for (; entry->name != NULL; entry++)
-    candidates.safe_push (entry->name);
-
-#ifdef HAVE_LOCAL_CPU_DETECT
-  /* Add also "native" as possible value.  */
-  if (arch)
-    candidates.safe_push ("native");
-#endif
-
-  char *s;
-  const char *hint = candidates_list_and_hint (str, s, candidates);
-  if (hint)
-    inform (input_location, "valid arguments are: %s;"
-			     " did you mean %qs?", s, hint);
-  else
-    inform (input_location, "valid arguments are: %s", s);
-
-  XDELETEVEC (s);
-}
-
-/* Print a hint with a suggestion for a core name that most closely resembles
-   what the user passed in STR.  */
-
-inline static void
-aarch64_print_hint_for_core (const char *str)
-{
-  aarch64_print_hint_for_core_or_arch (str, false);
-}
-
-/* Print a hint with a suggestion for an architecture name that most closely
-   resembles what the user passed in STR.  */
-
-inline static void
-aarch64_print_hint_for_arch (const char *str)
-{
-  aarch64_print_hint_for_core_or_arch (str, true);
-}
-
-
-/* Print a hint with a suggestion for an extension name
-   that most closely resembles what the user passed in STR.  */
-
-void
-aarch64_print_hint_for_extensions (const std::string &str)
-{
-  auto_vec<const char *> candidates;
-  aarch64_get_all_extension_candidates (&candidates);
-  char *s;
-  const char *hint = candidates_list_and_hint (str.c_str (), s, candidates);
-  if (hint)
-    inform (input_location, "valid arguments are: %s;"
-			     " did you mean %qs?", s, hint);
-  else
-    inform (input_location, "valid arguments are: %s", s);
-
-  XDELETEVEC (s);
-}
-
-/* Validate a command-line -mcpu option.  Parse the cpu and extensions (if any)
-   specified in STR and throw errors if appropriate.  Put the results if
-   they are valid in RES and ISA_FLAGS.  Return whether the option is
-   valid.  */
-
-static bool
-aarch64_validate_mcpu (const char *str, const struct processor **res,
-		       aarch64_feature_flags *isa_flags)
-{
-  std::string invalid_extension;
-  enum aarch_parse_opt_result parse_res
-    = aarch64_parse_cpu (str, res, isa_flags, &invalid_extension);
-
-  if (parse_res == AARCH_PARSE_OK)
-    return true;
-
-  switch (parse_res)
-    {
-      case AARCH_PARSE_MISSING_ARG:
-	error ("missing cpu name in %<-mcpu=%s%>", str);
-	break;
-      case AARCH_PARSE_INVALID_ARG:
-	error ("unknown value %qs for %<-mcpu%>", str);
-	aarch64_print_hint_for_core (str);
-	/* A common user error is confusing -march and -mcpu.
-	   If the -mcpu string matches a known architecture then suggest
-	   -march=.  */
-	parse_res = aarch64_parse_arch (str, res, isa_flags, &invalid_extension);
-	if (parse_res == AARCH_PARSE_OK)
-	  inform (input_location, "did you mean %<-march=%s%>?", str);
-	break;
-      case AARCH_PARSE_INVALID_FEATURE:
-	error ("invalid feature modifier %qs in %<-mcpu=%s%>",
-	       invalid_extension.c_str (), str);
-	aarch64_print_hint_for_extensions (invalid_extension);
-	break;
-      default:
-	gcc_unreachable ();
-    }
-
-  return false;
-}
-
 /* Straight line speculation indicators.  */
 enum aarch64_sls_hardening_type
 {
@@ -19075,77 +18847,6 @@ aarch64_validate_sls_mitigation (const char *const_str)
   free (str_root);
 }
 
-/* Validate a command-line -march option.  Parse the arch and extensions
-   (if any) specified in STR and throw errors if appropriate.  Put the
-   results, if they are valid, in RES and ISA_FLAGS.  Return whether the
-   option is valid.  */
-
-static bool
-aarch64_validate_march (const char *str, const struct processor **res,
-			aarch64_feature_flags *isa_flags)
-{
-  std::string invalid_extension;
-  enum aarch_parse_opt_result parse_res
-    = aarch64_parse_arch (str, res, isa_flags, &invalid_extension);
-
-  if (parse_res == AARCH_PARSE_OK)
-    return true;
-
-  switch (parse_res)
-    {
-      case AARCH_PARSE_MISSING_ARG:
-	error ("missing arch name in %<-march=%s%>", str);
-	break;
-      case AARCH_PARSE_INVALID_ARG:
-	error ("unknown value %qs for %<-march%>", str);
-	aarch64_print_hint_for_arch (str);
-	/* A common user error is confusing -march and -mcpu.
-	   If the -march string matches a known CPU suggest -mcpu.  */
-	parse_res = aarch64_parse_cpu (str, res, isa_flags, &invalid_extension);
-	if (parse_res == AARCH_PARSE_OK)
-	  inform (input_location, "did you mean %<-mcpu=%s%>?", str);
-	break;
-      case AARCH_PARSE_INVALID_FEATURE:
-	error ("invalid feature modifier %qs in %<-march=%s%>",
-	       invalid_extension.c_str (), str);
-	aarch64_print_hint_for_extensions (invalid_extension);
-	break;
-      default:
-	gcc_unreachable ();
-    }
-
-  return false;
-}
-
-/* Validate a command-line -mtune option.  Parse the cpu
-   specified in STR and throw errors if appropriate.  Put the
-   result, if it is valid, in RES.  Return whether the option is
-   valid.  */
-
-static bool
-aarch64_validate_mtune (const char *str, const struct processor **res)
-{
-  enum aarch_parse_opt_result parse_res
-    = aarch64_parse_tune (str, res);
-
-  if (parse_res == AARCH_PARSE_OK)
-    return true;
-
-  switch (parse_res)
-    {
-      case AARCH_PARSE_MISSING_ARG:
-	error ("missing cpu name in %<-mtune=%s%>", str);
-	break;
-      case AARCH_PARSE_INVALID_ARG:
-	error ("unknown value %qs for %<-mtune%>", str);
-	aarch64_print_hint_for_core (str);
-	break;
-      default:
-	gcc_unreachable ();
-    }
-  return false;
-}
-
 /* Return the VG value associated with -msve-vector-bits= value VALUE.  */
 
 static poly_uint16
@@ -19254,9 +18955,9 @@ aarch64_override_options (void)
   aarch64_feature_flags arch_isa = 0;
   aarch64_set_asm_isa_flags (0);
 
-  const struct processor *cpu = NULL;
-  const struct processor *arch = NULL;
-  const struct processor *tune = NULL;
+  aarch64_cpu cpu = aarch64_no_cpu;
+  aarch64_arch arch = aarch64_no_arch;
+  aarch64_cpu tune = aarch64_no_cpu;
 
   if (aarch64_harden_sls_string)
     aarch64_validate_sls_mitigation (aarch64_harden_sls_string);
@@ -19282,20 +18983,17 @@ aarch64_override_options (void)
   SUBTARGET_OVERRIDE_OPTIONS;
 #endif
 
-  if (cpu && arch)
+  if (cpu != aarch64_no_cpu && arch != aarch64_no_arch)
     {
       /* If both -mcpu and -march are specified, warn if they are not
 	 feature compatible.  feature compatible means that the inclusion of the
 	 cpu features would end up disabling an achitecture feature.  In
 	 otherwords the cpu features need to be a strict superset of the arch
 	 features and if so prefer the -march ISA flags.  */
-      auto full_arch_flags = arch->flags | arch_isa;
-      auto full_cpu_flags = cpu->flags | cpu_isa;
-      if (~full_cpu_flags & full_arch_flags)
+      if (~cpu_isa & arch_isa)
 	{
 	  std::string ext_diff
-	    = aarch64_get_extension_string_for_isa_flags (full_arch_flags,
-							  full_cpu_flags);
+	    = aarch64_get_extension_string_for_isa_flags (arch_isa, cpu_isa);
 	  warning (0, "switch %<-mcpu=%s%> conflicts with %<-march=%s%> switch "
 		      "and resulted in options %qs being added",
 		       aarch64_cpu_string,
@@ -19303,29 +19001,31 @@ aarch64_override_options (void)
 		       ext_diff.c_str ());
 	}
 
-      selected_arch = arch->arch;
+      selected_arch = arch;
       aarch64_set_asm_isa_flags (arch_isa | AARCH64_FL_DEFAULT_ISA_MODE);
     }
-  else if (cpu)
+  else if (cpu != aarch64_no_cpu)
     {
-      selected_arch = cpu->arch;
+      selected_arch = aarch64_get_tune_cpu (cpu)->arch;
       aarch64_set_asm_isa_flags (cpu_isa | AARCH64_FL_DEFAULT_ISA_MODE);
     }
-  else if (arch)
+  else if (arch != aarch64_no_arch)
     {
-      cpu = &all_cores[arch->ident];
-      selected_arch = arch->arch;
+      cpu = aarch64_get_arch (arch)->ident;
+      selected_arch = arch;
       aarch64_set_asm_isa_flags (arch_isa | AARCH64_FL_DEFAULT_ISA_MODE);
     }
   else
     {
       /* No -mcpu or -march specified, so use the default CPU.  */
-      cpu = &all_cores[TARGET_CPU_DEFAULT];
-      selected_arch = cpu->arch;
-      aarch64_set_asm_isa_flags (cpu->flags | AARCH64_FL_DEFAULT_ISA_MODE);
+      cpu = TARGET_CPU_DEFAULT;
+      const processor *cpu_info = aarch64_get_tune_cpu (cpu);
+      selected_arch = cpu_info->arch;
+      aarch64_set_asm_isa_flags (cpu_info->flags
+				 | AARCH64_FL_DEFAULT_ISA_MODE);
     }
 
-  selected_tune = tune ? tune->ident : cpu->ident;
+  selected_tune = (tune != aarch64_no_cpu) ? tune : cpu;
 
   if (aarch_enable_bti == 2)
     {
@@ -19631,7 +19331,7 @@ struct aarch64_attribute_info
 static bool
 aarch64_handle_attr_arch (const char *str)
 {
-  const struct processor *tmp_arch = NULL;
+  aarch64_arch tmp_arch = aarch64_no_arch;
   std::string invalid_extension;
   aarch64_feature_flags tmp_flags;
   enum aarch_parse_opt_result parse_res
@@ -19639,8 +19339,8 @@ aarch64_handle_attr_arch (const char *str)
 
   if (parse_res == AARCH_PARSE_OK)
     {
-      gcc_assert (tmp_arch);
-      selected_arch = tmp_arch->arch;
+      gcc_assert (tmp_arch != aarch64_no_arch);
+      selected_arch = tmp_arch;
       aarch64_set_asm_isa_flags (tmp_flags | (aarch64_asm_isa_flags
 					      & AARCH64_FL_ISA_MODES));
       return true;
@@ -19658,7 +19358,7 @@ aarch64_handle_attr_arch (const char *str)
       case AARCH_PARSE_INVALID_FEATURE:
 	error ("invalid feature modifier %s of value %qs in "
 	       "%<target()%> pragma or attribute", invalid_extension.c_str (), str);
-	aarch64_print_hint_for_extensions (invalid_extension);
+	aarch64_print_hint_for_extensions (invalid_extension.c_str ());
 	break;
       default:
 	gcc_unreachable ();
@@ -19672,7 +19372,7 @@ aarch64_handle_attr_arch (const char *str)
 static bool
 aarch64_handle_attr_cpu (const char *str)
 {
-  const struct processor *tmp_cpu = NULL;
+  aarch64_cpu tmp_cpu = aarch64_no_cpu;
   std::string invalid_extension;
   aarch64_feature_flags tmp_flags;
   enum aarch_parse_opt_result parse_res
@@ -19680,9 +19380,9 @@ aarch64_handle_attr_cpu (const char *str)
 
   if (parse_res == AARCH_PARSE_OK)
     {
-      gcc_assert (tmp_cpu);
-      selected_tune = tmp_cpu->ident;
-      selected_arch = tmp_cpu->arch;
+      gcc_assert (tmp_cpu != aarch64_no_cpu);
+      selected_tune = tmp_cpu;
+      selected_arch = aarch64_get_tune_cpu (tmp_cpu)->arch;
       aarch64_set_asm_isa_flags (tmp_flags | (aarch64_asm_isa_flags
 					      & AARCH64_FL_ISA_MODES));
       return true;
@@ -19700,7 +19400,7 @@ aarch64_handle_attr_cpu (const char *str)
       case AARCH_PARSE_INVALID_FEATURE:
 	error ("invalid feature modifier %qs of value %qs in "
 	       "%<target()%> pragma or attribute", invalid_extension.c_str (), str);
-	aarch64_print_hint_for_extensions (invalid_extension);
+	aarch64_print_hint_for_extensions (invalid_extension.c_str ());
 	break;
       default:
 	gcc_unreachable ();
@@ -19723,14 +19423,14 @@ aarch64_handle_attr_branch_protection (const char* str)
 static bool
 aarch64_handle_attr_tune (const char *str)
 {
-  const struct processor *tmp_tune = NULL;
+  aarch64_cpu tmp_tune = aarch64_no_cpu;
   enum aarch_parse_opt_result parse_res
     = aarch64_parse_tune (str, &tmp_tune);
 
   if (parse_res == AARCH_PARSE_OK)
     {
-      gcc_assert (tmp_tune);
-      selected_tune = tmp_tune->ident;
+      gcc_assert (tmp_tune != aarch64_no_cpu);
+      selected_tune = tmp_tune;
       return true;
     }
 
@@ -21584,6 +21284,7 @@ aarch64_build_builtin_va_list (void)
 			     get_identifier ("__va_list"),
 			     va_list_type);
   DECL_ARTIFICIAL (va_list_name) = 1;
+  TREE_PUBLIC (va_list_name) = 1;
   TYPE_NAME (va_list_type) = va_list_name;
   TYPE_STUB_DECL (va_list_type) = va_list_name;
 
@@ -24352,6 +24053,85 @@ aarch64_simd_make_constant (rtx vals)
     return NULL_RTX;
 }
 
+/* VALS is a PARALLEL rtx that contains element values for a vector of
+   mode MODE.  Return a constant that contains all the CONST_INT and
+   CONST_DOUBLE elements of VALS, using any convenient values for the
+   other elements.  */
+
+static rtx
+aarch64_choose_vector_init_constant (machine_mode mode, rtx vals)
+{
+  unsigned int n_elts = XVECLEN (vals, 0);
+
+  /* We really don't care what goes into the parts we will overwrite, but we're
+     more likely to be able to load the constant efficiently if it has fewer,
+     larger, repeating parts (see aarch64_simd_valid_imm).  */
+  rtvec copy = shallow_copy_rtvec (XVEC (vals, 0));
+  for (unsigned int i = 0; i < n_elts; ++i)
+    {
+      rtx x = RTVEC_ELT (copy, i);
+      if (CONST_INT_P (x) || CONST_DOUBLE_P (x))
+	continue;
+      /* This is effectively a bit-reversed increment, e.g.: 8, 4, 12,
+	 2, 10, 6, 12, ... for n_elts == 16.  The early break makes the
+	 outer "i" loop O(n_elts * log(n_elts)).  */
+      unsigned int j = 0;
+      for (;;)
+	{
+	  for (unsigned int bit = n_elts / 2; bit > 0; bit /= 2)
+	    {
+	      j ^= bit;
+	      if (j & bit)
+		break;
+	    }
+	  rtx test = XVECEXP (vals, 0, i ^ j);
+	  if (CONST_INT_P (test) || CONST_DOUBLE_P (test))
+	    {
+	      RTVEC_ELT (copy, i) = test;
+	      break;
+	    }
+	  gcc_assert (j != 0);
+	}
+    }
+
+  rtx c = gen_rtx_CONST_VECTOR (mode, copy);
+  if (aarch64_simd_valid_mov_imm (c))
+    return c;
+
+  /* Try generating a stepped sequence.  */
+  if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
+    for (unsigned int i = 0; i < n_elts; ++i)
+      if (CONST_INT_P (XVECEXP (vals, 0, i)))
+	{
+	  auto base = UINTVAL (XVECEXP (vals, 0, i));
+	  for (unsigned int j = i + 1; j < n_elts; ++j)
+	    if (CONST_INT_P (XVECEXP (vals, 0, j)))
+	      {
+		/* It doesn't matter whether this division is exact.
+		   All that matters is whether the constant we produce
+		   is valid.  */
+		HOST_WIDE_INT diff = UINTVAL (XVECEXP (vals, 0, j)) - base;
+		unsigned HOST_WIDE_INT step = diff / int (j - i);
+		rtx_vector_builder builder (mode, n_elts, 1);
+		for (unsigned int k = 0; k < n_elts; ++k)
+		  {
+		    rtx x = XVECEXP (vals, 0, k);
+		    if (!CONST_INT_P (x))
+		      x = gen_int_mode (int (k - i) * step + base,
+					GET_MODE_INNER (mode));
+		    builder.quick_push (x);
+		  }
+		rtx step_c = builder.build ();
+		if (aarch64_simd_valid_mov_imm (step_c))
+		  return step_c;
+		break;
+	      }
+	  break;
+	}
+
+  return c;
+}
+
 /* A subroutine of aarch64_expand_vector_init, with the same interface.
    The caller has already tried a divide-and-conquer approach, so do
    not consider that case here.  */
@@ -24365,7 +24145,6 @@ aarch64_expand_vector_init_fallback (rtx target, rtx vals)
   int n_elts = XVECLEN (vals, 0);
   /* The number of vector elements which are not constant.  */
   int n_var = 0;
-  rtx any_const = NULL_RTX;
   /* The first element of vals.  */
   rtx v0 = XVECEXP (vals, 0, 0);
   bool all_same = true;
@@ -24391,8 +24170,6 @@ aarch64_expand_vector_init_fallback (rtx target, rtx vals)
       rtx x = XVECEXP (vals, 0, i);
       if (!(CONST_INT_P (x) || CONST_DOUBLE_P (x)))
 	++n_var;
-      else
-	any_const = x;
 
       all_same &= rtx_equal_p (x, v0);
     }
@@ -24536,31 +24313,9 @@ aarch64_expand_vector_init_fallback (rtx target, rtx vals)
      can.  */
   if (n_var != n_elts)
     {
-      rtx copy = copy_rtx (vals);
-
-      /* Load constant part of vector.  We really don't care what goes into the
-	 parts we will overwrite, but we're more likely to be able to load the
-	 constant efficiently if it has fewer, larger, repeating parts
-	 (see aarch64_simd_valid_imm).  */
-      for (int i = 0; i < n_elts; i++)
-	{
-	  rtx x = XVECEXP (vals, 0, i);
-	  if (CONST_INT_P (x) || CONST_DOUBLE_P (x))
-	    continue;
-	  rtx subst = any_const;
-	  for (int bit = n_elts / 2; bit > 0; bit /= 2)
-	    {
-	      /* Look in the copied vector, as more elements are const.  */
-	      rtx test = XVECEXP (copy, 0, i ^ bit);
-	      if (CONST_INT_P (test) || CONST_DOUBLE_P (test))
-		{
-		  subst = test;
-		  break;
-		}
-	    }
-	  XVECEXP (copy, 0, i) = subst;
-	}
-      aarch64_expand_vector_init_fallback (target, copy);
+      /* Load the constant part of the vector.  */
+      rtx constant = aarch64_choose_vector_init_constant (mode, vals);
+      emit_move_insn (target, constant);
     }
 
   /* Insert the variable lanes directly.  */
@@ -25166,16 +24921,12 @@ aarch64_declare_function_name (FILE *stream, const char* name,
     targ_options = TREE_TARGET_OPTION (target_option_current_node);
   gcc_assert (targ_options);
 
-  const struct processor *this_arch
-    = aarch64_get_arch (targ_options->x_selected_arch);
-
   auto isa_flags = aarch64_get_asm_isa_flags (targ_options);
-  std::string extension
-    = aarch64_get_extension_string_for_isa_flags (isa_flags,
-						  this_arch->flags);
+  aarch64_arch arch = targ_options->x_selected_arch;
+  std::string to_print
+    = aarch64_get_arch_string_for_assembler (arch, isa_flags);
   /* Only update the assembler .arch string if it is distinct from the last
      such string we printed.  */
-  std::string to_print = this_arch->name + extension;
   if (to_print != aarch64_last_printed_arch_string)
     {
       asm_fprintf (asm_out_file, "\t.arch %s\n", to_print.c_str ());
@@ -25297,19 +25048,16 @@ aarch64_start_file (void)
   struct cl_target_option *default_options
     = TREE_TARGET_OPTION (target_option_default_node);
 
-  const struct processor *default_arch
-    = aarch64_get_arch (default_options->x_selected_arch);
+  aarch64_arch default_arch = default_options->x_selected_arch;
   auto default_isa_flags = aarch64_get_asm_isa_flags (default_options);
-  std::string extension
-    = aarch64_get_extension_string_for_isa_flags (default_isa_flags,
-						  default_arch->flags);
-
-   aarch64_last_printed_arch_string = default_arch->name + extension;
-   aarch64_last_printed_tune_string = "";
-   asm_fprintf (asm_out_file, "\t.arch %s\n",
-		aarch64_last_printed_arch_string.c_str ());
-
-   default_file_start ();
+  std::string arch_string
+    = aarch64_get_arch_string_for_assembler (default_arch, default_isa_flags);
+  aarch64_last_printed_arch_string = arch_string;
+  aarch64_last_printed_tune_string = "";
+  asm_fprintf (asm_out_file, "\t.arch %s\n",
+	       arch_string.c_str ());
+
+  default_file_start ();
 }
 
 /* Emit load exclusive.  */
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 1a19b27fd934e4d5af0446008c97f129c7c1ac0f..e8bd8c73c1296f6ad0d8ab16177eab120afa6f9b 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -928,16 +928,9 @@ enum reg_class
 /* CPU/ARCH option handling.  */
 #include "config/aarch64/aarch64-opts.h"
 
-enum target_cpus
-{
-#define AARCH64_CORE(NAME, INTERNAL_IDENT, SCHED, ARCH, FLAGS, COSTS, IMP, PART, VARIANT) \
-  TARGET_CPU_##INTERNAL_IDENT,
-#include "aarch64-cores.def"
-};
-
 /* If there is no CPU defined at configure, use generic as default.  */
 #ifndef TARGET_CPU_DEFAULT
-# define TARGET_CPU_DEFAULT TARGET_CPU_generic_armv8_a
+# define TARGET_CPU_DEFAULT AARCH64_CPU_generic_armv8_a
 #endif
 
 /* If inserting NOP before a mult-accumulate insn remember to adjust the
@@ -953,7 +946,7 @@ enum target_cpus
     aarch64_final_prescan_insn (INSN);			\
 
 /* The processor for which instructions should be scheduled.  */
-extern enum aarch64_processor aarch64_tune;
+extern enum aarch64_cpu aarch64_tune;
 
 /* RTL generation support.  */
 #define INIT_EXPANDERS aarch64_init_expanders ()
@@ -1481,7 +1474,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
 #define HAVE_LOCAL_CPU_DETECT
 # define EXTRA_SPEC_FUNCTIONS                                           \
   { "local_cpu_detect", host_detect_local_cpu },                        \
-  MCPU_TO_MARCH_SPEC_FUNCTIONS
+  AARCH64_BASE_SPEC_FUNCTIONS
 
 /* Rewrite -m{arch,cpu,tune}=native based on the host system information.
    When rewriting -march=native convert it into an -mcpu option if no other
@@ -1498,7 +1491,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
  { "tune", "%{!mcpu=*:%{!mtune=*:%{!march=native:-mtune=%(VALUE)}}}" },
 #else
 # define MCPU_MTUNE_NATIVE_SPECS ""
-# define EXTRA_SPEC_FUNCTIONS MCPU_TO_MARCH_SPEC_FUNCTIONS
+# define EXTRA_SPEC_FUNCTIONS AARCH64_BASE_SPEC_FUNCTIONS
 # define CONFIG_TUNE_SPEC                                                \
   {"tune", "%{!mcpu=*:%{!mtune=*:-mtune=%(VALUE)}}"},
 #endif
@@ -1513,18 +1506,21 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
   {"cpu",  "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" },   \
   CONFIG_TUNE_SPEC
 
-#define MCPU_TO_MARCH_SPEC \
-   "%{!march=*:%{mcpu=*:-march=%:rewrite_mcpu(%{mcpu=*:%*})}}"
+#define MARCH_REWRITE_SPEC \
+   "%{march=*:-march=%:rewrite_march(%{march=*:%*});" \
+     "mcpu=*:-march=%:rewrite_mcpu(%{mcpu=*:%*})}"
 
+extern const char *aarch64_rewrite_march (int argc, const char **argv);
 extern const char *aarch64_rewrite_mcpu (int argc, const char **argv);
 extern const char *is_host_cpu_not_armv8_base (int argc, const char **argv);
-#define MCPU_TO_MARCH_SPEC_FUNCTIONS		       \
+#define AARCH64_BASE_SPEC_FUNCTIONS		       \
+  { "rewrite_march", aarch64_rewrite_march },          \
   { "rewrite_mcpu",            aarch64_rewrite_mcpu }, \
   { "is_local_not_armv8_base", is_host_cpu_not_armv8_base },
 
 
 #define ASM_CPU_SPEC \
-   MCPU_TO_MARCH_SPEC
+   MARCH_REWRITE_SPEC
 
 #define EXTRA_SPECS						\
   { "asm_cpu_spec",		ASM_CPU_SPEC }
diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
index 7e309d9efe46a3eb073f948316441a2cb90959d3..f32d56d4ffaef7862c1c45a11753be5d480220d0 100644
--- a/gcc/config/aarch64/aarch64.opt
+++ b/gcc/config/aarch64/aarch64.opt
@@ -25,7 +25,7 @@ HeaderInclude
 config/arm/aarch-common.h
 
 TargetVariable
-enum aarch64_processor selected_tune = aarch64_none
+enum aarch64_cpu selected_tune = aarch64_no_cpu
 
 TargetVariable
 enum aarch64_arch selected_arch = aarch64_no_arch
diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 1e0791dc8c25f3649bb3401f3905a8dce81e782d..7e2082101d83bcde87d84467d6cf92e196548807 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -2906,6 +2906,7 @@ arm_build_builtin_va_list (void)
 			     get_identifier ("__va_list"),
 			     va_list_type);
   DECL_ARTIFICIAL (va_list_name) = 1;
+  TREE_PUBLIC (va_list_name) = 1;
   TYPE_NAME (va_list_type) = va_list_name;
   TYPE_STUB_DECL (va_list_type) = va_list_name;
   /* Create the __ap field.  */
@@ -14266,6 +14267,30 @@ adjacent_mem_locations (rtx a, rtx b)
   return 0;
 }
 
+/* Helper routine for ldm_stm_operation_p.  Decompose a simple offset
+   address into the base register and the offset.  Return false iff
+   it is more complex than this.  */
+static inline bool
+decompose_addr_for_ldm_stm (rtx addr, rtx *base, HOST_WIDE_INT *offset)
+{
+  if (REG_P (addr))
+    {
+      *base = addr;
+      *offset = 0;
+      return true;
+    }
+  else if (GET_CODE (addr) == PLUS
+      && REG_P (XEXP (addr, 0))
+      && CONST_INT_P (XEXP (addr, 1)))
+    {
+      *base = XEXP (addr, 0);
+      *offset = INTVAL (XEXP (addr, 1));
+      return true;
+    }
+
+  return false;
+}
+
 /* Return true if OP is a valid load or store multiple operation.  LOAD is true
    for load operations, false for store operations.  CONSECUTIVE is true
    if the register numbers in the operation must be consecutive in the register
@@ -14281,23 +14306,25 @@ adjacent_mem_locations (rtx a, rtx b)
      1.  If offset is 0, first insn should be (SET (R_d0) (MEM (src_addr))).
      2.  REGNO (R_d0) < REGNO (R_d1) < ... < REGNO (R_dn).
      3.  If consecutive is TRUE, then for kth register being loaded,
-         REGNO (R_dk) = REGNO (R_d0) + k.
+	 REGNO (R_dk) = REGNO (R_d0) + k.
    The pattern for store is similar.  */
 bool
 ldm_stm_operation_p (rtx op, bool load, machine_mode mode,
-                     bool consecutive, bool return_pc)
+		     bool consecutive, bool return_pc)
 {
-  HOST_WIDE_INT count = XVECLEN (op, 0);
-  rtx reg, mem, addr;
-  unsigned regno;
-  unsigned first_regno;
-  HOST_WIDE_INT i = 1, base = 0, offset = 0;
+  int count = XVECLEN (op, 0);
+  rtx reg, mem;
+  rtx addr_base;
+  int reg_loc, mem_loc;
+  unsigned prev_regno;
+  HOST_WIDE_INT addr_offset;
   rtx elt;
   bool addr_reg_in_reglist = false;
   bool update = false;
-  int reg_increment;
-  int offset_adj;
-  int regs_per_val;
+  int reg_bytes;
+  int words_per_reg;  /* How many words in memory a register takes.  */
+  int elt_num = 0;
+  int base_elt_num;  /* Element number of the first transfer operation.  */
 
   /* If not in SImode, then registers must be consecutive
      (e.g., VLDM instructions for DFmode).  */
@@ -14305,138 +14332,140 @@ ldm_stm_operation_p (rtx op, bool load, machine_mode mode,
   /* Setting return_pc for stores is illegal.  */
   gcc_assert (!return_pc || load);
 
-  /* Set up the increments and the regs per val based on the mode.  */
-  reg_increment = GET_MODE_SIZE (mode);
-  regs_per_val = reg_increment / 4;
-  offset_adj = return_pc ? 1 : 0;
+  /* Set up the increments and sizes for the mode.  */
+  reg_bytes = GET_MODE_SIZE (mode);
+  words_per_reg = ARM_NUM_REGS (mode);
 
-  if (count <= 1
-      || GET_CODE (XVECEXP (op, 0, offset_adj)) != SET
-      || (load && !REG_P (SET_DEST (XVECEXP (op, 0, offset_adj)))))
+  /* If this is a return, then the first element in the par must be
+     (return).  */
+  if (return_pc)
+    {
+      if (GET_CODE (XVECEXP (op, 0, 0)) != RETURN)
+	return false;
+      elt_num++;
+    }
+
+  if (elt_num >= count)
     return false;
 
   /* Check if this is a write-back.  */
-  elt = XVECEXP (op, 0, offset_adj);
+  elt = XVECEXP (op, 0, elt_num);
+  if (GET_CODE (elt) != SET)
+    return false;
   if (GET_CODE (SET_SRC (elt)) == PLUS)
     {
-      i++;
-      base = 1;
+      elt_num++;
       update = true;
 
       /* The offset adjustment must be the number of registers being
-         popped times the size of a single register.  */
+	 popped times the size of a single register.  */
       if (!REG_P (SET_DEST (elt))
-          || !REG_P (XEXP (SET_SRC (elt), 0))
-          || (REGNO (SET_DEST (elt)) != REGNO (XEXP (SET_SRC (elt), 0)))
-          || !CONST_INT_P (XEXP (SET_SRC (elt), 1))
-          || INTVAL (XEXP (SET_SRC (elt), 1)) !=
-             ((count - 1 - offset_adj) * reg_increment))
-        return false;
+	  || !REG_P (XEXP (SET_SRC (elt), 0))
+	  || (REGNO (SET_DEST (elt)) != REGNO (XEXP (SET_SRC (elt), 0)))
+	  || !CONST_INT_P (XEXP (SET_SRC (elt), 1))
+	  /* ??? Can't this be negative for a PUSH?  */
+	  || (INTVAL (XEXP (SET_SRC (elt), 1)) !=
+	      ((count - elt_num) * reg_bytes)))
+	return false;
     }
 
-  i = i + offset_adj;
-  base = base + offset_adj;
-  /* Perform a quick check so we don't blow up below. If only one reg is loaded,
-     success depends on the type: VLDM can do just one reg,
-     LDM must do at least two.  */
-  if ((count <= i) && (mode == SImode))
-      return false;
+  base_elt_num = elt_num;
+  /* There must be at least one register to transfer.  */
+  if (base_elt_num >= count)
+    return false;
 
-  elt = XVECEXP (op, 0, i - 1);
+  elt = XVECEXP (op, 0, elt_num);
   if (GET_CODE (elt) != SET)
     return false;
 
+  /* Where to look for the register and memory elements.  These save us
+     needing to check LOAD multiple times in the loop.  */
   if (load)
     {
-      reg = SET_DEST (elt);
-      mem = SET_SRC (elt);
+      reg_loc = 0;  /* SET_DEST.  */
+      mem_loc = 1;  /* SET_SRC.  */
     }
   else
     {
-      reg = SET_SRC (elt);
-      mem = SET_DEST (elt);
+      mem_loc = 0;  /* SET_DEST.  */
+      reg_loc = 1;  /* SET_SRC.  */
     }
 
+  reg = XEXP (elt, reg_loc);
+  mem = XEXP (elt, mem_loc);
+
   if (!REG_P (reg) || !MEM_P (mem))
     return false;
 
-  regno = REGNO (reg);
-  first_regno = regno;
-  addr = XEXP (mem, 0);
-  if (GET_CODE (addr) == PLUS)
-    {
-      if (!CONST_INT_P (XEXP (addr, 1)))
-	return false;
-
-      offset = INTVAL (XEXP (addr, 1));
-      addr = XEXP (addr, 0);
-    }
-
-  if (!REG_P (addr))
+  prev_regno = REGNO (reg);
+  if (!decompose_addr_for_ldm_stm (XEXP (mem, 0), &addr_base, &addr_offset))
     return false;
 
-  /* Don't allow SP to be loaded unless it is also the base register. It
-     guarantees that SP is reset correctly when an LDM instruction
-     is interrupted. Otherwise, we might end up with a corrupt stack.  */
-  if (load && (REGNO (reg) == SP_REGNUM) && (REGNO (addr) != SP_REGNUM))
+  /* Don't allow SP to be loaded unless it is also the base register.
+     Otherwise SP will not be correctly restored if an LDM instruction is
+     interrupted (low latency interrupt or address fault), which can result in
+     stack corruption.  */
+  if (load && (REGNO (reg) == SP_REGNUM) && (REGNO (addr_base) != SP_REGNUM))
     return false;
 
-  if (regno == REGNO (addr))
-    addr_reg_in_reglist = true;
+  addr_reg_in_reglist = (prev_regno == REGNO (addr_base));
 
-  for (; i < count; i++)
+  for (elt_num++; elt_num < count; elt_num++)
     {
-      elt = XVECEXP (op, 0, i);
+      rtx elt_base;
+      HOST_WIDE_INT elt_offset;
+
+      elt = XVECEXP (op, 0, elt_num);
       if (GET_CODE (elt) != SET)
-        return false;
+	return false;
 
-      if (load)
-        {
-          reg = SET_DEST (elt);
-          mem = SET_SRC (elt);
-        }
-      else
-        {
-          reg = SET_SRC (elt);
-          mem = SET_DEST (elt);
-        }
+      reg = XEXP (elt, reg_loc);
+      mem = XEXP (elt, mem_loc);
 
       if (!REG_P (reg)
-          || GET_MODE (reg) != mode
-          || REGNO (reg) <= regno
-          || (consecutive
-              && (REGNO (reg) !=
-                  (unsigned int) (first_regno + regs_per_val * (i - base))))
-          /* Don't allow SP to be loaded unless it is also the base register. It
-             guarantees that SP is reset correctly when an LDM instruction
-             is interrupted. Otherwise, we might end up with a corrupt stack.  */
-          || (load && (REGNO (reg) == SP_REGNUM) && (REGNO (addr) != SP_REGNUM))
-          || !MEM_P (mem)
-          || GET_MODE (mem) != mode
-          || ((GET_CODE (XEXP (mem, 0)) != PLUS
-	       || !rtx_equal_p (XEXP (XEXP (mem, 0), 0), addr)
-	       || !CONST_INT_P (XEXP (XEXP (mem, 0), 1))
-	       || (INTVAL (XEXP (XEXP (mem, 0), 1)) !=
-                   offset + (i - base) * reg_increment))
-	      && (!REG_P (XEXP (mem, 0))
-		  || offset + (i - base) * reg_increment != 0)))
-        return false;
+	  || GET_MODE (reg) != mode
+	  || REGNO (reg) <= prev_regno
+	  || (consecutive
+	      && REGNO (reg) != prev_regno + words_per_reg)
+	  /* Don't allow SP to be loaded unless it is also the base register
+	     (see similar comment above).  */
+	  || (load
+	      && (REGNO (reg) == SP_REGNUM)
+	      && (REGNO (addr_base) != SP_REGNUM))
+	  || !MEM_P (mem)
+	  || GET_MODE (mem) != mode
+	  || !decompose_addr_for_ldm_stm (XEXP (mem, 0), &elt_base,
+					  &elt_offset)
+	  || REGNO (addr_base) != REGNO (elt_base)
+	  || addr_offset + (elt_num - base_elt_num) * reg_bytes != elt_offset)
+	return false;
 
-      regno = REGNO (reg);
-      if (regno == REGNO (addr))
-        addr_reg_in_reglist = true;
+      prev_regno = REGNO (reg);
+      if (prev_regno == REGNO (addr_base))
+	{
+	  /* Storing the base register is unpredictable if it is not the first
+	     transfer register and the base register is being modified.  */
+	  if (update && !load)
+	    return false;
+	  addr_reg_in_reglist = true;
+	}
     }
 
   if (load)
     {
       if (update && addr_reg_in_reglist)
-        return false;
+	return false;
+
+      /* A return instruction must load PC last.  */
+      if (return_pc && prev_regno != PC_REGNUM)
+	return false;
 
-      /* For Thumb-1, address register is always modified - either by write-back
-         or by explicit load.  If the pattern does not describe an update,
-         then the address register must be in the list of loaded registers.  */
+      /* For Thumb-1, address register is always modified - either by
+	 write-back or by explicit load.  If the pattern does not describe an
+	 update, then the address register must be in the list of loaded
+	 registers.  */
       if (TARGET_THUMB1)
-        return update || addr_reg_in_reglist;
+	return update || addr_reg_in_reglist;
     }
 
   return true;
@@ -27733,35 +27762,40 @@ thumb2_expand_return (bool simple_return)
       /* TODO: Verify that this path is never taken for cmse_nonsecure_entry
 	 functions or adapt code to handle according to ACLE.  This path should
 	 not be reachable for cmse_nonsecure_entry functions though we prefer
-	 to assert it for now to ensure that future code changes do not silently
-	 change this behavior.  */
+	 to assert it for now to ensure that future code changes do not
+	 silently change this behavior.  */
       gcc_assert (!IS_CMSE_ENTRY (arm_current_func_type ()));
       if (arm_current_function_pac_enabled_p ())
-        {
-          gcc_assert (!(saved_regs_mask & (1 << PC_REGNUM)));
-          arm_emit_multi_reg_pop (saved_regs_mask);
-          emit_insn (gen_aut_nop ());
-          emit_jump_insn (simple_return_rtx);
-        }
-      else if (num_regs == 1)
-        {
-          rtx par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
-          rtx reg = gen_rtx_REG (SImode, PC_REGNUM);
-          rtx addr = gen_rtx_MEM (SImode,
-                                  gen_rtx_POST_INC (SImode,
-                                                    stack_pointer_rtx));
-          set_mem_alias_set (addr, get_frame_alias_set ());
-          XVECEXP (par, 0, 0) = ret_rtx;
-          XVECEXP (par, 0, 1) = gen_rtx_SET (reg, addr);
-          RTX_FRAME_RELATED_P (XVECEXP (par, 0, 1)) = 1;
-          emit_jump_insn (par);
-        }
+	{
+	  gcc_assert (!(saved_regs_mask & (1 << PC_REGNUM)));
+	  arm_emit_multi_reg_pop (saved_regs_mask);
+	  emit_insn (gen_aut_nop ());
+	  emit_jump_insn (simple_return_rtx);
+	}
+      /* Use LDR PC, [sp], #4.  Only do this if not optimizing for size and
+	 there's a known performance benefit (we don't know this exactly, but
+	 preferring LDRD/STRD over LDM/STM is a reasonable proxy).  */
+      else if (num_regs == 1
+	       && !optimize_size
+	       && current_tune->prefer_ldrd_strd)
+	{
+	  rtx par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
+	  rtx reg = gen_rtx_REG (SImode, PC_REGNUM);
+	  rtx addr = gen_rtx_MEM (SImode,
+				  gen_rtx_POST_INC (SImode,
+						    stack_pointer_rtx));
+	  set_mem_alias_set (addr, get_frame_alias_set ());
+	  XVECEXP (par, 0, 0) = ret_rtx;
+	  XVECEXP (par, 0, 1) = gen_rtx_SET (reg, addr);
+	  RTX_FRAME_RELATED_P (XVECEXP (par, 0, 1)) = 1;
+	  emit_jump_insn (par);
+	}
       else
-        {
-          saved_regs_mask &= ~ (1 << LR_REGNUM);
-          saved_regs_mask |=   (1 << PC_REGNUM);
-          arm_emit_multi_reg_pop (saved_regs_mask);
-        }
+	{
+	  saved_regs_mask &= ~ (1 << LR_REGNUM);
+	  saved_regs_mask |=   (1 << PC_REGNUM);
+	  arm_emit_multi_reg_pop (saved_regs_mask);
+	}
     }
   else
     {
@@ -28175,7 +28209,10 @@ arm_expand_epilogue (bool really_return)
           return_in_pc = true;
         }
 
-      if (num_regs == 1 && (!IS_INTERRUPT (func_type) || !return_in_pc))
+      if (num_regs == 1
+	  && !optimize_size
+	  && current_tune->prefer_ldrd_strd
+	  && !(IS_INTERRUPT (func_type) && return_in_pc))
         {
           for (i = 0; i <= LAST_ARM_REGNUM; i++)
             if (saved_regs_mask & (1 << i))
diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
index 842903e0bcdbfc88b2d382e0c1ff3a18c2b65af4..442d86b932926e85d438f28e8666face4bd2cf92 100644
--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -11964,12 +11964,10 @@
 (define_insn "*pop_multiple_with_writeback_and_return"
   [(match_parallel 0 "pop_multiple_return"
     [(return)
-     (set (match_operand:SI 1 "s_register_operand" "+rk")
+     (set (match_operand:SI 1 "register_operand" "")
           (plus:SI (match_dup 1)
-                   (match_operand:SI 2 "const_int_I_operand" "I")))
-     (set (match_operand:SI 3 "s_register_operand" "=rk")
-          (mem:SI (match_dup 1)))
-        ])]
+                   (match_operand:SI 2 "const_int_I_operand" "")))
+    ])]
   "TARGET_32BIT && (reload_in_progress || reload_completed)"
   "*
   {
diff --git a/gcc/config/arm/t-rtems b/gcc/config/arm/t-rtems
index b2fcf572bca92a712e2caa847f22da8346f0db67..797640bd4f4532cd021e36198ee359a9a49493f9 100644
--- a/gcc/config/arm/t-rtems
+++ b/gcc/config/arm/t-rtems
@@ -17,8 +17,8 @@ MULTILIB_DIRNAMES	+= eb
 MULTILIB_OPTIONS	+= mthumb
 MULTILIB_DIRNAMES	+= thumb
 
-MULTILIB_OPTIONS	+= march=armv5te+fp/march=armv6-m/march=armv7-a/march=armv7-a+simd/march=armv7-r/march=armv7-r+fp/mcpu=cortex-r52/mcpu=cortex-m3/mcpu=cortex-m4/mcpu=cortex-m4+nofp/mcpu=cortex-m7
-MULTILIB_DIRNAMES	+= armv5te+fp       armv6-m       armv7-a       armv7-a+simd       armv7-r       armv7-r+fp       cortex-r52      cortex-m3      cortex-m4      cortex-m4+nofp      cortex-m7
+MULTILIB_OPTIONS	+= march=armv5te+fp/march=armv6-m/march=armv7-a/march=armv7-a+simd/march=armv7-r/march=armv7-r+fp/mcpu=cortex-r52/mcpu=cortex-m3/mcpu=cortex-m33/mcpu=cortex-m4/mcpu=cortex-m4+nofp/mcpu=cortex-m7
+MULTILIB_DIRNAMES	+= armv5te+fp       armv6-m       armv7-a       armv7-a+simd       armv7-r       armv7-r+fp       cortex-r52      cortex-m3      cortex-m33      cortex-m4      cortex-m4+nofp      cortex-m7
 
 MULTILIB_OPTIONS	+= mfloat-abi=hard
 MULTILIB_DIRNAMES	+= hard
@@ -33,6 +33,7 @@ MULTILIB_REQUIRED	+= mthumb/march=armv7-r+fp/mfloat-abi=hard
 MULTILIB_REQUIRED	+= mthumb/march=armv7-r
 MULTILIB_REQUIRED	+= mthumb/mcpu=cortex-r52/mfloat-abi=hard
 MULTILIB_REQUIRED	+= mthumb/mcpu=cortex-m3
+MULTILIB_REQUIRED	+= mthumb/mcpu=cortex-m33
 MULTILIB_REQUIRED	+= mthumb/mcpu=cortex-m4/mfloat-abi=hard
 MULTILIB_REQUIRED	+= mthumb/mcpu=cortex-m4+nofp
 MULTILIB_REQUIRED	+= mthumb/mcpu=cortex-m7/mfloat-abi=hard
diff --git a/gcc/config/avr/avr-c.cc b/gcc/config/avr/avr-c.cc
index 53f15f2be7b3b743052c2f8865b2a4f8e2e2d6cb..f4236555bf6cf326ea98b3633052326e974081eb 100644
--- a/gcc/config/avr/avr-c.cc
+++ b/gcc/config/avr/avr-c.cc
@@ -500,7 +500,8 @@ avr_cpu_cpp_builtins (cpp_reader *pfile)
      not a specific builtin is available. */
 
 #define DEF_BUILTIN(NAME, N_ARGS, TYPE, CODE, LIBNAME, ATTRS) \
-  cpp_define (pfile, "__BUILTIN_AVR_" #NAME);
+  if (avr_builtin_supported_p (AVR_BUILTIN_ ## NAME))	      \
+    cpp_define (pfile, "__BUILTIN_AVR_" #NAME);
 #include "builtins.def"
 #undef DEF_BUILTIN
 
diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h
index 83137c7f6f63fbee8c3354ec936483b301261d22..6f37c48143ec82377a785ba18eec9ae2deaf864d 100644
--- a/gcc/config/avr/avr-protos.h
+++ b/gcc/config/avr/avr-protos.h
@@ -21,6 +21,7 @@
 
 extern bool avr_function_arg_regno_p (int r);
 extern void avr_cpu_cpp_builtins (cpp_reader * pfile);
+extern bool avr_builtin_supported_p (unsigned id);
 extern enum reg_class avr_regno_reg_class (int r);
 extern void asm_globalize_label (FILE *file, const char *name);
 extern void avr_adjust_reg_alloc_order (void);
diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 656d3e7389b4f2a7c812346ed31191d245d11f8d..9454cb933d7c358bcd309c661ff61244bc85c789 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -15689,6 +15689,27 @@ avr_bdesc[AVR_BUILTIN_COUNT] =
   };
 
 
+/* Some of our built-in function are available for GNU-C only:
+   - Built-ins that use named address-spaces.
+   - Built-ins that use fixed-point types.  */
+
+bool
+avr_builtin_supported_p (unsigned id)
+{
+  const bool uses_as = (id == AVR_BUILTIN_FLASH_SEGMENT
+			|| id == AVR_BUILTIN_STRLEN_FLASH
+			|| id == AVR_BUILTIN_STRLEN_FLASHX
+			|| id == AVR_BUILTIN_STRLEN_MEMX);
+
+  // We don't support address-spaces on Reduced Tiny.
+  if (AVR_TINY && uses_as)
+    return false;
+
+  return (lang_GNU_C ()
+	  || id < AVR_FIRST_C_ONLY_BUILTIN_ID);
+}
+
+
 /* Implement `TARGET_BUILTIN_DECL'.  */
 
 static tree
@@ -15714,6 +15735,25 @@ avr_init_builtin_int24 (void)
 }
 
 
+/* Return a function signature type similar to strlen, but where
+   the address is qualified by named address-space AS.  */
+
+static tree
+avr_ftype_strlen (addr_space_t as)
+{
+  tree const_AS_char_node
+    = build_qualified_type (char_type_node,
+			    TYPE_QUAL_CONST | ENCODE_QUAL_ADDR_SPACE (as));
+  tree const_AS_ptr_type_node
+    = build_pointer_type_for_mode (const_AS_char_node,
+				   avr_addr_space_pointer_mode (as), false);
+  tree size_ftype_const_AS_char_ptr
+    = build_function_type_list (size_type_node, const_AS_ptr_type_node, NULL);
+
+  return size_ftype_const_AS_char_ptr;
+}
+
+
 /* Implement `TARGET_INIT_BUILTINS' */
 /* Set up all builtin functions for this target.  */
 
@@ -15771,6 +15811,10 @@ avr_init_builtins (void)
 				const_memx_ptr_type_node,
 				NULL);
 
+  tree strlen_flash_node = avr_ftype_strlen (ADDR_SPACE_FLASH);
+  tree strlen_flashx_node = avr_ftype_strlen (ADDR_SPACE_FLASHX);
+  tree strlen_memx_node = avr_ftype_strlen (ADDR_SPACE_MEMX);
+
 #define ITYP(T)                                                         \
   lang_hooks.types.type_for_size (TYPE_PRECISION (T), TYPE_UNSIGNED (T))
 
@@ -15891,9 +15935,10 @@ avr_init_builtins (void)
     char *name = (char *) alloca (1 + strlen (Name));			\
 									\
     gcc_assert (id < AVR_BUILTIN_COUNT);				\
-    avr_bdesc[id].fndecl						\
-      = add_builtin_function (avr_tolower (name, Name), TYPE, id,	\
-			      BUILT_IN_MD, LIBNAME, ATTRS);		\
+    avr_bdesc[id].fndecl = avr_builtin_supported_p (id)			\
+      ? add_builtin_function (avr_tolower (name, Name), TYPE, id,	\
+			      BUILT_IN_MD, LIBNAME, ATTRS)		\
+      : NULL_TREE;							\
   }
 #include "builtins.def"
 #undef DEF_BUILTIN
@@ -16161,6 +16206,13 @@ avr_fold_builtin (tree fndecl, int /*n_args*/, tree *arg, bool /*ignore*/)
 			    build_int_cst (val_type, 4));
       }
 
+    case AVR_BUILTIN_STRLEN_FLASH:
+    case AVR_BUILTIN_STRLEN_FLASHX:
+    case AVR_BUILTIN_STRLEN_MEMX:
+      if (tree len = c_strlen (arg[0], 0))
+	return len;
+      break;
+
     case AVR_BUILTIN_ABSHR:
     case AVR_BUILTIN_ABSR:
     case AVR_BUILTIN_ABSLR:
diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md
index 1c956114a4b87b196b3f7e06f26deb01291524bb..06e31aa7d72d13aacff5cf3f2d7eebb1537658bb 100644
--- a/gcc/config/avr/avr.md
+++ b/gcc/config/avr/avr.md
@@ -6299,6 +6299,15 @@
   ""
   [(set_attr "isa" "*,*,mov,movw")])
 
+(define_insn "*negsi2.libgcc"
+  [(set (reg:SI REG_22)
+        (neg:SI (reg:SI REG_22)))
+   (clobber (reg:CC REG_CC))]
+  "reload_completed
+   && optimize_size"
+  "%~call __negsi2"
+  [(set_attr "type" "xcall")])
+
 (define_insn "*negsi2"
   [(set (match_operand:SI 0 "register_operand"       "=!d,r,&r,&r")
         (neg:SI (match_operand:SI 1 "register_operand" "0,0,r ,r")))
diff --git a/gcc/config/avr/builtins.def b/gcc/config/avr/builtins.def
index 61dbc3a6c1be4369bd100ccc87d39653b7d14d14..c96108977844252247288353890a8fcca15bd403 100644
--- a/gcc/config/avr/builtins.def
+++ b/gcc/config/avr/builtins.def
@@ -34,6 +34,8 @@
    ATTRS:   Function attributes like "attr_const" for the `const' attribute
             or "NULL_TREE" for no attribute.  */
 
+#define AVR_FIRST_C_ONLY_BUILTIN_ID AVR_BUILTIN_FLASH_SEGMENT
+
 /* Mapped to respective instruction.  */
 
 DEF_BUILTIN (NOP,  -1, void_ftype_void, nothing, NULL, NULL_TREE)
@@ -56,8 +58,19 @@ DEF_BUILTIN (DELAY_CYCLES, -1, void_ftype_uintSI, nothing, NULL, NULL_TREE)
 DEF_BUILTIN (NOPS,         -1, void_ftype_uintSI, nothing, NULL, NULL_TREE)
 DEF_BUILTIN (MASK1,       2, uintQI_ftype_uintQI_uintQI, gen_mask1, NULL, attr_const)
 DEF_BUILTIN (INSERT_BITS, 3, uintQI_ftype_uintSI_uintQI_uintQI, insert_bits, NULL, attr_const)
+
+/* All following built-ins are C only, see avr.cc::avr_builtin_C_only_p()
+ * since they are using named address-spaces or fixed-point types, none
+ * of which are supported for C++.  */
+
 DEF_BUILTIN (FLASH_SEGMENT, 1, intQI_ftype_const_memx_ptr, flash_segment, NULL, attr_const)
 
+/* strlen for ASes so that __builtin_constant_p can be used wthout raising
+   a diagnostic from -Waddr-space-convert in some AVR-LibC headers.  */
+DEF_BUILTIN (STRLEN_FLASH,  1, strlen_flash_node,  nothing, "__strlen_P", attr_const) // AVR-LibC
+DEF_BUILTIN (STRLEN_FLASHX, 1, strlen_flashx_node, nothing, "strlen_PF",  attr_const) // AVR-LibC
+DEF_BUILTIN (STRLEN_MEMX,   1, strlen_memx_node,   nothing, "__strlen_memx", NULL_TREE)
+
 /* ISO/IEC TR 18037 "Embedded C"
    The following builtins are undocumented and used by stdfix.h.  */
 
diff --git a/gcc/config/bfin/bfin.md b/gcc/config/bfin/bfin.md
index 810bd52cadf00bd370c7e552168533073ade56c8..27c156b6c1e81b05c663c1781f06438df0c52853 100644
--- a/gcc/config/bfin/bfin.md
+++ b/gcc/config/bfin/bfin.md
@@ -1440,12 +1440,15 @@
   "%0 = min(%1,%2)%!"
   [(set_attr "type" "dsp32")])
 
-(define_insn "abssi2"
-  [(set (match_operand:SI 0 "register_operand" "=d")
-	(abs:SI (match_operand:SI 1 "register_operand" "d")))]
-  ""
-  "%0 = abs %1%!"
-  [(set_attr "type" "dsp32")])
+;; The ABS instruction is defined as saturating.  So at the least
+;; it is inappropriate for -fwrapv.  This also fixes the C23 uabs
+;; tests.
+;;(define_insn "abssi2"
+;;  [(set (match_operand:SI 0 "register_operand" "=d")
+;;	(abs:SI (match_operand:SI 1 "register_operand" "d")))]
+;;  ""
+;;  "%0 = abs %1%!"
+;;  [(set_attr "type" "dsp32")])
 
 (define_insn "ssabssi2"
   [(set (match_operand:SI 0 "register_operand" "=d")
diff --git a/gcc/config/h8300/constraints.md b/gcc/config/h8300/constraints.md
index 65579267359782e72014ff4bc19e921ba6f8bcc9..ba76df834a65bf71d4217d1913ed0de1efa7d214 100644
--- a/gcc/config/h8300/constraints.md
+++ b/gcc/config/h8300/constraints.md
@@ -168,13 +168,9 @@
   (and (match_code "const_int")
        (match_test "!h8300_shift_needs_scratch_p (ival, SImode, CLOBBER)")))
 
-(define_constraint "U"
+(define_memory_constraint "U"
   "An operand valid for a bset destination."
-  (ior (and (match_code "reg")
-	    (match_test "(reload_in_progress || reload_completed)
-			 ? REG_OK_FOR_BASE_STRICT_P (op)
-			 : REG_OK_FOR_BASE_P (op)"))
-       (and (match_code "mem")
+  (ior (and (match_code "mem")
 	    (match_code "reg" "0")
 	    (match_test "(reload_in_progress || reload_completed)
 			 ? REG_OK_FOR_BASE_STRICT_P (XEXP (op, 0))
diff --git a/gcc/config/h8300/logical.md b/gcc/config/h8300/logical.md
index 5df0922ef4e0d3f56c3d6358b7d32f13beabf15e..f848242ac87342a639520a9449acca64bf5f46d1 100644
--- a/gcc/config/h8300/logical.md
+++ b/gcc/config/h8300/logical.md
@@ -32,7 +32,7 @@
 ;; ----------------------------------------------------------------------
 
 (define_insn_and_split "*andqi3_2"
-  [(set (match_operand:QI 0 "bit_operand" "=U,rQ,r")
+  [(set (match_operand:QI 0 "bit_operand" "=rU,rQ,r")
 	(and:QI (match_operand:QI 1 "bit_operand" "%0,0,WU")
 		(match_operand:QI 2 "h8300_src_operand" "Y0,rQi,IP1>X")))]
   "TARGET_H8300SX"
@@ -42,7 +42,7 @@
 	      (clobber (reg:CC CC_REG))])])
 
 (define_insn "*andqi3_2_clobber_flags"
-  [(set (match_operand:QI 0 "bit_operand" "=U,rQ,r")
+  [(set (match_operand:QI 0 "bit_operand" "=rU,rQ,r")
 	(and:QI (match_operand:QI 1 "bit_operand" "%0,0,WU")
 		(match_operand:QI 2 "h8300_src_operand" "Y0,rQi,IP1>X")))
    (clobber (reg:CC CC_REG))]
@@ -55,7 +55,7 @@
    (set_attr "length_table" "*,logicb,*")])
 
 (define_insn_and_split "andqi3_1"
-  [(set (match_operand:QI 0 "bit_operand" "=U,r")
+  [(set (match_operand:QI 0 "bit_operand" "=rU,r")
 	(and:QI (match_operand:QI 1 "bit_operand" "%0,0")
 		(match_operand:QI 2 "h8300_src_operand" "Y0,rn")))]
   "register_operand (operands[0], QImode)
@@ -156,7 +156,7 @@
 ;; ----------------------------------------------------------------------
 
 (define_insn_and_split "<code>qi3_1"
-  [(set (match_operand:QI 0 "bit_operand" "=U,rQ")
+  [(set (match_operand:QI 0 "bit_operand" "=rU,rQ")
 	(ors:QI (match_operand:QI 1 "bit_operand" "%0,0")
 		(match_operand:QI 2 "h8300_src_operand" "Y2,rQi")))]
   "TARGET_H8300SX || register_operand (operands[0], QImode)
diff --git a/gcc/config/h8300/testcompare.md b/gcc/config/h8300/testcompare.md
index efa66d274c7a3b9ba2e1d841a111d923435683cf..694c9e60d4eabf4d93c69414904efa2e52b528b3 100644
--- a/gcc/config/h8300/testcompare.md
+++ b/gcc/config/h8300/testcompare.md
@@ -4,7 +4,7 @@
 
 ;; (define_insn_and_split "*tst_extzv_1_n"
 ;;   [(set (cc0)
-;; 	(compare (zero_extract:SI (match_operand:QI 0 "general_operand_src" "r,U,mn>")
+;; 	(compare (zero_extract:SI (match_operand:QI 0 "general_operand_src" "r,rU,mn>")
 ;; 				  (const_int 1)
 ;; 				  (match_operand 1 "const_int_operand" "n,n,n"))
 ;; 		 (const_int 0)))
diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md
index 9dd280568bdd8920b6409eccff3e00571ff71f0a..38877a7e61bdccd042de195e1ce22efca13e4dec 100644
--- a/gcc/config/i386/constraints.md
+++ b/gcc/config/i386/constraints.md
@@ -203,21 +203,19 @@
 
 (define_constraint "Bs"
   "@internal Sibcall memory operand."
-  (ior (and (not (match_test "TARGET_INDIRECT_BRANCH_REGISTER"))
-	    (not (match_test "TARGET_X32"))
-	    (match_operand 0 "sibcall_memory_operand"))
-       (and (match_test "TARGET_X32")
-	    (match_test "Pmode == DImode")
-	    (match_operand 0 "GOT_memory_operand"))))
+  (and (not (match_test "TARGET_INDIRECT_BRANCH_REGISTER"))
+       (if_then_else (match_test "TARGET_X32")
+         (and (match_test "Pmode == DImode")
+              (match_operand 0 "GOT_memory_operand"))
+         (match_operand 0 "sibcall_memory_operand"))))
 
 (define_constraint "Bw"
   "@internal Call memory operand."
-  (ior (and (not (match_test "TARGET_INDIRECT_BRANCH_REGISTER"))
-	    (not (match_test "TARGET_X32"))
-	    (match_operand 0 "memory_operand"))
-       (and (match_test "TARGET_X32")
-	    (match_test "Pmode == DImode")
-	    (match_operand 0 "GOT_memory_operand"))))
+  (and (not (match_test "TARGET_INDIRECT_BRANCH_REGISTER"))
+       (if_then_else (match_test "TARGET_X32")
+         (and (match_test "Pmode == DImode")
+              (match_operand 0 "GOT_memory_operand"))
+         (match_operand 0 "memory_operand"))))
 
 (define_constraint "Bz"
   "@internal Constant call address operand."
diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index 117f6f6f7eb0ddb7a8d32ff4b8d4b768745340dd..9590cd9a8c98ba1e5dbfbeac25b6a0627d1fff8f 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -10225,13 +10225,15 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1,
     fnaddr = gen_rtx_MEM (QImode, construct_plt_address (XEXP (fnaddr, 0)));
   /* Since x32 GOT slot is 64 bit with zero upper 32 bits, indirect
      branch via x32 GOT slot is OK.  */
-  else if (!(TARGET_X32
-	     && MEM_P (fnaddr)
-	     && GET_CODE (XEXP (fnaddr, 0)) == ZERO_EXTEND
-	     && GOT_memory_operand (XEXP (XEXP (fnaddr, 0), 0), Pmode))
-	   && (sibcall
-	       ? !sibcall_insn_operand (XEXP (fnaddr, 0), word_mode)
-	       : !call_insn_operand (XEXP (fnaddr, 0), word_mode)))
+  else if (TARGET_X32
+      && MEM_P (fnaddr)
+      && GET_CODE (XEXP (fnaddr, 0)) == ZERO_EXTEND
+      && GOT_memory_operand (XEXP (XEXP (fnaddr, 0), 0), Pmode)
+      && !TARGET_INDIRECT_BRANCH_REGISTER)
+    ;
+  else if (sibcall
+	   ? !sibcall_insn_operand (XEXP (fnaddr, 0), word_mode)
+	   : !call_insn_operand (XEXP (fnaddr, 0), word_mode))
     {
       fnaddr = convert_to_mode (word_mode, XEXP (fnaddr, 0), 1);
       fnaddr = gen_rtx_MEM (QImode, copy_to_mode_reg (word_mode, fnaddr));
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
index f122fd8a0a36e42e699be886c7ce53684647f5e3..bea3fd4b2e2a3061151d1616da9c1b660a5d6c82 100644
--- a/gcc/config/i386/i386-protos.h
+++ b/gcc/config/i386/i386-protos.h
@@ -371,6 +371,7 @@ extern int asm_preferred_eh_data_format (int, int);
 extern enum attr_cpu ix86_schedule;
 #endif
 
+extern bool ix86_nopic_noplt_attribute_p (rtx call_op);
 extern const char * ix86_output_call_insn (rtx_insn *insn, rtx call_op);
 extern const char * ix86_output_indirect_jmp (rtx call_op);
 extern const char * ix86_output_function_return (bool long_p);
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 11770aa8a50004817435ab65f00abed7d58894f4..f89201684a8a43d914a64ff3a45551574497cbe1 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -16724,7 +16724,7 @@ ix86_ifunc_ref_local_ok (void)
    This is currently used only with 64-bit or 32-bit GOT32X ELF targets
    to call the function marked "noplt" indirectly.  */
 
-static bool
+bool
 ix86_nopic_noplt_attribute_p (rtx call_op)
 {
   if (flag_pic || ix86_cmodel == CM_LARGE
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 52c02b6351a213c9c5f7bc6d06794f47fda32f23..27cd6c117b4eb511553ee06f46ec1eba7b2e6f0c 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -20133,7 +20133,7 @@
   [(call (mem:QI (zero_extend:DI
 		   (match_operand:SI 0 "GOT_memory_operand" "Bg")))
 	 (match_operand 1))]
-  "TARGET_X32"
+  "TARGET_X32 && !TARGET_INDIRECT_BRANCH_REGISTER"
 {
   rtx fnaddr = gen_const_mem (DImode, XEXP (operands[0], 0));
   return ix86_output_call_insn (insn, fnaddr);
@@ -20149,8 +20149,7 @@
 		     (match_operand:SI 1 "GOT32_symbol_operand"))))
 	 (match_operand 2))]
   "!TARGET_MACHO
-  && !TARGET_64BIT
-  && !TARGET_INDIRECT_BRANCH_REGISTER
+  && !TARGET_64BIT && !TARGET_INDIRECT_BRANCH_REGISTER
   && SIBLING_CALL_P (insn)"
 {
   rtx fnaddr = gen_rtx_PLUS (SImode, operands[0], operands[1]);
@@ -20179,8 +20178,7 @@
 	(match_operand:W 1 "memory_operand"))
    (call (mem:QI (match_dup 0))
 	 (match_operand 3))]
-  "!TARGET_X32
-   && !TARGET_INDIRECT_BRANCH_REGISTER
+  "!TARGET_X32 && !TARGET_INDIRECT_BRANCH_REGISTER
    && SIBLING_CALL_P (peep2_next_insn (1))
    && !reg_mentioned_p (operands[0],
 			CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
@@ -20194,8 +20192,7 @@
    (unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)
    (call (mem:QI (match_dup 0))
 	 (match_operand 3))]
-  "!TARGET_X32
-   && !TARGET_INDIRECT_BRANCH_REGISTER
+  "!TARGET_X32 && !TARGET_INDIRECT_BRANCH_REGISTER
    && SIBLING_CALL_P (peep2_next_insn (2))
    && !reg_mentioned_p (operands[0],
 			CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
@@ -20244,7 +20241,7 @@
 	(plus:SI (reg:SI SP_REG)
 		 (match_operand:SI 2 "immediate_operand" "i")))
    (unspec [(const_int 0)] UNSPEC_PEEPSIB)]
-  "!TARGET_64BIT"
+  "!TARGET_64BIT && !TARGET_INDIRECT_BRANCH_REGISTER"
   "* return ix86_output_call_insn (insn, operands[0]);"
   [(set_attr "type" "call")])
 
@@ -20292,8 +20289,7 @@
   [(set (match_operand:W 0 "register_operand")
         (match_operand:W 1 "memory_operand"))
    (set (pc) (match_dup 0))]
-  "!TARGET_X32
-   && !TARGET_INDIRECT_BRANCH_REGISTER
+  "!TARGET_X32 && !TARGET_INDIRECT_BRANCH_REGISTER
    && peep2_reg_dead_p (2, operands[0])"
   [(set (pc) (match_dup 1))])
 
@@ -20338,7 +20334,7 @@
 		(zero_extend:DI
 		  (match_operand:SI 1 "GOT_memory_operand" "Bg")))
 	      (match_operand 2)))]
-  "TARGET_X32"
+  "TARGET_X32 && !TARGET_INDIRECT_BRANCH_REGISTER"
 {
   rtx fnaddr = gen_const_mem (DImode, XEXP (operands[1], 0));
   return ix86_output_call_insn (insn, fnaddr);
@@ -20355,8 +20351,7 @@
 			  (match_operand:SI 2 "GOT32_symbol_operand"))))
 	 (match_operand 3)))]
   "!TARGET_MACHO
-   && !TARGET_64BIT
-   && !TARGET_INDIRECT_BRANCH_REGISTER
+   && !TARGET_64BIT && !TARGET_INDIRECT_BRANCH_REGISTER
    && SIBLING_CALL_P (insn)"
 {
   rtx fnaddr = gen_rtx_PLUS (SImode, operands[1], operands[2]);
@@ -20388,8 +20383,7 @@
    (set (match_operand 2)
    (call (mem:QI (match_dup 0))
 		 (match_operand 3)))]
-  "!TARGET_X32
-   && !TARGET_INDIRECT_BRANCH_REGISTER
+  "!TARGET_X32 && !TARGET_INDIRECT_BRANCH_REGISTER
    && SIBLING_CALL_P (peep2_next_insn (1))
    && !reg_mentioned_p (operands[0],
 			CALL_INSN_FUNCTION_USAGE (peep2_next_insn (1)))"
@@ -20405,8 +20399,7 @@
    (set (match_operand 2)
 	(call (mem:QI (match_dup 0))
 	      (match_operand 3)))]
-  "!TARGET_X32
-   && !TARGET_INDIRECT_BRANCH_REGISTER
+  "!TARGET_X32 && !TARGET_INDIRECT_BRANCH_REGISTER
    && SIBLING_CALL_P (peep2_next_insn (2))
    && !reg_mentioned_p (operands[0],
 			CALL_INSN_FUNCTION_USAGE (peep2_next_insn (2)))"
@@ -20460,7 +20453,7 @@
 	(plus:SI (reg:SI SP_REG)
 		 (match_operand:SI 3 "immediate_operand" "i")))
    (unspec [(const_int 0)] UNSPEC_PEEPSIB)]
-  "!TARGET_64BIT"
+  "!TARGET_64BIT && !TARGET_INDIRECT_BRANCH_REGISTER"
   "* return ix86_output_call_insn (insn, operands[1]);"
   [(set_attr "type" "callv")])
 
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index e733a474f9e590bab115752aaa52ba4dd3a40523..8631588f78e0c11df54814426465dd3b39fe4f57 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -670,7 +670,9 @@
   (match_code "symbol_ref")
 {
   if (ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC
-      || flag_force_indirect_call)
+      || flag_force_indirect_call
+      || (TARGET_INDIRECT_BRANCH_REGISTER
+          && ix86_nopic_noplt_attribute_p (op)))
     return false;
   if (TARGET_DLLIMPORT_DECL_ATTRIBUTES && SYMBOL_REF_DLLIMPORT_P (op))
     return false;
@@ -779,22 +781,14 @@
   (ior (match_test "constant_call_address_operand
 		     (op, mode == VOIDmode ? mode : Pmode)")
        (match_operand 0 "call_register_operand")
-       (and (not (match_test "TARGET_INDIRECT_BRANCH_REGISTER"))
-	    (ior (and (not (match_test "TARGET_X32"))
-		      (match_operand 0 "memory_operand"))
-		 (and (match_test "TARGET_X32 && Pmode == DImode")
-		      (match_operand 0 "GOT_memory_operand"))))))
+       (match_test "satisfies_constraint_Bw (op)")))
 
 ;; Similarly, but for tail calls, in which we cannot allow memory references.
 (define_special_predicate "sibcall_insn_operand"
   (ior (match_test "constant_call_address_operand
 		     (op, mode == VOIDmode ? mode : Pmode)")
        (match_operand 0 "register_no_elim_operand")
-       (and (not (match_test "TARGET_INDIRECT_BRANCH_REGISTER"))
-	    (ior (and (not (match_test "TARGET_X32"))
-		      (match_operand 0 "sibcall_memory_operand"))
-		 (and (match_test "TARGET_X32 && Pmode == DImode")
-		      (match_operand 0 "GOT_memory_operand"))))))
+       (match_test "satisfies_constraint_Bs (op)")))
 
 ;; Return true if OP is a 32-bit GOT symbol operand.
 (define_predicate "GOT32_symbol_operand"
diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md
index df1b61e871f102d9a2edf50602c8e7e1db677f98..23129940e6448bb1025b74ae64566e435e7e266a 100644
--- a/gcc/config/pa/pa.md
+++ b/gcc/config/pa/pa.md
@@ -5632,8 +5632,10 @@
    (set_attr "length" "4")])
 
 (define_insn ""
-  [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
-   (clobber (match_operand:SI 0 "register_operand" "=a"))
+  [(set (reg:SI 29)
+	(mult:SI (match_operand:SI 1 "r26_operand" "")
+		 (match_operand:SI 0 "r25_operand" "")))
+   (clobber (match_operand:SI 2 "register_operand" "=a"))
    (clobber (reg:SI 26))
    (clobber (reg:SI 25))
    (clobber (reg:SI 31))]
@@ -5645,8 +5647,10 @@
 	      (symbol_ref "pa_attr_length_millicode_call (insn)")))])
 
 (define_insn ""
-  [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
-   (clobber (match_operand:SI 0 "register_operand" "=a"))
+  [(set (reg:SI 29)
+	(mult:SI (match_operand:SI 1 "r26_operand" "")
+		 (match_operand:SI 0 "r25_operand" "")))
+   (clobber (match_operand:SI 2 "register_operand" "=a"))
    (clobber (reg:SI 26))
    (clobber (reg:SI 25))
    (clobber (reg:SI 2))]
@@ -5753,8 +5757,9 @@
 
 (define_insn ""
   [(set (reg:SI 29)
-	(div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
-   (clobber (match_operand:SI 1 "register_operand" "=a"))
+	(div:SI (match_operand:SI 1 "r26_operand" "")
+		(match_operand:SI 0 "div_operand" "")))
+   (clobber (match_operand:SI 2 "register_operand" "=a"))
    (clobber (reg:SI 26))
    (clobber (reg:SI 25))
    (clobber (reg:SI 31))]
@@ -5768,8 +5773,9 @@
 
 (define_insn ""
   [(set (reg:SI 29)
-	(div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
-   (clobber (match_operand:SI 1 "register_operand" "=a"))
+	(div:SI (match_operand:SI 1 "r26_operand" "")
+		(match_operand:SI 0 "div_operand" "")))
+   (clobber (match_operand:SI 2 "register_operand" "=a"))
    (clobber (reg:SI 26))
    (clobber (reg:SI 25))
    (clobber (reg:SI 2))]
@@ -5800,8 +5806,9 @@
 
 (define_insn ""
   [(set (reg:SI 29)
-	(udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
-   (clobber (match_operand:SI 1 "register_operand" "=a"))
+	(udiv:SI (match_operand:SI 1 "r26_operand" "")
+		 (match_operand:SI 0 "div_operand" "")))
+   (clobber (match_operand:SI 2 "register_operand" "=a"))
    (clobber (reg:SI 26))
    (clobber (reg:SI 25))
    (clobber (reg:SI 31))]
@@ -5815,8 +5822,9 @@
 
 (define_insn ""
   [(set (reg:SI 29)
-	(udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
-   (clobber (match_operand:SI 1 "register_operand" "=a"))
+	(udiv:SI (match_operand:SI 1 "r26_operand" "")
+		 (match_operand:SI 0 "div_operand" "")))
+   (clobber (match_operand:SI 2 "register_operand" "=a"))
    (clobber (reg:SI 26))
    (clobber (reg:SI 25))
    (clobber (reg:SI 2))]
@@ -5844,8 +5852,10 @@
 }")
 
 (define_insn ""
-  [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
-   (clobber (match_operand:SI 0 "register_operand" "=a"))
+  [(set (reg:SI 29)
+	(mod:SI (match_operand:SI 1 "r26_operand" "")
+		(match_operand:SI 0 "r25_operand" "")))
+   (clobber (match_operand:SI 2 "register_operand" "=a"))
    (clobber (reg:SI 26))
    (clobber (reg:SI 25))
    (clobber (reg:SI 31))]
@@ -5858,8 +5868,10 @@
 	      (symbol_ref "pa_attr_length_millicode_call (insn)")))])
 
 (define_insn ""
-  [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
-   (clobber (match_operand:SI 0 "register_operand" "=a"))
+  [(set (reg:SI 29)
+	(mod:SI (match_operand:SI 1 "r26_operand" "")
+		(match_operand:SI 0 "r25_operand" "")))
+   (clobber (match_operand:SI 2 "register_operand" "=a"))
    (clobber (reg:SI 26))
    (clobber (reg:SI 25))
    (clobber (reg:SI 2))]
@@ -5887,8 +5899,10 @@
 }")
 
 (define_insn ""
-  [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
-   (clobber (match_operand:SI 0 "register_operand" "=a"))
+  [(set (reg:SI 29)
+	(umod:SI (match_operand:SI 1 "r26_operand" "")
+		 (match_operand:SI 0 "r25_operand" "")))
+   (clobber (match_operand:SI 2 "register_operand" "=a"))
    (clobber (reg:SI 26))
    (clobber (reg:SI 25))
    (clobber (reg:SI 31))]
@@ -5901,8 +5915,10 @@
 	      (symbol_ref "pa_attr_length_millicode_call (insn)")))])
 
 (define_insn ""
-  [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
-   (clobber (match_operand:SI 0 "register_operand" "=a"))
+  [(set (reg:SI 29)
+	(umod:SI (match_operand:SI 1 "r26_operand" "")
+		 (match_operand:SI 0 "r25_operand" "")))
+   (clobber (match_operand:SI 2 "register_operand" "=a"))
    (clobber (reg:SI 26))
    (clobber (reg:SI 25))
    (clobber (reg:SI 2))]
diff --git a/gcc/config/pa/predicates.md b/gcc/config/pa/predicates.md
index 24bb1ac8646f3296850c6ca8a7da7f974c2286ce..b0f8274ff798ba127a0d8f211301b8ea5278808a 100644
--- a/gcc/config/pa/predicates.md
+++ b/gcc/config/pa/predicates.md
@@ -191,6 +191,22 @@
 	  && CONSTANT_P (op) && ! TARGET_PORTABLE_RUNTIME);
 })
 
+;; True iff OP is a SImode r25 register operand.
+
+(define_predicate "r25_operand"
+  (match_code "reg")
+{
+  return mode == SImode && REG_P (op) && REGNO (op) == 25;
+})
+
+;; True iff OP is a SImode r26 register operand.
+
+(define_predicate "r26_operand"
+  (match_code "reg")
+{
+  return mode == SImode && REG_P (op) && REGNO (op) == 26;
+})
+
 ;; True iff OP can be used as the divisor in a div millicode call.
 
 (define_predicate "div_operand"
diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc
index e1172e9c7d2b382f4c4c03b38ede0495aa7983c1..9847439ca779cbb48a29e485d58e035f40d544d5 100644
--- a/gcc/config/riscv/riscv-v.cc
+++ b/gcc/config/riscv/riscv-v.cc
@@ -3947,11 +3947,22 @@ shuffle_generic_patterns (struct expand_vec_perm_d *d)
   if (!get_gather_index_mode (d).exists (&sel_mode))
     return false;
 
+  rtx sel = vec_perm_indices_to_rtx (sel_mode, d->perm);
+  poly_uint64 nunits = GET_MODE_NUNITS (sel_mode);
+  rtx elt;
+
+  bool is_simple = d->one_vector_p
+    || const_vec_duplicate_p (sel, &elt)
+    || (nunits.is_constant ()
+	&& const_vec_all_in_range_p (sel, 0, nunits - 1));
+
+  if (!is_simple && !riscv_two_source_permutes)
+    return false;
+
   /* Success! */
   if (d->testing_p)
     return true;
 
-  rtx sel = vec_perm_indices_to_rtx (sel_mode, d->perm);
   /* Some FIXED-VLMAX/VLS vector permutation situations call targethook
      instead of expand vec_perm<mode>, we handle it directly.  */
   expand_vec_perm (d->target, d->op0, d->op1, sel);
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 5a3a05041773877b8c3161bc22ee3868e5cd50c1..439cc12f93d5dee816fc663098cf9253f1d67bec 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -10885,7 +10885,9 @@ riscv_conditional_register_usage (void)
 	call_used_regs[r] = 1;
     }
 
-  if (!TARGET_HARD_FLOAT)
+  if (TARGET_HARD_FLOAT)
+    global_regs[FRM_REGNUM] = 1;
+  else
     {
       for (int regno = FP_REG_FIRST; regno <= FP_REG_LAST; regno++)
 	fixed_regs[regno] = call_used_regs[regno] = 1;
@@ -12642,14 +12644,27 @@ riscv_get_raw_result_mode (int regno)
 /* Generate a REG rtx of Xmode from the given rtx and mode.
    The rtx x can be REG (QI/HI/SI/DI) or const_int.
    The machine_mode mode is the original mode from define pattern.
+   The rtx_code can be ZERO_EXTEND or SIGN_EXTEND.
+
+   If rtx is REG:
+
+   1.  If rtx Xmode, the RTX x will be returned directly.
+   2.  If rtx non-Xmode, the value extended into a new REG of Xmode will be
+       returned.
+
+   The scalar ALU like add don't support non-Xmode like QI/HI.  Then the
+   gen_lowpart will have problem here.  For example, when we would like
+   to add -1 (0xff if QImode) and 2 (0x2 if QImode).  The 0xff and 0x2 will
+   be loaded to register for adding.  Aka:
 
-   If rtx is REG and Xmode, the RTX x will be returned directly.
+   0xff + 0x2 = 0x101 instead of -1 + 2 = 1.
 
-   If rtx is REG and non-Xmode, the zero extended to new REG of Xmode will be
-   returned.
+   Thus we need to sign extend 0xff to 0xffffffffffffffff if Xmode is DImode
+   for correctness.  Similar the unsigned also need zero extend.
 
-   If rtx is const_int, a new REG rtx will be created to hold the value of
-   const_int and then returned.
+   If rtx is const_int:
+
+   1.  A new REG rtx will be created to hold the value of const_int.
 
    According to the gccint doc, the constants generated for modes with fewer
    bits than in HOST_WIDE_INT must be sign extended to full width.  Thus there
@@ -12667,28 +12682,41 @@ riscv_get_raw_result_mode (int regno)
    the REG rtx of Xmode, instead of taking care of these in expand func.  */
 
 static rtx
-riscv_gen_zero_extend_rtx (rtx x, machine_mode mode)
+riscv_extend_to_xmode_reg (rtx x, machine_mode mode, enum rtx_code rcode)
 {
+  gcc_assert (rcode == ZERO_EXTEND || rcode == SIGN_EXTEND);
+
   rtx xmode_reg = gen_reg_rtx (Xmode);
 
-  if (!CONST_INT_P (x))
+  if (CONST_INT_P (x))
     {
       if (mode == Xmode)
-	return x;
-
-      riscv_emit_unary (ZERO_EXTEND, xmode_reg, x);
-      return xmode_reg;
-    }
+	emit_move_insn (xmode_reg, x);
+      else if (rcode == ZERO_EXTEND)
+	{
+	  /* Combine deliberately does not simplify extensions of constants
+	     (long story).  So try to generate the zero extended constant
+	     efficiently.
 
-  if (mode == Xmode)
-    emit_move_insn (xmode_reg, x);
-  else
-    {
-      rtx reg_x = gen_reg_rtx (mode);
+	     First extract the constant and mask off all the bits not in
+	     MODE.  */
+	  HOST_WIDE_INT val = INTVAL (x);
+	  val &= GET_MODE_MASK (mode);
 
-      emit_move_insn (reg_x, x);
-      riscv_emit_unary (ZERO_EXTEND, xmode_reg, reg_x);
+	  /* X may need synthesis, so do not blindly copy it.  */
+	  xmode_reg = force_reg (Xmode, gen_int_mode (val, Xmode));
+	}
+      else /* SIGN_EXTEND.  */
+	{
+	  rtx x_reg = gen_reg_rtx (mode);
+	  emit_move_insn (x_reg, x);
+	  riscv_emit_unary (rcode, xmode_reg, x_reg);
+	}
     }
+  else if (mode == Xmode)
+    return x;
+  else
+    riscv_emit_unary (rcode, xmode_reg, x);
 
   return xmode_reg;
 }
@@ -12709,8 +12737,8 @@ riscv_expand_usadd (rtx dest, rtx x, rtx y)
   machine_mode mode = GET_MODE (dest);
   rtx xmode_sum = gen_reg_rtx (Xmode);
   rtx xmode_lt = gen_reg_rtx (Xmode);
-  rtx xmode_x = riscv_gen_zero_extend_rtx (x, mode);
-  rtx xmode_y = riscv_gen_zero_extend_rtx (y, mode);
+  rtx xmode_x = riscv_extend_to_xmode_reg (x, mode, ZERO_EXTEND);
+  rtx xmode_y = riscv_extend_to_xmode_reg (y, mode, ZERO_EXTEND);
   rtx xmode_dest = gen_reg_rtx (Xmode);
 
   /* Step-1: sum = x + y  */
@@ -12788,8 +12816,8 @@ riscv_expand_ssadd (rtx dest, rtx x, rtx y)
   machine_mode mode = GET_MODE (dest);
   unsigned bitsize = GET_MODE_BITSIZE (mode).to_constant ();
   rtx shift_bits = GEN_INT (bitsize - 1);
-  rtx xmode_x = gen_lowpart (Xmode, x);
-  rtx xmode_y = gen_lowpart (Xmode, y);
+  rtx xmode_x = riscv_extend_to_xmode_reg (x, mode, SIGN_EXTEND);
+  rtx xmode_y = riscv_extend_to_xmode_reg (y, mode, SIGN_EXTEND);
   rtx xmode_sum = gen_reg_rtx (Xmode);
   rtx xmode_dest = gen_reg_rtx (Xmode);
   rtx xmode_xor_0 = gen_reg_rtx (Xmode);
@@ -12844,8 +12872,8 @@ void
 riscv_expand_ussub (rtx dest, rtx x, rtx y)
 {
   machine_mode mode = GET_MODE (dest);
-  rtx xmode_x = riscv_gen_zero_extend_rtx (x, mode);
-  rtx xmode_y = riscv_gen_zero_extend_rtx (y, mode);
+  rtx xmode_x = riscv_extend_to_xmode_reg (x, mode, ZERO_EXTEND);
+  rtx xmode_y = riscv_extend_to_xmode_reg (y, mode, ZERO_EXTEND);
   rtx xmode_lt = gen_reg_rtx (Xmode);
   rtx xmode_minus = gen_reg_rtx (Xmode);
   rtx xmode_dest = gen_reg_rtx (Xmode);
@@ -12892,8 +12920,8 @@ riscv_expand_sssub (rtx dest, rtx x, rtx y)
   machine_mode mode = GET_MODE (dest);
   unsigned bitsize = GET_MODE_BITSIZE (mode).to_constant ();
   rtx shift_bits = GEN_INT (bitsize - 1);
-  rtx xmode_x = gen_lowpart (Xmode, x);
-  rtx xmode_y = gen_lowpart (Xmode, y);
+  rtx xmode_x = riscv_extend_to_xmode_reg (x, mode, SIGN_EXTEND);
+  rtx xmode_y = riscv_extend_to_xmode_reg (y, mode, SIGN_EXTEND);
   rtx xmode_minus = gen_reg_rtx (Xmode);
   rtx xmode_xor_0 = gen_reg_rtx (Xmode);
   rtx xmode_xor_1 = gen_reg_rtx (Xmode);
@@ -13003,7 +13031,7 @@ riscv_expand_sstrunc (rtx dest, rtx src)
   rtx xmode_narrow_min = gen_reg_rtx (Xmode);
   rtx xmode_lt = gen_reg_rtx (Xmode);
   rtx xmode_gt = gen_reg_rtx (Xmode);
-  rtx xmode_src = gen_lowpart (Xmode, src);
+  rtx xmode_src = riscv_extend_to_xmode_reg (src, GET_MODE (src), SIGN_EXTEND);
   rtx xmode_dest = gen_reg_rtx (Xmode);
   rtx xmode_mask = gen_reg_rtx (Xmode);
   rtx xmode_sat = gen_reg_rtx (Xmode);
diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index e4123c912dcb272814dcc59f8006c9b0c0a7d9dc..09053df1eb9be4a1634e5cdf768e126043057db9 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -2470,7 +2470,8 @@
         (match_operand:GPR 1 "splittable_const_int_operand" "i"))]
   "!ira_in_progress
    && !(p2m1_shift_operand (operands[1], <MODE>mode)
-        || high_mask_shift_operand (operands[1], <MODE>mode))"
+	|| high_mask_shift_operand (operands[1], <MODE>mode)
+	|| exact_log2 (INTVAL (operands[1])) >= 0)"
   "#"
   "&& 1"
   [(const_int 0)]
diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
index f51f8fd1cdf41cf3e5f010550cb2c0fe46295399..7515c8ea13ddd2deb80ec8179b2ddfe4aaf85da4 100644
--- a/gcc/config/riscv/riscv.opt
+++ b/gcc/config/riscv/riscv.opt
@@ -622,6 +622,10 @@ Enum(vsetvl_strategy) String(optim-no-fusion) Value(VSETVL_OPT_NO_FUSION)
 Target Undocumented RejectNegative Joined Enum(vsetvl_strategy) Var(vsetvl_strategy) Init(VSETVL_OPT)
 -param=vsetvl-strategy=<string>	Set the optimization level of VSETVL insert pass.
 
+-param=riscv-two-source-permutes
+Target Undocumented Uinteger Var(riscv_two_source_permutes) Init(0)
+-param=riscv-two-source-permutes Enable permutes with two source vectors.
+
 Enum
 Name(stringop_strategy) Type(enum stringop_strategy_enum)
 Valid arguments to -mstringop-strategy=:
diff --git a/gcc/config/rx/constraints.md b/gcc/config/rx/constraints.md
index 4fc242667ab4e2d623946d05df0a3be12cd0fea0..4b81ae6aa75bfe254deba7aadfdeb7c6cf718ea3 100644
--- a/gcc/config/rx/constraints.md
+++ b/gcc/config/rx/constraints.md
@@ -80,7 +80,8 @@
        (ior (match_code "reg" "0")
 	    (and (match_code "plus" "0")
 	         (and (match_code "reg,subreg" "00")
-		      (match_code "const_int" "01")
+		      (and (match_code "const_int" "01")
+		           (match_test "rx_is_restricted_memory_address (XEXP (op, 0), mode)"))
 		 )
 	    )
        )
diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
index 86a5f059b85dc6e48612861a5c4c18669be59a4c..1d96df49feac3258206e7c88972094975f6ea1e3 100644
--- a/gcc/config/s390/s390.cc
+++ b/gcc/config/s390/s390.cc
@@ -8585,7 +8585,7 @@ print_operand_address (FILE *file, rtx addr)
     'E': print opcode suffix for branch on index instruction.
     'G': print the size of the operand in bytes.
     'J': print tls_load/tls_gdcall/tls_ldcall suffix
-    'K': print @PLT suffix for call targets and load address values.
+    'K': print @PLT suffix for branch targets; do not use with larl.
     'M': print the second word of a TImode operand.
     'N': print the second word of a DImode operand.
     'O': print only the displacement of a memory reference or address.
@@ -8854,19 +8854,9 @@ print_operand (FILE *file, rtx x, int code)
 	 call even static functions via PLT.  ld will optimize @PLT away for
 	 normal code, and keep it for patches.
 
-	 Do not indiscriminately add @PLT in 31-bit mode due to the %r12
-	 restriction, use UNSPEC_PLT31 instead.
-
 	 @PLT only makes sense for functions, data is taken care of by
-	 -mno-pic-data-is-text-relative.
-
-	 Adding @PLT interferes with handling of weak symbols in non-PIC code,
-	 since their addresses are loaded with larl, which then always produces
-	 a non-NULL result, so skip them here as well.  */
-      if (TARGET_64BIT
-	  && GET_CODE (x) == SYMBOL_REF
-	  && SYMBOL_REF_FUNCTION_P (x)
-	  && !(SYMBOL_REF_WEAK (x) && !flag_pic))
+	 -mno-pic-data-is-text-relative.  */
+      if (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (x))
 	fprintf (file, "@PLT");
       return;
     }
diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index c164ea72c78b7eb96d696d19cf082748079165fe..9d4958033873c9164f1100e08547d61ec65b4ecb 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -2001,7 +2001,7 @@
    vlgvg\t%0,%v1,0
    vleg\t%v0,%1,0
    vsteg\t%v1,%0,0
-   larl\t%0,%1%K1"
+   larl\t%0,%1"
   [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RRE,RXY,RIL,RRE,RXY,
                         RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS,VRI,VRR,VRS,VRS,
                         VRX,VRX,RIL")
@@ -2390,7 +2390,7 @@
         (match_operand:SI 1 "larl_operand" "X"))]
   "!TARGET_64BIT
    && !FP_REG_P (operands[0])"
-  "larl\t%0,%1%K1"
+  "larl\t%0,%1"
    [(set_attr "op_type" "RIL")
     (set_attr "type"    "larl")
     (set_attr "z10prop" "z10_fwd_A1")
@@ -11735,7 +11735,7 @@
   [(set (match_operand 0 "register_operand" "=a")
         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
   "GET_MODE (operands[0]) == Pmode"
-  "larl\t%0,%1%K1"
+  "larl\t%0,%1"
   [(set_attr "op_type" "RIL")
    (set_attr "type"    "larl")
    (set_attr "z10prop" "z10_fwd_A1")
@@ -11755,7 +11755,7 @@
   [(set (match_operand 0 "register_operand" "=a")
         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
   "GET_MODE (operands[0]) == Pmode"
-  "larl\t%0,%1%K1"
+  "larl\t%0,%1"
   [(set_attr "op_type" "RIL")
    (set_attr "type"    "larl")
    (set_attr "z10prop" "z10_fwd_A1")])
diff --git a/gcc/config/s390/vector.md b/gcc/config/s390/vector.md
index 547e6a2828160b99e2a70a491acbdd5e7c0be2b9..e29255fe1116e0ddfed2178bc212110e80736137 100644
--- a/gcc/config/s390/vector.md
+++ b/gcc/config/s390/vector.md
@@ -2166,7 +2166,7 @@
 	(vec_duplicate:V2DI
 	 (vec_select:DI
 	  (match_dup 4)
-	  (parallel [(const_int 1)]))))
+	  (parallel [(const_int 0)]))))
    (set (match_dup 0)
 	(subreg:<MODE> (match_dup 4) 0))]
 {
@@ -2198,7 +2198,7 @@
 	(vec_duplicate:V2DI
 	 (vec_select:DI
 	  (match_dup 4)
-	  (parallel [(const_int 1)]))))
+	  (parallel [(const_int 0)]))))
    (set (match_dup 0)
 	(subreg:<MODE> (match_dup 4) 0))]
 {
diff --git a/gcc/configure b/gcc/configure
index b4c52de6218406ddb00425a29b6effa5d6130d9c..e36d1d91612a3317f7361432807189621ad2a8ac 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -10637,7 +10637,7 @@ for ac_func in times clock kill getrlimit setrlimit atoq \
 	popen sysconf strsignal getrusage nl_langinfo \
 	gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \
 	clearerr_unlocked feof_unlocked   ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked   fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked   fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked   putchar_unlocked putc_unlocked madvise mallinfo mallinfo2 fstatat getauxval \
-	clock_gettime
+	clock_gettime munmap msync
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 6c38c4925fb3a55eea39912a7e6807f37f6c79da..8fab93c9365496062583c5bd8ace402c8a797817 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1574,7 +1574,7 @@ AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoq \
 	popen sysconf strsignal getrusage nl_langinfo \
 	gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \
 	gcc_UNLOCKED_FUNCS madvise mallinfo mallinfo2 fstatat getauxval \
-	clock_gettime)
+	clock_gettime munmap msync)
 
 # At least for glibc, clock_gettime is in librt.  But don't pull that
 # in if it still doesn't give us the function we want.
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 62cee4efc3a6297f448457587eb07c1003f3b358..9bb6e5bcb82635d5872952fc04efe69bcde75730 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,263 @@
+2025-02-04  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/118671
+	* call.cc (build_list_conv): For RAW_DATA_CST, call
+	implicit_conversion with INTEGER_CST representing first byte instead
+	of the whole RAW_DATA_CST.  If it is an optimizable trivial
+	conversion, just save that to subconvs, otherwise allocate an
+	artificial ck_list for all the RAW_DATA_CST bytes and create
+	subsubconv for each of them.
+	(convert_like_internal): For ck_list with RAW_DATA_CST, instead of
+	doing all the checks for optimizable conversion just check kind and
+	assert everything else, otherwise use subsubconversions instead of
+	the subconversion for each element.
+
+2025-02-04  Marek Polacek  <polacek@redhat.com>
+
+	PR c++/117778
+	* parser.cc (cp_parser_late_return_type_opt): Maybe override
+	auto_is_implicit_function_template_parm_p.
+	(cp_parser_parameter_declaration): Move a make_temp_override below.
+
+2025-02-04  Marek Polacek  <polacek@redhat.com>
+
+	PR c++/118718
+	* parser.cc (warn_about_ambiguous_parse): Don't warn when a trailing
+	return type is present.
+
+2025-02-04  Simon Martin  <simon@nasilyan.com>
+	    Jason Merrill  <jason@redhat.com>
+
+	PR c++/117114
+	PR c++/109918
+	* class.cc (warn_hidden): Keep track of overloaded and of hidden
+	base methods.
+	* error.cc (location_of): Skip over conv_op_marker.
+
+2025-02-04  Simon Martin  <simon@nasilyan.com>
+
+	PR c++/114619
+	* init.cc (build_vec_init): Properly determine whether
+	digest_init has been called.
+
+2025-02-04  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/118719
+	* lambda.cc (add_capture): Only pedwarn about capturing structured
+	binding if !explicit_init_p.
+
+2025-02-04  Nathaniel Shead  <nathanieloshead@gmail.com>
+
+	PR c++/108205
+	* contracts.cc (get_pseudo_contract_violation_type): Give names
+	to generated FIELD_DECLs.
+	(declare_handle_contract_violation): Mark contract_violation
+	type as external linkage.
+	(build_contract_handler_call): Ensure any builtin declarations
+	created here aren't treated as attached to the current module.
+
+2025-02-04  Nathaniel Shead  <nathanieloshead@gmail.com>
+
+	PR c++/98893
+	* decl.cc (start_cleanup_fn): Make name from the mangled name of
+	the passed-in decl.
+	(register_dtor_fn): Pass decl to start_cleanup_fn.
+
+2025-02-03  A J Ryan Solutions Ltd  <gcc.gnu.org@ajryansolutions.co.uk>
+
+	PR c++/118265
+	* pt.cc (find_parameter_packs_r) <case TEMPLATE_PARM_INDEX>:
+	Walk into the type of a parameter pack.
+
+2025-02-03  Iain Sandoe  <iains.gcc@gmail.com>
+	    Jason Merrill  <jason@redhat.com>
+
+	PR c++/116506
+	PR c++/116880
+	* coroutines.cc (build_co_await): Ensure that xvalues are
+	materialised.  Handle references/pointer values in awaiter
+	access expressions.
+	(is_stable_lvalue): New.
+	* decl.cc (cxx_maybe_build_cleanup): Handle null arg.
+
+2025-02-03  Jason Merrill  <jason@redhat.com>
+
+	PR c++/116914
+	PR c++/117231
+	PR c++/118470
+	PR c++/118491
+	* semantics.cc (finish_for_stmt): Don't wrap the result of
+	pop_stmt_list in EXPR_STMT.
+
+2025-02-03  Richard Biener  <rguenther@suse.de>
+
+	PR c++/79786
+	* rtti.cc (emit_tinfo_decl): Fix DATA_ABI_ALIGNMENT invocation.
+
+2025-01-31  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/117516
+	* class.cc (field_nonempty_p): Formatting fixes.  Use
+	integer_zerop instead of tree_int_cst_equal with size_zero_node.
+	(struct flexmems_t): Change type of first member from tree to bool.
+	(find_flexarrays): Add nested_p argument.  Change pun argument type
+	from tree to bool, adjust uses.  Formatting fixes.  If BASE_P or
+	NESTED_P and T is RECORD_TYPE, start looking only at the last
+	non-empty or array FIELD_DECL.  Adjust recursive call, set first
+	if it was a nested call and found an array.
+	(diagnose_invalid_flexarray, diagnose_flexarrays, check_flexarrays):
+	Formatting fixes.
+
+2025-01-31  Marek Polacek  <polacek@redhat.com>
+
+	PR c++/117501
+	* cp-gimplify.cc (cp_build_init_expr_for_ctor): New.
+	(cp_fold_immediate_r): Call it.
+	(cp_fold): Break out code into cp_build_init_expr_for_ctor.
+
+2025-01-30  Patrick Palka  <ppalka@redhat.com>
+
+	* cp-tree.h (LAMBDA_EXPR_CAPTURES_THIS_P): Remove.
+
+2025-01-30  Iain Sandoe  <iain@sandoe.co.uk>
+
+	PR c++/118673
+	* tree.cc (lvalue_kind): Mark CONST_DECLs as mergable
+	when they are also TREE_STATIC.
+
+2025-01-30  Tobias Burnus  <tburnus@baylibre.com>
+
+	* parser.cc (cp_finish_omp_declare_variant): Modify how append_args
+	is saved internally.
+	* pt.cc (tsubst_attribute): Likewise.
+	(tsubst_omp_clauses): Remove C_ORT_OMP_DECLARE_SIMD from interop
+	handling as no longer called for it.
+	* decl.cc (omp_declare_variant_finalize_one): Update append_args
+	changes; fixes for ADL input.
+
+2025-01-29  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/118655
+	* semantics.cc (trait_expr_value) <case CPTK_IS_BOUNDED_ARRAY>: Return
+	false for zero-sized arrays.
+
+2025-01-28  Jason Merrill  <jason@redhat.com>
+
+	PR c++/118285
+	* constexpr.cc (cxx_eval_vec_init_1): Build INIT_EXPR for
+	initializing a class.
+
+2025-01-28  Jason Merrill  <jason@redhat.com>
+
+	PR c++/118673
+	* call.cc (maybe_init_list_as_array): Check for lvalue
+	initializers.
+	* cp-tree.h (enum cp_lvalue_kind_flags): Add clk_mergeable.
+	* tree.cc (lvalue_kind): Return it.
+	(non_mergeable_glvalue_p): New.
+	(test_lvalue_kind): Adjust.
+
+2025-01-28  Patrick Palka  <ppalka@redhat.com>
+
+	PR c++/117855
+	* cp-tree.h (DECL_FRIEND_CONTEXT): Exclude deduction guides.
+
+2025-01-27  Jason Merrill  <jason@redhat.com>
+
+	PR c++/118632
+	* pt.cc (unify): Only strip conversion if deducible_expression.
+
+2025-01-27  Simon Martin  <simon@nasilyan.com>
+
+	PR c++/114292
+	* pt.cc (for_each_template_parm_r) <INTEGER_TYPE>: Remove case
+	now handled by cp_walk_subtrees.
+	* tree.cc (cp_walk_subtrees): Walk the type of DECL_EXPR
+	declarations, as well as the TYPE_{MIN,MAX}_VALUE of
+	INTEGER_TYPEs.
+
+2025-01-27  John David Anglin  <danglin@gcc.gnu.org>
+
+	* module.cc: Test HAVE_MUNMAP and HAVE_MSYNC instead of
+	_POSIX_MAPPED_FILES > 0.
+
+2025-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/115769
+	* module.cc (module_state::write_inits): Verify
+	STATIC_INIT_DECOMP_{,NON}BASE_P flags and stream changes in those
+	out.
+	(module_state::read_inits): Stream those flags in.
+
+2025-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/115769
+	* cp-tree.h (STATIC_INIT_DECOMP_BASE_P): Define.
+	(STATIC_INIT_DECOMP_NONBASE_P): Define.
+	* decl.cc (cp_finish_decl): Mark nodes in {static,tls}_aggregates
+	emitted for namespace scope structured bindings with
+	STATIC_INIT_DECOMP_{,NON}BASE_P flags when needed.
+	* decl2.cc (decomp_handle_one_var, decomp_finalize_var_list): New
+	functions.
+	(emit_partial_init_fini_fn): Use them.
+	(prune_vars_needing_no_initialization): Assert
+	STATIC_INIT_DECOMP_*BASE_P is not set on DECL_EXTERNAL vars to be
+	pruned out.
+	(partition_vars_for_init_fini): Use same priority for
+	consecutive STATIC_INIT_DECOMP_*BASE_P vars and propagate
+	those flags to new TREE_LISTs when possible.  Formatting fix.
+	(handle_tls_init): Use decomp_handle_one_var and
+	decomp_finalize_var_list functions.
+
+2025-01-25  Simon Martin  <simon@nasilyan.com>
+
+	PR c++/118239
+	* constexpr.cc (cx_check_missing_mem_inits): Don't skip fields
+	with DECL_FIELD_IS_BASE.
+
+2025-01-25  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/117827
+	* init.cc (build_new_1): Pass address of a make_tree_vector ()
+	initialized gc tree vector to build_vec_init and append
+	build_disable_temp_cleanup to init_expr from it.
+
+2025-01-25  Nathaniel Shead  <nathanieloshead@gmail.com>
+
+	PR c++/116568
+	* module.cc (trees_out::get_merge_kind): Treat all lambdas
+	without a mangling scope as un-mergeable.
+
+2025-01-25  Nathaniel Shead  <nathanieloshead@gmail.com>
+
+	PR c++/116568
+	* cp-tree.h (finish_concept_definition): Adjust parameters.
+	(start_concept_definition): Declare.
+	* module.cc (depset::hash::is_tu_local_entity): Use
+	LAMBDA_EXPR_EXTRA_SCOPE to detect TU-local lambdas.
+	* parser.cc (cp_parser_concept_definition): Start a lambda scope
+	for concept definitions.
+	* pt.cc (tsubst_lambda_expr): Namespace-scope lambdas may now
+	have extra scope.
+	(finish_concept_definition): Split into...
+	(start_concept_definition): ...this new function.
+
+2025-01-25  Nathaniel Shead  <nathanieloshead@gmail.com>
+
+	PR c++/118245
+	* cp-tree.h (LAMBDA_EXPR_EXTRA_SCOPE): Adjust comment.
+	* parser.cc (cp_parser_class_head): Start (and do not finish)
+	lambda scope for all valid types.
+	(cp_parser_class_specifier): Finish lambda scope after parsing
+	members instead.
+	* pt.cc (instantiate_class_template): Add lambda scoping.
+
+2025-01-24  Marek Polacek  <polacek@redhat.com>
+
+	PR c++/117153
+	* decl2.cc (build_anon_union_vars): Use FIELD for the second operand
+	of a COMPONENT_REF.
+
 2025-01-23  Marek Polacek  <polacek@redhat.com>
 
 	PR c++/117602
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 469af83ccbfdfd124e3fbdde482598be6e936f76..c08bd0c8634a9722d39ce0cd240f368d0acb8d61 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -868,6 +868,67 @@ build_list_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
 
   FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), i, val)
     {
+      if (TREE_CODE (val) == RAW_DATA_CST)
+	{
+	  tree elt
+	    = build_int_cst (TREE_TYPE (val), RAW_DATA_UCHAR_ELT (val, 0));
+	  conversion *sub
+	    = implicit_conversion (elttype, TREE_TYPE (val), elt,
+				   false, flags, complain);
+	  conversion *next;
+	  if (sub == NULL)
+	    return NULL;
+	  /* For conversion to initializer_list<unsigned char> or
+	     initializer_list<char> or initializer_list<signed char>
+	     we can optimize and keep RAW_DATA_CST with adjusted
+	     type if we report narrowing errors if needed.
+	     Use just one subconversion for that case.  */
+	  if (sub->kind == ck_std
+	      && sub->type
+	      && (TREE_CODE (sub->type) == INTEGER_TYPE
+		  || is_byte_access_type (sub->type))
+	      && TYPE_PRECISION (sub->type) == CHAR_BIT
+	      && (next = next_conversion (sub))
+	      && next->kind == ck_identity)
+	    {
+	      subconvs[i] = sub;
+	      continue;
+	    }
+	  /* Otherwise. build separate subconv for each RAW_DATA_CST
+	     byte.  Wrap those into an artificial ck_list which convert_like
+	     will then handle.  */
+	  conversion **subsubconvs = alloc_conversions (RAW_DATA_LENGTH (val));
+	  unsigned int j;
+	  subsubconvs[0] = sub;
+	  for (j = 1; j < (unsigned) RAW_DATA_LENGTH (val); ++j)
+	    {
+	      elt = build_int_cst (TREE_TYPE (val),
+				   RAW_DATA_UCHAR_ELT (val, j));
+	      sub = implicit_conversion (elttype, TREE_TYPE (val), elt,
+					 false, flags, complain);
+	      if (sub == NULL)
+		return NULL;
+	      subsubconvs[j] = sub;
+	    }
+
+	  t = alloc_conversion (ck_list);
+	  t->type = type;
+	  t->u.list = subsubconvs;
+	  t->rank = cr_exact;
+	  for (j = 0; j < (unsigned) RAW_DATA_LENGTH (val); ++j)
+	    {
+	      sub = subsubconvs[i];
+	      if (sub->rank > t->rank)
+		t->rank = sub->rank;
+	      if (sub->user_conv_p)
+		t->user_conv_p = true;
+	      if (sub->bad_p)
+		t->bad_p = true;
+	    }
+	  subconvs[i] = t;
+	  continue;
+	}
+
       conversion *sub
 	= implicit_conversion (elttype, TREE_TYPE (val), val,
 			       false, flags, complain);
@@ -4374,6 +4435,15 @@ maybe_init_list_as_array (tree elttype, tree init)
     /* Let the normal code give the error.  */
     return NULL_TREE;
 
+  /* A glvalue initializer might be significant to a reference constructor
+     or conversion operator.  */
+  if (!DECL_CONSTRUCTOR_P (c->cand->fn)
+      || (TYPE_REF_P (TREE_VALUE
+		      (FUNCTION_FIRST_USER_PARMTYPE (c->cand->fn)))))
+    for (auto &ce : CONSTRUCTOR_ELTS (init))
+      if (non_mergeable_glvalue_p (ce.value))
+	return NULL_TREE;
+
   tree first = CONSTRUCTOR_ELT (init, 0)->value;
   conversion *fc = implicit_conversion (elttype, init_elttype, first, false,
 					LOOKUP_IMPLICIT|LOOKUP_NO_NARROWING,
@@ -8841,22 +8911,22 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum,
 	      {
 		if (TREE_CODE (val) == RAW_DATA_CST)
 		  {
-		    tree elt_type;
-		    conversion *next;
 		    /* For conversion to initializer_list<unsigned char> or
 		       initializer_list<char> or initializer_list<signed char>
 		       we can optimize and keep RAW_DATA_CST with adjusted
 		       type if we report narrowing errors if needed, for
 		       others this converts each element separately.  */
-		    if (convs->u.list[ix]->kind == ck_std
-			&& (elt_type = convs->u.list[ix]->type)
-			&& (TREE_CODE (elt_type) == INTEGER_TYPE
-			    || is_byte_access_type (elt_type))
-			&& TYPE_PRECISION (elt_type) == CHAR_BIT
-			&& (next = next_conversion (convs->u.list[ix]))
-			&& next->kind == ck_identity)
+		    if (convs->u.list[ix]->kind == ck_std)
 		      {
-			if (!TYPE_UNSIGNED (elt_type)
+			tree et = convs->u.list[ix]->type;
+			conversion *next = next_conversion (convs->u.list[ix]);
+			gcc_assert (et
+				    && (TREE_CODE (et) == INTEGER_TYPE
+					|| is_byte_access_type (et))
+				    && TYPE_PRECISION (et) == CHAR_BIT
+				    && next
+				    && next->kind == ck_identity);
+			if (!TYPE_UNSIGNED (et)
 			    /* For RAW_DATA_CST, TREE_TYPE (val) can be
 			       either integer_type_node (when it has been
 			       created by the lexer from CPP_EMBED) or
@@ -8882,7 +8952,7 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum,
 						 "narrowing conversion of "
 						 "%qd from %qH to %qI",
 						 RAW_DATA_UCHAR_ELT (val, i),
-						 TREE_TYPE (val), elt_type);
+						 TREE_TYPE (val), et);
 				  if (errorcount != savederrorcount)
 				    return error_mark_node;
 				}
@@ -8890,19 +8960,21 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum,
 				return error_mark_node;
 			    }
 			tree sub = copy_node (val);
-			TREE_TYPE (sub) = elt_type;
+			TREE_TYPE (sub) = et;
 			CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (new_ctor),
 						NULL_TREE, sub);
 		      }
 		    else
 		      {
+			conversion *conv = convs->u.list[ix];
+			gcc_assert (conv->kind == ck_list);
 			for (int i = 0; i < RAW_DATA_LENGTH (val); ++i)
 			  {
 			    tree elt
 			      = build_int_cst (TREE_TYPE (val),
 					       RAW_DATA_UCHAR_ELT (val, i));
 			    tree sub
-			      = convert_like (convs->u.list[ix], elt,
+			      = convert_like (conv->u.list[i], elt,
 					      fn, argnum, false, false,
 					      /*nested_p=*/true, complain);
 			    if (sub == error_mark_node)
diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index f2f81a44718e8b3e4ac9452b76862a68067e8c0c..d5ae69b0fdfad6be026c9311d78682d517997e0e 100644
--- a/gcc/cp/class.cc
+++ b/gcc/cp/class.cc
@@ -141,8 +141,8 @@ static bool accessible_nvdtor_p (tree);
 /* Used by find_flexarrays and related functions.  */
 struct flexmems_t;
 static void diagnose_flexarrays (tree, const flexmems_t *);
-static void find_flexarrays (tree, flexmems_t *, bool = false,
-			     tree = NULL_TREE, tree = NULL_TREE);
+static void find_flexarrays (tree, flexmems_t *, bool, bool = false,
+			     bool = false, tree = NULL_TREE);
 static void check_flexarrays (tree, flexmems_t * = NULL, bool = false);
 static void check_bases (tree, int *, int *);
 static void check_bases_and_members (tree);
@@ -3243,10 +3243,16 @@ warn_hidden (tree t)
 	  continue;
 
 	tree name = OVL_NAME (fns);
+	size_t num_fns = 0; /* The number of fndecls in fns.  */
 	auto_vec<tree, 20> base_fndecls;
 	tree base_binfo;
 	tree binfo;
 	unsigned j;
+	size_t num_overriders = 0;
+	hash_set<tree> overriden_base_fndecls;
+	/* base_fndecls that are hidden but not overriden. The "value"
+	   contains the last fndecl we saw that hides the "key".  */
+	hash_map<tree, tree> hidden_base_fndecls;
 
 	if (IDENTIFIER_CDTOR_P (name))
 	  continue;
@@ -3264,47 +3270,65 @@ warn_hidden (tree t)
 	if (base_fndecls.is_empty ())
 	  continue;
 
-	/* Remove any overridden functions.  */
-	bool seen_non_override = false;
+	/* Find all the base_fndecls that are overridden, as well as those
+	   that are hidden, in T.  */
 	for (tree fndecl : ovl_range (fns))
 	  {
-	    bool any_override = false;
-	    if (TREE_CODE (fndecl) == FUNCTION_DECL
-		&& DECL_VINDEX (fndecl))
+	    bool template_p = TREE_CODE (fndecl) == TEMPLATE_DECL;
+	    bool fndecl_overrides_p = false;
+	    fndecl = STRIP_TEMPLATE (fndecl);
+	    if (TREE_CODE (fndecl) != FUNCTION_DECL
+		|| fndecl == conv_op_marker)
+	      continue;
+	    num_fns++;
+	    for (size_t k = 0; k < base_fndecls.length (); k++)
 	      {
-		/* If the method from the base class has the same
-		   signature as the method from the derived class, it
-		   has been overridden.  Note that we can't move on
-		   after finding one match: fndecl might override
-		   multiple base fns.  */
-		for (size_t k = 0; k < base_fndecls.length (); k++)
-		  if (base_fndecls[k]
-		      && same_signature_p (fndecl, base_fndecls[k]))
-		    {
-		      base_fndecls[k] = NULL_TREE;
-		      any_override = true;
-		    }
+		if (!base_fndecls[k] || !DECL_VINDEX (base_fndecls[k]))
+		  continue;
+		if (IDENTIFIER_CONV_OP_P (name)
+		    && !same_type_p (DECL_CONV_FN_TYPE (fndecl),
+				     DECL_CONV_FN_TYPE (base_fndecls[k])))
+		  /* If base_fndecl[k] and fndecl are conversion operators
+		     to different types, they're unrelated.  */
+		  ;
+		else if (!template_p /* Template methods don't override.  */
+			 && same_signature_p (fndecl, base_fndecls[k]))
+		  {
+		    overriden_base_fndecls.add (base_fndecls[k]);
+		    fndecl_overrides_p = true;
+		  }
+		else
+		  {
+		    /* fndecl hides base_fndecls[k].  */
+		    hidden_base_fndecls.put (base_fndecls[k], fndecl);
+		  }
 	      }
-	    if (!any_override)
-	      seen_non_override = true;
+	    if (fndecl_overrides_p)
+	      ++num_overriders;
 	  }
 
-	if (!seen_non_override && warn_overloaded_virtual == 1)
-	  /* All the derived fns override base virtuals.  */
-	  return;
+	if (warn_overloaded_virtual == 1 && num_overriders == num_fns)
+	  /* All the fns override a base virtual.  */
+	  continue;
 
-	/* Now give a warning for all base functions without overriders,
-	   as they are hidden.  */
-	for (tree base_fndecl : base_fndecls)
-	  if (base_fndecl)
-	    {
-	      auto_diagnostic_group d;
-	      /* Here we know it is a hider, and no overrider exists.  */
-	      if (warning_at (location_of (base_fndecl),
-			      OPT_Woverloaded_virtual_,
-			      "%qD was hidden", base_fndecl))
-		inform (location_of (fns), "  by %qD", fns);
-	    }
+	/* Now give a warning for all hidden methods. Note that a method that
+	   is both in hidden_base_fndecls and overriden_base_fndecls is not
+	   hidden.  */
+	for (auto hidden_base_fndecl : hidden_base_fndecls)
+	  {
+	    tree hidden_fndecl = hidden_base_fndecl.first;
+	    if (!hidden_fndecl
+		|| overriden_base_fndecls.contains (hidden_fndecl))
+	      continue;
+	    auto_diagnostic_group d;
+	    if (warning_at (location_of (hidden_fndecl),
+			    OPT_Woverloaded_virtual_,
+			    "%qD was hidden", hidden_fndecl))
+	      {
+		tree hider = hidden_base_fndecl.second;
+		inform (location_of (hider), "  by %qD", hider);
+	      }
+	  }
       }
 }
 
@@ -7362,11 +7386,7 @@ field_nonempty_p (const_tree fld)
   if (TREE_CODE (fld) == FIELD_DECL
       && TREE_CODE (type) != ERROR_MARK
       && (DECL_NAME (fld) || RECORD_OR_UNION_TYPE_P (type)))
-    {
-      return TYPE_SIZE (type)
-	&& (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST
-	    || !tree_int_cst_equal (size_zero_node, TYPE_SIZE (type)));
-    }
+    return TYPE_SIZE (type) && !integer_zerop (TYPE_SIZE (type));
 
   return false;
 }
@@ -7378,8 +7398,9 @@ struct flexmems_t
   /* The first flexible array member or non-zero array member found
      in the order of layout.  */
   tree array;
-  /* First non-static non-empty data member in the class or its bases.  */
-  tree first;
+  /* True if there is a non-static non-empty data member in the class or
+     its bases.  */
+  bool first;
   /* The first non-static non-empty data member following either
      the flexible array member, if found, or the zero-length array member
      otherwise.  AFTER[1] refers to the first such data member of a union
@@ -7400,24 +7421,51 @@ struct flexmems_t
    array, in that order of preference, among members of class T (but not
    its base classes), and set members of FMEM accordingly.
    BASE_P is true if T is a base class of another class.
-   PUN is set to the outermost union in which the flexible array member
-   (or zero-length array) is defined if one such union exists, otherwise
-   to NULL.
-   Similarly, PSTR is set to a data member of the outermost struct of
+   PUN is true when inside of a union (perhaps recursively).
+   PSTR is set to a data member of the outermost struct of
    which the flexible array is a member if one such struct exists,
-   otherwise to NULL.  */
+   otherwise to NULL.  NESTED_P is true for recursive calls except ones
+   handling anonymous aggregates.  Those types are expected to be diagnosed
+   on its own already and so only the last member is checked vs. what
+   follows it in the outer type.  */
 
 static void
 find_flexarrays (tree t, flexmems_t *fmem, bool base_p,
-		 tree pun /* = NULL_TREE */,
+		 bool nested_p /* = false */, bool pun /* = false */,
 		 tree pstr /* = NULL_TREE */)
 {
-  /* Set the "pointer" to the outermost enclosing union if not set
-     yet and maintain it for the remainder of the recursion.   */
-  if (!pun && TREE_CODE (t) == UNION_TYPE)
-    pun = t;
-
-  for (tree fld = TYPE_FIELDS (t); fld; fld = DECL_CHAIN (fld))
+  if (TREE_CODE (t) == UNION_TYPE)
+    pun = true;
+
+  tree fld = TYPE_FIELDS (t);
+  if ((base_p || nested_p) && TREE_CODE (t) == RECORD_TYPE)
+    {
+      /* In bases or in nested structures, only process the last
+	 non-static data member.  If we have say
+	 struct A { int a; int b[]; int c; };
+	 struct B { int d; int e[]; int f; };
+	 struct C : A { int g; B h, i; int j; };
+	 then the A::b followed by A::c should have been diagnosed
+	 already when completing struct A, and B::e followed by B::f
+	 when completing struct B, so no need to repeat that when completing
+	 struct C.  So, only look at the last member so we cover e.g.
+	 struct D { int k; int l[]; };
+	 struct E : D { int m; };
+	 struct F { D n; int o; };
+	 where flexible array member at the end of D is fine, but it isn't
+	 correct that E::m in E or F::o in F follows it.  */
+      tree last_fld = NULL_TREE;
+      for (; (fld = next_subobject_field (fld)); fld = DECL_CHAIN (fld))
+	if (DECL_ARTIFICIAL (fld))
+	  continue;
+	else if (TREE_TYPE (fld) == error_mark_node)
+	  return;
+	else if (TREE_CODE (TREE_TYPE (fld)) == ARRAY_TYPE
+		 || field_nonempty_p (fld))
+	  last_fld = fld;
+      fld = last_fld;
+    }
+  for (; fld; fld = DECL_CHAIN (fld))
     {
       if (fld == error_mark_node)
 	return;
@@ -7462,11 +7510,11 @@ find_flexarrays (tree t, flexmems_t *fmem, bool base_p,
 
       if (RECORD_OR_UNION_TYPE_P (eltype))
 	{
-	  if (fmem->array && !fmem->after[bool (pun)])
+	  if (fmem->array && !fmem->after[pun])
 	    {
 	      /* Once the member after the flexible array has been found
 		 we're done.  */
-	      fmem->after[bool (pun)] = fld;
+	      fmem->after[pun] = fld;
 	      break;
 	    }
 
@@ -7480,32 +7528,43 @@ find_flexarrays (tree t, flexmems_t *fmem, bool base_p,
 		 are already in the process of being checked by one of the
 		 recursive calls).  */
 
-	      tree first = fmem->first;
+	      bool first = fmem->first;
 	      tree array = fmem->array;
+	      bool maybe_anon_p = TYPE_UNNAMED_P (eltype);
+	      if (tree ctx = maybe_anon_p ? TYPE_CONTEXT (eltype) : NULL_TREE)
+		maybe_anon_p = RECORD_OR_UNION_TYPE_P (ctx);
 
 	      /* If this member isn't anonymous and a prior non-flexible array
 		 member has been seen in one of the enclosing structs, clear
 		 the FIRST member since it doesn't contribute to the flexible
 		 array struct's members.  */
 	      if (first && !array && !ANON_AGGR_TYPE_P (eltype))
-		fmem->first = NULL_TREE;
+		fmem->first = false;
 
-	      find_flexarrays (eltype, fmem, false, pun,
-			       !pstr && TREE_CODE (t) == RECORD_TYPE ? fld : pstr);
+	      find_flexarrays (eltype, fmem, false, !maybe_anon_p, pun,
+			       !pstr && TREE_CODE (t) == RECORD_TYPE
+			       ? fld : pstr);
 
 	      if (fmem->array != array)
-		continue;
-
-	      if (first && !array && !ANON_AGGR_TYPE_P (eltype))
 		{
-		  /* Restore the FIRST member reset above if no flexible
-		     array member has been found in this member's struct.  */
-		  fmem->first = first;
+		  /* If the recursive call passed true to nested_p,
+		     it only looked at the last field and we do not
+		     want to diagnose in that case the "in otherwise empty"
+		     case, just if it is followed by some other non-empty
+		     member.  So set fmem->first.  */
+		  if (!maybe_anon_p)
+		    fmem->first = true;
+		  continue;
 		}
 
+	      if (first && !array && !ANON_AGGR_TYPE_P (eltype))
+		/* Restore the FIRST member reset above if no flexible
+		   array member has been found in this member's struct.  */
+		fmem->first = first;
+
 	      /* If the member struct contains the first flexible array
 		 member, or if this member is a base class, continue to
-		 the next member and avoid setting the FMEM->NEXT pointer
+		 the next member and avoid setting the FMEM->AFTER pointer
 		 to point to it.  */
 	      if (base_p)
 		continue;
@@ -7516,13 +7575,13 @@ find_flexarrays (tree t, flexmems_t *fmem, bool base_p,
 	{
 	  /* Remember the first non-static data member.  */
 	  if (!fmem->first)
-	    fmem->first = fld;
+	    fmem->first = true;
 
 	  /* Remember the first non-static data member after the flexible
 	     array member, if one has been found, or the zero-length array
 	     if it has been found.  */
-	  if (fmem->array && !fmem->after[bool (pun)])
-	    fmem->after[bool (pun)] = fld;
+	  if (fmem->array && !fmem->after[pun])
+	    fmem->after[pun] = fld;
 	}
 
       /* Skip non-arrays.  */
@@ -7538,8 +7597,8 @@ find_flexarrays (tree t, flexmems_t *fmem, bool base_p,
 		 such field or a flexible array member has been seen to
 		 handle the pathological and unlikely case of multiple
 		 such members.  */
-	      if (!fmem->after[bool (pun)])
-		fmem->after[bool (pun)] = fld;
+	      if (!fmem->after[pun])
+		fmem->after[pun] = fld;
 	    }
 	  else if (integer_all_onesp (TYPE_MAX_VALUE (TYPE_DOMAIN (fldtype))))
 	    {
@@ -7558,13 +7617,13 @@ find_flexarrays (tree t, flexmems_t *fmem, bool base_p,
 		{
 		  /* Replace the zero-length array if it's been stored and
 		     reset the after pointer.  */
-		  fmem->after[bool (pun)] = NULL_TREE;
+		  fmem->after[pun] = NULL_TREE;
 		  fmem->array = fld;
 		  fmem->enclosing = pstr;
 		}
-	      else if (!fmem->after[bool (pun)])
+	      else if (!fmem->after[pun])
 		/* Make a record of another flexible array member.  */
-		fmem->after[bool (pun)] = fld;
+		fmem->after[pun] = fld;
 	    }
 	  else
 	    {
@@ -7585,15 +7644,14 @@ diagnose_invalid_flexarray (const flexmems_t *fmem)
     {
       auto_diagnostic_group d;
       if (pedwarn (location_of (fmem->enclosing), OPT_Wpedantic,
-		     TYPE_DOMAIN (TREE_TYPE (fmem->array))
-		     ? G_("invalid use of %q#T with a zero-size array "
-			  "in %q#D")
-		     : G_("invalid use of %q#T with a flexible array member "
-			  "in %q#T"),
-		     DECL_CONTEXT (fmem->array),
-		     DECL_CONTEXT (fmem->enclosing)))
+		   TYPE_DOMAIN (TREE_TYPE (fmem->array))
+		   ? G_("invalid use of %q#T with a zero-size array in %q#D")
+		   : G_("invalid use of %q#T with a flexible array member "
+			"in %q#T"),
+		   DECL_CONTEXT (fmem->array),
+		   DECL_CONTEXT (fmem->enclosing)))
 	inform (DECL_SOURCE_LOCATION (fmem->array),
-		  "array member %q#D declared here", fmem->array);
+		"array member %q#D declared here", fmem->array);
     }
 }
 
@@ -7662,8 +7720,8 @@ diagnose_flexarrays (tree t, const flexmems_t *fmem)
 	     overlaps another member of a common union, point to it.
 	     Otherwise it should be obvious.  */
 	  if (fmem->after[0]
-	      && ((DECL_CONTEXT (fmem->after[0])
-		   != DECL_CONTEXT (fmem->array))))
+	      && (DECL_CONTEXT (fmem->after[0])
+		  != DECL_CONTEXT (fmem->array)))
 	    {
 	      inform (DECL_SOURCE_LOCATION (fmem->after[0]),
 		      "next member %q#D declared here",
@@ -7756,14 +7814,12 @@ check_flexarrays (tree t, flexmems_t *fmem /* = NULL */,
     find_flexarrays (t, fmem, base_p || fam != fmem->array);
 
   if (fmem == &flexmems && !maybe_anon_p)
-    {
-      /* Issue diagnostics for invalid flexible and zero-length array
-	 members found in base classes or among the members of the current
-	 class.  Ignore anonymous structs and unions whose members are
-	 considered to be members of the enclosing class and thus will
-	 be diagnosed when checking it.  */
-      diagnose_flexarrays (t, fmem);
-    }
+    /* Issue diagnostics for invalid flexible and zero-length array
+       members found in base classes or among the members of the current
+       class.  Ignore anonymous structs and unions whose members are
+       considered to be members of the enclosing class and thus will
+       be diagnosed when checking it.  */
+    diagnose_flexarrays (t, fmem);
 }
 
 /* Perform processing required when the definition of T (a class type)
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 41ff78bbf2b9b399a31b7bebe4a8be021a7242e1..58bed6f8965f28985382f8213148accc5d502ae2 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -839,9 +839,8 @@ cx_check_missing_mem_inits (tree ctype, tree body, bool complain)
       if (i < nelts)
 	{
 	  index = CONSTRUCTOR_ELT (body, i)->index;
-	  /* Skip base and vtable inits.  */
-	  if (TREE_CODE (index) != FIELD_DECL
-	      || DECL_ARTIFICIAL (index))
+	  /* Skip vptr adjustment represented with a COMPONENT_REF.  */
+	  if (TREE_CODE (index) != FIELD_DECL)
 	    continue;
 	}
 
@@ -852,7 +851,8 @@ cx_check_missing_mem_inits (tree ctype, tree body, bool complain)
 	    continue;
 	  if (DECL_UNNAMED_BIT_FIELD (field))
 	    continue;
-	  if (DECL_ARTIFICIAL (field))
+	  /* Artificial fields can be ignored unless they're bases.  */
+	  if (DECL_ARTIFICIAL (field) && !DECL_FIELD_IS_BASE (field))
 	    continue;
 	  if (ANON_AGGR_TYPE_P (TREE_TYPE (field)))
 	    {
@@ -5624,7 +5624,11 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init,
 	  if (init == void_node)
 	    /* Trivial default-init, don't do anything to the CONSTRUCTOR.  */
 	    return ctx->ctor;
-	  eltinit = cxx_eval_constant_expression (&new_ctx, init, lval,
+	  eltinit = init;
+	  if (CLASS_TYPE_P (elttype) && new_ctx.object)
+	    /* Clarify what object is being initialized (118285).  */
+	    eltinit = build2 (INIT_EXPR, elttype, new_ctx.object, eltinit);
+	  eltinit = cxx_eval_constant_expression (&new_ctx, eltinit, lval,
 						  non_constant_p, overflow_p);
 	  reuse = i == 0;
 	}
@@ -5637,6 +5641,9 @@ cxx_eval_vec_init_1 (const constexpr_ctx *ctx, tree atype, tree init,
 	  eltinit = (perform_implicit_conversion_flags
 		     (elttype, eltinit, complain,
 		      LOOKUP_IMPLICIT|LOOKUP_NO_NARROWING));
+	  if (CLASS_TYPE_P (elttype) && new_ctx.object)
+	    /* Clarify what object is being initialized (118285).  */
+	    eltinit = build2 (INIT_EXPR, elttype, new_ctx.object, eltinit);
 	  eltinit = cxx_eval_constant_expression (&new_ctx, eltinit, lval,
 						  non_constant_p, overflow_p);
 	}
diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc
index 5782ec8bf29596884c30da240347a3043d6e1b85..f2b126c8d6bea7e905f4195402b71b41c0b97290 100644
--- a/gcc/cp/contracts.cc
+++ b/gcc/cp/contracts.cc
@@ -1633,19 +1633,22 @@ get_pseudo_contract_violation_type ()
 	   signed char _M_continue;
 	 If this changes, also update the initializer in
 	 build_contract_violation.  */
-      const tree types[] = { const_string_type_node,
-			     const_string_type_node,
-			     const_string_type_node,
-			     const_string_type_node,
-			     const_string_type_node,
-			     uint_least32_type_node,
-			     signed_char_type_node };
+      struct field_info { tree type; const char* name; };
+      const field_info info[] = {
+	{ const_string_type_node, "_M_file" },
+	{ const_string_type_node, "_M_function" },
+	{ const_string_type_node, "_M_comment" },
+	{ const_string_type_node, "_M_level" },
+	{ const_string_type_node, "_M_role" },
+	{ uint_least32_type_node, "_M_line" },
+	{ signed_char_type_node, "_M_continue" }
+      };
       tree fields = NULL_TREE;
-      for (tree type : types)
+      for (const field_info& i : info)
 	{
 	  /* finish_builtin_struct wants fieldss chained in reverse.  */
 	  tree next = build_decl (BUILTINS_LOCATION, FIELD_DECL,
-				  NULL_TREE, type);
+				  get_identifier (i.name), i.type);
 	  DECL_CHAIN (next) = fields;
 	  fields = next;
 	}
@@ -1737,6 +1740,7 @@ declare_handle_contract_violation ()
       create_implicit_typedef (viol_name, violation);
       DECL_SOURCE_LOCATION (TYPE_NAME (violation)) = BUILTINS_LOCATION;
       DECL_CONTEXT (TYPE_NAME (violation)) = current_namespace;
+      TREE_PUBLIC (TYPE_NAME (violation)) = true;
       pushdecl_namespace_level (TYPE_NAME (violation), /*hidden*/true);
       pop_namespace ();
       pop_nested_namespace (std_node);
@@ -1761,6 +1765,11 @@ static void
 build_contract_handler_call (tree contract,
 			     contract_continuation cmode)
 {
+  /* We may need to declare new types, ensure they are not considered
+     attached to a named module.  */
+  auto module_kind_override = make_temp_override
+    (module_kind, module_kind & ~(MK_PURVIEW | MK_ATTACH | MK_EXPORTING));
+
   tree violation = build_contract_violation (contract, cmode);
   tree violation_fn = declare_handle_contract_violation ();
   tree call = build_call_n (violation_fn, 1, build_address (violation));
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 1dee3d25b9b4d89ca899e007e0c47a6a6e6919d3..d3c7ff3bd72d9a21765fa4a92b022aeb1f8b83fb 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -1188,6 +1188,28 @@ build_template_co_await_expr (location_t kw, tree type, tree expr, tree kind)
   return aw_expr;
 }
 
+/* Is EXPR an lvalue that will refer to the same object after a resume?
+
+   This is close to asking tree_invariant_p of its address, but that doesn't
+   distinguish temporaries from other variables.  */
+
+static bool
+is_stable_lvalue (tree expr)
+{
+  if (TREE_SIDE_EFFECTS (expr))
+    return false;
+
+  for (; handled_component_p (expr);
+       expr = TREE_OPERAND (expr, 0))
+    {
+      if (TREE_CODE (expr) == ARRAY_REF
+	  && !TREE_CONSTANT (TREE_OPERAND (expr, 1)))
+	return false;
+    }
+
+  return (TREE_CODE (expr) == PARM_DECL
+	  || (VAR_P (expr) && !is_local_temp (expr)));
+}
 
 /*  This performs [expr.await] bullet 3.3 and validates the interface obtained.
     It is also used to build the initial and final suspend points.
@@ -1250,7 +1272,7 @@ build_co_await (location_t loc, tree a, suspend_point_kind suspend_kind,
   if (o_type && !VOID_TYPE_P (o_type))
     o_type = complete_type_or_else (o_type, o);
 
-  if (!o_type)
+  if (!o_type || o_type == error_mark_node)
     return error_mark_node;
 
   if (TREE_CODE (o_type) != RECORD_TYPE)
@@ -1282,14 +1304,30 @@ build_co_await (location_t loc, tree a, suspend_point_kind suspend_kind,
   if (!glvalue_p (o))
     o = get_target_expr (o, tf_warning_or_error);
 
+  /* [expr.await]/3.4 e is an lvalue referring to the result of evaluating the
+     (possibly-converted) o.
+
+     So, either reuse an existing stable lvalue such as a variable or
+     COMPONENT_REF thereof, or create a new a coroutine state frame variable
+     for the awaiter, since it must persist across suspension.  */
+  tree e_var = NULL_TREE;
   tree e_proxy = o;
-  if (glvalue_p (o))
+  if (is_stable_lvalue (o))
     o = NULL_TREE; /* Use the existing entity.  */
-  else /* We need to materialise it.  */
+  else /* We need a non-temp var.  */
     {
-      e_proxy = get_awaitable_var (suspend_kind, o_type);
-      o = cp_build_init_expr (loc, e_proxy, o);
-      e_proxy = convert_from_reference (e_proxy);
+      tree p_type = TREE_TYPE (o);
+      tree o_a = o;
+      if (glvalue_p (o))
+	{
+	  /* Build a reference variable for a non-stable lvalue o.  */
+	  p_type = cp_build_reference_type (p_type, xvalue_p (o));
+	  o_a = build_address (o);
+	  o_a = cp_fold_convert (p_type, o_a);
+	}
+      e_var = get_awaitable_var (suspend_kind, p_type);
+      o = cp_build_init_expr (loc, e_var, o_a);
+      e_proxy = convert_from_reference (e_var);
     }
 
   /* I suppose we could check that this is contextually convertible to bool.  */
@@ -1355,7 +1393,7 @@ build_co_await (location_t loc, tree a, suspend_point_kind suspend_kind,
 	return error_mark_node;
       if (coro_diagnose_throwing_fn (awrs_func))
 	return error_mark_node;
-      if (tree dummy = cxx_maybe_build_cleanup (e_proxy, tf_none))
+      if (tree dummy = cxx_maybe_build_cleanup (e_var, tf_none))
 	{
 	  if (CONVERT_EXPR_P (dummy))
 	    dummy = TREE_OPERAND (dummy, 0);
@@ -1366,7 +1404,8 @@ build_co_await (location_t loc, tree a, suspend_point_kind suspend_kind,
     }
 
   /* We now have three call expressions, in terms of the promise, handle and
-     'e' proxies.  Save them in the await expression for later expansion.  */
+     'e' proxy expression.  Save them in the await expression for later
+     expansion.  */
 
   tree awaiter_calls = make_tree_vec (3);
   TREE_VEC_ELT (awaiter_calls, 0) = awrd_call; /* await_ready().  */
@@ -1379,8 +1418,8 @@ build_co_await (location_t loc, tree a, suspend_point_kind suspend_kind,
     }
   TREE_VEC_ELT (awaiter_calls, 2) = awrs_call; /* await_resume().  */
 
-  if (REFERENCE_REF_P (e_proxy))
-    e_proxy = TREE_OPERAND (e_proxy, 0);
+  if (e_var)
+    e_proxy = e_var;
 
   tree awrs_type = TREE_TYPE (TREE_TYPE (awrs_func));
   tree suspend_kind_cst = build_int_cst (integer_type_node,
diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
index 4ec3de13008c00ed0da01df555a006766b28910f..45f4e27b8b742b3f674baf1025d383ea95cbceb4 100644
--- a/gcc/cp/cp-gimplify.cc
+++ b/gcc/cp/cp-gimplify.cc
@@ -1182,6 +1182,28 @@ taking_address_of_imm_fn_error (tree expr, tree decl)
   maybe_explain_promoted_consteval (loc, decl);
 }
 
+/* Build up an INIT_EXPR to initialize the object of a constructor call that
+   has been folded to a constant value.  CALL is the CALL_EXPR for the
+   constructor call; INIT is the value.  */
+
+static tree
+cp_build_init_expr_for_ctor (tree call, tree init)
+{
+  tree a = CALL_EXPR_ARG (call, 0);
+  if (is_dummy_object (a))
+    return init;
+  const bool return_this = targetm.cxx.cdtor_returns_this ();
+  const location_t loc = EXPR_LOCATION (call);
+  if (return_this)
+    a = cp_save_expr (a);
+  tree s = build_fold_indirect_ref_loc (loc, a);
+  init = cp_build_init_expr (s, init);
+  if (return_this)
+    init = build2_loc (loc, COMPOUND_EXPR, TREE_TYPE (call), init,
+		    fold_convert_loc (loc, TREE_TYPE (call), a));
+  return init;
+}
+
 /* A subroutine of cp_fold_r to handle immediate functions.  */
 
 static tree
@@ -1297,7 +1319,12 @@ cp_fold_immediate_r (tree *stmt_p, int *walk_subtrees, void *data_)
 	}
       /* We've evaluated the consteval function call.  */
       if (call_p)
-	*stmt_p = e;
+	{
+	  if (code == CALL_EXPR && DECL_CONSTRUCTOR_P (decl))
+	    *stmt_p = cp_build_init_expr_for_ctor (stmt, e);
+	  else
+	    *stmt_p = e;
+	}
     }
   /* We've encountered a function call that may turn out to be consteval
      later.  Store its caller so that we can ensure that the call is
@@ -3422,18 +3449,7 @@ cp_fold (tree x, fold_flags_t flags)
         if (TREE_CODE (r) != CALL_EXPR)
 	  {
 	    if (DECL_CONSTRUCTOR_P (callee))
-	      {
-		loc = EXPR_LOCATION (x);
-		tree a = CALL_EXPR_ARG (x, 0);
-		bool return_this = targetm.cxx.cdtor_returns_this ();
-		if (return_this)
-		  a = cp_save_expr (a);
-		tree s = build_fold_indirect_ref_loc (loc, a);
-		r = cp_build_init_expr (s, r);
-		if (return_this)
-		  r = build2_loc (loc, COMPOUND_EXPR, TREE_TYPE (x), r,
-				  fold_convert_loc (loc, TREE_TYPE (x), a));
-	      }
+	      r = cp_build_init_expr_for_ctor (x, r);
 	    x = r;
 	    break;
 	  }
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 5e8aefc12893cb8ea87ef781e63a42225de95d30..ec976928f5fb0eb25935b47c7b7042cc064756f9 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -429,7 +429,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
       LAMBDA_CAPTURE_EXPLICIT_P (in a TREE_LIST in LAMBDA_EXPR_CAPTURE_LIST)
       PARENTHESIZED_LIST_P (in the TREE_LIST for a parameter-declaration-list)
       CONSTRUCTOR_IS_DIRECT_INIT (in CONSTRUCTOR)
-      LAMBDA_EXPR_CAPTURES_THIS_P (in LAMBDA_EXPR)
       DECLTYPE_FOR_LAMBDA_CAPTURE (in DECLTYPE_TYPE)
       VEC_INIT_EXPR_IS_CONSTEXPR (in VEC_INIT_EXPR)
       DECL_OVERRIDE_P (in FUNCTION_DECL)
@@ -472,6 +471,7 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
       BASELINK_FUNCTIONS_MAYBE_INCOMPLETE_P (in BASELINK)
       BIND_EXPR_VEC_DTOR (in BIND_EXPR)
       ATOMIC_CONSTR_EXPR_FROM_CONCEPT_P (in ATOMIC_CONSTR)
+      STATIC_INIT_DECOMP_BASE_P (in the TREE_LIST for {static,tls}_aggregates)
    2: IDENTIFIER_KIND_BIT_2 (in IDENTIFIER_NODE)
       ICS_THIS_FLAG (in _CONV)
       DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (in VAR_DECL)
@@ -491,6 +491,8 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
       IMPLICIT_CONV_EXPR_BRACED_INIT (in IMPLICIT_CONV_EXPR)
       PACK_EXPANSION_AUTO_P (in *_PACK_EXPANSION)
       contract_semantic (in ASSERTION_, PRECONDITION_, POSTCONDITION_STMT)
+      STATIC_INIT_DECOMP_NONBASE_P (in the TREE_LIST
+				    for {static,tls}_aggregates)
    3: IMPLICIT_RVALUE_P (in NON_LVALUE_EXPR or STATIC_CAST_EXPR)
       ICS_BAD_FLAG (in _CONV)
       FN_TRY_BLOCK_P (in TRY_BLOCK)
@@ -1540,10 +1542,6 @@ enum cp_lambda_default_capture_mode_type {
 #define LAMBDA_EXPR_THIS_CAPTURE(NODE) \
   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->this_capture)
 
-/* Predicate tracking whether `this' is in the effective capture set.  */
-#define LAMBDA_EXPR_CAPTURES_THIS_P(NODE) \
-  LAMBDA_EXPR_THIS_CAPTURE(NODE)
-
 /* True iff uses of a const variable capture were optimized away.  */
 #define LAMBDA_EXPR_CAPTURE_OPTIMIZED(NODE) \
   TREE_LANG_FLAG_2 (LAMBDA_EXPR_CHECK (NODE))
@@ -1562,7 +1560,8 @@ enum cp_lambda_default_capture_mode_type {
   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->locus)
 
 /* The mangling scope for the lambda: FUNCTION_DECL, PARM_DECL, VAR_DECL,
-   FIELD_DECL or NULL_TREE.  If this is NULL_TREE, we have no linkage.  */
+   FIELD_DECL, TYPE_DECL, or NULL_TREE.  If this is NULL_TREE, we have no
+   linkage.  */
 #define LAMBDA_EXPR_EXTRA_SCOPE(NODE) \
   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->extra_scope)
 
@@ -3631,7 +3630,8 @@ struct GTY(()) lang_decl {
    the DECL_FRIEND_CONTEXT for `f' will be `S'.  */
 #define DECL_FRIEND_CONTEXT(NODE)				\
   ((DECL_DECLARES_FUNCTION_P (NODE) && !DECL_VIRTUAL_P (NODE)	\
-    && !DECL_CONSTRUCTOR_P (NODE))				\
+    && !DECL_CONSTRUCTOR_P (NODE)				\
+    && (cxx_dialect < cxx23 || !deduction_guide_p (NODE)))	\
    ? LANG_DECL_FN_CHECK (NODE)->context				\
    : NULL_TREE)
 
@@ -5674,7 +5674,8 @@ enum cp_lvalue_kind_flags {
   clk_class = 4,    /* A prvalue of class or array type.  */
   clk_bitfield = 8, /* An lvalue for a bit-field.  */
   clk_packed = 16,  /* An lvalue for a packed field.  */
-  clk_implicit_rval = 1<<5 /* An lvalue being treated as an xvalue.  */
+  clk_implicit_rval = 1<<5, /* An lvalue being treated as an xvalue.  */
+  clk_mergeable = 1<<6
 };
 
 /* This type is used for parameters and variables which hold
@@ -6046,6 +6047,21 @@ extern bool defer_mangling_aliases;
 
 extern bool flag_noexcept_type;
 
+/* True if this TREE_LIST in {static,tls}_aggregates is a for dynamic
+   initialization of namespace scope structured binding base or related
+   extended ref init temps.  Temporaries from the initialization of
+   STATIC_INIT_DECOMP_BASE_P dynamic initializers should be destroyed only
+   after the last STATIC_INIT_DECOMP_NONBASE_P dynamic initializer following
+   it.  */
+#define STATIC_INIT_DECOMP_BASE_P(NODE) \
+  TREE_LANG_FLAG_1 (TREE_LIST_CHECK (NODE))
+
+/* True if this TREE_LIST in {static,tls}_aggregates is a for dynamic
+   initialization of namespace scope structured binding non-base
+   variable using get.  */
+#define STATIC_INIT_DECOMP_NONBASE_P(NODE) \
+  TREE_LANG_FLAG_2 (TREE_LIST_CHECK (NODE))
+
 /* A list of namespace-scope objects which have constructors or
    destructors which reside in the global scope.  The decl is stored
    in the TREE_VALUE slot and the initializer is stored in the
@@ -8171,6 +8187,7 @@ extern bool glvalue_p				(const_tree);
 extern bool obvalue_p				(const_tree);
 extern bool xvalue_p	                        (const_tree);
 extern bool bitfield_p				(const_tree);
+extern bool non_mergeable_glvalue_p		(const_tree);
 extern tree cp_stabilize_reference		(tree);
 extern bool builtin_valid_in_constant_expr_p    (const_tree);
 extern tree build_min				(enum tree_code, tree, ...);
@@ -8688,7 +8705,8 @@ struct diagnosing_failed_constraint
 extern cp_expr finish_constraint_or_expr	(location_t, cp_expr, cp_expr);
 extern cp_expr finish_constraint_and_expr	(location_t, cp_expr, cp_expr);
 extern cp_expr finish_constraint_primary_expr	(cp_expr);
-extern tree finish_concept_definition		(cp_expr, tree, tree);
+extern tree start_concept_definition		(cp_expr);
+extern tree finish_concept_definition		(tree, tree, tree);
 extern tree combine_constraint_expressions      (tree, tree);
 extern tree append_constraint			(tree, tree);
 extern tree get_constraints                     (const_tree);
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index d6fb76e70345e3c9814dd82563070cb66b83b375..4238314558b1aaba1afbe71957dd139800066249 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -96,7 +96,7 @@ static void record_key_method_defined (tree);
 static tree create_array_type_for_decl (tree, tree, tree, location_t);
 static tree get_atexit_node (void);
 static tree get_dso_handle_node (void);
-static tree start_cleanup_fn (bool);
+static tree start_cleanup_fn (tree, bool);
 static void end_cleanup_fn (void);
 static tree cp_make_fname_decl (location_t, tree, int);
 static void initialize_predefined_identifiers (void);
@@ -8473,27 +8473,33 @@ omp_declare_variant_finalize_one (tree decl, tree attr)
   if (append_args_list)
     {
       append_args_list = TREE_VALUE (append_args_list);
-      if (append_args_list)
-	append_args_list = TREE_CHAIN (append_args_list);
+      append_args_list = (append_args_list && TREE_CHAIN (append_args_list)
+			  ? TREE_VALUE (TREE_CHAIN (append_args_list))
+			  : NULL_TREE);
       for (tree t = append_args_list; t; t = TREE_CHAIN (t))
 	nappend_args++;
       if (nappend_args)
 	{
 	  tree type;
-	  if ((type = lookup_qualified_name (current_scope (),
+	  if ((type = lookup_qualified_name (global_namespace,
 					     "omp_interop_t",
 					     LOOK_want::NORMAL,
 					     /*complain*/false)) == NULL_TREE
 	      || !c_omp_interop_t_p (TREE_TYPE (type)))
 	    {
+	      location_t loc = input_location;
 	      variant = tree_strip_any_location_wrapper (variant);
-	      if (TREE_CODE (variant) == OVERLOAD && OVL_SINGLE_P (variant))
-		variant = OVL_FIRST (variant);
-	      error_at (EXPR_LOC_OR_LOC (variant, DECL_SOURCE_LOCATION (variant)),
-			"argument %d of %qE must be of %<omp_interop_t%>",
+	      if (!identifier_p (variant))
+		{
+		  if (TREE_CODE (variant) == OVERLOAD && OVL_SINGLE_P (variant))
+		    variant = OVL_FIRST (variant);
+		  loc = EXPR_LOC_OR_LOC (variant,
+					 DECL_SOURCE_LOCATION (variant));
+		}
+	      error_at (loc, "argument %d of %qE must be of %<omp_interop_t%>",
 			args->length () + 1, variant);
-	      inform (OMP_CLAUSE_LOCATION (append_args_list),
-			"%<append_args%> specified here");
+	      inform (EXPR_LOCATION (TREE_PURPOSE (append_args_list)),
+		      "%<append_args%> specified here");
 	      return true;
 	    }
 	  for (unsigned i = 0; i < nappend_args; i++)
@@ -8598,7 +8604,7 @@ omp_declare_variant_finalize_one (tree decl, tree attr)
 		  error_at (DECL_SOURCE_LOCATION (variant),
 			    "argument %d of %qD must be of %<omp_interop_t%>",
 			    nbase_args + i + 1, variant);
-		  inform (OMP_CLAUSE_LOCATION (append_args_list),
+		  inform (EXPR_LOCATION (TREE_PURPOSE (append_args_list)),
 			  "%<append_args%> specified here");
 		  break;
 		}
@@ -8641,6 +8647,15 @@ omp_declare_variant_finalize_one (tree decl, tree attr)
 		      = build_int_cst (TREE_TYPE (t),
 				       tree_to_uhwi (TREE_VALUE (t)) + 1);
 		}
+	      if (DECL_NONSTATIC_MEMBER_P (variant) && append_args_list)
+		{
+		  /* Shift likewise the number of args after which the
+		     interop object should be added.  */
+		  tree nargs = TREE_CHAIN (TREE_VALUE (adjust_args_list));
+		  TREE_PURPOSE (nargs)
+		    = build_int_cst (TREE_TYPE (nargs),
+				     tree_to_uhwi (TREE_PURPOSE (nargs)) + 1);
+		}
 	      DECL_ATTRIBUTES (variant) = tree_cons (
 		get_identifier ("omp declare variant variant args"),
 		TREE_VALUE (adjust_args_list), DECL_ATTRIBUTES (variant));
@@ -8742,6 +8757,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
   bool var_definition_p = false;
   tree auto_node;
   auto_vec<tree> extra_cleanups;
+  tree aggregates1 = NULL_TREE;
   struct decomp_cleanup {
     tree decl;
     cp_decomp *&decomp;
@@ -9129,7 +9145,16 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
 	}
 
       if (decomp)
-	cp_maybe_mangle_decomp (decl, decomp);
+	{
+	  cp_maybe_mangle_decomp (decl, decomp);
+	  if (TREE_STATIC (decl) && !DECL_FUNCTION_SCOPE_P (decl))
+	    {
+	      if (CP_DECL_THREAD_LOCAL_P (decl))
+		aggregates1 = tls_aggregates;
+	      else
+		aggregates1 = static_aggregates;
+	    }
+	}
 
       /* If this is a local variable that will need a mangled name,
 	 register it now.  We must do this before processing the
@@ -9467,6 +9492,32 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
   if (decomp_init)
     add_stmt (decomp_init);
 
+  if (decomp
+      && var_definition_p
+      && TREE_STATIC (decl)
+      && !DECL_FUNCTION_SCOPE_P (decl))
+    {
+      tree &aggregates3 = (CP_DECL_THREAD_LOCAL_P (decl)
+			   ? tls_aggregates : static_aggregates);
+      tree aggregates2 = aggregates3;
+      if (aggregates2 != aggregates1)
+	{
+	  cp_finish_decomp (decl, decomp);
+	  decomp = NULL;
+	  if (aggregates3 != aggregates2)
+	    {
+	      /* If there are dynamic initializers for the structured
+		 binding base or associated extended ref temps and also
+		 dynamic initializers for the structured binding non-base
+		 vars, mark them.  */
+	      for (tree t = aggregates3; t != aggregates2; t = TREE_CHAIN (t))
+		STATIC_INIT_DECOMP_NONBASE_P (t) = 1;
+	      for (tree t = aggregates2; t != aggregates1; t = TREE_CHAIN (t))
+		STATIC_INIT_DECOMP_BASE_P (t) = 1;
+	    }
+	}
+    }
+
   if (was_readonly)
     TREE_READONLY (decl) = 1;
 
@@ -10322,23 +10373,23 @@ get_dso_handle_node (void)
 }
 
 /* Begin a new function with internal linkage whose job will be simply
-   to destroy some particular variable.  OB_PARM is true if object pointer
+   to destroy some particular DECL.  OB_PARM is true if object pointer
    is passed to the cleanup function, otherwise no argument is passed.  */
 
-static GTY(()) int start_cleanup_cnt;
-
 static tree
-start_cleanup_fn (bool ob_parm)
+start_cleanup_fn (tree decl, bool ob_parm)
 {
-  char name[32];
-
   push_to_top_level ();
 
   /* No need to mangle this.  */
   push_lang_context (lang_name_c);
 
   /* Build the name of the function.  */
-  sprintf (name, "__tcf_%d", start_cleanup_cnt++);
+  gcc_checking_assert (HAS_DECL_ASSEMBLER_NAME_P (decl));
+  const char *dname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+  dname = targetm.strip_name_encoding (dname);
+  char *name = ACONCAT (("__tcf", dname, NULL));
+
   tree fntype = TREE_TYPE (ob_parm ? get_cxa_atexit_fn_ptr_type ()
 				   : get_atexit_fn_ptr_type ());
   /* Build the function declaration.  */
@@ -10431,7 +10482,7 @@ register_dtor_fn (tree decl)
       build_cleanup (decl);
 
       /* Now start the function.  */
-      cleanup = start_cleanup_fn (ob_parm);
+      cleanup = start_cleanup_fn (decl, ob_parm);
 
       /* Now, recompute the cleanup.  It may contain SAVE_EXPRs that refer
 	 to the original function, rather than the anonymous one.  That
@@ -11162,14 +11213,28 @@ grokfndecl (tree ctype,
      expression, that declaration shall be a definition..."  */
   if (friendp && !funcdef_flag)
     {
+      bool has_errored = false;
       for (tree t = FUNCTION_FIRST_USER_PARMTYPE (decl);
 	   t && t != void_list_node; t = TREE_CHAIN (t))
 	if (TREE_PURPOSE (t))
 	  {
-	    permerror (DECL_SOURCE_LOCATION (decl),
-		       "friend declaration of %qD specifies default "
-		       "arguments and isn%'t a definition", decl);
-	    break;
+	    diagnostic_t diag_kind = DK_PERMERROR;
+	    /* For templates, mark the default argument as erroneous and give a
+	       hard error.  */
+	    if (processing_template_decl)
+	      {
+		diag_kind = DK_ERROR;
+		TREE_PURPOSE (t) = error_mark_node;
+	      }
+	    if (!has_errored)
+	      {
+		has_errored = true;
+		emit_diagnostic (diag_kind,
+				 DECL_SOURCE_LOCATION (decl),
+				 /*diagnostic_option_id=*/0,
+				 "friend declaration of %qD specifies default "
+				 "arguments and isn%'t a definition", decl);
+	      }
 	  }
     }
 
@@ -19582,7 +19647,7 @@ cxx_maybe_build_cleanup (tree decl, tsubst_flags_t complain)
   /* Assume no cleanup is required.  */
   cleanup = NULL_TREE;
 
-  if (error_operand_p (decl))
+  if (!decl || error_operand_p (decl))
     return cleanup;
 
   /* Handle "__attribute__((cleanup))".  We run the cleanup function
diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc
index ffe1aa3a3244449ccefde7a5a00c7d0e92ad1a45..a11c431758f7935e7b69166d5fbc6821a16078fc 100644
--- a/gcc/cp/decl2.cc
+++ b/gcc/cp/decl2.cc
@@ -2032,7 +2032,7 @@ build_anon_union_vars (tree type, tree object)
 
       if (processing_template_decl)
 	ref = build_min_nt_loc (UNKNOWN_LOCATION, COMPONENT_REF, object,
-				DECL_NAME (field), NULL_TREE);
+				field, NULL_TREE);
       else
 	ref = build_class_member_access_expr (object, field, NULL_TREE,
 					      false, tf_warning_or_error);
@@ -4504,6 +4504,55 @@ one_static_initialization_or_destruction (bool initp, tree decl, tree init)
   DECL_STATIC_FUNCTION_P (current_function_decl) = 0;
 }
 
+/* Helper function for emit_partial_init_fini_fn and handle_tls_init.
+   For structured bindings, disable stmts_are_full_exprs_p ()
+   on STATIC_INIT_DECOMP_BASE_P nodes, reenable it on the
+   first STATIC_INIT_DECOMP_NONBASE_P node and emit all the
+   STATIC_INIT_DECOMP_BASE_P and STATIC_INIT_DECOMP_NONBASE_P
+   consecutive nodes in a single STATEMENT_LIST wrapped with
+   CLEANUP_POINT_EXPR.  */
+
+static inline tree
+decomp_handle_one_var (tree node, tree sl, bool *saw_nonbase,
+		       int save_stmts_are_full_exprs_p)
+{
+  if (sl && !*saw_nonbase && STATIC_INIT_DECOMP_NONBASE_P (node))
+    {
+      *saw_nonbase = true;
+      current_stmt_tree ()->stmts_are_full_exprs_p
+	= save_stmts_are_full_exprs_p;
+    }
+  else if (sl && *saw_nonbase && !STATIC_INIT_DECOMP_NONBASE_P (node))
+    {
+      sl = pop_stmt_list (sl);
+      sl = maybe_cleanup_point_expr_void (sl);
+      add_stmt (sl);
+      sl = NULL_TREE;
+    }
+  if (sl == NULL_TREE && STATIC_INIT_DECOMP_BASE_P (node))
+    {
+      sl = push_stmt_list ();
+      *saw_nonbase = false;
+      current_stmt_tree ()->stmts_are_full_exprs_p = 0;
+    }
+  return sl;
+}
+
+/* Similarly helper called when the whole var list is processed.  */
+
+static inline void
+decomp_finalize_var_list (tree sl, int save_stmts_are_full_exprs_p)
+{
+  if (sl)
+    {
+      current_stmt_tree ()->stmts_are_full_exprs_p
+	= save_stmts_are_full_exprs_p;
+      sl = pop_stmt_list (sl);
+      sl = maybe_cleanup_point_expr_void (sl);
+      add_stmt (sl);
+    }
+}
+
 /* Generate code to do the initialization or destruction of the decls in VARS,
    a TREE_LIST of VAR_DECL with static storage duration.
    Whether initialization or destruction is performed is specified by INITP.  */
@@ -4533,12 +4582,17 @@ emit_partial_init_fini_fn (bool initp, unsigned priority, tree vars,
       finish_if_stmt_cond (target_dev_p, nonhost_if_stmt);
     }
 
+  tree sl = NULL_TREE;
+  int save_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
+  bool saw_nonbase = false;
   for (tree node = vars; node; node = TREE_CHAIN (node))
     {
       tree decl = TREE_VALUE (node);
       tree init = TREE_PURPOSE (node);
-	/* We will emit 'init' twice, and it is modified in-place during
-	   gimplification.  Make a copy here.  */
+      sl = decomp_handle_one_var (node, sl, &saw_nonbase,
+				  save_stmts_are_full_exprs_p);
+      /* We will emit 'init' twice, and it is modified in-place during
+	 gimplification.  Make a copy here.  */
       if (omp_target)
 	{
 	  /* We've already emitted INIT in the host version of the ctor/dtor
@@ -4562,6 +4616,7 @@ emit_partial_init_fini_fn (bool initp, unsigned priority, tree vars,
       /* Do one initialization or destruction.  */
       one_static_initialization_or_destruction (initp, decl, init);
     }
+  decomp_finalize_var_list (sl, save_stmts_are_full_exprs_p);
 
   if (omp_target)
     {
@@ -4611,6 +4666,8 @@ prune_vars_needing_no_initialization (tree *vars)
 	 here.  */
       if (DECL_EXTERNAL (decl))
 	{
+	  gcc_checking_assert (!STATIC_INIT_DECOMP_BASE_P (t)
+			       && !STATIC_INIT_DECOMP_NONBASE_P (t));
 	  var = &TREE_CHAIN (t);
 	  continue;
 	}
@@ -4640,12 +4697,19 @@ prune_vars_needing_no_initialization (tree *vars)
 void
 partition_vars_for_init_fini (tree var_list, priority_map_t *(&parts)[4])
 {
+  unsigned priority = 0;
+  enum { none, base, nonbase } decomp_state = none;
   for (auto node = var_list; node; node = TREE_CHAIN (node))
     {
       tree decl = TREE_VALUE (node);
       tree init = TREE_PURPOSE (node);
       bool has_cleanup = !TYPE_HAS_TRIVIAL_DESTRUCTOR (TREE_TYPE (decl));
-      unsigned priority = DECL_EFFECTIVE_INIT_PRIORITY (decl);
+      if (decomp_state == base && STATIC_INIT_DECOMP_NONBASE_P (node))
+	decomp_state = nonbase;
+      else if (decomp_state == nonbase && !STATIC_INIT_DECOMP_NONBASE_P (node))
+	decomp_state = none;
+      if (decomp_state == none)
+	priority = DECL_EFFECTIVE_INIT_PRIORITY (decl);
 
       if (init || (flag_use_cxa_atexit && has_cleanup))
 	{
@@ -4654,6 +4718,34 @@ partition_vars_for_init_fini (tree var_list, priority_map_t *(&parts)[4])
 	    parts[true] = priority_map_t::create_ggc ();
 	  auto &slot = parts[true]->get_or_insert (priority);
 	  slot = tree_cons (init, decl, slot);
+	  if (init
+	      && STATIC_INIT_DECOMP_BASE_P (node)
+	      && decomp_state == none)
+	    {
+	      /* If one or more STATIC_INIT_DECOMP_BASE_P with at least
+		 one init is followed by at least one
+		 STATIC_INIT_DECOMP_NONBASE_P with init, mark it in the
+		 resulting chain as well.  */
+	      for (tree n = TREE_CHAIN (node); n; n = TREE_CHAIN (n))
+		if (STATIC_INIT_DECOMP_BASE_P (n))
+		  continue;
+		else if (STATIC_INIT_DECOMP_NONBASE_P (n))
+		  {
+		    if (TREE_PURPOSE (n))
+		      {
+			decomp_state = base;
+			break;
+		      }
+		    else
+		      continue;
+		  }
+		else
+		  break;
+	    }
+	  if (init && decomp_state == base)
+	    STATIC_INIT_DECOMP_BASE_P (slot) = 1;
+	  else if (decomp_state == nonbase)
+	    STATIC_INIT_DECOMP_NONBASE_P (slot) = 1;
 	}
 
       if (!flag_use_cxa_atexit && has_cleanup)
@@ -4666,7 +4758,7 @@ partition_vars_for_init_fini (tree var_list, priority_map_t *(&parts)[4])
 	}
 
       if (flag_openmp
-	   && lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))
+	  && lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))
 	{
 	  priority_map_t **omp_parts = parts + 2;
 
@@ -4677,6 +4769,10 @@ partition_vars_for_init_fini (tree var_list, priority_map_t *(&parts)[4])
 		omp_parts[true] = priority_map_t::create_ggc ();
 	      auto &slot = omp_parts[true]->get_or_insert (priority);
 	      slot = tree_cons (init, decl, slot);
+	      if (init && decomp_state == base)
+		STATIC_INIT_DECOMP_BASE_P (slot) = 1;
+	      else if (decomp_state == nonbase)
+		STATIC_INIT_DECOMP_NONBASE_P (slot) = 1;
 	    }
 
 	  if (!flag_use_cxa_atexit && has_cleanup)
@@ -5063,10 +5159,15 @@ handle_tls_init (void)
   finish_expr_stmt (cp_build_modify_expr (loc, guard, NOP_EXPR,
 					  boolean_true_node,
 					  tf_warning_or_error));
+  tree sl = NULL_TREE;
+  int save_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
+  bool saw_nonbase = false;
   for (; vars; vars = TREE_CHAIN (vars))
     {
       tree var = TREE_VALUE (vars);
       tree init = TREE_PURPOSE (vars);
+      sl = decomp_handle_one_var (vars, sl, &saw_nonbase,
+				  save_stmts_are_full_exprs_p);
       one_static_initialization_or_destruction (/*initp=*/true, var, init);
 
       /* Output init aliases even with -fno-extern-tls-init.  */
@@ -5081,6 +5182,7 @@ handle_tls_init (void)
 	  gcc_assert (alias != NULL);
 	}
     }
+  decomp_finalize_var_list (sl, save_stmts_are_full_exprs_p);
 
   finish_then_clause (if_stmt);
   finish_if_stmt (if_stmt);
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index a33afdb3d509871cfcee5f1a886a8d72e4a2119a..72e169585487f922e8fa2398655e2a29d9eeb4b4 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -3402,7 +3402,8 @@ location_of (tree t)
 	return input_location;
     }
   else if (TREE_CODE (t) == OVERLOAD)
-    t = OVL_FIRST (t);
+    t = (OVL_FIRST (t) != conv_op_marker ? OVL_FIRST (t)
+	 : OVL_FIRST (OVL_CHAIN (t)));
 
   if (DECL_P (t))
     return DECL_SOURCE_LOCATION (t);
diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index f2c462419af01769cc03a6b299a0622947b928b3..613775c5a7c821c9ddd08c507a248264d803e1fa 100644
--- a/gcc/cp/init.cc
+++ b/gcc/cp/init.cc
@@ -3709,6 +3709,11 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
                 error ("parenthesized initializer in array new");
 	      return error_mark_node;
             }
+
+	  /* Collect flags for disabling subobject cleanups once the complete
+	     object is fully constructed.  */
+	  vec<tree, va_gc> *flags = make_tree_vector ();
+
 	  init_expr
 	    = build_vec_init (data_addr,
 			      cp_build_binary_op (input_location,
@@ -3718,7 +3723,17 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
 			      vecinit,
 			      explicit_value_init_p,
 			      /*from_array=*/0,
-                              complain);
+			      complain,
+			      &flags);
+
+	  for (tree f : flags)
+	    {
+	      tree cl = build_disable_temp_cleanup (f);
+	      cl = convert_to_void (cl, ICV_STATEMENT, complain);
+	      init_expr = build2 (COMPOUND_EXPR, void_type_node,
+				  init_expr, cl);
+	    }
+	  release_tree_vector (flags);
 	}
       else
 	{
@@ -4771,7 +4786,8 @@ build_vec_init (tree base, tree maxindex, tree init,
       tree field, elt;
       /* If the constructor already has the array type, it's been through
 	 digest_init, so we shouldn't try to do anything more.  */
-      bool digested = same_type_p (atype, TREE_TYPE (init));
+      bool digested = (TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE
+		       && same_type_p (type, TREE_TYPE (TREE_TYPE (init))));
       from_array = 0;
 
       if (length_check)
diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc
index 5593636eaf8edc9b5ac8efda8c964c0214e383a9..2d86e9892f99aea2baa4953878726c0ed813585b 100644
--- a/gcc/cp/lambda.cc
+++ b/gcc/cp/lambda.cc
@@ -613,7 +613,7 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
 	    return error_mark_node;
 	}
 
-      if (cxx_dialect < cxx20)
+      if (cxx_dialect < cxx20 && !explicit_init_p)
 	{
 	  auto_diagnostic_group d;
 	  tree stripped_init = tree_strip_any_location_wrapper (initializer);
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 17215594fd3f99380df371883d5f56ba3c642bbe..59716e1873e96b545127f3d90cf8c61665dc55e7 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -241,11 +241,11 @@ Classes used:
 #define MAPPED_READING 0
 #define MAPPED_WRITING 0
 #else
-#if HAVE_MMAP_FILE && _POSIX_MAPPED_FILES > 0
-/* mmap, munmap.  */
+#if HAVE_MMAP_FILE && HAVE_MUNMAP && HAVE_MSYNC
+/* mmap, munmap, msync.  */
 #define MAPPED_READING 1
 #if HAVE_SYSCONF && defined (_SC_PAGE_SIZE)
-/* msync, sysconf (_SC_PAGE_SIZE), ftruncate  */
+/* sysconf (_SC_PAGE_SIZE), ftruncate  */
 /* posix_fallocate used if available.  */
 #define MAPPED_WRITING 1
 #else
@@ -11014,18 +11014,23 @@ trees_out::get_merge_kind (tree decl, depset *dep)
 	       g++.dg/modules/lambda-6_a.C.  */
 	    if (DECL_IMPLICIT_TYPEDEF_P (STRIP_TEMPLATE (decl))
 		&& LAMBDA_TYPE_P (TREE_TYPE (decl)))
-	      if (tree scope = LAMBDA_TYPE_EXTRA_SCOPE (TREE_TYPE (decl)))
-		{
-		  /* Lambdas attached to fields are keyed to its class.  */
-		  if (TREE_CODE (scope) == FIELD_DECL)
-		    scope = TYPE_NAME (DECL_CONTEXT (scope));
-		  if (DECL_LANG_SPECIFIC (scope)
-		      && DECL_MODULE_KEYED_DECLS_P (scope))
-		    {
-		      mk = MK_keyed;
-		      break;
-		    }
-		}
+	      {
+		if (tree scope = LAMBDA_TYPE_EXTRA_SCOPE (TREE_TYPE (decl)))
+		  {
+		    /* Lambdas attached to fields are keyed to its class.  */
+		    if (TREE_CODE (scope) == FIELD_DECL)
+		      scope = TYPE_NAME (DECL_CONTEXT (scope));
+		    if (DECL_LANG_SPECIFIC (scope)
+			&& DECL_MODULE_KEYED_DECLS_P (scope))
+		      {
+			mk = MK_keyed;
+			break;
+		      }
+		  }
+		/* Lambdas not attached to any mangling scope are TU-local.  */
+		mk = MK_unique;
+		break;
+	      }
 
 	    if (TREE_CODE (decl) == TEMPLATE_DECL
 		&& DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P (decl))
@@ -11329,7 +11334,8 @@ trees_out::key_mergeable (int tag, merge_kind mk, tree decl, tree inner,
 	    gcc_checking_assert (TREE_CODE (scope) == VAR_DECL
 				 || TREE_CODE (scope) == FIELD_DECL
 				 || TREE_CODE (scope) == PARM_DECL
-				 || TREE_CODE (scope) == TYPE_DECL);
+				 || TREE_CODE (scope) == TYPE_DECL
+				 || TREE_CODE (scope) == CONCEPT_DECL);
 	    /* Lambdas attached to fields are keyed to the class.  */
 	    if (TREE_CODE (scope) == FIELD_DECL)
 	      scope = TYPE_NAME (DECL_CONTEXT (scope));
@@ -13435,9 +13441,10 @@ depset::hash::is_tu_local_entity (tree decl, bool explain/*=false*/)
       tree main_decl = TYPE_MAIN_DECL (type);
       if (!DECL_CLASS_SCOPE_P (main_decl)
 	  && !decl_function_context (main_decl)
-	  /* FIXME: Lambdas defined outside initializers.  We'll need to more
-	     thoroughly set LAMBDA_TYPE_EXTRA_SCOPE to check this.  */
-	  && !LAMBDA_TYPE_P (type))
+	  /* LAMBDA_EXPR_EXTRA_SCOPE will be set for lambdas defined in
+	     contexts where they would not be TU-local.  */
+	  && !(LAMBDA_TYPE_P (type)
+	       && LAMBDA_TYPE_EXTRA_SCOPE (type)))
 	{
 	  if (explain)
 	    inform (loc, "%qT has no name and is not defined within a class, "
@@ -18720,6 +18727,65 @@ module_state::write_inits (elf_out *to, depset::hash &table, unsigned *crc_ptr)
       for (tree init = list; init; init = TREE_CHAIN (init))
 	if (TREE_LANG_FLAG_0 (init))
 	  {
+	    if (STATIC_INIT_DECOMP_BASE_P (init))
+	      {
+		/* Ensure that in the returned result chain if the
+		   STATIC_INIT_DECOMP_*BASE_P flags are set, there is
+		   always one or more STATIC_INIT_DECOMP_BASE_P TREE_LIST
+		   followed by one or more STATIC_INIT_DECOMP_NONBASE_P.  */
+		int phase = 0;
+		tree last = NULL_TREE;
+		for (tree init2 = TREE_CHAIN (init);
+		     init2; init2 = TREE_CHAIN (init2))
+		  {
+		    if (phase == 0 && STATIC_INIT_DECOMP_BASE_P (init2))
+		      ;
+		    else if (phase == 0
+			     && STATIC_INIT_DECOMP_NONBASE_P (init2))
+		      {
+			phase = TREE_LANG_FLAG_0 (init2) ? 2 : 1;
+			last = init2;
+		      }
+		    else if (IN_RANGE (phase, 1, 2)
+			     && STATIC_INIT_DECOMP_NONBASE_P (init2))
+		      {
+			if (TREE_LANG_FLAG_0 (init2))
+			  phase = 2;
+			last = init2;
+		      }
+		    else
+		      break;
+		  }
+		if (phase == 2)
+		  {
+		    /* In that case, add markers about it so that the
+		       STATIC_INIT_DECOMP_BASE_P and
+		       STATIC_INIT_DECOMP_NONBASE_P flags can be restored.  */
+		    sec.tree_node (build_int_cst (integer_type_node,
+						  2 * passes + 1));
+		    phase = 1;
+		    for (tree init2 = init; init2 != TREE_CHAIN (last);
+			 init2 = TREE_CHAIN (init2))
+		      if (TREE_LANG_FLAG_0 (init2))
+			{
+			  tree decl = TREE_VALUE (init2);
+			  if (phase == 1
+			      && STATIC_INIT_DECOMP_NONBASE_P (init2))
+			    {
+			      sec.tree_node (build_int_cst (integer_type_node,
+							    2 * passes + 2));
+			      phase = 2;
+			    }
+			  dump ("Initializer:%u for %N", count, decl);
+			  sec.tree_node (decl);
+			  ++count;
+			}
+		    sec.tree_node (integer_zero_node);
+		    init = last;
+		    continue;
+		  }
+	      }
+
 	    tree decl = TREE_VALUE (init);
 
 	    dump ("Initializer:%u for %N", count, decl);
@@ -18790,16 +18856,54 @@ module_state::read_inits (unsigned count)
   dump.indent ();
 
   lazy_snum = ~0u;
+  int decomp_phase = 0;
+  tree *aggrp = NULL;
   for (unsigned ix = 0; ix != count; ix++)
     {
+      tree last = NULL_TREE;
+      if (decomp_phase)
+	last = *aggrp;
       /* Merely referencing the decl causes its initializer to be read
 	 and added to the correct list.  */
       tree decl = sec.tree_node ();
+      /* module_state::write_inits can add special INTEGER_CST markers in
+	 between the decls.  1 means STATIC_INIT_DECOMP_BASE_P entries
+	 follow in static_aggregates, 2 means STATIC_INIT_DECOMP_NONBASE_P
+	 entries follow in static_aggregates, 3 means
+	 STATIC_INIT_DECOMP_BASE_P entries follow in tls_aggregates,
+	 4 means STATIC_INIT_DECOMP_NONBASE_P follow in tls_aggregates,
+	 0 means end of STATIC_INIT_DECOMP_{,NON}BASE_P sequence.  */
+      if (tree_fits_shwi_p (decl))
+	{
+	  if (sec.get_overrun ())
+	    break;
+	  decomp_phase = tree_to_shwi (decl);
+	  if (decomp_phase)
+	    {
+	      aggrp = decomp_phase > 2 ? &tls_aggregates : &static_aggregates;
+	      last = *aggrp;
+	    }
+	  decl = sec.tree_node ();
+	}
 
       if (sec.get_overrun ())
 	break;
       if (decl)
-	dump ("Initializer:%u for %N", count, decl);
+	dump ("Initializer:%u for %N", ix, decl);
+      if (decomp_phase)
+	{
+	  tree init = *aggrp;
+	  gcc_assert (TREE_VALUE (init) == decl && TREE_CHAIN (init) == last);
+	  if ((decomp_phase & 1) != 0)
+	    STATIC_INIT_DECOMP_BASE_P (init) = 1;
+	  else
+	    STATIC_INIT_DECOMP_NONBASE_P (init) = 1;
+	}
+    }
+  if (decomp_phase && !sec.get_overrun ())
+    {
+      tree decl = sec.tree_node ();
+      gcc_assert (integer_zerop (decl));
     }
   lazy_snum = 0;
   post_load_processing ();
@@ -20309,11 +20413,12 @@ maybe_key_decl (tree ctx, tree decl)
     return;
 
   /* We only need to deal with lambdas attached to var, field,
-     parm, or type decls.  */
+     parm, type, or concept decls.  */
   if (TREE_CODE (ctx) != VAR_DECL
       && TREE_CODE (ctx) != FIELD_DECL
       && TREE_CODE (ctx) != PARM_DECL
-      && TREE_CODE (ctx) != TYPE_DECL)
+      && TREE_CODE (ctx) != TYPE_DECL
+      && TREE_CODE (ctx) != CONCEPT_DECL)
     return;
 
   /* For fields, key it to the containing type to handle deduplication
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 03010089c3c625a0f625c83e0dc7ce8901c19a1f..9b8be084452e7fd1162995e26b44f239a5abd087 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -23617,6 +23617,10 @@ warn_about_ambiguous_parse (const cp_decl_specifier_seq *decl_specifiers,
 			(const_cast<cp_declarator *>(declarator))))
     return;
 
+  /* Don't warn for auto f () -> auto.  */
+  if (declarator->u.function.late_return_type)
+    return;
+
   /* Don't warn when the whole declarator (not just the declarator-id!)
      was parenthesized.  That is, don't warn for int(n()) but do warn
      for int(f)().  */
@@ -25514,6 +25518,26 @@ cp_parser_late_return_type_opt (cp_parser *parser, cp_declarator *declarator,
       /* Consume the ->.  */
       cp_lexer_consume_token (parser->lexer);
 
+      /* We may be in the context of parsing a parameter declaration,
+	 namely, its declarator.  auto_is_implicit_function_template_parm_p
+	 will be disabled in that case.  But for code like
+
+	   int g (auto fp() -> auto);
+
+	 we have to re-enable the flag for the trailing auto.  However, that
+	 only applies for the outermost trailing auto in a parameter clause; in
+
+	   int f2 (auto fp(auto fp2() -> auto) -> auto);
+
+	 the inner -> auto should not be synthesized.  */
+      int i = 0;
+      for (cp_binding_level *b = current_binding_level;
+	   b->kind == sk_function_parms; b = b->level_chain)
+	++i;
+      auto cleanup = make_temp_override
+	(parser->auto_is_implicit_function_template_parm_p,
+	 (i == 2 && !current_function_decl));
+
       type = cp_parser_trailing_type_id (parser);
     }
 
@@ -26279,15 +26303,6 @@ cp_parser_parameter_declaration (cp_parser *parser,
 				&decl_specifiers,
 				&declares_class_or_enum);
 
-  /* [dcl.spec.auto.general]: "A placeholder-type-specifier of the form
-     type-constraint opt auto can be used as a decl-specifier of the
-     decl-specifier-seq of a parameter-declaration of a function declaration
-     or lambda-expression..." but we must not synthesize an implicit template
-     type parameter in its declarator.  That is, in "void f(auto[auto{10}]);"
-     we want to synthesize only the first auto.  */
-  auto cleanup = make_temp_override
-    (parser->auto_is_implicit_function_template_parm_p, false);
-
   /* Complain about missing 'typename' or other invalid type names.  */
   if (!decl_specifiers.any_type_specifiers_p
       && cp_parser_parse_and_diagnose_invalid_type_name (parser))
@@ -26301,6 +26316,16 @@ cp_parser_parameter_declaration (cp_parser *parser,
       return NULL;
     }
 
+  /* [dcl.spec.auto.general]: "A placeholder-type-specifier of the form
+     type-constraint opt auto can be used as a decl-specifier of the
+     decl-specifier-seq of a parameter-declaration of a function declaration
+     or lambda-expression..." but we must not synthesize an implicit template
+     type parameter in its declarator (except the trailing-return-type).
+     That is, in "void f(auto[auto{10}]);" we want to synthesize only the
+     first auto.  */
+  auto cleanup = make_temp_override
+    (parser->auto_is_implicit_function_template_parm_p, false);
+
   /* Peek at the next token.  */
   token = cp_lexer_peek_token (parser->lexer);
 
@@ -27462,6 +27487,8 @@ cp_parser_class_specifier (cp_parser* parser)
   if (!braces.require_open (parser))
     {
       pop_deferring_access_checks ();
+      if (type != error_mark_node)
+	finish_lambda_scope ();
       return error_mark_node;
     }
 
@@ -27526,7 +27553,10 @@ cp_parser_class_specifier (cp_parser* parser)
   if (cp_parser_allow_gnu_extensions_p (parser))
     attributes = cp_parser_gnu_attributes_opt (parser);
   if (type != error_mark_node)
-    type = finish_struct (type, attributes);
+    {
+      type = finish_struct (type, attributes);
+      finish_lambda_scope ();
+    }
   if (nested_name_specifier_p)
     pop_inner_scope (old_scope, scope);
 
@@ -28366,6 +28396,12 @@ cp_parser_class_head (cp_parser* parser,
   if (flag_concepts)
     type = associate_classtype_constraints (type);
 
+  /* Lambdas in bases and members must have the same mangling scope for ABI.
+     We open this scope now, and will close it in cp_parser_class_specifier
+     after parsing the member list.  */
+  if (type && type != error_mark_node)
+    start_lambda_scope (TYPE_NAME (type));
+
   /* We will have entered the scope containing the class; the names of
      base classes should be looked up in that context.  For example:
 
@@ -28380,16 +28416,10 @@ cp_parser_class_head (cp_parser* parser,
   if (cp_lexer_next_token_is (parser->lexer, CPP_COLON))
     {
       if (type)
-	{
-	  pushclass (type);
-	  start_lambda_scope (TYPE_NAME (type));
-	}
+	pushclass (type);
       bases = cp_parser_base_clause (parser);
       if (type)
-	{
-	  finish_lambda_scope ();
-	  popclass ();
-	}
+	popclass ();
     }
   else
     bases = NULL_TREE;
@@ -31825,8 +31855,20 @@ cp_parser_concept_definition (cp_parser *parser)
       return error_mark_node;
     }
 
+  tree decl = start_concept_definition (id);
+  if (decl == error_mark_node)
+    {
+      cp_parser_skip_to_end_of_statement (parser);
+      cp_parser_consume_semicolon_at_end_of_statement (parser);
+      return error_mark_node;
+    }
+
   processing_constraint_expression_sentinel parsing_constraint;
+
+  start_lambda_scope (decl);
   tree init = cp_parser_constraint_expression (parser);
+  finish_lambda_scope ();
+
   if (init == error_mark_node)
     cp_parser_skip_to_end_of_statement (parser);
 
@@ -31834,7 +31876,7 @@ cp_parser_concept_definition (cp_parser *parser)
      but continue as if it were.  */
   cp_parser_consume_semicolon_at_end_of_statement (parser);
 
-  return finish_concept_definition (id, init, attrs);
+  return finish_concept_definition (decl, init, attrs);
 }
 
 // -------------------------------------------------------------------------- //
@@ -50512,17 +50554,19 @@ cp_finish_omp_declare_variant (cp_parser *parser, cp_token *pragma_tok,
 							&targetsync,
 							&prefer_type_tree))
 		goto fail;
-	      tree t = build_omp_clause (loc, OMP_CLAUSE_INIT);
+	      tree t = build_tree_list (target ? boolean_true_node
+					       : boolean_false_node,
+					targetsync ? boolean_true_node
+						   : boolean_false_node);
+	      t = build1_loc (loc, NOP_EXPR, void_type_node, t);
+	      t = build_tree_list (t, prefer_type_tree);
 	      if (append_args_tree)
-		OMP_CLAUSE_CHAIN (append_args_last) = t;
+		{
+		  TREE_CHAIN (append_args_last) = t;
+		  append_args_last = t;
+		}
 	      else
 		append_args_tree = append_args_last = t;
-	      if (target)
-		OMP_CLAUSE_INIT_TARGET (t) = 1;
-	      if (targetsync)
-		OMP_CLAUSE_INIT_TARGETSYNC (t) = 1;
-	      if (prefer_type_tree)
-		OMP_CLAUSE_INIT_PREFER_TYPE (t) = prefer_type_tree;
 	      if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN))
 		{
 		  cp_parser_error (parser, "expected %<)%> or %<,%>");
@@ -50542,6 +50586,15 @@ cp_finish_omp_declare_variant (cp_parser *parser, cp_token *pragma_tok,
 	      cp_lexer_consume_token (parser->lexer); // ','
 	    }
 	  while (true);
+	  int nbase_args = 0;
+	  for (tree t = parms;
+	       t && TREE_VALUE (t) != void_type_node; t = TREE_CHAIN (t))
+	    nbase_args++;
+	  /* Store as purpose = arg number after which to append
+	     and value = list of interop items.  */
+	  append_args_tree = build_tree_list (build_int_cst (integer_type_node,
+							     nbase_args),
+					      append_args_tree);
 	}
   } while (cp_lexer_next_token_is_not (parser->lexer, CPP_PRAGMA_EOL));
 
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 28e05490d06c997d40d45db9b27c1db2ae1ef094..39232b5e67fd8fb3d792a0b43ed2d84730d27927 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -4010,6 +4010,11 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
 		    &find_parameter_packs_r, ppd, ppd->visited);
       return NULL_TREE;
 
+    case TEMPLATE_PARM_INDEX:
+      if (parameter_pack_p)
+	WALK_SUBTREE (TREE_TYPE (t));
+      return NULL_TREE;
+
     case DECL_EXPR:
       {
 	tree decl = DECL_EXPR_DECL (t);
@@ -10822,11 +10827,6 @@ for_each_template_parm_r (tree *tp, int *walk_subtrees, void *d)
 	WALK_SUBTREE (TYPE_TI_ARGS (t));
       break;
 
-    case INTEGER_TYPE:
-      WALK_SUBTREE (TYPE_MIN_VALUE (t));
-      WALK_SUBTREE (TYPE_MAX_VALUE (t));
-      break;
-
     case METHOD_TYPE:
       /* Since we're not going to walk subtrees, we have to do this
 	 explicitly here.  */
@@ -12165,13 +12165,27 @@ tsubst_attribute (tree t, tree *decl_p, tree args,
       location_t match_loc = cp_expr_loc_or_input_loc (TREE_PURPOSE (chain));
       tree ctx = copy_list (TREE_VALUE (val));
       tree append_args_list = TREE_CHAIN (TREE_CHAIN (chain));
-      if (append_args_list)
+      if (append_args_list && TREE_VALUE (append_args_list))
 	{
-	  append_args_list = TREE_VALUE (append_args_list);
-	  if (append_args_list)
-	    TREE_CHAIN (append_args_list)
-	      = tsubst_omp_clauses (TREE_CHAIN (append_args_list),
-				    C_ORT_OMP_DECLARE_SIMD, args, complain, in_decl);
+	  append_args_list = TREE_VALUE (TREE_VALUE (append_args_list));
+	  for (; append_args_list;
+	       append_args_list = TREE_CHAIN (append_args_list))
+	     {
+	      tree pref_list = TREE_VALUE (append_args_list);
+	      tree fr_list = TREE_VALUE (pref_list);
+	      int len = TREE_VEC_LENGTH (fr_list);
+	      for (int i = 0; i < len; i++)
+		{
+		  tree *fr_expr = &TREE_VEC_ELT (fr_list, i);
+		  /* Preserve NOP_EXPR to have a location.  */
+		  if (*fr_expr && TREE_CODE (*fr_expr) == NOP_EXPR)
+		    TREE_OPERAND (*fr_expr, 0)
+		      = tsubst_expr (TREE_OPERAND (*fr_expr, 0), args, complain,
+				     in_decl);
+		  else
+		    *fr_expr = tsubst_expr (*fr_expr, args, complain, in_decl);
+		}
+	    }
 	}
       for (tree tss = ctx; tss; tss = TREE_CHAIN (tss))
 	{
@@ -12606,6 +12620,10 @@ instantiate_class_template (tree type)
   gcc_assert (!DECL_CLASS_SCOPE_P (TYPE_MAIN_DECL (pattern))
 	      || COMPLETE_OR_OPEN_TYPE_P (TYPE_CONTEXT (type)));
 
+  /* When instantiating nested lambdas, ensure that they get the mangling
+     scope of the new class type.  */
+  start_lambda_scope (TYPE_NAME (type));
+
   base_list = NULL_TREE;
   /* Defer access checking while we substitute into the types named in
      the base-clause.  */
@@ -12967,6 +12985,8 @@ instantiate_class_template (tree type)
   finish_struct_1 (type);
   TYPE_BEING_DEFINED (type) = 0;
 
+  finish_lambda_scope ();
+
   /* Remember if instantiating this class ran into errors, so we can avoid
      instantiating member functions in limit_bad_template_recursion.  We set
      this flag even if the problem was in another instantiation triggered by
@@ -18014,7 +18034,7 @@ tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort,
 			     complain, in_decl);
 	  break;
 	case OMP_CLAUSE_INIT:
-	  if ((ort == C_ORT_OMP_INTEROP  || ort == C_ORT_OMP_DECLARE_SIMD)
+	  if (ort == C_ORT_OMP_INTEROP
 	      && OMP_CLAUSE_INIT_PREFER_TYPE (nc)
 	      && TREE_CODE (OMP_CLAUSE_INIT_PREFER_TYPE (nc)) == TREE_LIST
 	      && (OMP_CLAUSE_CHAIN (nc)  == NULL_TREE
@@ -20225,7 +20245,7 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 
   if (LAMBDA_EXPR_EXTRA_SCOPE (t))
     record_lambda_scope (r);
-  else if (TYPE_NAMESPACE_SCOPE_P (TREE_TYPE (t)))
+  if (TYPE_NAMESPACE_SCOPE_P (TREE_TYPE (t)))
     /* If we're pushed into another scope (PR105652), fix it.  */
     TYPE_CONTEXT (type) = DECL_CONTEXT (TYPE_NAME (type))
       = TYPE_CONTEXT (TREE_TYPE (t));
@@ -25098,15 +25118,6 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
 			     ? tf_warning_or_error
 			     : tf_none);
 
-  /* I don't think this will do the right thing with respect to types.
-     But the only case I've seen it in so far has been array bounds, where
-     signedness is the only information lost, and I think that will be
-     okay.  VIEW_CONVERT_EXPR can appear with class NTTP, thanks to
-     finish_id_expression_1, and are also OK.  */
-  while (CONVERT_EXPR_P (parm) || TREE_CODE (parm) == VIEW_CONVERT_EXPR
-	 || TREE_CODE (parm) == IMPLICIT_CONV_EXPR)
-    parm = TREE_OPERAND (parm, 0);
-
   if (arg == error_mark_node)
     return unify_invalid (explain_p);
   if (arg == unknown_type_node
@@ -25118,11 +25129,16 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
   if (parm == any_targ_node || arg == any_targ_node)
     return unify_success (explain_p);
 
-  /* Stripping IMPLICIT_CONV_EXPR above can produce this mismatch
-     (g++.dg/abi/mangle57.C).  */
-  if (TREE_CODE (parm) == FUNCTION_DECL
-      && TREE_CODE (arg) == ADDR_EXPR)
-    arg = TREE_OPERAND (arg, 0);
+  /* Strip conversions that will interfere with NTTP deduction.
+     I don't think this will do the right thing with respect to types.
+     But the only case I've seen it in so far has been array bounds, where
+     signedness is the only information lost, and I think that will be
+     okay.  VIEW_CONVERT_EXPR can appear with class NTTP, thanks to
+     finish_id_expression_1, and are also OK.  */
+  if (deducible_expression (parm))
+    while (CONVERT_EXPR_P (parm) || TREE_CODE (parm) == VIEW_CONVERT_EXPR
+	   || TREE_CODE (parm) == IMPLICIT_CONV_EXPR)
+      parm = TREE_OPERAND (parm, 0);
 
   /* If PARM uses template parameters, then we can't bail out here,
      even if ARG == PARM, since we won't record unifications for the
@@ -30021,12 +30037,10 @@ placeholder_type_constraint_dependent_p (tree t)
   return false;
 }
 
-/* Build and return a concept definition. Like other templates, the
-   CONCEPT_DECL node is wrapped by a TEMPLATE_DECL.  This returns the
-   the TEMPLATE_DECL. */
+/* Prepare and return a concept definition.  */
 
 tree
-finish_concept_definition (cp_expr id, tree init, tree attrs)
+start_concept_definition (cp_expr id)
 {
   gcc_assert (identifier_p (id));
   gcc_assert (processing_template_decl);
@@ -30058,9 +30072,20 @@ finish_concept_definition (cp_expr id, tree init, tree attrs)
   /* Initially build the concept declaration; its type is bool.  */
   tree decl = build_lang_decl_loc (loc, CONCEPT_DECL, *id, boolean_type_node);
   DECL_CONTEXT (decl) = current_scope ();
-  DECL_INITIAL (decl) = init;
   TREE_PUBLIC (decl) = true;
 
+  return decl;
+}
+
+/* Finish building a concept definition. Like other templates, the
+   CONCEPT_DECL node is wrapped by a TEMPLATE_DECL.  This returns the
+   the TEMPLATE_DECL. */
+
+tree
+finish_concept_definition (tree decl, tree init, tree attrs)
+{
+  DECL_INITIAL (decl) = init;
+
   if (attrs)
     cplus_decl_attributes (&decl, attrs, 0);
 
diff --git a/gcc/cp/rtti.cc b/gcc/cp/rtti.cc
index 2dfc2e3d7c5328ede2cb8ea34bf110c279aa4719..dcf84f17163b11c7325d72fc58eae130eda50da2 100644
--- a/gcc/cp/rtti.cc
+++ b/gcc/cp/rtti.cc
@@ -1741,7 +1741,8 @@ emit_tinfo_decl (tree decl)
       /* Avoid targets optionally bumping up the alignment to improve
 	 vector instruction accesses, tinfo are never accessed this way.  */
 #ifdef DATA_ABI_ALIGNMENT
-      SET_DECL_ALIGN (decl, DATA_ABI_ALIGNMENT (decl, TYPE_ALIGN (TREE_TYPE (decl))));
+      SET_DECL_ALIGN (decl, DATA_ABI_ALIGNMENT (TREE_TYPE (decl),
+						TYPE_ALIGN (TREE_TYPE (decl))));
       DECL_USER_ALIGN (decl) = true;
 #endif
       return true;
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index e891319f9a99842558138642d1806209f29bfdc7..73b49174de43331c25de690634eb55db6d41a0c4 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -1709,7 +1709,6 @@ finish_for_stmt (tree for_stmt)
     {
       tree stmt = pop_stmt_list (FOR_INIT_STMT (for_stmt));
       FOR_INIT_STMT (for_stmt) = NULL_TREE;
-      stmt = build_stmt (EXPR_LOCATION (for_stmt), EXPR_STMT, stmt);
       stmt = maybe_cleanup_point_expr_void (stmt);
       add_stmt (stmt);
     }
@@ -13165,7 +13164,14 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
 		  || DERIVED_FROM_P (type1, type2)));
 
     case CPTK_IS_BOUNDED_ARRAY:
-      return type_code1 == ARRAY_TYPE && TYPE_DOMAIN (type1);
+      return (type_code1 == ARRAY_TYPE
+	      && TYPE_DOMAIN (type1)
+	      /* We don't want to report T[0] as being a bounded array type.
+		 This is for compatibility with an implementation of
+		 std::is_bounded_array by template argument deduction, because
+		 compute_array_index_type_loc rejects a zero-size array
+		 in SFINAE context.  */
+	      && !(TYPE_SIZE (type1) && integer_zerop (TYPE_SIZE (type1))));
 
     case CPTK_IS_CLASS:
       return NON_UNION_CLASS_TYPE_P (type1);
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 36581865a17766e31d0f885b72b0191d2b7076b1..79bc74fa2b7ae141a067c1f0472e3c5b27c396d1 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -191,6 +191,8 @@ lvalue_kind (const_tree ref)
       return op1_lvalue_kind;
 
     case STRING_CST:
+      return clk_ordinary | clk_mergeable;
+
     case COMPOUND_LITERAL_EXPR:
       return clk_ordinary;
 
@@ -210,6 +212,10 @@ lvalue_kind (const_tree ref)
 	  && DECL_LANG_SPECIFIC (ref)
 	  && DECL_IN_AGGR_P (ref))
 	return clk_none;
+
+      if (TREE_CODE (ref) == CONST_DECL || DECL_MERGEABLE (ref))
+	return clk_ordinary | clk_mergeable;
+
       /* FALLTHRU */
     case INDIRECT_REF:
     case ARROW_EXPR:
@@ -407,6 +413,17 @@ bitfield_p (const_tree ref)
   return (lvalue_kind (ref) & clk_bitfield);
 }
 
+/* True if REF is a glvalue with a unique address, excluding mergeable glvalues
+   such as string constants.  */
+
+bool
+non_mergeable_glvalue_p (const_tree ref)
+{
+  auto kind = lvalue_kind (ref);
+  return (kind != clk_none
+	  && !(kind & (clk_class|clk_mergeable)));
+}
+
 /* C++-specific version of stabilize_reference.  */
 
 tree
@@ -5793,6 +5810,7 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func,
 		  && !TREE_STATIC (TREE_OPERAND (t, 0)))))
 	{
 	  tree decl = TREE_OPERAND (t, 0);
+	  WALK_SUBTREE (TREE_TYPE (decl));
 	  WALK_SUBTREE (DECL_INITIAL (decl));
 	  WALK_SUBTREE (DECL_SIZE (decl));
 	  WALK_SUBTREE (DECL_SIZE_UNIT (decl));
@@ -5843,6 +5861,12 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func,
       WALK_SUBTREE (STATIC_ASSERT_MESSAGE (t));
       break;
 
+    case INTEGER_TYPE:
+      /* Removed from walk_type_fields in r119481.  */
+      WALK_SUBTREE (TYPE_MIN_VALUE (t));
+      WALK_SUBTREE (TYPE_MAX_VALUE (t));
+      break;
+
     default:
       return NULL_TREE;
     }
@@ -6488,11 +6512,11 @@ test_lvalue_kind ()
   tree string_lit = build_string (4, "foo");
   TREE_TYPE (string_lit) = char_array_type_node;
   string_lit = fix_string_type (string_lit);
-  ASSERT_EQ (clk_ordinary, lvalue_kind (string_lit));
+  ASSERT_EQ (clk_ordinary|clk_mergeable, lvalue_kind (string_lit));
 
   tree wrapped_string_lit = maybe_wrap_with_location (string_lit, loc);
   ASSERT_TRUE (location_wrapper_p (wrapped_string_lit));
-  ASSERT_EQ (clk_ordinary, lvalue_kind (wrapped_string_lit));
+  ASSERT_EQ (clk_ordinary|clk_mergeable, lvalue_kind (wrapped_string_lit));
 
   tree parm = build_decl (UNKNOWN_LOCATION, PARM_DECL,
 			  get_identifier ("some_parm"),
diff --git a/gcc/cselib.cc b/gcc/cselib.cc
index aedde9fdd60795aa080e367341d889179e916df7..7f1991b09c3c8fd107b1a483d9dc47b9e1b1cdd7 100644
--- a/gcc/cselib.cc
+++ b/gcc/cselib.cc
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cselib.h"
 #include "function-abi.h"
 #include "alias.h"
+#include "predict.h"
 
 /* A list of cselib_val structures.  */
 struct elt_list
@@ -248,8 +249,9 @@ static unsigned int *used_regs;
 static unsigned int n_used_regs;
 
 /* We pass this to cselib_invalidate_mem to invalidate all of
-   memory for a non-const call instruction.  */
-static GTY(()) rtx callmem;
+   memory for a non-const call instruction and memory below stack pointer
+   for const/pure calls.  */
+static GTY(()) rtx callmem[2];
 
 /* Set by discard_useless_locs if it deleted the last location of any
    value.  */
@@ -808,7 +810,7 @@ cselib_preserve_only_values (void)
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
     cselib_invalidate_regno (i, reg_raw_mode[i]);
 
-  cselib_invalidate_mem (callmem);
+  cselib_invalidate_mem (callmem[0]);
 
   remove_useless_values ();
 
@@ -2630,6 +2632,8 @@ cselib_invalidate_mem (rtx mem_rtx)
       struct elt_loc_list **p = &v->locs;
       bool had_locs = v->locs != NULL;
       rtx_insn *setting_insn = v->locs ? v->locs->setting_insn : NULL;
+      rtx sp_base = NULL_RTX;
+      HOST_WIDE_INT sp_off = 0;
 
       while (*p)
 	{
@@ -2644,6 +2648,114 @@ cselib_invalidate_mem (rtx mem_rtx)
 	      p = &(*p)->next;
 	      continue;
 	    }
+
+	  /* When invalidating memory below the stack pointer for const/pure
+	     calls and alloca/VLAs aren't used, attempt to optimize.  Values
+	     stored into area sometimes below the stack pointer shouldn't be
+	     addressable and should be stored just through stack pointer
+	     derived expressions, so don't invalidate MEMs not using stack
+	     derived addresses, or if the MEMs clearly aren't below the stack
+	     pointer.  This isn't a fully conservative approach, the hope is
+	     that invalidating more MEMs than this isn't actually needed.  */
+	  if (mem_rtx == callmem[1]
+	      && num_mems < param_max_cselib_memory_locations
+	      && GET_CODE (XEXP (x, 0)) == VALUE
+	      && !cfun->calls_alloca)
+	    {
+	      cselib_val *v2 = CSELIB_VAL_PTR (XEXP (x, 0));
+	      rtx x_base = NULL_RTX;
+	      HOST_WIDE_INT x_off = 0;
+	      if (SP_DERIVED_VALUE_P (v2->val_rtx))
+		x_base = v2->val_rtx;
+	      else
+		for (struct elt_loc_list *l = v2->locs; l; l = l->next)
+		  if (GET_CODE (l->loc) == PLUS
+		      && GET_CODE (XEXP (l->loc, 0)) == VALUE
+		      && SP_DERIVED_VALUE_P (XEXP (l->loc, 0))
+		      && CONST_INT_P (XEXP (l->loc, 1)))
+		    {
+		      x_base = XEXP (l->loc, 0);
+		      x_off = INTVAL (XEXP (l->loc, 1));
+		      break;
+		    }
+	      /* If x_base is NULL here, don't invalidate x as its address
+		 isn't derived from sp such that it could be in outgoing
+		 argument area of some call in !ACCUMULATE_OUTGOING_ARGS
+		 function.  */
+	      if (x_base)
+		{
+		  if (sp_base == NULL_RTX)
+		    {
+		      if (cselib_val *v3
+			  = cselib_lookup_1 (stack_pointer_rtx, Pmode, 0,
+					     VOIDmode))
+			{
+			  if (SP_DERIVED_VALUE_P (v3->val_rtx))
+			    sp_base = v3->val_rtx;
+			  else
+			    for (struct elt_loc_list *l = v3->locs;
+				 l; l = l->next)
+			      if (GET_CODE (l->loc) == PLUS
+				  && GET_CODE (XEXP (l->loc, 0)) == VALUE
+				  && SP_DERIVED_VALUE_P (XEXP (l->loc, 0))
+				  && CONST_INT_P (XEXP (l->loc, 1)))
+				{
+				  sp_base = XEXP (l->loc, 0);
+				  sp_off = INTVAL (XEXP (l->loc, 1));
+				  break;
+				}
+			}
+		      if (sp_base == NULL_RTX)
+			sp_base = pc_rtx;
+		    }
+		  /* Otherwise, if x_base and sp_base are the same,
+		     we know that x_base + x_off is the x's address and
+		     sp_base + sp_off is current value of stack pointer,
+		     so try to determine if x is certainly not below stack
+		     pointer.  */
+		  if (sp_base == x_base)
+		    {
+		      if (STACK_GROWS_DOWNWARD)
+			{
+			  HOST_WIDE_INT off = sp_off;
+#ifdef STACK_ADDRESS_OFFSET
+			  /* On SPARC take stack pointer bias into account as
+			     well.  */
+			  off += (STACK_ADDRESS_OFFSET
+				  - FIRST_PARM_OFFSET (current_function_decl));
+#endif
+			  if (x_off >= off)
+			    /* x is at or above the current stack pointer,
+			       no need to invalidate it.  */
+			    x_base = NULL_RTX;
+			}
+		      else
+			{
+			  HOST_WIDE_INT sz;
+			  enum machine_mode mode = GET_MODE (x);
+			  if ((MEM_SIZE_KNOWN_P (x)
+			       && MEM_SIZE (x).is_constant (&sz))
+			      || (mode != BLKmode
+				  && GET_MODE_SIZE (mode).is_constant (&sz)))
+			    if (x_off < sp_off
+				&& ((HOST_WIDE_INT) ((unsigned HOST_WIDE_INT)
+						     x_off + sz) <= sp_off))
+			      /* x's end is below or at the current stack
+				 pointer in !STACK_GROWS_DOWNWARD target,
+				 no need to invalidate it.  */
+			      x_base = NULL_RTX;
+			 }
+		    }
+		}
+	      if (x_base == NULL_RTX)
+		{
+		  has_mem = true;
+		  num_mems++;
+		  p = &(*p)->next;
+		  continue;
+		}
+	    }
+
 	  if (num_mems < param_max_cselib_memory_locations
 	      && ! canon_anti_dependence (x, false, mem_rtx,
 					  GET_MODE (mem_rtx), mem_addr))
@@ -3196,14 +3308,24 @@ cselib_process_insn (rtx_insn *insn)
 	 as if they were regular functions.  */
       if (RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)
 	  || !(RTL_CONST_OR_PURE_CALL_P (insn)))
-	cselib_invalidate_mem (callmem);
+	cselib_invalidate_mem (callmem[0]);
       else
-	/* For const/pure calls, invalidate any argument slots because
-	   they are owned by the callee.  */
-	for (x = CALL_INSN_FUNCTION_USAGE (insn); x; x = XEXP (x, 1))
-	  if (GET_CODE (XEXP (x, 0)) == USE
-	      && MEM_P (XEXP (XEXP (x, 0), 0)))
-	    cselib_invalidate_mem (XEXP (XEXP (x, 0), 0));
+	{
+	  /* For const/pure calls, invalidate any argument slots because
+	     they are owned by the callee.  */
+	  for (x = CALL_INSN_FUNCTION_USAGE (insn); x; x = XEXP (x, 1))
+	    if (GET_CODE (XEXP (x, 0)) == USE
+		&& MEM_P (XEXP (XEXP (x, 0), 0)))
+	      cselib_invalidate_mem (XEXP (XEXP (x, 0), 0));
+	  /* And invalidate memory below the stack (or above for
+	     !STACK_GROWS_DOWNWARD), as even const/pure call can invalidate
+	     that.  Do this only if !ACCUMULATE_OUTGOING_ARGS or if
+	     cfun->calls_alloca, otherwise the stack pointer shouldn't be
+	     changing in the middle of the function and nothing should be
+	     stored below the stack pointer.  */
+	  if (!ACCUMULATE_OUTGOING_ARGS || cfun->calls_alloca)
+	    cselib_invalidate_mem (callmem[1]);
+	}
     }
 
   cselib_record_sets (insn);
@@ -3256,8 +3378,31 @@ cselib_init (int record_what)
 
   /* (mem:BLK (scratch)) is a special mechanism to conflict with everything,
      see canon_true_dependence.  This is only created once.  */
-  if (! callmem)
-    callmem = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode));
+  if (! callmem[0])
+    callmem[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode));
+  /* Similarly create a MEM representing roughly everything below
+     the stack for STACK_GROWS_DOWNWARD targets or everything above
+     it otherwise.  Do this only when !ACCUMULATE_OUTGOING_ARGS or
+     if cfun->calls_alloca, otherwise the stack pointer shouldn't be
+     changing in the middle of the function and nothing should be stored
+     below the stack pointer.  */
+  if (!callmem[1] && (!ACCUMULATE_OUTGOING_ARGS || cfun->calls_alloca))
+    {
+      if (STACK_GROWS_DOWNWARD)
+	{
+	  unsigned HOST_WIDE_INT off = -(GET_MODE_MASK (Pmode) >> 1);
+#ifdef STACK_ADDRESS_OFFSET
+	  /* On SPARC take stack pointer bias into account as well.  */
+	  off += (STACK_ADDRESS_OFFSET
+		  - FIRST_PARM_OFFSET (current_function_decl));
+#endif
+	  callmem[1] = plus_constant (Pmode, stack_pointer_rtx, off);
+	}
+      else
+	callmem[1] = stack_pointer_rtx;
+      callmem[1] = gen_rtx_MEM (BLKmode, callmem[1]);
+      set_mem_size (callmem[1], GET_MODE_MASK (Pmode) >> 1);
+    }
 
   cselib_nregs = max_reg_num ();
 
diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog
index fb8feef420faa1f67ebb4f666fd6b36eeb2eba3f..56bfb849cf6101c156e07fcbfa557b4ef0f915e4 100644
--- a/gcc/d/ChangeLog
+++ b/gcc/d/ChangeLog
@@ -1,3 +1,10 @@
+2025-01-29  Arsen Arsenović  <arsen@aarsen.me>
+	    Jakub Jelinek  <jakub@redhat.com>
+
+	PR d/118477
+	* Make-lang.in (DCOMPILE, DPOSTCOMPILE): Use $(basename $(@F))
+	instead of $(*F).
+
 2025-01-22  Arsen Arsenović  <arsen@aarsen.me>
 
 	* lang-specs.h: Replace %{nostdinc*} with %{nostdinc}.
diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
index f28761e4b37012e7b6292db11c7ff8962f7d61c4..a29531c8b7f685e3530ac52b35854275b4edd813 100644
--- a/gcc/d/Make-lang.in
+++ b/gcc/d/Make-lang.in
@@ -65,8 +65,8 @@ ALL_DFLAGS = $(DFLAGS-$@) $(GDCFLAGS) -fversion=IN_GCC $(CHECKING_DFLAGS) \
 	$(WARN_DFLAGS)
 
 DCOMPILE.base = $(GDC) -c $(ALL_DFLAGS) -o $@
-DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo
-DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po
+DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(basename $(@F)).TPo
+DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(basename $(@F)).TPo $(@D)/$(DEPDIR)/$(basename $(@F)).Po
 DLINKER = $(GDC) $(NO_PIE_FLAG) -lstdc++
 
 # Like LINKER, but use a mutex for serializing front end links.
diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc
index 168a52fddf5b98ba157bb295f44830f1d28f0768..554992bddba1c7670bf4db49966e492315a2aa12 100644
--- a/gcc/diagnostic-format-sarif.cc
+++ b/gcc/diagnostic-format-sarif.cc
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #define INCLUDE_LIST
 #define INCLUDE_MAP
+#define INCLUDE_STRING
 #define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
@@ -2821,6 +2822,38 @@ sarif_builder::maybe_make_kinds_array (diagnostic_event::meaning m) const
   return kinds_arr;
 }
 
+/* In "3.11.5 Messages with placeholders":
+   "Within both plain text and formatted message strings, the characters
+   "{" and "}" SHALL be represented by the character sequences
+   "{{" and "}}" respectively."  */
+
+static std::string
+escape_braces (const char *text)
+{
+  std::string result;
+  while (char ch = *text++)
+    switch (ch)
+      {
+      case '{':
+      case '}':
+	result += ch;
+	/* Fall through.  */
+      default:
+	result += ch;
+	break;
+      }
+  return result;
+}
+
+static void
+set_string_property_escaping_braces (json::object &obj,
+				     const char *property_name,
+				     const char *value)
+{
+  std::string escaped (escape_braces (value));
+  obj.set_string (property_name, escaped.c_str ());
+}
+
 /* Make a "message" object (SARIF v2.1.0 section 3.11) for MSG.  */
 
 std::unique_ptr<sarif_message>
@@ -2829,7 +2862,8 @@ sarif_builder::make_message_object (const char *msg) const
   auto message_obj = ::make_unique<sarif_message> ();
 
   /* "text" property (SARIF v2.1.0 section 3.11.8).  */
-  message_obj->set_string ("text", msg);
+  set_string_property_escaping_braces (*message_obj,
+				       "text", msg);
 
   return message_obj;
 }
@@ -2844,7 +2878,8 @@ sarif_builder::make_message_object_for_diagram (const diagnostic_diagram &diagra
   auto message_obj = ::make_unique<sarif_message> ();
 
   /* "text" property (SARIF v2.1.0 section 3.11.8).  */
-  message_obj->set_string ("text", diagram.get_alt_text ());
+  set_string_property_escaping_braces (*message_obj,
+				       "text", diagram.get_alt_text ());
 
   pretty_printer *const pp = m_printer;
   char *saved_prefix = pp_take_prefix (pp);
@@ -2857,7 +2892,8 @@ sarif_builder::make_message_object_for_diagram (const diagnostic_diagram &diagra
   pp_set_prefix (pp, saved_prefix);
 
   /* "markdown" property (SARIF v2.1.0 section 3.11.9).  */
-  message_obj->set_string ("markdown", pp_formatted_text (pp));
+  set_string_property_escaping_braces (*message_obj,
+				       "markdown", pp_formatted_text (pp));
 
   pp_clear_output_area (pp);
 
@@ -2873,7 +2909,8 @@ sarif_builder::make_multiformat_message_string (const char *msg) const
   auto message_obj = ::make_unique<sarif_multiformat_message_string> ();
 
   /* "text" property (SARIF v2.1.0 section 3.12.3).  */
-  message_obj->set_string ("text", msg);
+  set_string_property_escaping_braces (*message_obj,
+				       "text", msg);
 
   return message_obj;
 }
@@ -4341,6 +4378,28 @@ test_message_with_embedded_link (enum sarif_version version)
   }
 }
 
+/* Verify that braces in messages get escaped, as per
+   3.11.5 ("Messages with placeholders").  */
+
+static void
+test_message_with_braces (enum sarif_version version)
+{
+  auto_fix_quotes fix_quotes;
+  {
+    test_sarif_diagnostic_context dc ("test.c", version);
+    rich_location richloc (line_table, UNKNOWN_LOCATION);
+    dc.report (DK_ERROR, richloc, nullptr, 0,
+	       "open brace: %qs close brace: %qs",
+	       "{", "}");
+    std::unique_ptr<sarif_log> log = dc.flush_to_object ();
+
+    auto message_obj = get_message_from_log (log.get ());
+    ASSERT_JSON_STRING_PROPERTY_EQ
+      (message_obj, "text",
+       "open brace: `{{' close brace: `}}'");
+  }
+}
+
 static void
 test_buffering (enum sarif_version version)
 {
@@ -4457,6 +4516,7 @@ diagnostic_format_sarif_cc_tests ()
 
       test_simple_log (version);
       test_message_with_embedded_link (version);
+      test_message_with_braces (version);
       test_buffering (version);
     }
 
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 2764597a479b3412d795a0ea555decf4ecd75009..d79e97d9a030b704c9f9a85fe2290ed2f4c7aa86 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -17369,14 +17369,6 @@ might increase delay time. @var{ticks} must be a compile-time
 integer constant; delays with a variable number of cycles are not supported.
 @enddefbuiltin
 
-@defbuiltin{int8_t __builtin_avr_flash_segment (const __memx void*)}
-This built-in takes a byte address to the 24-bit
-@ref{AVR Named Address Spaces,address space} @code{__memx} and returns
-the number of the flash segment (the 64 KiB chunk) where the address
-points to.  Counting starts at @code{0}.
-If the address does not point to flash memory, return @code{-1}.
-@enddefbuiltin
-
 @defbuiltin{uint8_t __builtin_avr_insert_bits (uint32_t @var{map}, uint8_t @var{bits}, uint8_t @var{val})}
 Insert bits from @var{bits} into @var{val} and return the resulting
 value. The nibbles of @var{map} determine how the insertion is
@@ -17445,6 +17437,26 @@ Insert @var{count} @code{NOP} instructions.
 The number of instructions must be a compile-time integer constant.
 @enddefbuiltin
 
+@b{All of the following built-in functions are only available for GNU-C}
+
+@defbuiltin{int8_t __builtin_avr_flash_segment (const __memx void*)}
+This built-in takes a byte address to the 24-bit
+@ref{AVR Named Address Spaces,named address space} @code{__memx} and returns
+the number of the flash segment (the 64 KiB chunk) where the address
+points to.  Counting starts at @code{0}.
+If the address does not point to flash memory, return @code{-1}.
+@enddefbuiltin
+
+@defbuiltin{size_t __builtin_avr_strlen_flash (const __flash char*)}
+@defbuiltinx{size_t __builtin_avr_strlen_flashx (const __flashx char*)}
+@defbuiltinx{size_t __builtin_avr_strlen_memx (const __memx char*)}
+These built-ins return the length of a string located in
+named address-space @code{__flash}, @code{__flashx} or @code{__memx},
+respectively.  They are used to support functions like @code{strlen_F} from
+@w{@uref{https://avrdudes.github.io/avr-libc/avr-libc-user-manual/,AVR-LibC}}'s
+header @code{avr/flash.h}.
+@enddefbuiltin
+
 @noindent
 There are many more AVR-specific built-in functions that are used to
 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi
index 5af8b228831f84151f94a4f3a2317cb29b475ef6..8baee24f14e0248b61934d9d5d07ffc75cacaa39 100644
--- a/gcc/doc/gm2.texi
+++ b/gcc/doc/gm2.texi
@@ -234,6 +234,7 @@ such as the AVR and the ARM).
 * Extensions::            GNU Modula-2 language extensions.
 * Type compatibility::    Data type compatibility.
 * Unbounded by reference::Explanation of a language optimization.
+* Exception handling::    Example of exception handling.
 * Building a shared library:: How to build a shared library.
 * Interface for Python::  How to produce swig interface files.
 * Producing a Python module::  How to produce a Python module.
@@ -502,7 +503,8 @@ the previous forms could be:
 
 @item -fm2-file-offset-bits=
 force the type @code{SYSTEM.COFF_T} to be built using the specified
-number of bits.  If this option is not used then default is 64 bits.
+number of bits.  If this option is not used then default is
+@code{CSSIZE_T} bits.
 
 @item -fm2-g
 improve the debugging experience for new programmers at the expense
@@ -1836,7 +1838,7 @@ are all exported from the @code{SYSTEM} module.
 @xref{The PIM system module}.
 @xref{The ISO system module}.
 
-@node Type compatibility, Unbounded by reference, Extensions, Using
+@node Type compatibility, Exception handling, Extensions, Using
 @section Type compatibility
 
 This section discuss the issues surrounding assignment, expression
@@ -1984,7 +1986,148 @@ The types @code{BYTE}, @code{LOC}, @code{WORD} and @code{WORD}n
 derivatives are assignment and parameter compatible with any data type
 of the same size.
 
-@node Unbounded by reference, Building a shared library, Type compatibility, Using
+@node Exception handling, Unbounded by reference, Type compatibility, Using
+@section Exception handling
+
+This section gives an example of exception handling and briefly
+describes its runtime behavior.  The module below is written in the
+ISO dialect of Modula-2 and can be compiled with the command line:
+
+@example
+$ gm2 -g -fiso -fsoft-check-all lazyunique.mod
+@end example
+
+The option @samp{-fsoft-check-all} generates checks for @code{NIL}
+pointer access violation.  In turn this will call the exception handler.
+
+@example
+@group
+MODULE lazyunique ;  (*!m2iso+gm2*)
+
+FROM Storage IMPORT ALLOCATE ;
+FROM libc IMPORT printf, exit ;
+
+TYPE
+   List = POINTER TO RECORD
+                        next : List ;
+                        value: INTEGER ;
+                     END ;
+
+   Array = ARRAY [0..3] OF INTEGER ;
+
+CONST
+   Unsorted = Array @{0, 2, 1, 1@} ;
+
+VAR
+   head: List ;
+@end group   
+@end example
+
+@example
+@group
+PROCEDURE Display ;
+VAR
+   p: List ;
+BEGIN
+   p := head^.next ;
+   printf ("\nunique data\n");
+   printf ("===========\n");   
+   WHILE p # NIL DO
+      printf ("%d\n", p^.value);
+      p := p^.next
+   END
+END Display ;
+@end group   
+@end example
+
+@example
+@group
+PROCEDURE Add (VAR p: List; val: INTEGER) ;
+BEGIN
+   NEW (p) ;
+   WITH p^ DO
+      value := val ;
+      next := NIL
+   END
+END Add ;
+@end group   
+@end example
+
+@example
+@group
+PROCEDURE Unique (val: INTEGER) ;
+VAR
+   p: List ;
+BEGIN
+   printf ("new value %d\n", val);
+   p := head ;
+   (* The following line may cause an exception accessing next or
+      value.  *)
+   WHILE p^.next^.value # val DO
+      p := p^.next
+   END
+EXCEPT
+   (* Now fixup.  Determine the source of the exception and retry.  *)
+   IF head = NIL
+   THEN
+      printf ("list was empty, add sentinal\n");
+      Add (head, -1) ;
+      RETRY  (* Jump back to the begin statement.  *)      
+   ELSIF p^.next = NIL
+   THEN
+      printf ("growing the list\n");
+      Add (p^.next, val) ;
+      RETRY  (* Jump back to the begin statement.  *)
+   ELSE
+      printf ("should never reach here!\n");   
+   END
+END Unique ;
+@end group   
+@end example
+
+@example
+@group
+PROCEDURE unique ;
+VAR
+   i: CARDINAL ;
+BEGIN
+   FOR i := 0 TO HIGH (Unsorted) DO
+      Unique (Unsorted[i])
+   END ;
+   Display
+END unique ;
+
+BEGIN
+   head := NIL ;
+   unique
+END lazyunique.
+@end group   
+@end example
+
+@example
+@group
+new value 0
+list was empty, add sentinal
+new value 0
+growing the list
+new value 0
+new value 2
+growing the list
+new value 2
+new value 1
+growing the list
+new value 1
+new value 1
+
+unique data
+===========
+0
+2
+1
+@end group   
+@end example
+
+@node Unbounded by reference, Building a shared library, Exception handling, Using
 @section Unbounded by reference
 
 This section documents a GNU Modula-2 compiler switch which implements
@@ -2588,9 +2731,8 @@ END Example ;
 Both examples generate exactly the same code.  It is worth noting that
 the specifier ``rm'' indicates that the operand can be either a
 register or memory.  Of course you must choose an instruction which
-can take either, but this allows the compiler to take make more
-efficient choices depending upon the optimization level given to the
-compiler.
+can take either, but this allows the compiler to make more
+efficient choices depending upon the optimization level.
 
 @node Alignment, Packed, Assembly language, Using
 @section Data type alignment
@@ -2895,10 +3037,13 @@ base module).  PIM-2 defined @code{SIZE} in the @code{SYSTEM} module
 GNU Modula-2 allows users to specify the dialect of Modula-2 by using
 the @code{-fiso} and @code{-fpim2} command line switches.
 
-The data types @code{CSIZE_T} and @code{CSSIZE_T} are also exported from
-the @code{SYSTEM} module.  The type @code{CSIZE_T} is unsigned and is
-mapped onto the target C data type @code{size_t} whereas the type
-@code{CSSIZE_T} is mapped onto the signed C data type @code{ssize_t}.
+The data types @code{CSIZE_T}, @code{CSSIZE_T} and @code{COFF_T} are
+also exported from the @code{SYSTEM} module.  The type @code{CSIZE_T}
+is unsigned and is mapped onto the target C data type @code{size_t}
+whereas the type @code{CSSIZE_T} is mapped onto the signed C data type
+@code{ssize_t}.  The default size for the signed type @code{COFF_T} is
+the same as @code{CSSIZE_T} and this can be overridden by the
+@code{-fm2-file-offset-bits=} command line option.
 
 It is anticipated that these should only be used to provide cross
 platform definition modules for C libraries.
@@ -2912,10 +3057,13 @@ depend upon the target architecture.
 
 @include m2/SYSTEM-iso.texi
 
-The data types @code{CSIZE_T} and @code{CSSIZE_T} are also exported from
-the @code{SYSTEM} module.  The type @code{CSIZE_T} is unsigned and is
-mapped onto the target C data type @code{size_t} whereas the type
-@code{CSSIZE_T} is mapped onto the signed C data type @code{ssize_t}.
+The data types @code{CSIZE_T}, @code{CSSIZE_T} and @code{COFF_T} are
+also exported from the @code{SYSTEM} module.  The type @code{CSIZE_T}
+is unsigned and is mapped onto the target C data type @code{size_t}
+whereas the type @code{CSSIZE_T} is mapped onto the signed C data type
+@code{ssize_t}.  The default size for the signed type @code{COFF_T} is
+the same as @code{CSSIZE_T} and this can be overridden by the
+@code{-fm2-file-offset-bits=} command line option.
 
 It is anticipated that these should only be used to provide cross
 platform definition modules for C libraries.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 2f5d60baadbee3e41ba96e48cf3f8caa14e07f38..9050ffa59dd0c2ae6852e2528a6ff5cd6330a622 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -13010,6 +13010,16 @@ having large chains of nested wrapper functions.
 
 Enabled by default.
 
+@item -ffile-cache-files=
+Max number of files in the file cache.
+The file cache is used to print source lines in diagnostics and do some
+source checks like @option{-Wmisleading-indentation}.
+
+@item -ffile-cache-files=
+Max number of lines to index into file cache. When 0 this is automatically sized.
+The file cache is used to print source lines in diagnostics and do some
+source checks like @option{-Wmisleading-indentation}.
+
 @opindex fipa-sra
 @item -fipa-sra
 Perform interprocedural scalar replacement of aggregates, removal of
@@ -21669,9 +21679,10 @@ and the features that they enable by default:
 @item @samp{armv8.9-a} @tab Armv8.9-a @tab @samp{armv8.8-a}
 @item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
 @item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
-@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}
+@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+wfxt}, @samp{+xs}
 @item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
 @item @samp{armv9.4-a} @tab Armv9.4-A @tab @samp{armv9.3-a}
+@item @samp{armv9.5-a} @tab Armv9.4-A @tab @samp{armv9.4-a}, @samp{cpa}, @samp{+faminmax}, @samp{+lut}
 @item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
 @end multitable
 
@@ -22084,6 +22095,8 @@ extension in streaming mode.
 Enable the Floating Point Absolute Maximum/Minimum extension.
 @item lut
 Enable the Lookup Table extension.
+@item cpa
+Enable the Checked Pointer Arithmetic instructions.
 @item sve-b16b16
 Enable the SVE non-widening brain floating-point (@code{bf16}) extension.
 This only has an effect when @code{sve2} or @code{sme2} are also enabled.
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 2ec7cce5833868e09b29986635459e0984351796..accbf73d82117ad98322a416ce930d92f5ccf752 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -13678,8 +13678,7 @@ modified_type_die (tree type, int cv_quals, bool reverse,
   struct array_descr_info info;
   /* Only these cv-qualifiers are currently handled.  */
   const int cv_qual_mask = (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE
-			    | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC |
-			    ENCODE_QUAL_ADDR_SPACE(~0U));
+			    | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC);
   /* DW_AT_endianity is specified only for base types in the standard.  */
   const bool reverse_type
     = need_endianity_attribute_p (reverse)
diff --git a/gcc/expr.cc b/gcc/expr.cc
index a310b2d913154efed7eb90f3c57fdbedea118a18..f684e26cef78089ead787976ab8a960f00f29711 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -11796,15 +11796,36 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
 		&& known_eq (GET_MODE_BITSIZE (DECL_MODE (base)), type_size))
 	      return expand_expr (build1 (VIEW_CONVERT_EXPR, type, base),
 				  target, tmode, modifier);
-	    if (TYPE_MODE (type) == BLKmode)
+	    unsigned align;
+	    if (TYPE_MODE (type) == BLKmode || maybe_lt (offset, 0))
 	      {
 		temp = assign_stack_temp (DECL_MODE (base),
 					  GET_MODE_SIZE (DECL_MODE (base)));
 		store_expr (base, temp, 0, false, false);
-		temp = adjust_address (temp, BLKmode, offset);
-		set_mem_size (temp, int_size_in_bytes (type));
+		temp = adjust_address (temp, TYPE_MODE (type), offset);
+		if (TYPE_MODE (type) == BLKmode)
+		  set_mem_size (temp, int_size_in_bytes (type));
+		/* When the original ref was misaligned so will be the
+		   access to the stack temporary.  Not all targets handle
+		   this correctly, some will ICE in sanity checking.
+		   Handle this by doing bitfield extraction when necessary.  */
+		else if ((align = get_object_alignment (exp))
+			 < GET_MODE_ALIGNMENT (TYPE_MODE (type)))
+		  temp
+		    = expand_misaligned_mem_ref (temp, TYPE_MODE (type),
+						 unsignedp, align,
+						 modifier == EXPAND_STACK_PARM
+						 ? NULL_RTX : target, NULL);
 		return temp;
 	      }
+	    /* When the access is fully outside of the underlying object
+	       expand the offset as zero.  This avoids out-of-bound
+	       BIT_FIELD_REFs and generates smaller code for these cases
+	       with UB.  */
+	    type_size = tree_to_poly_uint64 (TYPE_SIZE_UNIT (type));
+	    if (!ranges_maybe_overlap_p (offset, type_size, 0,
+					 GET_MODE_SIZE (DECL_MODE (base))))
+	      offset = 0;
 	    exp = build3 (BIT_FIELD_REF, type, base, TYPE_SIZE (type),
 			  bitsize_int (offset * BITS_PER_UNIT));
 	    REF_REVERSE_STORAGE_ORDER (exp) = reverse;
@@ -12147,7 +12168,13 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
 	   and need be, put it there.  */
 	else if (CONSTANT_P (op0) || (!MEM_P (op0) && must_force_mem))
 	  {
-	    memloc = assign_temp (TREE_TYPE (tem), 1, 1);
+	    poly_int64 size;
+	    if (!poly_int_tree_p (TYPE_SIZE_UNIT (TREE_TYPE (tem)), &size))
+	      size = max_int_size_in_bytes (TREE_TYPE (tem));
+	    memloc = assign_stack_local (TYPE_MODE (TREE_TYPE (tem)), size,
+					 TREE_CODE (tem) == SSA_NAME
+					 ? TYPE_ALIGN (TREE_TYPE (tem))
+					 : get_object_alignment (tem));
 	    emit_move_insn (memloc, op0);
 	    op0 = memloc;
 	    clear_mem_expr = true;
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index d7f660356f8bfb825ff08d5754eba98bc100be2b..f91118be718c5d9266a4ab3d40b5e50cc614981c 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,177 @@
+2025-02-04  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+	* arith.cc (arith_power): Handle modular arithmetic for
+	BT_UNSIGNED.
+	(eval_intrinsic):  Error for unsigned exponentiation with
+	-pedantic.
+	* expr.cc (gfc_type_convert_binary): Use type of first
+	argument for unsigned exponentiation.
+	* gfortran.texi: Mention arithmetic exponentiation.
+	* resolve.cc (resolve_operator): Allow unsigned exponentiation.
+	* trans-decl.cc (gfc_build_intrinsic_function_decls): Build
+	declarations for unsigned exponentiation.
+	* trans-expr.cc (gfc_conv_cst_uint_power): New function.
+	(gfc_conv_power_op): Call it.  Handle unsigned exponentiation.
+	* trans.h (gfor_fndecl_unsigned_pow_list):  Add declaration.
+
+2025-02-03  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/93289
+	* decl.cc (gfc_set_constant_character_len): Downgrade different
+	string lengths in character array constructor to legacy extension.
+
+2025-01-31  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108454
+	* resolve.cc (resolve_common_blocks): Initialize variable.
+	(resolve_symbol): If a symbol is already registered with a COMMON
+	block, do not search for an interface with the same name.
+
+2025-01-31  Paul-Antoine Arras  <parras@baylibre.com>
+
+	PR fortran/118714
+	* parse.cc (parse_omp_dispatch): Add missing pop_state.
+
+2025-01-30  Sandra Loosemore  <sloosemore@baylibre.com>
+	    Kwok Cheung Yeung  <kcy@codesourcery.com>
+	    Sandra Loosemore  <sandra@codesourcery.com>
+	    Tobias Burnus  <tobias@codesourcery.com>
+	    Paul-Antoine Arras  <pa@codesourcery.com>
+
+	PR middle-end/112779
+	PR middle-end/113904
+	* decl.cc (gfc_match_end): Handle COMP_OMP_BEGIN_METADIRECTIVE and
+	COMP_OMP_METADIRECTIVE.
+	* dump-parse-tree.cc (show_omp_node): Handle EXEC_OMP_METADIRECTIVE.
+	(show_code_node): Likewise.
+	* gfortran.h (enum gfc_statement): Add ST_OMP_METADIRECTIVE,
+	ST_OMP_BEGIN_METADIRECTIVE, and ST_OMP_END_METADIRECTIVE.
+	(struct gfc_omp_clauses): Rename target_first_st_is_teams to
+	target_first_st_is_teams_or_meta.
+	(struct gfc_omp_variant): New.
+	(gfc_get_omp_variant): New.
+	(struct gfc_st_label): Add omp_region field.
+	(enum gfc_exec_op): Add EXEC_OMP_METADIRECTIVE.
+	(struct gfc_code): Add omp_variants fields.
+	(gfc_free_omp_variants): Declare.
+	(match_omp_directive): Declare.
+	(is_omp_declarative_stmt): Declare.
+	* io.cc (format_asterisk): Adjust initializer.
+	* match.h (gfc_match_omp_begin_metadirective): Declare.
+	(gfc_match_omp_metadirective): Declare.
+	* openmp.cc (gfc_omp_directives): Uncomment metadirective.
+	(gfc_match_omp_eos): Adjust to match context selectors.
+	(gfc_free_omp_variants): New.
+	(gfc_match_omp_clauses): Remove context_selector parameter and adjust
+	to use gfc_match_omp_eos instead.
+	(match_omp): Adjust call to gfc_match_omp_clauses.
+	(gfc_match_omp_context_selector): Add metadirective_p parameter and
+	adjust error-checking.  Adjust matching of simd clauses.
+	(gfc_match_omp_context_selector_specification): Adjust parameters
+	so it can be used for metadirective as well as declare variant.
+	(match_omp_metadirective): New.
+	(gfc_match_omp_begin_metadirective): New.
+	(gfc_match_omp_metadirective): New.
+	(resolve_omp_metadirective): New.
+	(resolve_omp_target): Handle metadirectives.
+	(gfc_resolve_omp_directive): Handle EXEC_OMP_METADIRECTIVE.
+	* parse.cc (gfc_matching_omp_context_selector): New.
+	(gfc_in_omp_metadirective_body): New.
+	(gfc_omp_region_count): New.
+	(decode_omp_directive): Handle ST_OMP_BEGIN_METADIRECTIVE and
+	ST_OMP_METADIRECTIVE.
+	(match_omp_directive): New.
+	(case_omp_structured_block): Define.
+	(case_omp_do): Define.
+	(gfc_ascii_statement): Handle ST_OMP_BEGIN_METADIRECTIVE,
+	ST_OMP_END_METADIRECTIVE, and ST_OMP_METADIRECTIVE.
+	(accept_statement):  Handle ST_OMP_METADIRECTIVE and
+	ST_OMP_BEGIN_METADIRECTIVE.
+	(gfc_omp_end_stmt): New, split from...
+	(parse_omp_do): ...here, and...
+	(parse_omp_structured_block): ...here.  Handle metadirectives,
+	plus "allocate", "atomic", and "dispatch" which were missing.
+	(parse_omp_oacc_atomic): Handle "end metadirective".
+	(parse_openmp_allocate_block): Likewise.
+	(parse_omp_dispatch): Likewise.
+	(parse_omp_metadirective_body): New.
+	(parse_executable): Handle metadirective.  Use new case macros
+	defined above.
+	(gfc_parse_file): Initialize metadirective state.
+	(is_omp_declarative_stmt): New.
+	* parse.h (enum gfc_compile_state): Add COMP_OMP_METADIRECTIVE
+	and COMP_OMP_BEGIN_METADIRECTIVE.
+	(gfc_omp_end_stmt): Declare.
+	(gfc_matching_omp_context_selector): Declare.
+	(gfc_in_omp_metadirective_body): Declare.
+	(gfc_omp_metadirective_region_count): Declare.
+	* resolve.cc (gfc_resolve_code): Handle EXEC_OMP_METADIRECTIVE.
+	* st.cc (gfc_free_statement): Likewise.
+	* symbol.cc (compare_st_labels): Handle labels within a metadirective
+	body.
+	(gfc_get_st_label): Likewise.
+	* trans-decl.cc (gfc_get_label_decl): Encode the metadirective region
+	in the label_name.
+	* trans-openmp.cc (gfc_trans_omp_directive): Handle
+	EXEC_OMP_METADIRECTIVE.
+	(gfc_trans_omp_set_selector): New, split/adapted from code....
+	(gfc_trans_omp_declare_variant): ...here.
+	(gfc_trans_omp_metadirective): New.
+	* trans-stmt.h 	(gfc_trans_omp_metadirective): Declare.
+	* trans.cc (trans_code): Handle EXEC_OMP_METADIRECTIVE.
+
+2025-01-30  Tobias Burnus  <tburnus@baylibre.com>
+
+	* gfortran.h (gfc_omp_declare_variant): Add append_args_list.
+	* openmp.cc (gfc_parser_omp_clause_init_modifiers): New;
+	splitt of from ...
+	(gfc_match_omp_init): ... here; call it.
+	(gfc_match_omp_declare_variant): Update to handle append_args
+	clause; some syntax handling fixes.
+	* trans-openmp.cc (gfc_trans_omp_declare_variant): Handle
+	append_args clause; add some diagnostic.
+
+2025-01-29  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/118683
+	* trans-expr.cc (gfc_conv_procedure_call): The bounds update for
+	passing to assumed-rank dummies shall also handle component
+	references besides inquiry references.
+
+2025-01-27  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/110993
+	* frontend-passes.cc (check_externals_procedure): Do not compare
+	interfaces of a non-bind(C) procedure against a bind(C) global one.
+	(check_against_globals): Use local name from rename-on-use in the
+	search for interfaces.
+
+2025-01-27  Paul Thomas  <pault@gcc.gnu.org>
+
+	PR fortran/118640
+	* resolve.cc (generate_component_assignments): Make sure that
+	the rhs temporary does not pick up the optional attribute from
+	the lhs.
+
+2025-01-26  Tobias Burnus  <tburnus@baylibre.com>
+
+	* openmp.cc (gfc_omp_directives): Uncomment unroll and tile lines
+	as the directives are by now implemented.
+
+2025-01-26  Sandra Loosemore  <sloosemore@baylibre.com>
+
+	* openmp.cc (resolve_omp_atomic): Fix typo in error message.
+
+2025-01-25  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/58857
+	* class.cc (gfc_find_derived_vtab): Declare some frontend generated
+	variables and procedures (_vtab, _copy, _deallocate) as artificial.
+	(find_intrinsic_vtab): Likewise.
+	* trans-decl.cc (check_block_data_decls): New helper function.
+	(gfc_generate_block_data): Use it to emit warnings for variables
+	declared in a BLOCK DATA program unit but not in a COMMON block.
+
 2025-01-23  Harald Anlauf  <anlauf@gmx.de>
 
 	PR fortran/118613
diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc
index 5fc91421e48c5dd364b9d55b3d3313cf20664cbc..82a8b6fb995143eba092af3f798a1024bc12fc3a 100644
--- a/gcc/fortran/arith.cc
+++ b/gcc/fortran/arith.cc
@@ -1143,6 +1143,20 @@ arith_power (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp)
 		 op2->value.complex, GFC_MPC_RND_MODE);
       }
       break;
+    case BT_UNSIGNED:
+      {
+	int k;
+	mpz_t x;
+	gcc_assert (op1->ts.type == BT_UNSIGNED);
+	k = gfc_validate_kind (BT_UNSIGNED, op1->ts.kind, false);
+	/* Exponentiation is performed modulo x = 2**n.  */
+	mpz_init (x);
+	mpz_add_ui (x, gfc_unsigned_kinds[k].huge, 1);
+	mpz_powm (result->value.integer, op1->value.integer,
+		  op2->value.integer, x);
+	mpz_clear (x);
+      }
+      break;
     default:
       gfc_internal_error ("arith_power(): unknown type");
     }
@@ -1827,10 +1841,11 @@ eval_intrinsic (gfc_intrinsic_op op,
     gcc_fallthrough ();
     /* Numeric binary  */
     case INTRINSIC_POWER:
-      if (flag_unsigned && op == INTRINSIC_POWER)
+      if (pedantic && (op1->ts.type == BT_UNSIGNED || op2->ts.type == BT_UNSIGNED))
 	{
-	  if (op1->ts.type == BT_UNSIGNED || op2->ts.type == BT_UNSIGNED)
-	    goto runtime;
+	  gfc_error ("Unsigned exponentiation not permitted with -pedantic "
+		     "at %L", &op1->where);
+	  goto runtime;
 	}
 
       gcc_fallthrough ();
@@ -1940,7 +1955,6 @@ runtime:
   /* Create a run-time expression.  */
   result = gfc_get_operator_expr (&op1->where, op, op1, op2);
   result->ts = temp.ts;
-
   return result;
 }
 
diff --git a/gcc/fortran/class.cc b/gcc/fortran/class.cc
index 97ff54df5e1cd5c9f085708b38012354c2e6ade5..df18601e45bd5d01ee8ff5302d105d30dc59b244 100644
--- a/gcc/fortran/class.cc
+++ b/gcc/fortran/class.cc
@@ -2498,6 +2498,7 @@ gfc_find_derived_vtab (gfc_symbol *derived)
 	  vtab->attr.save = SAVE_IMPLICIT;
 	  vtab->attr.vtab = 1;
 	  vtab->attr.access = ACCESS_PUBLIC;
+	  vtab->attr.artificial = 1;
 	  gfc_set_sym_referenced (vtab);
 	  free (name);
 	  name = xasprintf ("__vtype_%s", tname);
@@ -2610,6 +2611,7 @@ gfc_find_derived_vtab (gfc_symbol *derived)
 		goto cleanup;
 	      c->attr.proc_pointer = 1;
 	      c->attr.access = ACCESS_PRIVATE;
+	      c->attr.artificial = 1;
 	      c->tb = XCNEW (gfc_typebound_proc);
 	      c->tb->ppc = 1;
 	      if (derived->attr.unlimited_polymorphic
@@ -2687,6 +2689,7 @@ gfc_find_derived_vtab (gfc_symbol *derived)
 		goto cleanup;
 	      c->attr.proc_pointer = 1;
 	      c->attr.access = ACCESS_PRIVATE;
+	      c->attr.artificial = 1;
 	      c->tb = XCNEW (gfc_typebound_proc);
 	      c->tb->ppc = 1;
 	      if (derived->attr.unlimited_polymorphic || derived->attr.abstract
@@ -2951,6 +2954,7 @@ find_intrinsic_vtab (gfc_typespec *ts)
 		goto cleanup;
 	      c->attr.proc_pointer = 1;
 	      c->attr.access = ACCESS_PRIVATE;
+	      c->attr.artificial = 1;
 	      c->tb = XCNEW (gfc_typebound_proc);
 	      c->tb->ppc = 1;
 
diff --git a/gcc/fortran/cpp.cc b/gcc/fortran/cpp.cc
index 69567995b6a886bfa2834c3c0e3f4e526588811a..1b7042056460269e03557e7b22d0faf6682b3896 100644
--- a/gcc/fortran/cpp.cc
+++ b/gcc/fortran/cpp.cc
@@ -96,6 +96,8 @@ struct gfc_cpp_option_data
   int deps_skip_system;                 /* -MM */
   const char *deps_filename;            /* -M[M]D */
   const char *deps_filename_user;       /* -MF <arg> */
+  const char *deps_target_filename;     /* -MT / -MQ <arg> */
+  bool quote_deps_target_filename;      /* -MQ */
   int deps_missing_are_generated;       /* -MG */
   int deps_phony;                       /* -MP */
   int warn_date_time;                   /* -Wdate-time */
@@ -287,6 +289,8 @@ gfc_cpp_init_options (unsigned int decoded_options_count,
   gfc_cpp_option.deps_missing_are_generated = 0;
   gfc_cpp_option.deps_filename = NULL;
   gfc_cpp_option.deps_filename_user = NULL;
+  gfc_cpp_option.deps_target_filename = NULL;
+  gfc_cpp_option.quote_deps_target_filename = false;
 
   gfc_cpp_option.multilib = NULL;
   gfc_cpp_option.prefix = NULL;
@@ -439,9 +443,8 @@ gfc_cpp_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED
 
     case OPT_MQ:
     case OPT_MT:
-      gfc_cpp_option.deferred_opt[gfc_cpp_option.deferred_opt_count].code = code;
-      gfc_cpp_option.deferred_opt[gfc_cpp_option.deferred_opt_count].arg = arg;
-      gfc_cpp_option.deferred_opt_count++;
+      gfc_cpp_option.quote_deps_target_filename = (code == OPT_MQ);
+      gfc_cpp_option.deps_target_filename = arg;
       break;
 
     case OPT_P:
@@ -593,6 +596,12 @@ gfc_cpp_init_0 (void)
     }
 
   gcc_assert(cpp_in);
+
+  if (gfc_cpp_option.deps_target_filename)
+    if (mkdeps *deps = cpp_get_deps (cpp_in))
+      deps_add_target (deps, gfc_cpp_option.deps_target_filename,
+		       gfc_cpp_option.quote_deps_target_filename);
+
   if (!cpp_read_main_file (cpp_in, gfc_source_file))
     errorcount++;
 }
@@ -635,9 +644,6 @@ gfc_cpp_init (void)
 	  else
 	    cpp_assert (cpp_in, opt->arg);
 	}
-      else if (opt->code == OPT_MT || opt->code == OPT_MQ)
-	if (mkdeps *deps = cpp_get_deps (cpp_in))
-	  deps_add_target (deps, opt->arg, opt->code == OPT_MQ);
     }
 
   /* Pre-defined macros for non-required INTEGER kind types.  */
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 0c597607bd8b6daec6e2279f093c954ba46546b2..5a46658651aa9a617fc11993b905191f16e9b773 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -1889,12 +1889,20 @@ gfc_set_constant_character_len (gfc_charlen_t len, gfc_expr *expr,
 
       /* Apply the standard by 'hand' otherwise it gets cleared for
 	 initializers.  */
-      if (check_len != -1 && slen != check_len
-          && !(gfc_option.allow_std & GFC_STD_GNU))
-	gfc_error_now ("The CHARACTER elements of the array constructor "
-		       "at %L must have the same length (%ld/%ld)",
-		       &expr->where, (long) slen,
-		       (long) check_len);
+      if (check_len != -1 && slen != check_len)
+	{
+	  if (!(gfc_option.allow_std & GFC_STD_GNU))
+	    gfc_error_now ("The CHARACTER elements of the array constructor "
+			   "at %L must have the same length (%ld/%ld)",
+			   &expr->where, (long) slen,
+			   (long) check_len);
+	  else
+	    gfc_notify_std (GFC_STD_LEGACY,
+			    "The CHARACTER elements of the array constructor "
+			    "at %L must have the same length (%ld/%ld)",
+			    &expr->where, (long) slen,
+			    (long) check_len);
+	}
 
       s[len] = '\0';
       free (expr->value.character.string);
@@ -8457,6 +8465,7 @@ gfc_match_end (gfc_statement *st)
 
     case COMP_CONTAINS:
     case COMP_DERIVED_CONTAINS:
+    case COMP_OMP_BEGIN_METADIRECTIVE:
       state = gfc_state_stack->previous->state;
       block_name = gfc_state_stack->previous->sym == NULL
 		 ? NULL : gfc_state_stack->previous->sym->name;
@@ -8464,6 +8473,28 @@ gfc_match_end (gfc_statement *st)
 		&& gfc_state_stack->previous->sym->abr_modproc_decl;
       break;
 
+    case COMP_OMP_METADIRECTIVE:
+      {
+	/* Metadirectives can be nested, so we need to drill down to the
+	   first state that is not COMP_OMP_METADIRECTIVE.  */
+	gfc_state_data *state_data = gfc_state_stack;
+
+	do
+	  {
+	    state_data = state_data->previous;
+	    state = state_data->state;
+	    block_name = (state_data->sym == NULL
+			  ? NULL : state_data->sym->name);
+	    abbreviated_modproc_decl = (state_data->sym
+					&& state_data->sym->abr_modproc_decl);
+	  }
+	while (state == COMP_OMP_METADIRECTIVE);
+
+	if (block_name && startswith (block_name, "block@"))
+	  block_name = NULL;
+      }
+      break;
+
     default:
       break;
     }
@@ -8609,6 +8640,12 @@ gfc_match_end (gfc_statement *st)
       gfc_free_enum_history ();
       break;
 
+    case COMP_OMP_BEGIN_METADIRECTIVE:
+      *st = ST_OMP_END_METADIRECTIVE;
+      target = " metadirective";
+      eos_ok = 0;
+      break;
+
     default:
       gfc_error ("Unexpected END statement at %C");
       goto cleanup;
diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc
index 0ae135058767c005262e041151c2144dbb35d7e2..adc07da133e54f54b03f3be3db8d245bd69ca5f4 100644
--- a/gcc/fortran/dump-parse-tree.cc
+++ b/gcc/fortran/dump-parse-tree.cc
@@ -2377,6 +2377,7 @@ show_omp_node (int level, gfc_code *c)
     case EXEC_OMP_MASTER: name = "MASTER"; break;
     case EXEC_OMP_MASTER_TASKLOOP: name = "MASTER TASKLOOP"; break;
     case EXEC_OMP_MASTER_TASKLOOP_SIMD: name = "MASTER TASKLOOP SIMD"; break;
+    case EXEC_OMP_METADIRECTIVE: name = "METADIRECTIVE"; break;
     case EXEC_OMP_ORDERED: name = "ORDERED"; break;
     case EXEC_OMP_DEPOBJ: name = "DEPOBJ"; break;
     case EXEC_OMP_PARALLEL: name = "PARALLEL"; break;
@@ -2581,6 +2582,24 @@ show_omp_node (int level, gfc_code *c)
 	  d = d->block;
 	}
     }
+  else if (c->op == EXEC_OMP_METADIRECTIVE)
+    {
+      gfc_omp_variant *variant = c->ext.omp_variants;
+
+      while (variant)
+	{
+	  code_indent (level + 1, 0);
+	  if (variant->selectors)
+	    fputs ("WHEN ()\n", dumpfile);
+	  else
+	    fputs ("DEFAULT ()\n", dumpfile);
+	  /* TODO: Print selector.  */
+	  show_code (level + 2, variant->code);
+	  if (variant->next)
+	    fputs ("\n", dumpfile);
+	  variant = variant->next;
+	}
+    }
   else
     show_code (level + 1, c->block->next);
   if (c->op == EXEC_OMP_ATOMIC)
@@ -3821,6 +3840,7 @@ show_code_node (int level, gfc_code *c)
     case EXEC_OMP_MASTER:
     case EXEC_OMP_MASTER_TASKLOOP:
     case EXEC_OMP_MASTER_TASKLOOP_SIMD:
+    case EXEC_OMP_METADIRECTIVE:
     case EXEC_OMP_ORDERED:
     case EXEC_OMP_PARALLEL:
     case EXEC_OMP_PARALLEL_DO:
diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 7f3f6c52fb5450e725c01cac81ae6b97d6cc377d..e4ab3ba5bfa3effaa98c7eac5ed7fba9a3f64a24 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -981,6 +981,14 @@ gfc_type_convert_binary (gfc_expr *e, int wconversion)
 	  goto done;
 	}
 
+      /* Unsigned exponentiation is special, we need the type of the first
+	 argument here because of modulo arithmetic.  */
+      if (op1->ts.type == BT_UNSIGNED && e->value.op.op == INTRINSIC_POWER)
+	{
+	  e->ts = op1->ts;
+	  goto done;
+	}
+
       if (op1->ts.kind > op2->ts.kind)
 	gfc_convert_type_warn (op2, &op1->ts, 2, wconversion);
       else
diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc
index 987238794dabd5180e43a28912fc2c95f0d1fea7..6b470b83e21af02e8da37d3fe6ad90c555845036 100644
--- a/gcc/fortran/frontend-passes.cc
+++ b/gcc/fortran/frontend-passes.cc
@@ -5704,6 +5704,9 @@ check_externals_procedure (gfc_symbol *sym, locus *loc,
   if (gsym->ns)
     gfc_find_symbol (sym->name, gsym->ns, 0, &def_sym);
 
+  if (gsym->bind_c && def_sym && def_sym->binding_label == NULL)
+    return 0;
+
   if (def_sym)
     {
       gfc_compare_actual_formal (&actual, def_sym->formal, 0, 0, 0, loc);
@@ -5800,6 +5803,10 @@ check_against_globals (gfc_symbol *sym)
 
   if (sym->binding_label)
     sym_name = sym->binding_label;
+  else if (sym->attr.use_rename
+	   && sym->ns->use_stmts->rename
+	   && sym->ns->use_stmts->rename->local_name[0] != '\0')
+    sym_name = sym->ns->use_stmts->rename->local_name;
   else
     sym_name = sym->name;
 
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 825dc2ae8e2bbdda137935d8f5c4038075196f6d..5fe127646152c43df5c8f8659d15a8490d48d39a 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -318,6 +318,7 @@ enum gfc_statement
   ST_OMP_END_PARALLEL_MASKED_TASKLOOP_SIMD, ST_OMP_MASKED_TASKLOOP,
   ST_OMP_END_MASKED_TASKLOOP, ST_OMP_MASKED_TASKLOOP_SIMD,
   ST_OMP_END_MASKED_TASKLOOP_SIMD, ST_OMP_SCOPE, ST_OMP_END_SCOPE,
+  ST_OMP_METADIRECTIVE, ST_OMP_BEGIN_METADIRECTIVE, ST_OMP_END_METADIRECTIVE,
   ST_OMP_ERROR, ST_OMP_ASSUME, ST_OMP_END_ASSUME, ST_OMP_ASSUMES,
   ST_OMP_ALLOCATE, ST_OMP_ALLOCATE_EXEC,
   ST_OMP_ALLOCATORS, ST_OMP_END_ALLOCATORS,
@@ -1634,7 +1635,7 @@ typedef struct gfc_omp_clauses
   unsigned order_unconstrained:1, order_reproducible:1, capture:1;
   unsigned grainsize_strict:1, num_tasks_strict:1, compare:1, weak:1;
   unsigned non_rectangular:1, order_concurrent:1;
-  unsigned contains_teams_construct:1, target_first_st_is_teams:1;
+  unsigned contains_teams_construct:1, target_first_st_is_teams_or_meta:1;
   unsigned contained_in_target_construct:1, indirect:1;
   unsigned full:1, erroneous:1;
   ENUM_BITFIELD (gfc_omp_sched_kind) sched_kind:3;
@@ -1749,6 +1750,7 @@ typedef struct gfc_omp_declare_variant
 
   gfc_omp_set_selector *set_selectors;
   gfc_omp_namelist *adjust_args_list;
+  gfc_omp_namelist *append_args_list;
 
   bool checked_p : 1; /* Set if previously checked for errors.  */
   bool error_p : 1; /* Set if error found in directive.  */
@@ -1756,6 +1758,17 @@ typedef struct gfc_omp_declare_variant
 gfc_omp_declare_variant;
 #define gfc_get_omp_declare_variant() XCNEW (gfc_omp_declare_variant)
 
+typedef struct gfc_omp_variant
+{
+  struct gfc_omp_variant *next;
+  locus where; /* Where the metadirective clause occurred.  */
+
+  gfc_omp_set_selector *selectors;
+  enum gfc_statement stmt;
+  struct gfc_code *code;
+
+} gfc_omp_variant;
+#define gfc_get_omp_variant() XCNEW (gfc_omp_variant)
 
 typedef struct gfc_omp_udr
 {
@@ -1804,6 +1817,7 @@ typedef struct gfc_st_label
   locus where;
 
   gfc_namespace *ns;
+  int omp_region;
 }
 gfc_st_label;
 
@@ -3107,7 +3121,7 @@ enum gfc_exec_op
   EXEC_OMP_TARGET_TEAMS_LOOP, EXEC_OMP_MASKED, EXEC_OMP_PARALLEL_MASKED,
   EXEC_OMP_PARALLEL_MASKED_TASKLOOP, EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD,
   EXEC_OMP_MASKED_TASKLOOP, EXEC_OMP_MASKED_TASKLOOP_SIMD, EXEC_OMP_SCOPE,
-  EXEC_OMP_UNROLL, EXEC_OMP_TILE, EXEC_OMP_INTEROP,
+  EXEC_OMP_UNROLL, EXEC_OMP_TILE, EXEC_OMP_INTEROP, EXEC_OMP_METADIRECTIVE,
   EXEC_OMP_ERROR, EXEC_OMP_ALLOCATE, EXEC_OMP_ALLOCATORS, EXEC_OMP_DISPATCH
 };
 
@@ -3153,6 +3167,7 @@ typedef struct gfc_code
     gfc_omp_clauses *omp_clauses;
     const char *omp_name;
     gfc_omp_namelist *omp_namelist;
+    gfc_omp_variant *omp_variants;
     bool omp_bool;
     int stop_code;
 
@@ -3801,6 +3816,7 @@ void gfc_free_omp_declare_variant_list (gfc_omp_declare_variant *list);
 void gfc_free_omp_declare_simd (gfc_omp_declare_simd *);
 void gfc_free_omp_declare_simd_list (gfc_omp_declare_simd *);
 void gfc_free_omp_udr (gfc_omp_udr *);
+void gfc_free_omp_variants (gfc_omp_variant *);
 gfc_omp_udr *gfc_omp_udr_find (gfc_symtree *, gfc_typespec *);
 void gfc_resolve_omp_allocate (gfc_namespace *, gfc_omp_namelist *);
 void gfc_resolve_omp_assumptions (gfc_omp_assumptions *);
@@ -4088,6 +4104,8 @@ void debug (gfc_expr *);
 bool gfc_parse_file (void);
 void gfc_global_used (gfc_gsymbol *, locus *);
 gfc_namespace* gfc_build_block_ns (gfc_namespace *);
+gfc_statement match_omp_directive (void);
+bool is_omp_declarative_stmt (gfc_statement);
 
 /* dependency.cc */
 int gfc_dep_compare_functions (gfc_expr *, gfc_expr *, bool);
diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index d3fe0935aa44e68e1e6ab59ab116612b3b3dd55b..ab8a4cb590fee2592a6a82df7465ab08937ae0ae 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -2772,9 +2772,10 @@ end program main
 @noindent
 which outputs the number 18446744073709551583.
 
-Arithmetic operations work on unsigned integers, except for exponentiation,
-which is prohibited.  Unary minus is not permitted when @code{-pedantic}
-is in force; this prohibition is part of J3/24-116.txt.
+Arithmetic operations work on unsigned integers, also for
+exponentiation.  As an extension to J3/24-116.txt, unary minus
+and exponentiation of unsigned integers are permitted unless
+@code{-pedantic} is in force.
 
 In intrinsic procedures, unsigned arguments are typically permitted
 for arguments for the data to be processed, analogous to the
diff --git a/gcc/fortran/io.cc b/gcc/fortran/io.cc
index 48f4359f409855fcf135bb5c513493f99ea8255c..b5c9d33374968b158339757c175d7e06bd8ea218 100644
--- a/gcc/fortran/io.cc
+++ b/gcc/fortran/io.cc
@@ -29,7 +29,7 @@ along with GCC; see the file COPYING3.  If not see
 
 gfc_st_label
 format_asterisk = {0, NULL, NULL, -1, ST_LABEL_FORMAT, ST_LABEL_FORMAT, NULL,
-		   0, {NULL, NULL}, NULL};
+		   0, {NULL, NULL}, NULL, 0};
 
 typedef struct
 {
diff --git a/gcc/fortran/match.h b/gcc/fortran/match.h
index 40416136c459d72da2372e718459b6b0d9752204..410361c4bd1c8de5a90a59a8de93557eaeb80ba9 100644
--- a/gcc/fortran/match.h
+++ b/gcc/fortran/match.h
@@ -155,6 +155,7 @@ match gfc_match_omp_assume (void);
 match gfc_match_omp_assumes (void);
 match gfc_match_omp_atomic (void);
 match gfc_match_omp_barrier (void);
+match gfc_match_omp_begin_metadirective (void);
 match gfc_match_omp_cancel (void);
 match gfc_match_omp_cancellation_point (void);
 match gfc_match_omp_critical (void);
@@ -180,6 +181,7 @@ match gfc_match_omp_masked_taskloop_simd (void);
 match gfc_match_omp_master (void);
 match gfc_match_omp_master_taskloop (void);
 match gfc_match_omp_master_taskloop_simd (void);
+match gfc_match_omp_metadirective (void);
 match gfc_match_omp_nothing (void);
 match gfc_match_omp_ordered (void);
 match gfc_match_omp_ordered_depend (void);
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index be78aa1ab27582e7efb97dc07c345af80974daf2..e8df9d63fec2bbcd02a60d39e5d96d3e52ec7554 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -83,7 +83,7 @@ static const struct gfc_omp_directive gfc_omp_directives[] = {
   {"interop", GFC_OMP_DIR_EXECUTABLE, ST_OMP_INTEROP},
   {"loop", GFC_OMP_DIR_EXECUTABLE, ST_OMP_LOOP},
   {"masked", GFC_OMP_DIR_EXECUTABLE, ST_OMP_MASKED},
-  /* {"metadirective", GFC_OMP_DIR_META, ST_OMP_METADIRECTIVE}, */
+  {"metadirective", GFC_OMP_DIR_META, ST_OMP_METADIRECTIVE},
   /* Note: gfc_match_omp_nothing returns ST_NONE.  */
   {"nothing", GFC_OMP_DIR_UTILITY, ST_OMP_NOTHING},
   /* Special case; for now map to the first one.
@@ -109,14 +109,15 @@ static const struct gfc_omp_directive gfc_omp_directives[] = {
   {"task", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TASK},
   {"teams", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TEAMS},
   {"threadprivate", GFC_OMP_DIR_DECLARATIVE, ST_OMP_THREADPRIVATE},
-  /* {"tile", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TILE}, */
-  /* {"unroll", GFC_OMP_DIR_EXECUTABLE, ST_OMP_UNROLL}, */
+  {"tile", GFC_OMP_DIR_EXECUTABLE, ST_OMP_TILE},
+  {"unroll", GFC_OMP_DIR_EXECUTABLE, ST_OMP_UNROLL},
   {"workshare", GFC_OMP_DIR_EXECUTABLE, ST_OMP_WORKSHARE},
 };
 
 
 /* Match an end of OpenMP directive.  End of OpenMP directive is optional
-   whitespace, followed by '\n' or comment '!'.  */
+   whitespace, followed by '\n' or comment '!'.  In the special case where a
+   context selector is being matched, match against ')' instead.  */
 
 static match
 gfc_match_omp_eos (void)
@@ -127,17 +128,25 @@ gfc_match_omp_eos (void)
   old_loc = gfc_current_locus;
   gfc_gobble_whitespace ();
 
-  c = gfc_next_ascii_char ();
-  switch (c)
+  if (gfc_matching_omp_context_selector)
     {
-    case '!':
-      do
-	c = gfc_next_ascii_char ();
-      while (c != '\n');
-      /* Fall through */
+      if (gfc_peek_ascii_char () == ')')
+	return MATCH_YES;
+    }
+  else
+    {
+      c = gfc_next_ascii_char ();
+      switch (c)
+	{
+	case '!':
+	  do
+	    c = gfc_next_ascii_char ();
+	  while (c != '\n');
+	  /* Fall through */
 
-    case '\n':
-      return MATCH_YES;
+	case '\n':
+	  return MATCH_YES;
+	}
     }
 
   gfc_current_locus = old_loc;
@@ -349,6 +358,19 @@ gfc_free_omp_udr (gfc_omp_udr *omp_udr)
     }
 }
 
+/* Free variants of an !$omp metadirective construct.  */
+
+void
+gfc_free_omp_variants (gfc_omp_variant *variant)
+{
+  while (variant)
+    {
+      gfc_omp_variant *next_variant = variant->next;
+      gfc_free_omp_set_selector_list (variant->selectors);
+      free (variant);
+      variant = next_variant;
+    }
+}
 
 static gfc_omp_udr *
 gfc_find_omp_udr (gfc_namespace *ns, const char *name, gfc_typespec *ts)
@@ -2112,33 +2134,51 @@ gfc_match_omp_prefer_type (char **type_str, int *type_str_len)
 }
 
 
-/* Match OpenMP 5.1's 'init' clause for 'interop' objects:
-   init([prefer_type(...)][,][<target|targetsync>, ...] :] interop-obj-list)  */
+/* Match OpenMP 5.1's 'init'-clause modifiers, used by the 'init' clause of
+   the 'interop' directive and the 'append_args' directive of 'declare variant'.
+     [prefer_type(...)][,][<target|targetsync>, ...])
+
+   If is_init_clause, there might be no modifiers but variables like 'target';
+   additionally, the modifier parsing ends with a ':'.
+   If not is_init_clause (i.e. append_args), there must be modifiers and the
+   parsing ends with ')'.  */
 
 static match
-gfc_match_omp_init (gfc_omp_namelist **list)
-{
-  bool target = false, targetsync = false;
-  char *type_str = NULL;
-  int type_str_len = 0;
+gfc_parser_omp_clause_init_modifiers (bool &target, bool &targetsync,
+				      char **type_str, int &type_str_len,
+				      bool is_init_clause)
+{
+  target = false;
+  targetsync = false;
+  *type_str = NULL;
+  type_str_len = 0;
   match m;
   locus old_loc = gfc_current_locus;
   do {
        if (gfc_match ("prefer_type ( ") == MATCH_YES)
 	{
-	  if (type_str)
+	  if (*type_str)
 	    {
 	      gfc_error ("Duplicate %<prefer_type%> modifier at %C");
 	      return MATCH_ERROR;
 	    }
-	  m = gfc_match_omp_prefer_type (&type_str, &type_str_len);
+	  m = gfc_match_omp_prefer_type (type_str, &type_str_len);
 	  if (m != MATCH_YES)
 	    return m;
 	  if (gfc_match (", ") == MATCH_YES)
 	    continue;
-	  if (gfc_match (": ") == MATCH_YES)
-	    break;
-	  gfc_error ("Expected %<,%> or %<:%> at %C");
+	  if (is_init_clause)
+	    {
+	      if (gfc_match (": ") == MATCH_YES)
+		break;
+	      gfc_error ("Expected %<,%> or %<:%> at %C");
+	    }
+	  else
+	    {
+	      if (gfc_match (") ") == MATCH_YES)
+		break;
+	      gfc_error ("Expected %<,%> or %<)%> at %C");
+	    }
 	  return MATCH_ERROR;
 	}
        if (gfc_match ("targetsync ") == MATCH_YES)
@@ -2153,11 +2193,18 @@ gfc_match_omp_init (gfc_omp_namelist **list)
 	  targetsync = true;
 	  if (gfc_match (", ") == MATCH_YES)
 	    continue;
+	  if (!is_init_clause)
+	    {
+	      if (gfc_match (") ") == MATCH_YES)
+		break;
+	      gfc_error ("Expected %<,%> or %<)%> at %C");
+	      return MATCH_ERROR;
+	    }
 	  if (gfc_match (": ") == MATCH_YES)
 	    break;
 	  gfc_char_t c = gfc_peek_char ();
-	  if (!type_str && (c == ')' || (gfc_current_form != FORM_FREE
-					 && (c == '_' || ISALPHA (c)))))
+	  if (!*type_str && (c == ')' || (gfc_current_form != FORM_FREE
+					  && (c == '_' || ISALPHA (c)))))
 	    {
 	      gfc_current_locus = old_loc;
 	      break;
@@ -2175,11 +2222,18 @@ gfc_match_omp_init (gfc_omp_namelist **list)
 	  target = true;
 	  if (gfc_match (", ") == MATCH_YES)
 	    continue;
+	  if (!is_init_clause)
+	    {
+	      if (gfc_match (") ") == MATCH_YES)
+		break;
+	      gfc_error ("Expected %<,%> or %<)%> at %C");
+	      return MATCH_ERROR;
+	    }
 	  if (gfc_match (": ") == MATCH_YES)
 	    break;
 	  gfc_char_t c = gfc_peek_char ();
-	  if (!type_str && (c == ')' || (gfc_current_form != FORM_FREE
-					 && (c == '_' || ISALPHA (c)))))
+	  if (!*type_str && (c == ')' || (gfc_current_form != FORM_FREE
+					  && (c == '_' || ISALPHA (c)))))
 	    {
 	      gfc_current_locus = old_loc;
 	      break;
@@ -2187,7 +2241,7 @@ gfc_match_omp_init (gfc_omp_namelist **list)
 	  gfc_error ("Expected %<,%> or %<:%> at %C");
 	  return MATCH_ERROR;
 	}
-      if (type_str)
+      if (*type_str)
 	{
 	  gfc_error ("Expected %<target%> or %<targetsync%> at %C");
 	  return MATCH_ERROR;
@@ -2196,6 +2250,21 @@ gfc_match_omp_init (gfc_omp_namelist **list)
       break;
     }
   while (true);
+  return MATCH_YES;
+}
+
+/* Match OpenMP 5.1's 'init' clause for 'interop' objects:
+   init([prefer_type(...)][,][<target|targetsync>, ...] :] interop-obj-list)  */
+
+static match
+gfc_match_omp_init (gfc_omp_namelist **list)
+{
+  bool target, targetsync;
+  char *type_str = NULL;
+  int type_str_len;
+  if (gfc_parser_omp_clause_init_modifiers (target, targetsync, &type_str,
+					    type_str_len, true) == MATCH_ERROR)
+    return MATCH_ERROR;
 
  gfc_omp_namelist **head = NULL;
  if (gfc_match_omp_variable_list ("", list, false, NULL, &head) != MATCH_YES)
@@ -2274,8 +2343,7 @@ gfc_match_dupl_atomic (bool not_dupl, const char *name)
 static match
 gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
 		       bool first = true, bool needs_space = true,
-		       bool openacc = false, bool context_selector = false,
-		       bool openmp_target = false)
+		       bool openacc = false, bool openmp_target = false)
 {
   bool error = false;
   gfc_omp_clauses *c = gfc_get_omp_clauses ();
@@ -4337,9 +4405,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
     }
 
 end:
-  if (error
-      || (context_selector && gfc_peek_ascii_char () != ')')
-      || (!context_selector && gfc_match_omp_eos () != MATCH_YES))
+  if (error || gfc_match_omp_eos () != MATCH_YES)
     {
       if (!gfc_error_flag_test ())
 	gfc_error ("Failed to match clause at %C");
@@ -5053,7 +5119,7 @@ static match
 match_omp (gfc_exec_op op, const omp_mask mask)
 {
   gfc_omp_clauses *c;
-  if (gfc_match_omp_clauses (&c, mask, true, true, false, false,
+  if (gfc_match_omp_clauses (&c, mask, true, true, false,
 			     op == EXEC_OMP_TARGET) != MATCH_YES)
     return MATCH_ERROR;
   new_st.op = op;
@@ -6248,7 +6314,8 @@ gfc_match_omp_interop (void)
      score(score-expression)  */
 
 match
-gfc_match_omp_context_selector (gfc_omp_set_selector *oss)
+gfc_match_omp_context_selector (gfc_omp_set_selector *oss,
+				bool metadirective_p)
 {
   do
     {
@@ -6408,14 +6475,31 @@ gfc_match_omp_context_selector (gfc_omp_set_selector *oss)
 		  || (property_kind == OMP_TRAIT_PROPERTY_DEV_NUM_EXPR
 		      && otp->expr->ts.type != BT_INTEGER)
 		  || otp->expr->rank != 0
-		  || otp->expr->expr_type != EXPR_CONSTANT)
+		  || (!metadirective_p
+		      && otp->expr->expr_type != EXPR_CONSTANT))
 		{
-		  if (property_kind == OMP_TRAIT_PROPERTY_BOOL_EXPR)
-		    gfc_error ("property must be a constant logical expression "
-			       "at %C");
+		  if (metadirective_p)
+		    {
+		      if (property_kind == OMP_TRAIT_PROPERTY_BOOL_EXPR)
+			gfc_error ("property must be a "
+				   "logical expression at %L",
+				   &otp->expr->where);
+		      else
+			gfc_error ("property must be an "
+				   "integer expression at %L",
+				   &otp->expr->where);
+		    }
 		  else
-		    gfc_error ("property must be a constant integer expression "
-			       "at %C");
+		    {
+		      if (property_kind == OMP_TRAIT_PROPERTY_BOOL_EXPR)
+			gfc_error ("property must be a constant "
+				   "logical expression at %L",
+				   &otp->expr->where);
+		      else
+			gfc_error ("property must be a constant "
+				   "integer expression at %L",
+				   &otp->expr->where);
+		    }
 		  return MATCH_ERROR;
 		}
 	      /* Device number must be conforming, which includes
@@ -6435,21 +6519,25 @@ gfc_match_omp_context_selector (gfc_omp_set_selector *oss)
 	      {
 		if (os->code == OMP_TRAIT_CONSTRUCT_SIMD)
 		  {
+		    gfc_matching_omp_context_selector = true;
 		    if (gfc_match_omp_clauses (&otp->clauses,
 					       OMP_DECLARE_SIMD_CLAUSES,
-					       true, false, false, true)
+					       true, false, false)
 			!= MATCH_YES)
 		      {
+			gfc_matching_omp_context_selector = false;
 			gfc_error ("expected simd clause at %C");
 			return MATCH_ERROR;
 		      }
+		    gfc_matching_omp_context_selector = false;
 		  }
 		else if (os->code == OMP_TRAIT_IMPLEMENTATION_REQUIRES)
 		  {
 		    /* FIXME: The "requires" selector was added in OpenMP 5.1.
 		       Currently only the now-deprecated syntax
 		       from OpenMP 5.0 is supported.  */
-		    sorry ("%<requires%> selector is not supported yet");
+		    sorry_at (gfc_get_location (&gfc_current_locus),
+			      "%<requires%> selector is not supported yet");
 		    return MATCH_ERROR;
 		  }
 		else
@@ -6499,7 +6587,8 @@ gfc_match_omp_context_selector (gfc_omp_set_selector *oss)
      user  */
 
 match
-gfc_match_omp_context_selector_specification (gfc_omp_declare_variant *odv)
+gfc_match_omp_context_selector_specification (gfc_omp_set_selector **oss_head,
+					      bool metadirective_p)
 {
   do
     {
@@ -6532,11 +6621,11 @@ gfc_match_omp_context_selector_specification (gfc_omp_declare_variant *odv)
 	}
 
       gfc_omp_set_selector *oss = gfc_get_omp_set_selector ();
-      oss->next = odv->set_selectors;
+      oss->next = *oss_head;
       oss->code = set;
-      odv->set_selectors = oss;
+      *oss_head = oss;
 
-      if (gfc_match_omp_context_selector (oss) != MATCH_YES)
+      if (gfc_match_omp_context_selector (oss, metadirective_p) != MATCH_YES)
 	return MATCH_ERROR;
 
       m = gfc_match (" }");
@@ -6616,32 +6705,39 @@ gfc_match_omp_declare_variant (void)
       return MATCH_ERROR;
     }
 
-  bool has_match = false, has_adjust_args = false, error_p = false;
+  bool has_match = false, has_adjust_args = false, has_append_args = false;
+  bool error_p = false;
   locus adjust_args_loc;
+  locus append_args_loc;
 
+  gfc_gobble_whitespace ();
+  gfc_match_char (',');
   for (;;)
     {
       gfc_gobble_whitespace ();
-      gfc_match_char (',');
-      gfc_gobble_whitespace ();
 
       enum clause
       {
 	match,
-	adjust_args
+	adjust_args,
+	append_args
       } ccode;
 
-      if (gfc_match (" match") == MATCH_YES)
+      if (gfc_match ("match") == MATCH_YES)
 	ccode = match;
-      else if (gfc_match (" adjust_args") == MATCH_YES)
+      else if (gfc_match ("adjust_args") == MATCH_YES)
 	{
 	  ccode = adjust_args;
 	  adjust_args_loc = gfc_current_locus;
 	}
+      else if (gfc_match ("append_args") == MATCH_YES)
+	{
+	  ccode = append_args;
+	  append_args_loc = gfc_current_locus;
+	}
       else
 	{
-	  if (gfc_match_omp_eos () != MATCH_YES)
-	    error_p = true;
+	  error_p = true;
 	  break;
 	}
 
@@ -6653,8 +6749,15 @@ gfc_match_omp_declare_variant (void)
 
       if (ccode == match)
 	{
+	  if (has_match)
+	    {
+	      gfc_error ("%qs clause at %L specified more than once",
+			 "match", &gfc_current_locus);
+	      return MATCH_ERROR;
+	    }
 	  has_match = true;
-	  if (gfc_match_omp_context_selector_specification (odv)
+	  if (gfc_match_omp_context_selector_specification (&odv->set_selectors,
+							    false)
 	      != MATCH_YES)
 	    return MATCH_ERROR;
 	  if (gfc_match (" )") != MATCH_YES)
@@ -6688,20 +6791,82 @@ gfc_match_omp_declare_variant (void)
 	    for (gfc_omp_namelist *n = *head; n != NULL; n = n->next)
 	      n->u.need_device_ptr = true;
 	}
+      else if (ccode == append_args)
+	{
+	  if (has_append_args)
+	    {
+	      gfc_error ("%qs clause at %L specified more than once",
+			 "append_args", &gfc_current_locus);
+	      return MATCH_ERROR;
+	    }
+	  has_append_args = true;
+	  gfc_omp_namelist *append_args_last = NULL;
+	  do
+	    {
+	      gfc_gobble_whitespace ();
+	      if (gfc_match ("interop ") != MATCH_YES)
+		{
+		  gfc_error ("expected %<interop%> at %C");
+		  return MATCH_ERROR;
+		}
+	      if (gfc_match ("( ") != MATCH_YES)
+		{
+		  gfc_error ("expected %<(%> at %C");
+		  return MATCH_ERROR;
+		}
+
+	      bool target, targetsync;
+	      char *type_str = NULL;
+	      int type_str_len;
+	      locus loc = gfc_current_locus;
+	      if (gfc_parser_omp_clause_init_modifiers (target, targetsync,
+							&type_str, type_str_len,
+							false) == MATCH_ERROR)
+		return MATCH_ERROR;
+
+	      gfc_omp_namelist *n = gfc_get_omp_namelist();
+	      n->where = loc;
+	      n->u.init.target = target;
+	      n->u.init.targetsync = targetsync;
+	      n->u.init.len = type_str_len;
+	      n->u2.init_interop = type_str;
+	      if (odv->append_args_list)
+		{
+		  append_args_last->next = n;
+		  append_args_last = n;
+		}
+	      else
+		append_args_last = odv->append_args_list = n;
+
+	      gfc_gobble_whitespace ();
+	      if (gfc_match_char (',') == MATCH_YES)
+		continue;
+	      if (gfc_match_char (')') == MATCH_YES)
+		break;
+	      gfc_error ("Expected %<,%> or %<)%> at %C");
+	      return MATCH_ERROR;
+	    }
+	  while (true);
+	}
+      gfc_gobble_whitespace ();
+      if (gfc_match_omp_eos () == MATCH_YES)
+	break;
+      gfc_match_char (',');
     }
 
-  if (error_p || (!has_match && !has_adjust_args))
+  if (error_p || (!has_match && !has_adjust_args && !has_append_args))
     {
-      gfc_error ("expected %<match%> or %<adjust_args%> at %C");
+      gfc_error ("expected %<match%>, %<adjust_args%> or %<append_args%> at %C");
       return MATCH_ERROR;
     }
 
-  if (has_adjust_args && !has_match)
+  if ((has_adjust_args || has_append_args) && !has_match)
     {
-      gfc_error ("an %<adjust_args%> clause at %L can only be specified if the "
+      gfc_error ("the %qs clause at %L can only be specified if the "
 		 "%<dispatch%> selector of the construct selector set appears "
 		 "in the %<match%> clause",
-		 &adjust_args_loc);
+		 has_adjust_args ? "adjust_args" : "append_args",
+		 has_adjust_args ?  &adjust_args_loc : &append_args_loc);
       return MATCH_ERROR;
     }
 
@@ -6709,6 +6874,168 @@ gfc_match_omp_declare_variant (void)
 }
 
 
+static match
+match_omp_metadirective (bool begin_p)
+{
+  locus old_loc = gfc_current_locus;
+  gfc_omp_variant *variants_head;
+  gfc_omp_variant **next_variant = &variants_head;
+  bool default_seen = false;
+
+  /* Parse the context selectors.  */
+  for (;;)
+    {
+      bool default_p = false;
+      gfc_omp_set_selector *selectors = NULL;
+
+      gfc_gobble_whitespace ();
+      if (gfc_match_eos () == MATCH_YES)
+	break;
+      gfc_match_char (',');
+      gfc_gobble_whitespace ();
+
+      locus variant_locus = gfc_current_locus;
+
+      if (gfc_match (" default ( ") == MATCH_YES)
+	default_p = true;
+      else if (gfc_match (" otherwise ( ") == MATCH_YES)
+	default_p = true;
+      else if (gfc_match (" when ( ") != MATCH_YES)
+	{
+	  gfc_error ("expected %<when%>, %<otherwise%>, or %<default%> at %C");
+	  gfc_current_locus = old_loc;
+	  return MATCH_ERROR;
+	}
+
+      if (default_p && default_seen)
+	{
+	  gfc_error ("too many %<otherwise%> or %<default%> clauses "
+		     "in %<metadirective%> at %C");
+	  gfc_current_locus = old_loc;
+	  return MATCH_ERROR;
+	}
+      else if (default_seen)
+	{
+	  gfc_error ("%<otherwise%> or %<default%> clause "
+		     "must appear last in %<metadirective%> at %C");
+	  gfc_current_locus = old_loc;
+	  return MATCH_ERROR;
+	}
+
+      if (!default_p)
+	{
+	  if (gfc_match_omp_context_selector_specification (&selectors, true)
+	      != MATCH_YES)
+	    return MATCH_ERROR;
+
+	  if (gfc_match (" : ") != MATCH_YES)
+	    {
+	      gfc_error ("expected %<:%> at %C");
+	      gfc_current_locus = old_loc;
+	      return MATCH_ERROR;
+	    }
+
+	  gfc_commit_symbols ();
+	}
+
+      gfc_matching_omp_context_selector = true;
+      gfc_statement directive = match_omp_directive ();
+      gfc_matching_omp_context_selector = false;
+
+      if (is_omp_declarative_stmt (directive))
+	sorry_at (gfc_get_location (&gfc_current_locus),
+		  "declarative directive variants are not supported");
+
+      if (gfc_error_flag_test ())
+	{
+	  gfc_current_locus = old_loc;
+	  return MATCH_ERROR;
+	}
+
+      if (gfc_match (" )") != MATCH_YES)
+	{
+	  gfc_error ("Expected %<)%> at %C");
+	  gfc_current_locus = old_loc;
+	  return MATCH_ERROR;
+	}
+
+      gfc_commit_symbols ();
+
+      if (begin_p
+	  && directive != ST_NONE
+	  && gfc_omp_end_stmt (directive) == ST_NONE)
+	{
+	  gfc_error ("variant directive used in OMP BEGIN METADIRECTIVE "
+		     "at %C must have a corresponding end directive");
+	  gfc_current_locus = old_loc;
+	  return MATCH_ERROR;
+	}
+
+      if (default_p)
+	default_seen = true;
+
+      gfc_omp_variant *omv = gfc_get_omp_variant ();
+      omv->selectors = selectors;
+      omv->stmt = directive;
+      omv->where = variant_locus;
+
+      if (directive == ST_NONE)
+	{
+	  /* The directive was a 'nothing' directive.  */
+	  omv->code = gfc_get_code (EXEC_CONTINUE);
+	  omv->code->ext.omp_clauses = NULL;
+	}
+      else
+	{
+	  omv->code = gfc_get_code (new_st.op);
+	  omv->code->ext.omp_clauses = new_st.ext.omp_clauses;
+	  /* Prevent the OpenMP clauses from being freed via NEW_ST.  */
+	  new_st.ext.omp_clauses = NULL;
+	}
+
+      *next_variant = omv;
+      next_variant = &omv->next;
+    }
+
+  if (gfc_match_omp_eos () != MATCH_YES)
+    {
+      gfc_error ("Unexpected junk after OMP METADIRECTIVE at %C");
+      gfc_current_locus = old_loc;
+      return MATCH_ERROR;
+    }
+
+  /* Add a 'default (nothing)' clause if no default is explicitly given.  */
+  if (!default_seen)
+    {
+      gfc_omp_variant *omv = gfc_get_omp_variant ();
+      omv->stmt = ST_NONE;
+      omv->code = gfc_get_code (EXEC_CONTINUE);
+      omv->code->ext.omp_clauses = NULL;
+      omv->where = old_loc;
+      omv->selectors = NULL;
+
+      *next_variant = omv;
+      next_variant = &omv->next;
+    }
+
+  new_st.op = EXEC_OMP_METADIRECTIVE;
+  new_st.ext.omp_variants = variants_head;
+
+  return MATCH_YES;
+}
+
+match
+gfc_match_omp_begin_metadirective (void)
+{
+  return match_omp_metadirective (true);
+}
+
+match
+gfc_match_omp_metadirective (void)
+{
+  return match_omp_metadirective (false);
+}
+
 match
 gfc_match_omp_threadprivate (void)
 {
@@ -10410,7 +10737,7 @@ resolve_omp_atomic (gfc_code *code)
       gfc_intrinsic_op alt_op = INTRINSIC_NONE;
 
       if (atomic_code->ext.omp_clauses->fail != OMP_MEMORDER_UNSET)
-	gfc_error ("!$OMP ATOMIC UPDATE at %L with FAIL clause requiries either"
+	gfc_error ("!$OMP ATOMIC UPDATE at %L with FAIL clause requires either"
 		   " the COMPARE clause or using the intrinsic MIN/MAX "
 		   "procedure", &atomic_code->loc);
       switch (op)
@@ -11865,6 +12192,19 @@ resolve_omp_do (gfc_code *code)
 				  non_generated_count);
 }
 
+static void
+resolve_omp_metadirective (gfc_code *code, gfc_namespace *ns)
+{
+  gfc_omp_variant *variant = code->ext.omp_variants;
+
+  while (variant)
+    {
+      gfc_code *variant_code = variant->code;
+      gfc_resolve_code (variant_code, ns);
+      variant = variant->next;
+    }
+}
+
 
 static gfc_statement
 omp_code_to_statement (gfc_code *code)
@@ -12416,13 +12756,32 @@ resolve_omp_target (gfc_code *code)
   gfc_code *c = code->block->next;
   if (c->op == EXEC_BLOCK)
     c = c->ext.block.ns->code;
-  if (code->ext.omp_clauses->target_first_st_is_teams
-      && ((GFC_IS_TEAMS_CONSTRUCT (c->op) && c->next == NULL)
-	  || (c->op == EXEC_BLOCK
-	      && c->next
-	      && GFC_IS_TEAMS_CONSTRUCT (c->next->op)
-	      && c->next->next == NULL)))
-    return;
+  if (code->ext.omp_clauses->target_first_st_is_teams_or_meta)
+    {
+      if (c->op == EXEC_OMP_METADIRECTIVE)
+	{
+	  struct gfc_omp_variant *mc
+	    = c->ext.omp_variants;
+	  /* All mc->(next...->)code should be identical with regards
+	     to the diagnostic below.  */
+	  do
+	    {
+	      if (mc->stmt != ST_NONE
+		  && GFC_IS_TEAMS_CONSTRUCT (mc->code->op))
+		{
+		  if (c->next == NULL && mc->code->next == NULL)
+		    return;
+		  c = mc->code;
+		  break;
+		}
+	      mc = mc->next;
+	    }
+	  while (mc);
+	}
+      else if (GFC_IS_TEAMS_CONSTRUCT (c->op) && c->next == NULL)
+	return;
+    }
+
   while (c && !GFC_IS_TEAMS_CONSTRUCT (c->op))
     c = c->next;
   if (c)
@@ -12592,6 +12951,9 @@ gfc_resolve_omp_directive (gfc_code *code, gfc_namespace *ns)
 	resolve_omp_clauses (code, code->ext.omp_clauses, ns);
       resolve_omp_dispatch (code);
       break;
+    case EXEC_OMP_METADIRECTIVE:
+      resolve_omp_metadirective (code, ns);
+      break;
     default:
       break;
     }
diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc
index a75284ec0bc0504ebc6d33f9df5d6ee022ecaab5..5094d9d3eadf6b0e120966df41a0baae213dc575 100644
--- a/gcc/fortran/parse.cc
+++ b/gcc/fortran/parse.cc
@@ -48,6 +48,16 @@ gfc_state_data *gfc_state_stack;
 static bool last_was_use_stmt = false;
 bool in_exec_part;
 
+/* True when matching an OpenMP context selector.  */
+bool gfc_matching_omp_context_selector;
+
+/* True when parsing the body of an OpenMP metadirective.  */
+bool gfc_in_omp_metadirective_body;
+
+/* Each metadirective body in the translation unit is given a unique
+   number, used to ensure that labels in the body have unique names.  */
+int gfc_omp_metadirective_region_count;
+
 /* TODO: Re-order functions to kill these forward decls.  */
 static void check_statement_label (gfc_statement);
 static void undo_new_statement (void);
@@ -993,6 +1003,12 @@ decode_omp_directive (void)
       matcho ("assumes", gfc_match_omp_assumes, ST_OMP_ASSUMES);
       matchs ("assume", gfc_match_omp_assume, ST_OMP_ASSUME);
       break;
+
+    case 'b':
+      matcho ("begin metadirective", gfc_match_omp_begin_metadirective,
+	      ST_OMP_BEGIN_METADIRECTIVE);
+      break;
+
     case 'd':
       matchds ("declare reduction", gfc_match_omp_declare_reduction,
 	       ST_OMP_DECLARE_REDUCTION);
@@ -1005,11 +1021,19 @@ decode_omp_directive (void)
       break;
     case 'e':
       matchs ("end assume", gfc_match_omp_eos_error, ST_OMP_END_ASSUME);
+      matcho ("end metadirective", gfc_match_omp_eos_error,
+	      ST_OMP_END_METADIRECTIVE);
       matchs ("end simd", gfc_match_omp_eos_error, ST_OMP_END_SIMD);
       matchs ("end tile", gfc_match_omp_eos_error, ST_OMP_END_TILE);
       matchs ("end unroll", gfc_match_omp_eos_error, ST_OMP_END_UNROLL);
       matcho ("error", gfc_match_omp_error, ST_OMP_ERROR);
       break;
+
+    case 'm':
+      matcho ("metadirective", gfc_match_omp_metadirective,
+	      ST_OMP_METADIRECTIVE);
+      break;
+
     case 'n':
       matcho ("nothing", gfc_match_omp_nothing, ST_NONE);
       break;
@@ -1309,6 +1333,10 @@ decode_omp_directive (void)
 	gfc_error_now ("Unclassifiable OpenMP directive at %C");
     }
 
+  /* If parsing a metadirective, let the caller deal with the cleanup.  */
+  if (gfc_matching_omp_context_selector)
+    return ST_NONE;
+
   reject_statement ();
 
   gfc_error_recovery ();
@@ -1430,6 +1458,12 @@ decode_omp_directive (void)
   return ST_GET_FCN_CHARACTERISTICS;
 }
 
+gfc_statement
+match_omp_directive (void)
+{
+  return decode_omp_directive ();
+}
+
 static gfc_statement
 decode_gcc_attribute (void)
 {
@@ -1955,6 +1989,44 @@ next_statement (void)
   case ST_OMP_DECLARE_VARIANT: case ST_OMP_ALLOCATE: case ST_OMP_ASSUMES: \
   case ST_OMP_REQUIRES: case ST_OACC_ROUTINE: case ST_OACC_DECLARE
 
+/* OpenMP statements that are followed by a structured block.  */
+
+#define case_omp_structured_block case ST_OMP_ASSUME: case ST_OMP_PARALLEL: \
+  case ST_OMP_PARALLEL_MASKED: case ST_OMP_PARALLEL_MASTER: \
+  case ST_OMP_PARALLEL_SECTIONS: case ST_OMP_ORDERED: \
+  case ST_OMP_CRITICAL: case ST_OMP_MASKED: case ST_OMP_MASTER: \
+  case ST_OMP_SCOPE: case ST_OMP_SECTIONS: case ST_OMP_SINGLE: \
+  case ST_OMP_TARGET: case ST_OMP_TARGET_DATA: case ST_OMP_TARGET_PARALLEL: \
+  case ST_OMP_TARGET_TEAMS: case ST_OMP_TEAMS: case ST_OMP_TASK: \
+  case ST_OMP_TASKGROUP: \
+  case ST_OMP_WORKSHARE: case ST_OMP_PARALLEL_WORKSHARE
+
+/* OpenMP statements that are followed by a do loop.  */
+
+#define case_omp_do case ST_OMP_DISTRIBUTE: \
+  case ST_OMP_DISTRIBUTE_PARALLEL_DO: \
+  case ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD: case ST_OMP_DISTRIBUTE_SIMD: \
+  case ST_OMP_DO: case ST_OMP_DO_SIMD: case ST_OMP_LOOP: \
+  case ST_OMP_PARALLEL_DO: case ST_OMP_PARALLEL_DO_SIMD: \
+  case ST_OMP_PARALLEL_LOOP: case ST_OMP_PARALLEL_MASKED_TASKLOOP: \
+  case ST_OMP_PARALLEL_MASKED_TASKLOOP_SIMD: \
+  case ST_OMP_PARALLEL_MASTER_TASKLOOP: \
+  case ST_OMP_PARALLEL_MASTER_TASKLOOP_SIMD: \
+  case ST_OMP_MASKED_TASKLOOP: case ST_OMP_MASKED_TASKLOOP_SIMD: \
+  case ST_OMP_MASTER_TASKLOOP: case ST_OMP_MASTER_TASKLOOP_SIMD: \
+  case ST_OMP_SIMD: \
+  case ST_OMP_TARGET_PARALLEL_DO: case ST_OMP_TARGET_PARALLEL_DO_SIMD: \
+  case ST_OMP_TARGET_PARALLEL_LOOP: case ST_OMP_TARGET_SIMD: \
+  case ST_OMP_TARGET_TEAMS_DISTRIBUTE: \
+  case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO: \
+  case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: \
+  case ST_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD: case ST_OMP_TARGET_TEAMS_LOOP: \
+  case ST_OMP_TASKLOOP: case ST_OMP_TASKLOOP_SIMD: \
+  case ST_OMP_TEAMS_DISTRIBUTE: case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO: \
+  case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: \
+  case ST_OMP_TEAMS_DISTRIBUTE_SIMD: case ST_OMP_TEAMS_LOOP: \
+  case ST_OMP_TILE: case ST_OMP_UNROLL
+
 /* Block end statements.  Errors associated with interchanging these
    are detected in gfc_match_end().  */
 
@@ -2592,6 +2664,9 @@ gfc_ascii_statement (gfc_statement st, bool strip_sentinel)
     case ST_OMP_BARRIER:
       p = "!$OMP BARRIER";
       break;
+    case ST_OMP_BEGIN_METADIRECTIVE:
+      p = "!$OMP BEGIN METADIRECTIVE";
+      break;
     case ST_OMP_CANCEL:
       p = "!$OMP CANCEL";
       break;
@@ -2697,6 +2772,9 @@ gfc_ascii_statement (gfc_statement st, bool strip_sentinel)
     case ST_OMP_END_MASTER_TASKLOOP_SIMD:
       p = "!$OMP END MASTER TASKLOOP SIMD";
       break;
+    case ST_OMP_END_METADIRECTIVE:
+      p = "!$OMP END METADIRECTIVE";
+      break;
     case ST_OMP_END_ORDERED:
       p = "!$OMP END ORDERED";
       break;
@@ -2850,6 +2928,9 @@ gfc_ascii_statement (gfc_statement st, bool strip_sentinel)
     case ST_OMP_MASTER_TASKLOOP_SIMD:
       p = "!$OMP MASTER TASKLOOP SIMD";
       break;
+    case ST_OMP_METADIRECTIVE:
+      p = "!$OMP METADIRECTIVE";
+      break;
     case ST_OMP_ORDERED:
     case ST_OMP_ORDERED_DEPEND:
       p = "!$OMP ORDERED";
@@ -3116,6 +3197,8 @@ accept_statement (gfc_statement st)
       break;
 
     case ST_ENTRY:
+    case ST_OMP_METADIRECTIVE:
+    case ST_OMP_BEGIN_METADIRECTIVE:
     case_executable:
     case_exec_markers:
       add_statement ();
@@ -5511,6 +5594,150 @@ loop:
   accept_statement (st);
 }
 
+/* Get the corresponding ending statement type for the OpenMP directive
+   OMP_ST.  If it does not have one, return ST_NONE.  */
+
+gfc_statement
+gfc_omp_end_stmt (gfc_statement omp_st,
+		  bool omp_do_p, bool omp_structured_p)
+{
+  if (omp_do_p)
+    {
+      switch (omp_st)
+	{
+	case ST_OMP_DISTRIBUTE: return ST_OMP_END_DISTRIBUTE;
+	case ST_OMP_DISTRIBUTE_PARALLEL_DO:
+	  return ST_OMP_END_DISTRIBUTE_PARALLEL_DO;
+	case ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD:
+	  return ST_OMP_END_DISTRIBUTE_PARALLEL_DO_SIMD;
+	case ST_OMP_DISTRIBUTE_SIMD:
+	  return ST_OMP_END_DISTRIBUTE_SIMD;
+	case ST_OMP_DO: return ST_OMP_END_DO;
+	case ST_OMP_DO_SIMD: return ST_OMP_END_DO_SIMD;
+	case ST_OMP_LOOP: return ST_OMP_END_LOOP;
+	case ST_OMP_PARALLEL_DO: return ST_OMP_END_PARALLEL_DO;
+	case ST_OMP_PARALLEL_DO_SIMD:
+	  return ST_OMP_END_PARALLEL_DO_SIMD;
+	case ST_OMP_PARALLEL_LOOP:
+	  return ST_OMP_END_PARALLEL_LOOP;
+	case ST_OMP_SIMD: return ST_OMP_END_SIMD;
+	case ST_OMP_TARGET_PARALLEL_DO:
+	  return ST_OMP_END_TARGET_PARALLEL_DO;
+	case ST_OMP_TARGET_PARALLEL_DO_SIMD:
+	  return ST_OMP_END_TARGET_PARALLEL_DO_SIMD;
+	case ST_OMP_TARGET_PARALLEL_LOOP:
+	  return ST_OMP_END_TARGET_PARALLEL_LOOP;
+	case ST_OMP_TARGET_SIMD: return ST_OMP_END_TARGET_SIMD;
+	case ST_OMP_TARGET_TEAMS_DISTRIBUTE:
+	  return ST_OMP_END_TARGET_TEAMS_DISTRIBUTE;
+	case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO:
+	  return ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO;
+	case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
+	  return ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD;
+	case ST_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD:
+	  return ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_SIMD;
+	case ST_OMP_TARGET_TEAMS_LOOP:
+	  return ST_OMP_END_TARGET_TEAMS_LOOP;
+	case ST_OMP_TASKLOOP: return ST_OMP_END_TASKLOOP;
+	case ST_OMP_TASKLOOP_SIMD: return ST_OMP_END_TASKLOOP_SIMD;
+	case ST_OMP_MASKED_TASKLOOP: return ST_OMP_END_MASKED_TASKLOOP;
+	case ST_OMP_MASKED_TASKLOOP_SIMD:
+	  return ST_OMP_END_MASKED_TASKLOOP_SIMD;
+	case ST_OMP_MASTER_TASKLOOP: return ST_OMP_END_MASTER_TASKLOOP;
+	case ST_OMP_MASTER_TASKLOOP_SIMD:
+	  return ST_OMP_END_MASTER_TASKLOOP_SIMD;
+	case ST_OMP_PARALLEL_MASKED_TASKLOOP:
+	  return ST_OMP_END_PARALLEL_MASKED_TASKLOOP;
+	case ST_OMP_PARALLEL_MASKED_TASKLOOP_SIMD:
+	  return ST_OMP_END_PARALLEL_MASKED_TASKLOOP_SIMD;
+	case ST_OMP_PARALLEL_MASTER_TASKLOOP:
+	  return ST_OMP_END_PARALLEL_MASTER_TASKLOOP;
+	case ST_OMP_PARALLEL_MASTER_TASKLOOP_SIMD:
+	  return ST_OMP_END_PARALLEL_MASTER_TASKLOOP_SIMD;
+	case ST_OMP_TEAMS_DISTRIBUTE:
+	  return ST_OMP_END_TEAMS_DISTRIBUTE;
+	case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
+	  return ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO;
+	case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
+	  return ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD;
+	case ST_OMP_TEAMS_DISTRIBUTE_SIMD:
+	  return ST_OMP_END_TEAMS_DISTRIBUTE_SIMD;
+	case ST_OMP_TEAMS_LOOP:
+	  return ST_OMP_END_TEAMS_LOOP;
+	case ST_OMP_TILE:
+	  return ST_OMP_END_TILE;
+	case ST_OMP_UNROLL:
+	  return ST_OMP_END_UNROLL;
+	default:
+	  break;
+	}
+    }
+
+  if (omp_structured_p)
+    {
+      switch (omp_st)
+	{
+	case ST_OMP_ALLOCATORS:
+	  return ST_OMP_END_ALLOCATORS;
+	case ST_OMP_ASSUME:
+	  return ST_OMP_END_ASSUME;
+	case ST_OMP_ATOMIC:
+	  return ST_OMP_END_ATOMIC;
+	case ST_OMP_DISPATCH:
+	  return ST_OMP_END_DISPATCH;
+	case ST_OMP_PARALLEL:
+	  return ST_OMP_END_PARALLEL;
+	case ST_OMP_PARALLEL_MASKED:
+	  return ST_OMP_END_PARALLEL_MASKED;
+	case ST_OMP_PARALLEL_MASTER:
+	  return ST_OMP_END_PARALLEL_MASTER;
+	case ST_OMP_PARALLEL_SECTIONS:
+	  return ST_OMP_END_PARALLEL_SECTIONS;
+	case ST_OMP_SCOPE:
+	  return ST_OMP_END_SCOPE;
+	case ST_OMP_SECTIONS:
+	  return ST_OMP_END_SECTIONS;
+	case ST_OMP_ORDERED:
+	  return ST_OMP_END_ORDERED;
+	case ST_OMP_CRITICAL:
+	  return ST_OMP_END_CRITICAL;
+	case ST_OMP_MASKED:
+	  return ST_OMP_END_MASKED;
+	case ST_OMP_MASTER:
+	  return ST_OMP_END_MASTER;
+	case ST_OMP_SINGLE:
+	  return ST_OMP_END_SINGLE;
+	case ST_OMP_TARGET:
+	  return ST_OMP_END_TARGET;
+	case ST_OMP_TARGET_DATA:
+	  return ST_OMP_END_TARGET_DATA;
+	case ST_OMP_TARGET_PARALLEL:
+	  return ST_OMP_END_TARGET_PARALLEL;
+	case ST_OMP_TARGET_TEAMS:
+	  return ST_OMP_END_TARGET_TEAMS;
+	case ST_OMP_TASK:
+	  return ST_OMP_END_TASK;
+	case ST_OMP_TASKGROUP:
+	  return ST_OMP_END_TASKGROUP;
+	case ST_OMP_TEAMS:
+	  return ST_OMP_END_TEAMS;
+	case ST_OMP_TEAMS_DISTRIBUTE:
+	  return ST_OMP_END_TEAMS_DISTRIBUTE;
+	case ST_OMP_DISTRIBUTE:
+	  return ST_OMP_END_DISTRIBUTE;
+	case ST_OMP_WORKSHARE:
+	  return ST_OMP_END_WORKSHARE;
+	case ST_OMP_PARALLEL_WORKSHARE:
+	  return ST_OMP_END_PARALLEL_WORKSHARE;
+	case ST_OMP_BEGIN_METADIRECTIVE:
+	  return ST_OMP_END_METADIRECTIVE;
+	default:
+	  break;
+	}
+    }
+
+  return ST_NONE;
+}
 
 /* Parse the statements of OpenMP do/parallel do.  */
 
@@ -5571,94 +5798,16 @@ parse_omp_do (gfc_statement omp_st, int nested)
 
   st = next_statement ();
 do_end:
-  gfc_statement omp_end_st = ST_OMP_END_DO;
-  switch (omp_st)
-    {
-    case ST_OMP_DISTRIBUTE: omp_end_st = ST_OMP_END_DISTRIBUTE; break;
-    case ST_OMP_DISTRIBUTE_PARALLEL_DO:
-      omp_end_st = ST_OMP_END_DISTRIBUTE_PARALLEL_DO;
-      break;
-    case ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD:
-      omp_end_st = ST_OMP_END_DISTRIBUTE_PARALLEL_DO_SIMD;
-      break;
-    case ST_OMP_DISTRIBUTE_SIMD:
-      omp_end_st = ST_OMP_END_DISTRIBUTE_SIMD;
-      break;
-    case ST_OMP_DO: omp_end_st = ST_OMP_END_DO; break;
-    case ST_OMP_DO_SIMD: omp_end_st = ST_OMP_END_DO_SIMD; break;
-    case ST_OMP_LOOP: omp_end_st = ST_OMP_END_LOOP; break;
-    case ST_OMP_PARALLEL_DO: omp_end_st = ST_OMP_END_PARALLEL_DO; break;
-    case ST_OMP_PARALLEL_DO_SIMD:
-      omp_end_st = ST_OMP_END_PARALLEL_DO_SIMD;
-      break;
-    case ST_OMP_PARALLEL_LOOP:
-      omp_end_st = ST_OMP_END_PARALLEL_LOOP;
-      break;
-    case ST_OMP_SIMD: omp_end_st = ST_OMP_END_SIMD; break;
-    case ST_OMP_TARGET_PARALLEL_DO:
-      omp_end_st = ST_OMP_END_TARGET_PARALLEL_DO;
-      break;
-    case ST_OMP_TARGET_PARALLEL_DO_SIMD:
-      omp_end_st = ST_OMP_END_TARGET_PARALLEL_DO_SIMD;
-      break;
-    case ST_OMP_TARGET_PARALLEL_LOOP:
-      omp_end_st = ST_OMP_END_TARGET_PARALLEL_LOOP;
-      break;
-    case ST_OMP_TARGET_SIMD: omp_end_st = ST_OMP_END_TARGET_SIMD; break;
-    case ST_OMP_TARGET_TEAMS_DISTRIBUTE:
-      omp_end_st = ST_OMP_END_TARGET_TEAMS_DISTRIBUTE;
-      break;
-    case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO:
-      omp_end_st = ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO;
-      break;
-    case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
-      omp_end_st = ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD;
-      break;
-    case ST_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD:
-      omp_end_st = ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_SIMD;
-      break;
-    case ST_OMP_TARGET_TEAMS_LOOP:
-      omp_end_st = ST_OMP_END_TARGET_TEAMS_LOOP;
-      break;
-    case ST_OMP_TASKLOOP: omp_end_st = ST_OMP_END_TASKLOOP; break;
-    case ST_OMP_TASKLOOP_SIMD: omp_end_st = ST_OMP_END_TASKLOOP_SIMD; break;
-    case ST_OMP_MASKED_TASKLOOP: omp_end_st = ST_OMP_END_MASKED_TASKLOOP; break;
-    case ST_OMP_MASKED_TASKLOOP_SIMD:
-      omp_end_st = ST_OMP_END_MASKED_TASKLOOP_SIMD;
-      break;
-    case ST_OMP_MASTER_TASKLOOP: omp_end_st = ST_OMP_END_MASTER_TASKLOOP; break;
-    case ST_OMP_MASTER_TASKLOOP_SIMD:
-      omp_end_st = ST_OMP_END_MASTER_TASKLOOP_SIMD;
-      break;
-    case ST_OMP_PARALLEL_MASKED_TASKLOOP:
-      omp_end_st = ST_OMP_END_PARALLEL_MASKED_TASKLOOP;
-      break;
-    case ST_OMP_PARALLEL_MASKED_TASKLOOP_SIMD:
-      omp_end_st = ST_OMP_END_PARALLEL_MASKED_TASKLOOP_SIMD;
-      break;
-    case ST_OMP_PARALLEL_MASTER_TASKLOOP:
-      omp_end_st = ST_OMP_END_PARALLEL_MASTER_TASKLOOP;
-      break;
-    case ST_OMP_PARALLEL_MASTER_TASKLOOP_SIMD:
-      omp_end_st = ST_OMP_END_PARALLEL_MASTER_TASKLOOP_SIMD;
-      break;
-    case ST_OMP_TEAMS_DISTRIBUTE:
-      omp_end_st = ST_OMP_END_TEAMS_DISTRIBUTE;
-      break;
-    case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
-      omp_end_st = ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO;
-      break;
-    case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
-      omp_end_st = ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD;
-      break;
-    case ST_OMP_TEAMS_DISTRIBUTE_SIMD:
-      omp_end_st = ST_OMP_END_TEAMS_DISTRIBUTE_SIMD;
-      break;
-    case ST_OMP_TEAMS_LOOP: omp_end_st = ST_OMP_END_TEAMS_LOOP; break;
-    case ST_OMP_TILE: omp_end_st = ST_OMP_END_TILE; break;
-    case ST_OMP_UNROLL: omp_end_st = ST_OMP_END_UNROLL; break;
-    default: gcc_unreachable ();
-    }
+  gfc_statement omp_end_st = gfc_omp_end_stmt (omp_st, true, false);
+  if (omp_st == ST_NONE)
+    gcc_unreachable ();
+
+  /* If handling a metadirective variant, treat 'omp end metadirective'
+     as the expected end statement for the current construct.  */
+  if (st == ST_OMP_END_METADIRECTIVE
+      && gfc_state_stack->state == COMP_OMP_BEGIN_METADIRECTIVE)
+    st = omp_end_st;
+
   if (st == omp_end_st)
     {
       if (new_st.op == EXEC_OMP_END_NOWAIT)
@@ -5693,7 +5842,10 @@ parse_omp_oacc_atomic (bool omp_p)
   if (omp_p)
     {
       st_atomic = ST_OMP_ATOMIC;
-      st_end_atomic = ST_OMP_END_ATOMIC;
+      if (gfc_state_stack->state == COMP_OMP_BEGIN_METADIRECTIVE)
+	st_end_atomic = ST_OMP_END_METADIRECTIVE;
+      else
+	st_end_atomic = ST_OMP_END_ATOMIC;
     }
   else
     {
@@ -5944,7 +6096,10 @@ parse_openmp_allocate_block (gfc_statement omp_st)
   accept_statement (st);
   pop_state ();
   st = next_statement ();
-  if (omp_st == ST_OMP_ALLOCATORS && st == ST_OMP_END_ALLOCATORS)
+  if (omp_st == ST_OMP_ALLOCATORS
+      && (st == ST_OMP_END_ALLOCATORS
+	  || (st == ST_OMP_END_METADIRECTIVE
+	      && gfc_state_stack->state == COMP_OMP_BEGIN_METADIRECTIVE)))
     {
       accept_statement (st);
       st = next_statement ();
@@ -5970,80 +6125,15 @@ parse_omp_structured_block (gfc_statement omp_st, bool workshare_stmts_only)
   np->op = cp->op;
   np->block = NULL;
 
-  switch (omp_st)
-    {
-    case ST_OMP_ASSUME:
-      omp_end_st = ST_OMP_END_ASSUME;
-      break;
-    case ST_OMP_PARALLEL:
-      omp_end_st = ST_OMP_END_PARALLEL;
-      break;
-    case ST_OMP_PARALLEL_MASKED:
-      omp_end_st = ST_OMP_END_PARALLEL_MASKED;
-      break;
-    case ST_OMP_PARALLEL_MASTER:
-      omp_end_st = ST_OMP_END_PARALLEL_MASTER;
-      break;
-    case ST_OMP_PARALLEL_SECTIONS:
-      omp_end_st = ST_OMP_END_PARALLEL_SECTIONS;
-      break;
-    case ST_OMP_SCOPE:
-      omp_end_st = ST_OMP_END_SCOPE;
-      break;
-    case ST_OMP_SECTIONS:
-      omp_end_st = ST_OMP_END_SECTIONS;
-      break;
-    case ST_OMP_ORDERED:
-      omp_end_st = ST_OMP_END_ORDERED;
-      break;
-    case ST_OMP_CRITICAL:
-      omp_end_st = ST_OMP_END_CRITICAL;
-      break;
-    case ST_OMP_MASKED:
-      omp_end_st = ST_OMP_END_MASKED;
-      break;
-    case ST_OMP_MASTER:
-      omp_end_st = ST_OMP_END_MASTER;
-      break;
-    case ST_OMP_SINGLE:
-      omp_end_st = ST_OMP_END_SINGLE;
-      break;
-    case ST_OMP_TARGET:
-      omp_end_st = ST_OMP_END_TARGET;
-      break;
-    case ST_OMP_TARGET_DATA:
-      omp_end_st = ST_OMP_END_TARGET_DATA;
-      break;
-    case ST_OMP_TARGET_PARALLEL:
-      omp_end_st = ST_OMP_END_TARGET_PARALLEL;
-      break;
-    case ST_OMP_TARGET_TEAMS:
-      omp_end_st = ST_OMP_END_TARGET_TEAMS;
-      break;
-    case ST_OMP_TASK:
-      omp_end_st = ST_OMP_END_TASK;
-      break;
-    case ST_OMP_TASKGROUP:
-      omp_end_st = ST_OMP_END_TASKGROUP;
-      break;
-    case ST_OMP_TEAMS:
-      omp_end_st = ST_OMP_END_TEAMS;
-      break;
-    case ST_OMP_TEAMS_DISTRIBUTE:
-      omp_end_st = ST_OMP_END_TEAMS_DISTRIBUTE;
-      break;
-    case ST_OMP_DISTRIBUTE:
-      omp_end_st = ST_OMP_END_DISTRIBUTE;
-      break;
-    case ST_OMP_WORKSHARE:
-      omp_end_st = ST_OMP_END_WORKSHARE;
-      break;
-    case ST_OMP_PARALLEL_WORKSHARE:
-      omp_end_st = ST_OMP_END_PARALLEL_WORKSHARE;
-      break;
-    default:
-      gcc_unreachable ();
-    }
+  omp_end_st = gfc_omp_end_stmt (omp_st, false, true);
+  if (omp_end_st == ST_NONE)
+    gcc_unreachable ();
+
+  /* If handling a metadirective variant, treat 'omp end metadirective'
+     as the expected end statement for the current construct.  */
+  if (gfc_state_stack->previous != NULL
+      && gfc_state_stack->previous->state == COMP_OMP_BEGIN_METADIRECTIVE)
+    omp_end_st = ST_OMP_END_METADIRECTIVE;
 
   bool block_construct = false;
   gfc_namespace *my_ns = NULL;
@@ -6089,11 +6179,13 @@ parse_omp_structured_block (gfc_statement omp_st, bool workshare_stmts_only)
       case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
       case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
       case ST_OMP_TEAMS_LOOP:
+      case ST_OMP_METADIRECTIVE:
+      case ST_OMP_BEGIN_METADIRECTIVE:
 	{
 	  gfc_state_data *stk = gfc_state_stack->previous;
 	  if (stk->state == COMP_OMP_STRICTLY_STRUCTURED_BLOCK)
 	    stk = stk->previous;
-	  stk->tail->ext.omp_clauses->target_first_st_is_teams = true;
+	  stk->tail->ext.omp_clauses->target_first_st_is_teams_or_meta = true;
 	  break;
 	}
       default:
@@ -6266,7 +6358,6 @@ parse_omp_structured_block (gfc_statement omp_st, bool workshare_stmts_only)
   return st;
 }
 
-
 static gfc_statement
 parse_omp_dispatch (void)
 {
@@ -6284,7 +6375,10 @@ parse_omp_dispatch (void)
 
   st = next_statement ();
   if (st == ST_NONE)
-    return st;
+    {
+      pop_state ();
+      return st;
+    }
   if (st == ST_CALL || st == ST_ASSIGNMENT)
     accept_statement (st);
   else
@@ -6295,7 +6389,9 @@ parse_omp_dispatch (void)
     }
   pop_state ();
   st = next_statement ();
-  if (st == ST_OMP_END_DISPATCH)
+  if (st == ST_OMP_END_DISPATCH
+      || (st == ST_OMP_END_METADIRECTIVE
+	  && gfc_state_stack->state == COMP_OMP_BEGIN_METADIRECTIVE))
     {
       if (cp->ext.omp_clauses->nowait && new_st.ext.omp_bool)
 	gfc_error_now ("Duplicated NOWAIT clause on !$OMP DISPATCH and !$OMP "
@@ -6307,6 +6403,98 @@ parse_omp_dispatch (void)
   return st;
 }
 
+static gfc_statement
+parse_omp_metadirective_body (gfc_statement omp_st)
+{
+  gfc_omp_variant *variant
+    = new_st.ext.omp_variants;
+  locus body_locus = gfc_current_locus;
+
+  accept_statement (omp_st);
+
+  gfc_statement next_st = ST_NONE;
+
+  while (variant)
+    {
+      gfc_current_locus = body_locus;
+      gfc_state_data s;
+      bool workshare_p
+	= (variant->stmt == ST_OMP_WORKSHARE
+	   || variant->stmt == ST_OMP_PARALLEL_WORKSHARE);
+      enum gfc_compile_state new_state
+	= (omp_st == ST_OMP_METADIRECTIVE
+	   ? COMP_OMP_METADIRECTIVE : COMP_OMP_BEGIN_METADIRECTIVE);
+
+      new_st = *variant->code;
+      push_state (&s, new_state, NULL);
+
+      gfc_statement st;
+      bool old_in_metadirective_body = gfc_in_omp_metadirective_body;
+      gfc_in_omp_metadirective_body = true;
+
+      gfc_omp_metadirective_region_count++;
+      switch (variant->stmt)
+	{
+	case_omp_structured_block:
+	  st = parse_omp_structured_block (variant->stmt, workshare_p);
+	  break;
+	case_omp_do:
+	  st = parse_omp_do (variant->stmt, 0);
+	  /* TODO: Does st == ST_IMPLIED_ENDDO need special handling?  */
+	  break;
+	case ST_OMP_ALLOCATORS:
+	  st = parse_openmp_allocate_block (variant->stmt);
+	  break;
+	case ST_OMP_ATOMIC:
+	  st = parse_omp_oacc_atomic (true);
+	  break;
+	case ST_OMP_DISPATCH:
+	  st = parse_omp_dispatch ();
+	  break;
+	default:
+	  accept_statement (variant->stmt);
+	  st = parse_executable (next_statement ());
+	  break;
+	}
+
+      if (gfc_state_stack->state == COMP_OMP_METADIRECTIVE
+	  && startswith (gfc_ascii_statement (st), "!$OMP END "))
+	{
+	  for (gfc_state_data *p = gfc_state_stack; p; p = p->previous)
+	    if (p->state == COMP_OMP_STRUCTURED_BLOCK
+		|| p->state == COMP_OMP_BEGIN_METADIRECTIVE)
+	      goto finish;
+	  gfc_error ("Unexpected %s statement in OMP METADIRECTIVE "
+		     "block at %C",
+		     gfc_ascii_statement (st));
+	  reject_statement ();
+	  st = next_statement ();
+	}
+    finish:
+
+      gfc_in_omp_metadirective_body = old_in_metadirective_body;
+
+      if (gfc_state_stack->head)
+	*variant->code = *gfc_state_stack->head;
+      pop_state ();
+
+      gfc_commit_symbols ();
+      gfc_warning_check ();
+      if (variant->next)
+	gfc_clear_new_st ();
+
+      /* Sanity-check that each variant finishes parsing at the same place.  */
+      if (next_st == ST_NONE)
+	next_st = st;
+      else
+	gcc_assert (st == next_st);
+
+      variant = variant->next;
+    }
+
+  return next_st;
+}
+
 /* Accept a series of executable statements.  We return the first
    statement that doesn't fit to the caller.  Any block statements are
    passed on to the correct handler, which usually passes the buck
@@ -6316,6 +6504,7 @@ static gfc_statement
 parse_executable (gfc_statement st)
 {
   int close_flag;
+  bool one_stmt_p = false;
   in_exec_part = true;
 
   if (st == ST_NONE)
@@ -6323,6 +6512,12 @@ parse_executable (gfc_statement st)
 
   for (;;)
     {
+      /* Only parse one statement for the form of metadirective without
+	 an explicit begin..end.  */
+      if (gfc_state_stack->state == COMP_OMP_METADIRECTIVE && one_stmt_p)
+	return st;
+      one_stmt_p = true;
+
       close_flag = check_do_closure ();
       if (close_flag)
 	switch (st)
@@ -6432,70 +6627,13 @@ parse_executable (gfc_statement st)
 	  st = parse_openmp_allocate_block (st);
 	  continue;
 
-	case ST_OMP_ASSUME:
-	case ST_OMP_PARALLEL:
-	case ST_OMP_PARALLEL_MASKED:
-	case ST_OMP_PARALLEL_MASTER:
-	case ST_OMP_PARALLEL_SECTIONS:
-	case ST_OMP_ORDERED:
-	case ST_OMP_CRITICAL:
-	case ST_OMP_MASKED:
-	case ST_OMP_MASTER:
-	case ST_OMP_SCOPE:
-	case ST_OMP_SECTIONS:
-	case ST_OMP_SINGLE:
-	case ST_OMP_TARGET:
-	case ST_OMP_TARGET_DATA:
-	case ST_OMP_TARGET_PARALLEL:
-	case ST_OMP_TARGET_TEAMS:
-	case ST_OMP_TEAMS:
-	case ST_OMP_TASK:
-	case ST_OMP_TASKGROUP:
-	  st = parse_omp_structured_block (st, false);
+	case_omp_structured_block:
+	  st = parse_omp_structured_block (st,
+					   st == ST_OMP_WORKSHARE
+					   || st == ST_OMP_PARALLEL_WORKSHARE);
 	  continue;
 
-	case ST_OMP_WORKSHARE:
-	case ST_OMP_PARALLEL_WORKSHARE:
-	  st = parse_omp_structured_block (st, true);
-	  continue;
-
-	case ST_OMP_DISTRIBUTE:
-	case ST_OMP_DISTRIBUTE_PARALLEL_DO:
-	case ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD:
-	case ST_OMP_DISTRIBUTE_SIMD:
-	case ST_OMP_DO:
-	case ST_OMP_DO_SIMD:
-	case ST_OMP_LOOP:
-	case ST_OMP_PARALLEL_DO:
-	case ST_OMP_PARALLEL_DO_SIMD:
-	case ST_OMP_PARALLEL_LOOP:
-	case ST_OMP_PARALLEL_MASKED_TASKLOOP:
-	case ST_OMP_PARALLEL_MASKED_TASKLOOP_SIMD:
-	case ST_OMP_PARALLEL_MASTER_TASKLOOP:
-	case ST_OMP_PARALLEL_MASTER_TASKLOOP_SIMD:
-	case ST_OMP_MASKED_TASKLOOP:
-	case ST_OMP_MASKED_TASKLOOP_SIMD:
-	case ST_OMP_MASTER_TASKLOOP:
-	case ST_OMP_MASTER_TASKLOOP_SIMD:
-	case ST_OMP_SIMD:
-	case ST_OMP_TARGET_PARALLEL_DO:
-	case ST_OMP_TARGET_PARALLEL_DO_SIMD:
-	case ST_OMP_TARGET_PARALLEL_LOOP:
-	case ST_OMP_TARGET_SIMD:
-	case ST_OMP_TARGET_TEAMS_DISTRIBUTE:
-	case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO:
-	case ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
-	case ST_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD:
-	case ST_OMP_TARGET_TEAMS_LOOP:
-	case ST_OMP_TASKLOOP:
-	case ST_OMP_TASKLOOP_SIMD:
-	case ST_OMP_TEAMS_DISTRIBUTE:
-	case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
-	case ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
-	case ST_OMP_TEAMS_DISTRIBUTE_SIMD:
-	case ST_OMP_TEAMS_LOOP:
-	case ST_OMP_TILE:
-	case ST_OMP_UNROLL:
+	case_omp_do:
 	  st = parse_omp_do (st, 0);
 	  if (st == ST_IMPLIED_ENDDO)
 	    return st;
@@ -6513,6 +6651,17 @@ parse_executable (gfc_statement st)
 	  st = parse_omp_dispatch ();
 	  continue;
 
+	case ST_OMP_METADIRECTIVE:
+	case ST_OMP_BEGIN_METADIRECTIVE:
+	  st = parse_omp_metadirective_body (st);
+	  continue;
+
+	case ST_OMP_END_METADIRECTIVE:
+	  if (gfc_state_stack->state == COMP_OMP_BEGIN_METADIRECTIVE)
+	    return next_statement ();
+	  else
+	    return st;
+
 	default:
 	  return st;
 	}
@@ -7278,6 +7427,10 @@ gfc_parse_file (void)
 
   gfc_statement_label = NULL;
 
+  gfc_omp_metadirective_region_count = 0;
+  gfc_in_omp_metadirective_body = false;
+  gfc_matching_omp_context_selector = false;
+
   if (setjmp (eof_buf))
     return false;	/* Come here on unexpected EOF */
 
@@ -7589,3 +7742,16 @@ is_oacc (gfc_state_data *sd)
       return false;
     }
 }
+
+/* Return true if ST is a declarative OpenMP statement.  */
+bool
+is_omp_declarative_stmt (gfc_statement st)
+{
+  switch (st)
+    {
+      case_omp_decl:
+	return true;
+      default:
+	return false;
+    }
+}
diff --git a/gcc/fortran/parse.h b/gcc/fortran/parse.h
index 448fa0fe12c8f2d432cd470523cff5db828fea39..722e94cef5410129429a7fdce6d52f3f7452e2d4 100644
--- a/gcc/fortran/parse.h
+++ b/gcc/fortran/parse.h
@@ -31,7 +31,8 @@ enum gfc_compile_state
   COMP_STRUCTURE, COMP_UNION, COMP_MAP,
   COMP_DO, COMP_SELECT, COMP_FORALL, COMP_WHERE, COMP_CONTAINS, COMP_ENUM,
   COMP_SELECT_TYPE, COMP_SELECT_RANK, COMP_OMP_STRUCTURED_BLOCK, COMP_CRITICAL,
-  COMP_DO_CONCURRENT, COMP_OMP_STRICTLY_STRUCTURED_BLOCK
+  COMP_DO_CONCURRENT, COMP_OMP_STRICTLY_STRUCTURED_BLOCK,
+  COMP_OMP_METADIRECTIVE, COMP_OMP_BEGIN_METADIRECTIVE
 };
 
 /* Stack element for the current compilation state.  These structures
@@ -67,10 +68,15 @@ bool gfc_check_do_variable (gfc_symtree *);
 bool gfc_find_state (gfc_compile_state);
 gfc_state_data *gfc_enclosing_unit (gfc_compile_state *);
 const char *gfc_ascii_statement (gfc_statement, bool strip_sentinel = false) ;
+gfc_statement gfc_omp_end_stmt (gfc_statement, bool = true, bool = true);
 match gfc_match_enum (void);
 match gfc_match_enumerator_def (void);
 void gfc_free_enum_history (void);
 extern bool gfc_matching_function;
+extern bool gfc_matching_omp_context_selector;
+extern bool gfc_in_omp_metadirective_body;
+extern int gfc_omp_metadirective_region_count;
+
 match gfc_match_prefix (gfc_typespec *);
 bool is_oacc (gfc_state_data *);
 #endif  /* GFC_PARSE_H  */
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 124f4ac4edcdca5406fd6b0e0e24cde95c4e5485..c9736db908fe75619b00549c79f5cdf0c221f2f9 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -1049,7 +1049,7 @@ resolve_common_vars (gfc_common_head *common_block, bool named_common)
 static void
 resolve_common_blocks (gfc_symtree *common_root)
 {
-  gfc_symbol *sym;
+  gfc_symbol *sym = NULL;
   gfc_gsymbol * gsym;
 
   if (common_root == NULL)
@@ -4310,19 +4310,6 @@ resolve_operator (gfc_expr *e)
       return false;
 
     case INTRINSIC_POWER:
-
-      if (flag_unsigned)
-	{
-	  if (op1->ts.type == BT_UNSIGNED || op2->ts.type == BT_UNSIGNED)
-	    {
-	      CHECK_INTERFACES
-	      gfc_error ("Exponentiation not valid at %L for %s and %s",
-			 &e->where, gfc_typename (op1), gfc_typename (op2));
-	      return false;
-	    }
-	}
-      gcc_fallthrough ();
-
     case INTRINSIC_PLUS:
     case INTRINSIC_MINUS:
     case INTRINSIC_TIMES:
@@ -13383,7 +13370,12 @@ generate_component_assignments (gfc_code **code, gfc_namespace *ns)
       tmp_expr = get_temp_from_expr ((*code)->expr1, ns);
       if (tmp_expr->symtree->n.sym->attr.pointer)
 	{
+	  /* Use allocate on assignment for the sake of simplicity. The
+	     temporary must not take on the optional attribute. Assume
+	     that the assignment is guarded by a PRESENT condition if the
+	     lhs is optional.  */
 	  tmp_expr->symtree->n.sym->attr.pointer = 0;
+	  tmp_expr->symtree->n.sym->attr.optional = 0;
 	  tmp_expr->symtree->n.sym->attr.allocatable = 1;
 	}
       this_code = build_assignment (EXEC_ASSIGN,
@@ -13801,6 +13793,11 @@ gfc_resolve_code (gfc_code *code, gfc_namespace *ns)
 	  gfc_resolve_forall (code, ns, forall_save);
 	  forall_flag = 2;
 	}
+      else if (code->op == EXEC_OMP_METADIRECTIVE)
+	for (gfc_omp_variant *variant
+	       = code->ext.omp_variants;
+	     variant; variant = variant->next)
+	  gfc_resolve_code (variant->code, ns);
       else if (code->block)
 	{
 	  omp_workshare_save = -1;
@@ -14374,6 +14371,7 @@ start:
 	case EXEC_OMP_MASKED:
 	case EXEC_OMP_MASKED_TASKLOOP:
 	case EXEC_OMP_MASKED_TASKLOOP_SIMD:
+	case EXEC_OMP_METADIRECTIVE:
 	case EXEC_OMP_ORDERED:
 	case EXEC_OMP_SCAN:
 	case EXEC_OMP_SCOPE:
@@ -17682,6 +17680,12 @@ resolve_symbol (gfc_symbol *sym)
 	  && sym->attr.if_source == IFSRC_UNKNOWN
 	  && sym->ts.type == BT_UNKNOWN))
     {
+      /* A symbol in a common block might not have been resolved yet properly.
+	 Do not try to find an interface with the same name.  */
+      if (sym->attr.flavor == FL_UNKNOWN && !sym->attr.intrinsic
+	  && !sym->attr.generic && !sym->attr.external
+	  && sym->attr.in_common)
+	goto skip_interfaces;
 
     /* If we find that a flavorless symbol is an interface in one of the
        parent namespaces, find its symtree in this namespace, free the
@@ -17705,6 +17709,7 @@ resolve_symbol (gfc_symbol *sym)
 	    }
 	}
 
+skip_interfaces:
       /* Otherwise give it a flavor according to such attributes as
 	 it has.  */
       if (sym->attr.flavor == FL_UNKNOWN && sym->attr.external == 0
diff --git a/gcc/fortran/st.cc b/gcc/fortran/st.cc
index 509d28c23bdab44b322bd6f5db0e3926e49a7825..f7f67b18b671ae5970b51b919d5b0e9c1e73fc3d 100644
--- a/gcc/fortran/st.cc
+++ b/gcc/fortran/st.cc
@@ -306,6 +306,10 @@ gfc_free_statement (gfc_code *p)
     case EXEC_OMP_TASKYIELD:
       break;
 
+    case EXEC_OMP_METADIRECTIVE:
+      gfc_free_omp_variants (p->ext.omp_variants);
+      break;
+
     default:
       gfc_internal_error ("gfc_free_statement(): Bad statement");
     }
diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index e6535fa184375b56ead44a5c4eae8d697c3a2830..c6894810bce7b9bb1545b7b4347faf1863498e95 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -2697,10 +2697,13 @@ free_components (gfc_component *p)
 static int
 compare_st_labels (void *a1, void *b1)
 {
-  int a = ((gfc_st_label *) a1)->value;
-  int b = ((gfc_st_label *) b1)->value;
+  gfc_st_label *a = (gfc_st_label *) a1;
+  gfc_st_label *b = (gfc_st_label *) b1;
 
-  return (b - a);
+  if (a->omp_region == b->omp_region)
+    return b->value - a->value;
+  else
+    return b->omp_region - a->omp_region;
 }
 
 
@@ -2750,6 +2753,8 @@ gfc_get_st_label (int labelno)
 {
   gfc_st_label *lp;
   gfc_namespace *ns;
+  int omp_region = (gfc_in_omp_metadirective_body
+		    ? gfc_omp_metadirective_region_count : 0);
 
   if (gfc_current_state () == COMP_DERIVED)
     ns = gfc_current_block ()->f2k_derived;
@@ -2766,10 +2771,16 @@ gfc_get_st_label (int labelno)
   lp = ns->st_labels;
   while (lp)
     {
-      if (lp->value == labelno)
-	return lp;
-
-      if (lp->value < labelno)
+      if (lp->omp_region == omp_region)
+	{
+	  if (lp->value == labelno)
+	    return lp;
+	  if (lp->value < labelno)
+	    lp = lp->left;
+	  else
+	    lp = lp->right;
+	}
+      else if (lp->omp_region < omp_region)
 	lp = lp->left;
       else
 	lp = lp->right;
@@ -2781,6 +2792,7 @@ gfc_get_st_label (int labelno)
   lp->defined = ST_LABEL_UNKNOWN;
   lp->referenced = ST_LABEL_UNKNOWN;
   lp->ns = ns;
+  lp->omp_region = omp_region;
 
   gfc_insert_bbt (&ns->st_labels, lp, compare_st_labels);
 
diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 97bb0a4185811efc06919d018f0dc8509d5352b7..017f184f179421123dcc311ed7a069b75e56c4b7 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -189,6 +189,8 @@ tree gfor_fndecl_caf_random_init;
    trans-intrinsic.cc.  */
 
 gfc_powdecl_list gfor_fndecl_math_powi[4][3];
+tree gfor_fndecl_unsigned_pow_list[5][5];
+
 tree gfor_fndecl_math_ishftc4;
 tree gfor_fndecl_math_ishftc8;
 tree gfor_fndecl_math_ishftc16;
@@ -342,7 +344,10 @@ gfc_get_label_decl (gfc_st_label * lp)
       gcc_assert (lp != NULL && lp->value <= MAX_LABEL_VALUE);
 
       /* Build a mangled name for the label.  */
-      sprintf (label_name, "__label_%.6d", lp->value);
+      if (lp->omp_region)
+	sprintf (label_name, "__label_%d_%.6d", lp->omp_region, lp->value);
+      else
+	sprintf (label_name, "__label_%.6d", lp->value);
 
       /* Build the LABEL_DECL node.  */
       label_decl = gfc_build_label_decl (get_identifier (label_name));
@@ -3743,8 +3748,10 @@ gfc_build_intrinsic_function_decls (void)
     int rkind, ikind, jkind;
 #define NIKINDS 3
 #define NRKINDS 4
-    static int ikinds[NIKINDS] = {4, 8, 16};
-    static int rkinds[NRKINDS] = {4, 8, 10, 16};
+#define NUKINDS 5
+    static const int ikinds[NIKINDS] = {4, 8, 16};
+    static const int rkinds[NRKINDS] = {4, 8, 10, 16};
+    static const int ukinds[NUKINDS] = {1, 2, 4, 8, 16};
     char name[PREFIX_LEN + 12]; /* _gfortran_pow_?n_?n */
 
     for (ikind=0; ikind < NIKINDS; ikind++)
@@ -3794,9 +3801,29 @@ gfc_build_intrinsic_function_decls (void)
 		TREE_NOTHROW (gfor_fndecl_math_powi[rkind][ikind].cmplx) = 1;
 	      }
 	  }
+	/* For unsigned types, we have every power for every type.  */
+	for (int base = 0; base < NUKINDS; base++)
+	  {
+	    tree base_type = gfc_get_unsigned_type (ukinds[base]);
+	    for (int expon = 0; expon < NUKINDS; expon++)
+	      {
+		tree expon_type = gfc_get_unsigned_type (ukinds[base]);
+		if (base_type && expon_type)
+		  {
+		    sprintf (name, PREFIX("pow_m%d_m%d"), ukinds[base],
+			 ukinds[expon]);
+		    gfor_fndecl_unsigned_pow_list [base][expon] =
+		      gfc_build_library_function_decl (get_identifier (name),
+			 base_type, 2, base_type, expon_type);
+		    TREE_READONLY (gfor_fndecl_unsigned_pow_list[base][expon]) = 1;
+		    TREE_NOTHROW (gfor_fndecl_unsigned_pow_list[base][expon]) = 1;
+		  }
+	      }
+	  }
       }
 #undef NIKINDS
 #undef NRKINDS
+#undef NUKINDS
   }
 
   gfor_fndecl_math_ishftc4 = gfc_build_library_function_decl (
@@ -8295,6 +8322,26 @@ gfc_generate_constructors (void)
 #endif
 }
 
+
+/* Helper function for checking of variables declared in a BLOCK DATA program
+   unit.  */
+
+static void
+check_block_data_decls (gfc_symbol * sym)
+{
+  if (warn_unused_variable
+      && sym->attr.flavor == FL_VARIABLE
+      && !sym->attr.in_common
+      && !sym->attr.artificial)
+    {
+      gfc_warning (OPT_Wunused_variable,
+		   "Symbol %qs at %L is declared in a BLOCK DATA "
+		   "program unit but is not in a COMMON block",
+		   sym->name, &sym->declared_at);
+    }
+}
+
+
 /* Translates a BLOCK DATA program unit. This means emitting the
    commons contained therein plus their initializations. We also emit
    a globally visible symbol to make sure that each BLOCK DATA program
@@ -8315,6 +8362,9 @@ gfc_generate_block_data (gfc_namespace * ns)
   /* Process the DATA statements.  */
   gfc_trans_common (ns);
 
+  /* Check for variables declared in BLOCK DATA but not used in COMMON.  */
+  gfc_traverse_ns (ns, check_block_data_decls);
+
   /* Create a global symbol with the mane of the block data.  This is to
      generate linker errors if the same name is used twice.  It is never
      really used.  */
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 78caf1f8996c94f3d803cde09c8f76194b73fada..f923aeb946051305f109f7c7dba481a8e5d8dfad 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -3595,8 +3595,93 @@ gfc_conv_cst_int_power (gfc_se * se, tree lhs, tree rhs)
   return 1;
 }
 
+/* Convert lhs**rhs, for constant rhs, when both are unsigned.
+   Method:
+   if (rhs == 0)      ! Checked here.
+     return 1;
+   if (lhs & 1 == 1)  ! odd_cnd
+     {
+       if (bit_size(rhs) < bit_size(lhs))  ! Checked here.
+	 return lhs ** rhs;
+
+       mask = (1 < bit_size(a) - 1) / 2;
+       return lhs ** (n & rhs);
+     }
+   if (rhs > bit_size(lhs))  ! Checked here.
+     return 0;
+
+   return lhs ** rhs;
+*/
+
+static int
+gfc_conv_cst_uint_power (gfc_se * se, tree lhs, tree rhs)
+{
+  tree type = TREE_TYPE (lhs);
+  tree tmp, is_odd, odd_branch, even_branch;
+  unsigned HOST_WIDE_INT lhs_prec, rhs_prec;
+  wi::tree_to_wide_ref wrhs = wi::to_wide (rhs);
+  unsigned HOST_WIDE_INT n, n_odd;
+  tree vartmp_odd[POWI_TABLE_SIZE], vartmp_even[POWI_TABLE_SIZE];
+
+  /* Anything ** 0 is one.  */
+  if (tree_int_cst_sgn (rhs) == 0)
+    {
+      se->expr = build_int_cst (type, 1);
+      return 1;
+    }
+
+  if (!wi::fits_shwi_p (wrhs))
+    return 0;
+
+  n = wrhs.to_uhwi ();
+
+  /* tmp = a & 1; . */
+  tmp = fold_build2_loc (input_location, BIT_AND_EXPR, type,
+			 lhs, build_int_cst (type, 1));
+  is_odd = fold_build2_loc (input_location, EQ_EXPR, logical_type_node,
+			    tmp, build_int_cst (type, 1));
+
+  lhs_prec = TYPE_PRECISION (type);
+  rhs_prec = TYPE_PRECISION (TREE_TYPE(rhs));
 
-/* Power op (**).  Constant integer exponent has special handling.  */
+  if (rhs_prec >= lhs_prec)
+    {
+      unsigned HOST_WIDE_INT mask;
+      mask = (((unsigned HOST_WIDE_INT) 1) << (lhs_prec - 1)) - 1;
+      n_odd = n & mask;
+    }
+  else
+    n_odd = n;
+
+  memset (vartmp_odd, 0, sizeof (vartmp_odd));
+  vartmp_odd[0] = build_int_cst(type, 1);
+  vartmp_odd[1] = lhs;
+  odd_branch = gfc_conv_powi (se, n_odd, vartmp_odd);
+  even_branch = NULL_TREE;
+
+  if (n > lhs_prec)
+    even_branch = build_int_cst (type, 0);
+  else
+    {
+      if (n_odd != n)
+	{
+	  memset (vartmp_even, 0, sizeof (vartmp_even));
+	  vartmp_even[0] = build_int_cst(type, 1);
+	  vartmp_even[1] = lhs;
+	  even_branch = gfc_conv_powi (se, n, vartmp_even);
+	}
+    }
+  if (even_branch != NULL_TREE)
+    se->expr = fold_build3_loc (input_location, COND_EXPR, type, is_odd,
+				odd_branch, even_branch);
+  else
+    se->expr = odd_branch;
+
+  return 1;
+}
+
+/* Power op (**).  Constant integer exponent and powers of 2 have special
+   handling.  */
 
 static void
 gfc_conv_power_op (gfc_se * se, gfc_expr * expr)
@@ -3618,13 +3703,29 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr)
   gfc_conv_expr_val (&rse, expr->value.op.op2);
   gfc_add_block_to_block (&se->pre, &rse.pre);
 
-  if (expr->value.op.op2->ts.type == BT_INTEGER
+  if (expr->value.op.op2->expr_type == EXPR_CONSTANT)
+    {
+      if (expr->value.op.op2->ts.type == BT_INTEGER)
+	{
+	  if (gfc_conv_cst_int_power (se, lse.expr, rse.expr))
+	    return;
+	}
+      else if (expr->value.op.op2->ts.type == BT_UNSIGNED)
+	{
+	  if (gfc_conv_cst_uint_power (se, lse.expr, rse.expr))
+	    return;
+	}
+    }
+
+  if ((expr->value.op.op2->ts.type == BT_INTEGER
+       || expr->value.op.op2->ts.type == BT_UNSIGNED)
       && expr->value.op.op2->expr_type == EXPR_CONSTANT)
     if (gfc_conv_cst_int_power (se, lse.expr, rse.expr))
       return;
 
   if (INTEGER_CST_P (lse.expr)
-      && TREE_CODE (TREE_TYPE (rse.expr)) == INTEGER_TYPE)
+      && TREE_CODE (TREE_TYPE (rse.expr)) == INTEGER_TYPE
+      && expr->value.op.op2->ts.type == BT_INTEGER)
     {
       wi::tree_to_wide_ref wlhs = wi::to_wide (lse.expr);
       HOST_WIDE_INT v;
@@ -3724,6 +3825,49 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr)
 	  return;
 	}
     }
+  /* Handle unsigned separate from signed above, things would be too
+     complicated otherwise.  */
+
+  if (INTEGER_CST_P (lse.expr) && expr->value.op.op1->ts.type == BT_UNSIGNED)
+    {
+      gfc_expr * op1 = expr->value.op.op1;
+      tree type;
+
+      type = TREE_TYPE (lse.expr);
+
+      if (mpz_cmp_ui (op1->value.integer, 1) == 0)
+	{
+	  /* 1**something is always 1.  */
+	  se->expr = build_int_cst (type, 1);
+	  return;
+	}
+
+      /* Simplify 2u**x to a shift, with the value set to zero if it falls
+       outside the range.  */
+      if (mpz_popcount (op1->value.integer) == 1)
+	{
+	  tree prec_m1, lim, shift, lshift, cond, tmp;
+	  tree rtype = TREE_TYPE (rse.expr);
+	  int e = mpz_scan1 (op1->value.integer, 0);
+
+	  shift = fold_build2_loc (input_location, MULT_EXPR,
+				   rtype, build_int_cst (rtype, e),
+				   rse.expr);
+	  lshift = fold_build2_loc (input_location, LSHIFT_EXPR, type,
+				    build_int_cst (type, 1), shift);
+	  prec_m1 = fold_build2_loc (input_location, MINUS_EXPR, rtype,
+				     build_int_cst (rtype, TYPE_PRECISION (type)),
+				     build_int_cst (rtype, 1));
+	  lim = fold_build2_loc (input_location, TRUNC_DIV_EXPR, rtype,
+				 prec_m1, build_int_cst (rtype, e));
+	  cond = fold_build2_loc (input_location, GT_EXPR, logical_type_node,
+				  rse.expr, lim);
+	  tmp = fold_build3_loc (input_location, COND_EXPR, type, cond,
+				 build_int_cst (type, 0), lshift);
+	  se->expr = tmp;
+	  return;
+	}
+    }
 
   gfc_int4_type_node = gfc_get_int_type (4);
 
@@ -3856,6 +4000,16 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr)
       fndecl = gfc_builtin_decl_for_float_kind (BUILT_IN_CPOW, kind);
       break;
 
+    case BT_UNSIGNED:
+      {
+	/* Valid kinds for unsigned are 1, 2, 4, 8, 16.  Instead of using a
+	   large switch statement, let's just use __builtin_ctz.  */
+	int base = __builtin_ctz (expr->value.op.op1->ts.kind);
+	int expon = __builtin_ctz (expr->value.op.op2->ts.kind);
+	fndecl = gfor_fndecl_unsigned_pow_list[base][expon];
+      }
+      break;
+
     default:
       gcc_unreachable ();
       break;
@@ -7495,6 +7649,9 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 		    {
 		      if (ref->next->type == REF_INQUIRY)
 			break;
+		      if (ref->type == REF_ARRAY
+			  && ref->u.ar.type != AR_ELEMENT)
+			break;
 		    };
 		  if (ref->u.ar.type == AR_FULL
 		      && ref->u.ar.as->type != AS_ASSUMED_SIZE)
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index d3ebc9b47455431c391789858946b7f91bad6955..e9103cd3bac3afc3645fc9fbe7c1e1a1a26ef369 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -3345,7 +3345,8 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
 		  if (openacc && n->sym->ts.type == BT_CLASS)
 		    {
 		      if (n->sym->attr.optional)
-			sorry ("optional class parameter");
+			sorry_at (gfc_get_location (&n->where),
+				  "optional class parameter");
 		      tree ptr = gfc_class_data_get (decl);
 		      ptr = build_fold_indirect_ref (ptr);
 		      OMP_CLAUSE_DECL (node) = ptr;
@@ -3761,7 +3762,8 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
 			    gcc_assert (!ref->next);
 			}
 		      else
-			sorry ("unhandled expression type");
+			sorry_at (gfc_get_location (&n->where),
+				  "unhandled expression type");
 		    }
 
 		  tree inner = se.expr;
@@ -4041,7 +4043,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
 		    gcc_unreachable ();
 		}
 	      else
-		sorry ("unhandled expression");
+		sorry_at (gfc_get_location (&n->where), "unhandled expression");
 
 	      finalize_map_clause:
 
@@ -8494,6 +8496,8 @@ gfc_trans_omp_directive (gfc_code *code)
     case EXEC_OMP_MASTER_TASKLOOP:
     case EXEC_OMP_MASTER_TASKLOOP_SIMD:
       return gfc_trans_omp_master_masked_taskloop (code, code->op);
+    case EXEC_OMP_METADIRECTIVE:
+      return gfc_trans_omp_metadirective (code);
     case EXEC_OMP_ORDERED:
       return gfc_trans_omp_ordered (code);
     case EXEC_OMP_PARALLEL:
@@ -8587,6 +8591,100 @@ gfc_trans_omp_declare_simd (gfc_namespace *ns)
     }
 }
 
+/* Translate the context selector list GFC_SELECTORS, using WHERE as the
+   locus for error messages.  */
+
+static tree
+gfc_trans_omp_set_selector (gfc_omp_set_selector *gfc_selectors, locus where)
+{
+  tree set_selectors = NULL_TREE;
+  gfc_omp_set_selector *oss;
+
+  for (oss = gfc_selectors; oss; oss = oss->next)
+    {
+      tree selectors = NULL_TREE;
+      gfc_omp_selector *os;
+      enum omp_tss_code set = oss->code;
+      gcc_assert (set != OMP_TRAIT_SET_INVALID);
+
+      for (os = oss->trait_selectors; os; os = os->next)
+	{
+	  tree scoreval = NULL_TREE;
+	  tree properties = NULL_TREE;
+	  gfc_omp_trait_property *otp;
+	  enum omp_ts_code sel = os->code;
+
+	  /* Per the spec, "Implementations can ignore specified
+	     selectors that are not those described in this section";
+	     however, we  must record such selectors because they
+	     cause match failures.  */
+	  if (sel == OMP_TRAIT_INVALID)
+	    {
+	      selectors = make_trait_selector (sel, NULL_TREE, NULL_TREE,
+					       selectors);
+	      continue;
+	    }
+
+	  for (otp = os->properties; otp; otp = otp->next)
+	    {
+	      switch (otp->property_kind)
+		{
+		case OMP_TRAIT_PROPERTY_DEV_NUM_EXPR:
+		case OMP_TRAIT_PROPERTY_BOOL_EXPR:
+		  {
+		    tree expr = NULL_TREE;
+		    gfc_se se;
+		    gfc_init_se (&se, NULL);
+		    gfc_conv_expr (&se, otp->expr);
+		    expr = se.expr;
+		    properties = make_trait_property (NULL_TREE, expr,
+						      properties);
+		  }
+		  break;
+		case OMP_TRAIT_PROPERTY_ID:
+		  properties
+		    = make_trait_property (get_identifier (otp->name),
+					   NULL_TREE, properties);
+		  break;
+		case OMP_TRAIT_PROPERTY_NAME_LIST:
+		  {
+		    tree prop = OMP_TP_NAMELIST_NODE;
+		    tree value = NULL_TREE;
+		    if (otp->is_name)
+		      value = get_identifier (otp->name);
+		    else
+		      value = gfc_conv_constant_to_tree (otp->expr);
+
+		    properties = make_trait_property (prop, value,
+						      properties);
+		  }
+		  break;
+		case OMP_TRAIT_PROPERTY_CLAUSE_LIST:
+		  properties = gfc_trans_omp_clauses (NULL, otp->clauses,
+						      where, true);
+		  break;
+		default:
+		  gcc_unreachable ();
+		}
+	    }
+
+	  if (os->score)
+	    {
+	      gfc_se se;
+	      gfc_init_se (&se, NULL);
+	      gfc_conv_expr (&se, os->score);
+	      scoreval = se.expr;
+	    }
+
+	  selectors = make_trait_selector (sel, scoreval,
+					   properties, selectors);
+	}
+      set_selectors = make_trait_set_selector (set, selectors, set_selectors);
+    }
+  return set_selectors;
+}
+
+
 void
 gfc_trans_omp_declare_variant (gfc_namespace *ns)
 {
@@ -8662,90 +8760,8 @@ gfc_trans_omp_declare_variant (gfc_namespace *ns)
 	      && strcmp (odv->base_proc_symtree->name, ns->proc_name->name)))
 	continue;
 
-      tree set_selectors = NULL_TREE;
-      gfc_omp_set_selector *oss;
-
-      for (oss = odv->set_selectors; oss; oss = oss->next)
-	{
-	  tree selectors = NULL_TREE;
-	  gfc_omp_selector *os;
-	  enum omp_tss_code set = oss->code;
-	  gcc_assert (set != OMP_TRAIT_SET_INVALID);
-
-	  for (os = oss->trait_selectors; os; os = os->next)
-	    {
-	      tree scoreval = NULL_TREE;
-	      tree properties = NULL_TREE;
-	      gfc_omp_trait_property *otp;
-	      enum omp_ts_code sel = os->code;
-
-	      /* Per the spec, "Implementations can ignore specified
-		 selectors that are not those described in this section";
-		 however, we  must record such selectors because they
-		 cause match failures.  */
-	      if (sel == OMP_TRAIT_INVALID)
-		{
-		  selectors = make_trait_selector (sel, NULL_TREE, NULL_TREE,
-						   selectors);
-		  continue;
-		}
-
-	      for (otp = os->properties; otp; otp = otp->next)
-		{
-		  switch (otp->property_kind)
-		    {
-		    case OMP_TRAIT_PROPERTY_DEV_NUM_EXPR:
-		    case OMP_TRAIT_PROPERTY_BOOL_EXPR:
-		      {
-			gfc_se se;
-			gfc_init_se (&se, NULL);
-			gfc_conv_expr (&se, otp->expr);
-			properties = make_trait_property (NULL_TREE, se.expr,
-							  properties);
-		      }
-		      break;
-		    case OMP_TRAIT_PROPERTY_ID:
-		      properties
-			= make_trait_property (get_identifier (otp->name),
-					       NULL_TREE, properties);
-		      break;
-		    case OMP_TRAIT_PROPERTY_NAME_LIST:
-		      {
-			tree prop = OMP_TP_NAMELIST_NODE;
-			tree value = NULL_TREE;
-			if (otp->is_name)
-			  value = get_identifier (otp->name);
-			else
-			  value = gfc_conv_constant_to_tree (otp->expr);
-
-			properties = make_trait_property (prop, value,
-							  properties);
-		      }
-		      break;
-		    case OMP_TRAIT_PROPERTY_CLAUSE_LIST:
-		      properties = gfc_trans_omp_clauses (NULL, otp->clauses,
-							  odv->where, true);
-		      break;
-		    default:
-		      gcc_unreachable ();
-		    }
-		}
-
-	      if (os->score)
-		{
-		  gfc_se se;
-		  gfc_init_se (&se, NULL);
-		  gfc_conv_expr (&se, os->score);
-		  scoreval = se.expr;
-		}
-
-	      selectors	= make_trait_selector (sel, scoreval,
-					       properties, selectors);
-	    }
-	  set_selectors = make_trait_set_selector (set, selectors,
-						   set_selectors);
-	}
-
+      tree set_selectors = gfc_trans_omp_set_selector (odv->set_selectors,
+						       odv->where);
       const char *variant_proc_name = odv->variant_proc_symtree->name;
       gfc_symbol *variant_proc_sym = odv->variant_proc_symtree->n.sym;
       if (variant_proc_sym == NULL || variant_proc_sym->attr.implicit_type)
@@ -8777,6 +8793,34 @@ gfc_trans_omp_declare_variant (gfc_namespace *ns)
 		   == NULL_TREE)
 	    {
 	      char err[256];
+	      gfc_formal_arglist *last_arg = NULL, *extra_arg = NULL;
+	      int nappend_args = 0;
+	      if (odv->append_args_list)
+		{
+		  gfc_formal_arglist *arg;
+		  int nargs = 0;
+		  for (arg = gfc_sym_get_dummy_args (ns->proc_name);
+		       arg; arg = arg->next)
+		    nargs++;
+
+		  last_arg = gfc_sym_get_dummy_args (variant_proc_sym);
+		  for (int i = 1 ; i < nargs && last_arg; i++)
+		    last_arg = last_arg->next;
+		  if (nargs == 0)
+		    {
+		      extra_arg = last_arg;
+		      last_arg = NULL;
+		      variant_proc_sym->formal = NULL;
+		    }
+		  else if (last_arg)
+		    {
+		      extra_arg = last_arg->next;
+		      last_arg->next = NULL;
+		    }
+		  for (gfc_omp_namelist *n = odv->append_args_list; n != NULL;
+		       n = n->next)
+		    nappend_args++;
+		}
 	      if (!gfc_compare_interfaces (ns->proc_name, variant_proc_sym,
 					   variant_proc_sym->name, 0, 1,
 					   err, sizeof (err), NULL, NULL))
@@ -8785,18 +8829,73 @@ gfc_trans_omp_declare_variant (gfc_namespace *ns)
 			     "incompatible types: %s",
 			     variant_proc_name, ns->proc_name->name,
 			     &odv->where, err);
+		  if (nappend_args)
+		    inform (gfc_get_location (&odv->append_args_list->where),
+			    "%<append_args%> clause implies that %qs has %d "
+			    "dummy arguments of integer type with "
+			    "%<omp_interop_kind%> kind", variant_proc_name,
+			    nappend_args);
+		  variant_proc_sym = NULL;
+		}
+	      if (last_arg)
+		last_arg->next = extra_arg;
+	      else if (extra_arg)
+		variant_proc_sym->formal = extra_arg;
+	      locus *loc = (odv->append_args_list
+			    ? &odv->append_args_list->where :  &odv->where);
+	      int nextra_arg = 0;
+	      for (; extra_arg; extra_arg = extra_arg->next)
+		{
+		  nextra_arg++;
+		  if (!variant_proc_sym)
+		    continue;
+		  if (extra_arg->sym->ts.type != BT_INTEGER
+		      || extra_arg->sym->ts.kind != gfc_index_integer_kind
+		      || extra_arg->sym->attr.dimension
+		      || extra_arg->sym->attr.codimension
+		      || extra_arg->sym->attr.pointer
+		      || extra_arg->sym->attr.allocatable
+		      || extra_arg->sym->attr.proc_pointer)
+		    {
+		      gfc_error ("%qs at %L must be a nonpointer, "
+				 "nonallocatable scalar integer dummy argument "
+				 "of %<omp_interop_kind%> kind as it utilized "
+				 "with the %<append_args%> clause at %L",
+				 extra_arg->sym->name,
+				 &extra_arg->sym->declared_at, loc);
+		      variant_proc_sym = NULL;
+		    }
+		  if (extra_arg->sym->attr.optional)
+		    {
+		      gfc_error ("%qs at %L with OPTIONAL attribute "
+				 "not support when utilized with the "
+				 "%<append_args%> clause at %L",
+				 extra_arg->sym->name,
+				 &extra_arg->sym->declared_at, loc);
+		      variant_proc_sym = NULL;
+		    }
+		}
+	      if (variant_proc_sym && nappend_args != nextra_arg)
+		{
+		  gfc_error ("%qs at %L has %d but requires %d "
+			     "%<omp_interop_kind%> kind dummy arguments as it "
+			     "is utilized with the %<append_args%> clause at "
+			     "%L", variant_proc_sym->name,
+			     &variant_proc_sym->declared_at, nextra_arg,
+			     nappend_args, loc);
 		  variant_proc_sym = NULL;
 		}
 	    }
-	  if (odv->adjust_args_list != NULL
+	  if ((odv->adjust_args_list != NULL || odv->append_args_list != NULL)
 	      && omp_get_context_selector (set_selectors,
 					   OMP_TRAIT_SET_CONSTRUCT,
 					   OMP_TRAIT_CONSTRUCT_DISPATCH)
 		   == NULL_TREE)
 	    {
-	      gfc_error ("an %<adjust_args%> clause can only be specified if "
+	      gfc_error ("the %qs clause can only be specified if "
 			 "the %<dispatch%> selector of the construct "
 			 "selector set appears in the %<match%> clause at %L",
+			 odv->adjust_args_list ? "adjust_args" : "append_args",
 			 &odv->where);
 	      variant_proc_sym = NULL;
 	    }
@@ -8812,15 +8911,13 @@ gfc_trans_omp_declare_variant (gfc_namespace *ns)
 	      if (omp_context_selector_matches (set_selectors,
 						NULL_TREE, false))
 		{
+		  tree need_device_ptr_list = NULL_TREE;
+		  tree append_args_tree = NULL_TREE;
 		  tree id = get_identifier ("omp declare variant base");
 		  tree variant = gfc_get_symbol_decl (variant_proc_sym);
 		  DECL_ATTRIBUTES (base_fn_decl)
 		    = tree_cons (id, build_tree_list (variant, set_selectors),
 				 DECL_ATTRIBUTES (base_fn_decl));
-
-		  // Handle adjust_args
-		  tree need_device_ptr_list = make_node (TREE_LIST);
-		  vec<gfc_symbol *> adjust_args_list = vNULL;
 		  int arg_idx_offset = 0;
 		  if (gfc_return_by_reference (ns->proc_name))
 		    {
@@ -8828,6 +8925,56 @@ gfc_trans_omp_declare_variant (gfc_namespace *ns)
 		      if (ns->proc_name->ts.type == BT_CHARACTER)
 			arg_idx_offset++;
 		    }
+		  if (odv->append_args_list)
+		    {
+		      int append_arg_no = arg_idx_offset;
+		      gfc_formal_arglist *arg;
+		      for (arg = gfc_sym_get_dummy_args (ns->proc_name); arg;
+			   arg = arg->next)
+			append_arg_no++;
+		      tree last_arg = NULL_TREE;
+		      for (gfc_omp_namelist *n = odv->append_args_list;
+			   n != NULL; n = n->next)
+			{
+			  tree pref = NULL_TREE;
+			  if (n->u.init.len)
+			    {
+			      tree pref = build_string (n->u.init.len,
+							n->u2.init_interop);
+			      TREE_TYPE (pref) = build_array_type_nelts (
+						   unsigned_char_type_node,
+						   n->u.init.len);
+			    }
+			  /* Save location, (target + target sync) and
+			     prefer_type list in a tree list.  */
+			  tree t = build_tree_list (n->u.init.target
+						    ? boolean_true_node
+						    : boolean_false_node,
+						    n->u.init.targetsync
+						    ? boolean_true_node
+						    : boolean_false_node);
+			  t = build1_loc (gfc_get_location (&n->where),
+					  NOP_EXPR, void_type_node, t);
+			  t = build_tree_list (t, pref);
+			  if (append_args_tree)
+			    {
+			      TREE_CHAIN (last_arg) = t;
+			      last_arg = t;
+			    }
+			  else
+			    append_args_tree = last_arg = t;
+			}
+		      /* Store as (purpose = arg number to be used for inserting
+			 and value = list of interop items.  */
+		      append_args_tree = build_tree_list (
+					   build_int_cst (integer_type_node,
+							  append_arg_no),
+					   append_args_tree);
+		    }
+
+		  if (odv->adjust_args_list)
+		    need_device_ptr_list = make_node (TREE_LIST);
+		  vec<gfc_symbol *> adjust_args_list = vNULL;
 		  for (gfc_omp_namelist *arg_list = odv->adjust_args_list;
 		       arg_list != NULL; arg_list = arg_list->next)
 		    {
@@ -8865,12 +9012,16 @@ gfc_trans_omp_declare_variant (gfc_namespace *ns)
 				idx + arg_idx_offset)));
 			}
 		    }
-
-		  DECL_ATTRIBUTES (variant) = tree_cons (
-		    get_identifier ("omp declare variant variant args"),
-		    build_tree_list (need_device_ptr_list,
-				     NULL_TREE /*need_device_addr */),
-		    DECL_ATTRIBUTES (variant));
+		  tree t = NULL_TREE;
+		  if (need_device_ptr_list || append_args_tree)
+		    {
+		      t = build_tree_list (need_device_ptr_list,
+					   NULL_TREE /*need_device_addr */),
+		      TREE_CHAIN (t) = append_args_tree;
+		      DECL_ATTRIBUTES (variant) = tree_cons (
+			get_identifier ("omp declare variant variant args"), t,
+			DECL_ATTRIBUTES (variant));
+		    }
 		}
 	    }
 	}
@@ -8913,3 +9064,54 @@ gfc_omp_call_is_alloc (tree ptr)
     }
   return build_call_expr_loc (input_location, fn, 1, ptr);
 }
+
+tree
+gfc_trans_omp_metadirective (gfc_code *code)
+{
+  gfc_omp_variant *variant = code->ext.omp_variants;
+
+  tree metadirective_tree = make_node (OMP_METADIRECTIVE);
+  SET_EXPR_LOCATION (metadirective_tree, gfc_get_location (&code->loc));
+  TREE_TYPE (metadirective_tree) = void_type_node;
+  OMP_METADIRECTIVE_VARIANTS (metadirective_tree) = NULL_TREE;
+
+  tree tree_body = NULL_TREE;
+
+  while (variant)
+    {
+      tree ctx = gfc_trans_omp_set_selector (variant->selectors,
+					     variant->where);
+      ctx = omp_check_context_selector (gfc_get_location (&variant->where),
+					ctx, true);
+      if (ctx == error_mark_node)
+	return error_mark_node;
+
+      /* If the selector doesn't match, drop the whole variant.  */
+      if (!omp_context_selector_matches (ctx, NULL_TREE, false))
+	{
+	  variant = variant->next;
+	  continue;
+	}
+
+      gfc_code *next_code = variant->code->next;
+      if (next_code && tree_body == NULL_TREE)
+	tree_body = gfc_trans_code (next_code);
+
+      if (next_code)
+	variant->code->next = NULL;
+      tree directive = gfc_trans_code (variant->code);
+      if (next_code)
+	variant->code->next = next_code;
+
+      tree body = next_code ? tree_body : NULL_TREE;
+      tree omp_variant = make_omp_metadirective_variant (ctx, directive, body);
+      OMP_METADIRECTIVE_VARIANTS (metadirective_tree)
+	= chainon (OMP_METADIRECTIVE_VARIANTS (metadirective_tree),
+		   omp_variant);
+      variant = variant->next;
+    }
+
+  /* TODO: Resolve the metadirective here if possible.   */
+
+  return metadirective_tree;
+}
diff --git a/gcc/fortran/trans-stmt.h b/gcc/fortran/trans-stmt.h
index 544c2f99a4bfd1dd7e889fb966b45c42d25d7f88..36cabaf633d144ed068e925fef35ef454cec090b 100644
--- a/gcc/fortran/trans-stmt.h
+++ b/gcc/fortran/trans-stmt.h
@@ -71,6 +71,7 @@ tree gfc_trans_deallocate (gfc_code *);
 tree gfc_trans_omp_directive (gfc_code *);
 void gfc_trans_omp_declare_simd (gfc_namespace *);
 void gfc_trans_omp_declare_variant (gfc_namespace *);
+tree gfc_trans_omp_metadirective (gfc_code *code);
 tree gfc_trans_oacc_directive (gfc_code *);
 tree gfc_trans_oacc_declare (gfc_namespace *);
 
diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc
index 3834986741cabf70f9967b05004bdefd9ebddf46..b03dcc1fb1a4803755000db4fec5041f74505ce3 100644
--- a/gcc/fortran/trans.cc
+++ b/gcc/fortran/trans.cc
@@ -2588,6 +2588,7 @@ trans_code (gfc_code * code, tree cond)
 	case EXEC_OMP_MASTER:
 	case EXEC_OMP_MASTER_TASKLOOP:
 	case EXEC_OMP_MASTER_TASKLOOP_SIMD:
+	case EXEC_OMP_METADIRECTIVE:
 	case EXEC_OMP_ORDERED:
 	case EXEC_OMP_PARALLEL:
 	case EXEC_OMP_PARALLEL_DO:
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index 449d2b3026c04134624e2471d923ed927434061d..915f17549c9fc639aeba2b8d7ef502825b086a22 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -942,6 +942,8 @@ typedef struct GTY(()) gfc_powdecl_list {
 gfc_powdecl_list;
 
 extern GTY(()) gfc_powdecl_list gfor_fndecl_math_powi[4][3];
+extern GTY(()) tree gfor_fndecl_unsigned_pow_list[5][5];
+
 extern GTY(()) tree gfor_fndecl_math_ishftc4;
 extern GTY(()) tree gfor_fndecl_math_ishftc8;
 extern GTY(()) tree gfor_fndecl_math_ishftc16;
diff --git a/gcc/gimple-loop-jam.cc b/gcc/gimple-loop-jam.cc
index 9a2eba02dd978a6e6310853d6ff64e8f0ed9c852..5e6c04a7d7f2e15a9d12a54b56bed9997e532103 100644
--- a/gcc/gimple-loop-jam.cc
+++ b/gcc/gimple-loop-jam.cc
@@ -279,13 +279,17 @@ unroll_jam_possible_p (class loop *outer, class loop *loop)
      body would be the after-iter value of the first body) if it's over
      an associative and commutative operation.  We wouldn't
      be able to handle unknown cycles.  */
+  bool inner_vdef = false;
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
     {
       affine_iv iv;
       tree op = gimple_phi_result (psi.phi ());
 
       if (virtual_operand_p (op))
-	continue;
+	{
+	  inner_vdef = true;
+	  continue;
+	}
       if (!simple_iv (loop, loop, op, &iv, true))
 	return false;
       /* The inductions must be regular, loop invariant step and initial
@@ -301,6 +305,12 @@ unroll_jam_possible_p (class loop *outer, class loop *loop)
 	 copy, _not_ the next value of the second body.  */
     }
 
+  /* When there's no inner loop virtual PHI IV we cannot handle the update
+     required to the inner loop if that doesn't already have one.  See
+     PR117113.  */
+  if (!inner_vdef && get_virtual_phi (outer->header))
+    return false;
+
   return true;
 }
 
diff --git a/gcc/gimple-ssa-split-paths.cc b/gcc/gimple-ssa-split-paths.cc
index 018e59f98cb71e8690ea2f8402cdeba6ce700dbf..9db73fdcc6d4a41332ee399e400c655868cc7888 100644
--- a/gcc/gimple-ssa-split-paths.cc
+++ b/gcc/gimple-ssa-split-paths.cc
@@ -138,8 +138,7 @@ poor_ifcvt_candidate_code (enum tree_code code)
   return (code == MIN_EXPR
 	  || code == MAX_EXPR
 	  || code == ABS_EXPR
-	  || code == COND_EXPR
-	  || code == CALL_EXPR);
+	  || code == COND_EXPR);
 }
 
 /* Return TRUE if PRED of BB is an poor ifcvt candidate. */
@@ -161,6 +160,11 @@ poor_ifcvt_pred (basic_block pred, basic_block bb)
   gimple *stmt = last_and_only_stmt (pred);
   if (!stmt || gimple_code (stmt) != GIMPLE_ASSIGN)
     return true;
+
+  /* If the statement could trap, then this is a poor ifcvt candidate. */
+  if (gimple_could_trap_p (stmt))
+    return true;
+
   tree_code code = gimple_assign_rhs_code (stmt);
   if (poor_ifcvt_candidate_code (code))
     return true;
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 8255131877b6f6e94f9350990eb3f9ab97ee525d..f2ae3a7d213d71c065c66ca8218f06d38051e51e 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -4311,9 +4311,20 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback)
   bool returns_twice = call_expr_flags (*expr_p) & ECF_RETURNS_TWICE;
 
   tree dispatch_device_num = NULL_TREE;
-  tree dispatch_interop = NULL_TREE;
-  tree dispatch_append_args = NULL_TREE;
   tree dispatch_adjust_args_list = NULL_TREE;
+  /* OpenMP: Handle the append_args and adjust_args clauses of declare_variant.
+     This is active if enclosed in 'omp dispatch' but only for the outermost
+     function call, which is therefore enclosed in IFN_GOMP_DISPATCH.
+
+     'append_args' cause's interop objects are added after the last regular
+     (nonhidden, nonvariadic) arguments of the variant function.
+     'adjust_args' with need_device_{addr,ptr} converts the pointer target of
+     a pointer from a host to a device address. This uses either the default
+     device or the passed device number, which then sets the default device
+     address.
+
+     FIXME: This code should be moved into an extra function,
+     cf. above + PR118457.  */
   if (flag_openmp
       && omp_dispatch_p
       && gimplify_omp_ctxp != NULL
@@ -4321,6 +4332,9 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback)
       && EXPR_P (CALL_EXPR_FN (*expr_p))
       && DECL_P (TREE_OPERAND (CALL_EXPR_FN (*expr_p), 0)))
     {
+      tree dispatch_interop = NULL_TREE;
+      tree dispatch_append_args = NULL_TREE;
+      int nfirst_args = 0;
       if (variant_substituted_p)
 	dispatch_adjust_args_list
 	  = lookup_attribute ("omp declare variant variant args",
@@ -4333,6 +4347,11 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback)
 	      && TREE_VALUE (dispatch_adjust_args_list) == NULL_TREE)
 	    dispatch_adjust_args_list = NULL_TREE;
 	}
+      if (dispatch_append_args)
+	{
+	  nfirst_args = tree_to_shwi (TREE_PURPOSE (dispatch_append_args));
+	  dispatch_append_args = TREE_VALUE (dispatch_append_args);
+	}
       dispatch_device_num = omp_find_clause (gimplify_omp_ctxp->clauses,
 					     OMP_CLAUSE_DEVICE);
       if (dispatch_device_num)
@@ -4370,7 +4389,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback)
 			"%<declare variant%> candidate %qD",
 			ninterop, nappend, fndecl);
 	      inform (dispatch_append_args
-		      ? OMP_CLAUSE_LOCATION (dispatch_append_args)
+		      ? EXPR_LOCATION (TREE_PURPOSE (dispatch_append_args))
 		      : DECL_SOURCE_LOCATION (fndecl),
 		      "%<declare variant%> candidate %qD declared here",
 		      fndecl);
@@ -4385,34 +4404,76 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback)
 	}
       if (dispatch_append_args && nappend != ninterop)
 	{
-	  sorry_at (OMP_CLAUSE_LOCATION (dispatch_append_args),
-		    "%<append_args%> clause not yet supported for %qD", fndecl);
+	  sorry_at (EXPR_LOCATION (TREE_PURPOSE (dispatch_append_args)),
+		    "%<append_args%> clause not yet supported for %qD, except "
+		    "when specifying all %d objects in the %<interop%> clause "
+		    "of the %<dispatch%> directive", fndecl, nappend);
 	  inform (gimplify_omp_ctxp->location,
 		    "required by %<dispatch%> construct");
 	}
       else if (dispatch_append_args)
 	{
-	  // Append interop objects
-	  int last_arg = 0;
-	  for (tree t = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
-	       t && TREE_VALUE(t) != void_type_node; t = TREE_CHAIN (t))
-	    last_arg++;
-	  last_arg = last_arg - nappend;
-
-	  int nvariadic = nargs - last_arg;
-	  nargs = last_arg + nappend + nvariadic;
-	  tree *buffer = XALLOCAVEC (tree, nargs);
+	  tree *buffer = XALLOCAVEC (tree, nargs + nappend);
+	  tree arg = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
+	  /* Copy the first arguments; insert then the interop objects,
+	     and then copy the rest (nargs - nfirst_args) args.  */
 	  int i;
-	  for (i = 0; i < last_arg; i++)
-	    buffer[i] = CALL_EXPR_ARG (*expr_p, i);
+	  for (i = 0; i < nfirst_args; i++)
+	    {
+	      arg = TREE_CHAIN (arg);
+	      buffer[i] = CALL_EXPR_ARG (*expr_p, i);
+	    }
 	  int j = nappend;
 	  for (tree t = dispatch_interop;
 	       t; t = TREE_CHAIN (t))
 	    if (OMP_CLAUSE_CODE (t) == OMP_CLAUSE_INTEROP)
 	      buffer[i + --j] = OMP_CLAUSE_DECL (t);
+	  gcc_checking_assert (j == 0);
+	  for (j = 0; j < nappend; j++)
+	    {
+	      /* Fortran permits by-reference or by-value for the dummy arg
+		 and by-value, by-reference, ptr by-reference as actual
+		 argument. Handle this.  */
+	      tree obj = buffer[i + j];  // interop object
+	      tree a2 = TREE_VALUE (arg);  // parameter type
+	      if (POINTER_TYPE_P (TREE_TYPE (obj))
+		  && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (obj))))
+		{
+		  gcc_checking_assert (INTEGRAL_TYPE_P (
+		    TREE_TYPE (TREE_TYPE (TREE_TYPE (obj)))));
+		  obj = fold_build1 (INDIRECT_REF,
+				     TREE_TYPE (TREE_TYPE (obj)), obj);
+		}
+	      if (POINTER_TYPE_P (TREE_TYPE (obj))
+		  && INTEGRAL_TYPE_P (a2))
+		{
+		  gcc_checking_assert (INTEGRAL_TYPE_P (
+		    TREE_TYPE (TREE_TYPE (obj))));
+		  obj = fold_build1 (INDIRECT_REF,
+				     TREE_TYPE (TREE_TYPE (obj)), obj);
+		}
+	      else if (INTEGRAL_TYPE_P (TREE_TYPE (obj))
+		       && POINTER_TYPE_P (a2))
+		{
+		  gcc_checking_assert (INTEGRAL_TYPE_P (TREE_TYPE (a2)));
+		  obj = build_fold_addr_expr (obj);
+		}
+	      else if (!INTEGRAL_TYPE_P (a2)
+		       || !INTEGRAL_TYPE_P (TREE_TYPE (obj)))
+		{
+		  gcc_checking_assert (
+		    POINTER_TYPE_P (TREE_TYPE (obj))
+		    && POINTER_TYPE_P (a2)
+		    && INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (obj)))
+		    && INTEGRAL_TYPE_P (TREE_TYPE (a2)));
+		}
+	      buffer[i + j] = obj;
+	      arg = TREE_CHAIN (arg);
+	    }
 	  i += nappend;
-	  for (j = last_arg; j < last_arg + nvariadic; j++)
+	  for (j = nfirst_args; j < nargs; j++)
 	    buffer[i++] = CALL_EXPR_ARG (*expr_p, j);
+	  nargs += nappend;
 	  tree call = *expr_p;
 	  *expr_p = build_call_array_loc (loc, TREE_TYPE (call),
 					  CALL_EXPR_FN (call),
@@ -4430,8 +4491,6 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback)
 			       is_gimple_call_addr, fb_rvalue);
 	  if (ret == GS_ERROR)
 	    return GS_ERROR;
-	  nargs = call_expr_nargs (*expr_p);
-	  fndecl = get_callee_fndecl (*expr_p);
 
 	  /* Mark as already processed.  */
 	  if (dispatch_interop)
diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
index cf0c84b9fe3b358403aa4fd725aa55919641c40a..9917812d0eaf74ac19ec37ae4a90fda6d3a2768b 100644
--- a/gcc/go/go-gcc.cc
+++ b/gcc/go/go-gcc.cc
@@ -540,16 +540,22 @@ class Gcc_backend : public Backend
   convert_tree(tree, tree, Location);
 
 private:
-  static const int builtin_const = 1 << 0;
-  static const int builtin_noreturn = 1 << 1;
-  static const int builtin_novops = 1 << 2;
-  static const int builtin_pure = 1 << 3;
-  static const int builtin_nothrow = 1 << 4;
+  static const int builtin_cold = 1 << 0;
+  static const int builtin_const = 1 << 1;
+  static const int builtin_leaf = 1 << 2;
+  static const int builtin_nonnull = 1 << 3;
+  static const int builtin_noreturn = 1 << 4;
+  static const int builtin_nothrow = 1 << 5;
+  static const int builtin_novops = 1 << 6;
+  static const int builtin_pure = 1 << 7;
 
   void
   define_builtin(built_in_function bcode, const char* name, const char* libname,
 		 tree fntype, int flags);
 
+  void
+  set_attributes(tree decl, int flags);
+
   // A mapping of the GCC built-ins exposed to GCCGo.
   std::map<std::string, Bfunction*> builtin_functions_;
 };
@@ -571,22 +577,26 @@ Gcc_backend::Gcc_backend()
   tree t = this->integer_type(true, BITS_PER_UNIT)->get_tree();
   tree p = build_pointer_type(build_qualified_type(t, TYPE_QUAL_VOLATILE));
   this->define_builtin(BUILT_IN_SYNC_ADD_AND_FETCH_1, "__sync_fetch_and_add_1",
-		       NULL, build_function_type_list(t, p, t, NULL_TREE), 0);
+		       NULL, build_function_type_list(t, p, t, NULL_TREE),
+		       builtin_leaf);
 
   t = this->integer_type(true, BITS_PER_UNIT * 2)->get_tree();
   p = build_pointer_type(build_qualified_type(t, TYPE_QUAL_VOLATILE));
   this->define_builtin(BUILT_IN_SYNC_ADD_AND_FETCH_2, "__sync_fetch_and_add_2",
-		       NULL, build_function_type_list(t, p, t, NULL_TREE), 0);
+		       NULL, build_function_type_list(t, p, t, NULL_TREE),
+		       builtin_leaf);
 
   t = this->integer_type(true, BITS_PER_UNIT * 4)->get_tree();
   p = build_pointer_type(build_qualified_type(t, TYPE_QUAL_VOLATILE));
   this->define_builtin(BUILT_IN_SYNC_ADD_AND_FETCH_4, "__sync_fetch_and_add_4",
-		       NULL, build_function_type_list(t, p, t, NULL_TREE), 0);
+		       NULL, build_function_type_list(t, p, t, NULL_TREE),
+		       builtin_leaf);
 
   t = this->integer_type(true, BITS_PER_UNIT * 8)->get_tree();
   p = build_pointer_type(build_qualified_type(t, TYPE_QUAL_VOLATILE));
   this->define_builtin(BUILT_IN_SYNC_ADD_AND_FETCH_8, "__sync_fetch_and_add_8",
-		       NULL, build_function_type_list(t, p, t, NULL_TREE), 0);
+		       NULL, build_function_type_list(t, p, t, NULL_TREE),
+		       builtin_leaf);
 
   // We use __builtin_expect for magic import functions.
   this->define_builtin(BUILT_IN_EXPECT, "__builtin_expect", NULL,
@@ -594,7 +604,7 @@ Gcc_backend::Gcc_backend()
 						long_integer_type_node,
 						long_integer_type_node,
 						NULL_TREE),
-		       builtin_const);
+		       builtin_const | builtin_nothrow | builtin_leaf);
 
   // We use __builtin_memcmp for struct comparisons.
   this->define_builtin(BUILT_IN_MEMCMP, "__builtin_memcmp", "memcmp",
@@ -603,7 +613,7 @@ Gcc_backend::Gcc_backend()
 						const_ptr_type_node,
 						size_type_node,
 						NULL_TREE),
-		       builtin_pure | builtin_nothrow);
+		       builtin_pure | builtin_nothrow | builtin_nonnull);
 
   // We use __builtin_memmove for copying data.
   this->define_builtin(BUILT_IN_MEMMOVE, "__builtin_memmove", "memmove",
@@ -612,7 +622,7 @@ Gcc_backend::Gcc_backend()
 						const_ptr_type_node,
 						size_type_node,
 						NULL_TREE),
-		       0);
+		       builtin_nothrow | builtin_nonnull);
 
   // We use __builtin_memset for zeroing data.
   this->define_builtin(BUILT_IN_MEMSET, "__builtin_memset", "memset",
@@ -621,64 +631,64 @@ Gcc_backend::Gcc_backend()
 						integer_type_node,
 						size_type_node,
 						NULL_TREE),
-		       0);
+		       builtin_nothrow | builtin_nonnull);
 
   // Used by runtime/internal/sys and math/bits.
   this->define_builtin(BUILT_IN_CTZ, "__builtin_ctz", "ctz",
 		       build_function_type_list(integer_type_node,
 						unsigned_type_node,
 						NULL_TREE),
-		       builtin_const);
+		       builtin_const | builtin_nothrow | builtin_leaf);
   this->define_builtin(BUILT_IN_CTZL, "__builtin_ctzl", "ctzl",
 		      build_function_type_list(integer_type_node,
 					       long_unsigned_type_node,
 					       NULL_TREE),
-		      builtin_const);
+		      builtin_const | builtin_nothrow | builtin_leaf);
   this->define_builtin(BUILT_IN_CTZLL, "__builtin_ctzll", "ctzll",
 		       build_function_type_list(integer_type_node,
 						long_long_unsigned_type_node,
 						NULL_TREE),
-		       builtin_const);
+		       builtin_const | builtin_nothrow | builtin_leaf);
   this->define_builtin(BUILT_IN_CLZ, "__builtin_clz", "clz",
 		       build_function_type_list(integer_type_node,
 						unsigned_type_node,
 						NULL_TREE),
-		       builtin_const);
+		       builtin_const | builtin_nothrow | builtin_leaf);
   this->define_builtin(BUILT_IN_CLZL, "__builtin_clzl", "clzl",
 		      build_function_type_list(integer_type_node,
 					       long_unsigned_type_node,
 					       NULL_TREE),
-		      builtin_const);
+		      builtin_const | builtin_nothrow | builtin_leaf);
   this->define_builtin(BUILT_IN_CLZLL, "__builtin_clzll", "clzll",
 		       build_function_type_list(integer_type_node,
 						long_long_unsigned_type_node,
 						NULL_TREE),
-		       builtin_const);
+		       builtin_const | builtin_nothrow | builtin_leaf);
   this->define_builtin(BUILT_IN_POPCOUNT, "__builtin_popcount", "popcount",
 		       build_function_type_list(integer_type_node,
 						unsigned_type_node,
 						NULL_TREE),
-		       builtin_const);
+		       builtin_const | builtin_nothrow | builtin_leaf);
   this->define_builtin(BUILT_IN_POPCOUNTLL, "__builtin_popcountll", "popcountll",
 		       build_function_type_list(integer_type_node,
 						long_long_unsigned_type_node,
 						NULL_TREE),
-		       builtin_const);
+		       builtin_const | builtin_nothrow | builtin_leaf);
   this->define_builtin(BUILT_IN_BSWAP16, "__builtin_bswap16", "bswap16",
 		       build_function_type_list(uint16_type_node,
 						uint16_type_node,
 						NULL_TREE),
-		       builtin_const);
+		       builtin_const | builtin_nothrow | builtin_leaf);
   this->define_builtin(BUILT_IN_BSWAP32, "__builtin_bswap32", "bswap32",
 		       build_function_type_list(uint32_type_node,
 						uint32_type_node,
 						NULL_TREE),
-		       builtin_const);
+		       builtin_const | builtin_nothrow | builtin_leaf);
   this->define_builtin(BUILT_IN_BSWAP64, "__builtin_bswap64", "bswap64",
 		       build_function_type_list(uint64_type_node,
 						uint64_type_node,
 						NULL_TREE),
-		       builtin_const);
+		       builtin_const | builtin_nothrow | builtin_leaf);
 
   // We provide some functions for the math library.
   tree math_function_type = build_function_type_list(double_type_node,
@@ -787,7 +797,7 @@ Gcc_backend::Gcc_backend()
   // functions which call recover, and for runtime.getcallerpc.
   t = build_function_type_list(ptr_type_node, unsigned_type_node, NULL_TREE);
   this->define_builtin(BUILT_IN_RETURN_ADDRESS, "__builtin_return_address",
-		       NULL, t, 0);
+		       NULL, t, builtin_leaf);
 
   // The runtime calls __builtin_dwarf_cfa for runtime.getcallersp.
   t = build_function_type_list(ptr_type_node, NULL_TREE);
@@ -801,123 +811,126 @@ Gcc_backend::Gcc_backend()
 		       build_function_type_list(ptr_type_node,
 						ptr_type_node,
 						NULL_TREE),
-		       0);
+		       builtin_leaf);
 
   // The compiler uses __builtin_trap for some exception handling
   // cases.
   this->define_builtin(BUILT_IN_TRAP, "__builtin_trap", NULL,
 		       build_function_type(void_type_node, void_list_node),
-		       builtin_noreturn);
+		       (builtin_noreturn | builtin_nothrow | builtin_leaf
+			| builtin_cold));
 
   // The runtime uses __builtin_prefetch.
   this->define_builtin(BUILT_IN_PREFETCH, "__builtin_prefetch", NULL,
 		       build_varargs_function_type_list(void_type_node,
 							const_ptr_type_node,
 							NULL_TREE),
-		       builtin_novops);
+		       builtin_novops | builtin_leaf);
 
   // The compiler uses __builtin_unreachable for cases that cannot
   // occur.
   this->define_builtin(BUILT_IN_UNREACHABLE, "__builtin_unreachable", NULL,
 		       build_function_type(void_type_node, void_list_node),
-		       builtin_const | builtin_noreturn);
+		       (builtin_const | builtin_noreturn | builtin_nothrow
+			| builtin_leaf | builtin_cold));
 
   // We provide some atomic functions.
   t = build_function_type_list(uint32_type_node,
-                               ptr_type_node,
-                               integer_type_node,
-                               NULL_TREE);
+			       ptr_type_node,
+			       integer_type_node,
+			       NULL_TREE);
   this->define_builtin(BUILT_IN_ATOMIC_LOAD_4, "__atomic_load_4", NULL,
-                       t, 0);
+		       t, builtin_leaf);
 
   t = build_function_type_list(uint64_type_node,
-                               ptr_type_node,
-                               integer_type_node,
-                               NULL_TREE);
+			       ptr_type_node,
+			       integer_type_node,
+			       NULL_TREE);
   this->define_builtin(BUILT_IN_ATOMIC_LOAD_8, "__atomic_load_8", NULL,
-                       t, 0);
+		       t, builtin_leaf);
 
   t = build_function_type_list(void_type_node,
-                               ptr_type_node,
-                               uint32_type_node,
-                               integer_type_node,
-                               NULL_TREE);
+			       ptr_type_node,
+			       uint32_type_node,
+			       integer_type_node,
+			       NULL_TREE);
   this->define_builtin(BUILT_IN_ATOMIC_STORE_4, "__atomic_store_4", NULL,
-                       t, 0);
+		       t, builtin_leaf);
 
   t = build_function_type_list(void_type_node,
-                               ptr_type_node,
-                               uint64_type_node,
-                               integer_type_node,
-                               NULL_TREE);
+			       ptr_type_node,
+			       uint64_type_node,
+			       integer_type_node,
+			       NULL_TREE);
   this->define_builtin(BUILT_IN_ATOMIC_STORE_8, "__atomic_store_8", NULL,
-                       t, 0);
+		       t, builtin_leaf);
 
   t = build_function_type_list(uint32_type_node,
-                               ptr_type_node,
-                               uint32_type_node,
-                               integer_type_node,
-                               NULL_TREE);
+			       ptr_type_node,
+			       uint32_type_node,
+			       integer_type_node,
+			       NULL_TREE);
   this->define_builtin(BUILT_IN_ATOMIC_EXCHANGE_4, "__atomic_exchange_4", NULL,
-                       t, 0);
+		       t, builtin_leaf);
 
   t = build_function_type_list(uint64_type_node,
-                               ptr_type_node,
-                               uint64_type_node,
-                               integer_type_node,
-                               NULL_TREE);
+			       ptr_type_node,
+			       uint64_type_node,
+			       integer_type_node,
+			       NULL_TREE);
   this->define_builtin(BUILT_IN_ATOMIC_EXCHANGE_8, "__atomic_exchange_8", NULL,
-                       t, 0);
+		       t, builtin_leaf);
 
   t = build_function_type_list(boolean_type_node,
-                               ptr_type_node,
-                               ptr_type_node,
-                               uint32_type_node,
-                               boolean_type_node,
-                               integer_type_node,
-                               integer_type_node,
-                               NULL_TREE);
+			       ptr_type_node,
+			       ptr_type_node,
+			       uint32_type_node,
+			       boolean_type_node,
+			       integer_type_node,
+			       integer_type_node,
+			       NULL_TREE);
   this->define_builtin(BUILT_IN_ATOMIC_COMPARE_EXCHANGE_4,
-                       "__atomic_compare_exchange_4", NULL,
-                       t, 0);
+		       "__atomic_compare_exchange_4", NULL,
+		       t, builtin_leaf);
 
   t = build_function_type_list(boolean_type_node,
-                               ptr_type_node,
-                               ptr_type_node,
-                               uint64_type_node,
-                               boolean_type_node,
-                               integer_type_node,
-                               integer_type_node,
-                               NULL_TREE);
+			       ptr_type_node,
+			       ptr_type_node,
+			       uint64_type_node,
+			       boolean_type_node,
+			       integer_type_node,
+			       integer_type_node,
+			       NULL_TREE);
   this->define_builtin(BUILT_IN_ATOMIC_COMPARE_EXCHANGE_8,
-                       "__atomic_compare_exchange_8", NULL,
-                       t, 0);
+		       "__atomic_compare_exchange_8", NULL,
+		       t, builtin_leaf);
 
   t = build_function_type_list(uint32_type_node,
-                               ptr_type_node,
-                               uint32_type_node,
-                               integer_type_node,
-                               NULL_TREE);
+			       ptr_type_node,
+			       uint32_type_node,
+			       integer_type_node,
+			       NULL_TREE);
   this->define_builtin(BUILT_IN_ATOMIC_ADD_FETCH_4, "__atomic_add_fetch_4",
-		       NULL, t, 0);
+		       NULL, t, builtin_leaf);
   this->define_builtin(BUILT_IN_ATOMIC_FETCH_ADD_4, "__atomic_fetch_add_4",
-		       NULL, t, 0);
+		       NULL, t, builtin_leaf);
 
   t = build_function_type_list(uint64_type_node,
-                               ptr_type_node,
-                               uint64_type_node,
-                               integer_type_node,
-                               NULL_TREE);
+			       ptr_type_node,
+			       uint64_type_node,
+			       integer_type_node,
+			       NULL_TREE);
   this->define_builtin(BUILT_IN_ATOMIC_ADD_FETCH_8, "__atomic_add_fetch_8",
-		       NULL, t, 0);
+		       NULL, t, builtin_leaf);
   this->define_builtin(BUILT_IN_ATOMIC_FETCH_ADD_8, "__atomic_fetch_add_8",
-		       NULL, t, 0);
+		       NULL, t, builtin_leaf);
 
   t = build_function_type_list(unsigned_char_type_node,
 			       ptr_type_node,
 			       integer_type_node,
 			       NULL_TREE);
-  this->define_builtin(BUILT_IN_ATOMIC_LOAD_1, "__atomic_load_1", NULL, t, 0);
+  this->define_builtin(BUILT_IN_ATOMIC_LOAD_1, "__atomic_load_1", NULL, t,
+		       builtin_leaf);
 
   t = build_function_type_list(void_type_node,
 			       ptr_type_node,
@@ -925,27 +938,27 @@ Gcc_backend::Gcc_backend()
 			       integer_type_node,
 			       NULL_TREE);
   this->define_builtin(BUILT_IN_ATOMIC_STORE_1, "__atomic_store_1", NULL,
-		       t, 0);
+		       t, builtin_leaf);
 
   t = build_function_type_list(unsigned_char_type_node,
-                               ptr_type_node,
-                               unsigned_char_type_node,
-                               integer_type_node,
-                               NULL_TREE);
+			       ptr_type_node,
+			       unsigned_char_type_node,
+			       integer_type_node,
+			       NULL_TREE);
   this->define_builtin(BUILT_IN_ATOMIC_AND_FETCH_1, "__atomic_and_fetch_1", NULL,
-                       t, 0);
+		       t, builtin_leaf);
   this->define_builtin(BUILT_IN_ATOMIC_FETCH_AND_1, "__atomic_fetch_and_1", NULL,
-                       t, 0);
+		       t, builtin_leaf);
 
   t = build_function_type_list(unsigned_char_type_node,
-                               ptr_type_node,
-                               unsigned_char_type_node,
-                               integer_type_node,
-                               NULL_TREE);
+			       ptr_type_node,
+			       unsigned_char_type_node,
+			       integer_type_node,
+			       NULL_TREE);
   this->define_builtin(BUILT_IN_ATOMIC_OR_FETCH_1, "__atomic_or_fetch_1", NULL,
-                       t, 0);
+		       t, builtin_leaf);
   this->define_builtin(BUILT_IN_ATOMIC_FETCH_OR_1, "__atomic_fetch_or_1", NULL,
-                       t, 0);
+		       t, builtin_leaf);
 }
 
 // Get an unnamed integer type.
@@ -3587,8 +3600,7 @@ Gcc_backend::write_export_data(const char* bytes, unsigned int size)
 // defined by builtins.def.  NAME is the name of the builtin function.
 // LIBNAME is the name of the corresponding library function, and is
 // NULL if there isn't one.  FNTYPE is the type of the function.
-// CONST_P is true if the function has the const attribute.
-// NORETURN_P is true if the function has the noreturn attribute.
+// FLAGS are the attributes to add, a bitset of builtin_xxx consts.
 
 void
 Gcc_backend::define_builtin(built_in_function bcode, const char* name,
@@ -3596,6 +3608,23 @@ Gcc_backend::define_builtin(built_in_function bcode, const char* name,
 {
   tree decl = add_builtin_function(name, fntype, bcode, BUILT_IN_NORMAL,
 				   libname, NULL_TREE);
+  this->set_attributes(decl, flags);
+  set_builtin_decl(bcode, decl, true);
+  this->builtin_functions_[name] = this->make_function(decl);
+  if (libname != NULL)
+    {
+      decl = add_builtin_function(libname, fntype, bcode, BUILT_IN_NORMAL,
+				  NULL, NULL_TREE);
+      this->set_attributes(decl, flags);
+      this->builtin_functions_[libname] = this->make_function(decl);
+    }
+}
+
+// Set the attributes of DECL based on FLAGS.
+
+void
+Gcc_backend::set_attributes(tree decl, int flags)
+{
   if ((flags & builtin_const) != 0)
     TREE_READONLY(decl) = 1;
   if ((flags & builtin_pure) != 0)
@@ -3606,24 +3635,15 @@ Gcc_backend::define_builtin(built_in_function bcode, const char* name,
     TREE_THIS_VOLATILE(decl) = 1;
   if ((flags & builtin_novops) != 0)
     DECL_IS_NOVOPS(decl) = 1;
-  set_builtin_decl(bcode, decl, true);
-  this->builtin_functions_[name] = this->make_function(decl);
-  if (libname != NULL)
-    {
-      decl = add_builtin_function(libname, fntype, bcode, BUILT_IN_NORMAL,
-				  NULL, NULL_TREE);
-      if ((flags & builtin_const) != 0)
-	TREE_READONLY(decl) = 1;
-      if ((flags & builtin_pure) != 0)
-	DECL_PURE_P(decl) = 1;
-      if ((flags & builtin_nothrow) != 0)
-	TREE_NOTHROW (decl) = 1;
-      if ((flags & builtin_noreturn) != 0)
-	TREE_THIS_VOLATILE(decl) = 1;
-      if ((flags & builtin_novops) != 0)
-	DECL_IS_NOVOPS(decl) = 1;
-      this->builtin_functions_[libname] = this->make_function(decl);
-    }
+  if ((flags & builtin_leaf) != 0)
+    DECL_ATTRIBUTES(decl) = tree_cons(get_identifier("leaf"), NULL_TREE,
+				      DECL_ATTRIBUTES(decl));
+  if ((flags & builtin_nonnull) != 0)
+    DECL_ATTRIBUTES(decl) = tree_cons(get_identifier("nonnull"), NULL_TREE,
+				      DECL_ATTRIBUTES(decl));
+  if ((flags & builtin_cold) != 0)
+    DECL_ATTRIBUTES(decl) = tree_cons(get_identifier("cold"), NULL_TREE,
+				      DECL_ATTRIBUTES(decl));
 }
 
 // Return the backend generator.
diff --git a/gcc/input.cc b/gcc/input.cc
index 7ed80cad13f404dca7d8ef3447fbc0e742b61f04..66a0ac6c5302de3c4e5ce2b1d4d6526bd4eba547 100644
--- a/gcc/input.cc
+++ b/gcc/input.cc
@@ -79,6 +79,10 @@ public:
   void evict ();
   void set_content (const char *buf, size_t sz);
 
+  static void tune(size_t line_record_size_) {
+      line_record_size = line_record_size_;
+  }
+
  private:
   /* These are information used to store a line boundary.  */
   class line_info
@@ -104,6 +108,11 @@ public:
     line_info ()
       :line_num (0), start_pos (0), end_pos (0)
     {}
+
+    static bool less_than(const line_info &a, const line_info &b)
+    {
+      return a.line_num < b.line_num;
+    }
   };
 
   bool needs_read_p () const;
@@ -116,7 +125,7 @@ public:
   bool goto_next_line ();
 
   static const size_t buffer_size = 4 * 1024;
-  static const size_t line_record_size = 100;
+  static size_t line_record_size;
 
   /* The number of time this file has been accessed.  This is used
      to designate which file cache to evict from the cache
@@ -131,6 +140,9 @@ public:
 
   FILE *m_fp;
 
+  /* True when an read error happened.  */
+  bool m_error;
+
   /* This points to the content of the file that we've read so
      far.  */
   char *m_data;
@@ -153,16 +165,6 @@ public:
      means we've read no line so far.  */
   size_t m_line_num;
 
-  /* This is the total number of lines of the current file.  At the
-     moment, we try to get this information from the line map
-     subsystem.  Note that this is just a hint.  When using the C++
-     front-end, this hint is correct because the input file is then
-     completely tokenized before parsing starts; so the line map knows
-     the number of lines before compilation really starts.  For e.g,
-     the C front-end, it can happen that we start emitting diagnostics
-     before the line map has seen the end of the file.  */
-  size_t m_total_lines;
-
   /* Could this file be missing a trailing newline on its final line?
      Initially true (to cope with empty files), set to true/false
      as each line is read.  */
@@ -171,10 +173,8 @@ public:
   /* This is a record of the beginning and end of the lines we've seen
      while reading the file.  This is useful to avoid walking the data
      from the beginning when we are asked to read a line that is
-     before LINE_START_IDX above.  Note that the maximum size of this
-     record is line_record_size, so that the memory consumption
-     doesn't explode.  We thus scale total_lines down to
-     line_record_size.  */
+     before LINE_START_IDX above.  When the lines exceed line_record_size
+     this is scaled down dynamically, with the line_info becoming anchors.  */
   vec<line_info, va_heap> m_line_record;
 
   void offset_buffer (int offset)
@@ -189,6 +189,18 @@ public:
 
 };
 
+size_t file_cache_slot::line_record_size = 0;
+
+/* Tune file_cache.  */
+void
+file_cache::tune (size_t num_file_slots_, size_t lines)
+{
+  num_file_slots = num_file_slots_;
+  file_cache_slot::tune (lines);
+}
+
+size_t file_cache::num_file_slots = 16;
+
 static const char *
 find_end_of_line (const char *s, size_t len);
 
@@ -295,25 +307,6 @@ expand_location_1 (const line_maps *set,
   return xloc;
 }
 
-/* Return the total lines number that have been read so far by the
-   line map (in the preprocessor) so far.  For languages like C++ that
-   entirely preprocess the input file before starting to parse, this
-   equals the actual number of lines of the file.  */
-
-static size_t
-total_lines_num (const char *file_path)
-{
-  size_t r = 0;
-  location_t l = 0;
-  if (linemap_get_file_highest_location (line_table, file_path, &l))
-    {
-      gcc_assert (l >= RESERVED_LOCATION_COUNT);
-      expanded_location xloc = expand_location (l);
-      r = xloc.line;
-    }
-  return r;
-}
-
 /* Lookup the cache used for the content of a given file accessed by
    caret diagnostic.  Return the found cached file, or NULL if no
    cached file was found.  */
@@ -396,13 +389,13 @@ file_cache_slot::evict ()
   m_file_path = NULL;
   if (m_fp)
     fclose (m_fp);
+  m_error = false;
   m_fp = NULL;
   m_nb_read = 0;
   m_line_start_idx = 0;
   m_line_num = 0;
   m_line_record.truncate (0);
   m_use_count = 0;
-  m_total_lines = 0;
   m_missing_trailing_newline = true;
 }
 
@@ -491,6 +484,7 @@ file_cache_slot::create (const file_cache::input_context &in_context,
   m_file_path = file_path;
   if (m_fp)
     fclose (m_fp);
+  m_error = false;
   m_fp = fp;
   if (m_alloc_offset)
     offset_buffer (-m_alloc_offset);
@@ -501,7 +495,6 @@ file_cache_slot::create (const file_cache::input_context &in_context,
   /* Ensure that this cache entry doesn't get evicted next time
      add_file_to_cache_tab is called.  */
   m_use_count = ++highest_use_count;
-  m_total_lines = total_lines_num (file_path);
   m_missing_trailing_newline = true;
 
 
@@ -548,17 +541,6 @@ file_cache_slot::set_content (const char *buf, size_t sz)
       fclose (m_fp);
       m_fp = nullptr;
     }
-
-  /* Compute m_total_lines based on content of buffer.  */
-  m_total_lines = 0;
-  const char *line_start = m_data;
-  size_t remaining_size = sz;
-  while (const char *line_end = find_end_of_line (line_start, remaining_size))
-    {
-      ++m_total_lines;
-      remaining_size -= line_end + 1 - line_start;
-      line_start = line_end + 1;
-    }
 }
 
 /* file_cache's ctor.  */
@@ -613,9 +595,9 @@ file_cache::lookup_or_add_file (const char *file_path)
    diagnostic.  */
 
 file_cache_slot::file_cache_slot ()
-: m_use_count (0), m_file_path (NULL), m_fp (NULL), m_data (0),
+: m_use_count (0), m_file_path (NULL), m_fp (NULL), m_error (false), m_data (0),
   m_alloc_offset (0), m_size (0), m_nb_read (0), m_line_start_idx (0),
-  m_line_num (0), m_total_lines (0), m_missing_trailing_newline (true)
+  m_line_num (0), m_missing_trailing_newline (true)
 {
   m_line_record.create (0);
 }
@@ -655,15 +637,15 @@ file_cache_slot::dump (FILE *out, int indent) const
   fprintf (out, "%*snb_read: %zi\n", indent, "", m_nb_read);
   fprintf (out, "%*sstart_line_idx: %zi\n", indent, "", m_line_start_idx);
   fprintf (out, "%*sline_num: %zi\n", indent, "", m_line_num);
-  fprintf (out, "%*stotal_lines: %zi\n", indent, "", m_total_lines);
   fprintf (out, "%*smissing_trailing_newline: %i\n",
 	   indent, "", (int)m_missing_trailing_newline);
   fprintf (out, "%*sline records (%i):\n",
 	   indent, "", m_line_record.length ());
+  int idx = 0;
   for (auto &line : m_line_record)
-    fprintf (out, "%*sline %zi: byte offsets: %zi-%zi\n",
+    fprintf (out, "%*s[%i]: line %zi: byte offsets: %zi-%zi\n",
 	     indent + 2, "",
-	     line.line_num, line.start_pos, line.end_pos);
+	     idx++, line.line_num, line.start_pos, line.end_pos);
 }
 
 /* Returns TRUE iff the cache would need to be filled with data coming
@@ -728,7 +710,10 @@ file_cache_slot::read_data ()
   size_t nb_read = fread (from, 1, to_read, m_fp);
 
   if (ferror (m_fp))
-    return false;
+    {
+      m_error = true;
+      return false;
+    }
 
   m_nb_read += nb_read;
   return !!nb_read;
@@ -846,7 +831,7 @@ file_cache_slot::get_next_line (char **line, ssize_t *line_len)
       m_missing_trailing_newline = false;
     }
 
-  if (m_fp && ferror (m_fp))
+  if (m_error)
     return false;
 
   /* At this point, we've found the end of the of line.  It either points to
@@ -860,38 +845,38 @@ file_cache_slot::get_next_line (char **line, ssize_t *line_len)
 
   ++m_line_num;
 
-  /* Before we update our line record, make sure the hint about the
-     total number of lines of the file is correct.  If it's not, then
-     we give up recording line boundaries from now on.  */
-  bool update_line_record = true;
-  if (m_line_num > m_total_lines)
-    update_line_record = false;
-
-    /* Now update our line record so that re-reading lines from the
+  /* Now update our line record so that re-reading lines from the
      before m_line_start_idx is faster.  */
-  if (update_line_record
-      && m_line_record.length () < line_record_size)
+  size_t rlen = m_line_record.length ();
+  /* Only update when beyond the previously cached region.  */
+  if (rlen == 0 || m_line_record[rlen - 1].line_num < m_line_num)
     {
-      /* If the file lines fits in the line record, we just record all
-	 its lines ...*/
-      if (m_total_lines <= line_record_size
-	  && m_line_num > m_line_record.length ())
+      size_t spacing = rlen >= 2 ?
+	m_line_record[rlen - 1].line_num - m_line_record[rlen - 2].line_num : 1;
+      size_t delta = rlen >= 1 ?
+	m_line_num - m_line_record[rlen - 1].line_num : 1;
+
+      size_t max_size = line_record_size;
+      /* One anchor per hundred input lines.  */
+      if (max_size == 0)
+	max_size = m_line_num / 100;
+
+      /* If we're too far beyond drop half of the lines to rebalance.  */
+      if (rlen == max_size && delta >= spacing*2)
+	{
+	  size_t j = 0;
+	  for (size_t i = 1; i < rlen; i += 2)
+	    m_line_record[j++] = m_line_record[i];
+	  m_line_record.truncate (j);
+	  rlen = j;
+	  spacing *= 2;
+	}
+
+      if (rlen < max_size && delta >= spacing)
 	m_line_record.safe_push
 	  (file_cache_slot::line_info (m_line_num,
 				       m_line_start_idx,
 				       line_end - m_data));
-      else if (m_total_lines > line_record_size)
-	{
-	  /* ... otherwise, we just scale total_lines down to
-	     (line_record_size lines.  */
-	  size_t n = (m_line_num * line_record_size) / m_total_lines;
-	  if (m_line_record.length () == 0
-	      || n >= m_line_record.length ())
-	    m_line_record.safe_push
-	      (file_cache_slot::line_info (m_line_num,
-					   m_line_start_idx,
-					   line_end - m_data));
-	}
     }
 
   /* Update m_line_start_idx so that it points to the next line to be
@@ -941,69 +926,26 @@ file_cache_slot::read_line_num (size_t line_num,
 
   if (line_num <= m_line_num)
     {
-      /* We've been asked to read lines that are before m_line_num.
-	 So lets use our line record (if it's not empty) to try to
-	 avoid re-reading the file from the beginning again.  */
-
-      if (m_line_record.is_empty ())
+      line_info l (line_num, 0, 0);
+      int i = m_line_record.lower_bound (l, line_info::less_than);
+      if (i == 0)
 	{
 	  m_line_start_idx = 0;
 	  m_line_num = 0;
 	}
-      else
+      else if (m_line_record[i - 1].line_num == line_num)
 	{
-	  file_cache_slot::line_info *i = NULL;
-	  if (m_total_lines <= line_record_size)
-	    {
-	      /* In languages where the input file is not totally
-		 preprocessed up front, the m_total_lines hint
-		 can be smaller than the number of lines of the
-		 file.  In that case, only the first
-		 m_total_lines have been recorded.
-
-		 Otherwise, the first m_total_lines we've read have
-		 their start/end recorded here.  */
-	      i = (line_num <= m_total_lines)
-		? &m_line_record[line_num - 1]
-		: &m_line_record[m_total_lines - 1];
-	      gcc_assert (i->line_num <= line_num);
-	    }
-	  else
-	    {
-	      /*  So the file had more lines than our line record
-		  size.  Thus the number of lines we've recorded has
-		  been scaled down to line_record_size.  Let's
-		  pick the start/end of the recorded line that is
-		  closest to line_num.  */
-	      size_t n = (line_num <= m_total_lines)
-		? line_num * line_record_size / m_total_lines
-		: m_line_record.length () - 1;
-	      if (n < m_line_record.length ())
-		{
-		  i = &m_line_record[n];
-		  gcc_assert (i->line_num <= line_num);
-		}
-	    }
-
-	  if (i && i->line_num == line_num)
-	    {
-	      /* We have the start/end of the line.  */
-	      *line = m_data + i->start_pos;
-	      *line_len = i->end_pos - i->start_pos;
-	      return true;
-	    }
-
-	  if (i)
-	    {
-	      m_line_start_idx = i->start_pos;
-	      m_line_num = i->line_num - 1;
-	    }
-	  else
-	    {
-	      m_line_start_idx = 0;
-	      m_line_num = 0;
-	    }
+	  /* We have the start/end of the line.  */
+	  *line = m_data + m_line_record[i - 1].start_pos;
+	  *line_len = m_line_record[i - 1].end_pos - m_line_record[i - 1].start_pos;
+	  return true;
 	}
+      else
+       {
+	 gcc_assert (m_line_record[i - 1].line_num < m_line_num);
+	 m_line_start_idx = m_line_record[i - 1].start_pos;
+	 m_line_num = m_line_record[i - 1].line_num - 1;
+       }
     }
 
   /*  Let's walk from line m_line_num up to line_num - 1, without
@@ -1012,8 +954,7 @@ file_cache_slot::read_line_num (size_t line_num,
     if (!goto_next_line ())
       return false;
 
-  /* The line we want is the next one.  Let's read and copy it back to
-     the caller.  */
+  /* The line we want is the next one.  Let's read it.  */
   return get_next_line (line, line_len);
 }
 
@@ -2360,6 +2301,48 @@ test_make_location_nonpure_range_endpoints (const line_table_case &case_)
   ASSERT_FALSE (IS_ADHOC_LOC (get_finish (not_aaa_eq_bbb)));
 }
 
+/* Verify reading of a specific line LINENUM in TMP, FC.  */
+
+static void check_line (temp_source_file &tmp, file_cache &fc, int linenum)
+{
+  char_span line = fc.get_source_line (tmp.get_filename (), linenum);
+  int n;
+  /* get_buffer is not null terminated, but the sscanf stops after a number.  */
+  ASSERT_TRUE (sscanf (line.get_buffer (), "%d", &n) == 1);
+  ASSERT_EQ (n, linenum);
+}
+
+/* Test file cache replacement.  */
+
+static void test_replacement ()
+{
+  const int maxline = 1000;
+
+  char *vec = XNEWVEC (char, maxline * 15);
+  char *p = vec;
+  int i;
+  for (i = 1; i <= maxline; i++)
+    p += sprintf (p, "%d\n", i);
+
+  temp_source_file tmp (SELFTEST_LOCATION, ".txt", vec);
+  free (vec);
+  file_cache fc;
+
+  for (i = 2; i <= maxline; i++)
+    {
+      check_line (tmp, fc, i);
+      check_line (tmp, fc, i - 1);
+      if (i >= 10)
+	check_line (tmp, fc, i - 9);
+      if (i >= 350) /* Exceed the look behind cache.  */
+	check_line (tmp, fc, i - 300);
+    }
+  for (i = 5; i <= maxline; i += 100)
+    check_line (tmp, fc, i);
+  for (i = 1; i <= maxline; i++)
+    check_line (tmp, fc, i);
+}
+
 /* Verify reading of input files (e.g. for caret-based diagnostics).  */
 
 static void
@@ -4310,6 +4293,7 @@ input_cc_tests ()
 
   test_reading_source_line ();
   test_reading_source_buffer ();
+  test_replacement ();
 
   test_line_offset_overflow ();
 
diff --git a/gcc/input.h b/gcc/input.h
index 18ccf4429fc5002abd58caefe0454bdd8c8ff13f..a60afe80681ff91867327024b1a20439e6b04f10 100644
--- a/gcc/input.h
+++ b/gcc/input.h
@@ -161,13 +161,15 @@ class file_cache
 			     const char *buffer,
 			     size_t sz);
 
+  static void tune(size_t num_file_slots_, size_t lines);
+
  private:
   file_cache_slot *evicted_cache_tab_entry (unsigned *highest_use_count);
   file_cache_slot *add_file (const char *file_path);
   file_cache_slot *lookup_file (const char *file_path);
 
  private:
-  static const size_t num_file_slots = 16;
+  static size_t num_file_slots;
   file_cache_slot *m_file_slots;
   input_context m_input_context;
 };
diff --git a/gcc/ipa-free-lang-data.cc b/gcc/ipa-free-lang-data.cc
index cb26e262f45b728a79910744fcbfa7e7c1d71e73..0b666cb225f3d824a42d4bd64af534a1ec792697 100644
--- a/gcc/ipa-free-lang-data.cc
+++ b/gcc/ipa-free-lang-data.cc
@@ -436,9 +436,7 @@ free_lang_data_in_type (tree type, class free_lang_data_d *fld)
 	 different front ends.  */
       for (tree p = TYPE_ARG_TYPES (type); p; p = TREE_CHAIN (p))
 	{
-	  TREE_VALUE (p) = fld_simplified_type (TREE_VALUE (p), fld);
 	  tree arg_type = TREE_VALUE (p);
-
 	  if (TYPE_READONLY (arg_type) || TYPE_VOLATILE (arg_type))
 	    {
 	      int quals = TYPE_QUALS (arg_type)
@@ -448,6 +446,7 @@ free_lang_data_in_type (tree type, class free_lang_data_d *fld)
 	      if (!fld->pset.add (TREE_VALUE (p)))
 		free_lang_data_in_type (TREE_VALUE (p), fld);
 	    }
+	  TREE_VALUE (p) = fld_simplified_type (TREE_VALUE (p), fld);
 	  /* C++ FE uses TREE_PURPOSE to store initial values.  */
 	  TREE_PURPOSE (p) = NULL;
 	}
diff --git a/gcc/ipa-icf-gimple.cc b/gcc/ipa-icf-gimple.cc
index 50b459c74b296872a26d4284d20f9b86caf22856..51ca8a3e114397b80800ef54dd432e25516c2d5b 100644
--- a/gcc/ipa-icf-gimple.cc
+++ b/gcc/ipa-icf-gimple.cc
@@ -459,7 +459,9 @@ func_checker::compare_asm_inputs_outputs (tree t1, tree t2,
 	return false;
 
       if (!compare_operand (TREE_VALUE (t1), TREE_VALUE (t2),
-			    get_operand_access_type (map, t1)))
+			    get_operand_access_type (map, t1))
+	  || !types_compatible_p (TREE_TYPE (TREE_VALUE (t1)),
+				  TREE_TYPE (TREE_VALUE (t2))))
 	return return_false ();
 
       tree p1 = TREE_PURPOSE (t1);
@@ -709,26 +711,37 @@ func_checker::compare_gimple_call (gcall *s1, gcall *s2)
       || gimple_call_alloca_for_var_p (s1) != gimple_call_alloca_for_var_p (s2))
     return false;
 
-  if (gimple_call_internal_p (s1)
-      && gimple_call_internal_fn (s1) != gimple_call_internal_fn (s2))
-    return false;
-
-  tree fntype1 = gimple_call_fntype (s1);
-  tree fntype2 = gimple_call_fntype (s2);
-
-  /* For direct calls we verify that types are compatible so if we matched
-     callees, callers must match, too.  For indirect calls however verify
-     function type.  */
-  if (!gimple_call_fndecl (s1))
+  unsigned check_arg_types_from = 0;
+  if (gimple_call_internal_p (s1))
     {
-      if ((fntype1 && !fntype2)
-	  || (!fntype1 && fntype2)
-	  || (fntype1 && !types_compatible_p (fntype1, fntype2)))
-	return return_false_with_msg ("call function types are not compatible");
+      if (gimple_call_internal_fn (s1) != gimple_call_internal_fn (s2))
+	return false;
     }
+  else
+    {
+      tree fntype1 = gimple_call_fntype (s1);
+      tree fntype2 = gimple_call_fntype (s2);
+      if (!types_compatible_p (fntype1, fntype2))
+	return return_false_with_msg ("call function types are not compatible");
+
+      if (comp_type_attributes (fntype1, fntype2) != 1)
+	return return_false_with_msg ("different fntype attributes");
 
-  if (fntype1 && fntype2 && comp_type_attributes (fntype1, fntype2) != 1)
-    return return_false_with_msg ("different fntype attributes");
+      check_arg_types_from = gimple_call_num_args (s1);
+      if (!prototype_p (fntype1) || !prototype_p (fntype2))
+	check_arg_types_from = 0;
+      else if (stdarg_p (fntype1))
+	{
+	  check_arg_types_from = list_length (TYPE_ARG_TYPES (fntype1));
+	  if (stdarg_p (fntype2))
+	    {
+	      unsigned n = list_length (TYPE_ARG_TYPES (fntype2));
+	      check_arg_types_from = MIN (check_arg_types_from, n);
+	    }
+	}
+      else if (stdarg_p (fntype2))
+	check_arg_types_from = list_length (TYPE_ARG_TYPES (fntype2));
+    }
 
   tree chain1 = gimple_call_chain (s1);
   tree chain2 = gimple_call_chain (s2);
@@ -746,6 +759,10 @@ func_checker::compare_gimple_call (gcall *s1, gcall *s2)
 
       if (!compare_operand (t1, t2, get_operand_access_type (&map, t1)))
 	return return_false_with_msg ("GIMPLE call operands are different");
+      if (i >= check_arg_types_from
+	  && !types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2)))
+	return return_false_with_msg ("GIMPLE call operand types are "
+				      "different");
     }
 
   /* Return value checking.  */
diff --git a/gcc/ira-color.cc b/gcc/ira-color.cc
index 23f68c007573bec87744d47f541343d1d7d11721..0699b349a1afd2da363b155e98cc381f5d57afca 100644
--- a/gcc/ira-color.cc
+++ b/gcc/ira-color.cc
@@ -1752,6 +1752,7 @@ calculate_saved_nregs (int hard_regno, machine_mode mode)
   ira_assert (hard_regno >= 0);
   for (i = hard_regno_nregs (hard_regno, mode) - 1; i >= 0; i--)
     if (!allocated_hardreg_p[hard_regno + i]
+	&& ira_hard_regno_nrefs[hard_regno + i] == 0
 	&& !crtl->abi->clobbers_full_reg_p (hard_regno + i)
 	&& !LOCAL_REGNO (hard_regno + i))
       nregs++;
diff --git a/gcc/ira-int.h b/gcc/ira-int.h
index aa8432416fce9edf2acd842399af95eebe8dba0f..49e086e4d4b139bdb2704bbdde42584c70a3a5aa 100644
--- a/gcc/ira-int.h
+++ b/gcc/ira-int.h
@@ -936,6 +936,9 @@ public:
 
   /* Flag of that the above array has been initialized.  */
   bool x_ira_prohibited_mode_move_regs_initialized_p;
+
+  /* Number of real occurences of hard regs before IRA.  */
+  size_t x_ira_hard_regno_nrefs[FIRST_PSEUDO_REGISTER];
 };
 
 extern class target_ira_int default_target_ira_int;
@@ -983,6 +986,8 @@ extern class target_ira_int *this_target_ira_int;
   (this_target_ira_int->x_ira_reg_class_superunion)
 #define ira_prohibited_mode_move_regs \
   (this_target_ira_int->x_ira_prohibited_mode_move_regs)
+#define ira_hard_regno_nrefs \
+  (this_target_ira_int->x_ira_hard_regno_nrefs)
 
 /* ira.cc: */
 
diff --git a/gcc/ira.cc b/gcc/ira.cc
index ad522b00f8b56fac32fac88e2d8168b060c25315..885239d1b43cbb9a912ada1a9d7a5060ad41404e 100644
--- a/gcc/ira.cc
+++ b/gcc/ira.cc
@@ -1416,7 +1416,7 @@ find_reg_classes (void)
 
 
 
-/* Set up the array above.  */
+/* Set up array ira_hard_regno_allocno_class.  */
 static void
 setup_hard_regno_aclass (void)
 {
@@ -1424,25 +1424,10 @@ setup_hard_regno_aclass (void)
 
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
     {
-#if 1
       ira_hard_regno_allocno_class[i]
 	= (TEST_HARD_REG_BIT (no_unit_alloc_regs, i)
 	   ? NO_REGS
 	   : ira_allocno_class_translate[REGNO_REG_CLASS (i)]);
-#else
-      int j;
-      enum reg_class cl;
-      ira_hard_regno_allocno_class[i] = NO_REGS;
-      for (j = 0; j < ira_allocno_classes_num; j++)
- 	{
-	  cl = ira_allocno_classes[j];
- 	  if (ira_class_hard_reg_index[cl][i] >= 0)
- 	    {
-	      ira_hard_regno_allocno_class[i] = cl;
- 	      break;
- 	    }
- 	}
-#endif
     }
 }
 
@@ -5549,6 +5534,30 @@ static int saved_flag_ira_share_spill_slots;
 /* Set to true while in IRA.  */
 bool ira_in_progress = false;
 
+/* Set up array ira_hard_regno_nrefs.  */
+static void
+setup_hard_regno_nrefs (void)
+{
+  int i;
+
+  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+    {
+      ira_hard_regno_nrefs[i] = 0;
+      for (df_ref use = DF_REG_USE_CHAIN (i);
+	   use != NULL;
+	   use = DF_REF_NEXT_REG (use))
+	if (DF_REF_CLASS (use) != DF_REF_ARTIFICIAL
+	    && !(DF_REF_INSN_INFO (use) && DEBUG_INSN_P (DF_REF_INSN (use))))
+	  ira_hard_regno_nrefs[i]++;
+      for (df_ref def = DF_REG_DEF_CHAIN (i);
+	   def != NULL;
+	   def = DF_REF_NEXT_REG (def))
+	if (DF_REF_CLASS (def) != DF_REF_ARTIFICIAL
+	    && !(DF_REF_INSN_INFO (def) && DEBUG_INSN_P (DF_REF_INSN (def))))
+	  ira_hard_regno_nrefs[i]++;
+    }
+}
+
 /* This is the main entry of IRA.  */
 static void
 ira (FILE *f)
@@ -5562,6 +5571,7 @@ ira (FILE *f)
   edge e;
   bool output_jump_reload_p = false;
 
+  setup_hard_regno_nrefs ();
   if (ira_use_lra_p)
     {
       /* First put potential jump output reloads on the output edges
diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog
index 7d35e8c5dfeffde8dfb224971929b680c75efb86..97ce9b73d95956b74b3e393ea2d09f214b71d5c8 100644
--- a/gcc/jit/ChangeLog
+++ b/gcc/jit/ChangeLog
@@ -1,3 +1,14 @@
+2025-01-24  David Malcolm  <dmalcolm@redhat.com>
+
+	PR jit/117886
+	* jit-recording.cc (reproducer::get_identifier_as_rvalue): Handle
+	null memento.
+	(reproducer::get_identifier_as_lvalue): Likewise.
+	(reproducer::get_identifier_as_type): Likewise.
+	(recording::ctor::write_reproducer): Use get_identifier_as_rvalue
+	rather than get_identifier when writing out gcc_jit_rvalue *
+	expressions.
+
 2025-01-22  David Malcolm  <dmalcolm@redhat.com>
 
 	* dummy-frontend.cc (tree_type_to_jit_type): For POINTER_TYPE,
diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc
index e6fef5bca076b79ae1e3ec2fd374c0115b012ca4..8da3cb0591568a379b0ba7092b72eed7368de03b 100644
--- a/gcc/jit/jit-recording.cc
+++ b/gcc/jit/jit-recording.cc
@@ -406,6 +406,8 @@ reproducer::get_identifier (recording::memento *m)
 const char *
 reproducer::get_identifier_as_rvalue (recording::rvalue *m)
 {
+  if (!m)
+    return "NULL";
   return m->access_as_rvalue (*this);
 }
 
@@ -415,6 +417,8 @@ reproducer::get_identifier_as_rvalue (recording::rvalue *m)
 const char *
 reproducer::get_identifier_as_lvalue (recording::lvalue *m)
 {
+  if (!m)
+    return "NULL";
   return m->access_as_lvalue (*this);
 }
 
@@ -424,6 +428,8 @@ reproducer::get_identifier_as_lvalue (recording::lvalue *m)
 const char *
 reproducer::get_identifier_as_type (recording::type *m)
 {
+  if (!m)
+    return "NULL";
   return m->access_as_type (*this);
 }
 
@@ -6041,7 +6047,7 @@ recording::ctor::write_reproducer (reproducer &r)
 	r.write ("    gcc_jit_rvalue *value = NULL;\n");
       else
 	r.write ("    gcc_jit_rvalue *value = %s;\n",
-		 r.get_identifier (m_values[0]));
+		 r.get_identifier_as_rvalue (m_values[0]));
 
       if (m_fields.length () == 0)
 	r.write ("    gcc_jit_field *field = NULL;\n");
@@ -6058,7 +6064,7 @@ recording::ctor::write_reproducer (reproducer &r)
 	{
 	  r.write ("    gcc_jit_rvalue *values[] = {\n");
 	  for (size_t i = 0; i < m_values.length (); i++)
-	    r.write ("        %s,\n", r.get_identifier (m_values[i]));
+	    r.write ("        %s,\n", r.get_identifier_as_rvalue (m_values[i]));
 	  r.write ("      };\n");
 	}
       /* Write the array of fields.  */
diff --git a/gcc/libsarifreplay.cc b/gcc/libsarifreplay.cc
index eb829064194d8c65fec472f8da7d32734f5aec28..61d9565588ed6022fb519056fe517aa77526e4a6 100644
--- a/gcc/libsarifreplay.cc
+++ b/gcc/libsarifreplay.cc
@@ -277,6 +277,7 @@ private:
   // "result" object (§3.27)
   enum status
   handle_result_obj (const json::object &result_obj,
+		     const json::object &run_obj,
 		     const json::object &tool_obj);
   json::result<enum diagnostic_level, enum status>
   get_level_from_level_str (const json::string &level_str);
@@ -284,6 +285,7 @@ private:
   // "location" object (§3.28)
   enum status
   handle_location_object (const json::object &location_obj,
+			  const json::object &run_obj,
 			  libgdiagnostics::physical_location &out_physical_loc,
 			  libgdiagnostics::logical_location &out_logical_loc);
 
@@ -301,16 +303,19 @@ private:
   // "logicalLocation" object (§3.33)
   enum status
   handle_logical_location_object (const json::object &logical_loc_obj,
+				  const json::object *run_obj,
 				  libgdiagnostics::logical_location &out);
 
   // "threadFlow" object (§3.37)
   enum status
   handle_thread_flow_object (const json::object &thread_flow_obj,
+			     const json::object &run_obj,
 			     libgdiagnostics::execution_path &out);
 
   // "threadFlowLocation" object (§3.38)
   enum status
   handle_thread_flow_location_object (const json::object &tflow_loc_obj,
+				      const json::object &run_obj,
 				      libgdiagnostics::execution_path &out);
 
   // reportingDescriptor lookup (§3.52.3)
@@ -806,7 +811,9 @@ sarif_replayer::handle_run_obj (const json::object &run_obj)
 		= require_object_for_element (*element, prop_results);
 	      if (!result_obj)
 		return status::err_invalid_sarif;
-	      enum status s = handle_result_obj (*result_obj, *tool_obj);
+	      enum status s = handle_result_obj (*result_obj,
+						 run_obj,
+						 *tool_obj);
 	      if (s != status::ok)
 		return s;
 	    }
@@ -974,6 +981,7 @@ sarif_replayer::get_level_from_level_str (const json::string &level_str)
 
 enum status
 sarif_replayer::handle_result_obj (const json::object &result_obj,
+				   const json::object &run_obj,
 				   const json::object &tool_obj)
 {
   const json::object *rule_obj = nullptr;
@@ -1025,7 +1033,7 @@ sarif_replayer::handle_result_obj (const json::object &result_obj,
 	= require_object_for_element (*locations_arr->get (0), locations_prop);
       if (!location_obj)
 	return status::err_invalid_sarif;
-      enum status s = handle_location_object (*location_obj,
+      enum status s = handle_location_object (*location_obj, run_obj,
 					      physical_loc,
 					      logical_loc);
       if (s != status::ok)
@@ -1059,7 +1067,7 @@ sarif_replayer::handle_result_obj (const json::object &result_obj,
 						  prop_thread_flows);
 		  if (!thread_flow_obj)
 		    return status::err_invalid_sarif;
-		  handle_thread_flow_object (*thread_flow_obj, path);
+		  handle_thread_flow_object (*thread_flow_obj, run_obj, path);
 		}
 	    }
 	}
@@ -1104,7 +1112,7 @@ sarif_replayer::handle_result_obj (const json::object &result_obj,
 					  prop_related_locations);
 	  if (!location_obj)
 	    return status::err_invalid_sarif;
-	  enum status s = handle_location_object (*location_obj,
+	  enum status s = handle_location_object (*location_obj, run_obj,
 						  physical_loc,
 						  logical_loc);
 	  if (s != status::ok)
@@ -1438,6 +1446,7 @@ lookup_plain_text_within_result_message (const json::object *tool_component_obj,
 
 enum status
 sarif_replayer::handle_thread_flow_object (const json::object &thread_flow_obj,
+					   const json::object &run_obj,
 					   libgdiagnostics::execution_path &out)
 {
   const property_spec_ref locations ("threadFlow", "locations", "3.37.6");
@@ -1454,7 +1463,7 @@ sarif_replayer::handle_thread_flow_object (const json::object &thread_flow_obj,
 	= require_object_for_element (*location, locations);
       if (!tflow_loc_obj)
 	return status::err_invalid_sarif;
-      handle_thread_flow_location_object (*tflow_loc_obj, out);
+      handle_thread_flow_location_object (*tflow_loc_obj, run_obj, out);
     }
 
   return status::ok;
@@ -1466,6 +1475,7 @@ sarif_replayer::handle_thread_flow_object (const json::object &thread_flow_obj,
 enum status
 sarif_replayer::
 handle_thread_flow_location_object (const json::object &tflow_loc_obj,
+				    const json::object &run_obj,
 				    libgdiagnostics::execution_path &path)
 {
   libgdiagnostics::physical_location physical_loc;
@@ -1479,8 +1489,8 @@ handle_thread_flow_location_object (const json::object &tflow_loc_obj,
 							       location_prop))
     {
       /* location object (§3.28).  */
-      enum status s
-	= handle_location_object (*location_obj, physical_loc, logical_loc);
+      enum status s = handle_location_object (*location_obj, run_obj,
+					      physical_loc, logical_loc);
       if (s != status::ok)
 	return s;
 
@@ -1552,6 +1562,7 @@ handle_thread_flow_location_object (const json::object &tflow_loc_obj,
 enum status
 sarif_replayer::
 handle_location_object (const json::object &location_obj,
+			const json::object &run_obj,
 			libgdiagnostics::physical_location &out_physical_loc,
 			libgdiagnostics::logical_location &out_logical_loc)
 {
@@ -1586,6 +1597,7 @@ handle_location_object (const json::object &location_obj,
 	  if (!logical_loc_obj)
 	    return status::err_invalid_sarif;
 	  enum status s = handle_logical_location_object (*logical_loc_obj,
+							  &run_obj,
 							  out_logical_loc);
 	  if (s != status::ok)
 	    return s;
@@ -1743,6 +1755,10 @@ handle_region_object (const json::object &region_obj,
 }
 
 /* Handle a "logicalLocation" object (§3.33), using it to populate OUT.
+
+   If RUN_OBJ is non-null, and has "logicalLocations", then use it if we
+   see an "index" property.
+
    Known limitations:
    - doesn't yet handle "parentIndex" property (§3.33.8)
 */
@@ -1750,8 +1766,48 @@ handle_region_object (const json::object &region_obj,
 enum status
 sarif_replayer::
 handle_logical_location_object (const json::object &logical_loc_obj,
+				const json::object *run_obj,
 				libgdiagnostics::logical_location &out)
 {
+  if (run_obj)
+    {
+      const property_spec_ref name_prop ("logicalLocation", "index", "3.33.3");
+      if (auto index_js_int
+	    = get_optional_property<json::integer_number> (logical_loc_obj,
+							   name_prop))
+	{
+	  const long index = index_js_int->get ();
+	  /* If "index" is present, then there must be theRun.logicalLocations
+	     and it must have a cached object at that index.  */
+	  const property_spec_ref run_logical_locs_prop
+	    ("run", "logicalLocations", "3.14.17");
+	  if (auto logical_locs_arr
+		= get_required_property<json::array> (*run_obj,
+						      run_logical_locs_prop))
+	    {
+	      /* "index" must be in range */
+	      if (index < 0 || index >= (long)logical_locs_arr->length ())
+		return report_invalid_sarif (*index_js_int, name_prop,
+					     "index value %li is out of range"
+					     " for theRun.logicalLocations",
+					     index);
+
+	      json::value *element = logical_locs_arr->get (index);
+
+	      if (const json::object *obj
+		    = require_object (*element,run_logical_locs_prop))
+		{
+		  /* Use this "cached" object instead.
+		     Pass nullptr for the run object so that we
+		     don't recurse.  */
+		  return handle_logical_location_object (*obj, nullptr, out);
+		}
+	    }
+	}
+    }
+
+  // Otherwise use the properties from LOGICAL_LOC_OBJ.
+
   const property_spec_ref name_prop ("logicalLocation", "name", "3.33.4");
   const char *short_name = nullptr;
   if (auto name_jstr = get_optional_property<json::string> (logical_loc_obj,
diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc
index 797222c9fbc26589c2d25f8fd111a75a7d78b570..0659aed94c7d0b9fbc07f420b310a4c08871284f 100644
--- a/gcc/lra-constraints.cc
+++ b/gcc/lra-constraints.cc
@@ -4138,8 +4138,28 @@ static bool invalid_mode_reg_p (enum machine_mode mode, rtx x)
   if (! REG_P (x))
     return false;
   enum reg_class rclass = get_reg_class (REGNO (x));
-  return hard_reg_set_subset_p (reg_class_contents[rclass],
-				ira_prohibited_class_mode_regs[rclass][mode]);
+  return (!hard_reg_set_empty_p (reg_class_contents[rclass])
+	  && hard_reg_set_subset_p
+	     (reg_class_contents[rclass],
+	      ira_prohibited_class_mode_regs[rclass][mode]));
+}
+
+/* Return TRUE if regno is referenced in more than one non-debug insn.  */
+static bool
+multiple_insn_refs_p (int regno)
+{
+  unsigned int uid;
+  bitmap_iterator bi;
+  int nrefs = 0;
+  EXECUTE_IF_SET_IN_BITMAP (&lra_reg_info[regno].insn_bitmap, 0, uid, bi)
+    {
+      if (!NONDEBUG_INSN_P (lra_insn_recog_data[uid]->insn))
+	continue;
+      if (nrefs == 1)
+	return true;
+      nrefs++;
+    }
+  return false;
 }
 
 /* Main entry point of the constraint code: search the body of the
@@ -4600,7 +4620,7 @@ curr_insn_transform (bool check_only_p)
 		 registers for other pseudos referenced in the insn.  The most
 		 common case of this is a scratch register which will be
 		 transformed to scratch back at the end of LRA.  */
-	      && bitmap_single_bit_set_p (&lra_reg_info[regno].insn_bitmap))
+	      && !multiple_insn_refs_p (regno))
 	    {
 	      if (lra_get_allocno_class (regno) != NO_REGS)
 		lra_change_class (regno, NO_REGS, "      Change to", true);
diff --git a/gcc/lra-remat.cc b/gcc/lra-remat.cc
index bb13c616a740a78b7c74fa5c50b09737fcee7421..2f3afffcf5bed774185a7c098f82028e0f438035 100644
--- a/gcc/lra-remat.cc
+++ b/gcc/lra-remat.cc
@@ -459,7 +459,8 @@ create_cands (void)
 	    if (insn2 != NULL
 		&& dst_regno >= FIRST_PSEUDO_REGISTER
 		&& reg_renumber[dst_regno] < 0
-		&& BLOCK_FOR_INSN (insn2) == BLOCK_FOR_INSN (insn))
+		&& BLOCK_FOR_INSN (insn2) == BLOCK_FOR_INSN (insn)
+		&& insn2 == prev_nonnote_insn (insn))
 	      {
 		create_cand (insn2, regno_potential_cand[src_regno].nop,
 			     dst_regno, insn);
@@ -473,9 +474,10 @@ create_cands (void)
 	    gcc_assert (REG_P (*id->operand_loc[nop]));
 	    int regno = REGNO (*id->operand_loc[nop]);
 	    gcc_assert (regno >= FIRST_PSEUDO_REGISTER);
-	    /* If we're setting an unrenumbered pseudo, make a candidate immediately.
-	       If it's an output reload register, save it for later; the code above
-	       looks for output reload insns later on.  */
+	    /* If we're setting an unrenumbered pseudo, make a candidate
+	       immediately.  If it's a potential output reload register, save
+	       it for later; the code above looks for output reload insns later
+	       on.  */
 	    if (reg_renumber[regno] < 0)
 	      create_cand (insn, nop, regno);
 	    else if (regno >= lra_constraint_new_regno_start)
diff --git a/gcc/m2/ChangeLog b/gcc/m2/ChangeLog
index 93b5ff1022ba90bf52c7eb539a6c89a6760e83ea..d5e21dea05e69fcfc8f8a0262f02fdb4d81a7410 100644
--- a/gcc/m2/ChangeLog
+++ b/gcc/m2/ChangeLog
@@ -1,3 +1,256 @@
+2025-02-04  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/115112
+	* gm2-compiler/M2Quads.mod (BuildPseudoProcedureCall): Pass
+	tokno to each build procedure.
+	(BuildThrowProcedure): New parameter functok.
+	(BuildIncProcedure): New parameter proctok.
+	Pass proctok on the quad stack during every push.
+	(BuildDecProcedure): Ditto.
+	(BuildInclProcedure): New parameter proctok.
+	(BuildExclProcedure): New parameter proctok.
+
+2025-02-01  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/118703
+	* gm2-gcc/m2builtins.cc (define_builtin_gcc): New function.
+	(m2builtins_init): Call define_builtin_gcc.
+	* gm2-libs/Builtins.def (clz): New procedure function.
+	(clzll): Ditto.
+	(ctz): Ditto.
+	(ctzll): Ditto.
+	* gm2-libs/Builtins.mod (clz): New procedure function.
+	(clzll): Ditto.
+	(ctz): Ditto.
+	(ctzll): Ditto.
+	* gm2-libs/cbuiltin.def (clz): New procedure function.
+	(clzll): Ditto.
+	(ctz): Ditto.
+	(ctzll): Ditto.
+
+2025-01-29  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/118010
+	PR modula2/118183
+	PR modula2/116073
+	* gm2-compiler/M2Options.mod (OffTBits): Assign to 0.
+	* gm2-gcc/m2type.cc (build_m2_specific_size_type): Ensure that
+	layout_type is called before returning c.
+	(build_m2_offt_type_node): If GetFileOffsetBits returns 0 then
+	use the type size of ssize_t.
+
+2025-01-26  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	* gm2-compiler/M2GenGCC.mod (FoldConstBecomes): Remove
+	commented out code.
+	Improve early return comment.
+
+2025-01-26  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	* gm2-compiler/M2GenGCC.mod (FoldStatementNote): Add header
+	comment.
+	(CodeStatementNote): Ditto.
+	(FoldRange): Tidy comment.
+	(CodeError): Ditto.
+	(CodeProcedureScope): Ditto.
+	(CheckConvertCoerceParameter): Replace op1 with nth.
+	Replace op2 with callee.
+	Replace op3 with actual.
+
+2025-01-25  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/117737
+	PR modula2/118010
+	* Make-maintainer.in (PGE-MC-OPTIONS): New macro.
+	(m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.o): Use $(PGE-MC-OPTIONS).
+	(m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.o): Ditto.
+	(m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.o): Ditto.
+	(m2/gm2-pge-boot/$(SRC_PREFIX)Lists.o): Ditto.
+	(m2/gm2-pge-boot/$(SRC_PREFIX)Output.o): Ditto.
+	(m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.o): Ditto.
+	(m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.o): Ditto.
+	(m2/gm2-pge-boot/$(SRC_PREFIX)%.o): Ditto.
+	(m2/gm2-pge-boot/$(SRC_PREFIX)pge.o): Ditto.
+	(m2/gm2-auto/pg.o): Ditto.
+	(m2/gm2-auto/pge.o): Ditto.
+	(mc-autogen): Add include directory $(GMPINC) to $(CXX).
+	* mc/keyc.mod (checkGccConfigSystem): Remove
+	INCLUDE_MEMORY define.
+	* mc-boot/GASCII.cc (INCLUDE_MEMORY): Removed during rebuild.
+	* mc-boot/GASCII.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GArgs.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GArgs.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GAssertion.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GAssertion.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GBreak.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GBreak.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GCOROUTINES.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GCmdArgs.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GCmdArgs.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GDebug.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GDebug.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GDynamicStrings.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GDynamicStrings.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GEnvironment.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GEnvironment.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GFIO.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GFIO.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GFormatStrings.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GFormatStrings.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GFpuIO.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GFpuIO.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GIO.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GIO.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GIndexing.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GIndexing.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GM2Dependent.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GM2Dependent.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GM2EXCEPTION.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GM2EXCEPTION.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GM2RTS.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GM2RTS.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GMemUtils.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GMemUtils.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GNumberIO.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GNumberIO.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GPushBackInput.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GPushBackInput.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GRTExceptions.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GRTExceptions.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GRTco.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GRTentity.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GRTint.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GRTint.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GSArgs.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GSArgs.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GSFIO.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GSFIO.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GSYSTEM.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GSelective.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GStdIO.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GStdIO.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GStorage.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GStorage.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GStrCase.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GStrCase.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GStrIO.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GStrIO.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GStrLib.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GStrLib.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GStringConvert.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GStringConvert.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GSysExceptions.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GSysStorage.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GSysStorage.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GTimeString.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GTimeString.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GUnixArgs.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Galists.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Galists.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gdecl.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gdecl.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gdtoa.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gerrno.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gkeyc.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gkeyc.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gldtoa.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Glibc.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Glibm.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Glists.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Glists.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcComment.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcComment.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcComp.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcComp.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcDebug.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcDebug.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcError.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcError.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcFileName.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcFileName.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcLexBuf.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcLexBuf.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcMetaError.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcMetaError.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcOptions.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcOptions.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcPreprocess.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcPreprocess.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcPretty.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcPretty.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcPrintf.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcPrintf.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcQuiet.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcQuiet.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcReserved.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcReserved.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcSearch.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcSearch.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcStack.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcStack.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcStream.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GmcStream.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gmcflex.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gmcp1.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gmcp1.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gmcp2.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gmcp2.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gmcp3.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gmcp3.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gmcp4.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gmcp4.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gmcp5.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gmcp5.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GnameKey.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GnameKey.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GsymbolKey.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/GsymbolKey.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gtermios.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gtop.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gvarargs.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gvarargs.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gwlists.cc (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gwlists.h (INCLUDE_MEMORY): Ditto.
+	* mc-boot/Gwrapc.h (INCLUDE_MEMORY): Ditto.
+	* pge-boot/GIndexing.h (INCLUDE_MEMORY): Ditto.
+	* pge-boot/GSEnvironment.h (INCLUDE_MEMORY): Ditto.
+	* pge-boot/GScan.h (INCLUDE_MEMORY): Ditto.
+
+2025-01-25  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/118010
+	* gm2-libs-log/FileSystem.mod (doModeChange): Replace
+	LONGINT with COFF_T.
+	(SetPos): Use COFF_T for the return value and offset type
+	when calling lseek.
+	* gm2-libs/FIO.mod (SetPositionFromBeginning): Convert pos
+	to COFF_T.
+	(SetPositionFromEnd): Ditto.
+	* mc-boot/GFIO.cc: Rebuild.
+	* mc-boot/Glibc.h: Ditto.
+	* pge-boot/GFIO.cc: Ditto.
+	* pge-boot/Glibc.h: Ditto.
+
+2025-01-25  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/118010
+	* gm2-compiler/P2SymBuild.mod (Debug): Comment out unused
+	procedure.
+	* gm2-libs/libc.def (lseek): Declare second parameter offset
+	as COFF_T.
+
+2025-01-25  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/118589
+	* gm2-compiler/M2MetaError.mod (symDesc): Add opaque type
+	description.
+	* gm2-compiler/M2Quads.mod (BuildDesignatorPointerError): New
+	procedure.
+	(BuildDesignatorPointer): Reimplement.
+	* gm2-compiler/P3Build.bnf (SubDesignator): Tidy up error message.
+	Use MetaErrorT2 rather than WriteForma1 and use the token pos from
+	the quad stack.
+
 2025-01-13  Gaius Mulley  <gaiusmod2@gmail.com>
 
 	PR modula2/116557
diff --git a/gcc/m2/Make-maintainer.in b/gcc/m2/Make-maintainer.in
index dea50004576c9ac7f229b2dafda4ae18994bfc3c..ad89474f375460e158259a9884b5b31f83e3b9e2 100644
--- a/gcc/m2/Make-maintainer.in
+++ b/gcc/m2/Make-maintainer.in
@@ -620,6 +620,7 @@ BUILD-PGE-O = $(PPG-INTERFACE-C:%.c=m2/gm2-pge-boot/$(SRC_PREFIX)%.o) \
               $(PGE-SRC:%.mod=m2/gm2-pge-boot/$(SRC_PREFIX)%.o)
 
 BUILD-BOOT-PGE-H = $(BUILD-BOOT-H) $(PGE-DEF:%.def=m2/gm2-pge-boot/$(SRC_PREFIX)%.h)
+PGE-MC-OPTIONS = --gcc-config-system 
 
 m2/gm2-auto/pge.mod: m2/pg$(exeext)
 	-test -d m2/gm2-auto || $(mkinstalldirs) m2/gm2-auto
@@ -676,7 +677,7 @@ m2/gm2-pge-boot/$(SRC_PREFIX)errno.o:  $(srcdir)/m2/mc-boot-ch/Gerrno.cc
 
 m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.o: $(srcdir)/m2/gm2-libs/M2RTS.mod $(MCDEPS) $(BUILD-BOOT-PGE-H)
 	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
-	$(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.cc $(srcdir)/m2/gm2-libs/M2RTS.mod
+	$(MCC) $(PGE-MC-OPTIONS) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.cc $(srcdir)/m2/gm2-libs/M2RTS.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \
               -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \
               $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.cc -o $@
@@ -689,7 +690,7 @@ m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.o: $(srcdir)/m2/gm2-compiler/SymbolKey.mo
                                           $(MCDEPS) $(BUILD-BOOT-PGE-H) \
                                           m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.h
 	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
-	$(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.cc $(srcdir)/m2/gm2-compiler/SymbolKey.mod
+	$(MCC) $(PGE-MC-OPTIONS) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.cc $(srcdir)/m2/gm2-compiler/SymbolKey.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \
               -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \
               $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.cc -o $@
@@ -702,7 +703,7 @@ m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.o: $(srcdir)/m2/gm2-compiler/NameKey.mod \
                                         $(MCDEPS) $(BUILD-BOOT-PGE-H) \
                                         m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.h
 	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
-	$(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.cc $(srcdir)/m2/gm2-compiler/NameKey.mod
+	$(MCC) $(PGE-MC-OPTIONS) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.cc $(srcdir)/m2/gm2-compiler/NameKey.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \
               -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \
               $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.cc -o $@
@@ -715,7 +716,7 @@ m2/gm2-pge-boot/$(SRC_PREFIX)Lists.o: $(srcdir)/m2/gm2-compiler/Lists.mod \
                                       $(MCDEPS) $(BUILD-BOOT-PGE-H) \
                                       m2/gm2-pge-boot/$(SRC_PREFIX)Lists.h
 	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
-	$(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)Lists.cc $(srcdir)/m2/gm2-compiler/Lists.mod
+	$(MCC) $(PGE-MC-OPTIONS) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)Lists.cc $(srcdir)/m2/gm2-compiler/Lists.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \
               -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \
               $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)Lists.cc -o $@
@@ -728,7 +729,7 @@ m2/gm2-pge-boot/$(SRC_PREFIX)Output.o: $(srcdir)/m2/gm2-compiler/Output.mod \
                                       $(MCDEPS) $(BUILD-BOOT-PGE-H) \
                                       m2/gm2-pge-boot/$(SRC_PREFIX)Output.h
 	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
-	$(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)Output.cc $(srcdir)/m2/gm2-compiler/Output.mod
+	$(MCC) $(PGE-MC-OPTIONS) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)Output.cc $(srcdir)/m2/gm2-compiler/Output.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \
               -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \
               $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)Output.cc -o $@
@@ -741,7 +742,7 @@ m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.o: $(srcdir)/m2/gm2-compiler/bnflex.mod \
                                       $(MCDEPS) $(BUILD-BOOT-PGE-H) \
                                       m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.h
 	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
-	$(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.cc $(srcdir)/m2/gm2-compiler/bnflex.mod
+	$(MCC) $(PGE-MC-OPTIONS) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.cc $(srcdir)/m2/gm2-compiler/bnflex.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \
               -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \
               $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.cc -o $@
@@ -764,28 +765,28 @@ m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.o: $(srcdir)/m2/gm2-libs-iso/RTentity.mod
                                       $(MCDEPS) $(BUILD-BOOT-PGE-H) \
                                       m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.h
 	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
-	$(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.cc $(srcdir)/m2/gm2-libs-iso/RTentity.mod
+	$(MCC) $(PGE-MC-OPTIONS) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.cc $(srcdir)/m2/gm2-libs-iso/RTentity.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \
               -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \
               $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.cc -o $@
 
 m2/gm2-pge-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-PGE-H)
 	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
-	$(MCC) -o=m2/gm2-pge-boot/$(SRC_PREFIX)$*.cc $(srcdir)/m2/gm2-libs/$*.mod
+	$(MCC) $(PGE-MC-OPTIONS) -o=m2/gm2-pge-boot/$(SRC_PREFIX)$*.cc $(srcdir)/m2/gm2-libs/$*.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/pge-boot -I$(srcdir)/m2/mc-boot \
               -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \
               $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)$*.cc -o $@
 
 m2/gm2-pge-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-compiler/%.mod $(MCDEPS) $(BUILD-BOOT-PGE-H)
 	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
-	$(MCC) -o=m2/gm2-pge-boot/$(SRC_PREFIX)$*.cc $(srcdir)/m2/gm2-compiler/$*.mod
+	$(MCC) $(PGE-MC-OPTIONS) -o=m2/gm2-pge-boot/$(SRC_PREFIX)$*.cc $(srcdir)/m2/gm2-compiler/$*.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot -Im2/gm2-compiler-boot \
               -Im2/gm2-libs-boot -Im2/gm2-pge-boot \
               -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)$*.cc -o $@
 
 m2/gm2-pge-boot/$(SRC_PREFIX)pge.o:  m2/gm2-auto/pge.mod $(MCDEPS) $(BUILD-BOOT-PGE-H)
 	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
-	$(MCC) -o=m2/gm2-pge-boot/$(SRC_PREFIX)pge.cc m2/gm2-auto/pge.mod
+	$(MCC) $(PGE-MC-OPTIONS) -o=m2/gm2-pge-boot/$(SRC_PREFIX)pge.cc m2/gm2-auto/pge.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) \
               -I$(srcdir)/m2/mc-boot -Im2/gm2-compiler-boot -Im2/gm2-libs-boot \
               -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)pge.cc -o $@
@@ -829,12 +830,12 @@ $(objdir)/m2/gm2-pge-boot:
 
 m2/gm2-auto/pg.o: m2/gm2-auto/pg.mod $(MCDEPS)
 	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
-	$(MC) --quiet -o=m2/gm2-auto/pg.c m2/gm2-auto/pg.mod
+	$(MC) $(PGE-MC-OPTIONS) --quiet -o=m2/gm2-auto/pg.c m2/gm2-auto/pg.mod
 	$(COMPILER) -c $(CFLAGS) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) m2/gm2-auto/pg.c -o $@
 
 m2/gm2-auto/pge.o: m2/gm2-auto/pge.mod $(MCDEPS)
 	-test -d m2/gm2-auto || $(mkinstalldirs) m2/gm2-auto
-	$(MC) --quiet -o=m2/gm2-auto/pge.c m2/gm2-auto/pge.mod
+	$(MC) $(PGE-MC-OPTIONS) --quiet -o=m2/gm2-auto/pge.c m2/gm2-auto/pge.mod
 	$(COMPILER) -c $(CFLAGS) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) m2/gm2-auto/pge.c -o $@
 
 pge-help: force
@@ -1061,8 +1062,8 @@ mc-autogen: mc-clean mc-devel \
             $(BUILD-MC-BOOT-H) $(BUILD-MC-BOOT-CC) \
             $(BUILD-MC-BOOT-AUTO-CC)
 	for i in m2/mc-boot-gen/*.cc ; do \
-           echo $(CXX) -g -c -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/mc-boot-gen/ $$i -o m2/mc-boot-gen/`basename $$i .cc`.o ; \
-                $(CXX) -g -c -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/mc-boot-gen/ $$i -o m2/mc-boot-gen/`basename $$i .cc`.o ; done
+           echo $(CXX) -g -c -I. $(GMPINC) -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/mc-boot-gen/ $$i -o m2/mc-boot-gen/`basename $$i .cc`.o ; \
+                $(CXX) -g -c -I. $(GMPINC) -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/mc-boot-gen/ $$i -o m2/mc-boot-gen/`basename $$i .cc`.o ; done
 	@echo -n "built "
 	@cd m2/mc-boot-gen ; ls *.o | wc -l
 	@echo -n "out of "
diff --git a/gcc/m2/gm2-compiler/M2GenGCC.mod b/gcc/m2/gm2-compiler/M2GenGCC.mod
index 7ddcc1622900842ad8850cc1d0088fa54db79ea1..bba77ff12e112b6544ab243b37e178515c8083f0 100644
--- a/gcc/m2/gm2-compiler/M2GenGCC.mod
+++ b/gcc/m2/gm2-compiler/M2GenGCC.mod
@@ -614,7 +614,7 @@ BEGIN
    GetQuad(q, op, op1, op2, op3) ;
    IF op=StatementNoteOp
    THEN
-      FoldStatementNote (op3)  (* will change CurrentQuadToken using op3  *)
+      FoldStatementNote (op3)  (* Will change CurrentQuadToken using op3.  *)
    ELSE
       CurrentQuadToken := QuadToTokenNo (q)
    END ;
@@ -701,7 +701,7 @@ BEGIN
 
    InlineOp           : CodeInline (q) |
    StatementNoteOp    : CodeStatementNote (op3) |
-   CodeOnOp           : |           (* the following make no sense with gcc *)
+   CodeOnOp           : |           (* The following make no sense with gcc.  *)
    CodeOffOp          : |
    ProfileOnOp        : |
    ProfileOffOp       : |
@@ -812,7 +812,7 @@ BEGIN
          LastForIteratorOp  : FoldLastForIterator (quad, p)
 
          ELSE
-            (* ignore quadruple as it is not associated with a constant expression *)
+            (* Ignore quadruple as it is not associated with a constant expression.  *)
          END ;
          quad := GetNextQuad (quad)
       END ;
@@ -969,12 +969,6 @@ BEGIN
                             str)
             END
          END ;
-(*
-         IF obj#NulSym
-         THEN
-            InternalError ('not expecting the object to be non null in the trash list')
-         END ;
-*)
          INC (i)
       UNTIL (str = NulSym) AND (obj = NulSym)
    END ;
@@ -1021,7 +1015,7 @@ END CodeInline ;
 
 
 (*
-   FoldStatementNote -
+   FoldStatementNote - set CurrentQuadToken to tokennno.
 *)
 
 PROCEDURE FoldStatementNote (tokenno: CARDINAL) ;
@@ -1031,7 +1025,8 @@ END FoldStatementNote ;
 
 
 (*
-   CodeStatementNote -
+   CodeStatementNote - set CurrentQuadToken to tokennno and
+                       add a statement note.
 *)
 
 PROCEDURE CodeStatementNote (tokenno: CARDINAL) ;
@@ -1043,7 +1038,7 @@ END CodeStatementNote ;
 
 (*
    FoldRange - attempts to fold the range test.
-               --fixme-- complete this
+               --fixme-- complete this.
 *)
 
 PROCEDURE FoldRange (tokenno: CARDINAL; (* p: WalkAction; *)
@@ -1073,7 +1068,7 @@ END CodeSaveException ;
 
 
 (*
-   CodeRestoreException - op1 := op3(op1)
+   CodeRestoreException - op1 := op3(op1).
 *)
 
 PROCEDURE CodeRestoreException (des, exceptionProcedure: CARDINAL) ;
@@ -1171,7 +1166,7 @@ END CodeRange ;
 
 PROCEDURE CodeError (errorId: CARDINAL) ;
 BEGIN
-   (* would like to test whether this position is in the same basicblock
+   (* We would like to test whether this position is in the same basicblock
       as any known entry point.  If so we could emit an error message.
    *)
    AddStatement (TokenToLocation (CurrentQuadToken),
@@ -1288,7 +1283,6 @@ VAR
 BEGIN
    IF CompilingMainModule OR WholeProgram
    THEN
-      (* SetFileNameAndLineNo (string (FileName), op1) ;  *)
       location := TokenToLocation (CurrentQuadToken) ;
       GetModuleCtors (moduleSym, ctor, init, fini, dep) ;
       BuildStartFunctionCode (location, Mod2Gcc (init),
@@ -1312,11 +1306,6 @@ VAR
 BEGIN
    IF CompilingMainModule OR WholeProgram
    THEN
-      (*
-         SetFileNameAndLineNo(string(FileName), op1) ;
-         EmitLineNote(string(FileName), op1) ;
-      *)
-
       location := TokenToLocation (GetDeclaredMod (moduleSym)) ;
       GetModuleCtors (moduleSym, ctor, init, fini, dep) ;
       finishFunctionDecl (location, Mod2Gcc (init)) ;
@@ -1340,7 +1329,6 @@ VAR
 BEGIN
    IF CompilingMainModule OR WholeProgram
    THEN
-      (* SetFileNameAndLineNo (string (FileName), op1) ;  *)
       location := TokenToLocation (CurrentQuadToken) ;
       GetModuleCtors (moduleSym, ctor, init, fini, dep) ;
       BuildStartFunctionCode (location, Mod2Gcc (fini),
@@ -1366,11 +1354,6 @@ VAR
 BEGIN
    IF CompilingMainModule OR WholeProgram
    THEN
-      (*
-         SetFileNameAndLineNo(string(FileName), op1) ;
-         EmitLineNote(string(FileName), op1) ;
-      *)
-
       tokenpos := GetDeclaredMod (moduleSym) ;
       location := TokenToLocation (tokenpos) ;
       GetModuleCtors (moduleSym, ctor, init, fini, dep) ;
@@ -1419,7 +1402,7 @@ BEGIN
    HighField := GetUnboundedHighOffset (UnboundedType, dim) ;
    IF HighField = NulSym
    THEN
-      (* it might be a dynamic array of static arrays,
+      (* It might be a dynamic array of static arrays,
          so lets see if there is an earlier dimension available.  *)
       accessibleDim := dim ;
       WHILE (HighField = NulSym) AND (accessibleDim > 1) DO
@@ -1476,7 +1459,7 @@ BEGIN
                               GetCardinalOne(location),
                               FALSE),
                      t, FALSE) ;
-      (* remember we must add one as HIGH(a) means we can legally reference a[HIGH(a)].  *)
+      (* Remember we must add one as a[HIGH(a)] is the last accessible element of the array.  *)
       INC(i)
    END ;
    RETURN( BuildConvert(location,
@@ -1574,7 +1557,7 @@ BEGIN
    NewArray := MaybeDebugBuiltinAlloca (location, tokenno, High) ;
    NewArray := MaybeDebugBuiltinMemcpy (location, NewArray, Addr, High) ;
 
-   (* now assign  param.Addr := ADR(NewArray) *)
+   (* Now assign  param.Addr := ADR(NewArray).  *)
 
    BuildAssignmentStatement (location,
                              BuildComponentRef (location,
@@ -1715,7 +1698,7 @@ VAR
 BEGIN
    location := TokenToLocation(tokenno) ;
    n := NoOfItemsInList(mustCheck) ;
-   (* want a sequence of if then elsif statements *)
+   (* We want a sequence of if then elsif statements.  *)
    IF n>0
    THEN
       INC(UnboundedLabelNo) ;
@@ -1813,8 +1796,8 @@ BEGIN
          paramTrashed := GetItemFromList(trashed, j) ;
          IF IsAssignmentCompatible(GetLowestType(param), GetLowestType(paramTrashed))
          THEN
-            (* we must check whether this unbounded parameter has the same
-               address as the trashed parameter *)
+            (* We must check whether this unbounded parameter has the same
+               address as the trashed parameter.  *)
             IF VerboseUnbounded
             THEN
                n1 := GetSymName(paramTrashed) ;
@@ -1832,7 +1815,7 @@ BEGIN
          END ;
          INC(j)
       END ;
-      (* now we build a sequence of if then { elsif then } end to check addresses *)
+      (* Now we build a sequence of if then { elsif then } end to check addresses.  *)
       BuildCascadedIfThenElsif (tokenno, mustCheck, proc, param) ;
       KillList(mustCheck)
    END
@@ -1851,7 +1834,7 @@ BEGIN
    END ;
    IF IsVar(sym)
    THEN
-      (* unbounded arrays will appear as vars *)
+      (* Unbounded arrays will appear as vars.  *)
       RETURN GetVarWritten(sym)
    END ;
    InternalError ('expecting IsVar to return TRUE')
@@ -1912,7 +1895,7 @@ BEGIN
       END ;
       INC(i)
    END ;
-   (* now see whether we need to copy any unbounded array parameters *)
+   (* Now see whether we need to copy any unbounded array parameters.  *)
    i := 1 ;
    p := NoOfParamAny (proc) ;
    WHILE i<=p DO
@@ -1939,7 +1922,7 @@ BEGIN
    THEN
       (* PrintSym (sym) ; *)
       type := SkipType (GetType (sym)) ;
-      (* the type SYSTEM.ADDRESS is a pointer type.  *)
+      (* The type SYSTEM.ADDRESS is a pointer type.  *)
       IF IsPointer (type)
       THEN
          BuildAssignmentStatement (location,
@@ -1968,7 +1951,7 @@ BEGIN
       i := 1 ;
       IF IsProcedure (scope)
       THEN
-         (* the parameters are stored as local variables.  *)
+         (* The parameters are stored as local variables.  *)
          INC (i, NoOfParamAny (scope))
       END ;
       WHILE i <= n DO
@@ -1988,7 +1971,7 @@ PROCEDURE CodeNewLocalVar (tokenno, CurrentProcedure: CARDINAL) ;
 VAR
    begin, end: CARDINAL ;
 BEGIN
-   (* callee saves non var unbounded parameter contents *)
+   (* Callee saves non var unbounded parameter contents.  *)
    SaveNonVarUnboundedParameters (tokenno, CurrentProcedure) ;
    BuildPushFunctionContext ;
    GetProcedureBeginEnd (CurrentProcedure, begin, end) ;
@@ -2032,7 +2015,7 @@ END CodeKillLocalVar ;
 
 
 (*
-   CodeProcedureScope -
+   CodeProcedureScope - start a procedure scope for CurrentProcedure.
 *)
 
 PROCEDURE CodeProcedureScope (CurrentProcedure: CARDINAL) ;
@@ -2072,7 +2055,7 @@ BEGIN
                 exprpos, nonepos, procpos) ;
    combinedpos := MakeVirtualTok (returnpos, returnpos, exprpos) ;
    location := TokenToLocation (combinedpos) ;
-   TryDeclareConstant (exprpos, expr) ;  (* checks to see whether it is a constant and declares it *)
+   TryDeclareConstant (exprpos, expr) ;  (* Checks to see whether it is a constant and declares it.  *)
    TryDeclareConstructor (exprpos, expr) ;
    IF IsConstString (expr) AND (SkipTypeAndSubrange (GetType (procedure)) # Char)
    THEN
@@ -2119,7 +2102,7 @@ BEGIN
       location := TokenToLocation (tokenno) ;
       AddStatement (location, callTree)
    ELSE
-      (* leave tree alone - as it will be picked up when processing FunctValue *)
+      (* Leave tree alone - as it will be picked up when processing FunctValue.  *)
    END
 END CodeCall ;
 
@@ -2199,7 +2182,7 @@ BEGIN
       ReturnType := tree(Mod2Gcc(GetType(proc)))
    END ;
 
-   (* now we dereference the lvalue if necessary *)
+   (* Now we dereference the lvalue if necessary.  *)
 
    IF GetMode(ProcVar)=LeftValue
    THEN
@@ -2239,7 +2222,7 @@ BEGIN
       THEN
          n := GetSymName(str) ;
          WriteFormat1("type incompatibility, attempting to use a string ('%a') when a CHAR is expected", n) ;
-         s := InitString('') ;  (* do something safe *)
+         s := InitString('') ;  (* Do something safe.  *)
          t := BuildCharConstant(location, s)
       END ;
       s := InitStringCharStar(KeyToCharStar(GetString(str))) ;
@@ -2322,54 +2305,54 @@ END IsConstant ;
 
 
 (*
-   CheckConvertCoerceParameter -
+   CheckConvertCoerceParameter - ensure that actual parameter is the same as the nth of callee.
 *)
 
-PROCEDURE CheckConvertCoerceParameter (tokenno: CARDINAL; op1, op2, op3: CARDINAL) : tree ;
+PROCEDURE CheckConvertCoerceParameter (tokenno: CARDINAL; nth, callee, actual: CARDINAL) : tree ;
 VAR
    OperandType,
    ParamType  : CARDINAL ;
    location   : location_t ;
 BEGIN
    location := TokenToLocation(tokenno) ;
-   IF GetNthParamAny (op2, op1)=NulSym
+   IF GetNthParamAny (callee, nth)=NulSym
    THEN
       (* We reach here if the argument is being passed to a C vararg function.  *)
-      RETURN( Mod2Gcc(op3) )
+      RETURN( Mod2Gcc(actual) )
    ELSE
-      OperandType := SkipType(GetType(op3)) ;
-      ParamType := SkipType(GetType(GetNthParamAny (op2, op1)))
+      OperandType := SkipType(GetType(actual)) ;
+      ParamType := SkipType(GetType(GetNthParamAny (callee, nth)))
    END ;
    IF IsProcType(ParamType)
    THEN
-      IF IsProcedure(op3) OR IsConstProcedure(op3) OR (OperandType = ParamType)
+      IF IsProcedure(actual) OR IsConstProcedure(actual) OR (OperandType = ParamType)
       THEN
-         RETURN( Mod2Gcc(op3) )
+         RETURN( Mod2Gcc(actual) )
       ELSE
-         RETURN( BuildConvert(location, Mod2Gcc(ParamType), Mod2Gcc(op3), FALSE) )
+         RETURN( BuildConvert(location, Mod2Gcc(ParamType), Mod2Gcc(actual), FALSE) )
       END
    ELSIF IsRealType(OperandType) AND IsRealType(ParamType) AND
       (ParamType#OperandType)
    THEN
-      (* SHORTREAL, LONGREAL and REAL conversion during parameter passing *)
+      (* SHORTREAL, LONGREAL and REAL conversion during parameter passing.  *)
       RETURN( BuildConvert(location, Mod2Gcc(ParamType),
-                           Mod2Gcc(op3), FALSE) )
-   ELSIF (OperandType#NulSym) AND IsSet(OperandType) AND IsConst(op3)
+                           Mod2Gcc(actual), FALSE) )
+   ELSIF (OperandType#NulSym) AND IsSet(OperandType) AND IsConst(actual)
    THEN
       RETURN( DeclareKnownConstant(location,
                                    Mod2Gcc(ParamType),
-                                   Mod2Gcc(op3)) )
-   ELSIF IsConst(op3) AND
+                                   Mod2Gcc(actual)) )
+   ELSIF IsConst(actual) AND
          (IsOrdinalType(ParamType) OR IsSystemType(ParamType))
    THEN
       RETURN( BuildConvert(location, Mod2Gcc(ParamType),
-                           StringToChar(Mod2Gcc(op3), ParamType, op3),
+                           StringToChar(Mod2Gcc(actual), ParamType, actual),
                            FALSE) )
-   ELSIF IsConstString(op3) OR ((OperandType#NulSym) AND IsCoerceableParameter(OperandType) AND (OperandType#ParamType))
+   ELSIF IsConstString(actual) OR ((OperandType#NulSym) AND IsCoerceableParameter(OperandType) AND (OperandType#ParamType))
    THEN
-      RETURN( BuildConvert(location, Mod2Gcc(ParamType), Mod2Gcc(op3), FALSE) )
+      RETURN( BuildConvert(location, Mod2Gcc(ParamType), Mod2Gcc(actual), FALSE) )
    ELSE
-      RETURN( Mod2Gcc(op3) )
+      RETURN( Mod2Gcc(actual) )
    END
 END CheckConvertCoerceParameter ;
 
@@ -2603,7 +2586,7 @@ BEGIN
       END ;
       IF (op=CallOp) AND (NOT IsProcedure(op3))
       THEN
-         (* cannot fold an indirect procedure function call *)
+         (* Cannot fold an indirect procedure function call.  *)
          resolved := FALSE
       END ;
       n := GetNextQuad(n) ;
@@ -2656,7 +2639,7 @@ PROCEDURE FoldBuiltinFunction (tokenno: CARDINAL; p: WalkAction;
 BEGIN
    IF op1=0
    THEN
-      (* must be a function as op1 is the return parameter *)
+      (* Must be a function as op1 is the return parameter.  *)
       IF op3=MakeAdr
       THEN
          FoldMakeAdr (tokenno, p, q, op1, op2, op3)
@@ -2881,7 +2864,7 @@ BEGIN
       END ;
       location := TokenToLocation (tokenno) ;
       type := SkipType (GetType (op3)) ;
-      DeclareConstant (tokenno, op3) ;  (* we might be asked to find the address of a constant string *)
+      DeclareConstant (tokenno, op3) ;  (* We might be asked to find the address of a constant string.  *)
       DeclareConstructor (tokenno, quad, op3) ;
       IF (IsConst (op3) AND (type=Char)) OR IsConstString (op3)
       THEN
@@ -3130,8 +3113,8 @@ END PerformFoldBecomes ;
 
 
 VAR
-   tryBlock: tree ;    (* this must be placed into gccgm2 and it must follow the
-                          current function scope - ie it needs work with nested procedures *)
+   tryBlock: tree ;    (* This must be placed into gccgm2 and it must follow the
+                          current function scope - ie it needs work with nested procedures.  *)
    handlerBlock: tree ;
 
 
@@ -3162,7 +3145,7 @@ BEGIN
    THEN
       AddStatement (location, BuildThrow (location, tree (NIL)))
    ELSE
-      DeclareConstant (CurrentQuadToken, value) ;  (* checks to see whether it is a constant and declares it *)
+      DeclareConstant (CurrentQuadToken, value) ;  (* Checks to see whether it is a constant and declares it.  *)
       AddStatement (location, BuildThrow (location, BuildConvert (location,
                                                                   GetIntegerType (),
                                                                   Mod2Gcc (value), FALSE)))
@@ -3245,19 +3228,11 @@ BEGIN
    IF IsConstSet(op3) OR ((SkipType(GetType(op3))#NulSym) AND
                           IsSet(SkipType(GetType(op3))))
    THEN
-      (* we have not checked set compatibility in
-         M2Quads.mod:BuildAssignmentTree so we do it here.
-      *)
-(*
-      IF (Iso AND (SkipType(GetType(op1))#SkipType(GetType(op3)))) OR
-         (Pim AND ((SkipType(GetType(op1))#SkipType(GetType(op3))) AND
-                   (SkipType(GetType(op1))#Bitset) AND
-                   (SkipType(GetType(op3))#Bitset)))
-*)
       IF SkipType(GetTypeMode(op1))#SkipType(GetTypeMode(op3))
       THEN
          DescribeTypeError (tokenno, op1, op3) ;
-         RETURN( Mod2Gcc (op1) ) (* we might crash if we execute the BuildAssignmentTree with op3 *)
+         (* Assigning an errant op3 might ICE, therefore it is safer to return op1.  *)         
+         RETURN( Mod2Gcc (op1) )
       END
    END ;
    location := TokenToLocation (tokenno) ;
@@ -3269,9 +3244,6 @@ BEGIN
       IF IsProcedure (op3)
       THEN
          RETURN t
-	 (*
-         t := BuildConvert(location, Mod2Gcc(GetType(op1)), BuildAddr(location, Mod2Gcc(op3), FALSE), TRUE)
-         *)
       ELSIF (NOT IsConstString (op3)) AND (NOT IsConstSet (op3)) AND
          (SkipType (GetType (op3)) # SkipType (GetType (op1)))
       THEN
diff --git a/gcc/m2/gm2-compiler/M2MetaError.mod b/gcc/m2/gm2-compiler/M2MetaError.mod
index 11874861e66dcdcaa6842717a3d85baaf3752fcd..22bc77f6ad00c416181b460145282653430d0af3 100644
--- a/gcc/m2/gm2-compiler/M2MetaError.mod
+++ b/gcc/m2/gm2-compiler/M2MetaError.mod
@@ -1611,7 +1611,12 @@ BEGIN
       END
    ELSIF IsType(sym)
    THEN
-      RETURN InitString('type')
+      IF IsHiddenType (sym)
+      THEN
+         RETURN InitString('opaque type')
+      ELSE
+         RETURN InitString('type')
+      END
    ELSIF IsRecord(sym)
    THEN
       RETURN InitString('record')
diff --git a/gcc/m2/gm2-compiler/M2Options.mod b/gcc/m2/gm2-compiler/M2Options.mod
index 4c03dfeddfba49b9252f5a8eb9eb7a6d788b64ec..39f0b2a73fb2ef3c74e4ad6fd103141c27fb2ee7 100644
--- a/gcc/m2/gm2-compiler/M2Options.mod
+++ b/gcc/m2/gm2-compiler/M2Options.mod
@@ -2147,5 +2147,5 @@ BEGIN
    M2Dump                            := NIL ;
    M2DumpFilter                      := NIL ;
    EnableForward                     := TRUE ;
-   OffTBits                          := 64 ;  (* Default to 64bit OFF_T.  *)
+   OffTBits                          := 0 ;  (* Default to CSSIZE_T.  *)
 END M2Options.
diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod
index fd3482b1f2d2e7277451a381668e0473dd72a2d6..46db4a6556dae7cd9baafd6a5db82807e8cf6cd7 100644
--- a/gcc/m2/gm2-compiler/M2Quads.mod
+++ b/gcc/m2/gm2-compiler/M2Quads.mod
@@ -63,6 +63,7 @@ FROM SymbolTable IMPORT ModeOfAddr, GetMode, PutMode, GetSymName, IsUnknown,
                         GetScope, GetCurrentScope,
                         GetSubrange, SkipTypeAndSubrange,
                         GetModule, GetMainModule,
+                        GetModuleScope, GetCurrentModuleScope,
                         GetCurrentModule, GetFileModule, GetLocalSym,
                         GetStringLength, GetString,
                         GetArraySubscript, GetDimension,
@@ -115,7 +116,7 @@ FROM SymbolTable IMPORT ModeOfAddr, GetMode, PutMode, GetSymName, IsUnknown,
                         PutDeclared,
                         MakeComponentRecord, MakeComponentRef,
                         IsSubscript, IsComponent, IsConstStringKnown,
-                        IsTemporary,
+                        IsTemporary, IsHiddenType,
                         IsAModula2Type,
                         PutLeftValueFrontBackType,
                         PushSize, PushValue, PopValue,
@@ -7020,19 +7021,19 @@ BEGIN
       BuildDisposeProcedure (tokno)
    ELSIF ProcSym = Inc
    THEN
-      BuildIncProcedure
+      BuildIncProcedure (tokno)
    ELSIF ProcSym = Dec
    THEN
-      BuildDecProcedure
+      BuildDecProcedure (tokno)
    ELSIF ProcSym = Incl
    THEN
-      BuildInclProcedure
+      BuildInclProcedure (tokno)
    ELSIF ProcSym = Excl
    THEN
-      BuildExclProcedure
+      BuildExclProcedure (tokno)
    ELSIF ProcSym = Throw
    THEN
-      BuildThrowProcedure
+      BuildThrowProcedure (tokno)
    ELSE
       InternalError  ('pseudo procedure not implemented yet')
    END
@@ -7083,14 +7084,12 @@ END GetItemPointedTo ;
                          |----------------|
 *)
 
-PROCEDURE BuildThrowProcedure ;
+PROCEDURE BuildThrowProcedure (functok: CARDINAL) ;
 VAR
-   functok  : CARDINAL ;
    op       : CARDINAL ;
    NoOfParam: CARDINAL ;
 BEGIN
    PopT (NoOfParam) ;
-   functok  := OperandTtok (NoOfParam + 1) ;
    IF NoOfParam = 1
    THEN
       op := OperandT (NoOfParam) ;
@@ -7327,19 +7326,19 @@ BEGIN
    IF IsExpressionCompatible (dtype, etype)
    THEN
       (* the easy case simulate a straightforward macro *)
-      PushTF (des, dtype) ;
+      PushTFtok (des, dtype, tokenpos) ;
       PushT (tok) ;
-      PushTF (expr, etype) ;
+      PushTFtok (expr, etype, tokenpos) ;
       doBuildBinaryOp (FALSE, TRUE)
    ELSE
       IF (IsOrdinalType (dtype) OR (dtype = Address) OR IsPointer (dtype)) AND
          (IsOrdinalType (etype) OR (etype = Address) OR IsPointer (etype))
       THEN
-         PushTF (des, dtype) ;
+         PushTFtok (des, dtype, tokenpos) ;
          PushT (tok) ;
-         PushTF (Convert, NulSym) ;
-         PushT (dtype) ;
-         PushT (expr) ;
+         PushTFtok (Convert, NulSym, tokenpos) ;
+         PushTtok (dtype, tokenpos) ;
+         PushTtok (expr, tokenpos) ;
          PushT (2) ;          (* Two parameters *)
          BuildConvertFunction (Convert, FALSE) ;
          doBuildBinaryOp (FALSE, TRUE)
@@ -7386,9 +7385,8 @@ END CheckRangeIncDec ;
                        |----------------|
 *)
 
-PROCEDURE BuildIncProcedure ;
+PROCEDURE BuildIncProcedure (proctok: CARDINAL) ;
 VAR
-   proctok   : CARDINAL ;
    NoOfParam,
    dtype,
    OperandSym,
@@ -7396,26 +7394,25 @@ VAR
    TempSym   : CARDINAL ;
 BEGIN
    PopT (NoOfParam) ;
-   proctok := OperandTtok (NoOfParam + 1) ;
    IF (NoOfParam = 1) OR (NoOfParam = 2)
    THEN
-      VarSym := OperandT (NoOfParam) ;  (* bottom/first parameter *)
+      VarSym := OperandT (NoOfParam) ;  (* Bottom/first parameter.  *)
       IF IsVar (VarSym)
       THEN
          dtype := GetDType (VarSym) ;
          IF NoOfParam = 2
          THEN
-            OperandSym := DereferenceLValue (OperandTok (1), OperandT (1))
+            OperandSym := DereferenceLValue (proctok, OperandT (1))
          ELSE
             PushOne (proctok, dtype,
                      'the {%EkINC} will cause an overflow {%1ad}') ;
 	    PopT (OperandSym)
          END ;
 
-         PushT (VarSym) ;
-         TempSym := DereferenceLValue (OperandTok (NoOfParam), VarSym) ;
-         CheckRangeIncDec (proctok, TempSym, OperandSym, PlusTok) ;  (* TempSym + OperandSym *)
-         BuildAssignmentWithoutBounds (proctok, FALSE, TRUE)   (* VarSym := TempSym + OperandSym *)
+         PushTtok (VarSym, proctok) ;
+         TempSym := DereferenceLValue (proctok, VarSym) ;
+         CheckRangeIncDec (proctok, TempSym, OperandSym, PlusTok) ;  (* TempSym + OperandSym.  *)
+         BuildAssignmentWithoutBounds (proctok, FALSE, TRUE)   (* VarSym := TempSym + OperandSym.  *)
       ELSE
          MetaErrorT1 (proctok,
                       'base procedure {%EkINC} expects a variable as a parameter but was given {%1Ed}',
@@ -7459,9 +7456,8 @@ END BuildIncProcedure ;
                        |----------------|
 *)
 
-PROCEDURE BuildDecProcedure ;
+PROCEDURE BuildDecProcedure (proctok: CARDINAL) ;
 VAR
-   proctok,
    NoOfParam,
    dtype,
    OperandSym,
@@ -7469,26 +7465,25 @@ VAR
    TempSym   : CARDINAL ;
 BEGIN
    PopT (NoOfParam) ;
-   proctok := OperandTtok (NoOfParam + 1) ;
    IF (NoOfParam = 1) OR (NoOfParam = 2)
    THEN
-      VarSym := OperandT (NoOfParam) ;  (* bottom/first parameter *)
+      VarSym := OperandT (NoOfParam) ;  (* Bottom/first parameter.  *)
       IF IsVar (VarSym)
       THEN
          dtype := GetDType (VarSym) ;
          IF NoOfParam = 2
          THEN
-            OperandSym := DereferenceLValue (OperandTok (1), OperandT (1))
+            OperandSym := DereferenceLValue (proctok, OperandT (1))
          ELSE
             PushOne (proctok, dtype,
                      'the {%EkDEC} will cause an overflow {%1ad}') ;
 	    PopT (OperandSym)
          END ;
 
-         PushT (VarSym) ;
+         PushTtok (VarSym, proctok) ;
          TempSym := DereferenceLValue (OperandTok (NoOfParam), VarSym) ;
-         CheckRangeIncDec (proctok, TempSym, OperandSym, MinusTok) ;  (* TempSym - OperandSym *)
-         BuildAssignmentWithoutBounds (proctok, FALSE, TRUE)   (* VarSym := TempSym - OperandSym *)
+         CheckRangeIncDec (proctok, TempSym, OperandSym, MinusTok) ;  (* TempSym - OperandSym.  *)
+         BuildAssignmentWithoutBounds (proctok, FALSE, TRUE)   (* VarSym := TempSym - OperandSym.  *)
       ELSE
          MetaErrorT1 (proctok,
                       'base procedure {%EkDEC} expects a variable as a parameter but was given {%1Ed}',
@@ -7552,9 +7547,8 @@ END DereferenceLValue ;
                         |----------------|
 *)
 
-PROCEDURE BuildInclProcedure ;
+PROCEDURE BuildInclProcedure (proctok: CARDINAL) ;
 VAR
-   proctok,
    optok     : CARDINAL ;
    NoOfParam,
    DerefSym,
@@ -7562,7 +7556,6 @@ VAR
    VarSym    : CARDINAL ;
 BEGIN
    PopT (NoOfParam) ;
-   proctok := OperandTtok (NoOfParam + 1) ;
    IF NoOfParam = 2
    THEN
       VarSym := OperandT (2) ;
@@ -7618,9 +7611,8 @@ END BuildInclProcedure ;
                         |----------------|
 *)
 
-PROCEDURE BuildExclProcedure ;
+PROCEDURE BuildExclProcedure (proctok: CARDINAL) ;
 VAR
-   proctok,
    optok     : CARDINAL ;
    NoOfParam,
    DerefSym,
@@ -7628,7 +7620,6 @@ VAR
    VarSym    : CARDINAL ;
 BEGIN
    PopT (NoOfParam) ;
-   proctok := OperandTtok (NoOfParam + 1) ;
    IF NoOfParam=2
    THEN
       VarSym := OperandT (2) ;
@@ -11427,6 +11418,24 @@ BEGIN
 END BuildDesignatorError ;
 
 
+(*
+   BuildDesignatorPointerError - removes the designator from the stack and replaces
+                                 it with an error symbol.
+*)
+
+PROCEDURE BuildDesignatorPointerError (type, rw: CARDINAL; tokpos: CARDINAL;
+                                       message: ARRAY OF CHAR) ;
+VAR
+   error: CARDINAL ;
+BEGIN
+   error := MakeError (tokpos, MakeKey (message)) ;
+   IF GetSType (type) # NulSym
+   THEN
+      type := GetSType (type)
+   END ;
+   PushTFrwtok (error, type, rw, tokpos)
+END BuildDesignatorPointerError ;
+
 
 (*
    BuildDesignatorArray - Builds the array referencing.
@@ -11819,13 +11828,13 @@ END DebugLocation ;
 PROCEDURE BuildDesignatorPointer (ptrtok: CARDINAL) ;
 VAR
    combinedtok,
-   exprtok    : CARDINAL ;
+   destok    : CARDINAL ;
    rw,
    Sym1, Type1,
    Sym2, Type2: CARDINAL ;
 BEGIN
-   PopTFrwtok (Sym1, Type1, rw, exprtok) ;
-   DebugLocation (exprtok, "expression") ;
+   PopTFrwtok (Sym1, Type1, rw, destok) ;
+   DebugLocation (destok, "des ptr expression") ;
 
    Type1 := SkipType (Type1) ;
    IF Type1 = NulSym
@@ -11834,33 +11843,44 @@ BEGIN
    ELSIF IsUnknown (Sym1)
    THEN
       MetaError1 ('{%1EMad} is undefined and therefore {%1ad}^ cannot be resolved', Sym1)
-   ELSIF IsPointer (Type1)
-   THEN
-      Type2 := GetSType (Type1) ;
-      Sym2 := MakeTemporary (ptrtok, LeftValue) ;
-      (*
-         Ok must reference by address
-         - but we contain the type of the referenced entity
-      *)
-      MarkAsRead (rw) ;
-      PutVarPointerCheck (Sym1, TRUE) ;
-      CheckPointerThroughNil (ptrtok, Sym1) ;
-      IF GetMode (Sym1) = LeftValue
-      THEN
-         rw := NulSym ;
-         PutLeftValueFrontBackType (Sym2, Type2, Type1) ;
-         GenQuadO (ptrtok, IndrXOp, Sym2, Type1, Sym1, FALSE)    (* Sym2 := *Sym1 *)
-      ELSE
-         PutLeftValueFrontBackType (Sym2, Type2, NulSym) ;
-         GenQuadO (ptrtok, BecomesOp, Sym2, NulSym, Sym1, FALSE) (* Sym2 :=  Sym1 *)
-      END ;
-      PutVarPointerCheck (Sym2, TRUE) ;       (* we should check this for *)
-                                     (* Sym2 later on (pointer via NIL)   *)
-      combinedtok := MakeVirtualTok (exprtok, exprtok, ptrtok) ;
-      PushTFrwtok (Sym2, Type2, rw, combinedtok) ;
-      DebugLocation (combinedtok, "pointer expression")
    ELSE
-      MetaError2 ('{%1ad} is not a pointer type but a {%2d}', Sym1, Type1)
+      combinedtok := MakeVirtual2Tok (destok, ptrtok) ;
+      IF IsPointer (Type1)
+      THEN
+         Type2 := GetSType (Type1) ;
+         Sym2 := MakeTemporary (ptrtok, LeftValue) ;
+         (*
+          Ok must reference by address
+          - but we contain the type of the referenced entity
+         *)
+         MarkAsRead (rw) ;
+         PutVarPointerCheck (Sym1, TRUE) ;
+         CheckPointerThroughNil (ptrtok, Sym1) ;
+         IF GetMode (Sym1) = LeftValue
+         THEN
+            rw := NulSym ;
+            PutLeftValueFrontBackType (Sym2, Type2, Type1) ;
+            GenQuadO (ptrtok, IndrXOp, Sym2, Type1, Sym1, FALSE)    (* Sym2 := *Sym1.  *)
+         ELSE
+            PutLeftValueFrontBackType (Sym2, Type2, NulSym) ;
+            GenQuadO (ptrtok, BecomesOp, Sym2, NulSym, Sym1, FALSE) (* Sym2 :=  Sym1.  *)
+         END ;
+         (* We should check this for Sym2 later on (pointer via NIL).   *)
+         PutVarPointerCheck (Sym2, TRUE) ;
+         PushTFrwtok (Sym2, Type2, rw, combinedtok) ;
+         DebugLocation (combinedtok, "pointer expression")
+      ELSIF IsHiddenType (Type1) AND (GetModuleScope (Type1) # GetCurrentModuleScope ())
+      THEN
+         MetaErrorT1 (ptrtok,
+                      '{%1Ead} is declared with an opaque type from a different module and cannot be dereferenced',
+                      Sym1) ;
+         MarkAsRead (rw) ;
+         BuildDesignatorPointerError (Type1, rw, combinedtok, 'bad opaque pointer dereference')
+      ELSE
+         MetaError2 ('{%1Ead} is not a pointer type but a {%2d}', Sym1, Type1) ;
+         MarkAsRead (rw) ;
+         BuildDesignatorPointerError (Type1, rw, combinedtok, 'bad pointer dereference')
+      END
    END
 END BuildDesignatorPointer ;
 
diff --git a/gcc/m2/gm2-compiler/P2SymBuild.mod b/gcc/m2/gm2-compiler/P2SymBuild.mod
index 1b59f3d631b6fae109e4ecc39e306899ce50febb..8f3b4995ac88a1ad5ad50e3861216621d08bfb1b 100644
--- a/gcc/m2/gm2-compiler/P2SymBuild.mod
+++ b/gcc/m2/gm2-compiler/P2SymBuild.mod
@@ -182,6 +182,7 @@ PROCEDURE stop ; BEGIN END stop ;
    Debug - call stop if symbol name is name.
 *)
 
+(*
 PROCEDURE Debug (tok: CARDINAL; sym: CARDINAL; name: ARRAY OF CHAR) ;
 BEGIN
    IF MakeKey (name) = GetSymName (sym)
@@ -190,6 +191,7 @@ BEGIN
    END ;
    MetaErrorT1 (tok, 'procedure {%1Wa}', sym)
 END Debug ;
+*)
 
 
 (*
diff --git a/gcc/m2/gm2-compiler/P3Build.bnf b/gcc/m2/gm2-compiler/P3Build.bnf
index b68f3e1192c6403f67791097de0b4ec1545fb6a7..d181f2381dfb5ca82052beb8b3e128acb68fc47b 100644
--- a/gcc/m2/gm2-compiler/P3Build.bnf
+++ b/gcc/m2/gm2-compiler/P3Build.bnf
@@ -54,7 +54,7 @@ FROM DynamicStrings IMPORT String, InitString, KillString, Mark, ConCat, ConCatC
 FROM M2Printf IMPORT printf0, printf1 ;
 FROM M2Debug IMPORT Assert ;
 FROM P2SymBuild IMPORT BuildString, BuildNumber ;
-FROM M2MetaError IMPORT MetaErrorT0 ;
+FROM M2MetaError IMPORT MetaErrorT0, MetaErrorT2 ;
 FROM M2CaseList IMPORT ElseCase ;
 
 FROM M2Reserved IMPORT tokToTok, toktype,
@@ -1085,15 +1085,14 @@ SubDesignator := "."                                                       % VAR
                                                                                 n1 := GetSymName(Sym) ;
                                                                                 IF IsModuleKnown(GetSymName(Sym))
                                                                                 THEN
-                                                                                   WriteFormat2('%a looks like a module which has not been globally imported (eg. suggest that you IMPORT %a ;)',
+                                                                                   WriteFormat2('%a looks like a module which has not been globally imported (eg. suggest that you IMPORT %a)',
                                                                                    n1, n1)
                                                                                 ELSE
                                                                                    WriteFormat1('%a is not a record variable', n1)
                                                                                 END
                                                                              ELSIF NOT IsRecord(Type)
                                                                              THEN
-                                                                                n1 := GetSymName(Type) ;
-                                                                                WriteFormat1('%a is not a record type', n1)
+                                                                                MetaErrorT2 (tok, "the type of {%1ad} is not a record (but {%2ad}) and therefore it has no field", Sym, Type) ;
                                                                              END ;
                                                                              StartScope(Type) %
                  Ident
diff --git a/gcc/m2/gm2-gcc/m2builtins.cc b/gcc/m2/gm2-gcc/m2builtins.cc
index 2c02d9781a79f95c2374165ffc9cbf7457b44d57..175c62a102a53c480782506ff0cd003cf289963f 100644
--- a/gcc/m2/gm2-gcc/m2builtins.cc
+++ b/gcc/m2/gm2-gcc/m2builtins.cc
@@ -375,6 +375,7 @@ static struct GTY(()) builtin_function_entry list_of_builtins[] = {
     BUILT_IN_NORMAL, "strchr", NULL, NULL, bf_default_lib },
   { "__builtin_strrchr", BT_FN_STRING_CONST_STRING_INT, BUILT_IN_STRCHR,
     BUILT_IN_NORMAL, "strrchr", NULL, NULL, bf_default_lib },
+
   { "__builtin_frame_address", BT_FN_PTR_UNSIGNED, BUILT_IN_FRAME_ADDRESS,
     BUILT_IN_NORMAL, "frame_address", NULL, NULL, bf_gcc },
   { "__builtin_return_address", BT_FN_PTR_UNSIGNED, BUILT_IN_RETURN_ADDRESS,
@@ -426,6 +427,9 @@ static GTY (()) tree long_doubleptr_type_node;
 static GTY (()) tree doubleptr_type_node;
 static GTY (()) tree floatptr_type_node;
 static GTY (()) tree builtin_ftype_int_var;
+static GTY (()) tree builtin_ftype_int_uint;
+static GTY (()) tree builtin_ftype_int_ulong;
+static GTY (()) tree builtin_ftype_int_ulonglong;
 static GTY (()) vec<builtin_macro_definition, va_gc> *builtin_macros;
 
 /* Prototypes for locally defined functions.  */
@@ -1480,6 +1484,27 @@ define_builtin_math (enum built_in_function val, const char *name, tree type,
      versions as well?  */
 }
 
+/* Define gcc specific builtins.  */
+
+static
+void
+define_builtin_gcc (void)
+{
+  /* Bit count functions.  */
+  define_builtin (BUILT_IN_CLZ, "clz", builtin_ftype_int_uint,
+		  "__builtin_clz", ECF_CONST | ECF_NOTHROW | ECF_LEAF);
+  define_builtin (BUILT_IN_CLZL, "clzl", builtin_ftype_int_ulong,
+		  "__builtin_clzl", ECF_CONST | ECF_NOTHROW | ECF_LEAF);
+  define_builtin (BUILT_IN_CLZLL, "clzll", builtin_ftype_int_ulonglong,
+		  "__builtin_clzll", ECF_CONST | ECF_NOTHROW | ECF_LEAF);
+  define_builtin (BUILT_IN_CTZ, "ctz", builtin_ftype_int_uint,
+		  "__builtin_ctz", ECF_CONST | ECF_NOTHROW | ECF_LEAF);
+  define_builtin (BUILT_IN_CTZL, "ctzl", builtin_ftype_int_ulong,
+		  "__builtin_ctzl", ECF_CONST | ECF_NOTHROW | ECF_LEAF);
+  define_builtin (BUILT_IN_CTZLL, "ctzll", builtin_ftype_int_ulonglong,
+		  "__builtin_ctzll", ECF_CONST | ECF_NOTHROW | ECF_LEAF);
+}
+
 void
 m2builtins_init (location_t location)
 {
@@ -1516,6 +1541,15 @@ m2builtins_init (location_t location)
   builtin_ftype_int_var = build_function_type (
       integer_type_node, tree_cons (NULL_TREE, double_type_node, endlink));
 
+  builtin_ftype_int_uint = build_function_type (
+      integer_type_node, tree_cons (NULL_TREE, unsigned_type_node, endlink));
+
+  builtin_ftype_int_ulong = build_function_type (
+      integer_type_node, tree_cons (NULL_TREE, long_unsigned_type_node, endlink));
+
+  builtin_ftype_int_ulonglong = build_function_type (
+      integer_type_node, tree_cons (NULL_TREE, long_long_unsigned_type_node, endlink));
+
   for (i = 0; list_of_builtins[i].name != NULL; i++)
     create_function_prototype (location, &list_of_builtins[i]);
 
@@ -1541,6 +1575,8 @@ m2builtins_init (location_t location)
   define_builtin_math (BUILT_IN_ISINF_SIGN, "isinf_sign", builtin_ftype_int_var,
 		       "__builtin_isinf_sign", ECF_CONST | ECF_NOTHROW | ECF_LEAF);
 
+  define_builtin_gcc ();
+
   gm2_alloca_node = find_builtin_tree ("__builtin_alloca");
   gm2_memcpy_node = find_builtin_tree ("__builtin_memcpy");
   gm2_memset_node = find_builtin_tree ("__builtin_memset");
diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
index 9f7a433e98061d844fc7ba0bf744215c1a3fcd66..a946509d1c25904c0f4d1cdc9ee6a75f9e6edbdb 100644
--- a/gcc/m2/gm2-gcc/m2type.cc
+++ b/gcc/m2/gm2-gcc/m2type.cc
@@ -1077,7 +1077,6 @@ build_m2_specific_size_type (location_t location, enum tree_code base,
     {
       if (!float_mode_for_size (TYPE_PRECISION (c)).exists ())
         return NULL;
-      layout_type (c);
     }
   else if (base == SET_TYPE)
     return build_m2_size_set_type (location, precision);
@@ -1096,6 +1095,7 @@ build_m2_specific_size_type (location_t location, enum tree_code base,
           TYPE_UNSIGNED (c) = true;
         }
     }
+  layout_type (c);
   return c;
 }
 
@@ -1385,8 +1385,12 @@ static tree
 build_m2_offt_type_node (location_t location)
 {
   m2assert_AssertLocation (location);
+  int offt_size = M2Options_GetFileOffsetBits ();
+
+  if (offt_size == 0)
+    offt_size = TREE_INT_CST_LOW (TYPE_SIZE (ssizetype));
   return build_m2_specific_size_type (location, INTEGER_TYPE,
-				      M2Options_GetFileOffsetBits (), true);
+				      offt_size, true);
 }
 
 /* m2type_InitSystemTypes initialise loc and word derivatives.  */
diff --git a/gcc/m2/gm2-libs-log/FileSystem.mod b/gcc/m2/gm2-libs-log/FileSystem.mod
index b1e9c59a895837de30a780555b364eb458a8f0a2..fbbc42229adbb0b31e431d6c408467e09ef62a6c 100644
--- a/gcc/m2/gm2-libs-log/FileSystem.mod
+++ b/gcc/m2/gm2-libs-log/FileSystem.mod
@@ -28,7 +28,7 @@ IMPLEMENTATION MODULE FileSystem ;
 
 FROM M2RTS IMPORT InstallTerminationProcedure ;
 FROM Storage IMPORT ALLOCATE ;
-FROM SYSTEM IMPORT ADR ;
+FROM SYSTEM IMPORT ADR, COFF_T ;
 IMPORT SFIO, libc, wrapc ;
 FROM DynamicStrings IMPORT InitString, ConCat, ConCatChar, KillString, string ;
 FROM FormatStrings IMPORT Sprintf2 ;
@@ -415,7 +415,7 @@ END Again ;
 
 PROCEDURE doModeChange (VAR f: File; mode: Flag) ;
 VAR
-   r: INTEGER ;
+   r: COFF_T ;
 BEGIN
    WITH f DO
       IF NOT (mode IN flags)
@@ -441,7 +441,7 @@ BEGIN
          END ;
          INCL (flags, opened) ;
          r := libc.lseek (fio,
-                          VAL (LONGINT, lowpos) + VAL (LONGINT, highpos) * VAL (LONGINT, MAX (CARDINAL)),
+                          VAL (COFF_T, lowpos) + VAL (COFF_T, highpos) * VAL (COFF_T, MAX (CARDINAL)),
                           SEEK_SET)
       END
    END
@@ -514,11 +514,11 @@ END Reset ;
 
 PROCEDURE SetPos (VAR f: File; high, low: CARDINAL) ;
 VAR
-   r: INTEGER ;
+   r: COFF_T ;
 BEGIN
    WITH f DO
-      r := libc.lseek(fio, VAL(LONGCARD, low) +
-                      (VAL(LONGCARD, MAX(CARDINAL)) * VAL(LONGCARD, high)),
+      r := libc.lseek(fio, VAL(COFF_T, low) +
+                      (VAL(COFF_T, MAX(CARDINAL)) * VAL(COFF_T, high)),
                       SEEK_SET) ;
       highpos := high ;
       lowpos := low ;
diff --git a/gcc/m2/gm2-libs/Builtins.def b/gcc/m2/gm2-libs/Builtins.def
index 0dc6deeb34f1b6cd90b2e055d3f9b4c89c02e5c2..954550e549acc7aee4c01f4d8f2f0829d34eae7c 100644
--- a/gcc/m2/gm2-libs/Builtins.def
+++ b/gcc/m2/gm2-libs/Builtins.def
@@ -229,6 +229,11 @@ PROCEDURE __BUILTIN__ strcspn (s, accept: ADDRESS) : CARDINAL ;
 PROCEDURE __BUILTIN__ strchr (s: ADDRESS; c: INTEGER) : ADDRESS ;
 PROCEDURE __BUILTIN__ strrchr (s: ADDRESS; c: INTEGER) : ADDRESS ;
 
+PROCEDURE __BUILTIN__ clz (value: CARDINAL) : INTEGER ;
+PROCEDURE __BUILTIN__ clzll (value: LONGCARD) : INTEGER ;
+PROCEDURE __BUILTIN__ ctz (value: CARDINAL) : INTEGER ;
+PROCEDURE __BUILTIN__ ctzll (value: LONGCARD) : INTEGER ;
+
 (*
    longjmp - this GCC builtin restricts the val to always 1.
 *)
diff --git a/gcc/m2/gm2-libs/Builtins.mod b/gcc/m2/gm2-libs/Builtins.mod
index 49942f443ad6f387defe231609dc4621fcfc7efb..922cda323934de0657ab38ea5ae2252292dfddb8 100644
--- a/gcc/m2/gm2-libs/Builtins.mod
+++ b/gcc/m2/gm2-libs/Builtins.mod
@@ -765,6 +765,26 @@ BEGIN
    RETURN 1
 END isinf_signl ;
 
+PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_clz)) clz (value: CARDINAL) : INTEGER ;
+BEGIN
+   RETURN 1
+END clz ;
+
+PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_clzll)) clzll (value: LONGCARD) : INTEGER ;
+BEGIN
+   RETURN 1
+END clzll ;
+
+PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_ctz)) ctz (value: CARDINAL) : INTEGER ;
+BEGIN
+   RETURN 1
+END ctz ;
+
+PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_ctzll)) ctzll (value: LONGCARD) : INTEGER ;
+BEGIN
+   RETURN 1
+END ctzll ;
+
 PROCEDURE __ATTRIBUTE__  __BUILTIN__ ((__builtin_longjmp)) longjmp (env: ADDRESS; val: INTEGER) ;
 BEGIN
    (* Empty, replaced internally by gcc.  *)
diff --git a/gcc/m2/gm2-libs/FIO.mod b/gcc/m2/gm2-libs/FIO.mod
index 55be703c5372fd7678e3fb02c57730ac84e3829d..8fa43e4b1c6f192e1869506eca377725ff32494b 100644
--- a/gcc/m2/gm2-libs/FIO.mod
+++ b/gcc/m2/gm2-libs/FIO.mod
@@ -36,7 +36,7 @@ IMPLEMENTATION MODULE FIO ;
                  provides a simple buffered file input/output library.
 *)
 
-FROM SYSTEM IMPORT ADR, TSIZE, WORD, CSSIZE_T ;
+FROM SYSTEM IMPORT ADR, TSIZE, WORD, COFF_T ;
 FROM ASCII IMPORT nl, nul, tab ;
 FROM StrLib IMPORT StrLen, StrConCat, StrCopy ;
 FROM Storage IMPORT ALLOCATE, DEALLOCATE ;
@@ -1446,7 +1446,7 @@ BEGIN
                      filled   := 0
                   END
                END ;
-               offset := lseek (unixfd, VAL (CSSIZE_T, pos), SeekSet ()) ;
+               offset := lseek (unixfd, VAL (COFF_T, pos), SeekSet ()) ;
                IF (offset>=0) AND (pos=offset)
                THEN
                   abspos := pos
@@ -1495,7 +1495,7 @@ BEGIN
                   filled   := 0
                END
             END ;
-            offset := lseek (unixfd, VAL (CSSIZE_T, pos), SeekEnd ()) ;
+            offset := lseek (unixfd, VAL (COFF_T, pos), SeekEnd ()) ;
             IF offset>=0
             THEN
                abspos := offset ;
diff --git a/gcc/m2/gm2-libs/cbuiltin.def b/gcc/m2/gm2-libs/cbuiltin.def
index 6cb028c4c526ce29e2375c9d1a2070119867eb6a..eee2499651ed8ba625c3f0dd7ca3541f1ab337a3 100644
--- a/gcc/m2/gm2-libs/cbuiltin.def
+++ b/gcc/m2/gm2-libs/cbuiltin.def
@@ -65,7 +65,10 @@ EXPORT UNQUALIFIED alloca, memcpy,
                    index, rindex,
                    memcmp, memset, memmove,
                    strcat, strncat, strcpy, strncpy, strcmp, strncmp,
-                   strlen, strstr, strpbrk, strspn, strcspn, strchr, strrchr ;
+                   strlen, strstr, strpbrk, strspn, strcspn, strchr, strrchr,
+
+                   clz, clzll,
+                   ctz, ctzll ;
 
 PROCEDURE alloca (i: CARDINAL) : ADDRESS ;
 PROCEDURE memcpy (dest, src: ADDRESS; n: CARDINAL) : ADDRESS ;
@@ -205,4 +208,10 @@ PROCEDURE strcspn (s, accept: ADDRESS) : CARDINAL ;
 PROCEDURE strchr (s: ADDRESS; c: INTEGER) : ADDRESS ;
 PROCEDURE strrchr (s: ADDRESS; c: INTEGER) : ADDRESS ;
 
+PROCEDURE clz (value: CARDINAL) : INTEGER ;
+PROCEDURE clzll (value: CARDINAL) : INTEGER ;
+PROCEDURE ctz (value: CARDINAL) : INTEGER ;
+PROCEDURE ctzll (value: CARDINAL) : INTEGER ;
+
+
 END cbuiltin.
diff --git a/gcc/m2/gm2-libs/libc.def b/gcc/m2/gm2-libs/libc.def
index f1f13ddd9aebb6ace9f9f02d409b502788dd57c7..525d016459001af64319b104f134384206f904f8 100644
--- a/gcc/m2/gm2-libs/libc.def
+++ b/gcc/m2/gm2-libs/libc.def
@@ -311,7 +311,7 @@ PROCEDURE creat (filename: ADDRESS; mode: CARDINAL) : INTEGER;
            off_t lseek(int fildes, off_t offset, int whence);
 *)
 
-PROCEDURE lseek (fd: INTEGER; offset: CSSIZE_T; whence: INTEGER) : [ COFF_T ] ;
+PROCEDURE lseek (fd: INTEGER; offset: COFF_T; whence: INTEGER) : [ COFF_T ] ;
 
 
 (*
diff --git a/gcc/m2/mc-boot/GASCII.cc b/gcc/m2/mc-boot/GASCII.cc
index 72cc6b251330454430898935fe1ceeec97c9f88a..35e77522b701580b8af480ec1b2f1d961bd9f94f 100644
--- a/gcc/m2/mc-boot/GASCII.cc
+++ b/gcc/m2/mc-boot/GASCII.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GASCII.h b/gcc/m2/mc-boot/GASCII.h
index c5a38b227c99262329e4897111047cb115b75256..18c2725057842062c139f68af4b48b19f4dc28ce 100644
--- a/gcc/m2/mc-boot/GASCII.h
+++ b/gcc/m2/mc-boot/GASCII.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_ASCII_H)
 #   define _ASCII_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GArgs.cc b/gcc/m2/mc-boot/GArgs.cc
index 2aafca77a3b6d64a142c5f2fc8c71ea6240d1f15..c87c35e73b6901985728df9933521e3e21361a2c 100644
--- a/gcc/m2/mc-boot/GArgs.cc
+++ b/gcc/m2/mc-boot/GArgs.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GArgs.h b/gcc/m2/mc-boot/GArgs.h
index 8de0d0f52f0f7335fd5b8a23dcb4394baa064ff7..4a7b4f9c886c872a704bff13ca0e370b90d0cffc 100644
--- a/gcc/m2/mc-boot/GArgs.h
+++ b/gcc/m2/mc-boot/GArgs.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_Args_H)
 #   define _Args_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GAssertion.cc b/gcc/m2/mc-boot/GAssertion.cc
index f4185f91cacc064ca3de21ed53dc76412c93adf2..18d693185f7fbe9712c815e90da9ed01be57611b 100644
--- a/gcc/m2/mc-boot/GAssertion.cc
+++ b/gcc/m2/mc-boot/GAssertion.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GAssertion.h b/gcc/m2/mc-boot/GAssertion.h
index 0ea29e4f406f1cab5f52cf527516ad88d9736ce2..94ca402a2152a4db31c6bb772119fb03cb80dce5 100644
--- a/gcc/m2/mc-boot/GAssertion.h
+++ b/gcc/m2/mc-boot/GAssertion.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_Assertion_H)
 #   define _Assertion_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GBreak.cc b/gcc/m2/mc-boot/GBreak.cc
index e8b5d053ac69af272275c54675392457c32020d9..f31d4a82b5ada9f1a9347c4751b3e8422e42fec2 100644
--- a/gcc/m2/mc-boot/GBreak.cc
+++ b/gcc/m2/mc-boot/GBreak.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GBreak.h b/gcc/m2/mc-boot/GBreak.h
index c29c8b9d3e066c9ba17234b884b42836f5499acb..14bd68e1ee9016997935d2fef994e918e3c1729b 100644
--- a/gcc/m2/mc-boot/GBreak.h
+++ b/gcc/m2/mc-boot/GBreak.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_Break_H)
 #   define _Break_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GCOROUTINES.h b/gcc/m2/mc-boot/GCOROUTINES.h
index 678a8742248419302d0cd9bb8ea51ee2850da5c5..7543c7e4969cf0d12de8300642adbb4bf59f3de5 100644
--- a/gcc/m2/mc-boot/GCOROUTINES.h
+++ b/gcc/m2/mc-boot/GCOROUTINES.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_COROUTINES_H)
 #   define _COROUTINES_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GCmdArgs.cc b/gcc/m2/mc-boot/GCmdArgs.cc
index 220fd0c3a8a9a4bbf2f1fc48608a54d19884d6e7..9c0da752714b1d9ac6c13b91ff7e157cc9c7e214 100644
--- a/gcc/m2/mc-boot/GCmdArgs.cc
+++ b/gcc/m2/mc-boot/GCmdArgs.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GCmdArgs.h b/gcc/m2/mc-boot/GCmdArgs.h
index a078d64a06d70fca04f29fddbb115fd21c20f862..b29a52acc0d04751f665f48c6c9fca534bb01e71 100644
--- a/gcc/m2/mc-boot/GCmdArgs.h
+++ b/gcc/m2/mc-boot/GCmdArgs.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_CmdArgs_H)
 #   define _CmdArgs_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GDebug.cc b/gcc/m2/mc-boot/GDebug.cc
index 1aa02a60e59150775e2f264de0486a577fc6c030..4e25f76428020c008b8f46b3cc85f164c668e533 100644
--- a/gcc/m2/mc-boot/GDebug.cc
+++ b/gcc/m2/mc-boot/GDebug.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GDebug.h b/gcc/m2/mc-boot/GDebug.h
index c43e363fe14ede45b9c39d055a347ec750f77d9f..b7530ea4d988d72ce29d79c44e45001d1dc0d4aa 100644
--- a/gcc/m2/mc-boot/GDebug.h
+++ b/gcc/m2/mc-boot/GDebug.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_Debug_H)
 #   define _Debug_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GDynamicStrings.cc b/gcc/m2/mc-boot/GDynamicStrings.cc
index a409ce79b1b4fb92895d2a31cf208021c839eaf5..55d2ae8038bc4fef3394a8c79366cb0a11315fa9 100644
--- a/gcc/m2/mc-boot/GDynamicStrings.cc
+++ b/gcc/m2/mc-boot/GDynamicStrings.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GDynamicStrings.h b/gcc/m2/mc-boot/GDynamicStrings.h
index 1860701b310b424f9a492590aa0b724af2803eb5..1939b73037ae1665d5a79a700df9a3d31f97b90c 100644
--- a/gcc/m2/mc-boot/GDynamicStrings.h
+++ b/gcc/m2/mc-boot/GDynamicStrings.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_DynamicStrings_H)
 #   define _DynamicStrings_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GEnvironment.cc b/gcc/m2/mc-boot/GEnvironment.cc
index 5a2ad756a05349be85f963afd6110f277d30fc25..044fba1079756e3a67e9035c0575a29ca9d0125b 100644
--- a/gcc/m2/mc-boot/GEnvironment.cc
+++ b/gcc/m2/mc-boot/GEnvironment.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GEnvironment.h b/gcc/m2/mc-boot/GEnvironment.h
index cf58be08b5fb85e5440ae163cadde21b38f3104c..3bfadaaebed2be15ecc159fe491f23a190699542 100644
--- a/gcc/m2/mc-boot/GEnvironment.h
+++ b/gcc/m2/mc-boot/GEnvironment.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_Environment_H)
 #   define _Environment_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GFIO.cc b/gcc/m2/mc-boot/GFIO.cc
index 440919af533811ed531f3194959ceff7712116a4..da373933d0935d7077051b6721486382c2a7766b 100644
--- a/gcc/m2/mc-boot/GFIO.cc
+++ b/gcc/m2/mc-boot/GFIO.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
@@ -2088,7 +2087,7 @@ extern "C" void FIO_SetPositionFromBeginning (FIO_File f, long int pos)
                   fd->buffer->position = 0;
                   fd->buffer->filled = 0;
                 }
-              offset = static_cast<long int> (libc_lseek (fd->unixfd, (ssize_t ) (pos), wrapc_SeekSet ()));
+              offset = static_cast<long int> (libc_lseek (fd->unixfd, (off_t ) (pos), wrapc_SeekSet ()));
               if ((offset >= 0) && (pos == offset))
                 {
                   fd->abspos = pos;
@@ -2137,7 +2136,7 @@ extern "C" void FIO_SetPositionFromEnd (FIO_File f, long int pos)
               fd->buffer->position = 0;
               fd->buffer->filled = 0;
             }
-          offset = static_cast<long int> (libc_lseek (fd->unixfd, (ssize_t ) (pos), wrapc_SeekEnd ()));
+          offset = static_cast<long int> (libc_lseek (fd->unixfd, (off_t ) (pos), wrapc_SeekEnd ()));
           if (offset >= 0)
             {
               fd->abspos = offset;
diff --git a/gcc/m2/mc-boot/GFIO.h b/gcc/m2/mc-boot/GFIO.h
index 3ab2c518da4a8263ad71de0218711b1ab67f0ccd..8b69241f1751e1a91756b06a21ce3e835847d5f1 100644
--- a/gcc/m2/mc-boot/GFIO.h
+++ b/gcc/m2/mc-boot/GFIO.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_FIO_H)
 #   define _FIO_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GFormatStrings.cc b/gcc/m2/mc-boot/GFormatStrings.cc
index e2ea1954d191b3988cf33ffa351588f670adf08b..f4c4fd6f8c102be75d6b4ec081a20451f9189311 100644
--- a/gcc/m2/mc-boot/GFormatStrings.cc
+++ b/gcc/m2/mc-boot/GFormatStrings.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GFormatStrings.h b/gcc/m2/mc-boot/GFormatStrings.h
index 61e84541e51321acd29dfe11d091566bb6f68f7a..6ab12c4ef02bbad7bed02fe961494d1ab8473b5b 100644
--- a/gcc/m2/mc-boot/GFormatStrings.h
+++ b/gcc/m2/mc-boot/GFormatStrings.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_FormatStrings_H)
 #   define _FormatStrings_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GFpuIO.cc b/gcc/m2/mc-boot/GFpuIO.cc
index 3fdd5fd2925db7b85dbcc81348c1cacaa7db61f8..6bd6a6bc59fd7c288e0d8fafad68e72ff2d0641d 100644
--- a/gcc/m2/mc-boot/GFpuIO.cc
+++ b/gcc/m2/mc-boot/GFpuIO.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GFpuIO.h b/gcc/m2/mc-boot/GFpuIO.h
index 1b6f9573ebc139ad9769e21db7a609428c1bca4f..1c6670d6c82ba1ee7d582b93703fb4f5816a73a3 100644
--- a/gcc/m2/mc-boot/GFpuIO.h
+++ b/gcc/m2/mc-boot/GFpuIO.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_FpuIO_H)
 #   define _FpuIO_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GIO.cc b/gcc/m2/mc-boot/GIO.cc
index a64f401a71619a6048e5cee0598b3d5716a26162..6e0ae3150a3491f3a27e8aaa4ca2c79e440d1a87 100644
--- a/gcc/m2/mc-boot/GIO.cc
+++ b/gcc/m2/mc-boot/GIO.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GIO.h b/gcc/m2/mc-boot/GIO.h
index 4037cfdef4c793267b08b90b9526852ab262ef74..d01d69a65168b0278220e7feffb09a22d22cbc8f 100644
--- a/gcc/m2/mc-boot/GIO.h
+++ b/gcc/m2/mc-boot/GIO.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_IO_H)
 #   define _IO_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GIndexing.cc b/gcc/m2/mc-boot/GIndexing.cc
index a38a4776c8c43916ff597714812ba7dad8589872..5ab0c4296aaf23aeb7fb85d002f9961c07a7a5c3 100644
--- a/gcc/m2/mc-boot/GIndexing.cc
+++ b/gcc/m2/mc-boot/GIndexing.cc
@@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GIndexing.h b/gcc/m2/mc-boot/GIndexing.h
index f6a58cf9b5472723d1418b8b246578c8e24ce17c..e1054b026fd8bec507ea4d4180aad7fefcc33fe7 100644
--- a/gcc/m2/mc-boot/GIndexing.h
+++ b/gcc/m2/mc-boot/GIndexing.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_Indexing_H)
 #   define _Indexing_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GM2Dependent.cc b/gcc/m2/mc-boot/GM2Dependent.cc
index 32f204fbbbceb08899ab4613045ef7988a965bbd..e8ade8773a14d0f3f9982cdca7a28b2a0e088b36 100644
--- a/gcc/m2/mc-boot/GM2Dependent.cc
+++ b/gcc/m2/mc-boot/GM2Dependent.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GM2Dependent.h b/gcc/m2/mc-boot/GM2Dependent.h
index f95d585ed96a682c9d5a17042305294b9a1ba4df..b9ad0c780b8c1c72cc44fddeeb0765709a865ecd 100644
--- a/gcc/m2/mc-boot/GM2Dependent.h
+++ b/gcc/m2/mc-boot/GM2Dependent.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_M2Dependent_H)
 #   define _M2Dependent_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GM2EXCEPTION.cc b/gcc/m2/mc-boot/GM2EXCEPTION.cc
index e2d89e0cb3742179b49fb752e66c8caecf52a3e7..62d47f08b5b532d0ebbe6ee941ebc3852d869ba9 100644
--- a/gcc/m2/mc-boot/GM2EXCEPTION.cc
+++ b/gcc/m2/mc-boot/GM2EXCEPTION.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GM2EXCEPTION.h b/gcc/m2/mc-boot/GM2EXCEPTION.h
index 66eb23ab12f001b796146eb09fa657e594525cfc..6f6b2f6712b6c02c01d9666ab6a4e408e7df1e16 100644
--- a/gcc/m2/mc-boot/GM2EXCEPTION.h
+++ b/gcc/m2/mc-boot/GM2EXCEPTION.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_M2EXCEPTION_H)
 #   define _M2EXCEPTION_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GM2RTS.cc b/gcc/m2/mc-boot/GM2RTS.cc
index 7149c1865dcddcedeeb4c7ecdcf67a10f39efe92..4fbce446882395a253090942b55bd705e7d5489d 100644
--- a/gcc/m2/mc-boot/GM2RTS.cc
+++ b/gcc/m2/mc-boot/GM2RTS.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GM2RTS.h b/gcc/m2/mc-boot/GM2RTS.h
index a1dbf88e2b63a1b2ed5677fd9aee72e32b8e62aa..ea6eabae97142ff22bcbb8ebd30975d47a1b0f7f 100644
--- a/gcc/m2/mc-boot/GM2RTS.h
+++ b/gcc/m2/mc-boot/GM2RTS.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_M2RTS_H)
 #   define _M2RTS_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GMemUtils.cc b/gcc/m2/mc-boot/GMemUtils.cc
index 4bdbe3e8344887a25d2b50149e6920adc952b654..828144fb02356a352c95627d37cbba7c2306d414 100644
--- a/gcc/m2/mc-boot/GMemUtils.cc
+++ b/gcc/m2/mc-boot/GMemUtils.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GMemUtils.h b/gcc/m2/mc-boot/GMemUtils.h
index 9fd5e46e790269bcf7f62cd59595889dc02b48fe..38a843417d96f17214f5d96efbc1b5aaf12bb284 100644
--- a/gcc/m2/mc-boot/GMemUtils.h
+++ b/gcc/m2/mc-boot/GMemUtils.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_MemUtils_H)
 #   define _MemUtils_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GNumberIO.cc b/gcc/m2/mc-boot/GNumberIO.cc
index 9de7a51353af3e63c8a94170f27ca37e7abc1832..8a04cbff7e63bb5d7136f8ab690769069d200edb 100644
--- a/gcc/m2/mc-boot/GNumberIO.cc
+++ b/gcc/m2/mc-boot/GNumberIO.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GNumberIO.h b/gcc/m2/mc-boot/GNumberIO.h
index b40c33d0316eaab495828d979cbd73a546bdbf34..13960e9660750ddcf6b5db6eed5f1b99272335a2 100644
--- a/gcc/m2/mc-boot/GNumberIO.h
+++ b/gcc/m2/mc-boot/GNumberIO.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_NumberIO_H)
 #   define _NumberIO_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GPushBackInput.cc b/gcc/m2/mc-boot/GPushBackInput.cc
index e526bf7438e50fe0fefdbc24b5a5769a547f33e3..60fb12ef898e86c461cb86521b0daff36960a90b 100644
--- a/gcc/m2/mc-boot/GPushBackInput.cc
+++ b/gcc/m2/mc-boot/GPushBackInput.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GPushBackInput.h b/gcc/m2/mc-boot/GPushBackInput.h
index b747e50baa4c677098ab6642db628aa62e6d1f7f..c2e034429481146a730958e7233794e260925d93 100644
--- a/gcc/m2/mc-boot/GPushBackInput.h
+++ b/gcc/m2/mc-boot/GPushBackInput.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_PushBackInput_H)
 #   define _PushBackInput_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GRTExceptions.cc b/gcc/m2/mc-boot/GRTExceptions.cc
index 881d97de1ec601859ec09d13ecdc7b0e9f020935..2f84fa638c30a1a5f1248de91e4be259f269abee 100644
--- a/gcc/m2/mc-boot/GRTExceptions.cc
+++ b/gcc/m2/mc-boot/GRTExceptions.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GRTExceptions.h b/gcc/m2/mc-boot/GRTExceptions.h
index 3d70cb3594676f3145f9acde593b56669aaf3889..24f3da38d6c301858600ddfbcd33413083dc8d02 100644
--- a/gcc/m2/mc-boot/GRTExceptions.h
+++ b/gcc/m2/mc-boot/GRTExceptions.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_RTExceptions_H)
 #   define _RTExceptions_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GRTco.h b/gcc/m2/mc-boot/GRTco.h
index aa6e928363545ee4e1be65174049cc2261e6e781..86c5b0316b1791d8fcc4742518cbeceb4d664eca 100644
--- a/gcc/m2/mc-boot/GRTco.h
+++ b/gcc/m2/mc-boot/GRTco.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_RTco_H)
 #   define _RTco_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GRTentity.h b/gcc/m2/mc-boot/GRTentity.h
index 6f54002aa31157e37f12d0ba84795a58fe7335e3..381ba680b634d52f62e187f7c7456946236b4847 100644
--- a/gcc/m2/mc-boot/GRTentity.h
+++ b/gcc/m2/mc-boot/GRTentity.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_RTentity_H)
 #   define _RTentity_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GRTint.cc b/gcc/m2/mc-boot/GRTint.cc
index 8f0f81036c32c5d10c0de2ad2ca32eba64ec0d71..188b6e0a9a24d799e9410457a507f55900606710 100644
--- a/gcc/m2/mc-boot/GRTint.cc
+++ b/gcc/m2/mc-boot/GRTint.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GRTint.h b/gcc/m2/mc-boot/GRTint.h
index 703dfb4c04ea556d0b16349369ece9d140545c26..daf64ecaae62050aa0c43646777d4ad2bee7e28d 100644
--- a/gcc/m2/mc-boot/GRTint.h
+++ b/gcc/m2/mc-boot/GRTint.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_RTint_H)
 #   define _RTint_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GSArgs.cc b/gcc/m2/mc-boot/GSArgs.cc
index cd4514ef8ddd865006b6db685f0244354cfab73a..414ea1f004e25bc19bd04643a80a42319a809b8a 100644
--- a/gcc/m2/mc-boot/GSArgs.cc
+++ b/gcc/m2/mc-boot/GSArgs.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GSArgs.h b/gcc/m2/mc-boot/GSArgs.h
index 70cab3886989bfc851fac56a07a5901972606d28..5164cca0bff8a6e44fe86762ef3ec89d3b42149a 100644
--- a/gcc/m2/mc-boot/GSArgs.h
+++ b/gcc/m2/mc-boot/GSArgs.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_SArgs_H)
 #   define _SArgs_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GSFIO.cc b/gcc/m2/mc-boot/GSFIO.cc
index 06fabab34f42195f927416e61f2cc7de8f2a1797..6ae0d5e048554fbe90e86b0f0663f986ca53602f 100644
--- a/gcc/m2/mc-boot/GSFIO.cc
+++ b/gcc/m2/mc-boot/GSFIO.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GSFIO.h b/gcc/m2/mc-boot/GSFIO.h
index e7fba7ebf7c8afec5b8c61f2d3a24def5b4917b5..42ffc48782a6b33bb74f03c240322c57b3d205b4 100644
--- a/gcc/m2/mc-boot/GSFIO.h
+++ b/gcc/m2/mc-boot/GSFIO.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_SFIO_H)
 #   define _SFIO_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GSYSTEM.h b/gcc/m2/mc-boot/GSYSTEM.h
index 125787f008a76792a16db8f22f4791c27c8a9706..e3d51ab97d58066ac301f9010827afad12ab0f58 100644
--- a/gcc/m2/mc-boot/GSYSTEM.h
+++ b/gcc/m2/mc-boot/GSYSTEM.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_SYSTEM_H)
 #   define _SYSTEM_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GSelective.h b/gcc/m2/mc-boot/GSelective.h
index 31f5932fedbb4160c422e8e9c84d87461943cafa..af2e9c31feaa97e38c65eb291633c6bb7c0a9de7 100644
--- a/gcc/m2/mc-boot/GSelective.h
+++ b/gcc/m2/mc-boot/GSelective.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_Selective_H)
 #   define _Selective_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GStdIO.cc b/gcc/m2/mc-boot/GStdIO.cc
index 85eebf4c8349b86a927dc3bff53d305034f811a8..e485eeb25752c7b39a65146bae71edf224a4336a 100644
--- a/gcc/m2/mc-boot/GStdIO.cc
+++ b/gcc/m2/mc-boot/GStdIO.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GStdIO.h b/gcc/m2/mc-boot/GStdIO.h
index 0418234bbb2fba759ca99b9c72250e1d81c013d6..b01480ac33a9eb753d8a34180de502035a83a28f 100644
--- a/gcc/m2/mc-boot/GStdIO.h
+++ b/gcc/m2/mc-boot/GStdIO.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_StdIO_H)
 #   define _StdIO_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GStorage.cc b/gcc/m2/mc-boot/GStorage.cc
index b19616f4ab556d8fa12f49f0112865160be6757c..f668201059f5fccc0c5264995289e5ee0c19014e 100644
--- a/gcc/m2/mc-boot/GStorage.cc
+++ b/gcc/m2/mc-boot/GStorage.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GStorage.h b/gcc/m2/mc-boot/GStorage.h
index e85fd7aeefa7a29012492224b0ba94fd69e4b3c8..f352d19f964438c9fe0a32a65e4dff83741be7d3 100644
--- a/gcc/m2/mc-boot/GStorage.h
+++ b/gcc/m2/mc-boot/GStorage.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_Storage_H)
 #   define _Storage_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GStrCase.cc b/gcc/m2/mc-boot/GStrCase.cc
index f33f5a52ac90d5b4e362958b47f022d4c7feacf6..40323ca949f77346e7cbd2a73a245f34304c4dd3 100644
--- a/gcc/m2/mc-boot/GStrCase.cc
+++ b/gcc/m2/mc-boot/GStrCase.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GStrCase.h b/gcc/m2/mc-boot/GStrCase.h
index 66b4f689fd09132a7de12584a8c2bb0550da0a7e..3762f57acac0ed88dfd73d3ecc8d59bfd82c2821 100644
--- a/gcc/m2/mc-boot/GStrCase.h
+++ b/gcc/m2/mc-boot/GStrCase.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_StrCase_H)
 #   define _StrCase_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GStrIO.cc b/gcc/m2/mc-boot/GStrIO.cc
index 46c392bb8a26acc0ca2ac836dc2544ad6492d07e..533460b63f706d01d60955d6c95eadc42e2b07fc 100644
--- a/gcc/m2/mc-boot/GStrIO.cc
+++ b/gcc/m2/mc-boot/GStrIO.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GStrIO.h b/gcc/m2/mc-boot/GStrIO.h
index 66ef3d4331c779e0385732726e4449b03a336274..24b31a992d5d2fcf02ac90047aba9cb13765ab7f 100644
--- a/gcc/m2/mc-boot/GStrIO.h
+++ b/gcc/m2/mc-boot/GStrIO.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_StrIO_H)
 #   define _StrIO_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GStrLib.cc b/gcc/m2/mc-boot/GStrLib.cc
index bc3c5e8c38810051ed82c44cc25164fd067bb8cc..dbde45c912262b939526da0fda106fcef310b976 100644
--- a/gcc/m2/mc-boot/GStrLib.cc
+++ b/gcc/m2/mc-boot/GStrLib.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GStrLib.h b/gcc/m2/mc-boot/GStrLib.h
index 2b11e84ca448568f086c379ee413ccfbe5f789e0..e79eb709845672c615c83fb93e2571ddfff682b7 100644
--- a/gcc/m2/mc-boot/GStrLib.h
+++ b/gcc/m2/mc-boot/GStrLib.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_StrLib_H)
 #   define _StrLib_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GStringConvert.cc b/gcc/m2/mc-boot/GStringConvert.cc
index ae50e99c2ab9b26c19e00ad9210e6dad60791c00..e552244fec553831f2c81a90e04042a14e0efd28 100644
--- a/gcc/m2/mc-boot/GStringConvert.cc
+++ b/gcc/m2/mc-boot/GStringConvert.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GStringConvert.h b/gcc/m2/mc-boot/GStringConvert.h
index 035ad56a52ad33d1524ad28e3745e19e462aa467..95f1bc1b52928d17626ccf404632dae72207d9f0 100644
--- a/gcc/m2/mc-boot/GStringConvert.h
+++ b/gcc/m2/mc-boot/GStringConvert.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_StringConvert_H)
 #   define _StringConvert_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GSysExceptions.h b/gcc/m2/mc-boot/GSysExceptions.h
index ef9a6a0f2d9d9bc8cdc02551a6dd433599fd03c2..928a0c1667de2f0827fcb66550d0af6701fe53e3 100644
--- a/gcc/m2/mc-boot/GSysExceptions.h
+++ b/gcc/m2/mc-boot/GSysExceptions.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_SysExceptions_H)
 #   define _SysExceptions_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GSysStorage.cc b/gcc/m2/mc-boot/GSysStorage.cc
index 906910bf3d8b8d805cdf7133943bfdd5f28aa3fe..1c0cb839ef4178ef73904ea8fcd61cf869eb6f24 100644
--- a/gcc/m2/mc-boot/GSysStorage.cc
+++ b/gcc/m2/mc-boot/GSysStorage.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GSysStorage.h b/gcc/m2/mc-boot/GSysStorage.h
index 930b3bae6cc26685c81bcfcdaa3f124001d7e3b0..3c1f310ff0ebf35b1ffe6020d2eeba531dbc3e81 100644
--- a/gcc/m2/mc-boot/GSysStorage.h
+++ b/gcc/m2/mc-boot/GSysStorage.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_SysStorage_H)
 #   define _SysStorage_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GTimeString.cc b/gcc/m2/mc-boot/GTimeString.cc
index fc9b8ada831b75c0212749a72c3cbc0f47f0dd21..b1d6e6e1e508c7df619996e800a8fc6404c5f715 100644
--- a/gcc/m2/mc-boot/GTimeString.cc
+++ b/gcc/m2/mc-boot/GTimeString.cc
@@ -25,7 +25,6 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GTimeString.h b/gcc/m2/mc-boot/GTimeString.h
index 6323436d70c23161897b77c95e7724bd6dc82885..c442abb2c22ff1eb97b4c29f8f1905d728a2b212 100644
--- a/gcc/m2/mc-boot/GTimeString.h
+++ b/gcc/m2/mc-boot/GTimeString.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_TimeString_H)
 #   define _TimeString_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GUnixArgs.h b/gcc/m2/mc-boot/GUnixArgs.h
index 79a1ea948d3a738183a101675161be3e6615d0e7..59ba2ac123ec7b5fbcf621b41a3c26d84edf681f 100644
--- a/gcc/m2/mc-boot/GUnixArgs.h
+++ b/gcc/m2/mc-boot/GUnixArgs.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_UnixArgs_H)
 #   define _UnixArgs_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Galists.cc b/gcc/m2/mc-boot/Galists.cc
index 09bfdccc49f868d5b0fdcd8d9cec2746d187de3d..7c42dd45625fbea0d3e35942fda0cc8184349f0c 100644
--- a/gcc/m2/mc-boot/Galists.cc
+++ b/gcc/m2/mc-boot/Galists.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/Galists.h b/gcc/m2/mc-boot/Galists.h
index fdacd985785b0d738190e75a123760d2923834f3..bda3ac6bf1f5139e77889c93b491ef382660b0ce 100644
--- a/gcc/m2/mc-boot/Galists.h
+++ b/gcc/m2/mc-boot/Galists.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_alists_H)
 #   define _alists_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gdecl.cc b/gcc/m2/mc-boot/Gdecl.cc
index 292c654fa66b915780412fb5c7deff9b758cc547..ae03483985012899df6a7a78e9745e1dea255176 100644
--- a/gcc/m2/mc-boot/Gdecl.cc
+++ b/gcc/m2/mc-boot/Gdecl.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
@@ -22790,7 +22789,7 @@ static decl_node__opaque doDupExpr (decl_node__opaque n)
         break;
 
       case decl_length:
-        M2RTS_HALT (-1);  /* length should have been converted into unary.  */
+        M2RTS_HALT (-1);
         __builtin_unreachable ();
         break;
 
diff --git a/gcc/m2/mc-boot/Gdecl.h b/gcc/m2/mc-boot/Gdecl.h
index 30e02f0a1e84b13ec6b821faea3e5b62d49e914e..a979c52f09593ce947b719262caacf15801c707e 100644
--- a/gcc/m2/mc-boot/Gdecl.h
+++ b/gcc/m2/mc-boot/Gdecl.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_decl_H)
 #   define _decl_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gdtoa.h b/gcc/m2/mc-boot/Gdtoa.h
index e58489e01e6d5e993558214c499e9215abfeea70..d371aeb78511f8ab1ff77758bde2f04c39364076 100644
--- a/gcc/m2/mc-boot/Gdtoa.h
+++ b/gcc/m2/mc-boot/Gdtoa.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_dtoa_H)
 #   define _dtoa_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gerrno.h b/gcc/m2/mc-boot/Gerrno.h
index 1f8c83a252da79fb379ed9961086d928e9deb843..256317afc8847c88da955849c8cd7e59986c0f9d 100644
--- a/gcc/m2/mc-boot/Gerrno.h
+++ b/gcc/m2/mc-boot/Gerrno.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_errno_H)
 #   define _errno_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gkeyc.cc b/gcc/m2/mc-boot/Gkeyc.cc
index 9a35e953d18cebb8143e33372b7e17326655d9eb..132c2fc7283c6aa3390e876eececf8acffdcad89 100644
--- a/gcc/m2/mc-boot/Gkeyc.cc
+++ b/gcc/m2/mc-boot/Gkeyc.cc
@@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
@@ -576,7 +575,6 @@ static void checkGccConfigSystem (mcPretty_pretty p)
       if (! initializedGCC)
         {
           initializedGCC = true;
-          mcPretty_print (p, (const char *) "#define INCLUDE_MEMORY\\n", 24);
           mcPretty_print (p, (const char *) "#include \"config.h\"\\n", 21);
           mcPretty_print (p, (const char *) "#include \"system.h\"\\n", 21);
           checkGccTypes (p);
diff --git a/gcc/m2/mc-boot/Gkeyc.h b/gcc/m2/mc-boot/Gkeyc.h
index 8537fbcc86b7bbb1dbb94af8ef6776645daed286..9a15c93d10f04329f621b0131c57c48c0c185209 100644
--- a/gcc/m2/mc-boot/Gkeyc.h
+++ b/gcc/m2/mc-boot/Gkeyc.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_keyc_H)
 #   define _keyc_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gldtoa.h b/gcc/m2/mc-boot/Gldtoa.h
index f24ab408bb0c23755ab4e0bc21dda0a4bdb5df5a..6ae682ee13c5d522f2569462ac55ad12790a72f6 100644
--- a/gcc/m2/mc-boot/Gldtoa.h
+++ b/gcc/m2/mc-boot/Gldtoa.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_ldtoa_H)
 #   define _ldtoa_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Glibc.h b/gcc/m2/mc-boot/Glibc.h
index cdf441f07741bbb72919b977ae494b79622abcc8..1519c99db850282a52c3aade115241583b10e53b 100644
--- a/gcc/m2/mc-boot/Glibc.h
+++ b/gcc/m2/mc-boot/Glibc.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_libc_H)
 #   define _libc_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
@@ -204,7 +203,7 @@ EXTERN int libc_creat (void * filename, unsigned int mode);
            off_t lseek(int fildes, off_t offset, int whence);
 */
 
-EXTERN ssize_t libc_lseek (int fd, ssize_t offset, int whence);
+EXTERN off_t libc_lseek (int fd, off_t offset, int whence);
 
 /*
    perror - writes errno and string. (ARRAY OF CHAR is translated onto ADDRESS).
diff --git a/gcc/m2/mc-boot/Glibm.h b/gcc/m2/mc-boot/Glibm.h
index 2c5a177735f445d47def168a7f8b93027fbf10fc..344ac623f0ed31afaacb0bc5302d61cda83b26cb 100644
--- a/gcc/m2/mc-boot/Glibm.h
+++ b/gcc/m2/mc-boot/Glibm.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_libm_H)
 #   define _libm_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Glists.cc b/gcc/m2/mc-boot/Glists.cc
index 2e459ca910dfbb806086ff6eabfa161b1fb56614..f29edec1a140b6e9bb223cb37b4eca5cf977d5a8 100644
--- a/gcc/m2/mc-boot/Glists.cc
+++ b/gcc/m2/mc-boot/Glists.cc
@@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/Glists.h b/gcc/m2/mc-boot/Glists.h
index e89a42a4006f406f4b76d4e9d754ea0bf52facb7..84537a1ffc5740c6458d1c600172e5ab4c117e6c 100644
--- a/gcc/m2/mc-boot/Glists.h
+++ b/gcc/m2/mc-boot/Glists.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_lists_H)
 #   define _lists_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcComment.cc b/gcc/m2/mc-boot/GmcComment.cc
index 320c512628902e2fe3f89d6ae23d0dca034a04ff..d5f741e047b77ac288fe32560c8aae4071798a8a 100644
--- a/gcc/m2/mc-boot/GmcComment.cc
+++ b/gcc/m2/mc-boot/GmcComment.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcComment.h b/gcc/m2/mc-boot/GmcComment.h
index bbb7d2fbb726a393c02e6400abf1360bb30c98a6..10dd5c2781c9cab030caf124d4fb49ebcc73a6b3 100644
--- a/gcc/m2/mc-boot/GmcComment.h
+++ b/gcc/m2/mc-boot/GmcComment.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcComment_H)
 #   define _mcComment_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcComp.cc b/gcc/m2/mc-boot/GmcComp.cc
index 72c277d203ab2bed6b7d2eda626f89e2481fb0a0..e36fa638c9e737096fcb52537df31840ffe8de7f 100644
--- a/gcc/m2/mc-boot/GmcComp.cc
+++ b/gcc/m2/mc-boot/GmcComp.cc
@@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcComp.h b/gcc/m2/mc-boot/GmcComp.h
index a4e302f6af9310bc84b08822854185bc44870f69..17e2080d780de64b56d27adb73dd85162e613a22 100644
--- a/gcc/m2/mc-boot/GmcComp.h
+++ b/gcc/m2/mc-boot/GmcComp.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcComp_H)
 #   define _mcComp_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcDebug.cc b/gcc/m2/mc-boot/GmcDebug.cc
index 7ded4aee139fcc593988f7a5ea58676e51c2b63d..0085384f2c98262114519c041d6e43cf589d5039 100644
--- a/gcc/m2/mc-boot/GmcDebug.cc
+++ b/gcc/m2/mc-boot/GmcDebug.cc
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcDebug.h b/gcc/m2/mc-boot/GmcDebug.h
index e4ac762d64864699827f36fc5076297eab500fad..a46fa13eeb0aa2087e3ff7f5d59c7e77ff009655 100644
--- a/gcc/m2/mc-boot/GmcDebug.h
+++ b/gcc/m2/mc-boot/GmcDebug.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcDebug_H)
 #   define _mcDebug_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcError.cc b/gcc/m2/mc-boot/GmcError.cc
index 4e29211845590e4e7ce548ef717a13d213e0492c..a3df34e77996825f219c6b121017f3ca2cad0505 100644
--- a/gcc/m2/mc-boot/GmcError.cc
+++ b/gcc/m2/mc-boot/GmcError.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcError.h b/gcc/m2/mc-boot/GmcError.h
index 951f6ae3bbe6ea9c16ab774b5c0427266dbfb875..054a4780a728cf7cf9383ca26524f7cc20a09234 100644
--- a/gcc/m2/mc-boot/GmcError.h
+++ b/gcc/m2/mc-boot/GmcError.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcError_H)
 #   define _mcError_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcFileName.cc b/gcc/m2/mc-boot/GmcFileName.cc
index f0f69129e06cf86a623308906bc413b0002e5281..3b516594c595e447de748ae00876a68b32b43364 100644
--- a/gcc/m2/mc-boot/GmcFileName.cc
+++ b/gcc/m2/mc-boot/GmcFileName.cc
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcFileName.h b/gcc/m2/mc-boot/GmcFileName.h
index 04e08ec8e9a2f5bc25d1f79728e31492023fd271..11f1512dbe81ccf3c17b13b46646a16358c4a6a8 100644
--- a/gcc/m2/mc-boot/GmcFileName.h
+++ b/gcc/m2/mc-boot/GmcFileName.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcFileName_H)
 #   define _mcFileName_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcLexBuf.cc b/gcc/m2/mc-boot/GmcLexBuf.cc
index dd6b87e5a211900862cb7f82853c6ca49fa29ecd..4f2293165aea49d692f6a43b22d03d29daf895b4 100644
--- a/gcc/m2/mc-boot/GmcLexBuf.cc
+++ b/gcc/m2/mc-boot/GmcLexBuf.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcLexBuf.h b/gcc/m2/mc-boot/GmcLexBuf.h
index bb552aee3fa653808b4e472908c4c5cdc26b9eb8..ca22526c0a43055b739ca6321a319fb2572fb42a 100644
--- a/gcc/m2/mc-boot/GmcLexBuf.h
+++ b/gcc/m2/mc-boot/GmcLexBuf.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcLexBuf_H)
 #   define _mcLexBuf_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcMetaError.cc b/gcc/m2/mc-boot/GmcMetaError.cc
index 9298d0e4192721d32a6d1447ab80007307aa5099..af64604534e2f189df03a43405ba166b9862c42b 100644
--- a/gcc/m2/mc-boot/GmcMetaError.cc
+++ b/gcc/m2/mc-boot/GmcMetaError.cc
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcMetaError.h b/gcc/m2/mc-boot/GmcMetaError.h
index ce5e8e1b7952cb9ac6baa017c8dd48f3b5815ee3..de244c186fffb52477c8f109d1cdebe413a13d35 100644
--- a/gcc/m2/mc-boot/GmcMetaError.h
+++ b/gcc/m2/mc-boot/GmcMetaError.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcMetaError_H)
 #   define _mcMetaError_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcOptions.cc b/gcc/m2/mc-boot/GmcOptions.cc
index f6e4417b6593929b83ed18b8cf8a089029456f00..5a0606047092a46b3dbf6eaf62b7adc0355e469f 100644
--- a/gcc/m2/mc-boot/GmcOptions.cc
+++ b/gcc/m2/mc-boot/GmcOptions.cc
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcOptions.h b/gcc/m2/mc-boot/GmcOptions.h
index 2db8bcb998a043876cb861d2d972e02c7a4417d7..aab560038e22e4317df4171a04f47f41e88eae62 100644
--- a/gcc/m2/mc-boot/GmcOptions.h
+++ b/gcc/m2/mc-boot/GmcOptions.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcOptions_H)
 #   define _mcOptions_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcPreprocess.cc b/gcc/m2/mc-boot/GmcPreprocess.cc
index 54d89bf33e75ac3931f13571832b1568e06c6485..741109ad7fbf40fd4dfe0fd035671a763807537a 100644
--- a/gcc/m2/mc-boot/GmcPreprocess.cc
+++ b/gcc/m2/mc-boot/GmcPreprocess.cc
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcPreprocess.h b/gcc/m2/mc-boot/GmcPreprocess.h
index 05e8122a332a50abd8a5d01269ba29ad03453b81..21b4fd458a4ffb2763d274702af36d16b6625180 100644
--- a/gcc/m2/mc-boot/GmcPreprocess.h
+++ b/gcc/m2/mc-boot/GmcPreprocess.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcPreprocess_H)
 #   define _mcPreprocess_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcPretty.cc b/gcc/m2/mc-boot/GmcPretty.cc
index c0be8c1e49915f0dd5c080573d5e35bed4b7d0bb..0bffa1ff6feb4025432e5dc2e01a4b550207c48c 100644
--- a/gcc/m2/mc-boot/GmcPretty.cc
+++ b/gcc/m2/mc-boot/GmcPretty.cc
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcPretty.h b/gcc/m2/mc-boot/GmcPretty.h
index 95d7a0b13ae2ab90fd8f9a0fdcc6cb7b6093b5c4..d6834e2f9004b466b1dd8a284cb872159b02d273 100644
--- a/gcc/m2/mc-boot/GmcPretty.h
+++ b/gcc/m2/mc-boot/GmcPretty.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcPretty_H)
 #   define _mcPretty_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcPrintf.cc b/gcc/m2/mc-boot/GmcPrintf.cc
index dafa728437fdcd5c57c4677a5a680b43c85b9fbf..e91e55acc14c73501b25126b86c113da004dec81 100644
--- a/gcc/m2/mc-boot/GmcPrintf.cc
+++ b/gcc/m2/mc-boot/GmcPrintf.cc
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcPrintf.h b/gcc/m2/mc-boot/GmcPrintf.h
index 6d70a6db6a5ee0e91cb3da841aa265bb6b460a5c..ca1129a26ef739e2219e747a03d59e78a474a976 100644
--- a/gcc/m2/mc-boot/GmcPrintf.h
+++ b/gcc/m2/mc-boot/GmcPrintf.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcPrintf_H)
 #   define _mcPrintf_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcQuiet.cc b/gcc/m2/mc-boot/GmcQuiet.cc
index 3309f13d736c9ee5c3f9a0ed486328fc390e9021..d0f2f009b2a86ece8f6228f039d49ff60a524835 100644
--- a/gcc/m2/mc-boot/GmcQuiet.cc
+++ b/gcc/m2/mc-boot/GmcQuiet.cc
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcQuiet.h b/gcc/m2/mc-boot/GmcQuiet.h
index 6eebb3b69cdbd6ae82e2073435094835adbbd64e..b84144c9f30b11d190ab49be7b9bbc5c13f582a0 100644
--- a/gcc/m2/mc-boot/GmcQuiet.h
+++ b/gcc/m2/mc-boot/GmcQuiet.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcQuiet_H)
 #   define _mcQuiet_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcReserved.cc b/gcc/m2/mc-boot/GmcReserved.cc
index 02132e48b4b8fbb007c12fc0880312f5c586cdc3..a42f1b1b0acb7a3b6124f98d418af8a43ea422e5 100644
--- a/gcc/m2/mc-boot/GmcReserved.cc
+++ b/gcc/m2/mc-boot/GmcReserved.cc
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcReserved.h b/gcc/m2/mc-boot/GmcReserved.h
index 18e15f6247eeba0de2934ae4139bec0167938215..8c5adca465a8e0a6ac05633f0422a7c15cbb4893 100644
--- a/gcc/m2/mc-boot/GmcReserved.h
+++ b/gcc/m2/mc-boot/GmcReserved.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcReserved_H)
 #   define _mcReserved_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcSearch.cc b/gcc/m2/mc-boot/GmcSearch.cc
index 14d3e3fe0abd69b667377483be490cd447f828ae..e1a2aa63e29d99ff6df0db90998a1a3cb6b895f1 100644
--- a/gcc/m2/mc-boot/GmcSearch.cc
+++ b/gcc/m2/mc-boot/GmcSearch.cc
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcSearch.h b/gcc/m2/mc-boot/GmcSearch.h
index 4ea92e0c0fa7b3b9f093915ed52833008ca44392..277f55858496f67a7040b0edb3e3c3b869210f1e 100644
--- a/gcc/m2/mc-boot/GmcSearch.h
+++ b/gcc/m2/mc-boot/GmcSearch.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcSearch_H)
 #   define _mcSearch_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcStack.cc b/gcc/m2/mc-boot/GmcStack.cc
index 8edae475e6de4d6afd9dba22bb47fbde547005ed..70f937b4299161810300f776a152506e5631e875 100644
--- a/gcc/m2/mc-boot/GmcStack.cc
+++ b/gcc/m2/mc-boot/GmcStack.cc
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcStack.h b/gcc/m2/mc-boot/GmcStack.h
index ee1fad402fc79fb86fbbc3ab271ea045d8ed33e3..fe790ced893383f3917e613462de6e902cad7bc0 100644
--- a/gcc/m2/mc-boot/GmcStack.h
+++ b/gcc/m2/mc-boot/GmcStack.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcStack_H)
 #   define _mcStack_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GmcStream.cc b/gcc/m2/mc-boot/GmcStream.cc
index a35ee25294f1215374efd311e523d64d17095fd2..f970dd61c2e5b6d333a15e48cfcd2c7c5af4b436 100644
--- a/gcc/m2/mc-boot/GmcStream.cc
+++ b/gcc/m2/mc-boot/GmcStream.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GmcStream.h b/gcc/m2/mc-boot/GmcStream.h
index 0584dd743c3ade64f62477836e667dc1b2e7609b..6fef979e5fb77ac29b4d6c31f09a90bba1b27737 100644
--- a/gcc/m2/mc-boot/GmcStream.h
+++ b/gcc/m2/mc-boot/GmcStream.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcStream_H)
 #   define _mcStream_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gmcflex.h b/gcc/m2/mc-boot/Gmcflex.h
index 739c99267e9313cced874e32ba878a30d4c3e79e..b6a3d0a03d7a2079b7ea524a7471c0fb8d07c7fb 100644
--- a/gcc/m2/mc-boot/Gmcflex.h
+++ b/gcc/m2/mc-boot/Gmcflex.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcflex_H)
 #   define _mcflex_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gmcp1.cc b/gcc/m2/mc-boot/Gmcp1.cc
index cb0d1ad1698d7e7493af17f965c1d4f7f69df934..389c1381bf356259f3d1b1d955d526840e5d7aca 100644
--- a/gcc/m2/mc-boot/Gmcp1.cc
+++ b/gcc/m2/mc-boot/Gmcp1.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING.  If not,
 see <https://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/Gmcp1.h b/gcc/m2/mc-boot/Gmcp1.h
index 428f312a6d62c5a77863c4beb6ee32c4488acaa9..2bc44047820ed44c4c68d2338c5a33349980dec9 100644
--- a/gcc/m2/mc-boot/Gmcp1.h
+++ b/gcc/m2/mc-boot/Gmcp1.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcp1_H)
 #   define _mcp1_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gmcp2.cc b/gcc/m2/mc-boot/Gmcp2.cc
index bfd3e0c5b62b6952d1f68ee9a56c11e12932c99c..88ff478ce70dfc3cee73813910a4b575b5792357 100644
--- a/gcc/m2/mc-boot/Gmcp2.cc
+++ b/gcc/m2/mc-boot/Gmcp2.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING.  If not,
 see <https://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/Gmcp2.h b/gcc/m2/mc-boot/Gmcp2.h
index 8fc92ea91122546ba350f688c8381ce0fd163e00..080c4fae962510c3682532320e205d1961c8ab9b 100644
--- a/gcc/m2/mc-boot/Gmcp2.h
+++ b/gcc/m2/mc-boot/Gmcp2.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcp2_H)
 #   define _mcp2_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gmcp3.cc b/gcc/m2/mc-boot/Gmcp3.cc
index f345cf666fb21655b0bf589bfc12ccba6177a619..aa8b7338d13a68e20f52cda99ce78902ae527cd8 100644
--- a/gcc/m2/mc-boot/Gmcp3.cc
+++ b/gcc/m2/mc-boot/Gmcp3.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING.  If not,
 see <https://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/Gmcp3.h b/gcc/m2/mc-boot/Gmcp3.h
index d58349f1998d68462ee82c35a15647c1c10c9464..231e6f0cc7a0cc6793c2fde77f3fdf8e5dfd0cf1 100644
--- a/gcc/m2/mc-boot/Gmcp3.h
+++ b/gcc/m2/mc-boot/Gmcp3.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcp3_H)
 #   define _mcp3_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gmcp4.cc b/gcc/m2/mc-boot/Gmcp4.cc
index 872b7b102c58e0e1f3e556002e96303e32ce2a11..5cf2ec15de3a12d001ecefaaedb3242763b28794 100644
--- a/gcc/m2/mc-boot/Gmcp4.cc
+++ b/gcc/m2/mc-boot/Gmcp4.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING.  If not,
 see <https://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/Gmcp4.h b/gcc/m2/mc-boot/Gmcp4.h
index c374b34bf777a210bee4ebbdbc0d6ed154db4437..826cba6809e51be97d5b004f8c38944826257d27 100644
--- a/gcc/m2/mc-boot/Gmcp4.h
+++ b/gcc/m2/mc-boot/Gmcp4.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcp4_H)
 #   define _mcp4_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gmcp5.cc b/gcc/m2/mc-boot/Gmcp5.cc
index 0fa727a7fc3594bc2e611e7c71102fb518483ed5..20b006cab71bc71270d1ca096f8b439eded93bd1 100644
--- a/gcc/m2/mc-boot/Gmcp5.cc
+++ b/gcc/m2/mc-boot/Gmcp5.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING.  If not,
 see <https://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/Gmcp5.h b/gcc/m2/mc-boot/Gmcp5.h
index 44cb6ce2b50a88d78d151a5360621c2ed968b4e7..001f08436691e1bab6fb6a97807628eade6b688c 100644
--- a/gcc/m2/mc-boot/Gmcp5.h
+++ b/gcc/m2/mc-boot/Gmcp5.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_mcp5_H)
 #   define _mcp5_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GnameKey.cc b/gcc/m2/mc-boot/GnameKey.cc
index 128ac93c9bcdb7ab8f99dbdb857e5a314723bf71..ea52ccbc3fe39cd0342a386a3ea21d05f04776e5 100644
--- a/gcc/m2/mc-boot/GnameKey.cc
+++ b/gcc/m2/mc-boot/GnameKey.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GnameKey.h b/gcc/m2/mc-boot/GnameKey.h
index 1ef63030a95606d03a647d8c4f90b092d522dd75..8204133d61f515218676d5fcfd56e6230c2d26d5 100644
--- a/gcc/m2/mc-boot/GnameKey.h
+++ b/gcc/m2/mc-boot/GnameKey.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_nameKey_H)
 #   define _nameKey_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/GsymbolKey.cc b/gcc/m2/mc-boot/GsymbolKey.cc
index c9848d54307413b522edb69526ca1391aa6cda11..61232975187976c5f8e4d6aac6ac49264e4f3ccf 100644
--- a/gcc/m2/mc-boot/GsymbolKey.cc
+++ b/gcc/m2/mc-boot/GsymbolKey.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/GsymbolKey.h b/gcc/m2/mc-boot/GsymbolKey.h
index 82c2fe114224e8d33cbac602317b78f9cd00ba07..be8d8ed9f76452405e4c2c849d70b97b244bf4ac 100644
--- a/gcc/m2/mc-boot/GsymbolKey.h
+++ b/gcc/m2/mc-boot/GsymbolKey.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_symbolKey_H)
 #   define _symbolKey_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gtermios.h b/gcc/m2/mc-boot/Gtermios.h
index a95e43fa3373f43dcb030d6edf79cf77db0f4cea..fc6cf989f7ea7f1a42d5b776211a34b5ce8c8e92 100644
--- a/gcc/m2/mc-boot/Gtermios.h
+++ b/gcc/m2/mc-boot/Gtermios.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_termios_H)
 #   define _termios_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gtop.cc b/gcc/m2/mc-boot/Gtop.cc
index ba492e5acbf565c604da507c8adb2687ac626ee9..34c5b27edd2ca021f16a8dc18e5f0d7610421dfe 100644
--- a/gcc/m2/mc-boot/Gtop.cc
+++ b/gcc/m2/mc-boot/Gtop.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/Gvarargs.cc b/gcc/m2/mc-boot/Gvarargs.cc
index 0f517c4d9d63dec2b12755c94ca056c30e2192a6..c9ba44d3439b08d122b02018abbbfd9e2aadc214 100644
--- a/gcc/m2/mc-boot/Gvarargs.cc
+++ b/gcc/m2/mc-boot/Gvarargs.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/Gvarargs.h b/gcc/m2/mc-boot/Gvarargs.h
index 9ac674ca5d65a65e1275a929eada6582878709e5..b68ca9fad56848abf34117c49d9373b065cf9b85 100644
--- a/gcc/m2/mc-boot/Gvarargs.h
+++ b/gcc/m2/mc-boot/Gvarargs.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_varargs_H)
 #   define _varargs_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gwlists.cc b/gcc/m2/mc-boot/Gwlists.cc
index adf86f80dd83b673000444d771ba1256153a0b08..68482482ae1538d9ae2ce35e27e3a82222016e91 100644
--- a/gcc/m2/mc-boot/Gwlists.cc
+++ b/gcc/m2/mc-boot/Gwlists.cc
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <stdbool.h>
diff --git a/gcc/m2/mc-boot/Gwlists.h b/gcc/m2/mc-boot/Gwlists.h
index 424cdfb57ed834f75a2c05958f83461ae5ae4309..fe07de5e5d96c7a30e1bc256ac08cf06e7476bfd 100644
--- a/gcc/m2/mc-boot/Gwlists.h
+++ b/gcc/m2/mc-boot/Gwlists.h
@@ -24,7 +24,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 #if !defined (_wlists_H)
 #   define _wlists_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc-boot/Gwrapc.h b/gcc/m2/mc-boot/Gwrapc.h
index d36d74ccd4a95ddf8ccb97ed6fc33eec74f3717a..4d77e274c3c0592ea0292a95c332065df824df30 100644
--- a/gcc/m2/mc-boot/Gwrapc.h
+++ b/gcc/m2/mc-boot/Gwrapc.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_wrapc_H)
 #   define _wrapc_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/mc/keyc.mod b/gcc/m2/mc/keyc.mod
index 857dffc6ab0dce67c480731bfc2a8d39c4894694..907db3daba9cead571373561eb6cde91923bde83 100644
--- a/gcc/m2/mc/keyc.mod
+++ b/gcc/m2/mc/keyc.mod
@@ -95,7 +95,6 @@ BEGIN
       IF NOT initializedGCC
       THEN
          initializedGCC := TRUE ;
-         print (p, '#define INCLUDE_MEMORY\n');
          print (p, '#include "config.h"\n');
          print (p, '#include "system.h"\n');
          checkGccTypes (p)
diff --git a/gcc/m2/pge-boot/GFIO.cc b/gcc/m2/pge-boot/GFIO.cc
index e34e3eff32cf517eee8d7b6c090a26df41bed5b6..e22a3bcdce2aa2c3e428f4a5b659e98f46372816 100644
--- a/gcc/m2/pge-boot/GFIO.cc
+++ b/gcc/m2/pge-boot/GFIO.cc
@@ -47,7 +47,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #   include "GStorage.h"
 #   include "Gmcrts.h"
 #include <unistd.h>
-#   include <sys/types.h>
 #if defined(__cplusplus)
 #   undef NULL
 #   define NULL 0
@@ -2091,7 +2090,7 @@ extern "C" void FIO_SetPositionFromBeginning (FIO_File f, long int pos)
                   fd->buffer->position = 0;
                   fd->buffer->filled = 0;
                 }
-              offset = static_cast<long int> (libc_lseek (fd->unixfd, (ssize_t ) (pos), wrapc_SeekSet ()));
+              offset = static_cast<long int> (libc_lseek (fd->unixfd, (off_t ) (pos), wrapc_SeekSet ()));
               if ((offset >= 0) && (pos == offset))
                 {
                   fd->abspos = pos;
@@ -2140,7 +2139,7 @@ extern "C" void FIO_SetPositionFromEnd (FIO_File f, long int pos)
               fd->buffer->position = 0;
               fd->buffer->filled = 0;
             }
-          offset = static_cast<long int> (libc_lseek (fd->unixfd, (ssize_t ) (pos), wrapc_SeekEnd ()));
+          offset = static_cast<long int> (libc_lseek (fd->unixfd, (off_t ) (pos), wrapc_SeekEnd ()));
           if (offset >= 0)
             {
               fd->abspos = offset;
diff --git a/gcc/m2/pge-boot/GIndexing.h b/gcc/m2/pge-boot/GIndexing.h
index 4227866039a52f8b273c62e7b38b1aaeecd9f7c5..bb307ffc860c81812096d68a50e3091afeefedf0 100644
--- a/gcc/m2/pge-boot/GIndexing.h
+++ b/gcc/m2/pge-boot/GIndexing.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_Indexing_H)
 #   define _Indexing_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/pge-boot/GSEnvironment.h b/gcc/m2/pge-boot/GSEnvironment.h
index 8429c3e87d9b7d2e4c0aec373602cfffbdfdfffe..01850abfd0f0d7d2fce151315040db0f6615c2ec 100644
--- a/gcc/m2/pge-boot/GSEnvironment.h
+++ b/gcc/m2/pge-boot/GSEnvironment.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_SEnvironment_H)
 #   define _SEnvironment_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/pge-boot/GScan.h b/gcc/m2/pge-boot/GScan.h
index 04b7490476edce798bd3deb741ade102b6c0de74..d4b901744f7e0db54497b2171064ad10b18c86c1 100644
--- a/gcc/m2/pge-boot/GScan.h
+++ b/gcc/m2/pge-boot/GScan.h
@@ -29,7 +29,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #if !defined (_Scan_H)
 #   define _Scan_H
 
-#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #   ifdef __cplusplus
diff --git a/gcc/m2/pge-boot/Glibc.h b/gcc/m2/pge-boot/Glibc.h
index ad7deb54d5300e5b0b6d0f991eee82b7d52aa4e1..6c670c7742d0d64a1fe2f2a3721bc6dfa9f70afb 100644
--- a/gcc/m2/pge-boot/Glibc.h
+++ b/gcc/m2/pge-boot/Glibc.h
@@ -203,7 +203,7 @@ EXTERN int libc_creat (void * filename, unsigned int mode);
            off_t lseek(int fildes, off_t offset, int whence);
 */
 
-EXTERN off_t libc_lseek (int fd, ssize_t offset, int whence);
+EXTERN off_t libc_lseek (int fd, off_t offset, int whence);
 
 /*
    perror - writes errno and string. (ARRAY OF CHAR is translated onto ADDRESS).
diff --git a/gcc/match.pd b/gcc/match.pd
index 1cdc7e94f1feed429994ae7805567ec2ea83bb43..97e0bafdda4b9aefc4d8be07d9c78b3cbebc4204 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -303,6 +303,23 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (mult @0 integer_zerop@1)
  @1)
 
+#if GIMPLE
+/* When multiplying a value by a boolean involving the value, we may
+   be able to simplify further.
+     a * ((a || b) != 0) -> a
+     a * ((a || b) == 0) -> 0
+
+   There are also bit-and cases which don't show up in practice yet.
+     a * ((a && b) != 0) -> a * b
+     a * ((a && b) == 0) -> b != 0 ? a : b */
+(for neeq (ne eq)
+ (simplify
+  (mult:c (convert? (neeq (bit_ior:c @0 @1) integer_zerop@2)) @0)
+  (if (neeq == EQ_EXPR)
+   { build_zero_cst (type); }
+   @0)))
+#endif
+
 /* -x == x -> x == 0 */
 (for cmp (eq ne)
  (simplify
@@ -965,6 +982,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (bit_and @0 (negate @1))))
 
 (for div (trunc_div ceil_div floor_div round_div exact_div)
+#if GIMPLE
+ /* Canonicalize unsigned t / 4 to t >> 2.  */
+ (simplify
+  (div @0 integer_pow2p@1)
+  (if (INTEGRAL_TYPE_P (type)
+       && (TYPE_UNSIGNED (type) || tree_expr_nonnegative_p (@0)))
+   (rshift @0 { build_int_cst (integer_type_node,
+			       wi::exact_log2 (wi::to_wide (@1))); })))
+#endif
  /* Simplify (t * u) / u -> t.  */
  (simplify
   (div (mult:c @0 @1) @1)
@@ -8320,12 +8346,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
     /* Simplify logN (x) CMP CST into x CMP expN (CST) */
     (simplify
     (cmp:c (logs:s @0) REAL_CST@1)
-     (cmp @0 (exps @1)))
+     (cmp @0 (exps! @1)))
 
     /* Simplify expN (x) CMP CST into x CMP logN (CST) */
     (simplify
     (cmp:c (exps:s @0) REAL_CST@1)
-     (cmp @0 (logs @1))))))
+     (cmp @0 (logs! @1))))))
 
  (for logs (LOG LOG2 LOG10 LOG10)
       exps (EXP EXP2 EXP10 POW10)
diff --git a/gcc/optabs-query.cc b/gcc/optabs-query.cc
index 65eeb5d8e519e8bebbc2e17d56764d034223ed46..f5ca98da818a7ae2f85c9fedd668afc97184e2e9 100644
--- a/gcc/optabs-query.cc
+++ b/gcc/optabs-query.cc
@@ -492,7 +492,7 @@ find_widening_optab_handler_and_mode (optab op, machine_mode to_mode,
     {
       gcc_checking_assert (VECTOR_MODE_P (from_mode)
 			   && GET_MODE_INNER (from_mode) < to_mode);
-      limit_mode = from_mode;
+      limit_mode = GET_MODE_NEXT_MODE (from_mode).require ();
     }
   else
     gcc_checking_assert (GET_MODE_CLASS (from_mode) == GET_MODE_CLASS (to_mode)
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index fa9218472edc5821492d741a740f151ec54eab8b..a3d7e5a478e4f29bcce69f88d6e2677dcceba553 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -1484,6 +1484,11 @@ for (i = 0; i < n_opts; i++) {
 	if (name == "")
 		continue;
 
+	# We do not want to compare warning-related options, since they
+	# might have been modified by a #pragma GCC diagnostic.
+	if (flag_set_p("Warning", flags[i]))
+		continue;
+
 	if (name in checked_options)
 		continue;
 	checked_options[name]++
diff --git a/gcc/pair-fusion.cc b/gcc/pair-fusion.cc
index b6643ca4812382bd7c1f28aa5bb1a9ad23549177..5708d0f3b671b3303cfda0649215d8550e89f545 100644
--- a/gcc/pair-fusion.cc
+++ b/gcc/pair-fusion.cc
@@ -573,11 +573,13 @@ pair_fusion_bb_info::track_access (insn_info *insn, bool load_p, rtx mem)
 // If IGNORE_INSN is non-NULL, we should further ignore any hazards arising
 // from that insn.
 //
-// N.B. we ignore any defs/uses of memory here as we deal with that separately,
-// making use of alias disambiguation.
+// IS_LOAD_STORE is true if INSN is one of the loads or stores in the
+// candidate pair.  We ignore any defs/uses of memory in such instructions
+// as we deal with that separately, making use of alias disambiguation.
 static insn_info *
 latest_hazard_before (insn_info *insn, rtx *ignore,
-		      insn_info *ignore_insn = nullptr)
+		      insn_info *ignore_insn = nullptr,
+		      bool is_load_store = true)
 {
   insn_info *result = nullptr;
 
@@ -588,6 +590,10 @@ latest_hazard_before (insn_info *insn, rtx *ignore,
       && find_reg_note (insn->rtl (), REG_EH_REGION, NULL_RTX))
     return insn->prev_nondebug_insn ();
 
+  if (!is_load_store
+      && accesses_include_memory (insn->defs ()))
+    return insn->prev_nondebug_insn ();
+
   // Return true if we registered the hazard.
   auto hazard = [&](insn_info *h) -> bool
     {
@@ -1238,7 +1244,7 @@ pair_fusion::find_trailing_add (insn_info *insns[2],
 		 insns[0]->uid (), insns[1]->uid ());
     };
 
-  insn_info *hazard = latest_hazard_before (cand, nullptr, insns[1]);
+  insn_info *hazard = latest_hazard_before (cand, nullptr, insns[1], false);
   if (!hazard || *hazard <= *pair_dst)
     {
       if (dump_file)
@@ -1633,7 +1639,7 @@ pair_fusion_bb_info::fuse_pair (bool load_p,
   insn_info *insns[2] = { first, second };
 
   auto_vec<insn_change *> changes;
-  auto_vec<int, 2> tombstone_uids (2);
+  auto_vec<int, 3> tombstone_uids;
 
   rtx pats[2] = {
     PATTERN (first->rtl ()),
@@ -1724,6 +1730,24 @@ pair_fusion_bb_info::fuse_pair (bool load_p,
       input_uses[i] = remove_note_accesses (attempt, input_uses[i]);
     }
 
+  // Get the uses that the pair instruction would have, and punt if
+  // the unpaired instructions use different definitions of the same
+  // register.  That would normally be caught as a side-effect of
+  // hazard detection below, but this check also deals with cases
+  // in which one use is undefined and the other isn't.
+  auto new_uses = merge_access_arrays (attempt,
+				       drop_memory_access (input_uses[0]),
+				       drop_memory_access (input_uses[1]));
+  if (!new_uses.is_valid ())
+    {
+      if (dump_file)
+	fprintf (dump_file,
+		 "  load pair: i%d and i%d use different definiitions of"
+		 " the same register\n",
+		 insns[0]->uid (), insns[1]->uid ());
+      return false;
+    }
+
   // Edge case: if the first insn is a writeback load and the
   // second insn is a non-writeback load which transfers into the base
   // register, then we should drop the writeback altogether as the
@@ -1824,6 +1848,16 @@ pair_fusion_bb_info::fuse_pair (bool load_p,
     validate_change (rti, &REG_NOTES (rti), reg_notes, true);
   };
 
+  // Turn CHANGE into a memory definition tombstone.
+  auto make_tombstone = [&](insn_change *change)
+    {
+      tombstone_uids.quick_push (change->insn ()->uid ());
+      rtx_insn *rti = change->insn ()->rtl ();
+      validate_change (rti, &PATTERN (rti), gen_tombstone (), true);
+      validate_change (rti, &REG_NOTES (rti), NULL_RTX, true);
+      change->new_uses = use_array ();
+    };
+
   if (load_p)
     {
       changes.safe_push (make_delete (first));
@@ -1836,11 +1870,7 @@ pair_fusion_bb_info::fuse_pair (bool load_p,
 						   input_defs[1]);
       gcc_assert (pair_change->new_defs.is_valid ());
 
-      pair_change->new_uses
-	= merge_access_arrays (attempt,
-			       drop_memory_access (input_uses[0]),
-			       drop_memory_access (input_uses[1]));
-      gcc_assert (pair_change->new_uses.is_valid ());
+      pair_change->new_uses = new_uses;
       set_pair_pat (pair_change);
     }
   else
@@ -1861,9 +1891,7 @@ pair_fusion_bb_info::fuse_pair (bool load_p,
 	    case Action::CHANGE:
 	    {
 	      set_pair_pat (change);
-	      change->new_uses = merge_access_arrays (attempt,
-						      input_uses[0],
-						      input_uses[1]);
+	      change->new_uses = new_uses;
 	      auto d1 = drop_memory_access (input_defs[0]);
 	      auto d2 = drop_memory_access (input_defs[1]);
 	      change->new_defs = merge_access_arrays (attempt, d1, d2);
@@ -1879,11 +1907,7 @@ pair_fusion_bb_info::fuse_pair (bool load_p,
 	    }
 	    case Action::TOMBSTONE:
 	    {
-	      tombstone_uids.quick_push (change->insn ()->uid ());
-	      rtx_insn *rti = change->insn ()->rtl ();
-	      validate_change (rti, &PATTERN (rti), gen_tombstone (), true);
-	      validate_change (rti, &REG_NOTES (rti), NULL_RTX, true);
-	      change->new_uses = use_array (nullptr, 0);
+	      make_tombstone (change);
 	      break;
 	    }
 	    case Action::INSERT:
@@ -1895,9 +1919,7 @@ pair_fusion_bb_info::fuse_pair (bool load_p,
 	      auto new_insn = crtl->ssa->create_insn (attempt, INSN, pair_pat);
 	      change = make_change (new_insn);
 	      change->move_range = move_range;
-	      change->new_uses = merge_access_arrays (attempt,
-						      input_uses[0],
-						      input_uses[1]);
+	      change->new_uses = new_uses;
 	      gcc_assert (change->new_uses.is_valid ());
 
 	      auto d1 = drop_memory_access (input_defs[0]);
@@ -1934,7 +1956,17 @@ pair_fusion_bb_info::fuse_pair (bool load_p,
     }
 
   if (trailing_add)
-    changes.safe_push (make_delete (trailing_add));
+    {
+      if (auto *mem_def = memory_access (trailing_add->defs()))
+	{
+	  auto *change = make_change (trailing_add);
+	  change->new_defs = insert_access (attempt, mem_def, def_array ());
+	  make_tombstone (change);
+	  changes.safe_push (change);
+	}
+      else
+	changes.safe_push (make_delete (trailing_add));
+    }
   else if ((writeback & 2) && !writeback_effect)
     {
       // The second insn initially had writeback but now the pair does not,
@@ -1991,7 +2023,6 @@ pair_fusion_bb_info::fuse_pair (bool load_p,
   confirm_change_group ();
   crtl->ssa->change_insns (changes);
 
-  gcc_checking_assert (tombstone_uids.length () <= 2);
   for (auto uid : tombstone_uids)
     track_tombstone (uid);
 
diff --git a/gcc/params.opt b/gcc/params.opt
index b5e7800d7e49caeb1e7f906525e258497077d03d..4f4eb4d7a2a527d3687235753f740e8501be6be4 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -134,6 +134,14 @@ Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
 Common Joined UInteger Var(param_early_inlining_insns) Init(6) Optimization Param
 Maximal estimated growth of function body caused by early inlining of single call.
 
+-param=file-cache-files=
+Common Joined UInteger Var(param_file_cache_files) Init(16) Param
+Max number of files in the file cache.
+
+-param=file-cache-lines=
+Common Joined UInteger Var(param_file_cache_lines) Init(0) Param
+Max number of lines to index into file cache. When 0 this is automatically sized.
+
 -param=fsm-scale-path-stmts=
 Common Joined UInteger Var(param_fsm_scale_path_stmts) Init(2) IntegerRange(1, 10) Param Optimization
 Scale factor to apply to the number of statements in a threading path crossing a loop backedge when comparing to max-jump-thread-duplication-stmts.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f62e58c001126d506232dcd273a2ea2351ae4e64..7419562550eb8e8a79c1fdbc0f337a5b71ffe7e1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,769 @@
+2025-02-04  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/115112
+	* gm2/pim/run/pass/dectest.mod: New test.
+	* gm2/pim/run/pass/inctest.mod: New test.
+
+2025-02-04  Marek Polacek  <polacek@redhat.com>
+
+	PR c++/94100
+	* g++.dg/cpp0x/variadic188.C: New test.
+
+2025-02-04  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/118671
+	* g++.dg/cpp/embed-25.C: New test.
+	* g++.dg/cpp0x/pr118671.C: New test.
+
+2025-02-04  Dimitar Dimitrov  <dimitar@dinux.eu>
+
+	* gcc.target/riscv/pr118170.c: Ignore for E ABI.
+
+2025-02-04  Thiago Jung Bauermann  <thiago.bauermann@linaro.org>
+
+	PR target/116010
+	* gcc.target/arm/simd/mve-vabs.c: Test tree dump and adjust to new
+	code.
+
+2025-02-04  Marek Polacek  <polacek@redhat.com>
+
+	PR c++/117778
+	* g++.dg/cpp1y/lambda-generic-117778.C: New test.
+	* g++.dg/cpp2a/abbrev-fn2.C: New test.
+	* g++.dg/cpp2a/abbrev-fn3.C: New test.
+
+2025-02-04  Marek Polacek  <polacek@redhat.com>
+
+	PR c++/118718
+	* g++.dg/warn/Wvexing-parse10.C: New test.
+
+2025-02-04  kelefth  <konstantinos.eleftheriou@vrull.eu>
+
+	PR testsuite/116845
+	* gcc.dg/pr109393.c: XFAIL on ilp32 targets.
+
+2025-02-04  Richard Biener  <rguenther@suse.de>
+
+	PR c/118742
+	* gcc.dg/gimplefe-56.c: New testcase.
+
+2025-02-04  Ilya Leoshkevich  <iii@linux.ibm.com>
+
+	* gcc.target/s390/call-z10-pic-nodatarel.c: Adjust
+	expectations.
+	* gcc.target/s390/call-z10-pic.c: Likewise.
+	* gcc.target/s390/call-z10.c: Likewise.
+	* gcc.target/s390/call-z9-pic-nodatarel.c: Likewise.
+	* gcc.target/s390/call-z9-pic.c: Likewise.
+	* gcc.target/s390/call-z9.c: Likewise.
+
+2025-02-04  Simon Martin  <simon@nasilyan.com>
+	    Jason Merrill  <jason@redhat.com>
+
+	PR c++/117114
+	PR c++/109918
+	* g++.dg/warn/Woverloaded-virt1.C: Check that no warning is
+	emitted for non virtual base methods.
+	* g++.dg/warn/Woverloaded-virt10.C: New test.
+	* g++.dg/warn/Woverloaded-virt11.C: New test.
+	* g++.dg/warn/Woverloaded-virt12.C: New test.
+	* g++.dg/warn/Woverloaded-virt13.C: New test.
+	* g++.dg/warn/Woverloaded-virt5.C: New test.
+	* g++.dg/warn/Woverloaded-virt6.C: New test.
+	* g++.dg/warn/Woverloaded-virt7.C: New test.
+	* g++.dg/warn/Woverloaded-virt8.C: New test.
+	* g++.dg/warn/Woverloaded-virt9.C: New test.
+
+2025-02-04  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/117113
+	* gcc.dg/torture/pr117113.c: New testcase.
+
+2025-02-04  Simon Martin  <simon@nasilyan.com>
+
+	PR c++/114619
+	* g++.dg/init/no-elide4.C: New test.
+
+2025-02-04  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/118719
+	* g++.dg/cpp1z/decomp63.C: New test.
+
+2025-02-04  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+	* gfortran.dg/unsigned_15.f90: Adjust error messages.
+	* gfortran.dg/unsigned_43.f90: New test.
+	* gfortran.dg/unsigned_44.f90: New test.
+
+2025-02-04  Richard Biener  <rguenther@suse.de>
+
+	PR rtl-optimization/117611
+	* gcc.dg/fixed-point/pr117611.c: New testcase.
+
+2025-02-04  Richard Biener  <rguenther@suse.de>
+
+	PR lto/113207
+	* gcc.dg/pr113207.c: New testcase.
+
+2025-02-04  Nathaniel Shead  <nathanieloshead@gmail.com>
+
+	PR c++/108205
+	* g++.dg/modules/contracts-5_a.C: New test.
+	* g++.dg/modules/contracts-5_b.C: New test.
+
+2025-02-04  Nathaniel Shead  <nathanieloshead@gmail.com>
+
+	PR c++/98893
+	* g++.dg/modules/pr98893_a.H: New test.
+	* g++.dg/modules/pr98893_b.C: New test.
+
+2025-02-03  A J Ryan Solutions Ltd  <gcc.gnu.org@ajryansolutions.co.uk>
+
+	PR c++/118265
+	* g++.dg/cpp1z/variadic-nontype1.C: New file.
+
+2025-02-03  Iain Sandoe  <iains.gcc@gmail.com>
+	    Jason Merrill  <jason@redhat.com>
+
+	PR c++/116506
+	PR c++/116880
+	* g++.dg/coroutines/pr116506.C: New test.
+	* g++.dg/coroutines/pr116880.C: New test.
+
+2025-02-03  Jason Merrill  <jason@redhat.com>
+
+	PR c++/116914
+	PR c++/117231
+	PR c++/118470
+	PR c++/118491
+	* g++.dg/coroutines/coro-range-for1.C: New test.
+
+2025-02-03  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/93289
+	* gfortran.dg/unlimited_polymorphic_1.f03: Pad element in character
+	array constructor to correct length.
+	* gfortran.dg/char_array_constructor_5.f90: New test.
+
+2025-02-03  Richard Sandiford  <richard.sandiford@arm.com>
+
+	* gcc.target/aarch64/sve/acle/general/dupq_12.c: New test.
+
+2025-02-03  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/118717
+	* gcc.dg/torture/pr118717.c: New testcase.
+
+2025-02-02  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/117411
+	* gm2/iso/run/pass/except9.mod: New test.
+	* gm2/iso/run/pass/lazyunique.mod: New test.
+
+2025-02-02  Lewis Hyatt  <lhyatt@gmail.com>
+
+	PR middle-end/115913
+	* c-c++-common/cpp/pr115913.c: New test.
+
+2025-02-01  H.J. Lu  <hjl.tools@gmail.com>
+
+	PR rtl-optimization/111673
+	* gcc.target/i386/pr111673.c: New file.
+
+2025-02-01  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/118703
+	* gm2/builtins/run/pass/testbitfns.mod: New test.
+
+2025-02-01  H.J. Lu  <hjl.tools@gmail.com>
+
+	PR target/118713
+	* gcc.target/i386/pr118713-1-x32.c: New test.
+	* gcc.target/i386/pr118713-1.c: Likewise.
+	* gcc.target/i386/pr118713-2-x32.c: Likewise.
+	* gcc.target/i386/pr118713-2.c: Likewise.
+	* gcc.target/i386/pr118713-3-x32.c: Likewise.
+	* gcc.target/i386/pr118713-3.c: Likewise.
+	* gcc.target/i386/pr118713-4-x32.c: Likewise.
+	* gcc.target/i386/pr118713-4.c: Likewise.
+	* gcc.target/i386/pr118713-5-x32.c: Likewise.
+	* gcc.target/i386/pr118713-5.c: Likewise.
+	* gcc.target/i386/pr118713-6-x32.c: Likewise.
+	* gcc.target/i386/pr118713-6.c: Likewise.
+	* gcc.target/i386/pr118713-7-x32.c: Likewise.
+	* gcc.target/i386/pr118713-7.c: Likewise.
+	* gcc.target/i386/pr118713-8-x32.c: Likewise.
+	* gcc.target/i386/pr118713-8.c: Likewise.
+	* gcc.target/i386/pr118713-9-x32.c: Likewise.
+	* gcc.target/i386/pr118713-9.c: Likewise.
+	* gcc.target/i386/pr118713-10-x32.c: Likewise.
+	* gcc.target/i386/pr118713-10.c: Likewise.
+	* gcc.target/i386/pr118713-11-x32.c: Likewise.
+	* gcc.target/i386/pr118713-11.c: Likewise.
+	* gcc.target/i386/pr118713-12-x32.c: Likewise.
+	* gcc.target/i386/pr118713-12.c: Likewise.
+
+2025-02-01  David Malcolm  <dmalcolm@redhat.com>
+
+	* sarif-replay.dg/2.1.0-invalid/3.33.3-index-out-of-range.sarif:
+	New test.
+	* sarif-replay.dg/2.1.0-valid/spec-example-4.sarif: Update expected
+	output to reflect that we now find the function name for the
+	events in the path.
+
+2025-02-01  Eric Botcazou  <ebotcazou@adacore.com>
+
+	* gnat.dg/warn33.adb: New test.
+	* gnat.dg/warn33_pkg.ads: New helper.
+
+2025-02-01  H.J. Lu  <hjl.tools@gmail.com>
+
+	* gcc.target/i386/ssp-global.c: New file.
+
+2025-02-01  Jeff Law  <jlaw@ventanamicro.com>
+
+	PR tree-optimization/114277
+	* gcc.target/i386/pr114277.c: New test.
+	* gcc.target/riscv/pr114277.c: Likewise.
+	Co-author:  Andrew Pinski <quic_apinski@quicinc.com>
+
+2025-01-31  Jakub Jelinek  <jakub@redhat.com>
+
+	PR ipa/117432
+	* gcc.c-torture/execute/pr117432.c: New test.
+	* gcc.target/i386/pr117432.c: New test.
+
+2025-01-31  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/117516
+	* g++.dg/ext/flexary9.C: Expect different wording of one of the
+	warnings and at a different line.
+	* g++.dg/ext/flexary19.C: Likewise.
+	* g++.dg/ext/flexary42.C: New test.
+	* g++.dg/other/pr117516.C: New test.
+
+2025-01-31  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108454
+	* gfortran.dg/common_29.f90: New test.
+
+2025-01-31  Marek Polacek  <polacek@redhat.com>
+
+	PR c++/117501
+	* g++.dg/cpp2a/consteval39.C: New test.
+	* g++.dg/cpp2a/consteval40.C: New test.
+
+2025-01-31  Vladimir N. Makarov  <vmakarov@redhat.com>
+
+	PR rtl-optimization/116234
+	* gfortran.target/aarch64/aarch64.exp: New.
+	* gfortran.target/aarch64/pr116234.f: New.
+
+2025-01-31  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/117498
+	* gcc.c-torture/execute/pr117498.c: New test.
+
+2025-01-31  H.J. Lu  <hjl.tools@gmail.com>
+
+	PR target/115673
+	* gcc.target/i386/force-indirect-call-2.c: Allow indirect branch
+	via GOT.
+
+2025-01-31  Richard Biener  <rguenther@suse.de>
+
+	PR debug/100530
+	* gcc.target/i386/pr100530.c: New testcase.
+
+2025-01-30  Alexandre Oliva  <oliva@adacore.com>
+
+	PR target/113689
+	* gcc.target/i386/pr113689-1.c: Require profiling support.
+	* gcc.target/i386/pr113689-2.c: Likewise.
+	* gcc.target/i386/pr113689-3.c: Likewise.
+
+2025-01-30  Alexandre Oliva  <oliva@adacore.com>
+
+	* gcc.dg/vect/vect-ifcvt-18.c: Split -Ofast out of
+	avx_runtime.
+
+2025-01-30  Sandra Loosemore  <sloosemore@baylibre.com>
+	    Kwok Cheung Yeung  <kcy@codesourcery.com>
+	    Sandra Loosemore  <sandra@codesourcery.com>
+	    Tobias Burnus  <tobias@codesourcery.com>
+	    Paul-Antoine Arras  <pa@codesourcery.com>
+
+	PR middle-end/112779
+	PR middle-end/113904
+	* gfortran.dg/gomp/metadirective-1.f90: New.
+	* gfortran.dg/gomp/metadirective-10.f90: New.
+	* gfortran.dg/gomp/metadirective-11.f90: New.
+	* gfortran.dg/gomp/metadirective-12.f90: New.
+	* gfortran.dg/gomp/metadirective-13.f90: New.
+	* gfortran.dg/gomp/metadirective-2.f90: New.
+	* gfortran.dg/gomp/metadirective-3.f90: New.
+	* gfortran.dg/gomp/metadirective-4.f90: New.
+	* gfortran.dg/gomp/metadirective-5.f90: New.
+	* gfortran.dg/gomp/metadirective-6.f90: New.
+	* gfortran.dg/gomp/metadirective-7.f90: New.
+	* gfortran.dg/gomp/metadirective-8.f90: New.
+	* gfortran.dg/gomp/metadirective-9.f90: New.
+	* gfortran.dg/gomp/metadirective-construct.f90: New.
+	* gfortran.dg/gomp/metadirective-no-score.f90: New.
+	* gfortran.dg/gomp/pure-1.f90 (func_metadirective): New.
+	(func_metadirective_2): New.
+	(func_metadirective_3): New.
+	* gfortran.dg/gomp/pure-2.f90 (func_metadirective): Delete.
+
+2025-01-30  Jakub Jelinek  <jakub@redhat.com>
+	    Stefan Schulze Frielinghaus  <stefansf@gcc.gnu.org>
+
+	PR target/118696
+	* gcc.dg/pr118696.c: New test.
+	* gcc.target/s390/vector/pr118696.c: New test.
+	* gcc.target/s390/vector/vec-abs-emu.c: Expect vrepg with 0 as last
+	operand rather than 1.
+	* gcc.target/s390/vector/vec-max-emu.c: Likewise.
+	* gcc.target/s390/vector/vec-min-emu.c: Likewise.
+
+2025-01-30  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/118695
+	* gcc.dg/pr118695.c: New testcase.
+
+2025-01-30  Tobias Burnus  <tburnus@baylibre.com>
+
+	* c-c++-common/gomp/append-args-1.c: Update dg-*.
+	* c-c++-common/gomp/append-args-3.c: Likewise.
+	* g++.dg/gomp/append-args-1.C: Likewise.
+	* gfortran.dg/gomp/adjust-args-1.f90: Likewise.
+	* gfortran.dg/gomp/adjust-args-3.f90: Likewise.
+	* gfortran.dg/gomp/declare-variant-2.f90: Likewise.
+	* c-c++-common/gomp/append-args-6.c: New test.
+	* c-c++-common/gomp/append-args-7.c: New test.
+	* c-c++-common/gomp/append-args-8.c: New test.
+	* c-c++-common/gomp/append-args-9.c: New test.
+	* g++.dg/gomp/append-args-4.C: New test.
+	* g++.dg/gomp/append-args-5.C: New test.
+	* g++.dg/gomp/append-args-6.C: New test.
+	* g++.dg/gomp/append-args-7.C: New test.
+	* gcc.dg/gomp/append-args-1.c: New test.
+	* gfortran.dg/gomp/append_args-1.f90: New test.
+	* gfortran.dg/gomp/append_args-2.f90: New test.
+	* gfortran.dg/gomp/append_args-3.f90: New test.
+	* gfortran.dg/gomp/append_args-4.f90: New test.
+
+2025-01-30  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/118692
+	* gcc.dg/pr118692.c: New testcase.
+
+2025-01-30  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/114052
+	* gcc.dg/pr114052-1.c: New testcase.
+
+2025-01-30  Richard Sandiford  <richard.sandiford@arm.com>
+
+	PR rtl-optimization/118320
+	* g++.dg/torture/pr118320.C: New test.
+
+2025-01-30  Jeff Law  <jlaw@ventanamicro.com>
+
+	PR target/116860
+	* gcc.dg/tree-ssa/fold-xor-and-or.c: Set logical-op-non-short-circuit.
+	* gcc.dg/tree-ssa/fold-xor-or.c: Similarly.
+
+2025-01-29  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/118010
+	PR modula2/118183
+	PR modula2/116073
+	* gm2/pim/run/pass/printtypesize.mod: New test.
+
+2025-01-29  Richard Sandiford  <richard.sandiford@arm.com>
+
+	PR rtl-optimization/118429
+	* gcc.c-torture/compile/pr118429.c: New test.
+
+2025-01-29  Marek Polacek  <polacek@redhat.com>
+
+	PR c++/57533
+	* g++.dg/eh/throw5.C: New test.
+
+2025-01-29  Siddhesh Poyarekar  <siddhesh@gotplt.org>
+
+	PR testsuite/118127
+	* lib/target-supports.exp
+	(check_effective_target_long_double_is_ibm128): New
+	procedure.
+	* gfortran.dg/default_format_2.f90: xfail for
+	long_double_is_ibm128.
+	* gfortran.dg/default_format_denormal_2.f90: Likewise.
+	* gfortran.dg/large_real_kind_form_io_2.f90: Likewise.
+
+2025-01-29  Martin Jambor  <mjambor@suse.cz>
+	    Michal Jireš  <mjires@suse.cz>
+
+	PR tree-optimization/117892
+	* gcc.dg/tree-ssa/pr117892.c: New test.
+	* gcc.dg/tree-ssa/pr118517.c: Likewise.
+
+2025-01-29  Pan Li  <pan2.li@intel.com>
+
+	PR target/117688
+	* gcc.target/riscv/pr117688.h: Add test helper macros.
+	* gcc.target/riscv/pr117688-trunc-run-1-s16-to-s8.c: New test.
+	* gcc.target/riscv/pr117688-trunc-run-1-s32-to-s16.c: New test.
+	* gcc.target/riscv/pr117688-trunc-run-1-s32-to-s8.c: New test.
+	* gcc.target/riscv/pr117688-trunc-run-1-s64-to-s16.c: New test.
+	* gcc.target/riscv/pr117688-trunc-run-1-s64-to-s32.c: New test.
+	* gcc.target/riscv/pr117688-trunc-run-1-s64-to-s8.c: New test.
+
+2025-01-29  Pan Li  <pan2.li@intel.com>
+
+	PR target/117688
+	* gcc.target/riscv/pr117688.h: Add test helper macro.
+	* gcc.target/riscv/pr117688-sub-run-1-s16.c: New test.
+	* gcc.target/riscv/pr117688-sub-run-1-s32.c: New test.
+	* gcc.target/riscv/pr117688-sub-run-1-s64.c: New test.
+	* gcc.target/riscv/pr117688-sub-run-1-s8.c: New test.
+
+2025-01-29  Pan Li  <pan2.li@intel.com>
+
+	PR target/117688
+	* gcc.target/riscv/pr117688-add-run-1-s16.c: New test.
+	* gcc.target/riscv/pr117688-add-run-1-s32.c: New test.
+	* gcc.target/riscv/pr117688-add-run-1-s64.c: New test.
+	* gcc.target/riscv/pr117688-add-run-1-s8.c: New test.
+	* gcc.target/riscv/pr117688.h: New test.
+
+2025-01-29  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/118684
+	* gcc.dg/pr118684.c: Require automatic_stack_alignment.
+
+2025-01-29  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/118655
+	* g++.dg/ext/is_bounded_array.C: Extend.
+
+2025-01-28  Jason Merrill  <jason@redhat.com>
+
+	PR c++/118285
+	* g++.dg/cpp0x/initlist-opt7.C: New test.
+
+2025-01-28  Jason Merrill  <jason@redhat.com>
+
+	PR c++/118673
+	* g++.dg/cpp0x/initlist-opt6.C: New test.
+
+2025-01-28  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/118684
+	* gcc.dg/pr118684.c: New testcase.
+
+2025-01-28  David Malcolm  <dmalcolm@redhat.com>
+
+	PR other/118675
+	* gcc.dg/sarif-output/bad-binary-op.py: Update expected output for
+	escaping of braces in message text.
+	* gcc.dg/sarif-output/missing-semicolon.py: Likewise.
+	* gcc.dg/sarif-output/multiple-outputs.py: Likewise.
+
+2025-01-28  Patrick Palka  <ppalka@redhat.com>
+
+	PR c++/117855
+	* g++.dg/cpp23/class-deduction-inherited7.C: New test.
+
+2025-01-28  Vladimir N. Makarov  <vmakarov@redhat.com>
+
+	PR target/118663
+	* gcc.target/powerpc/pr118663.c: New.
+
+2025-01-28  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/117424
+	* gcc.dg/tree-ssa/ssa-lim-25.c: New testcase.
+
+2025-01-28  Thomas Schwinge  <tschwinge@baylibre.com>
+
+	* c-c++-common/gomp/defaultmap-4.c: Adjust.
+	* c-c++-common/gomp/defaultmap-5.c: Likewise.
+	* c-c++-common/gomp/target-implicit-map-1.c: Likewise.
+	* c-c++-common/gomp/target-implicit-map-2.c: Likewise.
+	* gfortran.dg/gomp/defaultmap-8.f90: Likewise.
+	* gfortran.dg/gomp/defaultmap-9.f90: Likewise.
+	* gfortran.dg/gomp/map-subarray.f90: Likewise.
+	* gfortran.dg/gomp/target-enter-exit-data.f90: Likewise.
+
+2025-01-28  Jakub Jelinek  <jakub@redhat.com>
+
+	PR rtl-optimization/118638
+	* gcc.c-torture/execute/pr118638.c: New test.
+
+2025-01-28  Hafiz Abid Qadeer  <abidh@codesourcery.com>
+
+	* c-c++-common/goacc/implied-copy-1.c: New test.
+	* c-c++-common/goacc/implied-copy-2.c: New test.
+	* g++.dg/goacc/implied-copy.C: New test.
+	* gcc.dg/goacc/implied-copy.c: New test.
+	* gfortran.dg/goacc/implied-copy-1.f90: New test.
+	* gfortran.dg/goacc/implied-copy-2.f90: New test.
+
+2025-01-28  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/116357
+	* gcc.dg/pr116357.c: New test.
+
+2025-01-27  Jason Merrill  <jason@redhat.com>
+
+	PR c++/118632
+	* g++.dg/cpp0x/nontype7.C: New test.
+
+2025-01-27  Vineet Gupta  <vineetg@rivosinc.com>
+
+	PR target/118646
+	* gfortran.target/riscv/rvv/pr118646.f90 (New Test).
+
+2025-01-27  Simon Martin  <simon@nasilyan.com>
+
+	PR c++/114292
+	* g++.dg/cpp1y/lambda-ice4.C: New test.
+
+2025-01-27  Robin Dapp  <rdapp@ventanamicro.com>
+
+	* gcc.target/riscv/rvv/autovec/reduc/reduc-8.c: Remove
+	VEC_SHL_INSERT check.
+	* gcc.target/riscv/rvv/autovec/reduc/reduc-9.c: Ditto.
+
+2025-01-27  Robin Dapp  <rdapp@ventanamicro.com>
+
+	* gcc.target/riscv/rvv/autovec/gather-scatter/gather_load_64-12-zvbb.c:
+	Distinguish between zvfh and !zvfh.
+
+2025-01-27  Robin Dapp  <rdapp@ventanamicro.com>
+
+	PR target/117173
+	* gcc.dg/fold-perm-2.c: Run with two-source permutes.
+	* gcc.dg/pr54346.c: Ditto.
+
+2025-01-27  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/110993
+	* gfortran.dg/use_rename_14.f90: New test.
+
+2025-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/115769
+	* g++.dg/modules/dr2867-1_a.H: New test.
+	* g++.dg/modules/dr2867-1_b.C: New test.
+	* g++.dg/modules/dr2867-2_a.H: New test.
+	* g++.dg/modules/dr2867-2_b.C: New test.
+	* g++.dg/modules/dr2867-3_a.H: New test.
+	* g++.dg/modules/dr2867-3_b.C: New test.
+	* g++.dg/modules/dr2867-4_a.H: New test.
+	* g++.dg/modules/dr2867-4_b.C: New test.
+	* g++.dg/modules/dr2867-1_a.H.jj1: New file.
+	* g++.dg/modules/dr2867-1_b.C.jj1: New file.
+	* g++.dg/modules/dr2867-2_a.H.jj1: New file.
+	* g++.dg/modules/dr2867-2_b.C.jj1: New file.
+	* g++.dg/modules/dr2867-3_a.H.jj1: New file.
+	* g++.dg/modules/dr2867-3_b.C.jj1: New file.
+	* g++.dg/modules/dr2867-4_a.H.jj1: New file.
+	* g++.dg/modules/dr2867-4_b.C.jj1: New file.
+
+2025-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/115769
+	* g++.dg/DRs/dr2867-5.C: New test.
+	* g++.dg/DRs/dr2867-6.C: New test.
+	* g++.dg/DRs/dr2867-7.C: New test.
+	* g++.dg/DRs/dr2867-8.C: New test.
+
+2025-01-27  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/118653
+	* gcc.dg/vect/pr118653.c: New testcase.
+
+2025-01-27  Richard Biener  <rguenther@suse.de>
+
+	PR rtl-optimization/118662
+	* gcc.dg/torture/pr118662.c: New testcase.
+
+2025-01-27  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/118643
+	* gcc.dg/pr118643.c: New testcase.
+
+2025-01-27  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/112859
+	PR tree-optimization/115347
+	* gcc.dg/torture/pr112859.c: New testcase.
+	* gcc.dg/torture/pr115347.c: Likewise.
+
+2025-01-27  Paul Thomas  <pault@gcc.gnu.org>
+
+	PR fortran/118640
+	* gfortran.dg/pr118640.f90: New test.
+
+2025-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/118637
+	* gcc.dg/tree-ssa/pr118637.c: New test.
+
+2025-01-27  Soumya AR  <soumyaa@nvidia.com>
+
+	PR target/118490
+	* gcc.dg/pr118490.c: New test.
+	* gcc.dg/pr: New file.
+
+2025-01-26  Sandra Loosemore  <sloosemore@baylibre.com>
+
+	* gfortran.dg/gomp/atomic-26.f90: Correct expected output after
+	fixing typo in error message.
+
+2025-01-26  Pan Li  <pan2.li@intel.com>
+
+	PR target/118103
+	* gcc.target/riscv/rvv/base/pr118103-1.c: New test.
+	* gcc.target/riscv/rvv/base/pr118103-run-1.c: New test.
+
+2025-01-25  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/58857
+	* gfortran.dg/uncommon_block_data_2.f90: New test.
+
+2025-01-25  Simon Martin  <simon@nasilyan.com>
+
+	PR c++/118239
+	* g++.dg/cpp0x/constexpr-base8.C: New test.
+
+2025-01-25  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/118639
+	* c-c++-common/gomp/pr118639.c: New test.
+	* c-c++-common/goacc/cache-2.c: Remove one xfail for c.
+
+2025-01-25  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/117827
+	* g++.dg/init/array66.C: New test.
+
+2025-01-25  Nathaniel Shead  <nathanieloshead@gmail.com>
+
+	PR c++/116568
+	* g++.dg/modules/lambda-8.h: New test.
+	* g++.dg/modules/lambda-8_a.H: New test.
+	* g++.dg/modules/lambda-8_b.C: New test.
+
+2025-01-25  Nathaniel Shead  <nathanieloshead@gmail.com>
+
+	PR c++/116568
+	* g++.dg/modules/internal-4_b.C: Remove XFAIL, add lambda alias
+	testcase.
+	* g++.dg/modules/lambda-9.h: New test.
+	* g++.dg/modules/lambda-9_a.H: New test.
+	* g++.dg/modules/lambda-9_b.C: New test.
+
+2025-01-25  Nathaniel Shead  <nathanieloshead@gmail.com>
+
+	PR c++/118245
+	* g++.dg/abi/lambda-ctx3.C: New test.
+	* g++.dg/cpp2a/lambda-uneval22.C: New test.
+	* g++.dg/cpp2a/lambda-uneval23.C: New test.
+
+2025-01-25  Gaius Mulley  <gaiusmod2@gmail.com>
+
+	PR modula2/118589
+	* lib/gm2-dg.exp (gm2.exp): load_lib.
+	* gm2.dg/pim/fail/badopaque.mod: New test.
+	* gm2.dg/pim/fail/badopaque2.mod: New test.
+	* gm2.dg/pim/fail/dg-pim-fail.exp: New test.
+	* gm2.dg/pim/fail/opaquedefs.def: New test.
+	* gm2.dg/pim/fail/opaquedefs.mod: New test.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* gcc.target/aarch64/simd/armv9p5.c: New test.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* gcc.target/aarch64/crypto-alias-1.c: New test.
+
+2025-01-24  Andrew Carlotti  <andrew.carlotti@arm.com>
+
+	* gcc.target/aarch64/target_attr_crypto_ice_1.c: Prune warning.
+	* gcc.target/aarch64/target_attr_crypto_ice_2.c: Ditto.
+
+2025-01-24  Vladimir N. Makarov  <vmakarov@redhat.com>
+
+	PR target/118497
+	* gcc.target/i386/pr118497.c: New.
+	* gcc.target/i386/vartrack-1.c: Modify the regexp.
+
+2025-01-24  Marek Polacek  <polacek@redhat.com>
+
+	PR c++/117153
+	* g++.dg/other/anon-union6.C: New test.
+	* g++.dg/other/anon-union7.C: New test.
+
+2025-01-24  Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
+
+	* gcc.target/arm/thumb-bitfld1.c: Use -std=c17.
+
+2025-01-24  Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
+
+	PR testsuite/116448
+	* gcc.target/arm/vfp-1.c: Use -Os -fno-math-errno.
+
+2025-01-24  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+	PR libfortran/118571
+	* gfortran.dg/utf8_3.f03: New test.
+
+2025-01-24  yxj-github-437  <2457369732@qq.com>
+
+	* g++.dg/modules/builtin-8.C: New test.
+
+2025-01-24  David Malcolm  <dmalcolm@redhat.com>
+
+	PR jit/117886
+	* jit.dg/all-non-failing-tests.h: Add
+	test-pr117886-write-reproducer.c.
+	* jit.dg/test-pr117886-write-reproducer.c: New test.
+
+2025-01-24  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/116010
+	* gfortran.dg/vect/vect-8.f90: Adjust.
+
+2025-01-24  Stefan Schulze Frielinghaus  <stefansf@gcc.gnu.org>
+
+	* gcc.target/s390/isfinite-isinf-isnormal-signbit-1.c: New test.
+	* gcc.target/s390/isfinite-isinf-isnormal-signbit-2.c: New test.
+	* gcc.target/s390/isfinite-isinf-isnormal-signbit-3.c: New test.
+	* gcc.target/s390/isfinite-isinf-isnormal-signbit.h: New test.
+
+2025-01-24  Saurabh Jha  <saurabh.jha@arm.com>
+
+	* gcc.target/aarch64/sve/faminmax_1.c: Fix test to use the
+	correct flags.
+	* gcc.target/aarch64/sve/faminmax_2.c: Fix test to use the
+	correct flags.
+	* gcc.target/aarch64/sve/faminmax_3.c: New test.
+
+2025-01-24  Alexandre Oliva  <oliva@adacore.com>
+
+	PR tree-optimization/118572
+	* gcc.dg/field-merge-24.c: New.
+
+2025-01-24  Alexandre Oliva  <oliva@adacore.com>
+
+	PR tree-optimization/118514
+	* gcc.dg/field-merge-23.c: New.
+
 2025-01-23  Marek Polacek  <polacek@redhat.com>
 
 	PR c++/117602
diff --git a/gcc/testsuite/c-c++-common/cpp/pr115913.c b/gcc/testsuite/c-c++-common/cpp/pr115913.c
new file mode 100644
index 0000000000000000000000000000000000000000..b9d10cda8d2485d740a3ba4b3d052b5d0831a4fb
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/pr115913.c
@@ -0,0 +1,7 @@
+/* { dg-do preprocess } */
+/* PR middle-end/115913 */
+#pragma GCC push_options
+#pragma GCC diagnostic warning "-Wundef"
+/* The call to cl_optimization_compare performed by pop_options should not
+   lead to a checking failure.  */
+#pragma GCC pop_options
diff --git a/gcc/testsuite/c-c++-common/goacc/cache-2.c b/gcc/testsuite/c-c++-common/goacc/cache-2.c
index 80b925e5112553eba9a3f5fa08309cb54d5ebaa7..085091d2cd2f37df8cf0a403ad0201bfb36f003e 100644
--- a/gcc/testsuite/c-c++-common/goacc/cache-2.c
+++ b/gcc/testsuite/c-c++-common/goacc/cache-2.c
@@ -33,7 +33,7 @@ test ()
 #pragma acc cache () /* { dg-error "expected (identifier|unqualified-id) before '\\\)' token" } */
 #pragma acc cache (,) /* { dg-error "expected (identifier|unqualified-id) before '(,|\\\))' token" } */
 #pragma acc cache (a[0:N] /* { dg-error "expected '\\\)' before end of line" } */
-#pragma acc cache (a[0:N],) /* { dg-error "expected (identifier|unqualified-id) before '(,|\\\))' token" "" { xfail c } } */
+#pragma acc cache (a[0:N],) /* { dg-error "expected (identifier|unqualified-id) before '(,|\\\))' token" } */
 #pragma acc cache (a[0:N]) copyin (a[0:N]) /* { dg-error "expected end of line before 'copyin'" } */
 #pragma acc cache () /* { dg-error "expected (identifier|unqualified-id) before '\\\)' token" } */
 #pragma acc cache (a[0:N] b[0:N]) /* { dg-error "expected '\\\)' before 'b'" } */
diff --git a/gcc/testsuite/c-c++-common/goacc/implied-copy-1.c b/gcc/testsuite/c-c++-common/goacc/implied-copy-1.c
new file mode 100644
index 0000000000000000000000000000000000000000..ae06339dc2d88c3f8cff6c43f595a560d7f10ce3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/implied-copy-1.c
@@ -0,0 +1,33 @@
+/* { dg-additional-options "-fdump-tree-gimple" } */
+
+/* Test for implied copy of reduction variable on combined construct.  */
+void test1 (void)
+{
+  int i, sum = 0, prod = 1, a[100];
+
+  #pragma acc kernels loop reduction(+:sum) reduction(*:prod)
+  for (int i = 0; i < 10; ++i)
+  {
+    sum += a[i];
+    prod *= a[i];
+  }
+
+  #pragma acc parallel loop reduction(+:sum) reduction(*:prod)
+  for (int i = 0; i < 10; ++i)
+  {
+    sum += a[i];
+    prod *= a[i];
+  }
+
+  #pragma acc serial loop reduction(+:sum) reduction(*:prod)
+  for (int i = 0; i < 10; ++i)
+  {
+    sum += a[i];
+    prod *= a[i];
+  }
+}
+
+/* { dg-final { scan-tree-dump-times "map\\(force_tofrom:sum \\\[len: \[0-9\]+\\\]\\)" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "map\\(force_tofrom:prod \\\[len: \[0-9\]+\\\]\\)" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "map\\(tofrom:sum \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "map\\(tofrom:prod \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/implied-copy-2.c b/gcc/testsuite/c-c++-common/goacc/implied-copy-2.c
new file mode 100644
index 0000000000000000000000000000000000000000..9f5e2dce79cd54ed3e305d0c5d9c3caa4ba7bdaf
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/implied-copy-2.c
@@ -0,0 +1,121 @@
+/* { dg-additional-options "-fdump-tree-gimple" } */
+
+/* Test that reduction on compute construct implies a copy of the reduction
+  variable .  */
+
+#define n 1000
+
+#if __cplusplus
+  typedef bool BOOL;
+#else
+  typedef _Bool BOOL;
+#endif
+
+int
+main(void)
+{
+  int i;
+  int sum = 0;
+  int prod = 1;
+  int result = 0;
+  int tmp = 1;
+  int array[n];
+
+  double sumd = 0.0;
+  double arrayd[n];
+
+  float sumf = 0.0;
+  float arrayf[n];
+
+  char sumc;
+  char arrayc[n];
+
+  BOOL lres;
+
+#pragma acc parallel reduction(+:sum, sumf, sumd, sumc) reduction(*:prod)
+  for (i = 0; i < n; i++)
+    {
+      sum += array[i];
+      sumf += arrayf[i];
+      sumd += arrayd[i];
+      sumc += arrayc[i];
+      prod *= array[i];
+    }
+
+#pragma acc parallel reduction (max:result)
+  for (i = 0; i < n; i++)
+    result = result > array[i] ? result : array[i];
+
+#pragma acc parallel reduction (min:result)
+  for (i = 0; i < n; i++)
+    result = result < array[i] ? result : array[i];
+
+#pragma acc parallel reduction (&:result)
+  for (i = 0; i < n; i++)
+    result &= array[i];
+
+#pragma acc parallel reduction (|:result)
+  for (i = 0; i < n; i++)
+    result |= array[i];
+
+#pragma acc parallel reduction (^:result)
+  for (i = 0; i < n; i++)
+    result ^= array[i];
+
+#pragma acc parallel reduction (&&:lres) copy(tmp)
+  for (i = 0; i < n; i++)
+    lres = lres && (tmp > array[i]);
+
+#pragma acc parallel reduction (||:lres) copy(tmp)
+  for (i = 0; i < n; i++)
+    lres = lres || (tmp > array[i]);
+
+  /* Same checks on serial construct.  */
+#pragma acc serial reduction(+:sum, sumf, sumd, sumc) reduction(*:prod)
+  for (i = 0; i < n; i++)
+    {
+      sum += array[i];
+      sumf += arrayf[i];
+      sumd += arrayd[i];
+      sumc += arrayc[i];
+      prod *= array[i];
+    }
+
+#pragma acc serial reduction (max:result)
+  for (i = 0; i < n; i++)
+    result = result > array[i] ? result : array[i];
+
+#pragma acc serial reduction (min:result)
+  for (i = 0; i < n; i++)
+    result = result < array[i] ? result : array[i];
+
+#pragma acc serial reduction (&:result)
+  for (i = 0; i < n; i++)
+    result &= array[i];
+
+#pragma acc serial reduction (|:result)
+  for (i = 0; i < n; i++)
+    result |= array[i];
+
+#pragma acc serial reduction (^:result)
+  for (i = 0; i < n; i++)
+    result ^= array[i];
+
+#pragma acc serial reduction (&&:lres) copy(tmp)
+  for (i = 0; i < n; i++)
+    lres = lres && (tmp > array[i]);
+
+#pragma acc serial reduction (||:lres) copy(tmp)
+  for (i = 0; i < n; i++)
+    lres = lres || (tmp > array[i]);
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "map\\(tofrom:sum \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "map\\(tofrom:sumf \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "map\\(tofrom:sumd \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "map\\(tofrom:sumc \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "map\\(tofrom:lres \\\[len: \[0-9\]+\\\]\\)" 4 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "map\\(tofrom:result \\\[len: \[0-9\]+\\\]\\)" 10 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "map\\(tofrom:prod \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/append-args-1.c b/gcc/testsuite/c-c++-common/gomp/append-args-1.c
index 5bfd50d775d3bf9b9a3daf3fa5d6419e9d6f505d..2a4706362c43dbcdab17e3fda45c1f3c79878670 100644
--- a/gcc/testsuite/c-c++-common/gomp/append-args-1.c
+++ b/gcc/testsuite/c-c++-common/gomp/append-args-1.c
@@ -23,34 +23,50 @@ float base0();
 float repl1(omp_interop_t, omp_interop_t);
 #pragma omp declare variant(repl1) match(construct={dispatch}) append_args(interop(target), interop(targetsync))
 float base1();
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'repl1'" "" { target c } .-2 }  */
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'float repl1\\(omp_interop_t, omp_interop_t\\)'" "" { target c++ } .-3 }  */
+/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'repl1', except when specifying all 2 objects in the 'interop' clause of the 'dispatch' directive" "" { target c } .-2 }  */
+/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'float repl1\\(omp_interop_t, omp_interop_t\\)', except when specifying all 2 objects in the 'interop' clause of the 'dispatch' directive" "" { target c++ } .-3 }  */
 
 void repl2(int *, int *, omp_interop_t, omp_interop_t);
 #pragma omp declare variant(repl2) match(construct={dispatch}) adjust_args(need_device_ptr : y) \
         append_args(interop(target, targetsync, prefer_type(1)), \
                     interop(prefer_type({fr(3), attr("ompx_nop")},{fr(2)},{attr("ompx_all")})))
 void base2(int *x, int *y);
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'repl2'" "" { target c } .-3 }  */
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'void repl2\\(int\\*, int\\*, omp_interop_t, omp_interop_t\\)'" "" { target c++ } .-4 }  */
+/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'repl2', except when specifying all 2 objects in the 'interop' clause of the 'dispatch' directive" "" { target c } .-3 }  */
+/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'void repl2\\(int\\*, int\\*, omp_interop_t, omp_interop_t\\)', except when specifying all 2 objects in the 'interop' clause of the 'dispatch' directive" "" { target c++ } .-4 }  */
 
 void repl3(int, omp_interop_t, ...);
 #pragma omp declare variant(repl3) match(construct={dispatch}) \
         append_args(interop(prefer_type("cuda", "hsa")))
 void base3(int, ...);
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'repl3'" "" { target c } .-2 }  */
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'void repl3\\(int, omp_interop_t, \\.\\.\\.\\)'" "" { target c++ } .-3 }  */
+/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'repl3', except when specifying all 1 objects in the 'interop' clause of the 'dispatch' directive" "" { target c } .-2 }  */
+/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'void repl3\\(int, omp_interop_t, \\.\\.\\.\\)', except when specifying all 1 objects in the 'interop' clause of the 'dispatch' directive" "" { target c++ } .-3 }  */
 /* { dg-note "'declare variant' candidate 'repl3' declared here" "" { target c } .-4 } */
 /* { dg-note "'declare variant' candidate 'void repl3\\(int, omp_interop_t, \\.\\.\\.\\)' declared here" "" { target c++ } .-5 } */
 
 float repl4(short, short, omp_interop_t, short);
 #pragma omp declare variant(repl4) match(construct={dispatch}) append_args(interop(target)) append_args(interop(targetsync))  /* { dg-error "too many 'append_args' clauses" } */
 float base4(short, short);
-/* { dg-error "argument 4 of 'repl4' must be of 'omp_interop_t'" "" { target c } .-3 }  */
-/* { dg-error "argument 4 of 'float repl4\\(short int, short int, omp_interop_t, short int\\)' must be of 'omp_interop_t'" "" { target c++ } .-4 }  */
+/* { dg-error "variant 'repl4' and base 'base4' have incompatible types" "" { target c } .-2 }  */
+/* { dg-error "too few arguments to function 'float repl4\\(short int, short int, omp_interop_t, short int\\)'" "" { target c++ } .-3 }  */
+/* { dg-note "declared here" "" { target c++ } .-5 } */
+
+
+float repl5(short, short, omp_interop_t, short);
+#pragma omp declare variant(repl5) match(construct={dispatch}) append_args(interop(target),interop(targetsync))
+float base5(short, short);
+/* { dg-error "argument 4 of 'repl5' must be of 'omp_interop_t'" "" { target c } .-3 }  */
+/* { dg-error "argument 4 of 'float repl5\\(short int, short int, omp_interop_t, short int\\)' must be of 'omp_interop_t'" "" { target c++ } .-4 }  */
 /* { dg-note "'append_args' specified here" "" { target *-*-* } .-4 } */
 
 
+float repl6(short, short, omp_interop_t, short);
+#pragma omp declare variant(repl6) match(construct={dispatch}) append_args(interop(target))
+float base6(short, short);
+/* { dg-error "variant 'repl6' and base 'base6' have incompatible types" "" { target c } .-2 }  */
+/* { dg-error "too few arguments to function 'float repl6\\(short int, short int, omp_interop_t, short int\\)'" "" { target c++ } .-3 }  */
+/* { dg-note "declared here" "" { target c++ } .-5 } */
+
+
 float
 test (int *a, int *b)
 {
diff --git a/gcc/testsuite/c-c++-common/gomp/append-args-3.c b/gcc/testsuite/c-c++-common/gomp/append-args-3.c
index 7e08a2df9bb2782bbd1070e3866b405ebdb5e767..eaa42c4738d95fa0ccca37e806beb3cbf40fbebc 100644
--- a/gcc/testsuite/c-c++-common/gomp/append-args-3.c
+++ b/gcc/testsuite/c-c++-common/gomp/append-args-3.c
@@ -52,9 +52,9 @@ void varvar1(int, int, omp_interop_t, ...);
 #pragma omp declare variant(varvar1) match(construct={dispatch}) append_args(interop(target,targetsync))
 void varbase1(int x, int y, ...);
 
-void varvar2(int, int *, omp_interop_t, ...);
+void varvar2(int, int *, omp_interop_t, ...) { }
 #pragma omp declare variant(varvar2) match(construct={dispatch}) append_args(interop(target,targetsync)) adjust_args(need_device_ptr: y)
-void varbase2(int x, int *y, ...);
+void varbase2(int x, int *y, ...) { }
 
 
 void bar()
diff --git a/gcc/testsuite/c-c++-common/gomp/append-args-6.c b/gcc/testsuite/c-c++-common/gomp/append-args-6.c
new file mode 100644
index 0000000000000000000000000000000000000000..d96e5a1e268422838d04c1d77b7ceb0e608f2491
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/append-args-6.c
@@ -0,0 +1,106 @@
+/* { dg-additional-options "-fdump-tree-gimple" }  */
+
+#if __cplusplus >= 201103L
+# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__
+#else
+# define __GOMP_UINTPTR_T_ENUM
+#endif
+
+typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM
+{
+  omp_interop_none = 0,
+  __omp_interop_t_max__ = __UINTPTR_MAX__
+} omp_interop_t;
+
+typedef enum omp_interop_fr_t
+{
+  omp_ifr_cuda = 1,
+  omp_ifr_cuda_driver = 2,
+  omp_ifr_opencl = 3,
+  omp_ifr_sycl = 4,
+  omp_ifr_hip = 5,
+  omp_ifr_level_zero = 6,
+  omp_ifr_hsa = 7,
+  omp_ifr_last = omp_ifr_hsa
+} omp_interop_fr_t;
+
+
+
+void g(int, const char *, int *, int *, omp_interop_t, omp_interop_t) { }
+#pragma omp declare variant(g) match(construct={dispatch}) \
+   append_args(interop(target,prefer_type( {fr("cuda") }, {fr(omp_ifr_hsa)} , {attr("ompx_a") } , {fr(omp_ifr_hip) }), targetsync), \
+               interop(targetsync, prefer_type("cuda", "hsa"))) adjust_args(need_device_ptr : y, k)
+void f(int x, const char *y, int *, int *k) { }
+
+
+void gvar(int, const char *, int *, int *, omp_interop_t, omp_interop_t, ...) { }
+#pragma omp declare variant(gvar) match(construct={dispatch}) \
+   append_args(interop(target,prefer_type( {fr("cuda") }, {fr(omp_ifr_hsa)} , {attr("ompx_a") } , {fr(omp_ifr_hip) }), targetsync), \
+               interop(targetsync, prefer_type("cuda", "hsa"))) adjust_args(need_device_ptr : y, k)
+void fvar(int x, const char *y, int *, int *k, ...) { }
+
+
+
+void foo(const char *cp1, const char *cp2, int *a, int *b, int *c)
+{
+  omp_interop_t obj1, obj2, obj3, obj4;
+  obj1 = obj2 = obj3 = obj4 = omp_interop_none;
+
+  #pragma omp dispatch device(5) interop(obj1,obj2) is_device_ptr(cp1)
+     f(3, cp1, a, b);
+
+  #pragma omp dispatch device(4) interop(obj3,obj4) is_device_ptr(a,b,c)
+     fvar(99, cp2, a, b, c, a, b, c, a, b, c);
+}
+
+
+
+
+int *fi();
+
+struct t {
+  int *a, *b;
+};
+
+void fancy(int *x, int *y, omp_interop_t)  { }
+
+#pragma omp declare variant(fancy) match(construct={dispatch}) adjust_args(need_device_ptr: x,y) \
+                    append_args( interop (prefer_type(omp_ifr_hip), target) )
+void bar(int *x, int *y);
+
+void sub(struct t *s, void *y, const omp_interop_t obj5, omp_interop_t obj6)
+{
+ bar( fi(), s->b);
+
+ // This is a bit questionable as dereferencing 's' as device pointer might not work (unspecified behavior);
+ // but if for 's->b' it would still be need even if 's' was a device + host accessible pointer.
+ #pragma omp dispatch device(3) is_device_ptr(s) interop(obj5)
+    bar( fi(), s->b);
+
+ bar( (int *) y, s->b);
+ #pragma omp dispatch interop(obj6) is_device_ptr(y)
+    bar( (int *) y, s->b);
+}
+
+
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_default_device \\(\\);" 4 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_interop_int \\(obj6, -5, 0B\\);" 1 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(5\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(4\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(3\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(D\.\[0-9\]+\\);" 5 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(b, 5\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(cp2, 4\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(cp2, 4\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(cp2, 4\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(D\.\[0-9\]+, 3\\);" 2 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(D\.\[0-9\]+, D\.\[0-9\]+\\);" 1 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "g \\(3, cp1, a, D\.\[0-9\]+, obj1, obj2\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "gvar \\(99, D\.\[0-9\]+, a, b, obj3, obj4, c, a, b, c, a, b, c\\);" 1 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "fancy \\(D\.\[0-9\]+, D\.\[0-9\]+, obj5\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "fancy \\(y, D\.\[0-9\]+, obj6\\);" 1 "gimple" } }  */
diff --git a/gcc/testsuite/c-c++-common/gomp/append-args-7.c b/gcc/testsuite/c-c++-common/gomp/append-args-7.c
new file mode 100644
index 0000000000000000000000000000000000000000..b7dff8a2cb0789910dc524b371fa72fb1c5c3810
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/append-args-7.c
@@ -0,0 +1,47 @@
+/* { dg-additional-options "-fdump-tree-gimple" }  */
+
+#if __cplusplus >= 201103L
+# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__
+#else
+# define __GOMP_UINTPTR_T_ENUM
+#endif
+
+typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM
+{
+  omp_interop_none = 0,
+  __omp_interop_t_max__ = __UINTPTR_MAX__
+} omp_interop_t;
+
+void f1(...) { }
+#pragma omp declare variant(f1) match(construct={dispatch})
+void g1(...) { }
+
+
+void f2(...) { }
+/* { dg-error "argument 1 of 'f2' must be of 'omp_interop_t'" "" { target c } .-1 }  */
+/* { dg-error "argument 1 of 'void f2\\(\\.\\.\\.\\)' must be of 'omp_interop_t'" "" { target c++ } .-2 }  */
+#pragma omp declare variant(f2) append_args(interop(target), interop(prefer_type("cuda"))) \
+                                match(construct={dispatch})
+void g2(...) { }
+/* { dg-note "'append_args' specified here" "" { target *-*-* } .-3 }  */
+
+
+void f3(omp_interop_t, omp_interop_t, ...) { }
+#pragma omp declare variant(f3) append_args(interop(target), interop(prefer_type("cuda"))) \
+                                match(construct={dispatch})
+void g3(...) { }
+
+
+void foo (int *a, char *cp, int d) {
+  omp_interop_t obj1 = omp_interop_none;
+  omp_interop_t obj2 = omp_interop_none;
+  #pragma omp dispatch interop(obj1, obj2) device(22)
+    g3(1, a, cp, d);
+}
+
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_default_device \\(\\);" 1 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(22\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(D\.\[0-9\]+\\);" 1 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "f3 \\(obj1, obj2, 1, a, cp, d\\);" 1 "gimple" } }  */
diff --git a/gcc/testsuite/c-c++-common/gomp/append-args-8.c b/gcc/testsuite/c-c++-common/gomp/append-args-8.c
new file mode 100644
index 0000000000000000000000000000000000000000..fb442db4ae4aaf712c5c18cbb38d190688bc51c4
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/append-args-8.c
@@ -0,0 +1,53 @@
+/* { dg-additional-options "-fdump-tree-gimple" }  */
+
+#if __cplusplus >= 201103L
+# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__
+#else
+# define __GOMP_UINTPTR_T_ENUM
+#endif
+
+typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM
+{
+  omp_interop_none = 0,
+  __omp_interop_t_max__ = __UINTPTR_MAX__
+} omp_interop_t;
+
+void f1(omp_interop_t) { }
+#pragma omp declare variant(f1) match(construct={dispatch}) \
+                                append_args(interop(prefer_type({attr("ompx_fun")})))
+void g1(void);
+
+
+int f2(omp_interop_t, omp_interop_t);
+#pragma omp declare variant(f2) append_args(interop(prefer_type("cuda")), \
+                                            interop(prefer_type({fr("hsa")}),target)) \
+                                match(construct={dispatch})
+int g2(void) { return 5; }
+
+int foo (omp_interop_t obj1)
+{
+  omp_interop_t obj2 = omp_interop_none;
+  int res;
+
+  #pragma omp dispatch interop(obj1) device(11)
+    g1();
+
+  #pragma omp dispatch interop(obj1, obj2) device(22)
+    g2();
+
+  #pragma omp dispatch interop(obj2, obj1) device(33)
+    res = g2();
+
+  return res;
+}
+
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_default_device \\(\\);" 3 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(11\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(22\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(33\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(D\.\[0-9\]+\\);" 3 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "  f1 \\(obj1\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "  f2 \\(obj1, obj2\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "  res = f2 \\(obj2, obj1\\);" 1 "gimple" } }  */
diff --git a/gcc/testsuite/c-c++-common/gomp/append-args-9.c b/gcc/testsuite/c-c++-common/gomp/append-args-9.c
new file mode 100644
index 0000000000000000000000000000000000000000..b8586e0f54a9c03652c7eee6412f914a8281e7cf
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/append-args-9.c
@@ -0,0 +1,34 @@
+#if __cplusplus >= 201103L
+# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__
+#else
+# define __GOMP_UINTPTR_T_ENUM
+#endif
+
+typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM
+{
+  omp_interop_none = 0,
+  __omp_interop_t_max__ = __UINTPTR_MAX__
+} omp_interop_t;
+
+void f1(omp_interop_t *) { }
+/* { dg-error "argument 1 of 'f1' must be of 'omp_interop_t'" "" { target c } .-1 }  */
+/* { dg-note "initializing argument 1 of 'void f1\\(omp_interop_t\\*\\)'" "" { target c++ } .-2 }  */
+#pragma omp declare variant(f1) match(construct={dispatch}) \
+                                append_args(interop(prefer_type({attr("ompx_fun")})))
+void g1(void);
+/* { dg-note "'append_args' specified here" "" { target c } .-2 }  */
+/* { dg-error "cannot convert 'omp_interop_t' to 'omp_interop_t\\*'" "" { target c++ } .-4 }  */
+
+int f2(omp_interop_t);
+#pragma omp declare variant(f2) append_args(interop(prefer_type("cuda"))) \
+                                match(construct={dispatch})
+int g2(void) { return 5; }
+
+int foo (omp_interop_t *obj1)
+{
+  int res;
+
+  #pragma omp dispatch interop(obj1) device(11)  /* { dg-error "'obj1' must be of 'omp_interop_t'" }  */
+    res = g2();
+  return res;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/defaultmap-4.c b/gcc/testsuite/c-c++-common/gomp/defaultmap-4.c
index b84f89b0c7c792a3cfee37fb4b98eb737232b3a0..d4264afed1350a064557ca8afa90b1fd25d7f7b8 100644
--- a/gcc/testsuite/c-c++-common/gomp/defaultmap-4.c
+++ b/gcc/testsuite/c-c++-common/gomp/defaultmap-4.c
@@ -20,5 +20,5 @@ foo (void)
       c[i] = a[i] + b[i];
 }
 
-/* { dg-final { scan-tree-dump "pragma omp target.*defaultmap\\(present:aggregate\\) map\\(force_present:c \\\[len: \[0-9\]+\\\]\\\[implicit\\\]\\) map\\(force_present:b \\\[len: \[0-9\]+\\\]\\\[implicit\\\]\\) map\\(force_present:a \\\[len: \[0-9\]+\\\]\\\[implicit\\\]\\)" "gimple" } } */
-/* { dg-final { scan-tree-dump "pragma omp target.*defaultmap\\(present:aggregate\\) map\\(force_present:b \\\[len: \[0-9\]+\\\]\\\[implicit\\\]\\) map\\(force_present:a \\\[len: \[0-9\]+\\\]\\\[implicit\\\]\\) map\\(from:c \\\[len: \[0-9\]+\\\]\\)" "gimple" } } */
+/* { dg-final { scan-tree-dump "pragma omp target.*defaultmap\\(present:aggregate\\) map\\(force_present:c \\\[len: \[0-9\]+\\\] \\\[runtime_implicit\\\]\\) map\\(force_present:b \\\[len: \[0-9\]+\\\] \\\[runtime_implicit\\\]\\) map\\(force_present:a \\\[len: \[0-9\]+\\\] \\\[runtime_implicit\\\]\\)" "gimple" } } */
+/* { dg-final { scan-tree-dump "pragma omp target.*defaultmap\\(present:aggregate\\) map\\(force_present:b \\\[len: \[0-9\]+\\\] \\\[runtime_implicit\\\]\\) map\\(force_present:a \\\[len: \[0-9\]+\\\] \\\[runtime_implicit\\\]\\) map\\(from:c \\\[len: \[0-9\]+\\\]\\)" "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/defaultmap-5.c b/gcc/testsuite/c-c++-common/gomp/defaultmap-5.c
index cc1a77fadb3498de2106b42071982b7107c995b7..a47b5eb6df19630d95b14b5286692af09c052ebf 100644
--- a/gcc/testsuite/c-c++-common/gomp/defaultmap-5.c
+++ b/gcc/testsuite/c-c++-common/gomp/defaultmap-5.c
@@ -44,4 +44,4 @@ void f()
 
 /* { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(firstprivate\\) firstprivate\\(mystruct1\\) firstprivate\\(ptr1\\) firstprivate\\(array1\\) firstprivate\\(scalar1\\)" 1 "gimple" } } */
 /* { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(firstprivate:all\\) firstprivate\\(mystruct1\\) firstprivate\\(ptr1\\) firstprivate\\(array1\\) firstprivate\\(scalar1\\)" 1 "gimple" } } */
-/* { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(tofrom:all\\) map\\(tofrom:mystruct1 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(tofrom:ptr1 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(tofrom:array1 \\\[len: ..\\\]\\\[implicit\\\]\\) map\\(tofrom:scalar1 \\\[len: .\\\]\\\[implicit\\\]\\)" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(tofrom:all\\) map\\(tofrom:mystruct1 \\\[len: .\\\] \\\[runtime_implicit\\\]\\) map\\(tofrom:ptr1 \\\[len: .\\\] \\\[runtime_implicit\\\]\\) map\\(tofrom:array1 \\\[len: ..\\\] \\\[runtime_implicit\\\]\\) map\\(tofrom:scalar1 \\\[len: .\\\] \\\[runtime_implicit\\\]\\)" 1 "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/pr118639.c b/gcc/testsuite/c-c++-common/gomp/pr118639.c
new file mode 100644
index 0000000000000000000000000000000000000000..eba4b757debb6cf12cf6ad3ec39ee2b01aa7ef64
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr118639.c
@@ -0,0 +1,14 @@
+/* PR c/118639 */
+/* { dg-do compile } */
+
+void
+foo (void)
+{
+  int a = 0, b = 0, c = 0;
+#ifndef __cplusplus
+  #pragma omp allocate (a, )			/* { dg-error "expected" "" { target c } } */
+#endif
+  #pragma omp flush (b, )			/* { dg-error "expected" } */
+  #pragma omp parallel firstprivate (c, )	/* { dg-error "expected" } */
+  ;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/target-implicit-map-1.c b/gcc/testsuite/c-c++-common/gomp/target-implicit-map-1.c
index 52944fdc65a8ff757f29a782a7e1ded79973417d..0fdc6c2c05e406b513871f3463c67e2d08ddbbf5 100644
--- a/gcc/testsuite/c-c++-common/gomp/target-implicit-map-1.c
+++ b/gcc/testsuite/c-c++-common/gomp/target-implicit-map-1.c
@@ -34,6 +34,6 @@ main (void)
 
 /* { dg-final { scan-tree-dump {#pragma omp target enter data map\(alloc:array\[[^]]+\]\[0\] \[len: [0-9]+\]\)} "gimple" } } */
 
-/* { dg-final { scan-tree-dump {#pragma omp target num_teams.* firstprivate\(i\) map\(tofrom:array \[len: [0-9]+\]\[implicit\]\)} "gimple" } } */
+/* { dg-final { scan-tree-dump {#pragma omp target num_teams.* firstprivate\(i\) map\(tofrom:array \[len: [0-9]+\] \[runtime_implicit\]\)} "gimple" } } */
 
 /* { dg-final { scan-tree-dump {#pragma omp target exit data map\(from:array\[[^]]+\]\[0\] \[len: [0-9]+\]\)} "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/target-implicit-map-2.c b/gcc/testsuite/c-c++-common/gomp/target-implicit-map-2.c
index b3df466a7747d8eac6c733b3d887459ec2e8ee46..a336c2d9f551b576228c91d9e88cf84cd20f6857 100644
--- a/gcc/testsuite/c-c++-common/gomp/target-implicit-map-2.c
+++ b/gcc/testsuite/c-c++-common/gomp/target-implicit-map-2.c
@@ -49,7 +49,7 @@ main (void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(tofrom:a \[len: [0-9]+\]\[implicit\]\)} "gimple" } } */
+/* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(tofrom:a \[len: [0-9]+\] \[runtime_implicit\]\)} "gimple" } } */
 
 /* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(struct:a \[len: 1\]\) map\(alloc:a\.ptr \[len: [0-9]+\]\) map\(tofrom:\*_[0-9]+ \[len: [0-9]+\]\) map\(attach:a\.ptr \[bias: 0\]\)} "gimple" } } */
 /* { dg-final { scan-tree-dump-not {map\(struct:a \[len: 1\]\) map\(alloc:a\.ptr \[len: 0\]\)} "gimple" } } */
diff --git a/gcc/testsuite/g++.dg/DRs/dr2867-5.C b/gcc/testsuite/g++.dg/DRs/dr2867-5.C
new file mode 100644
index 0000000000000000000000000000000000000000..1e4690dd48490069adaf845b8635824352cf67f5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr2867-5.C
@@ -0,0 +1,92 @@
+// CWG2867 - Order of initialization for structured bindings.
+// { dg-do run { target c++11 } }
+// { dg-options "" }
+
+#define assert(X) do { if (!(X)) __builtin_abort(); } while (0)
+
+namespace std {
+  template<typename T> struct tuple_size;
+  template<int, typename> struct tuple_element;
+}
+
+int a, c, d, i;
+
+struct A {
+  A () { assert (c == 3); ++c; }
+  ~A () { ++a; }
+  template <int I> int &get () const { assert (c == 5 + I); ++c; return i; }
+};
+
+template <> struct std::tuple_size <A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, A> { using type = int; };
+template <> struct std::tuple_size <const A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, const A> { using type = int; };
+
+struct B {
+  B () { assert (c >= 1 && c <= 2); ++c; }
+  ~B () { assert (c >= 9 && c <= 10); ++c; }
+};
+
+struct C {
+  constexpr C () {}
+  constexpr C (const C &) {}
+  template <int I> int &get () const { assert (d == 1 + I); ++d; return i; }
+};
+
+template <> struct std::tuple_size <C> { static const int value = 3; };
+template <int I> struct std::tuple_element <I, C> { using type = int; };
+template <> struct std::tuple_size <const C> { static const int value = 3; };
+template <int I> struct std::tuple_element <I, const C> { using type = int; };
+
+A
+foo (const B &, const B &)
+{
+  A a;
+  assert (c == 4);
+  ++c;
+  return a;
+}
+
+constexpr C
+foo (const C &, const C &)
+{
+  return C {};
+}
+
+int
+bar (int &x, int y)
+{
+  x = y;
+  return y;
+}
+
+int
+baz (int &x, int y)
+{
+  assert (x == y);
+  return y;
+}
+
+struct E {
+  ~E () { assert (a == 2); }
+};
+
+E e;
+int c1 = bar (c, 1);
+const auto &[x, y, z, w] = foo (B {}, B {});	// { dg-warning "structured bindings only available with" "" { target c++14_down } }
+int c2 = baz (c, 11);
+int d1 = bar (d, 1);
+const auto &[s, t, u] = foo (C {}, C {});	// { dg-warning "structured bindings only available with" "" { target c++14_down } }
+int d2 = baz (d, 4);
+int c3 = bar (c, 1);
+auto [x2, y2, z2, w2] = foo (B {}, B {});	// { dg-warning "structured bindings only available with" "" { target c++14_down } }
+int c4 = baz (c, 11);
+int d3 = bar (d, 1);
+auto [s2, t2, u2] = foo (C {}, C {});		// { dg-warning "structured bindings only available with" "" { target c++14_down } }
+int d4 = baz (d, 4);
+
+int
+main ()
+{
+  assert (a == 0);
+}
diff --git a/gcc/testsuite/g++.dg/DRs/dr2867-6.C b/gcc/testsuite/g++.dg/DRs/dr2867-6.C
new file mode 100644
index 0000000000000000000000000000000000000000..1556661d5c2e0ca31ada2421db227804a5be3a3e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr2867-6.C
@@ -0,0 +1,83 @@
+// CWG2867 - Order of initialization for structured bindings.
+// { dg-do run { target c++11 } }
+// { dg-options "" }
+
+#define assert(X) do { if (!(X)) __builtin_abort(); } while (0)
+
+namespace std {
+  template<typename T> struct tuple_size;
+  template<int, typename> struct tuple_element;
+}
+
+int a, c;
+
+struct C {
+  C () { assert (c >= 5 && c <= 17 && (c - 5) % 4 == 0); ++c; }
+  ~C () { assert (c >= 8 && c <= 20 && c % 4 == 0); ++c; }
+};
+
+struct D {
+  D () { assert (c >= 7 && c <= 19 && (c - 7) % 4 == 0); ++c; }
+  ~D () { assert (a % 5 != 4); ++a; }
+};
+
+struct A {
+  A () { assert (c == 3); ++c; }
+  ~A () { assert (a % 5 == 4); ++a; }
+  template <int I> D get (const C & = C{}) const { assert (c == 6 + 4 * I); ++c; return D {}; }
+};
+
+template <> struct std::tuple_size <A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, A> { using type = D; };
+template <> struct std::tuple_size <const A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, const A> { using type = D; };
+
+struct B {
+  B () { assert (c >= 1 && c <= 2); ++c; }
+  ~B () { assert (c >= 21 && c <= 22); ++c; }
+};
+
+A
+foo (const B &, const B &)
+{
+  A a;
+  assert (c == 4);
+  ++c;
+  return a;
+}
+
+int
+bar (int &x, int y)
+{
+  x = y;
+  return y;
+}
+
+int
+baz (int &x, int y)
+{
+  assert (x == y);
+  return y;
+}
+
+struct E {
+  ~E () { assert (a == 5); }
+};
+
+E e;
+int c1 = bar (c, 1);
+// First B::B () is invoked twice, then foo called, which invokes A::A ().
+// e is reference bound to the A::A () constructed temporary.
+// Then 4 times (in increasing I):
+//   C::C () is invoked, get is called, D::D () is invoked, C::~C () is
+//   invoked.
+// After that B::~B () is invoked twice.
+// At exit time D::~D () is invoked 4 times, then A::~A ().
+const auto &[x, y, z, w] = foo (B {}, B {});	// { dg-warning "structured bindings only available with" "" { target c++14_down } }
+int c2 = baz (c, 23);
+
+int
+main ()
+{
+  assert (a == 0);
+}
diff --git a/gcc/testsuite/g++.dg/DRs/dr2867-7.C b/gcc/testsuite/g++.dg/DRs/dr2867-7.C
new file mode 100644
index 0000000000000000000000000000000000000000..701200613d73810429fbc9fbaacb47ae1b4e8822
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr2867-7.C
@@ -0,0 +1,98 @@
+// CWG2867 - Order of initialization for structured bindings.
+// { dg-do run { target c++11 } }
+// { dg-options "" }
+// { dg-add-options tls }
+// { dg-require-effective-target tls_runtime }
+
+#define assert(X) do { if (!(X)) __builtin_abort(); } while (0)
+
+namespace std {
+  template<typename T> struct tuple_size;
+  template<int, typename> struct tuple_element;
+}
+
+int a, c, d, i;
+
+struct A {
+  A () { assert (c == 3); ++c; }
+  ~A () { ++a; }
+  template <int I> int &get () const { assert (c == 5 + I); ++c; return i; }
+};
+
+template <> struct std::tuple_size <A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, A> { using type = int; };
+template <> struct std::tuple_size <const A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, const A> { using type = int; };
+
+struct B {
+  B () { assert (c >= 1 && c <= 2); ++c; }
+  ~B () { assert (c >= 9 && c <= 10); ++c; }
+};
+
+struct C {
+  constexpr C () {}
+  constexpr C (const C &) {}
+  template <int I> int &get () const { assert (d == 1 + I); ++d; return i; }
+};
+
+template <> struct std::tuple_size <C> { static const int value = 3; };
+template <int I> struct std::tuple_element <I, C> { using type = int; };
+template <> struct std::tuple_size <const C> { static const int value = 3; };
+template <int I> struct std::tuple_element <I, const C> { using type = int; };
+
+A
+foo (const B &, const B &)
+{
+  A a;
+  assert (c == 4);
+  ++c;
+  return a;
+}
+
+constexpr C
+foo (const C &, const C &)
+{
+  return C {};
+}
+
+int
+bar (int &x, int y)
+{
+  x = y;
+  return y;
+}
+
+int
+baz (int &x, int y)
+{
+  assert (x == y);
+  return y;
+}
+
+struct E {
+  ~E () { assert (a == 2); }
+};
+
+thread_local E e;
+thread_local int c1 = bar (c, 1);
+thread_local const auto &[x, y, z, w] = foo (B {}, B {});	// { dg-warning "structured bindings only available with" "" { target c++14_down } }
+thread_local int c2 = baz (c, 11);				// { dg-warning "structured binding declaration can be 'thread_local' only in" "" { target c++17_down } .-1 }
+thread_local int d1 = bar (d, 1);
+thread_local const auto &[s, t, u] = foo (C {}, C {});		// { dg-warning "structured bindings only available with" "" { target c++14_down } }
+thread_local int d2 = baz (d, 4);				// { dg-warning "structured binding declaration can be 'thread_local' only in" "" { target c++17_down } .-1 }
+thread_local int c3 = bar (c, 1);
+thread_local auto [x2, y2, z2, w2] = foo (B {}, B {});		// { dg-warning "structured bindings only available with" "" { target c++14_down } }
+thread_local int c4 = baz (c, 11);				// { dg-warning "structured binding declaration can be 'thread_local' only in" "" { target c++17_down } .-1 }
+thread_local int d3 = bar (d, 1);
+thread_local auto [s2, t2, u2] = foo (C {}, C {});		// { dg-warning "structured bindings only available with" "" { target c++14_down } }
+thread_local int d4 = baz (d, 4);				// { dg-warning "structured binding declaration can be 'thread_local' only in" "" { target c++17_down } .-1 }
+
+int
+main ()
+{
+  volatile int u = c1 + x + y + z + w + c2;
+  u += d1 + s + t + u + d2;
+  u += c3 + x2 + y2 + z2 + w2 + c4;
+  u += d3 + s2 + t2 + u2 + d4;
+  assert (a == 0);
+}
diff --git a/gcc/testsuite/g++.dg/DRs/dr2867-8.C b/gcc/testsuite/g++.dg/DRs/dr2867-8.C
new file mode 100644
index 0000000000000000000000000000000000000000..47744400977356522807e37799142504a46fe215
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr2867-8.C
@@ -0,0 +1,86 @@
+// CWG2867 - Order of initialization for structured bindings.
+// { dg-do run { target c++11 } }
+// { dg-options "" }
+// { dg-add-options tls }
+// { dg-require-effective-target tls_runtime }
+
+#define assert(X) do { if (!(X)) __builtin_abort(); } while (0)
+
+namespace std {
+  template<typename T> struct tuple_size;
+  template<int, typename> struct tuple_element;
+}
+
+int a, c;
+
+struct C {
+  C () { assert (c >= 5 && c <= 17 && (c - 5) % 4 == 0); ++c; }
+  ~C () { assert (c >= 8 && c <= 20 && c % 4 == 0); ++c; }
+};
+
+struct D {
+  D () { assert (c >= 7 && c <= 19 && (c - 7) % 4 == 0); ++c; }
+  ~D () { assert (a % 5 != 4); ++a; }
+};
+
+struct A {
+  A () { assert (c == 3); ++c; }
+  ~A () { assert (a % 5 == 4); ++a; }
+  template <int I> D get (const C & = C{}) const { assert (c == 6 + 4 * I); ++c; return D {}; }
+};
+
+template <> struct std::tuple_size <A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, A> { using type = D; };
+template <> struct std::tuple_size <const A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, const A> { using type = D; };
+
+struct B {
+  B () { assert (c >= 1 && c <= 2); ++c; }
+  ~B () { assert (c >= 21 && c <= 22); ++c; }
+};
+
+A
+foo (const B &, const B &)
+{
+  A a;
+  assert (c == 4);
+  ++c;
+  return a;
+}
+
+int
+bar (int &x, int y)
+{
+  x = y;
+  return y;
+}
+
+int
+baz (int &x, int y)
+{
+  assert (x == y);
+  return y;
+}
+
+struct E {
+  ~E () { assert (a == 5); }
+};
+
+thread_local E e;
+thread_local int c1 = bar (c, 1);
+// First B::B () is invoked twice, then foo called, which invokes A::A ().
+// e is reference bound to the A::A () constructed temporary.
+// Then 4 times (in increasing I):
+//   C::C () is invoked, get is called, D::D () is invoked, C::~C () is
+//   invoked.
+// After that B::~B () is invoked twice.
+// At exit time D::~D () is invoked 4 times, then A::~A ().
+thread_local const auto &[x, y, z, w] = foo (B {}, B {});	// { dg-warning "structured bindings only available with" "" { target c++14_down } }
+thread_local int c2 = baz (c, 23);				// { dg-warning "structured binding declaration can be 'thread_local' only in" "" { target c++17_down } .-1 }
+
+int
+main ()
+{
+  volatile int u = c1 + c2;
+  assert (a == 0);
+}
diff --git a/gcc/testsuite/g++.dg/abi/lambda-ctx3.C b/gcc/testsuite/g++.dg/abi/lambda-ctx3.C
new file mode 100644
index 0000000000000000000000000000000000000000..f782f2c0cb504fea9d21a40b6d62beea7a748bfd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/lambda-ctx3.C
@@ -0,0 +1,27 @@
+// { dg-do compile { target c++20 } }
+// { dg-additional-options "-fkeep-inline-functions" }
+// See also https://github.com/itanium-cxx-abi/cxx-abi/pull/85
+
+struct A {
+  decltype([]{ return 1; }) f;
+};
+
+struct B : decltype([]{ return 2; }) {
+  decltype([]{ return 3; }) f;
+};
+
+template <typename T>
+struct C : decltype([]{ return 4; }) {
+  decltype([]{ return 5; }) f;
+};
+
+template struct C<int>;
+template struct C<double>;
+
+// { dg-final { scan-assembler {_ZNK1AUlvE_clEv:} } }
+// { dg-final { scan-assembler {_ZNK1BUlvE_clEv:} } }
+// { dg-final { scan-assembler {_ZNK1BUlvE0_clEv:} } }
+// { dg-final { scan-assembler {_ZNK1CIiEUlvE_clEv:} } }
+// { dg-final { scan-assembler {_ZNK1CIiEUlvE0_clEv:} } }
+// { dg-final { scan-assembler {_ZNK1CIdEUlvE_clEv:} } }
+// { dg-final { scan-assembler {_ZNK1CIdEUlvE0_clEv:} } }
diff --git a/gcc/testsuite/g++.dg/coroutines/coro-range-for1.C b/gcc/testsuite/g++.dg/coroutines/coro-range-for1.C
new file mode 100644
index 0000000000000000000000000000000000000000..eaf4d19e62cbfb907aadca5490c393964d430d65
--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/coro-range-for1.C
@@ -0,0 +1,38 @@
+// PR c++/118491
+// { dg-do compile { target c++20 } }
+
+#include <coroutine>
+
+struct task {
+  struct promise_type {
+    task get_return_object() { return {}; }
+    std::suspend_always initial_suspend() { return {}; }
+    std::suspend_always final_suspend() noexcept { return {}; }
+    std::suspend_always yield_value(double value) { return {}; }
+    void unhandled_exception() { throw; }
+  };
+};
+
+task do_task() {
+  const int arr[]{1, 2, 3};
+
+  // No ICE if classic loop and not range-based one.
+  // for (auto i = 0; i < 10; ++i) {
+
+  // No ICE if these are moved out of the loop.
+  // auto x = std::suspend_always{};
+  // co_await x;
+
+  for (auto _ : arr) {
+    auto bar = std::suspend_always{};
+    co_await bar;
+
+    // Alternatively:
+    // auto bar = 42.;
+    // co_yield bar;
+
+    // No ICE if r-values:
+    // co_await std::suspend_always{};
+    // co_yield 42.;
+  }
+}
diff --git a/gcc/testsuite/g++.dg/coroutines/pr116506.C b/gcc/testsuite/g++.dg/coroutines/pr116506.C
new file mode 100644
index 0000000000000000000000000000000000000000..57a6e3605661ff72d65fd66ffbee59317f64f4d0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/pr116506.C
@@ -0,0 +1,53 @@
+// { dg-do run }
+// { dg-additional-options "-fno-exceptions" }
+                                                       
+#include <coroutine>
+
+bool g_too_early = true;
+std::coroutine_handle<> g_handle;
+
+struct Awaiter {
+    Awaiter() {}
+    ~Awaiter() {
+        if (g_too_early) {
+            __builtin_abort ();
+        }
+    }
+
+    bool await_ready() { return false; }
+    void await_suspend(std::coroutine_handle<> handle) {
+        g_handle = handle;
+    }
+
+    void await_resume() {}
+};
+
+struct SuspendNever {
+    bool await_ready() noexcept { return true; }
+    void await_suspend(std::coroutine_handle<>) noexcept {}
+    void await_resume() noexcept {}
+};
+
+struct Coroutine {
+    struct promise_type {
+        Coroutine get_return_object() { return {}; }
+        SuspendNever initial_suspend() { return {}; }
+        SuspendNever final_suspend() noexcept { return {}; }
+        void return_void() {}
+        void unhandled_exception() {}
+
+        Awaiter&& await_transform(Awaiter&& u) {
+            return static_cast<Awaiter&&>(u);
+        }
+    };
+};
+
+Coroutine foo() {
+    co_await Awaiter{};
+}
+
+int main() {
+    foo();
+    g_too_early = false;
+    g_handle.destroy();
+}
diff --git a/gcc/testsuite/g++.dg/coroutines/pr116880.C b/gcc/testsuite/g++.dg/coroutines/pr116880.C
new file mode 100644
index 0000000000000000000000000000000000000000..f0db6a26044530eeb8d9cef8ad83b1c96c3a41f4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/pr116880.C
@@ -0,0 +1,36 @@
+#include <coroutine>
+
+struct promise_type;
+using handle_type = std::coroutine_handle<promise_type>;
+
+struct Co {
+    handle_type handle;
+    using promise_type = ::promise_type;
+
+    explicit Co(handle_type handle) : handle(handle) {}
+
+    bool await_ready() { return false; }
+    std::coroutine_handle<> await_suspend(handle_type handle);
+    void await_resume() {}
+};
+
+struct Done {};
+
+struct promise_type {
+    Co get_return_object();
+
+    std::suspend_always initial_suspend() { return {}; };
+    std::suspend_always final_suspend() noexcept { return {}; };
+    void return_value(Done) {}
+    void return_value(Co&&);
+    void unhandled_exception() { throw; };
+    Co&& await_transform(Co&& co) { return static_cast<Co&&>(co); }
+};
+
+Co tryToRun();
+
+Co init()
+{
+    co_await tryToRun();
+    co_return Done{};
+}
diff --git a/gcc/testsuite/g++.dg/cpp/embed-25.C b/gcc/testsuite/g++.dg/cpp/embed-25.C
new file mode 100644
index 0000000000000000000000000000000000000000..3acffeb9caf87e5e19f762f3e62c17632b9248e6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/embed-25.C
@@ -0,0 +1,56 @@
+// PR c++/118671
+// { dg-do run { target c++11 } }
+// { dg-options "-O2" }
+
+namespace std {
+template <typename T>
+struct initializer_list {
+private:
+  T *_M_array;
+  decltype (sizeof 0) _M_len;
+public:
+  constexpr decltype (sizeof 0)
+  size () const noexcept { return _M_len; }
+  constexpr const T *
+  begin () const noexcept { return _M_array; }
+  constexpr const T *
+  end () const noexcept { return begin () + size (); }
+};
+}
+
+struct A {} a;
+
+struct B {
+  constexpr B (int x) : B (a, x) {}
+  template <typename... T>
+  constexpr B (A, T... x) : b(x...) {}
+  int b;
+};
+
+struct C {
+  C (std::initializer_list<B> x)
+  {
+    unsigned char buf[] = {
+#embed __FILE__
+    };
+    if (x.size () != sizeof (buf))
+      __builtin_abort ();
+    unsigned int i = 0;
+    for (auto a = x.begin (); a < x.end (); ++a, ++i)
+      if (a->b != buf[i])
+	__builtin_abort ();
+    c = true;
+  }
+  bool c;
+};
+
+C c {
+#embed __FILE__
+};
+
+int
+main ()
+{
+  if (!c.c)
+    __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-base8.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-base8.C
new file mode 100644
index 0000000000000000000000000000000000000000..ecc28693315eb7f0d7a70abc23fb473bb4fda212
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-base8.C
@@ -0,0 +1,24 @@
+// PR c++/118239
+// { dg-do "compile" { target c++11 } }
+
+struct NoMut1 {
+  int a, b;
+};
+
+// Reported case.
+struct NoMut2 : NoMut1 {
+  constexpr NoMut2(int a, int b) /*: NoMut1()*/
+  {} // { dg-error "must be initialized" "" { target c++17_down } }
+};
+
+// Variant with explicit initialization of some member.
+struct NoMut3 : NoMut1 {
+  constexpr NoMut3(int a, int b) : c(0) /*, NoMut1()*/
+  {} // { dg-error "must be initialized" "" { target c++17_down } }
+  int c;
+};
+
+void mutable_subobjects() {
+  constexpr NoMut2 nm2(1, 2); // { dg-error "constant expression" }
+  constexpr NoMut3 nm3(1, 2); // { dg-error "constant expression" }
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-opt6.C b/gcc/testsuite/g++.dg/cpp0x/initlist-opt6.C
new file mode 100644
index 0000000000000000000000000000000000000000..80192892b8a56f3873bd99fb6370c8d9bc1b23cc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-opt6.C
@@ -0,0 +1,26 @@
+// PR c++/118673
+// { dg-do run { target c++11 } }
+
+#include <initializer_list>
+
+struct ArrayRef {
+  const int *Data = nullptr;
+  ArrayRef(const int &OneElt) : Data(&OneElt) {}
+};
+
+struct Vec
+{
+  ArrayRef Elts[1];
+  Vec(std::initializer_list<ArrayRef> IL)
+    : Elts{*IL.begin()}
+    {  }
+};
+
+[[gnu::noinline]] Vec fn() {
+  static const auto extension = 42;
+  return {extension};
+}
+int main() {
+  auto t = fn();
+  if (t.Elts[0].Data[0] != 42) __builtin_abort();
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-opt7.C b/gcc/testsuite/g++.dg/cpp0x/initlist-opt7.C
new file mode 100644
index 0000000000000000000000000000000000000000..f55ef5b77c5ba0ecbe98228ed96ac61a2086fcad
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-opt7.C
@@ -0,0 +1,41 @@
+// PR c++/118285
+// { dg-do compile { target c++20 } }
+
+#include <initializer_list>
+
+struct A {
+  char *a;
+  union { char b[8]; long c; };
+  constexpr A (const char *x) : a(b)
+  {
+    for (int i = 0; i < 8; ++i)
+      b[i] = 0;
+  }
+  constexpr ~A ()
+  {
+    if (!foo ())
+      bar (c);
+  }
+  constexpr bool foo ()
+  {
+    char *x = a;
+    if (x == b)
+      return true;
+    return false;
+  }
+  constexpr void bar (long) {}
+};
+
+constexpr void
+baz (std::initializer_list<A>)
+{
+}
+
+constexpr bool
+qux ()
+{
+  baz ({""});
+  return true;
+}
+
+static_assert (qux (), "");
diff --git a/gcc/testsuite/g++.dg/cpp0x/nontype7.C b/gcc/testsuite/g++.dg/cpp0x/nontype7.C
new file mode 100644
index 0000000000000000000000000000000000000000..30c1d3933ee3dec97de9800c8260716346082f5d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nontype7.C
@@ -0,0 +1,13 @@
+// PR c++/118632
+// { dg-do compile { target c++11 } }
+
+template<class T, T* = nullptr>
+class Matrix {};
+
+template<class T>
+void operator*(Matrix<T>, int);
+
+int main() {
+  Matrix<int> m;
+  m * 42;
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr118671.C b/gcc/testsuite/g++.dg/cpp0x/pr118671.C
new file mode 100644
index 0000000000000000000000000000000000000000..d531274ab3e0b0506ccf7f9557c620d75a1d15ce
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr118671.C
@@ -0,0 +1,61 @@
+// PR c++/118671
+// { dg-do run { target c++11 } }
+// { dg-options "-O2" }
+
+namespace std {
+template <typename T>
+struct initializer_list {
+private:
+  T *_M_array;
+  decltype (sizeof 0) _M_len;
+public:
+  constexpr decltype (sizeof 0)
+  size () const noexcept { return _M_len; }
+  constexpr const T *
+  begin () const noexcept { return _M_array; }
+  constexpr const T *
+  end () const noexcept { return begin () + size (); }
+};
+}
+
+struct A {} a;
+
+struct B {
+  constexpr B (int x) : B (a, x) {}
+  template <typename... T>
+  constexpr B (A, T... x) : b(x...) {}
+  int b;
+};
+
+struct C {
+  C (std::initializer_list<B> x)
+  {
+    if (x.size () != 130)
+      __builtin_abort ();
+    unsigned int i = 1;
+    for (auto a = x.begin (); a < x.end (); ++a)
+      if (a->b != i)
+	__builtin_abort ();
+      else
+	i = (i & 15) + 1;
+    c = true;
+  }
+  bool c;
+};
+
+C c { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+      1, 2 };
+
+int
+main ()
+{
+  if (!c.c)
+    __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic188.C b/gcc/testsuite/g++.dg/cpp0x/variadic188.C
new file mode 100644
index 0000000000000000000000000000000000000000..04732a5e68fb9b40ca914396d485acbd1029363f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic188.C
@@ -0,0 +1,23 @@
+// PR c++/94100
+// { dg-do compile { target c++11 } }
+
+template <typename... T> struct ValListWithTypes {
+  template <T... Members> struct WithVals {
+    using TypeList = ValListWithTypes;
+  };
+};
+
+template <typename ValList, typename ValTypeList = typename ValList::TypeList>
+struct Widget;
+
+template <typename ValList, typename... ValTypes>
+struct Widget<ValList, ValListWithTypes<ValTypes...>> {
+  template <typename = ValList> struct Impl {};
+};
+
+template <typename ValList, typename... ValTypes>
+template <ValTypes... Vals>
+struct Widget<ValList, ValListWithTypes<ValTypes...>>::Impl<
+    typename ValListWithTypes<ValTypes...>::template WithVals<Vals...>> {};
+
+int main(void) { Widget<ValListWithTypes<int>::WithVals<0>>::Impl<> impl; }
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-117778.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-117778.C
new file mode 100644
index 0000000000000000000000000000000000000000..f377e3acc912a687dfe8ddc08f8960e6e16694ae
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-117778.C
@@ -0,0 +1,12 @@
+// PR c++/117778
+// { dg-do compile { target c++14 } }
+
+auto l1 = [](auto (*fp)() -> auto) { return fp; };
+auto l2 = [](auto fp() -> auto) { return fp; };
+auto l3 = [](auto fp()) { return fp; };
+auto l4 = [](auto (*fp)()) { return fp; };
+auto l5 = [](auto fp() -> auto) -> auto { return fp; };
+auto l6 = [](auto fp(auto fp2()) -> auto) -> auto { return fp; }; // { dg-error ".auto. parameter not permitted" }
+auto l7 = [](auto fp(auto fp2() -> auto) -> auto) -> auto { return fp; }; // { dg-error ".auto. parameter not permitted" }
+auto l8 = [](int fp(auto fp2())) { return fp; }; // { dg-error ".auto. parameter not permitted" }
+auto l9 = [](auto fp(auto fp2() -> auto) -> auto) { return fp; }; // { dg-error ".auto. parameter not permitted" }
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-ice4.C b/gcc/testsuite/g++.dg/cpp1y/lambda-ice4.C
new file mode 100644
index 0000000000000000000000000000000000000000..d8b7af9f99203a59978fdd7ebf0d335375efb7b9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-ice4.C
@@ -0,0 +1,63 @@
+// PR c++/114292
+// { dg-do "compile" { target c++14 } }
+// { dg-additional-options "-Wno-vla" }
+
+#define ASSERT_CAPTURE_NUMBER(Lambda, NumCaptures) \
+  { \
+    auto oneCapture = [&](auto) { int t[c]; }; \
+    const auto sizeOneCapture = sizeof (oneCapture); \
+    const auto expected = NumCaptures ? NumCaptures * sizeOneCapture : 1; \
+    static_assert (sizeof (Lambda) == expected, ""); \
+  }
+
+template<int r, int c>
+struct Want_a_Typedef { typedef int Type[r*c]; };
+    
+void foo (int c)
+{
+  constexpr int r = 4;
+
+  // This used to ICE.
+  auto ice_1 = [&](auto) { int t[c * r]; };
+  ice_1 (0);
+  ASSERT_CAPTURE_NUMBER (ice_1, 2);
+
+  // Another ICE identified following a great question in the patch submission
+  // mail thread.
+  auto ice_2 = [&](auto) { typedef int MyT[c*r]; };
+  ice_2 (0);
+  ASSERT_CAPTURE_NUMBER (ice_2, 2);
+
+  // All those worked already, but were not covered by any test - do it here.
+  auto ok_0 = [&](auto) { typedef int MyT[c*r]; MyT t; };
+  ok_0 (0);
+  ASSERT_CAPTURE_NUMBER (ok_0, 2);
+
+  auto ok_1 = [&](auto) { Want_a_Typedef<r, 42>::Type t; };
+  ok_1 (0);
+  ASSERT_CAPTURE_NUMBER (ok_1, 0);
+
+  auto ok_2 = [&](auto) { int t[c]; };
+  ok_2 (0);
+  ASSERT_CAPTURE_NUMBER (ok_2, 1);
+
+  auto ok_3 = [&](auto) { int n = r * c; int t[n]; };
+  ok_3 (0);
+  ASSERT_CAPTURE_NUMBER (ok_3, 2);
+
+  auto ok_4 = [&](auto) { int t[r]; };
+  ok_4 (0);
+  ASSERT_CAPTURE_NUMBER (ok_4, 0);
+
+  auto ok_5 = [&](auto) { int t[c * 4]; };
+  ok_5 (0);
+  ASSERT_CAPTURE_NUMBER (ok_5, 1);
+
+  auto ok_6 = [&](auto) { int t[1]; };
+  ok_6 (0);
+  ASSERT_CAPTURE_NUMBER (ok_6, 0);
+
+  auto ok_7 = [&](auto) { int t[c * r]; };
+  ok_7 (0);
+  ASSERT_CAPTURE_NUMBER (ok_7, 2);
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp63.C b/gcc/testsuite/g++.dg/cpp1z/decomp63.C
new file mode 100644
index 0000000000000000000000000000000000000000..50049255efb16c008aa3358dfcef7f9ea007997a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/decomp63.C
@@ -0,0 +1,18 @@
+// PR c++/118719
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+int
+main ()
+{
+  int a[] = { 42 };
+  auto [x] = a;					// { dg-warning "structured bindings only available with" "" { target c++14_down } }
+						// { dg-message "declared here" "" { target c++17_down } .-1 }
+  [=] () { int b = x; (void) b; };		// { dg-warning "captured structured bindings are a C\\\+\\\+20 extension" "" { target c++17_down } }
+  [&] () { int b = x; (void) b; };		// { dg-warning "captured structured bindings are a C\\\+\\\+20 extension" "" { target c++17_down } }
+  [x] () { int b = x; (void) b; };		// { dg-warning "captured structured bindings are a C\\\+\\\+20 extension" "" { target c++17_down } }
+  [&x] () { int b = x; (void) b; };		// { dg-warning "captured structured bindings are a C\\\+\\\+20 extension" "" { target c++17_down } }
+  [x = x] () { int b = x; (void) b; };		// { dg-warning "lambda capture initializers only available with" "" { target c++11_only } }
+  [y = x] () { int b = y; (void) b; };		// { dg-warning "lambda capture initializers only available with" "" { target c++11_only } }
+  [y = x * 2] () { int b = y; (void) b; };	// { dg-warning "lambda capture initializers only available with" "" { target c++11_only } }
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/variadic-nontype1.C b/gcc/testsuite/g++.dg/cpp1z/variadic-nontype1.C
new file mode 100644
index 0000000000000000000000000000000000000000..ad2af623b1397d19eba3fec2d59fdac9c2264578
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/variadic-nontype1.C
@@ -0,0 +1,18 @@
+// { dg-do compile { target c++17 } }
+struct Class1
+{
+    void apply_bool(bool){}
+    void apply_char(char){}
+};
+
+template<auto...Fn> struct Class2;
+template<typename...P, void(Class1::*...Fn)(P)> struct Class2<Fn...>
+{
+    void apply(){}
+};
+
+int main()
+{
+    Class2<&Class1::apply_bool, &Class1::apply_char> class2;
+    class2.apply ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp23/class-deduction-inherited7.C b/gcc/testsuite/g++.dg/cpp23/class-deduction-inherited7.C
new file mode 100644
index 0000000000000000000000000000000000000000..b1d5e89ad02139f2f3ab02973078c9f1f06d27a6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp23/class-deduction-inherited7.C
@@ -0,0 +1,12 @@
+// PR c++/117855
+// { dg-do compile { target c++20 } }
+
+template <typename T, int _Extent = -1> struct span { span(T&&);};
+template <typename T> span(T &&) -> span<T>;
+template <typename et, int e = -1>
+struct this_span : span<et, e> {
+  using span<et, e>::span;
+};
+template <typename T> this_span(T &&) -> this_span<T>;
+int vec;
+this_span a = vec;
diff --git a/gcc/testsuite/g++.dg/cpp2a/abbrev-fn2.C b/gcc/testsuite/g++.dg/cpp2a/abbrev-fn2.C
new file mode 100644
index 0000000000000000000000000000000000000000..902382651b893d0f3f943b22d9871babb7e89f90
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/abbrev-fn2.C
@@ -0,0 +1,49 @@
+// PR c++/117778
+// { dg-do run { target c++20 } }
+
+int
+f (auto fp())
+{
+  return fp ();
+}
+
+int
+g (auto fp() -> auto)
+{
+  return fp ();
+}
+
+int
+h (auto (*fp)() -> auto)
+{
+  return fp ();
+}
+
+auto
+fa (auto fp()) -> auto
+{
+  return fp ();
+}
+
+auto
+ga (auto fp() -> auto) -> auto
+{
+  return fp ();
+}
+
+auto
+ha (auto (*fp)() -> auto) -> auto
+{
+  return fp ();
+}
+
+int bar() { return 42; }
+
+int
+main ()
+{
+  if (f (bar) != 42 || g (bar) != 42 || h (bar) != 42)
+    __builtin_abort ();
+  if (fa (bar) != 42 || ga (bar) != 42 || ha (bar) != 42)
+    __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp2a/abbrev-fn3.C b/gcc/testsuite/g++.dg/cpp2a/abbrev-fn3.C
new file mode 100644
index 0000000000000000000000000000000000000000..865fc5cd10d0277da01a4fe59ee88f39d6d531bf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/abbrev-fn3.C
@@ -0,0 +1,15 @@
+// PR c++/117778
+// { dg-do compile { target c++20 } }
+
+int f1 (auto fp(auto fp2())); // { dg-error ".auto. parameter not permitted" }
+int f2 (auto fp(auto fp2() -> auto)); // { dg-error ".auto. parameter not permitted" }
+auto f3 (auto fp() -> auto) -> auto;
+auto f3 (auto fp(auto fp2() -> auto) -> auto) -> auto; // { dg-error ".auto. parameter not permitted" }
+
+void
+g ()
+{
+  extern int e1 (auto fp()); // { dg-error ".auto. parameter not permitted" }
+  extern int e2 (auto fp() -> auto); // { dg-error ".auto. parameter not permitted" }
+  extern int e3 (auto fp(auto fp2() -> auto) -> auto); // { dg-error ".auto. parameter not permitted" }
+}
diff --git a/gcc/testsuite/g++.dg/cpp2a/consteval39.C b/gcc/testsuite/g++.dg/cpp2a/consteval39.C
new file mode 100644
index 0000000000000000000000000000000000000000..523e8260eab295149c8a9341517cefed511a4e54
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/consteval39.C
@@ -0,0 +1,27 @@
+// PR c++/117501
+// { dg-do run { target c++20 } }
+
+constexpr unsigned
+length ()
+{
+  bool __trans_tmp_1 = __builtin_is_constant_evaluated();
+  if (__trans_tmp_1)
+    return 42;
+  return 1;
+}
+struct basic_string_view {
+  constexpr basic_string_view(const char *) : _M_len{length()}, _M_str{} {}
+  long _M_len;
+  char _M_str;
+};
+struct QQQ {
+  consteval QQQ(basic_string_view d) : data(d) {}
+  basic_string_view data;
+};
+int
+main ()
+{
+  QQQ q("");
+  if (q.data._M_len != 42)
+    __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp2a/consteval40.C b/gcc/testsuite/g++.dg/cpp2a/consteval40.C
new file mode 100644
index 0000000000000000000000000000000000000000..4d3ba20092b1e0a49c57c7df74152ab00d56cc72
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/consteval40.C
@@ -0,0 +1,25 @@
+// PR c++/117501
+// { dg-do run { target c++20 } }
+
+constexpr int
+twiddle (int i)
+{
+ if (__builtin_is_constant_evaluated ())
+    return 3;
+  return i;
+}
+struct S {
+  constexpr S(int i) : i{twiddle (i)} {}
+  int i;
+};
+struct Q {
+  consteval Q(S s_) : s{s_, s_} {}
+  S s[2];
+};
+int
+main ()
+{
+  Q q(twiddle (42));
+  if (q.s[0].i != 3 || q.s[1].i != 3)
+    __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-uneval22.C b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval22.C
new file mode 100644
index 0000000000000000000000000000000000000000..9c0e8128f1088fe41f43f24dd70959b9076ec389
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval22.C
@@ -0,0 +1,21 @@
+// { dg-do compile { target c++20 } }
+
+struct S {
+  template <int I>
+  using T = decltype([]{ return I; });
+
+  template <int I>
+  decltype([]{ return I; }) f() { return {}; }
+};
+
+void a(S::T<0>*);  // { dg-error "declared using local type" }
+void b(S::T<1>*);  // { dg-error "declared using local type" }
+void c(decltype(S{}.f<0>())*);  // { dg-error "declared using local type" }
+void d(decltype(S{}.f<1>())*);  // { dg-error "declared using local type" }
+
+int main() {
+  a(nullptr);
+  b(nullptr);
+  c(nullptr);
+  d(nullptr);
+}
diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-uneval23.C b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval23.C
new file mode 100644
index 0000000000000000000000000000000000000000..fa009f53ff23e7fc8ed4407877eff9eddfcb5d46
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval23.C
@@ -0,0 +1,7 @@
+// PR c++/118245
+// { dg-do compile { target c++20 } }
+
+template<auto> struct Cask {};
+struct T1 : Cask<[]{}> {
+  Cask<[]{}> c{};
+};
diff --git a/gcc/testsuite/g++.dg/eh/throw5.C b/gcc/testsuite/g++.dg/eh/throw5.C
new file mode 100644
index 0000000000000000000000000000000000000000..554e8700df00f0339f71bb17a26606b13f806231
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/throw5.C
@@ -0,0 +1,23 @@
+// PR c++/57533
+// { dg-do run { target c++11 } }
+
+struct X
+{
+    bool moved = false;
+
+    X() = default;
+    X(const X&) = default;
+    X(X&& x) { x.moved = true; }
+};
+
+int main()
+{
+    X x;
+    try {
+        throw x;
+    }
+    catch(...) {
+    }
+    if (x.moved)
+        __builtin_abort();
+}
diff --git a/gcc/testsuite/g++.dg/ext/flexary19.C b/gcc/testsuite/g++.dg/ext/flexary19.C
index 9a06f9ca758fe6aeccc392adcd43498b459648d3..f937728677889bef2a3ff6c4e43683837d179564 100644
--- a/gcc/testsuite/g++.dg/ext/flexary19.C
+++ b/gcc/testsuite/g++.dg/ext/flexary19.C
@@ -210,7 +210,7 @@ struct S22
     static int i;
 
     int a[];        // { dg-warning "in an otherwise empty" }
-  } s;
+  } s;		    // { dg-warning "invalid use" }
 };
 
 struct S23
diff --git a/gcc/testsuite/g++.dg/ext/flexary42.C b/gcc/testsuite/g++.dg/ext/flexary42.C
new file mode 100644
index 0000000000000000000000000000000000000000..f3372b21007a55e1aae81eda25bc8dc92b02aae7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/flexary42.C
@@ -0,0 +1,26 @@
+// PR c++/117516
+// { dg-do compile }
+// { dg-options "-Wpedantic -Wno-error=pedantic" }
+
+struct A { int a; char b[]; int c; };						// { dg-warning "forbids flexible array member" }
+										// { dg-error "flexible array member 'A::b' not at end of 'struct A'" "" { target *-*-* } .-1 }
+struct B { struct A d; struct A e[]; struct A f; };				// { dg-warning "forbids flexible array member" }
+										// { dg-error "flexible array member 'B::e' not at end of 'struct B'" "" { target *-*-* } .-1 }
+struct C { struct B g; struct B h[]; struct B i; };				// { dg-warning "forbids flexible array member" }
+										// { dg-error "flexible array member 'C::h' not at end of 'struct C'" "" { target *-*-* } .-1 }
+struct D { struct C j; };
+D k;
+struct E { int l; struct { int m; int n[]; int o; } p; int q; };		// { dg-warning "forbids flexible array member" }
+										// { dg-error "flexible array member 'E::<unnamed struct>::n' not at end of 'struct E'" "" { target *-*-* } .-1 }
+struct F {};
+struct G { int r[]; };								// { dg-warning "forbids flexible array member" }
+										// { dg-warning "flexible array member 'G::r' in an otherwise empty 'struct G' is a GCC extension" "" { target *-*-* } .-1 }
+struct H { int s; int t[]; };							// { dg-warning "forbids flexible array member" }
+										// { dg-error "flexible array member 'H::t' not at end of 'struct K'" "" { target *-*-* } .-1 }
+										// { dg-message "array member 'int H::t \\\[\\\]' declared here" "" { target *-*-* } .-2 }
+#if __cplusplus >= 202002L
+struct I { [[no_unique_address]] F u; [[no_unique_address]] F v; int w[]; };	// { dg-warning "forbids flexible array member" "" { target c++20 } }
+#endif
+struct J { int x; struct H y; };						// { dg-warning "invalid use of 'struct H' with a flexible array member in 'struct J'" }
+struct K { int z; struct H aa; int ab; };					// { dg-message "next member 'int K::ab' declared here" }
+										// { dg-message "in the definition of 'struct K'" "" { target *-*-* } .-1 }
diff --git a/gcc/testsuite/g++.dg/ext/flexary9.C b/gcc/testsuite/g++.dg/ext/flexary9.C
index b31e84b5fce81760a1ef208728d67273b0f86837..0dfcdfe91a963bca38ae07bae50dd12a2661ef62 100644
--- a/gcc/testsuite/g++.dg/ext/flexary9.C
+++ b/gcc/testsuite/g++.dg/ext/flexary9.C
@@ -272,7 +272,7 @@ struct S_S_S_x {
   struct A {
     struct B {
       int a[0];             // { dg-warning "zero-size array" }
-    } b;
+    } b;		    // { dg-warning "invalid use" }
   } a;
 };
 
diff --git a/gcc/testsuite/g++.dg/ext/is_bounded_array.C b/gcc/testsuite/g++.dg/ext/is_bounded_array.C
index b5fe435de95742682ba5bccefc2ec567f4e2b583..63cd4f89091bb4adcb58f09c9412eb905e392331 100644
--- a/gcc/testsuite/g++.dg/ext/is_bounded_array.C
+++ b/gcc/testsuite/g++.dg/ext/is_bounded_array.C
@@ -1,4 +1,5 @@
 // { dg-do compile { target c++11 } }
+// { dg-options "" }
 
 #define SA(X) static_assert((X),#X)
 
@@ -14,21 +15,34 @@
 
 class ClassType { };
 
+constexpr int sz0 = 0;
+constexpr int sz2 = 2;
+
 SA_TEST_CATEGORY(__is_bounded_array, int[2], true);
 SA_TEST_CATEGORY(__is_bounded_array, int[], false);
+SA_TEST_CATEGORY(__is_bounded_array, int[0], false);
 SA_TEST_CATEGORY(__is_bounded_array, int[2][3], true);
 SA_TEST_CATEGORY(__is_bounded_array, int[][3], false);
+SA_TEST_CATEGORY(__is_bounded_array, int[0][3], false);
+SA_TEST_CATEGORY(__is_bounded_array, int[3][0], false);
 SA_TEST_CATEGORY(__is_bounded_array, float*[2], true);
 SA_TEST_CATEGORY(__is_bounded_array, float*[], false);
 SA_TEST_CATEGORY(__is_bounded_array, float*[2][3], true);
 SA_TEST_CATEGORY(__is_bounded_array, float*[][3], false);
 SA_TEST_CATEGORY(__is_bounded_array, ClassType[2], true);
 SA_TEST_CATEGORY(__is_bounded_array, ClassType[], false);
+SA_TEST_CATEGORY(__is_bounded_array, ClassType[0], false);
 SA_TEST_CATEGORY(__is_bounded_array, ClassType[2][3], true);
 SA_TEST_CATEGORY(__is_bounded_array, ClassType[][3], false);
+SA_TEST_CATEGORY(__is_bounded_array, ClassType[0][3], false);
+SA_TEST_CATEGORY(__is_bounded_array, ClassType[2][0], false);
+SA_TEST_CATEGORY(__is_bounded_array, int[sz2], true);
+SA_TEST_CATEGORY(__is_bounded_array, int[sz0], false);
 SA_TEST_CATEGORY(__is_bounded_array, int(*)[2], false);
 SA_TEST_CATEGORY(__is_bounded_array, int(*)[], false);
+SA_TEST_CATEGORY(__is_bounded_array, int(*)[0], false);
 SA_TEST_CATEGORY(__is_bounded_array, int(&)[2], false);
+SA_TEST_CATEGORY(__is_bounded_array, int(&)[0], false);
 SA_TEST_FN(__is_bounded_array, int(&)[], false);
 
 // Sanity check.
diff --git a/gcc/testsuite/g++.dg/goacc/implied-copy.C b/gcc/testsuite/g++.dg/goacc/implied-copy.C
new file mode 100644
index 0000000000000000000000000000000000000000..cfc4e133e48e259c0c5d7e009fd456ce6304d3d4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/goacc/implied-copy.C
@@ -0,0 +1,24 @@
+/* { dg-additional-options "-fdump-tree-gimple" } */
+
+/* Test for wchar_t type.  */
+int
+main(void)
+{
+  int i;
+  wchar_t a[100], s;
+
+#pragma acc parallel reduction (+:s)
+  for (i = 0; i < 10; i++)
+    {
+      s += a[i];
+    }
+
+#pragma acc serial reduction (+:s)
+  for (i = 0; i < 10; i++)
+    {
+      s += a[i];
+    }
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "map\\(tofrom:s \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */
diff --git a/gcc/testsuite/g++.dg/gomp/append-args-1.C b/gcc/testsuite/g++.dg/gomp/append-args-1.C
index 2fbb21aeb4d6732bb4dc0f8dee6bde45a1a00c2d..7ff402336ceefb4995005d0b84da3ca2fcafbd15 100644
--- a/gcc/testsuite/g++.dg/gomp/append-args-1.C
+++ b/gcc/testsuite/g++.dg/gomp/append-args-1.C
@@ -20,8 +20,8 @@ template<typename T>
 float base1(T);
 
 
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'float repl1\\(T, T2, T2\\) \\\[with T = omp_interop_t; T2 = omp_interop_t\\\]'" "" { target *-*-* } .-5 }  */
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'float repl1\\(T, T2, T2\\) \\\[with T = float; T2 = omp_interop_t\\\]'" "" { target *-*-* } .-6 }  */
+/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'float repl1\\(T, T2, T2\\) \\\[with T = omp_interop_t; T2 = omp_interop_t\\\]', except when specifying all 2 objects in the 'interop' clause of the 'dispatch' directive" "" { target *-*-* } .-5 }  */
+/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'float repl1\\(T, T2, T2\\) \\\[with T = float; T2 = omp_interop_t\\\]', except when specifying all 2 objects in the 'interop' clause of the 'dispatch' directive" "" { target *-*-* } .-6 }  */
 
 
 
@@ -45,7 +45,7 @@ void repl99(T);
         append_args(interop(target, targetsync, prefer_type("cuda")))
 void base99();
 
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'void repl99\\(T\\) \\\[with T = omp_interop_t\\\]'" "" { target *-*-* } .-3 }  */
+/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'void repl99\\(T\\) \\\[with T = omp_interop_t\\\]', except when specifying all 1 objects in the 'interop' clause of the 'dispatch' directive" "" { target *-*-* } .-3 }  */
 
 
 
@@ -57,8 +57,8 @@ void repl2(T, T2, T3, T3);
 template<typename T, typename T2>
 void base2(T x, T2 y);
 
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'void repl2\\(T, T2, T3, T3\\) \\\[with T = int\\*; T2 = int\\*; T3 = omp_interop_t\\\]'" "" { target *-*-* } .-5 }  */
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'void repl2\\(T, T2, T3, T3\\) \\\[with T = int\\*; T2 = omp_interop_t; T3 = omp_interop_t\\\]'" "" { target *-*-* } .-6 }  */
+/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'void repl2\\(T, T2, T3, T3\\) \\\[with T = int\\*; T2 = int\\*; T3 = omp_interop_t\\\]', except when specifying all 2 objects in the 'interop' clause of the 'dispatch' directive" "" { target *-*-* } .-5 }  */
+/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'void repl2\\(T, T2, T3, T3\\) \\\[with T = int\\*; T2 = omp_interop_t; T3 = omp_interop_t\\\]', except when specifying all 2 objects in the 'interop' clause of the 'dispatch' directive" "" { target *-*-* } .-6 }  */
 
 
 template<typename T,typename T3>
@@ -83,7 +83,7 @@ void repl3(T, T2, ...);
 template<typename T>
 void base3(T, ...);
 
-/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'void repl3\\(T, T2, \.\.\.\\) \\\[with T = int\\*; T2 = omp_interop_t\\\]'" "" { target *-*-* } .-4 }  */
+/* { dg-message "sorry, unimplemented: 'append_args' clause not yet supported for 'void repl3\\(T, T2, \.\.\.\\) \\\[with T = int\\*; T2 = omp_interop_t\\\]', except when specifying all 1 objects in the 'interop' clause of the 'dispatch' directive" "" { target *-*-* } .-4 }  */
 
 
 
diff --git a/gcc/testsuite/g++.dg/gomp/append-args-4.C b/gcc/testsuite/g++.dg/gomp/append-args-4.C
new file mode 100644
index 0000000000000000000000000000000000000000..bdae6f18fd31ff0ad79189aac9e18309fa7944d1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/append-args-4.C
@@ -0,0 +1,17 @@
+/* Check the error when 'omp_interop_t' is not defined and the variant function
+   is found via Argument-dependent lookup; in that case, 'g' is not yet resolved
+   to a decl but is an indentifier node. Hence, the location is suboptimal, but
+   we get at least an error.  */
+
+namespace N {
+  class C{
+    public:
+  };
+  void g(C *c);
+}
+
+#pragma omp declare variant (g) match (construct={dispatch}) adjust_args (need_device_ptr: c) append_args (interop(target))
+void f3(N::C *c);
+
+/* { dg-error "30: argument 2 of 'g' must be of 'omp_interop_t'" "" { target *-*-* } .-3 }  */
+/* { dg-note "108: 'append_args' specified here" "" { target *-*-* } .-4 }  */
diff --git a/gcc/testsuite/g++.dg/gomp/append-args-5.C b/gcc/testsuite/g++.dg/gomp/append-args-5.C
new file mode 100644
index 0000000000000000000000000000000000000000..d5a3a78bb758ef16d94f3ac0b17e1446b3410d77
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/append-args-5.C
@@ -0,0 +1,72 @@
+/* { dg-additional-options "-fdump-tree-gimple" }  */
+
+/* Check that adjust_args applies to the right argument,
+   if C++ inserts a 'this' pointer.  */
+
+#if __cplusplus >= 201103L
+# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__
+#else
+# define __GOMP_UINTPTR_T_ENUM
+#endif
+
+typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM
+{
+  omp_interop_none = 0,
+  __omp_interop_t_max__ = __UINTPTR_MAX__
+} omp_interop_t;
+
+
+struct t1 {
+  void f1(int *x, int *y, int *z, omp_interop_t);
+  #pragma omp declare variant(f1) match(construct={dispatch}) \
+                                  adjust_args(need_device_ptr : y) \
+                                  append_args( interop(target))
+  void g1(int *x, int *y, int *z);
+};
+
+struct t2 {
+  void f2(int *x, int *y, int *z, omp_interop_t, ...);
+  #pragma omp declare variant(f2) match(construct={dispatch}) \
+                                  adjust_args(need_device_ptr : x, y, z) \
+                                  append_args( interop(prefer_type("cuda","hip","hsa"),target, targetsync))
+  void g2(int *x, int *y, int *z, ...);
+};
+
+
+omp_interop_t obj1, obj2;
+
+void test(int *a1, int *b1, int *c1,
+          int *a2, int *b2, int *c2,
+          int *a3, int *b3, int *c3,
+          int *x1, int *x2, int *x3,
+          int *y1, int *y2, int *y3)
+{
+  struct t1 s1;
+  struct t2 s2;
+
+  #pragma omp dispatch interop(obj1)
+   s1.g1 (a1, b1, c1);
+
+  #pragma omp dispatch interop(obj2) device(5)
+   s2.g2 (a2, b2, c2, y1, y2, y3);
+}
+
+
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_default_device \\(\\);" 2 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(D\.\[0-9\]+\\);" 3 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(5\\);" 1 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "obj1.\[0-9\] = obj1;" 2 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "obj2.\[0-9\] = obj2;" 1 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_interop_int \\(obj1.\[0-9\], -5, 0B\\);" 1 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "__builtin_omp_get_mapped_ptr" 4 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(b1, D\.\[0-9\]+\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(c2, 5\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(b2, 5\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "D\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(a2, 5\\);" 1 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "t1::f1 \\(&s1, a1, D\.\[0-9\]+, c1, obj1.\[0-9\]\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "t2::f2 \\(&s2, D\.\[0-9\]+, D\.\[0-9\]+, D\.\[0-9\]+, obj2.\[0-9\], y1, y2, y3\\);" 1 "gimple" } }  */
diff --git a/gcc/testsuite/g++.dg/gomp/append-args-6.C b/gcc/testsuite/g++.dg/gomp/append-args-6.C
new file mode 100644
index 0000000000000000000000000000000000000000..039d9faaf04d8d2d6d5bf59dd7bc9510bc3b5de6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/append-args-6.C
@@ -0,0 +1,34 @@
+#if __cplusplus >= 201103L
+# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__
+#else
+# define __GOMP_UINTPTR_T_ENUM
+#endif
+
+typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM
+{
+  omp_interop_none = 0,
+  __omp_interop_t_max__ = __UINTPTR_MAX__
+} omp_interop_t;
+
+void f1(omp_interop_t &) { }
+/* { dg-error "argument 1 of 'f1' must be of 'omp_interop_t'" "" { target c } .-1 }  */
+/* { dg-note "initializing argument 1 of 'void f1\\(omp_interop_t&\\)'" "" { target c++ } .-2 }  */
+#pragma omp declare variant(f1) match(construct={dispatch}) \
+                                append_args(interop(prefer_type({attr("ompx_fun")})))
+void g1(void);
+/* { dg-note "'append_args' specified here" "" { target c } .-2 }  */
+/* { dg-error "cannot bind non-const lvalue reference of type 'omp_interop_t&' to an rvalue of type 'omp_interop_t'" "" { target c++ } .-4 }  */
+
+int f2(omp_interop_t);
+#pragma omp declare variant(f2) append_args(interop(prefer_type("cuda"))) \
+                                match(construct={dispatch})
+int g2(void) { return 5; }
+
+int foo (omp_interop_t &obj1)
+{
+  int res;
+
+  #pragma omp dispatch interop(obj1) device(11)  /* { dg-error "'obj1' must be of 'omp_interop_t'" }  */
+    res = g2();
+  return res;
+}
diff --git a/gcc/testsuite/g++.dg/gomp/append-args-7.C b/gcc/testsuite/g++.dg/gomp/append-args-7.C
new file mode 100644
index 0000000000000000000000000000000000000000..97df32ea2475afefa6e910702b4b450e7406b0ac
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/append-args-7.C
@@ -0,0 +1,113 @@
+/* { dg-do compile { target c++11 } } */
+/* { dg-additional-options "-fdump-tree-gimple" }  */
+
+
+#if __cplusplus >= 201103L
+# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__
+#else
+# define __GOMP_UINTPTR_T_ENUM
+#endif
+
+typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM
+{
+  omp_interop_none = 0,
+  __omp_interop_t_max__ = __UINTPTR_MAX__
+} omp_interop_t;
+
+typedef enum omp_interop_fr_t
+{
+  omp_ifr_cuda = 1,
+  omp_ifr_cuda_driver = 2,
+  omp_ifr_opencl = 3,
+  omp_ifr_sycl = 4,
+  omp_ifr_hip = 5,
+  omp_ifr_level_zero = 6,
+  omp_ifr_hsa = 7,
+  omp_ifr_last = omp_ifr_hsa
+} omp_interop_fr_t;
+
+
+template<typename T2>
+float repl0(T2, T2);
+#pragma omp declare variant(repl0) match(construct={dispatch}) append_args(interop(target,prefer_type(1,5,4)), interop(targetsync))
+float base0();
+
+
+
+template<typename T, typename T2>
+float repl1(T x, T2 y, T2 z) { return sizeof(x) + y == z; }
+#pragma omp declare variant(repl1) match(construct={dispatch}) append_args(interop(target,prefer_type(1,5,4,sizeof(T))), interop(targetsync))
+template<typename T>
+float base1(T x) { return x + 42; }
+
+
+
+template<typename T, typename T2, typename T3>
+void repl3inval(T, T2, T3);
+#pragma omp declare variant(repl3inval) match(construct={dispatch}) adjust_args(nothing : y) \
+        append_args(interop(prefer_type({fr(3), attr("ompx_nop")},{fr(2)},{attr("ompx_all")}),target,targetsync))
+template<typename T, typename T2>
+void base2inval(T x, T2 y);
+
+
+
+template<typename T>
+void repl99(T);
+#pragma omp declare variant(repl99) match(construct={dispatch}) \
+        append_args(interop(target, targetsync, prefer_type("cuda")))
+template<typename T>
+void base99();
+
+
+
+template<typename T, typename T2, typename T3>
+void repl2(T, T2, T3, T3);
+#pragma omp declare variant(repl2) match(construct={dispatch}) adjust_args(need_device_ptr : y) \
+        append_args(interop(target, targetsync, prefer_type(1)), \
+                    interop(prefer_type({fr(3), attr("ompx_nop")},{fr(2)},{attr("ompx_all")})))
+template<typename T, typename T2>
+void base2(T x, T2 y);
+
+
+omp_interop_t obj2, obj3;
+
+void
+test_it (char *str, int i, int *ip, float *fp, omp_interop_t obj1)
+{
+  #pragma omp dispatch interop(obj2, obj1) device(99)
+    base0 ();
+
+  float f2;
+  #pragma omp dispatch interop(obj1, obj2) device(14)
+    f2 = base1 (*fp);
+  fp[0] = f2;
+
+  #pragma omp dispatch interop(obj1)
+    base2inval (str, i);
+
+  #pragma omp dispatch interop(obj2) device(21)
+    base99<double>();
+
+  #pragma omp dispatch interop(obj3, obj1) device(31)
+    base2(fp, ip);
+}
+
+
+
+/* { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = __builtin_omp_get_default_device \\(\\);" 5 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(99\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(14\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(21\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(31\\);" 1 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(D\\.\[0-9\]+\\);" 6 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = __builtin_omp_get_interop_int \\(obj1, -5, 0B\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = __builtin_omp_get_mapped_ptr \\(ip, 31\\);" 1 "gimple" } }  */
+
+/* { dg-final { scan-tree-dump-times "repl0<omp_interop_t> \\(obj2\\.\[0-9\], obj1\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "f2 = repl1<float, omp_interop_t> \\(D\\.\[0-9\]+, obj1, obj2\\.\[0-9\]\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "repl3inval<char\\*, int, omp_interop_t> \\(str, i, obj1\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "repl99<omp_interop_t> \\(obj2\\.\[0-9\]\\);" 1 "gimple" } }  */
+/* { dg-final { scan-tree-dump-times "repl2<float\\*, int\\*, omp_interop_t> \\(fp, D\\.\[0-9\]+, obj3\\.\[0-9\], obj1\\);" 1 "gimple" } }  */
diff --git a/gcc/testsuite/g++.dg/init/array66.C b/gcc/testsuite/g++.dg/init/array66.C
new file mode 100644
index 0000000000000000000000000000000000000000..ca38df815dea7f18539f2c2303eb0a507f5443aa
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/array66.C
@@ -0,0 +1,33 @@
+// PR c++/117827
+// { dg-do run { target c++11 } }
+
+struct C {
+  int c;
+  static int d, e;
+  C () : c (0) { ++d; }
+  C (const C &) = delete;
+  C &operator= (const C &) = delete;
+  ~C () { ++e; }
+};
+int C::d, C::e;
+
+C *
+foo (C *p)
+{
+  delete[] p;
+  throw 1;
+}
+
+int
+main ()
+{
+  try
+    {
+      foo (new C[1] {});
+    }
+  catch (...)
+    {
+    }
+  if (C::d != C::e)
+    __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/init/no-elide4.C b/gcc/testsuite/g++.dg/init/no-elide4.C
new file mode 100644
index 0000000000000000000000000000000000000000..9377d9f01611961b959b70999f58e1cd7ffcf7d3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/no-elide4.C
@@ -0,0 +1,11 @@
+// PR c++/114619
+// { dg-do "compile" { target c++11 } }
+// { dg-options "-fno-elide-constructors" }
+
+struct X {
+  X(const X&) {}
+};
+extern X x;
+void foo () {
+  new X[1]{x};
+}
diff --git a/gcc/testsuite/g++.dg/modules/builtin-8.C b/gcc/testsuite/g++.dg/modules/builtin-8.C
new file mode 100644
index 0000000000000000000000000000000000000000..ff91104e4a96457b90f35d77da41b213f9ec3ea9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/builtin-8.C
@@ -0,0 +1,9 @@
+// { dg-additional-options -fmodules-ts }
+module;
+#include <stdarg.h>
+export module builtins;
+// { dg-module-cmi builtins }
+
+export {
+  using ::va_list;
+}
diff --git a/gcc/testsuite/g++.dg/modules/contracts-5_a.C b/gcc/testsuite/g++.dg/modules/contracts-5_a.C
new file mode 100644
index 0000000000000000000000000000000000000000..2ff6701ff3f1e7365d12a31d18a572cbec9a6565
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/contracts-5_a.C
@@ -0,0 +1,8 @@
+// PR c++/108205
+// Test that the implicitly declared handle_contract_violation function is
+// properly matched with a later declaration in an importing TU.
+// { dg-additional-options "-fmodules -fcontracts -fcontract-continuation-mode=on" }
+// { dg-module-cmi test }
+
+export module test;
+export inline void foo(int x) noexcept [[ pre: x != 0 ]] {}
diff --git a/gcc/testsuite/g++.dg/modules/contracts-5_b.C b/gcc/testsuite/g++.dg/modules/contracts-5_b.C
new file mode 100644
index 0000000000000000000000000000000000000000..0e794b8ae453879c0ce12a669234872a3184d505
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/contracts-5_b.C
@@ -0,0 +1,20 @@
+// PR c++/108205
+// { dg-module-do run }
+// { dg-additional-options "-fmodules -fcontracts -fcontract-continuation-mode=on" }
+
+#include <experimental/contract>
+import test;
+
+bool saw_violation = false;
+void handle_contract_violation(const std::experimental::contract_violation& v) {
+  saw_violation = true;
+}
+
+int main() {
+  foo(10);
+  if (saw_violation)
+    __builtin_abort();
+  foo(0);
+  if (!saw_violation)
+    __builtin_abort();
+}
diff --git a/gcc/testsuite/g++.dg/modules/dr2867-1_a.H b/gcc/testsuite/g++.dg/modules/dr2867-1_a.H
new file mode 100644
index 0000000000000000000000000000000000000000..0d76407815d3f7577c9dfde4f59209f1fb2fae11
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/dr2867-1_a.H
@@ -0,0 +1,88 @@
+// CWG2867 - Order of initialization for structured bindings.
+// { dg-additional-options -fmodule-header }
+// { dg-module-cmi {} }
+
+#define assert(X) do { if (!(X)) __builtin_abort(); } while (0)
+
+namespace std {
+  template<typename T> struct tuple_size;
+  template<int, typename> struct tuple_element;
+}
+
+extern int a, c, d, i;
+
+struct A {
+  A () { assert (c == 3); ++c; }
+  ~A () { ++a; }
+  template <int I> int &get () const { assert (c == 5 + I); ++c; return i; }
+};
+
+template <> struct std::tuple_size <A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, A> { using type = int; };
+template <> struct std::tuple_size <const A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, const A> { using type = int; };
+
+struct B {
+  B () { assert (c >= 1 && c <= 2); ++c; }
+  ~B () { assert (c >= 9 && c <= 10); ++c; }
+};
+
+struct C {
+  constexpr C () {}
+  constexpr C (const C &) {}
+  template <int I> int &get () const { assert (d == 1 + I); ++d; return i; }
+};
+
+template <> struct std::tuple_size <C> { static const int value = 3; };
+template <int I> struct std::tuple_element <I, C> { using type = int; };
+template <> struct std::tuple_size <const C> { static const int value = 3; };
+template <int I> struct std::tuple_element <I, const C> { using type = int; };
+
+inline A
+foo (const B &, const B &)
+{
+  A a;
+  assert (c == 4);
+  ++c;
+  return a;
+}
+
+constexpr C
+foo (const C &, const C &)
+{
+  return C {};
+}
+
+inline int
+bar (int &x, int y)
+{
+  x = y;
+  return y;
+}
+
+inline int
+baz (int &x, int y)
+{
+  assert (x == y);
+  return y;
+}
+
+struct E {
+  ~E () { assert (a == 2); }
+};
+
+namespace {
+E e;
+int c1 = bar (c, 1);
+const auto &[x, y, z, w] = foo (B {}, B {});
+int c2 = baz (c, 11);
+int d1 = bar (d, 1);
+const auto &[s, t, u] = foo (C {}, C {});
+int d2 = baz (d, 4);
+int c3 = bar (c, 1);
+auto [x2, y2, z2, w2] = foo (B {}, B {});
+int c4 = baz (c, 11);
+int d3 = bar (d, 1);
+auto [s2, t2, u2] = foo (C {}, C {});
+int d4 = baz (d, 4);
+}
diff --git a/gcc/testsuite/g++.dg/modules/dr2867-1_b.C b/gcc/testsuite/g++.dg/modules/dr2867-1_b.C
new file mode 100644
index 0000000000000000000000000000000000000000..f31f7abdb4f2455bf3d3c7b858da34f7c9893e81
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/dr2867-1_b.C
@@ -0,0 +1,13 @@
+// CWG2867 - Order of initialization for structured bindings.
+// { dg-do run }
+// { dg-additional-options "-fmodules-ts" }
+
+import "dr2867-1_a.H";
+
+int a, c, d, i;
+
+int
+main ()
+{
+  assert (a == 0);
+}
diff --git a/gcc/testsuite/g++.dg/modules/dr2867-2_a.H b/gcc/testsuite/g++.dg/modules/dr2867-2_a.H
new file mode 100644
index 0000000000000000000000000000000000000000..f9cb388de1cb05462db82335b9bfe1b03cb0292d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/dr2867-2_a.H
@@ -0,0 +1,79 @@
+// CWG2867 - Order of initialization for structured bindings.
+// { dg-additional-options -fmodule-header }
+// { dg-module-cmi {} }
+
+#define assert(X) do { if (!(X)) __builtin_abort(); } while (0)
+
+namespace std {
+  template<typename T> struct tuple_size;
+  template<int, typename> struct tuple_element;
+}
+
+extern int a, c;
+
+struct C {
+  C () { assert (c >= 5 && c <= 17 && (c - 5) % 4 == 0); ++c; }
+  ~C () { assert (c >= 8 && c <= 20 && c % 4 == 0); ++c; }
+};
+
+struct D {
+  D () { assert (c >= 7 && c <= 19 && (c - 7) % 4 == 0); ++c; }
+  ~D () { assert (a % 5 != 4); ++a; }
+};
+
+struct A {
+  A () { assert (c == 3); ++c; }
+  ~A () { assert (a % 5 == 4); ++a; }
+  template <int I> D get (const C & = C{}) const { assert (c == 6 + 4 * I); ++c; return D {}; }
+};
+
+template <> struct std::tuple_size <A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, A> { using type = D; };
+template <> struct std::tuple_size <const A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, const A> { using type = D; };
+
+struct B {
+  B () { assert (c >= 1 && c <= 2); ++c; }
+  ~B () { assert (c >= 21 && c <= 22); ++c; }
+};
+
+inline A
+foo (const B &, const B &)
+{
+  A a;
+  assert (c == 4);
+  ++c;
+  return a;
+}
+
+inline int
+bar (int &x, int y)
+{
+  x = y;
+  return y;
+}
+
+inline int
+baz (int &x, int y)
+{
+  assert (x == y);
+  return y;
+}
+
+struct E {
+  ~E () { assert (a == 5); }
+};
+
+namespace {
+E e;
+int c1 = bar (c, 1);
+// First B::B () is invoked twice, then foo called, which invokes A::A ().
+// e is reference bound to the A::A () constructed temporary.
+// Then 4 times (in increasing I):
+//   C::C () is invoked, get is called, D::D () is invoked, C::~C () is
+//   invoked.
+// After that B::~B () is invoked twice.
+// At exit time D::~D () is invoked 4 times, then A::~A ().
+const auto &[x, y, z, w] = foo (B {}, B {});
+int c2 = baz (c, 23);
+}
diff --git a/gcc/testsuite/g++.dg/modules/dr2867-2_b.C b/gcc/testsuite/g++.dg/modules/dr2867-2_b.C
new file mode 100644
index 0000000000000000000000000000000000000000..2de9f19bdf789977bc10725b12ea3c35404de9b1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/dr2867-2_b.C
@@ -0,0 +1,13 @@
+// CWG2867 - Order of initialization for structured bindings.
+// { dg-do run }
+// { dg-additional-options "-fmodules-ts" }
+
+import "dr2867-2_a.H";
+
+int a, c;
+
+int
+main ()
+{
+  assert (a == 0);
+}
diff --git a/gcc/testsuite/g++.dg/modules/dr2867-3_a.H b/gcc/testsuite/g++.dg/modules/dr2867-3_a.H
new file mode 100644
index 0000000000000000000000000000000000000000..50d182b802f8886a4541b1a1d8f936bc5834978b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/dr2867-3_a.H
@@ -0,0 +1,91 @@
+// CWG2867 - Order of initialization for structured bindings.
+// { dg-require-effective-target c++20 }
+// { dg-additional-options -fmodule-header }
+// { dg-module-cmi {} }
+// { dg-add-options tls }
+// { dg-require-effective-target tls_runtime }
+
+#define assert(X) do { if (!(X)) __builtin_abort(); } while (0)
+
+namespace std {
+  template<typename T> struct tuple_size;
+  template<int, typename> struct tuple_element;
+}
+
+extern int a, c, d, i;
+
+struct A {
+  A () { assert (c == 3); ++c; }
+  ~A () { ++a; }
+  template <int I> int &get () const { assert (c == 5 + I); ++c; return i; }
+};
+
+template <> struct std::tuple_size <A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, A> { using type = int; };
+template <> struct std::tuple_size <const A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, const A> { using type = int; };
+
+struct B {
+  B () { assert (c >= 1 && c <= 2); ++c; }
+  ~B () { assert (c >= 9 && c <= 10); ++c; }
+};
+
+struct C {
+  constexpr C () {}
+  constexpr C (const C &) {}
+  template <int I> int &get () const { assert (d == 1 + I); ++d; return i; }
+};
+
+template <> struct std::tuple_size <C> { static const int value = 3; };
+template <int I> struct std::tuple_element <I, C> { using type = int; };
+template <> struct std::tuple_size <const C> { static const int value = 3; };
+template <int I> struct std::tuple_element <I, const C> { using type = int; };
+
+inline A
+foo (const B &, const B &)
+{
+  A a;
+  assert (c == 4);
+  ++c;
+  return a;
+}
+
+constexpr C
+foo (const C &, const C &)
+{
+  return C {};
+}
+
+inline int
+bar (int &x, int y)
+{
+  x = y;
+  return y;
+}
+
+inline int
+baz (int &x, int y)
+{
+  assert (x == y);
+  return y;
+}
+
+struct E {
+  ~E () { assert (a == 2); }
+};
+
+namespace {
+thread_local E e;
+thread_local int c1 = bar (c, 1);
+thread_local const auto &[x, y, z, w] = foo (B {}, B {});
+thread_local int c2 = baz (c, 11);
+thread_local int d1 = bar (d, 1);
+thread_local const auto &[s, t, u] = foo (C {}, C {});
+thread_local int d2 = baz (d, 4);
+thread_local int c3 = bar (c, 1);
+thread_local auto [x2, y2, z2, w2] = foo (B {}, B {});
+thread_local int c4 = baz (c, 11);
+thread_local int d3 = bar (d, 1);
+thread_local auto [s2, t2, u2] = foo (C {}, C {});
+thread_local int d4 = baz (d, 4);
+}
diff --git a/gcc/testsuite/g++.dg/modules/dr2867-3_b.C b/gcc/testsuite/g++.dg/modules/dr2867-3_b.C
new file mode 100644
index 0000000000000000000000000000000000000000..261ee3cbc09200357097af3b89bee657d117aafb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/dr2867-3_b.C
@@ -0,0 +1,19 @@
+// CWG2867 - Order of initialization for structured bindings.
+// { dg-do run { target c++20 } }
+// { dg-additional-options "-fmodules-ts" }
+// { dg-add-options tls }
+// { dg-require-effective-target tls_runtime }
+
+import "dr2867-3_a.H";
+
+int a, c, d, i;
+
+int
+main ()
+{
+  volatile int u = c1 + x + y + z + w + c2;
+  u += d1 + s + t + u + d2;
+  u += c3 + x2 + y2 + z2 + w2 + c4;
+  u += d3 + s2 + t2 + u2 + d4;
+  assert (a == 0);
+}
diff --git a/gcc/testsuite/g++.dg/modules/dr2867-4_a.H b/gcc/testsuite/g++.dg/modules/dr2867-4_a.H
new file mode 100644
index 0000000000000000000000000000000000000000..e5eba5518c99e58474b28655aff4682cfb8eba01
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/dr2867-4_a.H
@@ -0,0 +1,82 @@
+// CWG2867 - Order of initialization for structured bindings.
+// { dg-require-effective-target c++20 }
+// { dg-additional-options -fmodule-header }
+// { dg-module-cmi {} }
+// { dg-add-options tls }
+// { dg-require-effective-target tls_runtime }
+
+#define assert(X) do { if (!(X)) __builtin_abort(); } while (0)
+
+namespace std {
+  template<typename T> struct tuple_size;
+  template<int, typename> struct tuple_element;
+}
+
+extern int a, c;
+
+struct C {
+  C () { assert (c >= 5 && c <= 17 && (c - 5) % 4 == 0); ++c; }
+  ~C () { assert (c >= 8 && c <= 20 && c % 4 == 0); ++c; }
+};
+
+struct D {
+  D () { assert (c >= 7 && c <= 19 && (c - 7) % 4 == 0); ++c; }
+  ~D () { assert (a % 5 != 4); ++a; }
+};
+
+struct A {
+  A () { assert (c == 3); ++c; }
+  ~A () { assert (a % 5 == 4); ++a; }
+  template <int I> D get (const C & = C{}) const { assert (c == 6 + 4 * I); ++c; return D {}; }
+};
+
+template <> struct std::tuple_size <A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, A> { using type = D; };
+template <> struct std::tuple_size <const A> { static const int value = 4; };
+template <int I> struct std::tuple_element <I, const A> { using type = D; };
+
+struct B {
+  B () { assert (c >= 1 && c <= 2); ++c; }
+  ~B () { assert (c >= 21 && c <= 22); ++c; }
+};
+
+inline A
+foo (const B &, const B &)
+{
+  A a;
+  assert (c == 4);
+  ++c;
+  return a;
+}
+
+inline int
+bar (int &x, int y)
+{
+  x = y;
+  return y;
+}
+
+inline int
+baz (int &x, int y)
+{
+  assert (x == y);
+  return y;
+}
+
+struct E {
+  ~E () { assert (a == 5); }
+};
+
+namespace {
+thread_local E e;
+thread_local int c1 = bar (c, 1);
+// First B::B () is invoked twice, then foo called, which invokes A::A ().
+// e is reference bound to the A::A () constructed temporary.
+// Then 4 times (in increasing I):
+//   C::C () is invoked, get is called, D::D () is invoked, C::~C () is
+//   invoked.
+// After that B::~B () is invoked twice.
+// At exit time D::~D () is invoked 4 times, then A::~A ().
+thread_local const auto &[x, y, z, w] = foo (B {}, B {});
+thread_local int c2 = baz (c, 23);
+}
diff --git a/gcc/testsuite/g++.dg/modules/dr2867-4_b.C b/gcc/testsuite/g++.dg/modules/dr2867-4_b.C
new file mode 100644
index 0000000000000000000000000000000000000000..5fbf4762687eab159ca0aecc2a3e5287d5b840a1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/dr2867-4_b.C
@@ -0,0 +1,16 @@
+// CWG2867 - Order of initialization for structured bindings.
+// { dg-do run { target c++20 } }
+// { dg-additional-options "-fmodules-ts" }
+// { dg-add-options tls }
+// { dg-require-effective-target tls_runtime }
+
+import "dr2867-4_a.H";
+
+int a, c;
+
+int
+main ()
+{
+  volatile int u = c1 + c2;
+  assert (a == 0);
+}
diff --git a/gcc/testsuite/g++.dg/modules/internal-4_b.C b/gcc/testsuite/g++.dg/modules/internal-4_b.C
index 86bec294fc83b216906e0a74c7d8f15ac75b35f6..81fc65a69bddca776b61a80482b99dc83a32851e 100644
--- a/gcc/testsuite/g++.dg/modules/internal-4_b.C
+++ b/gcc/testsuite/g++.dg/modules/internal-4_b.C
@@ -80,13 +80,14 @@ void in_function_body() { struct {} x; }  // OK
 auto in_initializer = []{};  // OK
 
 #if __cplusplus >= 202002L
-decltype([]{}) d_lambda;  // { dg-error "exposes TU-local entity" "" { xfail *-*-* } }
+decltype([]{}) d_lambda;  // { dg-error "exposes TU-local entity" "" { target c++20 } }
+using alias_lambda = decltype([]{});  // { dg-error "exposes TU-local entity" "" { target c++20 } }
 
 template <typename T>
 concept in_constraint_expression = requires {
   // Strictly by the standard this is currently ill-formed
   // (this is a constraint-expression not an initializer)
-  // but I don't think that is intended.
+  // but I don't think that is intended; see CWG2988.
   []{};  // { dg-bogus "exposes TU-local entity" }
 };
 #endif
diff --git a/gcc/testsuite/g++.dg/modules/lambda-8.h b/gcc/testsuite/g++.dg/modules/lambda-8.h
new file mode 100644
index 0000000000000000000000000000000000000000..c4bb20dcf1f9c3fba3ed9ea205ebda53f7cc3bdd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/lambda-8.h
@@ -0,0 +1,8 @@
+// PR c++/116568
+
+template <typename> struct S {
+  template <typename> using t = decltype([]{});
+};
+
+// 't' does not currently have a mangling scope, but should not ICE
+using t = S<int>::t<int>;
diff --git a/gcc/testsuite/g++.dg/modules/lambda-8_a.H b/gcc/testsuite/g++.dg/modules/lambda-8_a.H
new file mode 100644
index 0000000000000000000000000000000000000000..d20958ee140fae9bbdd0dedee3a13825690621da
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/lambda-8_a.H
@@ -0,0 +1,5 @@
+// PR c++/116568
+// { dg-additional-options "-fmodules-ts -std=c++20" }
+// { dg-module-cmi {} }
+
+#include "lambda-8.h"
diff --git a/gcc/testsuite/g++.dg/modules/lambda-8_b.C b/gcc/testsuite/g++.dg/modules/lambda-8_b.C
new file mode 100644
index 0000000000000000000000000000000000000000..7ace4944dd2d0a8e3cd2f0986f37baa723735613
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/lambda-8_b.C
@@ -0,0 +1,7 @@
+// PR c++/116568
+// { dg-additional-options "-fmodules-ts -fno-module-lazy -std=c++20" }
+
+#include "lambda-8.h"
+import "lambda-8_a.H";
+
+// { dg-error "conflicting global module declaration" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/g++.dg/modules/lambda-9.h b/gcc/testsuite/g++.dg/modules/lambda-9.h
new file mode 100644
index 0000000000000000000000000000000000000000..fccd36da6d13d5f9000db75adadd2f9f4a37b36f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/lambda-9.h
@@ -0,0 +1,3 @@
+// CWG2988
+template <typename T>
+concept C = requires { []{}; };
diff --git a/gcc/testsuite/g++.dg/modules/lambda-9_a.H b/gcc/testsuite/g++.dg/modules/lambda-9_a.H
new file mode 100644
index 0000000000000000000000000000000000000000..da0fa3b31f2da4a3d1c3a5a313f2036662770792
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/lambda-9_a.H
@@ -0,0 +1,4 @@
+// { dg-additional-options "-fmodule-header -std=c++20" }
+// { dg-module-cmi {} }
+
+#include "lambda-9.h"
diff --git a/gcc/testsuite/g++.dg/modules/lambda-9_b.C b/gcc/testsuite/g++.dg/modules/lambda-9_b.C
new file mode 100644
index 0000000000000000000000000000000000000000..6f2186421f7d394398aa5d98a533c4f1dae0440f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/lambda-9_b.C
@@ -0,0 +1,6 @@
+// { dg-additional-options "-fmodules -std=c++20 -fno-module-lazy" }
+
+#include "lambda-9.h"
+import "lambda-9_a.H";
+
+static_assert(C<int>);
diff --git a/gcc/testsuite/g++.dg/modules/pr98893_a.H b/gcc/testsuite/g++.dg/modules/pr98893_a.H
new file mode 100644
index 0000000000000000000000000000000000000000..062ab6d9cccb1790c91d58e01b81a53e8c99b4b6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/pr98893_a.H
@@ -0,0 +1,9 @@
+// { dg-additional-options "-fmodule-header" }
+// { dg-module-cmi {} }
+
+struct S {
+  ~S() {}
+};
+inline void foo() {
+  static S a[1];
+}
diff --git a/gcc/testsuite/g++.dg/modules/pr98893_b.C b/gcc/testsuite/g++.dg/modules/pr98893_b.C
new file mode 100644
index 0000000000000000000000000000000000000000..9065589bdfbf28c0e0389d615a7163475cf9fd45
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/pr98893_b.C
@@ -0,0 +1,10 @@
+// { dg-additional-options "-fmodules" }
+
+import "pr98893_a.H";
+static S b[1];
+int main() {
+  foo();
+}
+
+// { dg-final { scan-assembler {__tcf_ZZ3foovE1a:} } }
+// { dg-final { scan-assembler {__tcf_ZL1b:} } }
diff --git a/gcc/testsuite/g++.dg/other/anon-union6.C b/gcc/testsuite/g++.dg/other/anon-union6.C
new file mode 100644
index 0000000000000000000000000000000000000000..d1cde30f790d3383bcafb57bf9190ce5244267bf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/anon-union6.C
@@ -0,0 +1,13 @@
+// PR c++/117153
+// { dg-do compile }
+
+template<typename T>
+void f() {
+  union {
+    union {
+      T d;
+    };
+  };
+  (void) (d + 0);
+}
+template void f<double>();
diff --git a/gcc/testsuite/g++.dg/other/anon-union7.C b/gcc/testsuite/g++.dg/other/anon-union7.C
new file mode 100644
index 0000000000000000000000000000000000000000..e89334a5d0e74810ea407d620ec1c6113cd5fc73
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/anon-union7.C
@@ -0,0 +1,16 @@
+// PR c++/117153
+// { dg-do compile { target c++11 } }
+
+using U = union { union { int a; }; };
+
+U
+foo ()
+{
+  return {};
+}
+
+void
+g ()
+{
+  [[maybe_unused]] auto u = foo ();
+}
diff --git a/gcc/testsuite/g++.dg/other/pr117516.C b/gcc/testsuite/g++.dg/other/pr117516.C
new file mode 100644
index 0000000000000000000000000000000000000000..2bbfeebbb7931a1c4d1b12c10fb3d659469c3567
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/pr117516.C
@@ -0,0 +1,21 @@
+// PR c++/117516
+// { dg-do compile }
+
+struct S10 { char a; };
+#define A(m, n) struct S##m { struct S##n a, b; };
+#define B(m) A(m##1, m##0) A(m##2, m##1) A(m##3, m##2) A(m##4, m##3) \
+	     A(m##5, m##4) A(m##6, m##5) A(m##7, m##6) A(m##8, m##7)
+B(1)
+#define S20 S18
+B(2)
+#define S30 S28
+B(3)
+#define S40 S38
+A(41, 40) A(42, 41) A(43, 42)
+
+int
+main ()
+{
+  struct S43 s;
+  __builtin_memset (&s, 0, sizeof (s));
+}
diff --git a/gcc/testsuite/g++.dg/parse/defarg18.C b/gcc/testsuite/g++.dg/parse/defarg18.C
new file mode 100644
index 0000000000000000000000000000000000000000..62c8f15f2843b85f9ea035e3927c523a51798840
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/defarg18.C
@@ -0,0 +1,48 @@
+// PR c++/118319
+// { dg-do "compile" { target c++11 } }
+
+// Template case, that used to crash.
+
+template <int>
+struct S {
+  friend void foo1 (int a = []{}());  // { dg-error "specifies default|only declaration" }
+  friend void foo3 (int a,	      // { dg-error "specifies default|only declaration" }
+		    int b = []{}(),
+		    int c = []{}());
+};
+
+void foo1 (int a) {}
+void foo3 (int a, int b, int c) {}
+
+void hello (){
+  S<0> t;
+  foo1 ();
+  foo3 (1, 2);
+}
+
+
+// Template case, that already worked.
+
+template <int>
+struct T {
+  friend void bar (int a = []{}()); // { dg-error "specifies default|only declaration" }
+};
+
+void hallo (){
+  T<0> t;
+  bar (); // { dg-error "not declared" }
+}
+
+
+// Non template case, that already worked.
+
+struct NoTemplate {
+  friend void baz (int a = []{}()); // { dg-error "specifies default|could not convert" }
+};
+
+void baz (int a) {} // { dg-error "only declaration" }
+
+void ola (){
+  NoTemplate t;
+  baz (); // { dg-error "void value not ignored" }
+}
diff --git a/gcc/testsuite/g++.dg/parse/defarg18a.C b/gcc/testsuite/g++.dg/parse/defarg18a.C
new file mode 100644
index 0000000000000000000000000000000000000000..9157a4d5158fef99ec74a6de7bc94bc68180a3d7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/defarg18a.C
@@ -0,0 +1,33 @@
+// PR c++/118319 - With -fpermissive
+// { dg-do "compile" { target c++11 } }
+// { dg-additional-options "-fpermissive" }
+
+// Template case, that used to crash.
+// Check that we error-out even with -fpermissive.
+
+template <int>
+struct S { // { dg-error "instantiating erroneous template" }
+  friend void foo1 (int a = []{}());  // { dg-warning "specifies default|only declaration" }
+};
+
+void foo1 (int a) {}
+
+void hello (){
+  S<0> t;
+  foo1 ();
+}
+
+
+// Non template case, that already worked.
+// Check that errors are demoted to warnings.
+
+struct NoTemplate {
+  friend void baz (int a = 1); // { dg-warning "specifies default" }
+};
+
+void baz (int a) {} // { dg-warning "only declaration" }
+
+void ola (){
+  NoTemplate t;
+  baz ();
+}
diff --git a/gcc/testsuite/g++.dg/torture/pr118320.C b/gcc/testsuite/g++.dg/torture/pr118320.C
new file mode 100644
index 0000000000000000000000000000000000000000..228d79860b5dc43102f56cdb16cedce5d141e449
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr118320.C
@@ -0,0 +1,15 @@
+// { dg-additional-options "-fno-tree-sra" } */
+
+struct T{
+  long f[2];
+};
+void f1(int);
+void g(T&);
+void f1()
+{
+  T a;
+  a.~T(); // To force the clobber
+  a.f[1] = 1;
+  T b = a;
+  g(b);
+}
diff --git a/gcc/testsuite/g++.dg/warn/Woverloaded-virt1.C b/gcc/testsuite/g++.dg/warn/Woverloaded-virt1.C
index 92f8327b9d0573f44e51577384a387b7888d2f14..9091bfabc967aa0ea1d05813cedd4b0c4b72c02d 100644
--- a/gcc/testsuite/g++.dg/warn/Woverloaded-virt1.C
+++ b/gcc/testsuite/g++.dg/warn/Woverloaded-virt1.C
@@ -5,10 +5,12 @@ class Foo
 {
 public:
     virtual void f(int);	// { dg-warning "hidden" }
+    void g(int);		// Not virtual, so no warning
 };
 
 class Bar : public Foo
 {
 public:
     virtual void f(short);	// { dg-message "by" }
+    virtual void g(short);
 };
diff --git a/gcc/testsuite/g++.dg/warn/Woverloaded-virt10.C b/gcc/testsuite/g++.dg/warn/Woverloaded-virt10.C
new file mode 100644
index 0000000000000000000000000000000000000000..42b8b0f97886a2a67d72080e99144fbcfff0ecb5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Woverloaded-virt10.C
@@ -0,0 +1,11 @@
+// PR c++/117114 - Test case from PR c++/117114
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -Woverloaded-virtual }
+
+struct Troops { virtual ~Troops(); };
+struct Control { virtual int GetControl() const = 0; };
+struct Army : Troops, Control { int GetControl() const override; };
+
+struct VirtualControl : virtual Control {
+  int GetControl() const override;
+};
diff --git a/gcc/testsuite/g++.dg/warn/Woverloaded-virt11.C b/gcc/testsuite/g++.dg/warn/Woverloaded-virt11.C
new file mode 100644
index 0000000000000000000000000000000000000000..4d96b318cc2ce21f4bd2122bb7a130be2121f2d5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Woverloaded-virt11.C
@@ -0,0 +1,25 @@
+// PR c++/109918 - More tests with multiple inheritance
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -Woverloaded-virtual }
+
+struct Troops { virtual ~Troops(); };
+struct Control {
+  virtual int GetControl() const { return 42; } // { dg-warning "was hidden" }
+};
+struct Army : Troops, Control {
+  template<class T> void GetControl() const; // { dg-message "by" }
+};
+
+
+struct A {
+  virtual void get() const;
+};
+struct B {
+  virtual void get() const;
+  virtual void get(char) const; // { dg-warning "was hidden" }
+};
+
+struct C : A, B {
+  virtual void get() const; // { dg-message "by" }
+  virtual void get(int) const;
+};
diff --git a/gcc/testsuite/g++.dg/warn/Woverloaded-virt12.C b/gcc/testsuite/g++.dg/warn/Woverloaded-virt12.C
new file mode 100644
index 0000000000000000000000000000000000000000..3cfe22c03ec5f5b21badc82604a0490a35cad580
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Woverloaded-virt12.C
@@ -0,0 +1,23 @@
+// PR c++/109918 - Test covariant return types
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -Woverloaded-virtual }
+
+struct Big { virtual ~Big () {} };
+struct Smaller : Big {};
+
+// Single inheritance case
+struct Foo {
+  virtual Big* getMe() const;
+};
+struct Bar : Foo {
+  virtual Smaller* getMe() const;
+};
+
+// Multiple inheritance case
+struct Troops { virtual ~Troops(); };
+struct Control {
+  virtual Big* GetControl() const;
+};
+struct Army : Troops, Control {
+  virtual Smaller* GetControl() const;
+};
diff --git a/gcc/testsuite/g++.dg/warn/Woverloaded-virt13.C b/gcc/testsuite/g++.dg/warn/Woverloaded-virt13.C
new file mode 100644
index 0000000000000000000000000000000000000000..fb421e17dc34d338e06614ab54721b6d81657188
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Woverloaded-virt13.C
@@ -0,0 +1,28 @@
+// PR c++/117114 - Reduced version of another bootstrap error
+// Unrelated methods can have the same DECL_VINDEX when the class hierarchy
+// depth is 2 or more.
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -Woverloaded-virtual }
+
+class HIRFullVisitor;
+class HIRTypeVisitor;
+
+struct FullVisitable {
+  virtual void accept_vis (HIRFullVisitor &vis) = 0;
+};
+
+struct Node {
+  virtual ~Node() {}
+};
+
+struct Type : Node, FullVisitable
+{
+  using FullVisitable::accept_vis;
+  virtual void accept_vis (HIRTypeVisitor &vis) = 0;
+};
+
+struct TypePath : Type
+{
+  void accept_vis (HIRFullVisitor &vis) override;
+  void accept_vis (HIRTypeVisitor &vis) override;
+};
diff --git a/gcc/testsuite/g++.dg/warn/Woverloaded-virt5.C b/gcc/testsuite/g++.dg/warn/Woverloaded-virt5.C
new file mode 100644
index 0000000000000000000000000000000000000000..01cd562609a8f9e7a0a47578390f4e5bc64e6afc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Woverloaded-virt5.C
@@ -0,0 +1,12 @@
+// PR c++/109918 - Exact PR testcase
+// { dg-do compile }
+// { dg-additional-options -Wall }
+
+struct A {
+  virtual operator int() { return 42; }
+  virtual operator char() = 0;
+};
+
+struct B : public A {
+  operator char() { return 'A'; }
+};
diff --git a/gcc/testsuite/g++.dg/warn/Woverloaded-virt6.C b/gcc/testsuite/g++.dg/warn/Woverloaded-virt6.C
new file mode 100644
index 0000000000000000000000000000000000000000..c18049e3a92bd040af702a1036fd3d759c1c373f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Woverloaded-virt6.C
@@ -0,0 +1,12 @@
+// PR c++/109918 - PR testcase with -Woverloaded-virtual=2
+// { dg-do compile }
+// { dg-additional-options -Woverloaded-virtual=2 }
+
+struct A {
+  virtual operator int() { return 42; }
+  virtual operator char() = 0;
+};
+
+struct B : public A {
+  operator char() { return 'A'; }
+};
diff --git a/gcc/testsuite/g++.dg/warn/Woverloaded-virt7.C b/gcc/testsuite/g++.dg/warn/Woverloaded-virt7.C
new file mode 100644
index 0000000000000000000000000000000000000000..39b0899c2d29b8074ff62fa40c1c69b2467bebe1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Woverloaded-virt7.C
@@ -0,0 +1,37 @@
+// PR c++/109918 - Test different CV-quals, usage of typedefs, and templates
+// { dg-do compile }
+// { dg-additional-options -Woverloaded-virtual }
+
+struct A {
+  virtual operator char() { return 'a'; }
+  virtual operator char() const { return 'b'; } // { dg-warning "was hidden" }
+  virtual operator int() { return 42; }
+};
+
+struct B : public A {
+  operator char() { return 'A'; } // { dg-note "operator char()" }
+  operator int() { return 43; }
+};
+
+typedef char MyChar;
+struct C : public A {
+  operator MyChar() { return 'A'; } // { dg-note "operator MyChar()" }
+  operator int() { return 43; }
+};
+
+struct D : public A {
+  template<class T>
+  operator T() { return T(); }
+};
+int d = D();
+
+struct AA {
+  virtual char func(char) { return 'a'; }
+  virtual char func(char) const { return 'b'; } // { dg-warning "was hidden" }
+  virtual int func(int) { return 42; }
+};
+
+struct BB : public AA {
+  char func(char) { return 'A'; } // { dg-note "by" }
+  int func(int) { return 43; }
+};
diff --git a/gcc/testsuite/g++.dg/warn/Woverloaded-virt8.C b/gcc/testsuite/g++.dg/warn/Woverloaded-virt8.C
new file mode 100644
index 0000000000000000000000000000000000000000..51af2dae77ca4facbf77ee94261cd1e02bdae268
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Woverloaded-virt8.C
@@ -0,0 +1,15 @@
+// Identified when investigating PR c++/109918: no warning was emitted due to
+// an incorrect early return in warn_hidden.
+// { dg-additional-options -Wall }
+
+struct Foo
+{
+  virtual void f(int); // { dg-warning "hidden" }
+  virtual void g() {}
+};
+
+struct Bar : Foo
+{
+  virtual void f(short); // { dg-message "by" }
+  virtual void g() {}
+};
diff --git a/gcc/testsuite/g++.dg/warn/Woverloaded-virt9.C b/gcc/testsuite/g++.dg/warn/Woverloaded-virt9.C
new file mode 100644
index 0000000000000000000000000000000000000000..6d315c63a08e62ea20b9e68bb60e2a5aa53519ea
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Woverloaded-virt9.C
@@ -0,0 +1,14 @@
+// PR c++/109918: Non virtual overloads in derived classes that don't override
+// anything shouldn't cause warnings, even at -Woverloaded-virtual=2
+// { dg-additional-options -Woverloaded-virtual=2 }
+
+struct Foo
+{
+  virtual void g() {}
+};
+
+struct Bar : Foo
+{
+  virtual void g() {}
+  void g(int) {}
+};
diff --git a/gcc/testsuite/g++.dg/warn/Wvexing-parse10.C b/gcc/testsuite/g++.dg/warn/Wvexing-parse10.C
new file mode 100644
index 0000000000000000000000000000000000000000..3fbe88b7d00b284b0fcf3c965bd123517b53ac04
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wvexing-parse10.C
@@ -0,0 +1,9 @@
+// PR c++/118718
+// { dg-do compile { target c++14 } }
+
+void
+fn ()
+{
+  auto f1 () -> auto;
+  auto f2 (); // { dg-warning "empty parentheses" }
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr118429.c b/gcc/testsuite/gcc.c-torture/compile/pr118429.c
new file mode 100644
index 0000000000000000000000000000000000000000..da7fcf9362d69be39978885acf27673ec3a0c023
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr118429.c
@@ -0,0 +1,7 @@
+void h(long, long, long, long, long, long, long, long, long, long);
+long i(long, long, long, long, long, long, long, long, long, long);
+void f(long a0, long a1, long a2, long a3, long a4, long a5,
+       long a6, long a7, long a8, long a9) {
+  i(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
+  h(a0, 1, 1, 1, 1, 1, 1, 1, 0, 0);
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr117432.c b/gcc/testsuite/gcc.c-torture/execute/pr117432.c
new file mode 100644
index 0000000000000000000000000000000000000000..9f39a93355f4f38a7d4939bf0bcec431216aa099
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr117432.c
@@ -0,0 +1,71 @@
+/* PR ipa/117432 */
+
+#include <stdarg.h>
+
+long long r;
+
+__attribute__((noipa)) void
+baz (int tag, ...)
+{
+  va_list ap;
+  va_start (ap, tag);
+  if (!r)
+    r = va_arg (ap, long long);
+  else
+    r = va_arg (ap, int);
+  va_end (ap);
+}
+
+void
+foo (void)
+{
+  baz (1, -1, 0);
+}
+
+void
+bar (void)
+{
+  baz (1, -1LL, 0);
+}
+
+__attribute__((noipa)) void
+qux (...)
+{
+  va_list ap;
+  va_start (ap);
+  if (!r)
+    r = va_arg (ap, long long);
+  else
+    r = va_arg (ap, int);
+  va_end (ap);
+}
+
+void
+corge (void)
+{
+  qux (-2, 0);
+}
+
+void
+fred (void)
+{
+  qux (-2LL, 0);
+}
+
+int
+main ()
+{
+  bar ();
+  if (r != -1LL)
+    __builtin_abort ();
+  foo ();
+  if (r != -1)
+    __builtin_abort ();
+  r = 0;
+  fred ();
+  if (r != -2LL)
+    __builtin_abort ();
+  corge ();
+  if (r != -2)
+    __builtin_abort ();
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr117498.c b/gcc/testsuite/gcc.c-torture/execute/pr117498.c
new file mode 100644
index 0000000000000000000000000000000000000000..085c6b6684bc96ec082cf31d9c78a58324b750cc
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr117498.c
@@ -0,0 +1,35 @@
+/* PR middle-end/117498 */
+
+int a, d, f;
+char g;
+volatile int c = 1;
+
+int
+foo ()
+{
+  if (c == 0)
+    return -1;
+  return 1;
+}
+
+void
+bar (int h, int i, char *k, char *m)
+{
+  for (; d < i; d += 2)
+    for (int j = 0; j < h; j++)
+      m[j] = k[4 * j];
+}
+
+void
+baz (long h)
+{
+  char n = 0;
+  bar (h, 4, &n, &g);
+}
+
+int
+main ()
+{
+  f = foo ();
+  baz ((unsigned char) f - 4);
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr118638.c b/gcc/testsuite/gcc.c-torture/execute/pr118638.c
new file mode 100644
index 0000000000000000000000000000000000000000..5c0dbca5c09af963afec342c12816aa14c3aab91
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr118638.c
@@ -0,0 +1,20 @@
+/* PR rtl-optimization/118638 */
+
+__attribute__((noipa)) int
+foo (int x)
+{
+  int a = x != -3, b, c;
+  a *= 3;
+  b = 2 * x - 9;
+  a = a + b;
+  a = ~a;
+  c = a & 1;
+  return -c;
+}
+
+int
+main ()
+{
+  if (foo (0) != -1)
+    __builtin_abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/fixed-point/pr117611.c b/gcc/testsuite/gcc.dg/fixed-point/pr117611.c
new file mode 100644
index 0000000000000000000000000000000000000000..c76093f12d19fa0f9d2e78a69a1f014e26a2eef2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fixed-point/pr117611.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+_Accum acc1 (_Accum x)
+{
+    return x << 16;
+}
diff --git a/gcc/testsuite/gcc.dg/fold-perm-2.c b/gcc/testsuite/gcc.dg/fold-perm-2.c
index 1a4ab4065de0c495f7545106cf4cfdcbb201b3b3..9fd809ee296785b5d562531458f741eddb65d9ac 100644
--- a/gcc/testsuite/gcc.dg/fold-perm-2.c
+++ b/gcc/testsuite/gcc.dg/fold-perm-2.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O -fdump-tree-fre1" } */
+/* { dg-additional-options "--param=riscv-two-source-permutes" { target riscv*-*-* } } */
 
 typedef int veci __attribute__ ((vector_size (4 * sizeof (int))));
 typedef unsigned int vecu __attribute__ ((vector_size (4 * sizeof (unsigned int))));
diff --git a/gcc/testsuite/gcc.dg/gimplefe-56.c b/gcc/testsuite/gcc.dg/gimplefe-56.c
new file mode 100644
index 0000000000000000000000000000000000000000..72c66ae463dddda53e3a2db68486f87c92c4b919
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gimplefe-56.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+
+_Bool __GIMPLE (ssa,startwith("optimized")) g1(int i)
+{
+  _Bool _1;
+  _Bool _2;
+
+  __BB(2):
+  _1 = i_3(D) == 1;
+  _2 = ~_1;
+  return _2;
+}
+
+signed char __GIMPLE (ssa,startwith("optimized")) g2(signed char i)
+{
+  signed char _1;
+  signed char _2;
+
+  __BB(2):
+  _1 = i_3(D);
+  _2 = -_1;
+  return _2;
+}
diff --git a/gcc/testsuite/gcc.dg/goacc/implied-copy.c b/gcc/testsuite/gcc.dg/goacc/implied-copy.c
new file mode 100644
index 0000000000000000000000000000000000000000..98adbcb1987c5031aaef7c98f6bd66284be33c34
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/goacc/implied-copy.c
@@ -0,0 +1,29 @@
+/* { dg-additional-options "-fdump-tree-gimple" } */
+
+/* Test for float _Complex and double _Complex types.  */
+int
+main(void)
+{
+  int i;
+  float _Complex fc[100];
+  float _Complex s1;
+  double _Complex dc[100];
+  double _Complex s2;
+
+#pragma acc parallel reduction (+:s1, s2)
+  for (i = 0; i < 10; i++)
+    {
+      s1 += fc[i];
+      s2 += dc[i];
+    }
+#pragma acc serial reduction (+:s1, s2)
+  for (i = 0; i < 10; i++)
+    {
+      s1 += fc[i];
+      s2 += dc[i];
+    }
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "map\\(tofrom:s1 \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "map\\(tofrom:s2 \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */
diff --git a/gcc/testsuite/gcc.dg/gomp/append-args-1.c b/gcc/testsuite/gcc.dg/gomp/append-args-1.c
new file mode 100644
index 0000000000000000000000000000000000000000..81dd1061aa15c2d7ba50a943f271814d8379909c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/append-args-1.c
@@ -0,0 +1,70 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-std=gnu17" } */
+
+/* The errors might be a bit questionable, but still a resonable solution
+   for questionable code ...  */
+
+/* For all empty args, assume C < C23; in C++/C23 it becomes the same as '…(void)'.  */
+
+/* This uses append_args, once with adjust_args and once without.  */
+
+typedef enum omp_interop_t
+{
+  omp_interop_none = 0,
+  __omp_interop_t_max__ = __UINTPTR_MAX__
+} omp_interop_t;
+
+
+/* (A) No prototype for the variant but for the base function.  */
+
+void variant_fn1();
+#pragma omp declare variant(variant_fn1) match(construct={dispatch}) append_args(interop(target)) \
+                                         adjust_args(need_device_ptr: x,y)
+void bar1(int *x, int *y);
+/* { dg-error "variant 'variant_fn1' and base 'bar1' have incompatible types" "" { target *-*-* } .-3 }  */
+
+
+void variant_fn2();
+#pragma omp declare variant(variant_fn2) match(construct={dispatch}) append_args(interop(target))
+void bar2(int *x, int *y);
+/* { dg-error "variant 'variant_fn2' and base 'bar2' have incompatible types" "" { target *-*-* } .-2 }  */
+
+
+
+/* (B) No prototype for the variant nor for the base function.  */
+
+void variant_fn3();  /* { dg-error "argument 1 of 'variant_fn3' must be of 'omp_interop_t'" }  */
+#pragma omp declare variant(variant_fn3) match(construct={dispatch}) append_args(interop(target)) \
+                                         adjust_args(need_device_ptr: x,y)
+void bar3();
+/* { dg-error "'x' undeclared here \\(not in a function\\)" "" { target *-*-* } .-2 }  */
+/* { dg-error "'y' undeclared here \\(not in a function\\)" "" { target *-*-* } .-3 }  */
+/* { dg-note "'append_args' specified here" "" { target *-*-* } .-5 }  */
+
+
+void variant_fn4();  /* { dg-error "argument 1 of 'variant_fn4' must be of 'omp_interop_t'" }  */
+#pragma omp declare variant(variant_fn4) match(construct={dispatch}) append_args(interop(target))
+void bar4();
+/* { dg-note "'append_args' specified here" "" { target *-*-* } .-2 }  */
+
+
+
+/* (C) Only a prototype on the variant-function side.  */
+
+void variant_fn5(omp_interop_t, omp_interop_t);
+#pragma omp declare variant(variant_fn5) match(construct={dispatch}) append_args(interop(target)) \
+                                         adjust_args(need_device_ptr: x,y)
+void bar5();
+/* { dg-error "variant 'variant_fn5' and base 'bar5' have incompatible types" "" { target *-*-* } .-3 }  */
+
+
+void variant_fn6(omp_interop_t, omp_interop_t);
+#pragma omp declare variant(variant_fn6) match(construct={dispatch}) append_args(interop(target))
+void bar6();
+/* { dg-error "variant 'variant_fn6' and base 'bar6' have incompatible types" "" { target *-*-* } .-2 }  */
+
+
+void variant_fn7(int *, int, omp_interop_t, omp_interop_t);
+#pragma omp declare variant(variant_fn7) match(construct={dispatch}) append_args(interop(target))
+void bar7();
+/* { dg-error "variant 'variant_fn7' and base 'bar7' have incompatible types" "" { target *-*-* } .-2 }  */
diff --git a/gcc/testsuite/gcc.dg/pr b/gcc/testsuite/gcc.dg/pr
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/gcc/testsuite/gcc.dg/pr108692.c b/gcc/testsuite/gcc.dg/pr108692.c
index 13a27496ad9f90dbd0bd5cb043856bbad3b5a4c1..eeee220328172fa68f4ecb6981adec0f9fa8c5db 100644
--- a/gcc/testsuite/gcc.dg/pr108692.c
+++ b/gcc/testsuite/gcc.dg/pr108692.c
@@ -1,4 +1,5 @@
 /* PR tree-optimization/108692 */
+/* PR tree-optimization/118727 */
 /* { dg-do run } */
 /* { dg-options "-O2 -ftree-vectorize" } */
 
diff --git a/gcc/testsuite/gcc.dg/pr109393.c b/gcc/testsuite/gcc.dg/pr109393.c
index b2dd5a0b645c1a3bdc0ed1f0b81eee3bc3fbcf71..108d30913894fb17ea6bb862c9f5aea72f7920f3 100644
--- a/gcc/testsuite/gcc.dg/pr109393.c
+++ b/gcc/testsuite/gcc.dg/pr109393.c
@@ -20,4 +20,5 @@ int bar(int *a, int j)
   return (&a[j + 1] - 2) == &a[k];
 }
 
-/* { dg-final { scan-tree-dump-times "return 1;" 3 "optimized" } } */
+/* The pattern is not applied on ilp32 targets (PR116845).  */
+/* { dg-final { scan-tree-dump-times "return 1;" 3 "optimized" { xfail { ilp32 } } } } */
diff --git a/gcc/testsuite/gcc.dg/pr113207.c b/gcc/testsuite/gcc.dg/pr113207.c
new file mode 100644
index 0000000000000000000000000000000000000000..81f53d8fcc2f65b962f40dfe5cad6c673d5fdc7c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr113207.c
@@ -0,0 +1,10 @@
+/* { dg-compile } */
+/* { dg-require-effective-target lto } */
+/* { dg-options "-flto -fchecking" }  */
+
+typedef struct cl_lispunion *cl_object;
+struct cl_lispunion {};
+cl_object cl_error() __attribute__((noreturn));
+volatile cl_object cl_coerce_value0;
+void cl_coerce() { cl_error(); }
+void L66safe_canonical_type(cl_object volatile);
diff --git a/gcc/testsuite/gcc.dg/pr114052-1.c b/gcc/testsuite/gcc.dg/pr114052-1.c
new file mode 100644
index 0000000000000000000000000000000000000000..98e93bf670da79c5b746131418aa15c5396995d0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr114052-1.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target signal } */
+/* { dg-require-effective-target alarm } */
+/* { dg-options "-O2" } */
+
+#include <stdint.h>
+#include <unistd.h>
+#include <signal.h>
+#include <stdlib.h>
+
+volatile int y;
+void __attribute__((noipa)) put(int x)
+{
+  if (y)
+    __builtin_printf ("%i\n", x);
+}
+
+void __attribute__((noipa)) f(void)
+{
+  int counter = 0;
+  while (1) {
+      if (counter >= 2) continue;
+      put (counter++);
+  }
+}
+
+void do_exit (int i)
+{
+  exit (0);
+}
+
+int main()
+{
+  struct sigaction s;
+  sigemptyset (&s.sa_mask);
+  s.sa_handler = do_exit;
+  s.sa_flags = 0;
+  sigaction (SIGALRM, &s, NULL);
+  alarm (1);
+  f();
+}
diff --git a/gcc/testsuite/gcc.dg/pr116357.c b/gcc/testsuite/gcc.dg/pr116357.c
new file mode 100644
index 0000000000000000000000000000000000000000..07effa13254825abc8ffea326a3e3bb8aa191ab5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr116357.c
@@ -0,0 +1,10 @@
+/* PR c/116357 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+typedef int A __attribute__((aligned (2 * alignof (int))));
+A a[4];	/* { dg-error "alignment of array elements is greater than element size" } */
+typedef volatile int B __attribute__((aligned (2 * alignof (int))));
+B b[4];	/* { dg-error "alignment of array elements is greater than element size" } */
+typedef const int C __attribute__((aligned (2 * alignof (int))));
+C c[4];	/* { dg-error "alignment of array elements is greater than element size" } */
diff --git a/gcc/testsuite/gcc.dg/pr117239.c b/gcc/testsuite/gcc.dg/pr117239.c
new file mode 100644
index 0000000000000000000000000000000000000000..0ff33d19677e67b5b1fca90495a3b229bf036ab7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr117239.c
@@ -0,0 +1,42 @@
+/* PR rtl-optimization/117239 */
+/* { dg-do run } */
+/* { dg-options "-fno-inline -O2" } */
+/* { dg-additional-options "-fschedule-insns" { target i?86-*-* x86_64-*-* } } */
+
+int a, b, c = 1, d;
+
+int
+foo (void)
+{
+  return a;
+}
+
+struct A {
+  int e, f, g, h;
+  short i;
+  int j;
+};
+
+void
+bar (int x, struct A y)
+{
+  if (y.j == 1)
+    c = 0;
+}
+
+int
+baz (struct A x)
+{
+  return b;
+}
+
+int
+main ()
+{
+  struct A k = { 0, 0, 0, 0, 0, 1 };
+  d = baz (k);
+  bar (foo (), k);
+  if (c != 0)
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr118490.c b/gcc/testsuite/gcc.dg/pr118490.c
new file mode 100644
index 0000000000000000000000000000000000000000..4ae0dacefeea9b7516e2f200d66997b0d9f261a9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr118490.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math -frounding-math -Wlogical-op" } */
+
+double exp(double);
+int foo(int v) {
+	return v && exp(1.) < 2.;
+}
diff --git a/gcc/testsuite/gcc.dg/pr118643.c b/gcc/testsuite/gcc.dg/pr118643.c
new file mode 100644
index 0000000000000000000000000000000000000000..ff2b081ae0b4ea7dc6c7b81459975e0397e7be7c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr118643.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+typedef __attribute__((__vector_size__(1))) unsigned char V;
+
+V x;
+void foo()
+{
+  V v = x;
+  x = *(V *)(&v - 1);
+}
diff --git a/gcc/testsuite/gcc.dg/pr118684.c b/gcc/testsuite/gcc.dg/pr118684.c
new file mode 100644
index 0000000000000000000000000000000000000000..28fd76e366dcf13da1ce65a94881c213ea25f7e2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr118684.c
@@ -0,0 +1,12 @@
+/* { dg-do run { target automatic_stack_alignment } } */
+/* { dg-options "-O2" } */
+
+typedef int v4si __attribute__((vector_size(16)));
+v4si x;
+int main ()
+{
+  int b __attribute__((aligned(16)));
+  b = 0;
+  x = *(v4si *)&b;
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr118692.c b/gcc/testsuite/gcc.dg/pr118692.c
new file mode 100644
index 0000000000000000000000000000000000000000..45fba560b35c5d7dfa22430ceb42b7a1f0614337
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr118692.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+_Complex double cf;
+
+void
+foo(char c)
+{
+  cf += *(_Complex double *)__builtin_memcpy(8143523003042804629LL + &c, 0, 0);
+}
diff --git a/gcc/testsuite/gcc.dg/pr118695.c b/gcc/testsuite/gcc.dg/pr118695.c
new file mode 100644
index 0000000000000000000000000000000000000000..55e3b767a21c45a4c742f0e9909276b3264ad02d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr118695.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+void * g(int obj)
+{
+  char *t = (char*)&obj;
+  t -= 1;
+  return *(int**)t;
+}
diff --git a/gcc/testsuite/gcc.dg/pr118696.c b/gcc/testsuite/gcc.dg/pr118696.c
new file mode 100644
index 0000000000000000000000000000000000000000..092af6f94173e3327b8a564bc4a75658cba6fd72
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr118696.c
@@ -0,0 +1,131 @@
+/* PR target/118696 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#if __CHAR_BIT__ == 8
+#if __SIZEOF_INT128__ == 16 && __SIZEOF_LONG_LONG__ == 8
+#define D __int128
+#define S long long
+#define M 0x8000000000000000ULL
+#define C 64
+#elif __SIZEOF_LONG_LONG__ == 8 && __SIZEOF_INT__ == 4
+#define D long long
+#define S int
+#define M 0x80000000U
+#define C 32
+#endif
+#endif
+
+#ifdef D
+static inline D
+combine (unsigned S x, unsigned S y)
+{
+  return (unsigned D) x << C | y;
+}
+
+__attribute__((noipa)) D
+smin (D x, D y)
+{
+  return x < y ? x : y;
+}
+
+__attribute__((noipa)) D
+smax (D x, D y)
+{
+  return x > y ? x : y;
+}
+
+__attribute__((noipa)) unsigned D
+umin (unsigned D x, unsigned D y)
+{
+  return x < y ? x : y;
+}
+
+__attribute__((noipa)) unsigned D
+umax (unsigned D x, unsigned D y)
+{
+  return x > y ? x : y;
+}
+#endif
+
+int
+main ()
+{
+#ifdef D
+  unsigned S vals[] = {
+    0, 12, 42, M, M | 12, M | 42
+  };
+  unsigned char expected[] = {
+    4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+    2,2,2,2,0,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,
+    2,2,2,2,2,2,2,2,0,0,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,
+    2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
+    2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,4,3,3,3,3,3,3,3,3,3,3,3,
+    3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,4,3,3,3,3,3,3,
+    3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,4,3,
+    3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,
+    0,0,0,4,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+    0,0,0,0,0,0,0,0,4,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+    2,2,2,2,0,0,0,0,0,0,0,0,0,4,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,
+    2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,4,3,3,3,3,3,3,3,2,2,2,2,2,2,
+    2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,4,3,3,3,3,3,3,2,2,
+    2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,4,3,3,3,
+    3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,
+    0,4,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,4,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,4,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+    2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,2,2,2,2,2,2,2,2,2,2,
+    2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,3,3,3,3,3,
+    3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,4,
+    3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,0,0,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,0,0,0,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,0,0,0,0,4,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,4,3,3,3,3,3,3,3,3,3,3,3,3,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,4,3,3,3,3,3,3,3,
+    3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,4,3,3,
+    3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,
+    0,0,4,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,
+    0,0,0,0,0,0,0,4,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,0,0,0,0,0,0,0,0,0,0,4,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,4,3,3,3,3,3,3,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,4,3,3,3,3,3,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,4,3,3,3,3,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    4,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,4,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,4,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4
+  };
+  int m = 0;
+  for (int i = 0; i < 6; ++i)
+    for (int j = 0; j < 6; ++j)
+      for (int k = 0; k < 6; ++k)
+	for (int l = 0; l < 6; ++l)
+	  {
+	    D a = combine (vals[i], vals[j]);
+	    D b = combine (vals[k], vals[l]);
+	    int r = 0;
+	    r |= (smin (a, b) == a) * 1;
+	    r |= (smin (a, b) == b) * 2;
+	    r |= (smax (a, b) == a) * 4;
+	    r |= (smax (a, b) == b) * 8;
+	    r |= (umin (a, b) == a) * 16;
+	    r |= (umin (a, b) == b) * 32;
+	    r |= (umax (a, b) == a) * 64;
+	    r |= (umax (a, b) == b) * 128;
+	    switch (r)
+	      {
+	      case 102: r = 0; break;
+	      case 105: r = 1; break;
+	      case 150: r = 2; break;
+	      case 153: r = 3; break;
+	      case 255: r = 4; break;
+	      default: __builtin_abort ();
+	      }
+	    if (r != expected[m++])
+	      __builtin_abort ();
+	  }
+#endif
+}
diff --git a/gcc/testsuite/gcc.dg/pr118727.c b/gcc/testsuite/gcc.dg/pr118727.c
new file mode 100644
index 0000000000000000000000000000000000000000..2ee5fa782362f428e0653903e2e28b371eab237a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr118727.c
@@ -0,0 +1,32 @@
+/* PR tree-optimization/118727 */
+/* { dg-do run } */
+/* { dg-options "-O2 -ftree-vectorize" } */
+
+__attribute__((noipa)) int
+foo (signed char *x, signed char *y, int n)
+{
+  int i, r = 0;
+  signed char a, b;
+  for (i = 0; i < n; i++)
+    {
+      a = x[i];
+      b = y[i];
+      /* Slightly twisted from pr108692.c.  */
+      int c = (unsigned int)(unsigned char) a - (signed int)(signed char) b;
+      r = r + (c < 0 ? -c : c);
+    }
+  return r;
+}
+
+int
+main ()
+{
+  signed char x[64] = {}, y[64] = {};
+  if (__CHAR_BIT__ != 8 || __SIZEOF_INT__ != 4)
+    return 0;
+  x[32] = -1;
+  y[32] = -128;
+  if (foo (x, y, 64) != 383)
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr54346.c b/gcc/testsuite/gcc.dg/pr54346.c
index 5ec0609f1e507bb8feb31986ad874b614fd141dd..b78e0533ac219226a0e7f5a4aa517874e23b82ae 100644
--- a/gcc/testsuite/gcc.dg/pr54346.c
+++ b/gcc/testsuite/gcc.dg/pr54346.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O -fdump-tree-dse1 -Wno-psabi" } */
+/* { dg-additional-options "--param=riscv-two-source-permutes" { target riscv*-*-* } } */
 
 typedef int veci __attribute__ ((vector_size (4 * sizeof (int))));
 
diff --git a/gcc/testsuite/gcc.dg/sarif-output/bad-binary-op.py b/gcc/testsuite/gcc.dg/sarif-output/bad-binary-op.py
index fe139e62e41715824fa4ece23daaa6ec6346f567..2281c06a6c943eb7af8775d21caa5f481b2ccb28 100644
--- a/gcc/testsuite/gcc.dg/sarif-output/bad-binary-op.py
+++ b/gcc/testsuite/gcc.dg/sarif-output/bad-binary-op.py
@@ -45,7 +45,7 @@ def test_error_location(sarif):
     assert result['level'] == 'error'
 
     assert result['message']['text'] \
-        == "invalid operands to binary + (have 'S' {aka 'struct s'} and 'T' {aka 'struct t'})"
+        == "invalid operands to binary + (have 'S' {{aka 'struct s'}} and 'T' {{aka 'struct t'}})"
     locations = result['locations']
     assert len(locations) == 1
 
@@ -63,8 +63,8 @@ def test_error_location(sarif):
     assert annotations[0]['startLine'] == EXPECTED_LINE
     assert annotations[0]['startColumn'] == 10
     assert annotations[0]['endColumn'] == 22
-    assert annotations[0]['message']['text'] == "S {aka struct s}"
+    assert annotations[0]['message']['text'] == "S {{aka struct s}}"
     assert annotations[1]['startLine'] == EXPECTED_LINE
     assert annotations[1]['startColumn'] == 25
     assert annotations[1]['endColumn'] == 37
-    assert annotations[1]['message']['text'] == "T {aka struct t}"
+    assert annotations[1]['message']['text'] == "T {{aka struct t}}"
diff --git a/gcc/testsuite/gcc.dg/sarif-output/missing-semicolon.py b/gcc/testsuite/gcc.dg/sarif-output/missing-semicolon.py
index 58c0a7d02cd8cfa129be88ba3e8bc0a3d907b95b..a0f848387a22e830125135ab398d9ad36864b279 100644
--- a/gcc/testsuite/gcc.dg/sarif-output/missing-semicolon.py
+++ b/gcc/testsuite/gcc.dg/sarif-output/missing-semicolon.py
@@ -43,7 +43,7 @@ def test_location_relationships(sarif):
     
     result = results[0]
     assert result['level'] == 'error'
-    assert result['message']['text'] == "expected ';' before '}' token"
+    assert result['message']['text'] == "expected ';' before '}}' token"
     locations = result['locations']
     assert len(locations) == 1
 
diff --git a/gcc/testsuite/gcc.dg/sarif-output/multiple-outputs.py b/gcc/testsuite/gcc.dg/sarif-output/multiple-outputs.py
index 8febfac4c7bf165614e6d936b970130ae931dbdb..4de91c2c8ef2ea66d0c444616d0a5a4dab181469 100644
--- a/gcc/testsuite/gcc.dg/sarif-output/multiple-outputs.py
+++ b/gcc/testsuite/gcc.dg/sarif-output/multiple-outputs.py
@@ -36,7 +36,7 @@ def test_result(sarif):
     
     result = results[0]
     assert result['level'] == 'error'
-    assert result['message']['text'] == "expected ';' before '}' token"
+    assert result['message']['text'] == "expected ';' before '}}' token"
     locations = result['locations']
     assert len(locations) == 1
 
diff --git a/gcc/testsuite/gcc.dg/torture/pr112859.c b/gcc/testsuite/gcc.dg/torture/pr112859.c
new file mode 100644
index 0000000000000000000000000000000000000000..18f5bf40cb70dddc129afe2a9975407f2be35d23
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr112859.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ftree-loop-distribution" } */
+
+struct a {
+  char b;
+  int c;
+} f, *i = &f;
+static struct a e[4];
+int *d, **g = &d;
+static int h, j;
+int main()
+{
+  for (; h < 1; h++) {
+    struct a k = {1, 1};
+    for (j = 0; j < 2; j++) {
+      *i = e[h];
+      e[h] = k;
+    }
+    *g = 0;
+  }
+  if (f.c != 1)
+    __builtin_abort();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr115347.c b/gcc/testsuite/gcc.dg/torture/pr115347.c
new file mode 100644
index 0000000000000000000000000000000000000000..2299495144b9dcd93e66d10f504cf963cfe2630b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr115347.c
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ftree-loop-distribution" } */
+
+struct a {
+  int b;
+  int c;
+} d, e[2];
+int f, g, h;
+int main()
+{
+  for (; f < 1; f++) {
+    for (h = 0; h < 2; h++) {
+      d = e[f];
+      g = e[1].c;
+      e[f].c = 1;
+    }
+  }
+  if (d.c != 1)
+    __builtin_abort();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr117113.c b/gcc/testsuite/gcc.dg/torture/pr117113.c
new file mode 100644
index 0000000000000000000000000000000000000000..e90ad034a4d3f5bfe05582c887051a4ff755907f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr117113.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-tree-dce -fno-inline" } */
+
+int a, b, c;
+volatile int d[1];
+void e() {}
+void f(int g) {}
+int main() {
+  int i;
+  for (; b; b--) {
+    for (i = 0; i < 3; i++) {
+      e();
+      f(d[0]);
+      d[0];
+    }
+    if (a)
+      c++;
+  }
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr118662.c b/gcc/testsuite/gcc.dg/torture/pr118662.c
new file mode 100644
index 0000000000000000000000000000000000000000..b9e8cca0aeb55fad5c4cf3422b035bbbcf78783e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr118662.c
@@ -0,0 +1,18 @@
+/* { dg-do run } */
+/* { dg-additional-options "-ftree-slp-vectorize -fno-vect-cost-model" } */
+/* { dg-additional-options "-msse4" { target sse4_runtime} } */
+
+int __attribute__((noipa)) addup(signed char *num) {
+  int val = num[0] + num[1] + num[2] + num[3];
+  if (num[3] >= 0)
+    val++;
+  return val;
+}
+
+int main(int, char *[])
+{
+  signed char num[4] = {1, 1, 1, -1};
+  if (addup(num) != 2)
+    __builtin_abort();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr118717.c b/gcc/testsuite/gcc.dg/torture/pr118717.c
new file mode 100644
index 0000000000000000000000000000000000000000..42dc5ec84f28ae350d47825032f2e52c19b16d0f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr118717.c
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+
+void jj(void);
+int ff1(void) __attribute__((__returns_twice__));
+struct s2 {
+  int prev;
+};
+typedef struct s1 {
+  unsigned interrupt_flag;
+  unsigned interrupt_mask;
+  int tag;
+  int state;
+}s1;
+int ff(void);
+static inline
+int mm(s1 *ec) {
+  if (ff())
+    if (ec->interrupt_flag & ~(ec)->interrupt_mask)
+      return 0;
+}
+void ll(s1 *ec) {
+  int t = 1;
+  int state;
+  if (t)
+  {
+    {
+      s1 *const _ec = ec;
+      struct s2 _tag = {0};
+      if (ff1())
+	state = ec->state;
+      else
+	state = 0;
+      if (!state)
+	mm (ec);
+      _ec->tag = _tag.prev;
+    }
+    if (state)
+      __builtin_exit(0);
+  }
+  jj();
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-and-or.c b/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-and-or.c
index e5dc98e7541d57637439ae12aba3459d67d5807b..99e83d8e5aae16d584df649b1d569e4e3ecb34ed 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-and-or.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-and-or.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O3 -fdump-tree-optimized" } */
+/* { dg-options "-O3 -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */
 
 typedef unsigned long int uint64_t;
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or.c b/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or.c
index c55cfbcc84c8d47fd3f535ef76dca9816203df18..51b7373af0d869f9f6a8c13e6196f9ca4ec9b3d5 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O3 -fdump-tree-optimized" } */
+/* { dg-options "-O3 -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */
 
 typedef unsigned long int uint64_t;
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr117892.c b/gcc/testsuite/gcc.dg/tree-ssa/pr117892.c
new file mode 100644
index 0000000000000000000000000000000000000000..d9b9c15095fc2a2931a0fa86771e216031bbf80b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr117892.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+
+volatile int a;
+void b(int *c) {
+  int *d = 0;
+  *c = 0;
+  *d = 0;
+  __builtin_abort();
+}
+int main() {
+  int f;
+  if (a)
+    b(&f);
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr118517.c b/gcc/testsuite/gcc.dg/tree-ssa/pr118517.c
new file mode 100644
index 0000000000000000000000000000000000000000..3a34f6788a9cb2aef152e75d775905c54e0d452d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr118517.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-ipa-pure-const" } */
+
+void __attribute__((noreturn)) bar(void) {
+  __builtin_unreachable ();
+}
+
+int p;
+void foo() {
+  if (p) bar();
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr118637.c b/gcc/testsuite/gcc.dg/tree-ssa/pr118637.c
new file mode 100644
index 0000000000000000000000000000000000000000..d612b1d906e0c81dc23a438cbf691ed67e2dab8f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr118637.c
@@ -0,0 +1,22 @@
+/* PR tree-optimization/118637 */
+/* { dg-do compile { target clz } } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-times "__builtin_clz|\\.CLZ" 2 "optimized" } } */
+
+__attribute__((noipa)) unsigned
+foo (unsigned x)
+{
+  unsigned result = 0;
+  while (x /= 2)
+    ++result;
+  return result;
+}
+
+__attribute__((noipa)) unsigned
+bar (unsigned x)
+{
+  unsigned result = 0;
+  while (x >>= 1)
+    ++result;
+  return result;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-25.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-25.c
new file mode 100644
index 0000000000000000000000000000000000000000..3e0f013d1e0d63e412af55fb6bca7ba472d0fdce
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-25.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-lim2-details" } */
+
+char x;
+
+long foo (int n)
+{
+  long y = 0;
+  for (int j = 0; j < 1024; ++j)
+    for (int i = 0; i < n; ++i)
+      y += *(long *)&x;
+  return y;
+}
+
+/* Because *(long *)&x may trap we have to preserve execution and
+   only hoist it from the innermost loop (after the header check).  */
+/* { dg-final { scan-tree-dump-not "out of loop 1" "lim2" } } */
+/* { dg-final { scan-tree-dump "out of loop 2" "lim2" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr118653.c b/gcc/testsuite/gcc.dg/vect/pr118653.c
new file mode 100644
index 0000000000000000000000000000000000000000..9322b23a17db05768a03527bb378709452acba21
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr118653.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3 -g" } */
+
+static short func1 (short si1, short si2) {
+  return (si1 - si2);
+}
+unsigned short g_72;
+extern int g_100[];
+short g_173;
+void func_42(void)
+{
+  for (g_173 = 10; g_173 > 0; g_173 = func1 (g_173, 1))
+    for (g_72 = 1; g_72 < 5; g_72++)
+      g_100[g_72] &= 1;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-18.c b/gcc/testsuite/gcc.dg/vect/vect-ifcvt-18.c
index c1d3c27d819335ad0882e5af8005667e6ed2a531..228011ae07bce5dee67f9f56e76001e0bf05ea43 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-18.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-ifcvt-18.c
@@ -1,6 +1,7 @@
 /* { dg-require-effective-target vect_condition } */
 /* { dg-require-effective-target vect_float } */
-/* { dg-additional-options "-Ofast -mavx" { target avx_runtime } } */
+/* { dg-additional-options "-Ofast" { target i?86-*-* x86_64-*-* } } */
+/* { dg-additional-options "-mavx" { target avx_runtime } } */
 
 
 int A0[4] = {36,39,42,45};
diff --git a/gcc/testsuite/gcc.target/aarch64/crypto-alias-1.c b/gcc/testsuite/gcc.target/aarch64/crypto-alias-1.c
new file mode 100644
index 0000000000000000000000000000000000000000..e2662b44e2db0b26f30c44e62c4b873a12a37972
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/crypto-alias-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mcpu=ampere1" } */
+
+__attribute__ ((__always_inline__))
+__attribute__ ((target ("arch=armv8-a+crypto")))
+inline int bar()
+{
+  return 5;
+}
+
+int foo()
+{
+  return bar();
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/pr100056.c b/gcc/testsuite/gcc.target/aarch64/pr100056.c
index 70499772d2857ccc5d05cdda28587ff0ae6b65b3..0b77824da45734c56444f9dd454983690eedb5fd 100644
--- a/gcc/testsuite/gcc.target/aarch64/pr100056.c
+++ b/gcc/testsuite/gcc.target/aarch64/pr100056.c
@@ -1,9 +1,7 @@
 /* PR target/100056 */
 /* { dg-do compile } */
 /* { dg-options "-O2" } */
-/* { dg-final { scan-assembler-not {\t[us]bfiz\tw[0-9]+, w[0-9]+, 11} { xfail *-*-* } } } */
-/* { dg-final { scan-assembler-times {\t[us]bfiz\tw[0-9]+, w[0-9]+, 11} 2 } } */
-/* { dg-final { scan-assembler-times {\tadd\tw[0-9]+, w[0-9]+, w[0-9]+, uxtb\n} 2 } } */
+/* { dg-final { scan-assembler-not {\t[us]bfiz\tw[0-9]+, w[0-9]+, 11} } } */
 
 int
 or_shift_u8 (unsigned char i)
diff --git a/gcc/testsuite/gcc.target/aarch64/simd/armv9p5.c b/gcc/testsuite/gcc.target/aarch64/simd/armv9p5.c
new file mode 100644
index 0000000000000000000000000000000000000000..6df47b8de1cc60d268a0ea3bf03e8a0ada6034e4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/simd/armv9p5.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-march=armv9.5-a" } */
+
+#include "arm_neon.h"
+
+int8x16_t foo (int8x16_t table, uint8x16_t indicies)
+{
+  return vluti2q_laneq_s8 (table, indicies, 1);
+}
+
+float32x4_t bar (float32x4_t a, float32x4_t b)
+{
+  return vaminq_f32 (a, b);
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/dupq_12.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/dupq_12.c
new file mode 100644
index 0000000000000000000000000000000000000000..690cb134ad5cbf047d55c98d9b0f60589bb382d6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/dupq_12.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-require-effective-target aarch64_little_endian } */
+
+#include <arm_sve.h>
+
+svint16_t
+dupq (int x)
+{
+  return svdupq_s16 (x, 0, x, 0, x, 0, 11, 0);
+}
+
+/* { dg-final { scan-assembler {\tmovi\tv[0-9]+\.4s, #?(?:0xb|11)} } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/target_attr_crypto_ice_1.c b/gcc/testsuite/gcc.target/aarch64/target_attr_crypto_ice_1.c
index 3b354c0611092b1fb66e4a9c2098a9806c749825..f13e5e2560cd43aab570ab5d240e4cf1975d2f12 100644
--- a/gcc/testsuite/gcc.target/aarch64/target_attr_crypto_ice_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/target_attr_crypto_ice_1.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -mcpu=thunderx+nofp -march=armv8-a" } */
+/* { dg-prune-output "warning: switch .* conflicts" } */
 
 #include "arm_neon.h"
 
diff --git a/gcc/testsuite/gcc.target/aarch64/target_attr_crypto_ice_2.c b/gcc/testsuite/gcc.target/aarch64/target_attr_crypto_ice_2.c
index d0a62b83351b671d157ec0de083d681394056d79..ab2549228a7fa06aa26592e02d0d2055f6b990ed 100644
--- a/gcc/testsuite/gcc.target/aarch64/target_attr_crypto_ice_2.c
+++ b/gcc/testsuite/gcc.target/aarch64/target_attr_crypto_ice_2.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -mcpu=thunderx+nofp -march=armv8-a" } */
+/* { dg-prune-output "warning: switch .* conflicts" } */
 
 /* Make sure that we don't ICE when dealing with vector parameters
    in a simd-tagged function within a non-simd translation unit.  */
diff --git a/gcc/testsuite/gcc.target/arm/simd/mve-vabs.c b/gcc/testsuite/gcc.target/arm/simd/mve-vabs.c
index f2f9ee3499065e555aa41a1d9ef510840f412294..e85d0b18ee71c6edfad6bab36e673cdb4d437c90 100644
--- a/gcc/testsuite/gcc.target/arm/simd/mve-vabs.c
+++ b/gcc/testsuite/gcc.target/arm/simd/mve-vabs.c
@@ -1,7 +1,7 @@
 /* { dg-do assemble } */
 /* { dg-require-effective-target arm_v8_1m_mve_fp_ok } */
 /* { dg-add-options arm_v8_1m_mve_fp } */
-/* { dg-additional-options "-O3 -funsafe-math-optimizations" } */
+/* { dg-additional-options "-O3 -funsafe-math-optimizations -fdump-tree-optimized" } */
 
 #include <stdint.h>
 #include <arm_mve.h>
@@ -35,10 +35,10 @@ FUNC_FLOAT(f, float, 32, 4, vabs)
 FUNC(f, float, 16, 8, vabs)
 
 /* Taking the absolute value of an unsigned value is a no-op, so half of the
-   integer optimizations actually generate a call to memmove, the other ones a
+   integer optimizations actually generate a call to memcpy, the other ones a
    'vabs'.  */
 /* { dg-final { scan-assembler-times {vabs.s[0-9]+\tq[0-9]+, q[0-9]+} 3 } } */
 /* { dg-final { scan-assembler-times {vabs.f[0-9]+\tq[0-9]+, q[0-9]+} 2 } } */
 /* { dg-final { scan-assembler-times {vldr[bhw].[0-9]+\tq[0-9]+} 5 } } */
 /* { dg-final { scan-assembler-times {vstr[bhw].[0-9]+\tq[0-9]+} 5 } } */
-/* { dg-final { scan-assembler-times {memmove} 3 } } */
+/* { dg-final { scan-tree-dump-times "memcpy" 3 "optimized" } } */
diff --git a/gcc/testsuite/gcc.target/arm/thumb-bitfld1.c b/gcc/testsuite/gcc.target/arm/thumb-bitfld1.c
index 37630f1a1f7ac5a093b42e171abb78f8916ea37f..3548e097611539c88a6ae5b4ddba051728cbd417 100644
--- a/gcc/testsuite/gcc.target/arm/thumb-bitfld1.c
+++ b/gcc/testsuite/gcc.target/arm/thumb-bitfld1.c
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target arm_thumb1_ok } */
-/* { dg-options "-O1 -mthumb" }  */
+/* { dg-options "-O1 -mthumb -std=c17" }  */
 
 struct foo
 {
diff --git a/gcc/testsuite/gcc.target/arm/vfp-1.c b/gcc/testsuite/gcc.target/arm/vfp-1.c
index b4694c786305dbde9fc8d81af8d65303fcc393a1..5bb675e566e8d6c4c7ca926921623d010a7a71f7 100644
--- a/gcc/testsuite/gcc.target/arm/vfp-1.c
+++ b/gcc/testsuite/gcc.target/arm/vfp-1.c
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target arm_fp_dp_ok } */
-/* { dg-options "-O2 -ffp-contract=off" } */
+/* { dg-options "-Os -fno-math-errno -ffp-contract=off" } */
 /* { dg-add-options arm_fp_dp } */
 /* { dg-skip-if "need fp instructions" { *-*-* } { "-mfloat-abi=soft" } { "" } } */
 
diff --git a/gcc/testsuite/gcc.target/i386/force-indirect-call-2.c b/gcc/testsuite/gcc.target/i386/force-indirect-call-2.c
index 2f7023630415b97c5d9c380e43f2ff4adf1bdbad..405c97c800087fe46559dd797d5c4495d57fc787 100644
--- a/gcc/testsuite/gcc.target/i386/force-indirect-call-2.c
+++ b/gcc/testsuite/gcc.target/i386/force-indirect-call-2.c
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -mforce-indirect-call -fPIC" } */
 /* { dg-require-effective-target fpic } */
-/* { dg-final { scan-assembler-times "(?:call|jmp)\[ \\t\]+\\*%" 3 } } */
+/* { dg-final { scan-assembler-times "(?:call|jmp)\[ \\t\]+\\*" 3 } } */
 
 #include "force-indirect-call-1.c"
diff --git a/gcc/testsuite/gcc.target/i386/pr100530.c b/gcc/testsuite/gcc.target/i386/pr100530.c
new file mode 100644
index 0000000000000000000000000000000000000000..005c019912957714385a025d1a54ef8f898c7057
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr100530.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-g" } */
+
+__seg_gs const int var;
+__seg_gs int foo;
diff --git a/gcc/testsuite/gcc.target/i386/pr111673.c b/gcc/testsuite/gcc.target/i386/pr111673.c
new file mode 100644
index 0000000000000000000000000000000000000000..8d8a5a764f0056d94b5ed025f2ae4c580d4aad6b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr111673.c
@@ -0,0 +1,17 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-O2 -fdump-rtl-pro_and_epilogue" } */
+
+/* Verify there is an early return without the prolog and shrink-wrap
+   the function. */
+
+int f (int);
+int
+advance (int dz)
+{
+  if (dz > 0)
+    return (dz + dz) * dz;
+  else
+    return dz * f (dz);
+}
+
+/* { dg-final { scan-rtl-dump-times "Performing shrink-wrapping" 1 "pro_and_epilogue" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr113689-1.c b/gcc/testsuite/gcc.target/i386/pr113689-1.c
index 0424db2dfdca03c7c7786114547f9dc8a38cf979..0ed911393eeacbadfae40100e585edcfb3050e97 100644
--- a/gcc/testsuite/gcc.target/i386/pr113689-1.c
+++ b/gcc/testsuite/gcc.target/i386/pr113689-1.c
@@ -1,5 +1,6 @@
 /* { dg-do run { target { lp64 && fpic } } } */
 /* { dg-options "-O2 -fno-pic -no-pie -fprofile -mcmodel=large" } */
+/* { dg-require-profiling "-fprofile" } */
 /* { dg-skip-if "PR90698" { *-*-darwin* } } */
 /* { dg-skip-if "PR113909" { *-*-solaris2* } } */
 
diff --git a/gcc/testsuite/gcc.target/i386/pr113689-2.c b/gcc/testsuite/gcc.target/i386/pr113689-2.c
index 58688b9a387c84bac14d6217f0d5607b978c155b..decc44a44fb56f488120967580eb05174941274d 100644
--- a/gcc/testsuite/gcc.target/i386/pr113689-2.c
+++ b/gcc/testsuite/gcc.target/i386/pr113689-2.c
@@ -1,5 +1,6 @@
 /* { dg-do run { target { lp64 && fpic } } } */
 /* { dg-options "-O2 -fpic -fprofile -mcmodel=large" } */
+/* { dg-require-profiling "-fprofile" } */
 /* { dg-skip-if "PR90698" { *-*-darwin* } } */
 /* { dg-skip-if "PR113909" { *-*-solaris2* } } */
 
diff --git a/gcc/testsuite/gcc.target/i386/pr113689-3.c b/gcc/testsuite/gcc.target/i386/pr113689-3.c
index 14c906239f9dbcdceefa79f8bf9b8caf2f4b74ac..a904feec13f04f3fcb90316ad410ace079a72c15 100644
--- a/gcc/testsuite/gcc.target/i386/pr113689-3.c
+++ b/gcc/testsuite/gcc.target/i386/pr113689-3.c
@@ -1,5 +1,6 @@
 /* { dg-do run { target { lp64 && fpic } } } */
 /* { dg-options "-O2 -fpic -fprofile -mcmodel=large" } */
+/* { dg-require-profiling "-fprofile" } */
 /* { dg-skip-if "PR90698" { *-*-darwin* } } */
 /* { dg-skip-if "PR113909" { *-*-solaris2* } } */
 
diff --git a/gcc/testsuite/gcc.target/i386/pr114277.c b/gcc/testsuite/gcc.target/i386/pr114277.c
new file mode 100644
index 0000000000000000000000000000000000000000..eb611d26d6af1b8b27fb1dae00995656970a3a08
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr114277.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int a,b;
+void func0(int x) { a=x * (x || b); }
+void func1(int x) { a=x * !(x || b); }
+
+/* { dg-final { scan-assembler-not "or" } } */
+/* { dg-final { scan-assembler-not "cmove" } } */
+
diff --git a/gcc/testsuite/gcc.target/i386/pr115568.c b/gcc/testsuite/gcc.target/i386/pr115568.c
new file mode 100644
index 0000000000000000000000000000000000000000..cedc7ac3843d540c74dcd4a76800cc27f458daa0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr115568.c
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-tree-sink -fno-tree-ter -fschedule-insns" } */
+
+int a, c, d = 1, e, f = 1, h, i, j;
+unsigned b = 1, g;
+int main() {
+  for (; h < 2; h++) {
+    int k = ~(b || 0), l = ((~e - j) ^ a % b) % k, m = (b ^ -1) + e;
+    unsigned o = ~a % ~1;
+    if (f) {
+      l = d;
+      m = 10;
+      i = e;
+      d = -(~e + b);
+      g = o % m;
+      e = -1;
+    n:
+      a = a % ~i;
+      b = ~k;
+      if (!g) {
+        b = e + o % -1;
+        continue;
+      }
+      if (!l)
+        break;
+    }
+    int q = (~d + g) << ~e, p = (~d - q) & a >> b;
+    unsigned s = ~((g & e) + (p | (b ^ (d + k))));
+    int r = (e & s) + p, u = d | ~a,
+        t = ((~(q + (~a + (s + e)))) & u) | (-g & (c << d ^ p));
+    if (t)
+      if (!r)
+        goto n;
+    g = m;
+    e = i;
+  }
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr117432.c b/gcc/testsuite/gcc.target/i386/pr117432.c
new file mode 100644
index 0000000000000000000000000000000000000000..adc54b8834445d3da9b504d548608e3f3d42378a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr117432.c
@@ -0,0 +1,17 @@
+/* PR ipa/117432 */
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler "# myinsn %rax" } } */
+/* { dg-final { scan-assembler "# myinsn %eax" } } */
+
+void
+foo (void)
+{
+  asm volatile ("# myinsn %0" : : "r" (-42L));
+}
+
+void
+bar (void)
+{
+  asm volatile ("# myinsn %0" : : "r" (-42));
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr118497.c b/gcc/testsuite/gcc.target/i386/pr118497.c
new file mode 100644
index 0000000000000000000000000000000000000000..ef720931aa491c5dd6d8144dabcf1a2f656eed4c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118497.c
@@ -0,0 +1,16 @@
+/* { dg-do compile { target { ia32 } } } */
+/* { dg-options "-O2 -fpic" } */
+extern void crosscall2 (void (*fn) (void *, int), void *, int);
+extern void _cgo_panic (void *, int);
+extern void _cgo_allocate (void *, int);
+
+void
+callPanic (void)
+{
+  struct { const char *p; } a;
+  a.p = "panic from C";
+  crosscall2 (_cgo_panic, &a, sizeof a);
+  *(int*) 1 = 1;
+}
+
+/* { dg-final { scan-assembler "__x86.get_pc_thunk.bx" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-1-x32.c b/gcc/testsuite/gcc.target/i386/pr118713-1-x32.c
new file mode 100644
index 0000000000000000000000000000000000000000..c27ac93ae87da18c66df7d748b69aabc5f180be1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-1-x32.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-options "-O2 -mx32 -fpic -fno-plt -mindirect-branch-register" } */
+
+#include "pr118713-1.c"
+
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOTPCREL" } } */
+/* { dg-final { scan-assembler "jmp\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-1.c b/gcc/testsuite/gcc.target/i386/pr118713-1.c
new file mode 100644
index 0000000000000000000000000000000000000000..56884f3d952254bdd3c39529afea2144de479255
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch-register" } */
+
+extern void bar (void);
+
+void
+foo (void)
+{
+  bar ();
+}
+
+/* { dg-final { scan-assembler "mov\(l|q\)\[ \t\]*bar@GOTPCREL" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOT\\(" { target ia32 } } } */
+/* { dg-final { scan-assembler "jmp\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-10-x32.c b/gcc/testsuite/gcc.target/i386/pr118713-10-x32.c
new file mode 100644
index 0000000000000000000000000000000000000000..30d25ad6d0e5873cd1d9fd04421eebebe342b8a0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-10-x32.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-options "-O2 -mx32 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+#include "pr118713-10.c"
+
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOTPCREL" } } */
+/* { dg-final { scan-assembler "call\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-10.c b/gcc/testsuite/gcc.target/i386/pr118713-10.c
new file mode 100644
index 0000000000000000000000000000000000000000..a0e2ff3760b327f8865b1d308d80874dbc4dd675
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-10.c
@@ -0,0 +1,15 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+extern void bar (void);
+
+int
+foo (void)
+{
+  bar ();
+  return 0;
+}
+
+/* { dg-final { scan-assembler "mov\(l|q\)\[ \t\]*bar@GOTPCREL" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOT, " { target ia32 } } } */
+/* { dg-final { scan-assembler "call\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-11-x32.c b/gcc/testsuite/gcc.target/i386/pr118713-11-x32.c
new file mode 100644
index 0000000000000000000000000000000000000000..98afe50f42c32ddbfc7ab5c1d28fde25834c52b6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-11-x32.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-options "-O2 -mx32 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+#include "pr118713-11.c"
+
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOTPCREL" } } */
+/* { dg-final { scan-assembler "jmp\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-11.c b/gcc/testsuite/gcc.target/i386/pr118713-11.c
new file mode 100644
index 0000000000000000000000000000000000000000..deb0c0df3c7774f76ad2c907317b23e8e0fbd89a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-11.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+extern int bar (void);
+
+int
+foo (void)
+{
+  return bar ();
+}
+
+/* { dg-final { scan-assembler "mov\(l|q\)\[ \t\]*bar@GOTPCREL" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOT, " { target ia32 } } } */
+/* { dg-final { scan-assembler "jmp\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-12-x32.c b/gcc/testsuite/gcc.target/i386/pr118713-12-x32.c
new file mode 100644
index 0000000000000000000000000000000000000000..534ddab2344f2e4be10213a06e0ac861d3e3c6af
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-12-x32.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-options "-O2 -mx32 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+#include "pr118713-12.c"
+
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOTPCREL" } } */
+/* { dg-final { scan-assembler "call\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-12.c b/gcc/testsuite/gcc.target/i386/pr118713-12.c
new file mode 100644
index 0000000000000000000000000000000000000000..333b9c813e59516810b438073d4fe832461ec145
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-12.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+extern int bar (void);
+
+int
+foo (void)
+{
+  return bar () + 1;
+}
+
+/* { dg-final { scan-assembler "mov\(l|q\)\[ \t\]*bar@GOTPCREL" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOT, " { target ia32 } } } */
+/* { dg-final { scan-assembler "call\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-2-x32.c b/gcc/testsuite/gcc.target/i386/pr118713-2-x32.c
new file mode 100644
index 0000000000000000000000000000000000000000..4af932e68ed875038d0e4dba5ded9ad6d9d3eadc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-2-x32.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-options "-O2 -mx32 -fpic -fno-plt -mindirect-branch-register" } */
+
+#include "pr118713-2.c"
+
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOTPCREL" } } */
+/* { dg-final { scan-assembler "call\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-2.c b/gcc/testsuite/gcc.target/i386/pr118713-2.c
new file mode 100644
index 0000000000000000000000000000000000000000..807724e031075ad720ec403114590c8f4b3e104c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-2.c
@@ -0,0 +1,15 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch-register" } */
+
+extern void bar (void);
+
+int
+foo (void)
+{
+  bar ();
+  return 0;
+}
+
+/* { dg-final { scan-assembler "mov\(l|q\)\[ \t\]*bar@GOTPCREL" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOT\\(" { target ia32 } } } */
+/* { dg-final { scan-assembler "call\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-3-x32.c b/gcc/testsuite/gcc.target/i386/pr118713-3-x32.c
new file mode 100644
index 0000000000000000000000000000000000000000..90a0e66a10c3a3f91b0f777910e7746fbfed553e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-3-x32.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-options "-O2 -mx32 -fpic -fno-plt -mindirect-branch-register" } */
+
+#include "pr118713-3.c"
+
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOTPCREL" } } */
+/* { dg-final { scan-assembler "jmp\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-3.c b/gcc/testsuite/gcc.target/i386/pr118713-3.c
new file mode 100644
index 0000000000000000000000000000000000000000..1cd3fcbdf66fbc670eb7f8d863daf4c010913337
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-3.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch-register" } */
+
+extern int bar (void);
+
+int
+foo (void)
+{
+  return bar ();
+}
+
+/* { dg-final { scan-assembler "mov\(l|q\)\[ \t\]*bar@GOTPCREL" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOT\\(" { target ia32 } } } */
+/* { dg-final { scan-assembler "jmp\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-4-x32.c b/gcc/testsuite/gcc.target/i386/pr118713-4-x32.c
new file mode 100644
index 0000000000000000000000000000000000000000..7f02f6003ead14995d28413d37d43aa6cd664f69
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-4-x32.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-options "-O2 -mx32 -fpic -fno-plt -mindirect-branch-register" } */
+
+#include "pr118713-4.c"
+
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOTPCREL" } } */
+/* { dg-final { scan-assembler "call\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-4.c b/gcc/testsuite/gcc.target/i386/pr118713-4.c
new file mode 100644
index 0000000000000000000000000000000000000000..86d13b73bfc939beef24f5173bf97fde68d8bf02
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-4.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fpic -fno-plt -mindirect-branch-register" } */
+
+extern int bar (void);
+
+int
+foo (void)
+{
+  return bar () + 1;
+}
+
+/* { dg-final { scan-assembler "mov\(l|q\)\[ \t\]*bar@GOTPCREL" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOT\\(" { target ia32 } } } */
+/* { dg-final { scan-assembler "call\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-5-x32.c b/gcc/testsuite/gcc.target/i386/pr118713-5-x32.c
new file mode 100644
index 0000000000000000000000000000000000000000..4642ace9d6a64cd62a43daa198dae48e248406f7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-5-x32.c
@@ -0,0 +1,7 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-options "-O2 -mx32 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+#include "pr118713-5.c"
+
+/* { dg-final { scan-assembler "jmp\[ \t\]*bar" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-5.c b/gcc/testsuite/gcc.target/i386/pr118713-5.c
new file mode 100644
index 0000000000000000000000000000000000000000..0f44ab23c9b7ce450c03bced066881cc096e56ef
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-5.c
@@ -0,0 +1,12 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+extern void bar (void) __attribute__((visibility("hidden")));
+
+void
+foo (void)
+{
+  bar ();
+}
+
+/* { dg-final { scan-assembler "jmp\[ \t\]*bar" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-6-x32.c b/gcc/testsuite/gcc.target/i386/pr118713-6-x32.c
new file mode 100644
index 0000000000000000000000000000000000000000..e7a2f35d569cf1ea71091e61c9e9a299c17a2de5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-6-x32.c
@@ -0,0 +1,7 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-options "-O2 -mx32 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+#include "pr118713-6.c"
+
+/* { dg-final { scan-assembler "call\[ \t\]*bar" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-6.c b/gcc/testsuite/gcc.target/i386/pr118713-6.c
new file mode 100644
index 0000000000000000000000000000000000000000..befe0b07e0699b5456768be438a4bbc8457b3770
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-6.c
@@ -0,0 +1,13 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+extern void bar (void) __attribute__((visibility("hidden")));
+
+int
+foo (void)
+{
+  bar ();
+  return 0;
+}
+
+/* { dg-final { scan-assembler "call\[ \t\]*bar" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-7-x32.c b/gcc/testsuite/gcc.target/i386/pr118713-7-x32.c
new file mode 100644
index 0000000000000000000000000000000000000000..35e9de5c187d8e8be9bf44702c421e852126b55a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-7-x32.c
@@ -0,0 +1,7 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-options "-O2 -mx32 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+#include "pr118713-7.c"
+
+/* { dg-final { scan-assembler "jmp\[ \t\]*bar" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-7.c b/gcc/testsuite/gcc.target/i386/pr118713-7.c
new file mode 100644
index 0000000000000000000000000000000000000000..ba405be4272fa256435ecf985715cc60c9e613cf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-7.c
@@ -0,0 +1,12 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+extern int bar (void) __attribute__((visibility("hidden")));
+
+int
+foo (void)
+{
+  return bar ();
+}
+
+/* { dg-final { scan-assembler "jmp\[ \t\]*bar" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-8-x32.c b/gcc/testsuite/gcc.target/i386/pr118713-8-x32.c
new file mode 100644
index 0000000000000000000000000000000000000000..9aebe6aef645ce5ff1112ba6ad1d22411e5fc8e2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-8-x32.c
@@ -0,0 +1,7 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-options "-O2 -mx32 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+#include "pr118713-8.c"
+
+/* { dg-final { scan-assembler "call\[ \t\]*bar" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-8.c b/gcc/testsuite/gcc.target/i386/pr118713-8.c
new file mode 100644
index 0000000000000000000000000000000000000000..046f107a6f58ed876daab11642770b62d45f94c8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-8.c
@@ -0,0 +1,12 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+extern int bar (void) __attribute__((visibility("hidden")));
+
+int
+foo (void)
+{
+  return bar () + 1;
+}
+
+/* { dg-final { scan-assembler "call\[ \t\]*bar" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-9-x32.c b/gcc/testsuite/gcc.target/i386/pr118713-9-x32.c
new file mode 100644
index 0000000000000000000000000000000000000000..85819aa3380c452ca6cab5d0cb481382b1037dfd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-9-x32.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-options "-O2 -mx32 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+#include "pr118713-9.c"
+
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOTPCREL" } } */
+/* { dg-final { scan-assembler "jmp\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr118713-9.c b/gcc/testsuite/gcc.target/i386/pr118713-9.c
new file mode 100644
index 0000000000000000000000000000000000000000..365f65fb194342e086208423fa55f4fd177823f1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr118713-9.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fno-pic -fno-plt -mindirect-branch-register" } */
+
+extern void bar (void);
+
+void
+foo (void)
+{
+  bar ();
+}
+
+/* { dg-final { scan-assembler "mov\(l|q\)\[ \t\]*bar@GOTPCREL" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOT, " { target ia32 } } } */
+/* { dg-final { scan-assembler "jmp\[ \t\]*\\*%" } } */
diff --git a/gcc/testsuite/gcc.target/i386/ssp-global.c b/gcc/testsuite/gcc.target/i386/ssp-global.c
new file mode 100644
index 0000000000000000000000000000000000000000..85a288c781c9d18b197fadd61e226c38b8699d98
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/ssp-global.c
@@ -0,0 +1,35 @@
+/* { dg-do run { target fstack_protector } } */
+/* { dg-options "-O2 -fstack-protector-all -mstack-protector-guard=global" } */
+
+#include <stdlib.h>
+
+#ifdef __LP64__
+const unsigned long int __stack_chk_guard = 0x2d853605a4d9a09cUL;
+#else
+const unsigned long int __stack_chk_guard = 0xdd2cc927UL;
+#endif
+
+void
+__stack_chk_fail (void)
+{
+  exit (0); /* pass */
+}
+
+__attribute__ ((noipa))
+void
+smash (char *p, int i)
+{
+  p[i] = 42;
+}
+
+int
+main (void)
+{
+  char foo[255];
+
+   /* smash stack */
+  for (int i = 0; i <= 400; i++)
+    smash (foo, i);
+
+  return 1;
+}
diff --git a/gcc/testsuite/gcc.target/i386/vartrack-1.c b/gcc/testsuite/gcc.target/i386/vartrack-1.c
index b7e7e7844d8ed1fbc1a4fb65f43604f3d16f6bf9..14a2d6a0a8a91fd9324cc3cf6298170e1868b3ac 100644
--- a/gcc/testsuite/gcc.target/i386/vartrack-1.c
+++ b/gcc/testsuite/gcc.target/i386/vartrack-1.c
@@ -15,14 +15,14 @@ main ()
 }
 
 /* Before adjust_insn:
-   26: [--sp:DI]=bx:DI
-   29: bx:DI=[sp:DI++]
+   26: [--sp:DI]=b[px]:DI
+   29: b[px]:DI=[sp:DI++]
 
    after adjust_insn:
-   26: {[argp:DI-0x10]=bx:DI;sp:DI=argp:DI-0x10;}
-   29: {bx:DI=[argp:DI-0x10];sp:DI=argp:DI-0x8;} */
+   26: {[argp:DI-0x10]=b[px]:DI;sp:DI=argp:DI-0x10;}
+   29: {b[px]:DI=[argp:DI-0x10];sp:DI=argp:DI-0x8;} */
 
-/* { dg-final { scan-rtl-dump-times {[0-9][0-9]*: \{\[argp:DI-0x10\]=bx:DI;sp:DI=argp:DI-0x10;\}} 1 "vartrack" } } */
+/* { dg-final { scan-rtl-dump-times {[0-9][0-9]*: \{\[argp:DI-0x10\]=b[px]:DI;sp:DI=argp:DI-0x10;\}} 1 "vartrack" } } */
 
-/* { dg-final { scan-rtl-dump-times {[0-9][0-9]*: \{bx:DI=\[argp:DI-0x10\];sp:DI=argp:DI-0x8;\}} 1 "vartrack" } } */
+/* { dg-final { scan-rtl-dump-times {[0-9][0-9]*: \{b[px]:DI=\[argp:DI-0x10\];sp:DI=argp:DI-0x8;\}} 1 "vartrack" } } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/pr118663.c b/gcc/testsuite/gcc.target/powerpc/pr118663.c
new file mode 100644
index 0000000000000000000000000000000000000000..8d3cbe07fc1f3f36651709e8204382cdac6cf385
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr118663.c
@@ -0,0 +1,10 @@
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
+/* { dg-options "-mcpu=601 -w -O2 -m64" } */
+
+extern void bar (void);
+void
+foo (_Decimal32 *dst, _Decimal32 src)
+{
+  bar ();
+  *dst = src;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/pr114277.c b/gcc/testsuite/gcc.target/riscv/pr114277.c
new file mode 100644
index 0000000000000000000000000000000000000000..cc1db19ee4c5518730ef947d468e321b4ddcac1e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr114277.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=rv64gc_zicond -mabi=lp64d" { target rv64 } } */
+/* { dg-options "-O2 -march=rv32gc_zicond -mabi=ilp32" { target rv32 } } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-Os" "-Oz" "-O3" "-Og" } } */
+
+#include "../i386/pr114277.c"
+
+/* { dg-final { scan-assembler-not "czero" } } */
+
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s16.c b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s16.c
new file mode 100644
index 0000000000000000000000000000000000000000..21ec107cbf10c14e985033b0902002baba28f086
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s16.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_ADD_RUN(int16_t, INT16_MIN, INT16_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s32.c b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s32.c
new file mode 100644
index 0000000000000000000000000000000000000000..1f197d1280b728465fee51b031713ea6d1483fe1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s32.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_ADD_RUN(int32_t, INT32_MIN, INT32_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s64.c b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s64.c
new file mode 100644
index 0000000000000000000000000000000000000000..4903bc854d3402aa7e0f8af0ebbac2dcad1a2772
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s64.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_ADD_RUN(int64_t, INT64_MIN, INT64_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s8.c b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s8.c
new file mode 100644
index 0000000000000000000000000000000000000000..a9f2fe7f1920239c865626508599232b862d6576
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s8.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_ADD_RUN(int8_t, INT8_MIN, INT8_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s16.c b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s16.c
new file mode 100644
index 0000000000000000000000000000000000000000..7b375bb6c85d90415401aa2ebf8a7fd574cfe59b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s16.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_SUB_RUN(int16_t, INT16_MIN, INT16_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s32.c b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s32.c
new file mode 100644
index 0000000000000000000000000000000000000000..ba0e8fc8ea5fc72314e26372446157003d75f97f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s32.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_SUB_RUN(int32_t, INT32_MIN, INT32_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s64.c b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s64.c
new file mode 100644
index 0000000000000000000000000000000000000000..c24c549af308c94e765621d1d9ce5b78f8a47a87
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s64.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_SUB_RUN(int64_t, INT64_MIN, INT64_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s8.c b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s8.c
new file mode 100644
index 0000000000000000000000000000000000000000..67f9df179a18b924205de38979cef52139ff5c20
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s8.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_SUB_RUN(int8_t, INT8_MIN, INT8_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s16-to-s8.c b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s16-to-s8.c
new file mode 100644
index 0000000000000000000000000000000000000000..df84615a25f90220056f87a30582839a4184cb18
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s16-to-s8.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_TRUNC_RUN(int16_t, int8_t, INT8_MIN, INT8_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s32-to-s16.c b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s32-to-s16.c
new file mode 100644
index 0000000000000000000000000000000000000000..1b0f860eb55ee913fc47253c83ed7f4c3077560e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s32-to-s16.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_TRUNC_RUN(int32_t, int16_t, INT16_MIN, INT16_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s32-to-s8.c b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s32-to-s8.c
new file mode 100644
index 0000000000000000000000000000000000000000..e412a29df36a65f0ea56e321bda12baebcb60240
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s32-to-s8.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_TRUNC_RUN(int32_t, int8_t, INT8_MIN, INT8_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s64-to-s16.c b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s64-to-s16.c
new file mode 100644
index 0000000000000000000000000000000000000000..234d33b1895248e73cd7cc8200ec503600e2edc8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s64-to-s16.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_TRUNC_RUN(int64_t, int16_t, INT16_MIN, INT16_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s64-to-s32.c b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s64-to-s32.c
new file mode 100644
index 0000000000000000000000000000000000000000..5f9e7f589f05735ddc96795a22260a62835bd4de
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s64-to-s32.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_TRUNC_RUN(int64_t, int32_t, INT32_MIN, INT32_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s64-to-s8.c b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s64-to-s8.c
new file mode 100644
index 0000000000000000000000000000000000000000..aae6be92e67582452e08577e305c6604ab1b74c8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s64-to-s8.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99" } */
+
+#include "pr117688.h"
+
+DEFINE_SIGNED_SAT_TRUNC_RUN(int64_t, int8_t, INT8_MIN, INT8_MAX)
diff --git a/gcc/testsuite/gcc.target/riscv/pr117688.h b/gcc/testsuite/gcc.target/riscv/pr117688.h
new file mode 100644
index 0000000000000000000000000000000000000000..7621021016a2eec7951e4564acacd2ba2c388e57
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr117688.h
@@ -0,0 +1,70 @@
+#ifndef HAVE_DEFINED_PR117688_H
+#define HAVE_DEFINED_PR117688_H
+
+#include <stdint.h>
+
+#define DEFINE_SIGNED_SAT_ADD_RUN(T, MIN, MAX)            \
+  T x, y, result;                                         \
+                                                          \
+  __attribute__ ((noipa)) void                            \
+  foo ()                                                  \
+  {                                                       \
+    T sum;                                                \
+    _Bool overflow = __builtin_add_overflow (x, y, &sum); \
+    result = overflow ? (x < 0 ? MIN : MAX) : sum;        \
+  }                                                       \
+                                                          \
+  int main ()                                             \
+  {                                                       \
+    x = MIN;                                              \
+    y = -0x1;                                             \
+    foo();                                                \
+    if (result != (T)MIN)                                 \
+      __builtin_abort ();                                 \
+    return 0;                                             \
+  }
+
+#define DEFINE_SIGNED_SAT_SUB_RUN(T, MIN, MAX)              \
+  T x, y, result;                                           \
+                                                            \
+  __attribute__ ((noipa)) void                              \
+  foo ()                                                    \
+  {                                                         \
+    T minus;                                                \
+    _Bool overflow = __builtin_sub_overflow (x, y, &minus); \
+    result = overflow ? (x < 0 ? MIN : MAX) : minus;        \
+  }                                                         \
+                                                            \
+  int main ()                                               \
+  {                                                         \
+    x = MIN;                                                \
+    y = 0x1;                                                \
+    foo();                                                  \
+    if (result != (T)MIN)                                   \
+      __builtin_abort ();                                   \
+    return 0;                                               \
+  }
+
+#define DEFINE_SIGNED_SAT_TRUNC_RUN(WT, NT, NT_MIN, NT_MAX) \
+  WT x;                                                     \
+  NT result;                                                \
+                                                            \
+  __attribute__ ((noipa)) void                              \
+  foo ()                                                    \
+  {                                                         \
+    NT trunc = (NT)x;                                       \
+    result = (WT)NT_MIN <= x && x <= (WT)NT_MAX             \
+       ? trunc                                              \
+       : x < 0 ? NT_MIN : NT_MAX;                           \
+  }                                                         \
+                                                            \
+  int main ()                                               \
+  {                                                         \
+    x = (WT)NT_MIN - 1 ;                                    \
+    foo();                                                  \
+    if (result != (NT)NT_MIN)                               \
+      __builtin_abort ();                                   \
+    return 0;                                               \
+  }
+
+#endif
diff --git a/gcc/testsuite/gcc.target/riscv/pr118170.c b/gcc/testsuite/gcc.target/riscv/pr118170.c
index 306ff888aebdaf03035a390206da08c3f739c4bf..baa7f8d3d9e6d6779ce472ea062157d504a065d9 100644
--- a/gcc/testsuite/gcc.target/riscv/pr118170.c
+++ b/gcc/testsuite/gcc.target/riscv/pr118170.c
@@ -1,4 +1,4 @@
-/* { dg-do "compile" } */
+/* { dg-do "compile" { target { ! riscv_abi_e } } } */
 /* { dg-options "-O2 -mcpu=tt-ascalon-d8" } */
 _Float16 f;
 
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/gather_load_64-12-zvbb.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/gather_load_64-12-zvbb.c
index de5a5ed7d56a9f3a25078d1a60dd2d215fe34afe..698f0091390ea5215567dec9516e66ee0c35bc97 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/gather_load_64-12-zvbb.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/gather_load_64-12-zvbb.c
@@ -106,7 +106,8 @@ TEST_LOOP (_Float16, uint64_t)
 TEST_LOOP (float, uint64_t)
 TEST_LOOP (double, uint64_t)
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 80 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 80 "vect" { target { ! riscv_zvfh } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 88 "vect" { target riscv_zvfh } } } */
 /* { dg-final { scan-tree-dump " \.MASK_LEN_GATHER_LOAD" "vect" } } */
 /* { dg-final { scan-tree-dump-not " \.GATHER_LOAD" "vect" } } */
 /* { dg-final { scan-tree-dump-not " \.MASK_GATHER_LOAD" "vect" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc-8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc-8.c
index fe47aa3648ddf3bc71c1cee6301c66b8ba03d44b..518f0c33cc4e4dfbd0f5a9355236e480a8921f86 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc-8.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc-8.c
@@ -12,5 +12,4 @@ add_loop (int *x, int n, int res)
   return res;
 }
 
-/* { dg-final { scan-tree-dump-times "VEC_SHL_INSERT" 1 "optimized" } } */
 /* { dg-final { scan-assembler-times {vslide1up\.vx\s+v[0-9]+,\s*v[0-9]+,\s*[a-x0-9]+} 1 } } */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc-9.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc-9.c
index 6630d3027210b079fba3e9b9a4a2a80a8c1fbbf4..a5bb8dcccb81b3a010896e543db4f1baa2cb9e83 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc-9.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc-9.c
@@ -12,5 +12,4 @@ add_loop (float *x, int n, float res)
   return res;
 }
 
-/* { dg-final { scan-tree-dump-times "VEC_SHL_INSERT" 1 "optimized" } } */
 /* { dg-final { scan-assembler-times {vfslide1up\.vf\s+v[0-9]+,\s*v[0-9]+,\s*[a-x0-9]+} 1 } } */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr118103-1.c b/gcc/testsuite/gcc.target/riscv/rvv/base/pr118103-1.c
new file mode 100644
index 0000000000000000000000000000000000000000..1afa5d3afb50e3091108194f16afcf6e3090deb7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr118103-1.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=rv64gcv_zvfh -mabi=lp64d" } */
+
+#include "riscv_vector.h"
+
+#define N 4
+typedef _Float16 float16_t;
+float16_t a[N]; float16_t b[N];
+
+extern void test ();
+
+int test_exampe () {
+  test ();
+
+  size_t vl = N;
+  vfloat16m1_t va = __riscv_vle16_v_f16m1(a, vl);
+  va = __riscv_vfnmadd_vv_f16m1_rm(va, va, va, __RISCV_FRM_RDN, vl);
+  va = __riscv_vfmsac_vv_f16m1(va, va, va, vl);
+
+  __riscv_vse16_v_f16m1(b, va, vl);
+
+  return 0;
+}
+
+/* { dg-final { scan-assembler-times {frrm\s+[axs][0-9]+} 1 } } */
+/* { dg-final { scan-assembler-times {fsrmi\s+[01234]} 1 } } */
+/* { dg-final { scan-assembler-times {fsrm\s+[axs][0-9]+} 1 } } */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr118103-run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/base/pr118103-run-1.c
new file mode 100644
index 0000000000000000000000000000000000000000..62375c63ee867282ff137aae778fffc8d807301d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr118103-run-1.c
@@ -0,0 +1,50 @@
+/* { dg-do run { target { riscv_zvfh } } } */
+/* { dg-options "-O3 -fno-strict-aliasing" } */
+
+#include "riscv_vector.h"
+#define N 4
+typedef _Float16 float16_t;
+float16_t a[N]; float16_t b[N];
+
+void initialize () {
+  uint16_t tmp_0[N] = {43883, 3213, 238, 275, };
+
+  for (int i = 0; i < N; ++i)
+    {
+      union { float16_t f16; uint16_t u16; } converter;
+      converter.u16 = tmp_0[i];
+      a[i] = converter.f16; 
+    }
+
+  for (int i = 0; i < N; ++i)
+    b[i] = 0;
+}
+
+void compute ()
+{
+  int avl = N;
+  float16_t* ptr_a = a; float16_t* ptr_b = b;
+
+  for (size_t vl; avl > 0; avl -= vl)
+    {
+      vl = __riscv_vsetvl_e16m1(avl);
+      vfloat16m1_t va = __riscv_vle16_v_f16m1(ptr_a, vl);
+      va = __riscv_vfnmadd_vv_f16m1_rm(va, va, va, __RISCV_FRM_RDN, vl);
+      va = __riscv_vfmsac_vv_f16m1(va, va, va, vl);
+      __riscv_vse16_v_f16m1(ptr_b, va, vl);
+      ptr_a += vl; ptr_b += vl;
+    }
+}
+
+int main ()
+{
+  initialize();
+  compute();
+
+  short *tmp = (short *)b;
+
+  if (*tmp != -21862)
+    __builtin_abort ();
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/s390/call-z10-pic-nodatarel.c b/gcc/testsuite/gcc.target/s390/call-z10-pic-nodatarel.c
index 49984614bc6f718ada64283c41a96ffe13a82575..6df0c75584f4b710bf077df3a2e35941373ed752 100644
--- a/gcc/testsuite/gcc.target/s390/call-z10-pic-nodatarel.c
+++ b/gcc/testsuite/gcc.target/s390/call-z10-pic-nodatarel.c
@@ -7,10 +7,8 @@
 /* { dg-final { scan-assembler {lgrl\t%r2,foo@GOTENT\n} { target lp64 } } } */
 /* { dg-final { scan-assembler {lrl\t%r2,foo@GOTENT\n} { target { ! lp64 } } } } */
 
-/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic\n} { target { ! lp64 } } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foostatic@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} { target { ! lp64 } } } } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} } } */
+/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} } } */
 
 /* { dg-final { scan-assembler {brasl\t%r\d+,fooweak@PLT\n} } } */
 /* { dg-final { scan-assembler {lgrl\t%r2,fooweak@GOTENT\n} { target lp64 } } } */
diff --git a/gcc/testsuite/gcc.target/s390/call-z10-pic.c b/gcc/testsuite/gcc.target/s390/call-z10-pic.c
index 210c56cc4cad0a30539948cbc8c4281232306459..30145d5b760878c9dbeee26f1cad56f647074d32 100644
--- a/gcc/testsuite/gcc.target/s390/call-z10-pic.c
+++ b/gcc/testsuite/gcc.target/s390/call-z10-pic.c
@@ -7,10 +7,8 @@
 /* { dg-final { scan-assembler {lgrl\t%r2,foo@GOTENT\n} { target lp64 } } } */
 /* { dg-final { scan-assembler {lrl\t%r2,foo@GOTENT\n} { target { ! lp64 } } } } */
 
-/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic\n} { target { ! lp64 } } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foostatic@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} { target { ! lp64 } } } } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} } } */
+/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} } } */
 
 /* { dg-final { scan-assembler {brasl\t%r\d+,fooweak@PLT\n} } } */
 /* { dg-final { scan-assembler {lgrl\t%r2,fooweak@GOTENT\n} { target lp64 } } } */
diff --git a/gcc/testsuite/gcc.target/s390/call-z10.c b/gcc/testsuite/gcc.target/s390/call-z10.c
index 2d7dc735df4aa39338b25d89d7179c41935b9c00..d4eab4ff89fc342bdba731b15f8d9c90ace7b150 100644
--- a/gcc/testsuite/gcc.target/s390/call-z10.c
+++ b/gcc/testsuite/gcc.target/s390/call-z10.c
@@ -3,17 +3,13 @@
 
 #include "call.h"
 
-/* { dg-final { scan-assembler {brasl\t%r\d+,foo@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {brasl\t%r\d+,foo\n} { target { ! lp64 } } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foo@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foo\n} { target { ! lp64 } } } } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,foo@PLT\n} } } */
+/* { dg-final { scan-assembler {larl\t%r2,foo\n} } } */
 
-/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic\n} { target { ! lp64 } } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foostatic@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} { target { ! lp64 } } } } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} } } */
+/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} } } */
 
-/* { dg-final { scan-assembler {brasl\t%r\d+,fooweak\n} } } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,fooweak@PLT\n} } } */
 /* { dg-final { scan-assembler {larl\t%r2,fooweak\n} } } */
 
 /* { dg-final { scan-assembler {foos:\n\t.quad\tfoo\n\t.quad\tfoostatic\n\t.quad\tfooweak\n} { target lp64 } } } */
diff --git a/gcc/testsuite/gcc.target/s390/call-z9-pic-nodatarel.c b/gcc/testsuite/gcc.target/s390/call-z9-pic-nodatarel.c
index b1ae318d3e99427f6fc254c7847466dbb5833242..fe515bf1903d310061a45e3299fddb8083a71683 100644
--- a/gcc/testsuite/gcc.target/s390/call-z9-pic-nodatarel.c
+++ b/gcc/testsuite/gcc.target/s390/call-z9-pic-nodatarel.c
@@ -6,10 +6,8 @@
 /* { dg-final { scan-assembler {brasl\t%r\d+,foo@PLT\n} } } */
 /* { dg-final { scan-assembler {larl\t%r\d+,foo@GOTENT\n} } } */
 
-/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic\n} { target { ! lp64 } } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foostatic@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} { target { ! lp64 } } } } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} } } */
+/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} } } */
 
 /* { dg-final { scan-assembler {brasl\t%r\d+,fooweak@PLT\n} } } */
 /* { dg-final { scan-assembler {larl\t%r\d+,fooweak@GOTENT\n} } } */
diff --git a/gcc/testsuite/gcc.target/s390/call-z9-pic.c b/gcc/testsuite/gcc.target/s390/call-z9-pic.c
index a89e78d8df8e5a356c2d163ac003b58e633cf0ea..43e1c2f7cb38c298c65b73a30d78d3fb7c3a0ccb 100644
--- a/gcc/testsuite/gcc.target/s390/call-z9-pic.c
+++ b/gcc/testsuite/gcc.target/s390/call-z9-pic.c
@@ -6,10 +6,8 @@
 /* { dg-final { scan-assembler {brasl\t%r\d+,foo@PLT\n} } } */
 /* { dg-final { scan-assembler {larl\t%r\d+,foo@GOTENT\n} } } */
 
-/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic\n} { target { ! lp64 } } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foostatic@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} { target { ! lp64 } } } } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} } } */
+/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} } } */
 
 /* { dg-final { scan-assembler {brasl\t%r\d+,fooweak@PLT\n} } } */
 /* { dg-final { scan-assembler {larl\t%r\d+,fooweak@GOTENT\n} } } */
diff --git a/gcc/testsuite/gcc.target/s390/call-z9.c b/gcc/testsuite/gcc.target/s390/call-z9.c
index 21d035aecb6b065af2cc7398a41a02b53c91fc4f..b755f33498a3b0e43b0268c1aadfe8ce1adeccea 100644
--- a/gcc/testsuite/gcc.target/s390/call-z9.c
+++ b/gcc/testsuite/gcc.target/s390/call-z9.c
@@ -3,17 +3,13 @@
 
 #include "call.h"
 
-/* { dg-final { scan-assembler {brasl\t%r\d+,foo@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {brasl\t%r\d+,foo\n} { target { ! lp64 } } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foo@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foo\n} { target { ! lp64 } } } } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,foo@PLT\n} } } */
+/* { dg-final { scan-assembler {larl\t%r2,foo\n} } } */
 
-/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic\n} { target { ! lp64 } } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foostatic@PLT\n} { target lp64 } } } */
-/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} { target { ! lp64 } } } } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} } } */
+/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} } } */
 
-/* { dg-final { scan-assembler {brasl\t%r\d+,fooweak\n} } } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,fooweak@PLT\n} } } */
 /* { dg-final { scan-assembler {larl\t%r2,fooweak\n} } } */
 
 /* { dg-final { scan-assembler {foos:\n\t.quad\tfoo\n\t.quad\tfoostatic\n\t.quad\tfooweak\n} { target lp64 } } } */
diff --git a/gcc/testsuite/gcc.target/s390/vector/pr118696.c b/gcc/testsuite/gcc.target/s390/vector/pr118696.c
new file mode 100644
index 0000000000000000000000000000000000000000..1f67bf5c47fd36abf78d32915a649575ee563368
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/vector/pr118696.c
@@ -0,0 +1,5 @@
+/* PR target/118696 */
+/* { dg-do run } */
+/* { dg-options "-O2 -mzarch -march=z13" } */
+
+#include "../../../gcc.dg/pr118696.c"
diff --git a/gcc/testsuite/gcc.target/s390/vector/vec-abs-emu.c b/gcc/testsuite/gcc.target/s390/vector/vec-abs-emu.c
index 8c1038a13d75617d533c2ceeb483dbee916bac55..e0dd222e62c7f7e34ed24329eeb32f92f673d5a9 100644
--- a/gcc/testsuite/gcc.target/s390/vector/vec-abs-emu.c
+++ b/gcc/testsuite/gcc.target/s390/vector/vec-abs-emu.c
@@ -18,7 +18,7 @@ typedef __attribute__ ((vector_size (16))) signed __int128 v1ti;
 **	vchg	%v[0-9]+,%v[0-9]+,%v[0-9]+
 **	vn	%v[0-9]+,%v[0-9]+,%v[0-9]+
 **	vo	%v[0-9]+,%v[0-9]+,%v[0-9]+
-**	vrepg	%v[0-9]+,%v[0-9]+,1
+**	vrepg	%v[0-9]+,%v[0-9]+,0
 **	vsq	%v[0-9]+,%v[0-9]+,%v[0-9]+
 **	vsel	%v[0-9]+,%v[0-9]+,%v[0-9]+,%v[0-9]+
 **	br	%r14
diff --git a/gcc/testsuite/gcc.target/s390/vector/vec-max-emu.c b/gcc/testsuite/gcc.target/s390/vector/vec-max-emu.c
index 1c4451b19c1d59dd892ade6601279fd39ab66eb9..12c7e76edc19536e640c90537c3dbf0ba20279c1 100644
--- a/gcc/testsuite/gcc.target/s390/vector/vec-max-emu.c
+++ b/gcc/testsuite/gcc.target/s390/vector/vec-max-emu.c
@@ -17,7 +17,7 @@ typedef __attribute__ ((vector_size (16))) signed __int128 v1ti;
 **	vchg	%v[0-9]+,%v[0-9]+,%v[0-9]+
 **	vn	%v[0-9]+,%v[0-9]+,%v[0-9]+
 **	vo	%v[0-9]+,%v[0-9]+,%v[0-9]+
-**	vrepg	%v[0-9]+,%v[0-9]+,1
+**	vrepg	%v[0-9]+,%v[0-9]+,0
 **	vsel	%v[0-9]+,%v[0-9]+,%v[0-9]+,%v[0-9]+
 **	br	%r14
 */
diff --git a/gcc/testsuite/gcc.target/s390/vector/vec-min-emu.c b/gcc/testsuite/gcc.target/s390/vector/vec-min-emu.c
index 89f4dff542d2b30de40ebd5ab4fd0a56bf1eb4a5..a9bcba39e224caca9d464df334897edce9ef60c3 100644
--- a/gcc/testsuite/gcc.target/s390/vector/vec-min-emu.c
+++ b/gcc/testsuite/gcc.target/s390/vector/vec-min-emu.c
@@ -17,7 +17,7 @@ typedef __attribute__ ((vector_size (16))) signed __int128 v1ti;
 **	vchg	%v[0-9]+,%v[0-9]+,%v[0-9]+
 **	vn	%v[0-9]+,%v[0-9]+,%v[0-9]+
 **	vo	%v[0-9]+,%v[0-9]+,%v[0-9]+
-**	vrepg	%v[0-9]+,%v[0-9]+,1
+**	vrepg	%v[0-9]+,%v[0-9]+,0
 **	vsel	%v[0-9]+,%v[0-9]+,%v[0-9]+,%v[0-9]+
 **	br	%r14
 */
diff --git a/gcc/testsuite/gfortran.dg/char_array_constructor_5.f90 b/gcc/testsuite/gfortran.dg/char_array_constructor_5.f90
new file mode 100644
index 0000000000000000000000000000000000000000..0cbe6b1468d111efc5a4f2d180cb6c98328e8c1c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/char_array_constructor_5.f90
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! { dg-additional-options "-std=gnu" }
+!
+! PR fortran/93289
+!
+! Contributed by Tobias Burnus
+
+character(len=*), parameter ::  str = "abj", str2 = "1234"
+print *, [character(5) :: str, "ab", "hjf333"]
+print *, [character(5) :: str, str2]
+print *, [str, "ab", "hjf333"]  ! { dg-warning "must have the same length" }
+print *, [str, str2]            ! { dg-warning "must have the same length" }
+end
diff --git a/gcc/testsuite/gfortran.dg/common_29.f90 b/gcc/testsuite/gfortran.dg/common_29.f90
new file mode 100644
index 0000000000000000000000000000000000000000..66f2a18a483629263d3ab975169ed57067e044a3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/common_29.f90
@@ -0,0 +1,34 @@
+! { dg-do compile }
+! PR fortran/108454
+!
+! Contributed by G.Steinmetz
+
+module m
+  type t
+  end type
+contains
+  subroutine s
+    common t
+  end
+end
+
+module m2
+  implicit none
+  type t
+  end type
+contains
+  subroutine s
+    real :: t
+    common /com/ t
+  end
+end
+
+module m3
+  type t
+  end type
+contains
+  subroutine s
+    type(t) :: x  ! { dg-error "cannot be host associated at .1." }
+    common t      ! { dg-error "incompatible object of the same name" }
+  end
+end
diff --git a/gcc/testsuite/gfortran.dg/default_format_2.f90 b/gcc/testsuite/gfortran.dg/default_format_2.f90
index 5ad7b3a642953d57a736d8f6aca6d8d55ee4fb03..dd04d3aae981893f43bf2b434f6479ccd38cea74 100644
--- a/gcc/testsuite/gfortran.dg/default_format_2.f90
+++ b/gcc/testsuite/gfortran.dg/default_format_2.f90
@@ -1,4 +1,4 @@
-! { dg-do run { xfail powerpc*-apple-darwin* powerpc*-*-linux* } }
+! { dg-do run { xfail long_double_is_ibm128 } }
 ! { dg-require-effective-target fortran_large_real }
 ! Test XFAILed on these platforms because the system's printf() lacks
 ! proper support for denormalized long doubles. See PR24685
diff --git a/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90 b/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90
index e9ccf5e8f61dae346c01f620443bc1724db1e8f3..ae056d506a29d093beb02cc8e70d4220490d30ad 100644
--- a/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90
+++ b/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90
@@ -1,4 +1,4 @@
-! { dg-do run { xfail powerpc*-*-* } }
+! { dg-do run { xfail long_double_is_ibm128 } }
 ! { dg-require-effective-target fortran_large_real }
 ! Test XFAILed on this platform because the system's printf() lacks
 ! proper support for denormalized long doubles. See PR24685
diff --git a/gcc/testsuite/gfortran.dg/dependency_generation_1.f90 b/gcc/testsuite/gfortran.dg/dependency_generation_1.f90
new file mode 100644
index 0000000000000000000000000000000000000000..d42a257f83a87f5464e0c5a9976d549d3a1996ac
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dependency_generation_1.f90
@@ -0,0 +1,15 @@
+! This test case ensures that the -MT flag is correctly replacing the object name in the dependency file.
+! See PR 47485
+!
+! Contributed by Vincent Vanlaer <vincenttc@volkihar.be>
+!
+! { dg-do preprocess }
+! { dg-additional-options "-cpp" }
+! { dg-additional-options "-M" }
+! { dg-additional-options "-MF deps" }
+! { dg-additional-options "-MT obj.o" }
+
+module test
+end module
+
+! { dg-final { scan-file "deps" "obj.o:.*" } }
diff --git a/gcc/testsuite/gfortran.dg/goacc/implied-copy-1.f90 b/gcc/testsuite/gfortran.dg/goacc/implied-copy-1.f90
new file mode 100644
index 0000000000000000000000000000000000000000..7f07c8afbece0e2ba9cc3b496780f23bac5c8fe7
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/implied-copy-1.f90
@@ -0,0 +1,35 @@
+! { dg-additional-options "-fdump-tree-gimple" }
+
+! Test for implied copy of reduction variable on combined construct.
+
+subroutine test
+  implicit none
+  integer a(100), i, s, p
+  p = 1
+
+  !$acc parallel loop reduction(+:s) reduction(*:p)
+  do i = 1, 100
+    s = s + a(i)
+    p = p * a(i)
+  end do
+  !$acc end parallel loop
+
+  !$acc serial loop reduction(+:s) reduction(*:p)
+  do i = 1, 100
+    s = s + a(i)
+    p = p * a(i)
+  end do
+  !$acc end serial loop
+
+  !$acc kernels loop reduction(+:s) reduction(*:p)
+  do i = 1, 100
+    s = s + a(i)
+    p = p * a(i)
+  end do
+  !$acc end kernels loop
+end subroutine test
+
+! { dg-final { scan-tree-dump-times "map\\(force_tofrom:s \\\[len: \[0-9\]+\\\]\\)" 1 "gimple" } } 
+! { dg-final { scan-tree-dump-times "map\\(force_tofrom:p \\\[len: \[0-9\]+\\\]\\)" 1 "gimple" } } 
+! { dg-final { scan-tree-dump-times "map\\(tofrom:s \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } 
+! { dg-final { scan-tree-dump-times "map\\(tofrom:p \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } 
diff --git a/gcc/testsuite/gfortran.dg/goacc/implied-copy-2.f90 b/gcc/testsuite/gfortran.dg/goacc/implied-copy-2.f90
new file mode 100644
index 0000000000000000000000000000000000000000..24e5610723b17705fd0dc257a0f79b7527f7da63
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/implied-copy-2.f90
@@ -0,0 +1,160 @@
+! { dg-additional-options "-fdump-tree-gimple" }
+
+! Test that reduction on compute construct implies a copy of the reduction variable
+
+subroutine test
+  implicit none
+  integer i
+  integer a(100), s1, p1
+  integer r1
+  real b(100), s2
+  logical c(100), r2
+  double precision d(100), s3
+  complex e(100), s4
+  p1 = 1
+
+  !$acc parallel reduction(+:s1, s2, s3, s4) reduction(*:p1)
+  do i = 1, 100
+    s1 = s1 + a(i)
+    p1 = p1 * a(i)
+    s2 = s2 +  b(i)
+    s3 = s3 +  d(i)
+    s4 = s4 +  e(i)
+  end do
+  !$acc end parallel
+
+  !$acc parallel reduction (max:r1)
+  do i = 1,10
+    if (r1 <= a(i)) then
+      r1 = a(i)
+    end if
+  end do
+  !$acc end parallel
+
+  !$acc parallel reduction (min:r1)
+  do i = 1,10
+    if (r1 >= a(i)) then
+      r1 = a(i)
+    end if
+  end do
+  !$acc end parallel
+
+  !$acc parallel reduction (iand:r1)
+  do i = 1,10
+    r1 = iand (r1, a(i))
+  end do
+  !$acc end parallel
+
+  !$acc parallel reduction (ior:r1)
+  do i = 1,10
+    r1 = ior (r1, a(i))
+  end do
+  !$acc end parallel
+
+  !$acc parallel reduction (ieor:r1)
+  do i = 1,10
+    r1 = ieor (r1, a(i))
+  end do
+  !$acc end parallel
+
+  !$acc parallel reduction (.and.:r2)
+  do i = 1,10
+    r2 = r2 .and. c(i)
+  end do
+  !$acc end parallel
+
+  !$acc parallel reduction (.or.:r2)
+  do i = 1,10
+    r2 = r2 .or. c(i)
+  end do
+  !$acc end parallel
+
+  !$acc parallel reduction (.eqv.:r2)
+  do i = 1,10
+    r2 = r2 .eqv. c(i)
+  end do
+  !$acc end parallel
+
+  !$acc parallel reduction (.neqv.:r2)
+  do i = 1,10
+    r2 = r2 .neqv. c(i)
+  end do
+  !$acc end parallel
+
+  !$acc serial reduction(+:s1, s2, s3, s4) reduction(*:p1)
+  do i = 1, 100
+    s1 = s1 + a(i)
+    p1 = p1 * a(i)
+    s2 = s2 +  b(i)
+    s3 = s3 +  d(i)
+    s4 = s4 +  e(i)
+  end do
+  !$acc end serial
+
+  !$acc serial reduction (max:r1)
+  do i = 1,10
+    if (r1 <= a(i)) then
+      r1 = a(i)
+    end if
+  end do
+  !$acc end serial
+
+  !$acc serial reduction (min:r1)
+  do i = 1,10
+    if (r1 >= a(i)) then
+      r1 = a(i)
+    end if
+  end do
+  !$acc end serial
+
+  !$acc serial reduction (iand:r1)
+  do i = 1,10
+    r1 = iand (r1, a(i))
+  end do
+  !$acc end serial
+
+  !$acc serial reduction (ior:r1)
+  do i = 1,10
+    r1 = ior (r1, a(i))
+  end do
+  !$acc end serial
+
+  !$acc serial reduction (ieor:r1)
+  do i = 1,10
+    r1 = ieor (r1, a(i))
+  end do
+  !$acc end serial
+
+  !$acc serial reduction (.and.:r2)
+  do i = 1,10
+    r2 = r2 .and. c(i)
+  end do
+  !$acc end serial
+
+  !$acc serial reduction (.or.:r2)
+  do i = 1,10
+    r2 = r2 .or. c(i)
+  end do
+  !$acc end serial
+
+  !$acc serial reduction (.eqv.:r2)
+  do i = 1,10
+    r2 = r2 .eqv. c(i)
+  end do
+  !$acc end serial
+
+  !$acc serial reduction (.neqv.:r2)
+  do i = 1,10
+    r2 = r2 .neqv. c(i)
+  end do
+  !$acc end serial
+
+end subroutine test
+
+! { dg-final { scan-tree-dump-times "map\\(tofrom:s1 \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(tofrom:r1 \\\[len: \[0-9\]+\\\]\\)" 10 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(tofrom:r2 \\\[len: \[0-9\]+\\\]\\)" 8 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(tofrom:s2 \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(tofrom:s3 \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(tofrom:s4 \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "map\\(tofrom:p1 \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/adjust-args-1.f90 b/gcc/testsuite/gfortran.dg/gomp/adjust-args-1.f90
index d9f2a670a683935764651401077f11f8433ef2fa..c0c06e7f8fdfecd190ee9048ee8203a9f4963ca0 100644
--- a/gcc/testsuite/gfortran.dg/gomp/adjust-args-1.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/adjust-args-1.f90
@@ -26,7 +26,7 @@ module main
       integer function f4 (a)
          import c_ptr
          type(c_ptr), intent(inout) :: a
-         !$omp declare variant (f0) adjust_args (nothing: a) ! { dg-error "an 'adjust_args' clause at .1. can only be specified if the 'dispatch' selector of the construct selector set appears in the 'match' clause" }
+         !$omp declare variant (f0) adjust_args (nothing: a) ! { dg-error "the 'adjust_args' clause at .1. can only be specified if the 'dispatch' selector of the construct selector set appears in the 'match' clause" }
       end function
       integer function f5 (i)
          integer, intent(inout) :: i
diff --git a/gcc/testsuite/gfortran.dg/gomp/adjust-args-3.f90 b/gcc/testsuite/gfortran.dg/gomp/adjust-args-3.f90
index 291bb47aaa25b7deaa123199292b3c56e5520bc2..9033221cc5c2f117406cf27f9ec47c5fd5909646 100644
--- a/gcc/testsuite/gfortran.dg/gomp/adjust-args-3.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/adjust-args-3.f90
@@ -9,7 +9,7 @@ module main
 contains
   subroutine base2 (a)
     type(c_ptr), intent(inout) :: a
-    !$omp declare variant (variant2) match (construct={parallel}) adjust_args (need_device_ptr: a) ! { dg-error "an 'adjust_args' clause can only be specified if the 'dispatch' selector of the construct selector set appears in the 'match' clause at .1." }
+    !$omp declare variant (variant2) match (construct={parallel}) adjust_args (need_device_ptr: a) ! { dg-error "the 'adjust_args' clause can only be specified if the 'dispatch' selector of the construct selector set appears in the 'match' clause at .1." }
   end subroutine
   subroutine base3 (a)
     type(c_ptr), intent(inout) :: a
diff --git a/gcc/testsuite/gfortran.dg/gomp/append_args-1.f90 b/gcc/testsuite/gfortran.dg/gomp/append_args-1.f90
new file mode 100644
index 0000000000000000000000000000000000000000..c994b555c97f6937884111eb4dac935367c0e92d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/append_args-1.f90
@@ -0,0 +1,76 @@
+module my_omp_lib
+ use iso_c_binding
+ implicit none
+
+ ! The following definitions are in omp_lib, which cannot be included
+ ! in gcc/testsuite/
+ integer, parameter :: omp_interop_kind = c_intptr_t
+ integer, parameter :: omp_interop_fr_kind = c_int
+
+ integer (omp_interop_kind), parameter :: omp_interop_none = 0_omp_interop_kind
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_cuda = 1
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_cuda_driver = 2
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_opencl = 3
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_sycl = 4
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_hip = 5
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_level_zero = 6
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_hsa = 7
+end module my_omp_lib
+
+module m
+  use my_omp_lib
+  implicit none
+  logical, parameter :: flag = .true.
+contains
+  subroutine f1a ()
+  end
+
+  subroutine f1b ()
+  end
+
+  subroutine f1c ()
+  end
+
+  subroutine f1d ()
+  end
+
+  subroutine f1e ()
+  end
+
+  subroutine f1po (q,r, obj)
+    type(c_ptr) :: q, r
+    value :: r
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine f2 ()
+    !$omp declare variant (f1a) match(user={condition(flag)}) &
+    !$omp&     append_args ( interop ( target , targetsync) ) match(construct={dispatch})   ! { dg-error "'match' clause at .1. specified more than once" }
+  end subroutine
+
+  subroutine f2a ()
+    !$omp declare variant (f1b) append_args ( interop ( prefer_type ( "cuda", "hip" ) ) , interop(target)) &
+    !$omp&     append_args ( interop ( target , targetsync) ) match(construct={dispatch})   ! { dg-error "'append_args' clause at .1. specified more than once" }
+  end subroutine
+
+
+  subroutine f2b ()
+    !$omp declare variant (f1c)  &
+    !$omp&     append_args ( interop ( target , targetsync) )   ! { dg-error "the 'append_args' clause at .1. can only be specified if the 'dispatch' selector of the construct selector set appears in the 'match' clause" } 
+  end subroutine
+
+  subroutine f2c (x,y)
+    !$omp declare variant (fop) , append_args ( interop ( prefer_type ( "cuda", "hip" ) ) , interop(target)) , &
+    !$omp&     adjust_args (need_device_ptr : x, y )   ! { dg-error "the 'adjust_args' clause at .1. can only be specified if the 'dispatch' selector of the construct selector set appears in the 'match' clause" } 
+    type(c_ptr) :: x, y
+    value :: y
+  end subroutine
+
+  subroutine f2d ()
+    !$omp declare variant (f1d) append_args ( interop ( prefer_type ( "cuda", "hip" ) ) , interop(target)) ,  ! { dg-error "111: expected 'match', 'adjust_args' or 'append_args' at .1." }
+  end subroutine
+
+  subroutine f2e ()
+    !$omp declare variant (f1e) append_args ( interop ( prefer_type ( "cuda", "hip" ) ) , interop(target) interop(targetsync))  ! { dg-error "Expected ',' or '\\)' at .1." }
+  end subroutine
+end
diff --git a/gcc/testsuite/gfortran.dg/gomp/append_args-2.f90 b/gcc/testsuite/gfortran.dg/gomp/append_args-2.f90
new file mode 100644
index 0000000000000000000000000000000000000000..7a68977ed4d0d28d3e6c47a6278405caa7f5957a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/append_args-2.f90
@@ -0,0 +1,199 @@
+! { dg-do compile }
+! { dg-additional-options "-fcoarray=single" }
+
+module my_omp_lib
+ use iso_c_binding
+ implicit none
+
+ ! The following definitions are in omp_lib, which cannot be included
+ ! in gcc/testsuite/
+ integer, parameter :: omp_interop_kind = c_intptr_t
+ integer, parameter :: omp_interop_fr_kind = c_int
+
+ integer (omp_interop_kind), parameter :: omp_interop_none = 0_omp_interop_kind
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_cuda = 1
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_cuda_driver = 2
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_opencl = 3
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_sycl = 4
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_hip = 5
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_level_zero = 6
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_hsa = 7
+end module my_omp_lib
+
+module m
+  use my_omp_lib
+  implicit none
+  logical, parameter :: flag = .true.
+contains
+  subroutine f1o (obj)
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine f1ox (q,r, obj)
+  ! { dg-error "'q' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    type(c_ptr) :: q, r
+    value :: r
+    integer(omp_interop_kind),value :: obj
+  end
+
+
+  subroutine f5 ()
+    !$omp declare variant (f1ox) match(user={condition(flag)}) & ! { dg-error "the 'append_args' clause can only be specified if the 'dispatch' selector of the construct selector set appears in the 'match' clause at .1." }
+    !$omp&  append_args ( interop ( target , targetsync) )
+    ! { dg-error "'q' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+  end subroutine
+
+  subroutine f6 (x, y)
+    !$omp declare variant (f1ox) match(user={condition(flag)}) & ! { dg-error "the 'adjust_args' clause can only be specified if the 'dispatch' selector of the construct selector set appears in the 'match' clause at .1." }
+    !$omp&  append_args ( interop ( target , targetsync) ) &
+    !$omp&  adjust_args ( need_device_ptr : x , y)
+    type(c_ptr) :: x, y
+    value :: y
+  end subroutine
+
+  subroutine g1 (obj, obj2, obj3)
+    integer(omp_interop_kind),value :: obj,obj3
+    integer(omp_interop_kind),value :: obj2
+  end
+  subroutine g1a (obj)
+    !$omp declare variant (g1 ) match(construct={dispatch}) append_args ( interop ( target , targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine g2 (obj, obj2, obj3)
+    ! { dg-error "'g2' at .1. has 2 but requires 1 'omp_interop_kind' kind dummy arguments as it is utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj,obj2,obj3
+  end
+  subroutine g2a (obj)
+    !$omp declare variant (g2 ) match(construct={dispatch}) append_args ( interop( target, prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")}), targetsync))
+    ! { dg-error "'g2' at .1. has 2 but requires 1 'omp_interop_kind' kind dummy arguments as it is utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine g3 (obj, obj2, obj3)
+    integer(omp_interop_kind),value :: obj,obj3
+    integer(omp_interop_kind) :: obj2
+  end
+  subroutine g3a (obj)
+    !$omp declare variant (g3 ) match(construct={dispatch}) append_args ( interop ( target , targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine g4 (obj, obj2, obj3)
+    integer(omp_interop_kind),value :: obj,obj3
+    integer(omp_interop_kind) :: obj2
+  end
+  subroutine g4a (obj)
+    !$omp declare variant (g4 ) match(construct={dispatch}) append_args ( interop ( target , targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine g5 (obj, obj2, obj3)
+    ! { dg-error "'obj3' at .1. with OPTIONAL attribute not support when utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj,obj3
+    integer(omp_interop_kind) :: obj2
+    optional :: obj3
+  end
+  subroutine g5a (obj)
+    !$omp declare variant (g5 ) match(construct={dispatch}) append_args ( interop ( target , targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+    ! { dg-error "'obj3' at .1. with OPTIONAL attribute not support when utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine g5var (obj, obj2, obj3)
+    ! { dg-error "'obj3' at .1. with OPTIONAL attribute not support when utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind) :: obj,obj3
+    integer(omp_interop_kind) :: obj2
+    value :: obj
+    optional :: obj3
+  end
+  subroutine g5avar (obj)
+    !$omp declare variant (g5var ) match(construct={dispatch}) append_args ( interop ( target , targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+    ! { dg-error "'obj3' at .1. with OPTIONAL attribute not support when utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine g6 (obj, obj2, obj3)
+    ! { dg-error "'obj3' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+    integer(omp_interop_kind),pointer :: obj3
+    integer(omp_interop_kind) :: obj2
+  end
+  subroutine g6a (obj)
+    !$omp declare variant (g6 ) match(construct={dispatch}) append_args ( interop ( target , targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+    ! { dg-error "'obj3' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine g7 (obj, obj2, obj3)
+    ! { dg-error "'obj2' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+    integer(omp_interop_kind) :: obj3
+    integer(omp_interop_kind),allocatable :: obj2
+  end
+  subroutine g7a (obj)
+    !$omp declare variant (g7 ) match(construct={dispatch}) append_args ( interop ( target , targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+    ! { dg-error "'obj2' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine g8 (obj, obj2, obj3)
+    ! { dg-error "'obj2' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+    integer(omp_interop_kind) :: obj3
+    integer(omp_interop_kind) :: obj2(:)
+  end
+  subroutine g8a (obj)
+    !$omp declare variant (g8 ) match(construct={dispatch}) append_args ( interop ( target , targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+    ! { dg-error "'obj2' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine g9 (obj, obj2, obj3)
+    ! { dg-error "'obj2' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+    integer(omp_interop_kind) :: obj3
+    integer(omp_interop_kind) :: obj2(2)
+  end
+  subroutine g9a (obj)
+    !$omp declare variant (g9 ) match(construct={dispatch}) append_args ( interop ( target , targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+    ! { dg-error "'obj2' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine g10 (obj, obj2, obj3)
+    ! { dg-error "'obj2' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+    integer(omp_interop_kind) :: obj3
+    integer(1) :: obj2
+  end
+  subroutine g10a (obj)
+    !$omp declare variant (g10 ) match(construct={dispatch}) append_args ( interop ( target , targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+    ! { dg-error "'obj2' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine g11 (obj, obj2, obj3)
+    ! { dg-error "'obj2' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+    integer(omp_interop_kind) :: obj3
+    real(omp_interop_kind) :: obj2  ! { dg-warning "C kind type parameter is for type INTEGER but type at .1. is REAL" }
+  end
+  subroutine g11a (obj)
+    !$omp declare variant (g11 ) match(construct={dispatch}) append_args ( interop ( target , targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+    ! { dg-error "'obj2' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+  end
+
+  subroutine g12 (obj, obj2, obj3)
+    ! { dg-error "'obj2' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+    integer(omp_interop_kind) :: obj3
+    integer(omp_interop_kind) :: obj2[*]
+  end
+  subroutine g12a (obj)
+    !$omp declare variant (g12 ) match(construct={dispatch}) append_args ( interop ( target , targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+    ! { dg-error "'obj2' at .1. must be a nonpointer, nonallocatable scalar integer dummy argument of 'omp_interop_kind' kind as it utilized with the 'append_args' clause at .2." "" { target *-*-* } .-1 }
+    integer(omp_interop_kind),value :: obj
+  end
+end
diff --git a/gcc/testsuite/gfortran.dg/gomp/append_args-3.f90 b/gcc/testsuite/gfortran.dg/gomp/append_args-3.f90
new file mode 100644
index 0000000000000000000000000000000000000000..5dbc246fc5376f5ee58d7bb5212ffdd00f2a7b53
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/append_args-3.f90
@@ -0,0 +1,293 @@
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-gimple -cpp" }
+
+module my_omp_lib
+ use iso_c_binding
+ implicit none
+
+ ! The following definitions are in omp_lib, which cannot be included
+ ! in gcc/testsuite/
+ integer, parameter :: omp_interop_kind = c_intptr_t
+ integer, parameter :: omp_interop_fr_kind = c_int
+
+ integer (omp_interop_kind), parameter :: omp_interop_none = 0_omp_interop_kind
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_cuda = 1
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_cuda_driver = 2
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_opencl = 3
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_sycl = 4
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_hip = 5
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_level_zero = 6
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_hsa = 7
+end module my_omp_lib
+
+module m
+  use my_omp_lib
+  implicit none (type, external)
+
+  integer(omp_interop_kind) :: myobj_mod, myobj2_mod
+  integer(omp_interop_kind), allocatable :: myobj_mod_alloc, myobj2_mod_alloc
+contains
+
+  subroutine vsub_no_arg (o_dummy, o_value)
+    integer(omp_interop_kind) :: o_dummy
+    integer(omp_interop_kind), value :: o_value
+  end
+  subroutine sub_no_arg ()
+    !$omp declare variant (vsub_no_arg ) match(construct={dispatch}) append_args (interop(targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+  end
+
+  integer(c_int) function vfun_cbind(arg2_int, arg2_str, o2_dummy, o2_value) bind(C)
+    integer(c_int), value :: arg2_int
+    character(len=1, kind=c_char) :: arg2_str(*)
+    integer(omp_interop_kind) :: o2_dummy
+    integer(omp_interop_kind), value :: o2_value
+    vfun_cbind = arg2_int
+  end
+  integer(c_int) function fun_cbind(arg2_int, arg2_str) bind(C)
+    !$omp declare variant(vfun_cbind)  , match(construct={dispatch}),append_args (interop(target), interop(target))
+    integer(c_int), value :: arg2_int
+    character(len=1, kind=c_char) :: arg2_str(*)
+    fun_cbind = arg2_int
+  end
+end
+
+subroutine test_sub_no_arg(obj_dummy_val, obj_dummy, obj_dummy_opt, obj_dummy_alloc, obj_dummy_alloc_opt, obj_dummy_ptr, obj_dummy_ptr_opt)
+  use m
+  implicit none (type, external)
+
+  integer(omp_interop_kind), value :: obj_dummy_val
+  integer(omp_interop_kind) :: obj_dummy
+  integer(omp_interop_kind), optional :: obj_dummy_opt
+
+  integer(omp_interop_kind), allocatable :: obj_dummy_alloc
+  integer(omp_interop_kind), allocatable, optional :: obj_dummy_alloc_opt
+
+  integer(omp_interop_kind), pointer :: obj_dummy_ptr
+  integer(omp_interop_kind), pointer, optional :: obj_dummy_ptr_opt
+
+  integer(omp_interop_kind), target :: obj_loc
+  integer(omp_interop_kind), pointer :: obj_loc_ptr
+  integer(omp_interop_kind), allocatable :: obj_loc_alloc
+
+  obj_loc = omp_interop_none
+  obj_loc_ptr => obj_loc
+
+  !$omp dispatch device(10) interop(obj_dummy_val, obj_dummy)
+    call sub_no_arg
+  !  subroutine vsub_no_arg (o_dummy, o_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(10\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj_dummy;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "obj_dummy_val\\.\[0-9\]+ = obj_dummy_val;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vsub_no_arg \\(&obj_dummy_val\\.\[0-9\]+, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(11) interop(obj_dummy, obj_dummy_val)
+    call sub_no_arg
+  !  subroutine vsub_no_arg (o_dummy, o_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(11\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vsub_no_arg \\(obj_dummy, obj_dummy_val\\);" 1 "gimple" } }
+
+  !$omp dispatch device(12) interop(obj_dummy_opt, obj_dummy_alloc)
+    call sub_no_arg
+  !  subroutine vsub_no_arg (o_dummy, o_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(12\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj_dummy_alloc;" 2 "gimple" } }
+  ! The follow inline shows up 4x sub_no_arg and 4x vfun_cbind
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*D\\.\[0-9\]+;" 8 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vsub_no_arg \\(obj_dummy_opt, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(13) interop(obj_dummy_alloc, obj_dummy_opt)
+    call sub_no_arg
+  !  subroutine vsub_no_arg (o_dummy, o_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(13\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj_dummy_opt;" 1 "gimple" } }
+  !              See above             D\\.\[0-9\]+ = \\*obj_dummy_alloc;
+  ! { dg-final { scan-tree-dump-times "vsub_no_arg \\(D\\.\[0-9\]+, D\\.\[0-9\]+\\);" 3 "gimple" } }
+
+  !$omp dispatch device(14) interop(obj_dummy_alloc_opt, obj_dummy_ptr)
+    call sub_no_arg
+  !  subroutine vsub_no_arg (o_dummy, o_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(14\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj_dummy_ptr;" 2 "gimple" } }
+  !              See above             D\\.\[0-9\]+ = \\*D\\.\[0-9\]+;
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj_dummy_alloc_opt;" 2 "gimple" } }
+  !              See above             vsub_no_arg \\(D\\.\[0-9\]+, D\\.\[0-9\]+\\);
+
+  !$omp dispatch device(15) interop(obj_dummy_ptr, obj_dummy_alloc_opt)
+    call sub_no_arg
+  !  subroutine vsub_no_arg (o_dummy, o_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(15\\);" 1 "gimple" } }
+  !              See above             D\\.\[0-9\]+ = \\*obj_dummy_alloc_opt;
+  !              See above             D\\.\[0-9\]+ = \\*D\\.\[0-9\]+;
+  !              See above             D\\.\[0-9\]+ = \\*obj_dummy_ptr;
+  !              See above             vsub_no_arg \\(D\\.\[0-9\]+, D\\.\[0-9\]+\\);
+
+  !$omp dispatch device(16) interop(obj_dummy_ptr_opt, myobj_mod)
+    call sub_no_arg
+  !  subroutine vsub_no_arg (o_dummy, o_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(16\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "myobj_mod\\.\[0-9\]+ = myobj_mod;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj_dummy_ptr_opt;" 2 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vsub_no_arg \\(D\\.\[0-9\]+, myobj_mod\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(17) interop(myobj_mod, obj_dummy_ptr_opt)
+    call sub_no_arg
+  !  subroutine vsub_no_arg (o_dummy, o_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(17\\);" 1 "gimple" } }
+  !              See above             D\\.\[0-9\]+ = \\*obj_dummy_ptr_opt;
+  !              See above             D\\.\[0-9\]+ = \\*D\\.\[0-9\]+;
+  ! { dg-final { scan-tree-dump-times "vsub_no_arg \\(&myobj_mod, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(18) interop(obj_loc, obj_loc_ptr)
+    call sub_no_arg
+  !  subroutine vsub_no_arg (o_dummy, o_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(18\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj_loc_ptr;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vsub_no_arg \\(&obj_loc, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(19) interop(obj_loc_ptr, obj_loc)
+    call sub_no_arg
+  !  subroutine vsub_no_arg (o_dummy, o_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(19\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "obj_loc\\.\[0-9\]+ = obj_loc;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vsub_no_arg \\(obj_loc_ptr, obj_loc\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(20) interop(obj_loc_alloc, myobj_mod_alloc)
+    call sub_no_arg
+  !  subroutine vsub_no_arg (o_dummy, o_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(20\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "myobj_mod_alloc\\.\[0-9\]+ = myobj_mod_alloc;" 2 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*myobj_mod_alloc\\.\[0-9\]+;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vsub_no_arg \\(obj_loc_alloc, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(21) interop(myobj_mod_alloc, obj_loc_alloc)
+    call sub_no_arg
+  !  subroutine vsub_no_arg (o_dummy, o_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(21\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj_loc_alloc;" 1 "gimple" } }
+  !              See above             myobj_mod_alloc\\.\[0-9\]+ = myobj_mod_alloc;
+  ! { dg-final { scan-tree-dump-times "vsub_no_arg \\(myobj_mod_alloc\\.\[0-9\]+, D\\.\[0-9\]+\\);" 1 "gimple" } }
+end
+
+
+integer(c_int) function test_fun_cbind (obj2_dummy_val, obj2_dummy, obj2_dummy_opt, obj2_dummy_alloc, obj2_dummy_alloc_opt, obj2_dummy_ptr, obj2_dummy_ptr_opt)
+  use m
+  implicit none (type, external)
+
+  integer(omp_interop_kind), value :: obj2_dummy_val
+  integer(omp_interop_kind) :: obj2_dummy
+  integer(omp_interop_kind), optional :: obj2_dummy_opt
+
+  integer(omp_interop_kind), allocatable :: obj2_dummy_alloc
+  integer(omp_interop_kind), allocatable, optional :: obj2_dummy_alloc_opt
+
+  integer(omp_interop_kind), pointer :: obj2_dummy_ptr
+  integer(omp_interop_kind), pointer, optional :: obj2_dummy_ptr_opt
+
+  integer(omp_interop_kind), target :: obj2_loc
+  integer(omp_interop_kind), pointer :: obj2_loc_ptr
+  integer(omp_interop_kind), allocatable :: obj2_loc_alloc
+
+  integer :: i30, i31, i32, i33, i34, i35, i36, i37, i38, i39, i40, i41
+
+  obj2_loc = omp_interop_none
+  obj2_loc_ptr => obj2_loc
+
+  !$omp dispatch device(30) interop(obj2_dummy, obj2_dummy_val)
+    i30 = fun_cbind (300, "abc30" // c_null_char)
+  !  vfun_cbind(arg2_int, arg2_str, o2_dummy, o2_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(30\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "i30 = vfun_cbind \\(300, &\"abc30\"\\\[1\\\]\{lb: 1 sz: 1\}, obj2_dummy, obj2_dummy_val\\);" 1 "gimple" } }
+
+  !$omp dispatch device(31) interop(obj2_dummy_val, obj2_dummy)
+    i31 = fun_cbind (301, "abc31" // c_null_char)
+  !  vfun_cbind(arg2_int, arg2_str, o2_dummy, o2_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(31\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj2_dummy;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "obj2_dummy_val\\.\[0-9\]+ = obj2_dummy_val;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "i31 = vfun_cbind \\(301, &\"abc31\"\\\[1\\\]\{lb: 1 sz: 1\}, &obj2_dummy_val\\.\[0-9\]+, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(32) interop(obj2_dummy_opt, obj2_dummy_alloc)
+    i32 = fun_cbind (302, "abc32" // c_null_char)
+  !  vfun_cbind(arg2_int, arg2_str, o2_dummy, o2_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(32\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj2_dummy_alloc;" 2 "gimple" } }
+  !              See above             D\\.\[0-9\]+ = \\*D\\.\[0-9\]+;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "i32 = vfun_cbind \\(302, &\"abc32\"\\\[1\\\]\{lb: 1 sz: 1\}, obj2_dummy_opt, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(33) interop(obj2_dummy_alloc, obj2_dummy_opt)
+    i33 = fun_cbind (303, "abc33" // c_null_char)
+  !  vfun_cbind(arg2_int, arg2_str, o2_dummy, o2_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(33\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj2_dummy_opt;" 1 "gimple" } }
+  !              See above             D\\.\[0-9\]+ = \\*obj2_dummy_alloc;
+  ! { dg-final { scan-tree-dump-times "i33 = vfun_cbind \\(303, &\"abc33\"\\\[1\\\]\{lb: 1 sz: 1\}, D\\.\[0-9\]+, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(34) interop(obj2_dummy_alloc_opt, obj2_dummy_ptr)
+    i34 = fun_cbind (304, "abc34" // c_null_char)
+  !  vfun_cbind(arg2_int, arg2_str, o2_dummy, o2_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(34\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj2_dummy_ptr;" 2 "gimple" } }
+  !              See above             D\\.\[0-9\]+ = \\*D\\.\[0-9\]+;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj2_dummy_alloc_opt;" 2 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "i34 = vfun_cbind \\(304, &\"abc34\"\\\[1\\\]\{lb: 1 sz: 1\}, D\\.\[0-9\]+, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(35) interop(obj2_dummy_ptr, obj2_dummy_alloc_opt)
+    i35 = fun_cbind (305, "abc35" // c_null_char)
+  !  vfun_cbind(arg2_int, arg2_str, o2_dummy, o2_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(35\\);" 1 "gimple" } }
+  !              See above             D\\.\[0-9\]+ = \\*obj2_dummy_alloc_opt;
+  !              See above             D\\.\[0-9\]+ = \\*D\\.\[0-9\]+;" 1 "gimple" } }
+  !              See above             D\\.\[0-9\]+ = \\*obj2_dummy_ptr;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "i35 = vfun_cbind \\(305, &\"abc35\"\\\[1\\\]\{lb: 1 sz: 1\}, D\\.\[0-9\]+, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(36) interop(obj2_dummy_ptr_opt, myobj2_mod)
+    i36 = fun_cbind (306, "abc36" // c_null_char)
+  !  vfun_cbind(arg2_int, arg2_str, o2_dummy, o2_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(36\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "myobj2_mod\\.\[0-9\]+ = myobj2_mod;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj2_dummy_ptr_opt;" 2 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "i36 = vfun_cbind \\(306, &\"abc36\"\\\[1\\\]\{lb: 1 sz: 1\}, D\\.\[0-9\]+, myobj2_mod\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(37) interop(myobj2_mod, obj2_dummy_ptr_opt)
+    i37 = fun_cbind (307, "abc37" // c_null_char)
+  !  vfun_cbind(arg2_int, arg2_str, o2_dummy, o2_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(37\\);" 1 "gimple" } }
+  !              See above             D\\.\[0-9\]+ = \\*obj2_dummy_ptr_opt;
+  !              See above             D\\.\[0-9\]+ = \\*D\\.\[0-9\]+;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "i37 = vfun_cbind \\(307, &\"abc37\"\\\[1\\\]\{lb: 1 sz: 1\}, &myobj2_mod, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(38) interop(obj2_loc, obj2_loc_ptr)
+    i38 = fun_cbind (308, "abc38" // c_null_char)
+  !  vfun_cbind(arg2_int, arg2_str, o2_dummy, o2_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(38\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj2_loc_ptr;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "i38 = vfun_cbind \\(308, &\"abc38\"\\\[1\\\]\{lb: 1 sz: 1\}, &obj2_loc, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(39) interop(obj2_loc_ptr, obj2_loc)
+    i39 = fun_cbind (309, "abc39" // c_null_char)
+  !  vfun_cbind(arg2_int, arg2_str, o2_dummy, o2_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(39\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "obj2_loc\\.\[0-9\]+ = obj2_loc;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "i39 = vfun_cbind \\(309, &\"abc39\"\\\[1\\\]\{lb: 1 sz: 1\}, obj2_loc_ptr, obj2_loc\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(40) interop(obj2_loc_alloc, myobj2_mod_alloc)
+    i40 = fun_cbind (400, "abc40" // c_null_char)
+  !  vfun_cbind(arg2_int, arg2_str, o2_dummy, o2_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(40\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "myobj2_mod_alloc\\.\[0-9\]+ = myobj2_mod_alloc;" 2 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*myobj2_mod_alloc\\.\[0-9\]+;" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "i40 = vfun_cbind \\(400, &\"abc40\"\\\[1\\\]\{lb: 1 sz: 1\}, obj2_loc_alloc, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  !$omp dispatch device(41) interop(myobj2_mod_alloc, obj2_loc_alloc)
+    i41 = fun_cbind (401, "abc41" // c_null_char)
+  !  vfun_cbind(arg2_int, arg2_str, o2_dummy, o2_value)
+  ! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(41\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = \\*obj2_loc_alloc;" 1 "gimple" } }
+  !              See above             myobj2_mod_alloc\\.\[0-9\]+ = myobj2_mod_alloc;
+  ! { dg-final { scan-tree-dump-times "i41 = vfun_cbind \\(401, &\"abc41\"\\\[1\\\]\{lb: 1 sz: 1\}, myobj2_mod_alloc\\.\[0-9\]+, D\\.\[0-9\]+\\);" 1 "gimple" } }
+
+  test_fun_cbind = i30 + i31 + i32 + i33 + i34 + i35 + i36 + i37 + i38 + i39 + i40 + i41
+end
+
+! { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = __builtin_omp_get_default_device \\(\\);" 24 "gimple" } }
+! { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(D\\.\[0-9\]+\\);" 24 "gimple" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/append_args-4.f90 b/gcc/testsuite/gfortran.dg/gomp/append_args-4.f90
new file mode 100644
index 0000000000000000000000000000000000000000..6f550842ca97654e2575be82e5b4022bc00069f9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/append_args-4.f90
@@ -0,0 +1,264 @@
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-gimple -cpp" }
+
+module my_omp_lib
+ use iso_c_binding
+ implicit none
+
+ ! The following definitions are in omp_lib, which cannot be included
+ ! in gcc/testsuite/
+ integer, parameter :: omp_interop_kind = c_intptr_t
+ integer, parameter :: omp_interop_fr_kind = c_int
+
+ integer (omp_interop_kind), parameter :: omp_interop_none = 0_omp_interop_kind
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_cuda = 1
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_cuda_driver = 2
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_opencl = 3
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_sycl = 4
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_hip = 5
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_level_zero = 6
+ integer (omp_interop_fr_kind), parameter :: omp_ifr_hsa = 7
+end module my_omp_lib
+
+module m
+  use my_omp_lib
+  implicit none (type, external)
+
+  integer(omp_interop_kind) :: myobj_mod, myobj2_mod
+  integer(omp_interop_kind), allocatable :: myobj_mod_alloc, myobj2_mod_alloc
+contains
+
+  integer function vifun (str, int_opt, alloc_str, o_dummy, o_value)
+    character(len=*) :: str
+    integer, optional, value :: int_opt
+    character(len=:), allocatable :: alloc_str
+    integer(omp_interop_kind) :: o_dummy
+    integer(omp_interop_kind), value :: o_value
+    vifun = 0
+  end
+  integer function ifun (str, int_opt, alloc_str)
+    character(len=*) :: str
+    integer, optional, value :: int_opt
+    character(len=:), allocatable :: alloc_str
+    !$omp declare variant (vifun ) match(construct={dispatch}) append_args (interop(targetsync), interop( prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
+    ifun = 0
+  end
+
+  character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
+    character(len=*) :: str
+    integer, value :: int_var
+    integer, optional, value :: int_opt
+    character(len=:), allocatable :: alloc_str
+    integer(omp_interop_kind) :: o2_dummy
+    integer(omp_interop_kind), value :: o2_value
+    vfun = ""
+  end
+  character(len=len(str)) function fun (str, int_var, int_opt, alloc_str)
+    !$omp declare variant(vfun), match(construct={dispatch}),append_args (interop(target), interop(target))
+    character(len=*) :: str
+    integer, value :: int_var
+    integer, optional, value :: int_opt
+    character(len=:), allocatable :: alloc_str
+    fun = ""
+  end
+end
+
+integer function test_ifun(obj_dummy_val, obj_dummy, obj_dummy_opt, obj_dummy_alloc, obj_dummy_alloc_opt, obj_dummy_ptr, obj_dummy_ptr_opt)
+  use m
+  implicit none (type, external)
+
+  integer(omp_interop_kind), value :: obj_dummy_val
+  integer(omp_interop_kind) :: obj_dummy
+  integer(omp_interop_kind), optional :: obj_dummy_opt
+
+  integer(omp_interop_kind), allocatable :: obj_dummy_alloc
+  integer(omp_interop_kind), allocatable, optional :: obj_dummy_alloc_opt
+
+  integer(omp_interop_kind), pointer :: obj_dummy_ptr
+  integer(omp_interop_kind), pointer, optional :: obj_dummy_ptr_opt
+
+  integer(omp_interop_kind), target :: obj_loc
+  integer(omp_interop_kind), pointer :: obj_loc_ptr
+  integer(omp_interop_kind), allocatable :: obj_loc_alloc
+
+  character(len=:), allocatable :: str_alloc
+  integer :: i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21
+
+  obj_loc = omp_interop_none
+  obj_loc_ptr => obj_loc
+
+  !$omp dispatch device(10) interop(obj_dummy_val, obj_dummy)
+    i10 = ifun ("abc10", i10, str_alloc)
+  !  integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
+  !  -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
+  ! { dg-final { scan-tree-dump-times "i10 = vifun \\(&\"abc10\"\\\[1\\\]\{lb: 1 sz: 1\}, i10, &str_alloc, &obj_dummy_val\\.\[0-9\]+, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
+
+  !$omp dispatch device(11) interop(obj_dummy, obj_dummy_val)
+    i11 = ifun ("abc11", i11, str_alloc)
+  !  integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
+  !  -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
+  ! { dg-final { scan-tree-dump-times "i11 = vifun \\(&\"abc11\"\\\[1\\\]\{lb: 1 sz: 1\}, i11, &str_alloc, obj_dummy, obj_dummy_val, 1, 5, &.str_alloc\\);" 1 "gimple" } }
+
+  !$omp dispatch device(12) interop(obj_dummy_opt, obj_dummy_alloc)
+    i12 = ifun ("abc12", i12, str_alloc)
+  !  integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
+  !  -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
+  ! { dg-final { scan-tree-dump-times "i12 = vifun \\(&\"abc12\"\\\[1\\\]\{lb: 1 sz: 1\}, i12, &str_alloc, obj_dummy_opt, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
+
+  !$omp dispatch device(13) interop(obj_dummy_alloc, obj_dummy_opt)
+    i13 = ifun ("abc13", i13, str_alloc)
+  !  integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
+  !  -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
+  ! { dg-final { scan-tree-dump-times "i13 = vifun \\(&\"abc13\"\\\[1\\\]\{lb: 1 sz: 1\}, i13, &str_alloc, D\.\[0-9\]+, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
+
+  !$omp dispatch device(14) interop(obj_dummy_alloc_opt, obj_dummy_ptr)
+    i14 = ifun ("abc14", i14, str_alloc)
+  !  integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
+  !  -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
+  ! { dg-final { scan-tree-dump-times "i14 = vifun \\(&\"abc14\"\\\[1\\\]\{lb: 1 sz: 1\}, i14, &str_alloc, D\.\[0-9\]+, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
+
+  !$omp dispatch device(15) interop(obj_dummy_ptr, obj_dummy_alloc_opt)
+    i15 = ifun ("abc15", i15, str_alloc)
+  !  integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
+  !  -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
+  ! { dg-final { scan-tree-dump-times "i15 = vifun \\(&\"abc15\"\\\[1\\\]\{lb: 1 sz: 1\}, i15, &str_alloc, D\.\[0-9\]+, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
+
+  !$omp dispatch device(16) interop(obj_dummy_ptr_opt, myobj_mod)
+    i16 = ifun ("abc16", i16, str_alloc)
+  !  integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
+  !  -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
+  ! { dg-final { scan-tree-dump-times "i16 = vifun \\(&\"abc16\"\\\[1\\\]\{lb: 1 sz: 1\}, i16, &str_alloc, D\.\[0-9\]+, myobj_mod\\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
+
+  !$omp dispatch device(17) interop(myobj_mod, obj_dummy_ptr_opt)
+    i17 = ifun ("abc17", i17, str_alloc)
+  !  integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
+  !  -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
+  ! { dg-final { scan-tree-dump-times "i17 = vifun \\(&\"abc17\"\\\[1\\\]\{lb: 1 sz: 1\}, i17, &str_alloc, &myobj_mod, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
+
+  !$omp dispatch device(18) interop(obj_loc, obj_loc_ptr)
+    i18 = ifun ("abc18", i18, str_alloc)
+  !  integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
+  !  -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
+  ! { dg-final { scan-tree-dump-times "i18 = vifun \\(&\"abc18\"\\\[1\\\]\{lb: 1 sz: 1\}, i18, &str_alloc, &obj_loc, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
+
+  !$omp dispatch device(19) interop(obj_loc_ptr, obj_loc)
+    i19 = ifun ("abc19", i19, str_alloc)
+  !  integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
+  !  -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
+  ! { dg-final { scan-tree-dump-times "i19 = vifun \\(&\"abc19\"\\\[1\\\]\{lb: 1 sz: 1\}, i19, &str_alloc, obj_loc_ptr, obj_loc\\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
+
+  !$omp dispatch device(20) interop(obj_loc_alloc, myobj_mod_alloc)
+    i20 = ifun ("abc20", i20, str_alloc)
+  !  integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
+  !  -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
+  ! { dg-final { scan-tree-dump-times "i20 = vifun \\(&\"abc20\"\\\[1\\\]\{lb: 1 sz: 1\}, i20, &str_alloc, obj_loc_alloc, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
+
+  !$omp dispatch device(21) interop(myobj_mod_alloc, obj_loc_alloc)
+    i21 = ifun ("abc21", i21, str_alloc)
+  !  integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
+  !  -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
+  ! { dg-final { scan-tree-dump-times "i21 = vifun \\(&\"abc21\"\\\[1\\\]\{lb: 1 sz: 1\}, i21, &str_alloc, myobj_mod_alloc\\.\[0-9\]+, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
+
+  test_ifun = i10 + i11 + i12 + i13 + i14 + i15 + i16 + i17 + i18 + i19 + i20 + i21
+end
+
+
+integer(c_int) function test_fun (obj2_dummy_val, obj2_dummy, obj2_dummy_opt, obj2_dummy_alloc, obj2_dummy_alloc_opt, obj2_dummy_ptr, obj2_dummy_ptr_opt)
+  use m
+  implicit none (type, external)
+
+  integer(omp_interop_kind), value :: obj2_dummy_val
+  integer(omp_interop_kind) :: obj2_dummy
+  integer(omp_interop_kind), optional :: obj2_dummy_opt
+
+  integer(omp_interop_kind), allocatable :: obj2_dummy_alloc
+  integer(omp_interop_kind), allocatable, optional :: obj2_dummy_alloc_opt
+
+  integer(omp_interop_kind), pointer :: obj2_dummy_ptr
+  integer(omp_interop_kind), pointer, optional :: obj2_dummy_ptr_opt
+
+  integer(omp_interop_kind), target :: obj2_loc
+  integer(omp_interop_kind), pointer :: obj2_loc_ptr
+  integer(omp_interop_kind), allocatable :: obj2_loc_alloc
+
+  character(len=:), allocatable :: str_alloc
+  character(1) :: res_str
+  integer :: i30, i31, i32, i33, i34, i35, i36, i37, i38, i39, i40, i41
+  i30 = 0; i31 = 0; i32 = 0; i33 = 0; i34 = 0; i35 = 0; i36 = 0; i37 = 0; i38 = 0; i39 = 0; i40 = 0; i41 = 0
+
+  obj2_loc = omp_interop_none
+  obj2_loc_ptr => obj2_loc
+
+  !$omp dispatch device(30) interop(obj2_dummy, obj2_dummy_val)
+    res_str = fun ("klm30", 300, i30, str_alloc)
+  !  character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
+  !  -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
+
+  !$omp dispatch device(31) interop(obj2_dummy_val, obj2_dummy)
+    res_str = fun ("klm31", 301, i31, str_alloc)
+  !  character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
+  !  -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
+
+  !$omp dispatch device(32) interop(obj2_dummy_opt, obj2_dummy_alloc)
+    res_str = fun ("klm32", 302, i32, str_alloc)
+  !  character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
+  !  -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
+
+  !$omp dispatch device(33) interop(obj2_dummy_alloc, obj2_dummy_opt)
+    res_str = fun ("klm33", 303, i33, str_alloc)
+  !  character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
+  !  -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
+
+  !$omp dispatch device(34) interop(obj2_dummy_alloc_opt, obj2_dummy_ptr)
+    res_str = fun ("klm34", 304, i34, str_alloc)
+  !  character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
+  !  -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
+
+  !$omp dispatch device(35) interop(obj2_dummy_ptr, obj2_dummy_alloc_opt)
+    res_str = fun ("klm35", 305, i35, str_alloc)
+  !  character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
+  !  -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
+
+  !$omp dispatch device(36) interop(obj2_dummy_ptr_opt, myobj2_mod)
+    res_str = fun ("klm36", 306, i36, str_alloc)
+  !  character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
+  !  -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
+
+  !$omp dispatch device(37) interop(myobj2_mod, obj2_dummy_ptr_opt)
+    res_str = fun ("klm37", 307, i37, str_alloc)
+  !  character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
+  !  -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
+
+  !$omp dispatch device(38) interop(obj2_loc, obj2_loc_ptr)
+    res_str = fun ("klm30", 308, i38, str_alloc)
+  !  character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
+  !  -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
+
+  !$omp dispatch device(39) interop(obj2_loc_ptr, obj2_loc)
+    res_str = fun ("klm39", 309, i39, str_alloc)
+  !  character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
+  !  -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
+
+  !$omp dispatch device(40) interop(obj2_loc_alloc, myobj2_mod_alloc)
+    res_str = fun ("klm40", 400, i40, str_alloc)
+  !  character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
+
+  !$omp dispatch device(41) interop(myobj2_mod_alloc, obj2_loc_alloc)
+    res_str = fun ("klm41", 401, i41, str_alloc)
+  !  character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
+  !  -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
+
+  test_fun = i30 + i31 + i32 + i33 + i34 + i35 + i36 + i37 + i38 + i39 + i40 + i41
+end
+  ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 300, D\\.\[0-9\]+, D\\.\[0-9\]+, obj2_dummy, obj2_dummy_val, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 301, D\\.\[0-9\]+, D\\.\[0-9\]+, &obj2_dummy_val\\.\[0-9\]+, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 302, D\\.\[0-9\]+, D\\.\[0-9\]+, obj2_dummy_opt, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 303, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 304, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 305, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 306, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, myobj2_mod\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 307, D\\.\[0-9\]+, D\\.\[0-9\]+, &myobj2_mod, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 308, D\\.\[0-9\]+, D\\.\[0-9\]+, &obj2_loc, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 309, D\\.\[0-9\]+, D\\.\[0-9\]+, obj2_loc_ptr, obj2_loc\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 400, D\\.\[0-9\]+, D\\.\[0-9\]+, obj2_loc_alloc, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
+  ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 401, D\\.\[0-9\]+, D\\.\[0-9\]+, myobj2_mod_alloc\\.\[0-9\]+, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/atomic-26.f90 b/gcc/testsuite/gfortran.dg/gomp/atomic-26.f90
index 6448bd9b8bb36999c3464d35c015d41b97849d95..3d88cd72d8dcec5119cae417e066bdf8d97b794b 100644
--- a/gcc/testsuite/gfortran.dg/gomp/atomic-26.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/atomic-26.f90
@@ -38,11 +38,11 @@ real function bar (y, e, f)
   v = d
   !$omp atomic fail(relaxed), write	! { dg-error "FAIL clause is incompatible with READ or WRITE" }
   d = v
-  !$omp atomic fail(relaxed) update	! { dg-error "FAIL clause requiries either the COMPARE clause or using the intrinsic MIN/MAX procedure" }
+  !$omp atomic fail(relaxed) update	! { dg-error "FAIL clause requires either the COMPARE clause or using the intrinsic MIN/MAX procedure" }
   d = d + 3.0
-  !$omp atomic fail(relaxed)	! { dg-error "FAIL clause requiries either the COMPARE clause or using the intrinsic MIN/MAX procedure" }
+  !$omp atomic fail(relaxed)	! { dg-error "FAIL clause requires either the COMPARE clause or using the intrinsic MIN/MAX procedure" }
   d = d + 3.0
-  !$omp atomic capture fail(relaxed)	! { dg-error "FAIL clause requiries either the COMPARE clause or using the intrinsic MIN/MAX procedure" }
+  !$omp atomic capture fail(relaxed)	! { dg-error "FAIL clause requires either the COMPARE clause or using the intrinsic MIN/MAX procedure" }
   v = d; d = d + 3.0
   !$omp atomic read weak		! { dg-error "WEAK clause requires COMPARE clause" }
   v = d
diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-2.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-variant-2.f90
index 17b112f065bf129d2638b0860ecbf1aec967a443..11be76e84ffc5ad18b387d1de6f83bab6b588e12 100644
--- a/gcc/testsuite/gfortran.dg/gomp/declare-variant-2.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/declare-variant-2.f90
@@ -18,10 +18,10 @@ contains
     !$omp declare variant match(user={condition(.false.)})	! { dg-error "expected '\\(' at .1." }
   end subroutine
   subroutine f6 ()
-    !$omp declare variant (f1)	! { dg-error "expected 'match' or 'adjust_args' at .1." }
+    !$omp declare variant (f1)	! { dg-error "expected 'match', 'adjust_args' or 'append_args' at .1." }
   end subroutine
   subroutine f7 ()
-    !$omp declare variant (f1) simd	! { dg-error "expected 'match' or 'adjust_args' at .1." }
+    !$omp declare variant (f1) simd	! { dg-error "expected 'match', 'adjust_args' or 'append_args' at .1." }
   end subroutine
   subroutine f8 ()
     !$omp declare variant (f1) match	! { dg-error "expected '\\(' at .1." }
@@ -183,13 +183,13 @@ contains
     !$omp declare variant (f1) match(construct={requires})	! { dg-warning "unknown selector 'requires' for context selector set 'construct' at .1." }
   end subroutine
   subroutine f75a ()
-    !$omp declare variant(f1) ,,match(construct={dispatch}) adjust_args(need_device_ptr : c)        ! { dg-error "expected 'match' or 'adjust_args' at .1." }
+    !$omp declare variant(f1) ,,match(construct={dispatch}) adjust_args(need_device_ptr : c)        ! { dg-error "expected 'match', 'adjust_args' or 'append_args' at .1." }
   end subroutine
   subroutine f75b ()
-    !$omp declare variant(f1) match(construct={dispatch}),,adjust_args(need_device_ptr : c)        ! { dg-error "expected 'match' or 'adjust_args' at .1." }
+    !$omp declare variant(f1) match(construct={dispatch}),,adjust_args(need_device_ptr : c)        ! { dg-error "expected 'match', 'adjust_args' or 'append_args' at .1." }
   end subroutine
   subroutine f75c ()
-    !$omp declare variant(f1) match(construct={dispatch}),nowait(a)        ! { dg-error "expected 'match' or 'adjust_args' at .1." }
+    !$omp declare variant(f1) match(construct={dispatch}),nowait(a)        ! { dg-error "expected 'match', 'adjust_args' or 'append_args' at .1." }
   end subroutine
   subroutine f76 ()
     !$omp declare variant (f1) match(implementation={atomic_default_mem_order("relaxed")})	! { dg-error "expected identifier at .1." }
diff --git a/gcc/testsuite/gfortran.dg/gomp/defaultmap-8.f90 b/gcc/testsuite/gfortran.dg/gomp/defaultmap-8.f90
index e26d1e004b1a711f4215be47d63ec1b5ec1a1002..8250d6c0bc366ab50066433e90675db5439880ec 100644
--- a/gcc/testsuite/gfortran.dg/gomp/defaultmap-8.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/defaultmap-8.f90
@@ -22,5 +22,5 @@ program main
   !$omp end target
 end program
   
-! { dg-final { scan-tree-dump "pragma omp target.*defaultmap\\(present:aggregate\\).*map\\(force_present:c \\\[len: \[0-9\]+\\\]\\\[implicit\\\]\\) map\\(force_present:b \\\[len: \[0-9\]+\\\]\\\[implicit\\\]\\) map\\(force_present:a \\\[len: \[0-9\]+\\\]\\\[implicit\\\]\\)" "gimple" } }
-! { dg-final { scan-tree-dump "pragma omp target.*map\\(force_present:b \\\[len: \[0-9\]+\\\]\\\[implicit\\\]\\) map\\(force_present:a \\\[len: \[0-9\]+\\\]\\\[implicit\\\]\\) map\\(from:c \\\[len: \[0-9\]+\\\]\\) defaultmap\\(present:aggregate\\)" "gimple" } }
+! { dg-final { scan-tree-dump "pragma omp target.*defaultmap\\(present:aggregate\\).*map\\(force_present:c \\\[len: \[0-9\]+\\\] \\\[runtime_implicit\\\]\\) map\\(force_present:b \\\[len: \[0-9\]+\\\] \\\[runtime_implicit\\\]\\) map\\(force_present:a \\\[len: \[0-9\]+\\\] \\\[runtime_implicit\\\]\\)" "gimple" } }
+! { dg-final { scan-tree-dump "pragma omp target.*map\\(force_present:b \\\[len: \[0-9\]+\\\] \\\[runtime_implicit\\\]\\) map\\(force_present:a \\\[len: \[0-9\]+\\\] \\\[runtime_implicit\\\]\\) map\\(from:c \\\[len: \[0-9\]+\\\]\\) defaultmap\\(present:aggregate\\)" "gimple" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/defaultmap-9.f90 b/gcc/testsuite/gfortran.dg/gomp/defaultmap-9.f90
index b24fc95fc747c3272a8ecfa95cd9fc5b76adff97..73d116959992e7531e6ba7dd63a6b23384e1f61a 100644
--- a/gcc/testsuite/gfortran.dg/gomp/defaultmap-9.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/defaultmap-9.f90
@@ -68,4 +68,4 @@ end subroutine
 
 ! { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(firstprivate:all\\) firstprivate\\(scalar\\) firstprivate\\(ptr2\\) firstprivate\\(ptr1\\) firstprivate\\(array\\) firstprivate\\(alloc2\\) firstprivate\\(alloc1\\) firstprivate\\(agg2\\) firstprivate\\(agg1\\)" 1 "gimple" } }
 
-! { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(tofrom:all\\) map\\(tofrom:scalar \\\[len: .\\\]\\\[implicit\\\]\\) map\\(tofrom:.*ptr2.data \\\[len: .*\\\]\\\[implicit\\\]\\) map\\(to:ptr2 \\\[pointer set, len: ..\\\]\\) map\\(always_pointer:.*ptr2.data \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:\\*ptr1 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(alloc:ptr1 \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:array \\\[len: ..\\\]\\\[implicit\\\]\\) map\\(tofrom:.*alloc2.data \\\[len: .*\\\]\\\[implicit\\\]\\) map\\(to:alloc2 \\\[pointer set, len: ..\\\]\\) map\\(alloc:.*alloc2.data \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:\\*alloc1 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(alloc:alloc1 \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:agg2 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(tofrom:agg1 \\\[len: .\\\]\\\[implicit\\\]\\)" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(tofrom:all\\) map\\(tofrom:scalar \\\[len: .\\\] \\\[runtime_implicit\\\]\\) map\\(tofrom:.*ptr2.data \\\[len: .*\\\] \\\[runtime_implicit\\\]\\) map\\(to:ptr2 \\\[pointer set, len: ..\\\]\\) map\\(always_pointer:.*ptr2.data \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:\\*ptr1 \\\[len: .\\\] \\\[runtime_implicit\\\]\\) map\\(alloc:ptr1 \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:array \\\[len: ..\\\] \\\[runtime_implicit\\\]\\) map\\(tofrom:.*alloc2.data \\\[len: .*\\\] \\\[runtime_implicit\\\]\\) map\\(to:alloc2 \\\[pointer set, len: ..\\\]\\) map\\(alloc:.*alloc2.data \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:\\*alloc1 \\\[len: .\\\] \\\[runtime_implicit\\\]\\) map\\(alloc:alloc1 \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:agg2 \\\[len: .\\\] \\\[runtime_implicit\\\]\\) map\\(tofrom:agg1 \\\[len: .\\\] \\\[runtime_implicit\\\]\\)" 1 "gimple" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/map-subarray.f90 b/gcc/testsuite/gfortran.dg/gomp/map-subarray.f90
index 197888a43365a9918e20bfa08b53c4e5e871f9b9..e95b60dff176e0d2a66c9097de98b170b9cc228b 100644
--- a/gcc/testsuite/gfortran.dg/gomp/map-subarray.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/map-subarray.f90
@@ -18,7 +18,7 @@ tv%arr2 => arr
 tv%arr1(1) = tv%arr1(1) + 1
 !$omp end target
 
-! { dg-final { scan-tree-dump {(?n)#pragma omp target.* map\(struct:tv \[len: 1\]\) map\(to:tv\.arr1 \[pointer set, len: [0-9]+\]\) map\(tofrom:MEM <integer\(kind=4\)\[0:\]> \[\(integer\(kind=4\)\[0:\] \*\)_[0-9]+\] \[len: _[0-9]+\]\[implicit\]\) map\(attach:tv\.arr1\.data \[bias: 0\]\)} "gimple" } }
+! { dg-final { scan-tree-dump {(?n)#pragma omp target.* map\(struct:tv \[len: 1\]\) map\(to:tv\.arr1 \[pointer set, len: [0-9]+\]\) map\(tofrom:MEM <integer\(kind=4\)\[0:\]> \[\(integer\(kind=4\)\[0:\] \*\)_[0-9]+\] \[len: _[0-9]+\] \[runtime_implicit\]\) map\(attach:tv\.arr1\.data \[bias: 0\]\)} "gimple" } }
 
 !$omp target map(tv%arr2) map(tv%arr2(1:10))
 tv%arr2(1) = tv%arr2(1) + 1
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-1.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-1.f90
new file mode 100644
index 0000000000000000000000000000000000000000..15671f28415fa2bdfa16c1f986ab0e863d6925ab
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-1.f90
@@ -0,0 +1,80 @@
+! { dg-do compile }
+
+program main
+  integer, parameter :: N = 10
+  integer, dimension(N) :: a
+  integer, dimension(N) :: b
+  integer, dimension(N) :: c
+  integer :: i
+
+  do i = 1, N
+    a(i) = i * 2
+    b(i) = i * 3
+  end do
+
+  !$omp metadirective &
+  !$omp&	default (teams loop) &
+  !$omp&	default (parallel loop)	! { dg-error "too many 'otherwise' or 'default' clauses in 'metadirective' at .1." }
+    do i = 1, N
+      c(i) = a(i) * b(i)
+    end do
+
+  !$omp metadirective &
+  !$omp&	otherwise (teams loop) &
+  !$omp&	default (parallel loop)	! { dg-error "too many 'otherwise' or 'default' clauses in 'metadirective' at .1." }
+    do i = 1, N
+      c(i) = a(i) * b(i)
+    end do
+
+  !$omp metadirective &
+  !$omp&	otherwise (teams loop) &
+  !$omp&	otherwise (parallel loop)	! { dg-error "too many 'otherwise' or 'default' clauses in 'metadirective' at .1." }
+    do i = 1, N
+      c(i) = a(i) * b(i)
+    end do
+
+  !$omp metadirective default (xyz) ! { dg-error "Unclassifiable OpenMP directive at .1." }
+    do i = 1, N
+      c(i) = a(i) * b(i)
+    end do
+
+  !$omp metadirective &
+  !$omp&	default (teams loop) &
+  !$omp&	where (device={arch("nvptx")}: parallel loop) ! { dg-error "expected 'when', 'otherwise', or 'default' at .1." }
+    do i = 1, N
+      c(i) = a(i) * b(i)
+    end do
+
+  !$omp metadirective &
+  !$omp&	otherwise (teams loop) &
+  !$omp&	when (device={arch("nvptx")}: parallel loop) ! { dg-error "'otherwise' or 'default' clause must appear last" }
+    do i = 1, N
+      c(i) = a(i) * b(i)
+    end do
+
+  !$omp metadirective &
+  !$omp&	when (device={arch("nvptx")} parallel loop) & ! { dg-error "expected .:." } 
+  !$omp&	default (teams loop)
+    do i = 1, N
+      c(i) = a(i) * b(i)
+    end do
+
+  ! Test improperly nested metadirectives - even though the second
+  ! metadirective resolves to 'omp nothing', that is not the same as there
+  ! being literally nothing there.
+  !$omp metadirective &
+  !$omp&    when (implementation={vendor("gnu")}: parallel do)
+    !$omp metadirective &
+    !$omp& when (implementation={vendor("cray")}: parallel do) ! { dg-error "Unexpected !.OMP METADIRECTIVE statement" }
+      do i = 1, N
+        c(i) = a(i) * b(i)
+      end do
+
+!$omp begin metadirective &
+  !$omp&	when (device={arch("nvptx")}: parallel do) &
+  !$omp&	default (barrier) ! { dg-error "variant directive used in OMP BEGIN METADIRECTIVE at .1. must have a corresponding end directive" }
+    do i = 1, N
+      c(i) = a(i) * b(i)
+    end do
+  !$omp end metadirective ! { dg-error "Unexpected !.OMP END METADIRECTIVE statement at .1." }
+end program
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-10.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-10.f90
new file mode 100644
index 0000000000000000000000000000000000000000..5dad5d29eb6039fb4c5bb7756957c86cd93de92a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-10.f90
@@ -0,0 +1,40 @@
+! { dg-do compile }
+
+program metadirectives
+   implicit none
+   logical :: UseDevice
+
+   !$OMP metadirective &
+   !$OMP   when ( user = { condition ( UseDevice ) } &
+   !$OMP     : parallel ) &
+   !$OMP   default ( parallel )
+   block
+      call bar()
+   end block
+
+   !$OMP metadirective &
+   !$OMP   when ( user = { condition ( UseDevice ) } &
+   !$OMP     : parallel ) &
+   !$OMP   default ( parallel )
+   call bar()
+   !$omp end parallel  ! Accepted, because all cases have 'parallel'
+   
+   !$OMP begin metadirective &
+   !$OMP   when ( user = { condition ( UseDevice ) } &
+   !$OMP     : nothing ) &
+   !$OMP   default ( parallel )
+   call bar()
+   block
+      call foo()
+   end block
+   !$OMP end metadirective
+
+   !$OMP begin metadirective &
+   !$OMP   when ( user = { condition ( UseDevice ) } &
+   !$OMP     : parallel ) &
+   !$OMP   default ( parallel )
+   call bar()
+   !$omp end parallel  ! { dg-error "Unexpected !.OMP END PARALLEL statement at .1." }
+end program ! { dg-error "Unexpected END statement at .1." }
+
+! { dg-error "Unexpected end of file" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-11.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-11.f90
new file mode 100644
index 0000000000000000000000000000000000000000..e7de70e62598194b1a19f847634ae15ea4b639cf
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-11.f90
@@ -0,0 +1,33 @@
+! { dg-do compile }
+! { dg-ice "Statements following a block in a metadirective" }
+! PR fortran/107067
+
+program metadirectives
+   implicit none
+   logical :: UseDevice
+
+   !$OMP begin metadirective &
+   !$OMP   when ( user = { condition ( UseDevice ) } &
+   !$OMP     : nothing ) &
+   !$OMP   default ( parallel )
+   block
+      call foo()
+   end block
+   call bar()   ! FIXME/XFAIL ICE in parse_omp_metadirective_body()
+   !$omp end metadirective
+
+
+   !$OMP begin metadirective &
+   !$OMP   when ( user = { condition ( UseDevice ) } &
+   !$OMP     : nothing ) &
+   !$OMP   default ( parallel )
+   block
+      call bar()
+   end block
+   block        ! FIXME/XFAIL ICE in parse_omp_metadirective_body()
+      call foo()
+   end block
+   !$omp end metadirective
+end program
+
+
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-12.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-12.f90
new file mode 100644
index 0000000000000000000000000000000000000000..fc122cc90f243b5a116f38309578c14f64ca3c0d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-12.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+
+! PR112779 item H; this testcase used to ICE.
+
+program test
+  implicit none
+  integer, parameter :: N = 100
+  integer :: x(N), y(N), z(N)
+  block
+    integer :: i
+    !$omp metadirective &
+                !$omp& when(device={arch("nvptx")}: teams loop) &
+                !$omp& default(parallel loop)
+    do i = 1, N
+          z(i) = x(i) * y(i)
+    enddo
+   end block
+end
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-13.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-13.f90
new file mode 100644
index 0000000000000000000000000000000000000000..bc69f65afcb3bf381179719476a1c08de216c795
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-13.f90
@@ -0,0 +1,30 @@
+! { dg-do compile }
+
+subroutine foo
+  implicit none
+  external f
+
+  !$omp dispatch
+  call f()
+  !$omp dispatch
+    call f()
+  !$omp end dispatch
+
+  !$omp begin metadirective when(construct={parallel} : nothing) otherwise(dispatch)
+  call f()
+  !$omp end metadirective
+end
+
+subroutine bar
+  implicit none
+  integer :: x
+  !$omp atomic update
+    x = x + 1
+  !$omp atomic update
+    x = x + 1
+  !$omp end atomic
+
+  !$omp begin metadirective when(construct={parallel} : nothing) otherwise(atomic update)
+    x = x + 1
+  !$omp end metadirective
+end
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-2.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-2.f90
new file mode 100644
index 0000000000000000000000000000000000000000..bd0c3825b53631cdc7786184af9bb5fd778f2ea7
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-2.f90
@@ -0,0 +1,72 @@
+! { dg-do compile }
+
+program main
+  integer, parameter :: N = 100
+  integer :: x = 0
+  integer :: y = 0
+  integer :: i
+
+  ! Test implicit default directive
+  !$omp metadirective &
+  !$omp&	when (device={arch("nvptx")}: barrier)
+    x = 1
+
+  ! Test implicit default directive combined with a directive that takes a
+  ! do loop.
+  !$omp metadirective &
+  !$omp&	when (device={arch("nvptx")}: parallel do)
+    do i = 1, N
+      x = x + i
+    end do
+
+  ! Test with multiple standalone directives.
+  !$omp metadirective &
+  !$omp&	when (device={arch("nvptx")}: barrier) &
+  !$omp&	default (flush)
+    x = 1
+
+  ! Test combining a standalone directive with one that takes a do loop.
+  !$omp metadirective &
+  !$omp&	when (device={arch("nvptx")}: parallel do) &
+  !$omp&	default (barrier)
+    do i = 1, N
+      x = x + i
+    end do
+
+  ! Test combining a directive that takes a do loop with one that takes
+  ! a statement body.
+  !$omp begin metadirective &
+  !$omp&	when (device={arch("nvptx")}: parallel do) &
+  !$omp&	default (parallel)
+    do i = 1, N
+      x = x + i
+    end do
+  !$omp end metadirective
+  
+  ! Test labels in the body.
+  !$omp begin metadirective &
+  !$omp&	when (device={arch("nvptx")}: parallel do) &
+  !$omp&	when (device={arch("gcn")}: parallel)
+    do i = 1, N
+      x = x + i
+      if (x .gt. N/2) goto 10
+10    x = x + 1
+      goto 20
+      x = x + 2
+20    continue
+    end do
+  !$omp end metadirective
+
+  ! Test that commas are permitted before each clause.
+  !$omp begin metadirective, &
+  !$omp&	when (device={arch("nvptx")}: parallel do) &
+  !$omp&	, when (device={arch("gcn")}: parallel) &
+  !$omp&	, default (parallel)
+    do i = 1, N
+      x = x + i
+    end do
+  !$omp end metadirective
+
+  ! Test empty metadirective.
+  !$omp metadirective
+end program
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-3.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-3.f90
new file mode 100644
index 0000000000000000000000000000000000000000..c5e25e598eb1d2ba554a781d2f986394d453f5d9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-3.f90
@@ -0,0 +1,25 @@
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-gimple" }
+
+module test
+  integer, parameter :: N = 100
+contains
+  subroutine f (x, y, z)
+    integer :: x(N), y(N), z(N)
+
+    !$omp target map (to: v1, v2) map(from: v3)
+      !$omp metadirective &
+		!$omp& when(device={arch("nvptx")}: teams loop) &
+		!$omp& default(parallel loop)
+	do i = 1, N
+	  z(i) = x(i) * y(i)
+	enddo
+    !$omp end target
+  end subroutine
+end module
+
+! If offload device "nvptx" isn't supported, the front end can eliminate
+!  that alternative and not produce a metadirective at all.  Otherwise this
+!  won't be resolved until late.
+! { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" { target { ! offload_nvptx } } } }
+! { dg-final { scan-tree-dump "#pragma omp metadirective" "gimple" { target { offload_nvptx } } } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-4.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-4.f90
new file mode 100644
index 0000000000000000000000000000000000000000..1da4a0ce42fd274ee2700bcf45d72f816150c9f8
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-4.f90
@@ -0,0 +1,37 @@
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-original" }
+! { dg-additional-options "-fdump-tree-gimple" }
+
+program test
+  implicit none
+  integer, parameter :: N = 100
+  real :: a(N)
+  
+  !$omp target map(from: a)
+    call f (a, 3.14159)
+  !$omp end target
+
+  call f (a, 2.71828)
+contains
+  subroutine f (a, x)
+    integer :: i
+    real :: a(N), x
+    !$omp declare target
+
+    !$omp metadirective &
+    !$omp&  when (construct={target}: distribute parallel do ) &
+    !$omp&  default(parallel do simd)
+      do i = 1, N
+ 	a(i) = x * i
+      end do
+  end subroutine
+end program
+
+! The metadirective should be resolved during Gimplification.
+
+! { dg-final { scan-tree-dump-times "#pragma omp metadirective" 1 "original" } }
+! { dg-final { scan-tree-dump-times "when \\(construct = .*target.*\\):" 1 "original" } }
+! { dg-final { scan-tree-dump-times "otherwise:" 1 "original" } }
+! { dg-final { scan-tree-dump-times "#pragma omp parallel" 2 "original" } }
+
+! { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-5.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-5.f90
new file mode 100644
index 0000000000000000000000000000000000000000..03970393eb444eff184792325d0679fda3a2dac9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-5.f90
@@ -0,0 +1,30 @@
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-gimple" }
+
+module test
+  integer, parameter :: N = 100
+contains
+  subroutine f (a, flag)
+    integer :: a(N)
+    logical :: flag
+    integer :: i
+    
+   !$omp metadirective &
+   !$omp&  when (user={condition(flag)}: &
+   !$omp&	 target teams distribute parallel do map(from: a(1:N))) &
+   !$omp&  default(parallel do)
+     do i = 1, N
+       a(i) = i
+     end do
+  end subroutine
+end module
+
+! The metadirective should be resolved at parse time, but is currently
+! resolved during Gimplification
+
+! { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" } }
+! { dg-final { scan-tree-dump-times "#pragma omp target" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "#pragma omp teams" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times  "#pragma omp distribute" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "#pragma omp parallel" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "#pragma omp for" 2 "gimple" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-6.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-6.f90
new file mode 100644
index 0000000000000000000000000000000000000000..a38d8cfe58518e593ad44a7a741b77c9e9e6090f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-6.f90
@@ -0,0 +1,26 @@
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-gimple" }
+
+module test
+  integer, parameter :: N = 100
+contains
+  subroutine f (a, run_parallel, run_guided)
+    integer :: a(N)
+    logical :: run_parallel, run_guided
+    integer :: i
+
+    !$omp begin metadirective when(user={condition(run_parallel)}: parallel)
+      !$omp metadirective &
+      !$omp&  when(construct={parallel}, user={condition(run_guided)}: &
+      !$omp&       do schedule(guided)) &
+      !$omp&  when(construct={parallel}: do schedule(static))
+	do i = 1, N
+	  a(i) = i
+	end do
+    !$omp end metadirective
+  end subroutine
+end module
+
+! { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" } }
+! { dg-final { scan-tree-dump-times "#pragma omp parallel" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "#pragma omp for" 2 "gimple" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-7.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-7.f90
new file mode 100644
index 0000000000000000000000000000000000000000..37825e632511f35ce6658718d0bd3f1ef9ba9fb5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-7.f90
@@ -0,0 +1,42 @@
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-gimple -fdump-tree-ompdevlow" }
+
+subroutine f (a, num)
+  integer, parameter :: N = 256
+  integer :: a(N)
+  integer :: num
+  integer :: i
+
+  !$omp metadirective &
+  !$omp& when (target_device={device_num(num), kind("gpu"), arch("nvptx")}: &
+  !$omp&       target parallel do map(tofrom: a(1:N))) &
+  !$omp& when (target_device={device_num(num), kind("gpu"), &
+  !$omp&                      arch("amdgcn"), isa("gfx906")}: &
+  !$omp&       target parallel do) &
+  !$omp& when (target_device={device_num(num), kind("cpu"), arch("x86_64")}: &
+  !$omp&       parallel do)
+    do i = 1, N
+      a(i) = a(i) + i
+    end do
+
+  !$omp metadirective &
+  !$omp& when (target_device={kind("gpu"), arch("nvptx")}: &
+  !$omp&       target parallel do map(tofrom: a(1:N)))
+    do i = 1, N
+      a(i) = a(i) + i
+    end do
+end subroutine
+
+! For configurations with offloading, we expect one "pragma omp target"
+! with "device(num)" for each target_device selector that specifies
+! "device_num(num)".  Without offloading, there should be zero as the
+!  resolution happens during gimplification.
+! { dg-final { scan-tree-dump-times "pragma omp target\[^\\n\]* device\\(" 3 "gimple" { target offloading_enabled } } }
+! { dg-final { scan-tree-dump-times "pragma omp target\[^\\n\]* device\\(" 0 "gimple" { target { ! offloading_enabled } } } }
+
+! For configurations with offloading, expect one OMP_TARGET_DEVICE_MATCHES
+! for each kind/arch/isa selector.  These are supposed to go away after
+!  ompdevlow.
+! { dg-final { scan-tree-dump-times "OMP_TARGET_DEVICE_MATCHES" 9 "gimple" { target offloading_enabled } } }
+! { dg-final { scan-tree-dump-times "OMP_TARGET_DEVICE_MATCHES" 0 "gimple" { target { ! offloading_enabled } } } }
+! { dg-final { scan-tree-dump-times "OMP_TARGET_DEVICE_MATCHES" 0 "ompdevlow" { target offloading_enabled } } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-8.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-8.f90
new file mode 100644
index 0000000000000000000000000000000000000000..1ebcd33a7be8f1a6e2c7925a21a2d7b0d47d8b99
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-8.f90
@@ -0,0 +1,22 @@
+! { dg-do compile }
+
+program test
+  integer :: i
+  integer, parameter :: N = 100
+  integer :: sum = 0
+  
+  ! The compiler should never consider a situation where both metadirectives
+  ! match, but that does not matter because the spec says "Replacement of
+  ! the metadirective with the directive variant associated with any of the
+  ! dynamic replacement candidates must result in a conforming OpenMP
+  ! program.  So the second metadirective is rejected as not being
+  ! a valid loop-nest even if the first one does not match.
+  
+!$omp metadirective when (implementation={vendor("ibm")}: &
+  !$omp&  target teams distribute)
+    !$omp metadirective when (implementation={vendor("gnu")}: parallel do) ! { dg-error "Unexpected !.OMP METADIRECTIVE statement" }
+      do i = 1, N
+	sum = sum + i
+      end do
+end program
+
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-9.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-9.f90
new file mode 100644
index 0000000000000000000000000000000000000000..9a63de894b01914a055a89241a410bbfdb182943
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-9.f90
@@ -0,0 +1,30 @@
+! { dg-do compile }
+
+program OpenMP_Metadirective_WrongEnd_Test
+  implicit none
+
+  integer :: &
+  iaVS, iV, jV, kV
+  integer, dimension ( 3 ) :: &
+    lV, uV
+  logical :: &
+    UseDevice
+
+    !$OMP metadirective &
+    !$OMP   when ( user = { condition ( UseDevice ) } &
+    !$OMP     : target teams distribute parallel do simd collapse ( 3 ) &
+    !$OMP         private ( iaVS ) ) &
+    !$OMP   default ( parallel do simd collapse ( 3 ) private ( iaVS ) )
+    do kV = lV ( 3 ), uV ( 3 )
+      do jV = lV ( 2 ), uV ( 2 )
+        do iV = lV ( 1 ), uV ( 1 )
+
+
+        end do
+      end do
+    end do
+    !$OMP end target teams distribute parallel do simd ! { dg-error "Unexpected !.OMP END TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD statement in OMP METADIRECTIVE block at .1." }
+
+
+end program
+
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-construct.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-construct.f90
new file mode 100644
index 0000000000000000000000000000000000000000..ec1f0ee3d9de526066ff383bd503252a95e15890
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-construct.f90
@@ -0,0 +1,260 @@
+! { dg-do compile }
+! { dg-additional-options "-foffload=disable -fdump-tree-original -fdump-tree-gimple" }
+
+program main
+implicit none
+
+integer, parameter :: N = 10
+double precision, parameter :: S = 2.0
+double precision :: a(N)
+
+call init (N, a)
+call f1 (N, a, S)
+call check (N, a, S)
+
+call init (N, a)
+call f2 (N, a, S)
+call check (N, a, S)
+
+call init (N, a)
+call f3 (N, a, S)
+call check (N, a, S)
+
+call init (N, a)
+call f4 (N, a, S)
+call check (N, a, S)
+
+call init (N, a)
+call f5 (N, a, S)
+call check (N, a, S)
+
+call init (N, a)
+call f6 (N, a, S)
+call check (N, a, S)
+
+call init (N, a)
+call f7 (N, a, S)
+call check (N, a, S)
+
+call init (N, a)
+call f8 (N, a, S)
+call check (N, a, S)
+
+call init (N, a)
+call f9 (N, a, S)
+call check (N, a, S)
+
+contains
+
+subroutine init (n, a)
+  implicit none
+  integer :: n
+  double precision :: a(n)
+  integer :: i
+  do i = 1, n
+    a(i) = i
+  end do
+end subroutine
+
+subroutine check (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(n)
+  double precision :: s
+  integer :: i
+  do i = 1, n
+    if (a(i) /= i * s) error stop
+  end do
+end subroutine
+
+! Check various combinations for enforcing correct ordering of 
+! construct matches.
+subroutine f1 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(n)
+  double precision :: s
+  integer :: i
+!$omp target teams
+!$omp parallel  
+!$omp metadirective &
+!$omp &  when (construct={target} &
+!$omp &	: do) &
+!$omp &  default (error at(execution) message("f1 match failed"))
+  do i = 1, n
+    a(i) = a(i) * s
+  end do
+!$omp end parallel  
+!$omp end target teams
+end subroutine
+
+subroutine f2 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(n)
+  double precision :: s
+  integer :: i
+!$omp target teams
+!$omp parallel
+!$omp metadirective &
+!$omp &  when (construct={teams, parallel} &
+!$omp &	: do) &
+!$omp &  default (error at(execution) message("f2 match failed"))
+  do i = 1, n
+    a(i) = a(i) * s
+  end do
+!$omp end parallel  
+!$omp end target teams
+end subroutine
+
+subroutine f3 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(n)
+  double precision :: s
+  integer :: i
+!$omp target teams
+!$omp parallel
+!$omp metadirective &
+!$omp &  when (construct={target, teams, parallel} &
+!$omp &	: do) &
+!$omp &  default (error at(execution) message("f3 match failed"))
+  do i = 1, n
+    a(i) = a(i) * s
+  end do
+!$omp end parallel  
+!$omp end target teams
+end subroutine
+
+subroutine f4 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(n)
+  double precision :: s
+  integer :: i
+!$omp target teams
+!$omp parallel
+!$omp metadirective &
+!$omp &  when (construct={target, parallel} &
+!$omp &	: do) &
+!$omp &  default (error at(execution) message("f4 match failed"))
+  do i = 1, n
+    a(i) = a(i) * s
+  end do
+!$omp end parallel  
+!$omp end target teams
+end subroutine
+
+subroutine f5 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(n)
+  double precision :: s
+  integer :: i
+!$omp target teams
+!$omp parallel
+!$omp metadirective &
+!$omp &  when (construct={target, teams} &
+!$omp &	: do) &
+!$omp &  default (error at(execution) message("f5 match failed"))
+  do i = 1, n
+    a(i) = a(i) * s
+  end do
+!$omp end parallel  
+!$omp end target teams
+end subroutine
+
+! Next batch is for things where the construct doesn't match the context.
+subroutine f6 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(n)
+  double precision :: s
+  integer :: i
+!$omp target
+!$omp teams
+!$omp metadirective &
+!$omp &  when (construct={parallel} &
+!$omp &	: error at(execution) message("f6 match failed")) &
+!$omp &  default (parallel do)
+  do i = 1, n
+    a(i) = a(i) * s
+  end do
+!$omp end teams
+!$omp end target
+end subroutine
+
+subroutine f7 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(n)
+  double precision :: s
+  integer :: i
+!$omp target
+!$omp teams
+!$omp metadirective &
+!$omp &  when (construct={target, parallel} &
+!$omp &	: error at(execution) message("f7 match failed")) &
+!$omp &  default (parallel do)
+  do i = 1, n
+    a(i) = a(i) * s
+  end do
+!$omp end teams
+!$omp end target
+end subroutine
+
+subroutine f8 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(n)
+  double precision :: s
+  integer :: i
+!$omp target
+!$omp teams
+!$omp metadirective &
+!$omp &  when (construct={parallel, target} &
+!$omp &	: error at(execution) message("f8 match failed")) &
+!$omp &  default (parallel do)
+  do i = 1, n
+    a(i) = a(i) * s
+  end do
+!$omp end teams
+!$omp end target
+end subroutine
+
+! Next test choosing the best alternative when there are multiple
+! matches.
+subroutine f9 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(n)
+  double precision :: s
+  integer :: i
+!$omp target teams
+!$omp parallel
+!$omp metadirective &
+!$omp &  when (construct={teams, parallel} &
+!$omp &	: error at(execution) message("f9 match incorrect 1")) &
+!$omp &  when (construct={target, teams, parallel} &
+!$omp &	: do) &
+!$omp &  when (construct={target, teams} &
+!$omp &	: error at(execution) message("f9 match incorrect 2")) &
+!$omp &  default (error at(execution) message("f9 match failed"))
+  do i = 1, n
+    a(i) = a(i) * s
+  end do
+!$omp end parallel  
+!$omp end target teams
+end subroutine
+
+end program
+
+! Note there are no tests for the matching the extended simd clause
+! syntax, which is only useful for "declare variant".
+
+
+! After parsing, there should be a runtime error call for each of the
+! failure cases, but they should all be optimized away during OMP 
+! lowering.
+! { dg-final { scan-tree-dump-times "__builtin_GOMP_error" 11 "original" } }
+! { dg-final { scan-tree-dump-not "__builtin_GOMP_error" "gimple" } }
diff --git a/gcc/testsuite/gfortran.dg/gomp/metadirective-no-score.f90 b/gcc/testsuite/gfortran.dg/gomp/metadirective-no-score.f90
new file mode 100644
index 0000000000000000000000000000000000000000..968ce609b10fa8ec428561db1edc4be37356ae83
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/metadirective-no-score.f90
@@ -0,0 +1,122 @@
+! { dg-do compile { target x86_64-*-* } }
+! { dg-additional-options "-foffload=disable" }
+
+! This test is expected to fail with compile-time errors:
+! "A trait-score cannot be specified in traits from the construct,
+!  device or target_device trait-selector-sets."
+
+
+subroutine f1 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(*)
+  double precision :: s
+  integer :: i
+!$omp metadirective &
+!$omp&  when (device={kind (score(5) : host)} &
+!$omp&	: parallel do)
+  ! { dg-error ".score. cannot be specified in traits in the .device. trait-selector-set" "" { target *-*-*} .-2 }
+  do i = 1, n
+    a(i) = a(i) * s;
+  end do
+end subroutine
+
+subroutine f2 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(*)
+  double precision :: s
+  integer :: i
+!$omp metadirective &
+!$omp&  when (device={kind (host), arch (score(6) : x86_64), isa (avx512f)} &
+!$omp&	: parallel do)
+  ! { dg-error ".score. cannot be specified in traits in the .device. trait-selector-set" "" { target *-*-*} .-2 }
+  do i = 1, n
+    a(i) = a(i) * s;
+  end do
+end subroutine
+
+subroutine f3 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(*)
+  double precision :: s
+  integer :: i
+!$omp metadirective &
+!$omp&  when (device={kind (host), arch (score(6) : x86_64), &
+!$omp&		  isa (score(7): avx512f)} &
+!$omp&	: parallel do)
+  ! { dg-error ".score. cannot be specified in traits in the .device. trait-selector-set" "" { target *-*-*} .-3 }
+  do i = 1, n
+    a(i) = a(i) * s;
+  end do
+end subroutine
+
+subroutine f4 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(*)
+  double precision :: s
+  integer :: i
+  integer, parameter :: omp_initial_device = -1
+!$omp metadirective &
+!$omp&  when (target_device={device_num (score(42) : omp_initial_device), &
+!$omp&			 kind (host)} &
+!$omp&	: parallel do)
+  ! { dg-error ".score. cannot be specified in traits in the .target_device. trait-selector-set" "" { target *-*-*} .-3 }
+  do i = 1, n
+    a(i) = a(i) * s;
+  end do
+end subroutine
+
+subroutine f5 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(*)
+  double precision :: s
+  integer :: i
+  integer, parameter :: omp_initial_device = -1
+!$omp metadirective &
+!$omp&  when (target_device={device_num(omp_initial_device), &
+!$omp&			 kind (score(5) : host)} &
+!$omp&	: parallel do)
+  ! { dg-error ".score. cannot be specified in traits in the .target_device. trait-selector-set" "" { target *-*-*} .-2 }
+  do i = 1, n
+    a(i) = a(i) * s;
+  end do
+end subroutine
+
+subroutine f6 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(*)
+  double precision :: s
+  integer :: i
+  integer, parameter :: omp_initial_device = -1
+!$omp metadirective &
+!$omp&  when (target_device={device_num(omp_initial_device), kind (host), &
+!$omp&			 arch (score(6) : x86_64), isa (avx512f)} &
+!$omp&	: parallel do)
+  ! { dg-error ".score. cannot be specified in traits in the .target_device. trait-selector-set" "" { target *-*-*} .-2 }
+  do i = 1, n
+    a(i) = a(i) * s;
+  end do
+end subroutine
+
+subroutine f7 (n, a, s)
+  implicit none
+  integer :: n
+  double precision :: a(*)
+  double precision :: s
+  integer :: i
+  integer, parameter :: omp_initial_device = -1
+!$omp metadirective &
+!$omp&  when (target_device={device_num(omp_initial_device), kind (host), &
+!$omp&			 arch (score(6) : x86_64), &
+!$omp&			 isa (score(7): avx512f)} &
+!$omp&	: parallel do)
+  ! { dg-error ".score. cannot be specified in traits in the .target_device. trait-selector-set" "" { target *-*-*} .-3 }
+  do i = 1, n
+    a(i) = a(i) * s;
+  end do
+end subroutine
diff --git a/gcc/testsuite/gfortran.dg/gomp/pure-1.f90 b/gcc/testsuite/gfortran.dg/gomp/pure-1.f90
index cdbebe215db7a94dfd0c677cb8515bd558996ed7..d7bc6cc6f6f7fc2cfee4d4eab83674ecddf01ab0 100644
--- a/gcc/testsuite/gfortran.dg/gomp/pure-1.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/pure-1.f90
@@ -110,3 +110,32 @@ pure integer function func_tile(n)
   end do
   func_tile = r
 end
+
+pure logical function func_metadirective()
+  implicit none
+  !$omp metadirective
+  func_metadirective = .false.
+end
+
+! not 'parallel' not pure -> invalid in 5.2; + in general invalid in 5.1
+pure logical function func_metadirective_2 ()
+  implicit none
+  integer :: i, n
+  n = 0
+  !$omp metadirective when (device={arch("nvptx")} : parallel do)     ! { dg-error "OpenMP directive at .1. is not pure and thus may not appear in a PURE procedure" }
+  do i = 1, 5
+    n = n + i
+  end do
+end
+
+! unroll is supposed to be pure, so this case is OK
+pure logical function func_metadirective_3()
+  implicit none
+  integer :: i, n
+
+  n = 0
+  !$omp metadirective when(device={arch("nvptx")} : unroll full)
+  do i = 1, 5
+    n = n + i
+  end do
+end
diff --git a/gcc/testsuite/gfortran.dg/gomp/pure-2.f90 b/gcc/testsuite/gfortran.dg/gomp/pure-2.f90
index 35503c6a284d18785fa449450dfee6bb61f4decc..f6022189a68c798edda61b2fde71d6bdbcebcd32 100644
--- a/gcc/testsuite/gfortran.dg/gomp/pure-2.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/pure-2.f90
@@ -26,14 +26,6 @@ logical function func_interchange(n)
   end do
 end
 
-
-!pure logical function func_metadirective()
-logical function func_metadirective()
-  implicit none
-  !$omp metadirective  ! { dg-error "Unclassifiable OpenMP directive" }
-  func_metadirective = .false.
-end
-
 !pure logical function func_reverse(n)
 logical function func_reverse(n)
   implicit none
diff --git a/gcc/testsuite/gfortran.dg/gomp/target-enter-exit-data.f90 b/gcc/testsuite/gfortran.dg/gomp/target-enter-exit-data.f90
index c14a11dacd9db98b88a4aadbf4a38b6e8b19b957..74eb894c04c6e562df3d062656dbf15717bb9967 100644
--- a/gcc/testsuite/gfortran.dg/gomp/target-enter-exit-data.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/target-enter-exit-data.f90
@@ -23,17 +23,17 @@ allocate (var%arr(1:100))
 
 
 !$omp target enter data map(to: var%arr)
-! { dg-final { scan-tree-dump-times {(?n)#pragma omp target enter data map\(to:\*\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[len: D\.[0-9]+ \* [0-9]+\]\[implicit\]\) map\(to:var\.arr \[pointer set, len: [0-9]+\]\) map\(attach_detach:\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[bias: 0\]\)$} 1 "original" } }
+! { dg-final { scan-tree-dump-times {(?n)#pragma omp target enter data map\(to:\*\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[len: D\.[0-9]+ \* [0-9]+\] \[runtime_implicit\]\) map\(to:var\.arr \[pointer set, len: [0-9]+\]\) map\(attach_detach:\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[bias: 0\]\)$} 1 "original" } }
 
 !$omp target exit data map(release: var%arr)
-! { dg-final { scan-tree-dump-times {(?n)#pragma omp target exit data map\(release:\*\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[len: D\.[0-9]+ \* [0-9]+\]\[implicit\]\) map\(release:var\.arr \[pointer set, len: [0-9]+\]\) map\(attach_detach:\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[bias: 0\]\)$} 1 "original" } }
+! { dg-final { scan-tree-dump-times {(?n)#pragma omp target exit data map\(release:\*\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[len: D\.[0-9]+ \* [0-9]+\] \[runtime_implicit\]\) map\(release:var\.arr \[pointer set, len: [0-9]+\]\) map\(attach_detach:\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[bias: 0\]\)$} 1 "original" } }
 
 
 !$omp target enter data map(alloc: var%arr)
-! { dg-final { scan-tree-dump-times {(?n)#pragma omp target enter data map\(alloc:\*\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[len: D\.[0-9]+ \* [0-9]+\]\[implicit\]\) map\(to:var\.arr \[pointer set, len: [0-9]+\]\) map\(attach_detach:\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[bias: 0\]\)$} 1 "original" } }
+! { dg-final { scan-tree-dump-times {(?n)#pragma omp target enter data map\(alloc:\*\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[len: D\.[0-9]+ \* [0-9]+\] \[runtime_implicit\]\) map\(to:var\.arr \[pointer set, len: [0-9]+\]\) map\(attach_detach:\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[bias: 0\]\)$} 1 "original" } }
 
 !$omp target exit data map(delete: var%arr)
-! { dg-final { scan-tree-dump-times {(?n)#pragma omp target exit data map\(delete:\*\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[len: D\.[0-9]+ \* [0-9]+\]\[implicit\]\) map\(delete:var\.arr \[pointer set, len: [0-9]+\]\) map\(attach_detach:\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[bias: 0\]\)$} 1 "original" } }
+! { dg-final { scan-tree-dump-times {(?n)#pragma omp target exit data map\(delete:\*\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[len: D\.[0-9]+ \* [0-9]+\] \[runtime_implicit\]\) map\(delete:var\.arr \[pointer set, len: [0-9]+\]\) map\(attach_detach:\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[bias: 0\]\)$} 1 "original" } }
 
 
 end
diff --git a/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90 b/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90
index 34b8aec462c68e0be331db365b5f4eed9e6627df..7b5ca645b62b18d1ecf93b4195242ef31da6a46a 100644
--- a/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90
+++ b/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90
@@ -1,4 +1,4 @@
-! { dg-do run { xfail powerpc*-apple-darwin* powerpc*-*-linux* } }
+! { dg-do run { xfail long_double_is_ibm128 } }
 ! Test XFAILed on these platforms because the system's printf() lacks
 ! proper support for denormalized long doubles. See PR24685
 ! { dg-require-effective-target fortran_large_real }
diff --git a/gcc/testsuite/gfortran.dg/pr118640.f90 b/gcc/testsuite/gfortran.dg/pr118640.f90
new file mode 100644
index 0000000000000000000000000000000000000000..8f74dbff06792195d784d82b1e7cdf5502df54fd
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr118640.f90
@@ -0,0 +1,38 @@
+! { dg-do compile }
+!
+! Check the fix for an ICE in gfc_conv_expr_present, which resulted from
+! the rhs temporary picking up the optional attribute from the lhs in a
+! defined assignment.
+!
+! Contributed by Jakub Jelenik  <jakub@gcc.gnu.org>
+!
+module foo
+  type t1
+  contains
+    procedure bar
+    generic :: assignment(=) => bar
+  end type
+  type t2
+    type(t1) m
+  end type
+contains
+  subroutine bar (x, y)
+    intent(in) y
+    class(t1), intent(out) :: x
+  end subroutine
+end module
+subroutine baz (x, y)
+  use foo
+  integer y
+  type(t2), pointer, optional :: x
+  interface
+    function qux (x)
+      use foo
+      integer x
+      type(t2) qux
+    end function
+  end interface
+  if (present (x)) then
+    x = qux (y)  ! ICE was here
+  end if
+end subroutine
diff --git a/gcc/testsuite/gfortran.dg/uncommon_block_data_2.f90 b/gcc/testsuite/gfortran.dg/uncommon_block_data_2.f90
new file mode 100644
index 0000000000000000000000000000000000000000..7b1a0b39a149b81d9126fa19be4fa97713bc6d97
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/uncommon_block_data_2.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! { dg-additional-options "-Wunused-variable" }
+!
+! PR fortran/58857
+
+BLOCK DATA valid
+  integer  :: i
+  integer  :: n  ! { dg-warning "not in a COMMON block" }
+  class(*) :: zz ! { dg-warning "not in a COMMON block" }
+  pointer  :: zz
+  common /com/ i, r
+END BLOCK DATA valid
diff --git a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_1.f03 b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_1.f03
index 8634031ad818449d4a72cb3f98e27a5e7aca8887..51483ed03325ea0c00b3feb4cfbd3a4867aa473e 100644
--- a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_1.f03
+++ b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_1.f03
@@ -155,7 +155,7 @@ END MODULE
   call foo([a(8),a(9)], res)
   if (trim (res) .ne. "type(a) array   8   9") STOP 1
 
-  call foo([sun, " & rain"], res)
+  call foo([sun, " & rain "], res)
   if (trim (res) .ne. "char( 8, 2)sunshine & rain") STOP 1
 
   call foo([sun//" never happens", " & rain always happens"], res)
diff --git a/gcc/testsuite/gfortran.dg/unsigned_15.f90 b/gcc/testsuite/gfortran.dg/unsigned_15.f90
index da4ccd2dc17a60724caaf24b23cbeb273542d825..80a7a54e3802d6bd6aa268da86e4b3b279bd0bd1 100644
--- a/gcc/testsuite/gfortran.dg/unsigned_15.f90
+++ b/gcc/testsuite/gfortran.dg/unsigned_15.f90
@@ -6,8 +6,8 @@ program main
   unsigned :: u
   print *,1 + 2u   ! { dg-error "Operands of binary numeric operator" }
   print *,2u + 1   ! { dg-error "Operands of binary numeric operator" }
-  print *,2u ** 1  ! { dg-error "Exponentiation not valid" }
-  print *,2u ** 1u ! { dg-error "Exponentiation not valid" }
+  print *,2u ** 1  ! { dg-error "Operands of binary numeric operator" }
+  print *,2u ** 1u
   print *,1u < 2   ! { dg-error "Inconsistent types" }
   print *,int(1u) < 2
 end program main
diff --git a/gcc/testsuite/gfortran.dg/unsigned_43.f90 b/gcc/testsuite/gfortran.dg/unsigned_43.f90
new file mode 100644
index 0000000000000000000000000000000000000000..fe1cd463f10822b5794a01c6b046a08d2590833f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/unsigned_43.f90
@@ -0,0 +1,11862 @@
+! { dg-do run }
+! { dg-options -funsigned }
+program memain
+  implicit none
+  call tst_1_1
+  call tst_1_2
+  call tst_1_4
+  call tst_1_8
+  call tst_2_1
+  call tst_2_2
+  call tst_2_4
+  call tst_2_8
+  call tst_4_1
+  call tst_4_2
+  call tst_4_4
+  call tst_4_8
+  call tst_8_1
+  call tst_8_2
+  call tst_8_4
+  call tst_8_8
+contains
+  subroutine tst_1_1
+    unsigned(kind=1) :: x, r1, r2, r3, r4
+    unsigned(kind=1) :: n
+    x = 0u_1
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_1_1
+  subroutine tst_1_2
+    unsigned(kind=1) :: x, r1, r2, r3, r4
+    unsigned(kind=2) :: n
+    x = 0u_1
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_1_2
+  subroutine tst_1_4
+    unsigned(kind=1) :: x, r1, r2, r3, r4
+    unsigned(kind=4) :: n
+    x = 0u_1
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_1_4
+  subroutine tst_1_8
+    unsigned(kind=1) :: x, r1, r2, r3, r4
+    unsigned(kind=8) :: n
+    x = 0u_1
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_1_8
+  subroutine tst_2_1
+    unsigned(kind=2) :: x, r1, r2, r3, r4
+    unsigned(kind=1) :: n
+    x = 0u_2
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_2_1
+  subroutine tst_2_2
+    unsigned(kind=2) :: x, r1, r2, r3, r4
+    unsigned(kind=2) :: n
+    x = 0u_2
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_2_2
+  subroutine tst_2_4
+    unsigned(kind=2) :: x, r1, r2, r3, r4
+    unsigned(kind=4) :: n
+    x = 0u_2
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_2_4
+  subroutine tst_2_8
+    unsigned(kind=2) :: x, r1, r2, r3, r4
+    unsigned(kind=8) :: n
+    x = 0u_2
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_2_8
+  subroutine tst_4_1
+    unsigned(kind=4) :: x, r1, r2, r3, r4
+    unsigned(kind=1) :: n
+    x = 0u_4
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_4_1
+  subroutine tst_4_2
+    unsigned(kind=4) :: x, r1, r2, r3, r4
+    unsigned(kind=2) :: n
+    x = 0u_4
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_4_2
+  subroutine tst_4_4
+    unsigned(kind=4) :: x, r1, r2, r3, r4
+    unsigned(kind=4) :: n
+    x = 0u_4
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_4_4
+  subroutine tst_4_8
+    unsigned(kind=4) :: x, r1, r2, r3, r4
+    unsigned(kind=8) :: n
+    x = 0u_4
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_4_8
+  subroutine tst_8_1
+    unsigned(kind=8) :: x, r1, r2, r3, r4
+    unsigned(kind=1) :: n
+    x = 0u_8
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_8_1
+  subroutine tst_8_2
+    unsigned(kind=8) :: x, r1, r2, r3, r4
+    unsigned(kind=2) :: n
+    x = 0u_8
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_8_2
+  subroutine tst_8_4
+    unsigned(kind=8) :: x, r1, r2, r3, r4
+    unsigned(kind=4) :: n
+    x = 0u_8
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_8_4
+  subroutine tst_8_8
+    unsigned(kind=8) :: x, r1, r2, r3, r4
+    unsigned(kind=8) :: n
+    x = 0u_8
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_8_8
+end program memain
diff --git a/gcc/testsuite/gfortran.dg/unsigned_44.f90 b/gcc/testsuite/gfortran.dg/unsigned_44.f90
new file mode 100644
index 0000000000000000000000000000000000000000..b25cbeb5512ee95088f1dd53bce460a072f46d9e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/unsigned_44.f90
@@ -0,0 +1,8436 @@
+! { dg-do run }
+! { dg-options -funsigned }
+! { dg-require-effective-target fortran_integer_16 }
+program memain
+  implicit none
+  call tst_1_16
+  call tst_2_16
+  call tst_4_16
+  call tst_8_16
+  call tst_16_1
+  call tst_16_2
+  call tst_16_4
+  call tst_16_8
+  call tst_16_16
+contains
+  subroutine tst_1_16
+    unsigned(kind=1) :: x, r1, r2, r3, r4
+    unsigned(kind=16) :: n
+    x = 0u_1
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_1
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 0u_1 ** n
+    r4 = 0u_1 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_1
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 1u_1 ** n
+    r4 = 1u_1 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_1
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 2u_1 ** n
+    r4 = 2u_1 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_1
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 3u_1 ** n
+    r4 = 3u_1 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_1
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 7u_1 ** n
+    r4 = 7u_1 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_1
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 8u_1 ** n
+    r4 = 8u_1 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_1
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 9u_1 ** n
+    r4 = 9u_1 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_1
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 14u_1 ** n
+    r4 = 14u_1 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_1
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 17u_1 ** n
+    r4 = 17u_1 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_1
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 254u_1 ** n
+    r4 = 254u_1 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_1_16
+  subroutine tst_2_16
+    unsigned(kind=2) :: x, r1, r2, r3, r4
+    unsigned(kind=16) :: n
+    x = 0u_2
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_2
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 0u_2 ** n
+    r4 = 0u_2 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_2
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 1u_2 ** n
+    r4 = 1u_2 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_2
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 2u_2 ** n
+    r4 = 2u_2 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_2
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 3u_2 ** n
+    r4 = 3u_2 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_2
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 7u_2 ** n
+    r4 = 7u_2 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_2
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 8u_2 ** n
+    r4 = 8u_2 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_2
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 9u_2 ** n
+    r4 = 9u_2 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_2
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 14u_2 ** n
+    r4 = 14u_2 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_2
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 17u_2 ** n
+    r4 = 17u_2 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_2
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 254u_2 ** n
+    r4 = 254u_2 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_2
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 65535u_2 ** n
+    r4 = 65535u_2 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_2_16
+  subroutine tst_4_16
+    unsigned(kind=4) :: x, r1, r2, r3, r4
+    unsigned(kind=16) :: n
+    x = 0u_4
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_4
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 0u_4 ** n
+    r4 = 0u_4 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_4
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 1u_4 ** n
+    r4 = 1u_4 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_4
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 2u_4 ** n
+    r4 = 2u_4 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_4
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 3u_4 ** n
+    r4 = 3u_4 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_4
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 7u_4 ** n
+    r4 = 7u_4 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_4
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 8u_4 ** n
+    r4 = 8u_4 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_4
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 9u_4 ** n
+    r4 = 9u_4 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_4
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 14u_4 ** n
+    r4 = 14u_4 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_4
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 17u_4 ** n
+    r4 = 17u_4 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_4
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 254u_4 ** n
+    r4 = 254u_4 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_4
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 65535u_4 ** n
+    r4 = 65535u_4 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_4
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 4294967295u_4 ** n
+    r4 = 4294967295u_4 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_4_16
+  subroutine tst_8_16
+    unsigned(kind=8) :: x, r1, r2, r3, r4
+    unsigned(kind=16) :: n
+    x = 0u_8
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_8
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 0u_8 ** n
+    r4 = 0u_8 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_8
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 1u_8 ** n
+    r4 = 1u_8 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_8
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 2u_8 ** n
+    r4 = 2u_8 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_8
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 3u_8 ** n
+    r4 = 3u_8 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_8
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 7u_8 ** n
+    r4 = 7u_8 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_8
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 8u_8 ** n
+    r4 = 8u_8 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_8
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 9u_8 ** n
+    r4 = 9u_8 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_8
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 14u_8 ** n
+    r4 = 14u_8 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_8
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 17u_8 ** n
+    r4 = 17u_8 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_8
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 254u_8 ** n
+    r4 = 254u_8 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_8
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 65535u_8 ** n
+    r4 = 65535u_8 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_8
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 4294967295u_8 ** n
+    r4 = 4294967295u_8 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_8
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 18446744073709551615u_8 ** n
+    r4 = 18446744073709551615u_8 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_8_16
+  subroutine tst_16_1
+    unsigned(kind=16) :: x, r1, r2, r3, r4
+    unsigned(kind=1) :: n
+    x = 0u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 0u_1
+    r1 = x ** n
+    r2 = x ** 0u_1
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 0u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 1u_1
+    r1 = x ** n
+    r2 = x ** 1u_1
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 1u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 2u_1
+    r1 = x ** n
+    r2 = x ** 2u_1
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 2u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 7u_1
+    r1 = x ** n
+    r2 = x ** 7u_1
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 7u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 8u_1
+    r1 = x ** n
+    r2 = x ** 8u_1
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 8u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 16u_1
+    r1 = x ** n
+    r2 = x ** 16u_1
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 16u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 135u_1
+    r1 = x ** n
+    r2 = x ** 135u_1
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 135u_1
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_16_1
+  subroutine tst_16_2
+    unsigned(kind=16) :: x, r1, r2, r3, r4
+    unsigned(kind=2) :: n
+    x = 0u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 0u_2
+    r1 = x ** n
+    r2 = x ** 0u_2
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 0u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 1u_2
+    r1 = x ** n
+    r2 = x ** 1u_2
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 1u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 2u_2
+    r1 = x ** n
+    r2 = x ** 2u_2
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 2u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 7u_2
+    r1 = x ** n
+    r2 = x ** 7u_2
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 7u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 8u_2
+    r1 = x ** n
+    r2 = x ** 8u_2
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 8u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 16u_2
+    r1 = x ** n
+    r2 = x ** 16u_2
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 16u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 135u_2
+    r1 = x ** n
+    r2 = x ** 135u_2
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 135u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 32779u_2
+    r1 = x ** n
+    r2 = x ** 32779u_2
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 32779u_2
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_16_2
+  subroutine tst_16_4
+    unsigned(kind=16) :: x, r1, r2, r3, r4
+    unsigned(kind=4) :: n
+    x = 0u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 0u_4
+    r1 = x ** n
+    r2 = x ** 0u_4
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 0u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 1u_4
+    r1 = x ** n
+    r2 = x ** 1u_4
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 1u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 2u_4
+    r1 = x ** n
+    r2 = x ** 2u_4
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 2u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 7u_4
+    r1 = x ** n
+    r2 = x ** 7u_4
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 7u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 8u_4
+    r1 = x ** n
+    r2 = x ** 8u_4
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 8u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 16u_4
+    r1 = x ** n
+    r2 = x ** 16u_4
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 16u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 135u_4
+    r1 = x ** n
+    r2 = x ** 135u_4
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 135u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 32779u_4
+    r1 = x ** n
+    r2 = x ** 32779u_4
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 32779u_4
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_16_4
+  subroutine tst_16_8
+    unsigned(kind=16) :: x, r1, r2, r3, r4
+    unsigned(kind=8) :: n
+    x = 0u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 0u_8
+    r1 = x ** n
+    r2 = x ** 0u_8
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 0u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 1u_8
+    r1 = x ** n
+    r2 = x ** 1u_8
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 1u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 2u_8
+    r1 = x ** n
+    r2 = x ** 2u_8
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 2u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 7u_8
+    r1 = x ** n
+    r2 = x ** 7u_8
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 7u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 8u_8
+    r1 = x ** n
+    r2 = x ** 8u_8
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 8u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 16u_8
+    r1 = x ** n
+    r2 = x ** 16u_8
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 16u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 135u_8
+    r1 = x ** n
+    r2 = x ** 135u_8
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 135u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 32779u_8
+    r1 = x ** n
+    r2 = x ** 32779u_8
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 32779u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 18446744073709551615u_8
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_8
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 18446744073709551615u_8
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_16_8
+  subroutine tst_16_16
+    unsigned(kind=16) :: x, r1, r2, r3, r4
+    unsigned(kind=16) :: n
+    x = 0u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 0u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 0u_16 ** n
+    r4 = 0u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 1u_16 ** n
+    r4 = 1u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 2u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 2u_16 ** n
+    r4 = 2u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 3u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 3u_16 ** n
+    r4 = 3u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 7u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 7u_16 ** n
+    r4 = 7u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 8u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 8u_16 ** n
+    r4 = 8u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 9u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 9u_16 ** n
+    r4 = 9u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 14u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 14u_16 ** n
+    r4 = 14u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 17u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 17u_16 ** n
+    r4 = 17u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 254u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 254u_16 ** n
+    r4 = 254u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 65535u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 65535u_16 ** n
+    r4 = 65535u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 4294967295u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 4294967295u_16 ** n
+    r4 = 4294967295u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 18446744073709551615u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 18446744073709551615u_16 ** n
+    r4 = 18446744073709551615u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 0u_16
+    r1 = x ** n
+    r2 = x ** 0u_16
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 0u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 1u_16
+    r1 = x ** n
+    r2 = x ** 1u_16
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 1u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 2u_16
+    r1 = x ** n
+    r2 = x ** 2u_16
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 2u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 7u_16
+    r1 = x ** n
+    r2 = x ** 7u_16
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 7u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 8u_16
+    r1 = x ** n
+    r2 = x ** 8u_16
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 8u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 16u_16
+    r1 = x ** n
+    r2 = x ** 16u_16
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 16u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 135u_16
+    r1 = x ** n
+    r2 = x ** 135u_16
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 135u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 32779u_16
+    r1 = x ** n
+    r2 = x ** 32779u_16
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 32779u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 18446744073709551615u_16
+    r1 = x ** n
+    r2 = x ** 18446744073709551615u_16
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 18446744073709551615u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+    x = 1267650600228229401496703205375u_16
+    n = 1267650600228229401496703205375u_16
+    r1 = x ** n
+    r2 = x ** 1267650600228229401496703205375u_16
+    r3 = 1267650600228229401496703205375u_16 ** n
+    r4 = 1267650600228229401496703205375u_16 ** 1267650600228229401496703205375u_16
+    if (r1 /= r2 .or. r3 /= r4 .or. r1 /= r3) error stop
+
+  end subroutine tst_16_16
+end program memain
diff --git a/gcc/testsuite/gfortran.dg/use_rename_14.f90 b/gcc/testsuite/gfortran.dg/use_rename_14.f90
new file mode 100644
index 0000000000000000000000000000000000000000..03815a5f229e15480b7865632ce058e1b526d8b4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/use_rename_14.f90
@@ -0,0 +1,46 @@
+! { dg-do compile }
+!
+! PR fortran/110993 - bogus diagnostics on renamed interface import
+!
+! Contributed by Rimvydas Jasinskas <rimvydas.jas at gmail.com>
+
+module m
+  interface
+    subroutine bar(x)
+      use iso_c_binding, only : c_float
+      implicit none
+      real(c_float) :: x(45)
+    end subroutine
+  end interface
+end
+
+module m1
+  interface
+    subroutine bar1(x) bind(c)
+      use iso_c_binding, only : c_float
+      implicit none
+      real(c_float) :: x(45)
+    end subroutine
+  end interface
+end
+
+module m2
+  interface
+    subroutine bar2(x) bind(c, name="bar2_")
+      use iso_c_binding, only : c_float
+      implicit none
+      real(c_float) :: x(45)
+    end subroutine
+  end interface
+end
+
+subroutine foo(y)
+  use m,  notthisone => bar
+  use m1, northisone => bar1
+  use m2,  orthisone => bar2
+  implicit none
+  real :: y(3)
+  call bar (y)
+  call bar1(y)
+  call bar2(y)
+end subroutine
diff --git a/gcc/testsuite/gfortran.dg/utf8_3.f03 b/gcc/testsuite/gfortran.dg/utf8_3.f03
new file mode 100644
index 0000000000000000000000000000000000000000..e1688149e5dcd20dd35a03e8ca20d19184edcd3c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/utf8_3.f03
@@ -0,0 +1,57 @@
+! { dg-do run }
+! PR118571 UTF-8 output and the A edit descriptor.
+
+program test
+
+  use iso_fortran_env
+  
+  implicit none
+  
+  integer, parameter :: ucs4 = selected_char_kind('ISO_10646')
+  
+  character(kind=ucs4, len=1), parameter :: alpha = char(int(z'03B1'), ucs4)
+  character(kind=ucs4, len=1), parameter :: beta  = char(int(z'03B2'), ucs4)
+  character(kind=ucs4, len=1), parameter :: space = ucs4_' '
+  
+  integer fd
+  character(kind=ucs4,len=:), allocatable :: str
+  character(kind=ucs4,len=25) :: instr, correct
+  
+  fd = 42
+  
+  open (fd, encoding='UTF-8', status="scratch")
+  open (output_unit, encoding='UTF-8')
+  str = repeat(space,6)//alpha//beta//alpha//beta
+
+  write(fd,'(I4,1X,A)') len_trim(str), str
+  rewind(fd)
+  read(fd,'(a)') instr
+  if (trim(instr) /= ucs4_'  10 '//trim(str)) stop 1
+  
+  str = alpha // beta // alpha // beta
+  rewind(fd) 
+  write(fd,'(I4,1X,">",A,"<")')  len_trim(str(1:1)), str(1:1)
+  rewind(fd)
+  read(fd,'(a)') instr
+  if (trim(instr) /= ucs4_'   1 >'//alpha//ucs4_'<') stop 2
+
+  rewind(fd)
+  write(fd,*) len_trim(str(1:1)), str(1:1)
+  rewind(fd)
+  read(fd,'(a)') instr
+  if (trim(instr) /= ucs4_'           1 '//alpha) stop 3
+
+  rewind(fd)  
+  write(fd,'(I4,1X,">",A1,"<")')  len_trim(str(1:1)), str(1:1)
+  rewind(fd)
+  read(fd, '(a)') instr
+  if (trim(instr) /= ucs4_'   1 >'//alpha//ucs4_'<') stop 4
+
+  rewind(fd)  
+  write(fd,'(I4,1X,">",A1,"<")')  len_trim(str), str
+  rewind(fd)
+  read(fd, '(a)') instr
+  if (trim(instr) /= ucs4_'   4 >'//alpha//ucs4_'<') stop 5
+  close(fd)
+end program
+
diff --git a/gcc/testsuite/gfortran.target/aarch64/aarch64.exp b/gcc/testsuite/gfortran.target/aarch64/aarch64.exp
new file mode 100644
index 0000000000000000000000000000000000000000..79afc6993187bc6e509dd3bc1cad37dd97f68648
--- /dev/null
+++ b/gcc/testsuite/gfortran.target/aarch64/aarch64.exp
@@ -0,0 +1,45 @@
+#   Copyright (C) 2025 Free Software Foundation, Inc.
+
+# This program 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 of the License, or
+# (at your option) any later version.
+# 
+# This program 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
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Exit immediately if this isn't a aarch64 target.
+if { ![istarget aarch64*-*-*] } then {
+  return
+}
+
+# Make sure there is a fortran compiler to test.
+if { ![check_no_compiler_messages fortran_available assembly {
+! Fortran
+program P
+  stop
+end program P
+} ""] } {
+    return
+}
+
+# Load support procs.
+load_lib gfortran-dg.exp
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+gfortran-dg-runtest [lsort \
+   [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" ""
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gfortran.target/aarch64/pr116234.f b/gcc/testsuite/gfortran.target/aarch64/pr116234.f
new file mode 100644
index 0000000000000000000000000000000000000000..78b49bc86f1089dbbc5b7ef4d5f48da383b179c4
--- /dev/null
+++ b/gcc/testsuite/gfortran.target/aarch64/pr116234.f
@@ -0,0 +1,80 @@
+! { dg-do compile }
+! { dg-options "-fcompare-debug -mcpu=phecda -O2 -funroll-all-loops -c -fno-rename-registers -fno-ivopts" }
+
+      SUBROUTINE FOO(UPLO, N, A, IA, JA, DESCA, SR, SC, SCOND, AMAX,
+     $     EQUED)
+
+      CHARACTER          EQUED, UPLO
+      INTEGER            IA, JA
+      DOUBLE PRECISION   AMAX, SCOND
+
+      INTEGER            DESCA(*)
+      DOUBLE PRECISION   A(*), SR(*)
+
+      INTEGER            IACOL, IAROW, IC, IIA, IOFFA, J, JB, JJ, KK,
+     $     LL, MYCOL, MYROW
+      DOUBLE PRECISION   CJ, SMALL
+      DOUBLE PRECISION   SC(*)
+
+      EXTERNAL           INFOG2L
+
+      LOGICAL            BAR
+      DOUBLE PRECISION   PDLAMCH
+      EXTERNAL           BAR, PDLAMCH
+
+      INTRINSIC          MOD
+
+      CALL INFOG2L(IA, JA, DESCA, MYROW, MYCOL, IIA, IAROW, IACOL)
+
+      CJ = 1
+      SMALL = PDLAMCH(IC, 'Safe minimum') / PDLAMCH(IC, 'Precision')
+
+      IF (SCOND .LT. 0.1D+0 .OR. AMAX .LT. SMALL) THEN
+         JJ = LL
+         JB = LL + 1
+
+         IF (BAR(UPLO, '0')) THEN
+            IF (MYCOL .EQ. IACOL) THEN
+               DO 10 LL = 1, JB
+                  IOFFA = IOFFA + LL
+ 10            CONTINUE
+            END IF
+
+            DO 60 J = 1, JA + 1
+               IF (MYCOL .EQ. IACOL) THEN
+                  IF (MYROW .EQ. IAROW) THEN
+                     DO 30 LL = JJ, JJ + JB - 1
+                        CJ = SC(LL)
+                        DO 20 KK = IIA, MYROW + LL - JJ + 1
+                           A(IOFFA + KK) = A(IOFFA + KK) * CJ * SR(KK)
+ 20                     CONTINUE
+ 30                  CONTINUE
+                  ELSE
+                     DO 50 LL = JJ, JJ + JB
+                        DO 40 KK = IIA, J
+                           A(IOFFA + KK) = A(IOFFA + KK) * CJ * SR(KK)
+ 40                     CONTINUE
+                        IOFFA = IOFFA + KK
+ 50                  CONTINUE
+                  END IF
+               END IF
+
+               IACOL = MOD(IACOL + 1, JA)
+ 60         CONTINUE
+         ELSE
+            IF (MYROW .NE. IAROW) THEN
+               DO 70 LL = 1, JB
+                  A(IOFFA + KK) = A(IOFFA + KK) * CJ
+ 70            CONTINUE
+            END IF
+
+            DO 90 J = 1, JA
+               DO 80 LL = 1, JJ
+                  A(IOFFA + KK) = A(IOFFA + KK) * CJ
+ 80            CONTINUE
+ 90         CONTINUE
+         END IF
+      END IF
+
+      RETURN
+      END
diff --git a/gcc/testsuite/gfortran.target/riscv/rvv/pr118646.f90 b/gcc/testsuite/gfortran.target/riscv/rvv/pr118646.f90
new file mode 100644
index 0000000000000000000000000000000000000000..e2a0343161237c68801c26fe006d38d2fc73ebce
--- /dev/null
+++ b/gcc/testsuite/gfortran.target/riscv/rvv/pr118646.f90
@@ -0,0 +1,48 @@
+! Reduced from SPEC2017 527.cam4 zm_conv.F90
+
+! { dg-do compile }
+! { dg-options "-Ofast -std=legacy -march=rv64gcv_zvl256b_zba_zbb_zbs_zicond -ftree-vectorize -mabi=lp64d" }
+
+module a
+  contains
+subroutine b(f)
+
+   real d(4)
+   integer e(4)
+   integer f(4)
+   real hmax(4)
+   real g(4)
+
+   integer h(4)
+   integer l(4,5)
+   do i = 1,c
+      h(i) = 0
+   end do
+   do k = j  ,1
+      do i = 1,c
+         q = g(i) + hmax(i)
+         if (k >= nint(d(i)) .and. k <= e(i) .and. q > 1.e4) then
+            f(i) = k
+         end if
+      if (k < o ) then
+            if (buoy<= 0.) then
+               l(i,h) = k
+            end if
+         end if
+      end do
+   end do
+   do n = 1,5
+      do k = 1,m
+         do i = 1,c
+            if (k > l(i,n)) then
+               p = r()
+            end if
+         end do
+      end do
+   end do
+end
+end
+
+! { dg-final { scan-assembler-times {frrm\s+[axs][0-9]+} 1 } }
+! { dg-final { scan-assembler-times {fsrmi\s+[01234]} 1 } }
+! { dg-final { scan-assembler-times {fsrm\s+[axs][0-9]+} 1 } }
diff --git a/gcc/testsuite/gm2.dg/pim/fail/badopaque.mod b/gcc/testsuite/gm2.dg/pim/fail/badopaque.mod
new file mode 100644
index 0000000000000000000000000000000000000000..1d67bf9e68177e689e8ea669931bbdb45042b636
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/pim/fail/badopaque.mod
@@ -0,0 +1,15 @@
+
+(* { dg-do compile } *)
+(* { dg-options "-g" } *)
+
+MODULE badopaque ;  
+
+FROM opaquedefs IMPORT OpaqueA ;
+
+VAR
+   a: OpaqueA ;
+   c: CARDINAL ;
+BEGIN
+   c := 123 ;
+   a^ := c     (* { dg-error "with an opaque type" }  *)
+END badopaque.
diff --git a/gcc/testsuite/gm2.dg/pim/fail/badopaque2.mod b/gcc/testsuite/gm2.dg/pim/fail/badopaque2.mod
new file mode 100644
index 0000000000000000000000000000000000000000..80f9324d2404da3fe5a1991610567188985ff28d
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/pim/fail/badopaque2.mod
@@ -0,0 +1,17 @@
+
+(* { dg-do compile } *)
+(* { dg-options "-g" } *)
+
+MODULE badopaque2 ;  
+
+FROM opaquedefs IMPORT OpaqueB ;
+
+VAR
+   b: OpaqueB ;
+   c: CARDINAL ;
+BEGIN
+   c := 123 ;
+   b^.width := c  (* { dg-bogus "unnamed" } *)
+   (* { dg-error "cannot be dereferenced" "b^.width" { target *-*-* } 14 } *)   
+   (* { dg-error "has no field" "no field" { target *-*-* } 14 } *)   
+END badopaque2.
diff --git a/gcc/testsuite/gm2.dg/pim/fail/dg-pim-fail.exp b/gcc/testsuite/gm2.dg/pim/fail/dg-pim-fail.exp
new file mode 100644
index 0000000000000000000000000000000000000000..09ea4f7551029c8f4e610babe477be720f89b1bc
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/pim/fail/dg-pim-fail.exp
@@ -0,0 +1,34 @@
+# Copyright (C) 2025 Free Software Foundation, Inc.
+
+# This program 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 of the License, or
+# (at your option) any later version.
+# 
+# This program 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
+# <http://www.gnu.org/licenses/>.
+
+# Compile tests, no torture testing.
+#
+# These tests raise errors in the front end; torture testing doesn't apply.
+
+# Load support procs.
+load_lib gm2-dg.exp
+
+gm2_init_pim4 $srcdir/$subdir
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] "" ""
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gm2.dg/pim/fail/opaquedefs.def b/gcc/testsuite/gm2.dg/pim/fail/opaquedefs.def
new file mode 100644
index 0000000000000000000000000000000000000000..3432a655be33bba230895bcb98ec9f9e7aeb2efe
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/pim/fail/opaquedefs.def
@@ -0,0 +1,7 @@
+DEFINITION MODULE opaquedefs ;  
+
+TYPE
+   OpaqueA ;
+   OpaqueB ;   
+
+END opaquedefs.
diff --git a/gcc/testsuite/gm2.dg/pim/fail/opaquedefs.mod b/gcc/testsuite/gm2.dg/pim/fail/opaquedefs.mod
new file mode 100644
index 0000000000000000000000000000000000000000..7c253292a2d22c2780e75cff2efea4e48cb90704
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/pim/fail/opaquedefs.mod
@@ -0,0 +1,13 @@
+(* { dg-do compile } *)
+(* { dg-options "-g -c" } *)
+
+IMPLEMENTATION MODULE opaquedefs ;
+
+TYPE
+   OpaqueA = POINTER TO CARDINAL ;
+   OpaqueB = POINTER TO RECORD
+                           width : CARDINAL ;
+                           height: CARDINAL ;
+                        END ;
+
+END opaquedefs.
diff --git a/gcc/testsuite/gm2/builtins/run/pass/testbitfns.mod b/gcc/testsuite/gm2/builtins/run/pass/testbitfns.mod
new file mode 100644
index 0000000000000000000000000000000000000000..16c6cb9a1e825d6bc6bc4bdf64dbc320cec6b265
--- /dev/null
+++ b/gcc/testsuite/gm2/builtins/run/pass/testbitfns.mod
@@ -0,0 +1,90 @@
+MODULE testbitfns ;  
+
+FROM libc IMPORT printf, exit ;
+FROM Builtins IMPORT clz, clzll, ctz, ctzll ;
+
+
+(*
+   Assert - 
+*)
+
+PROCEDURE Assert (name: ARRAY OF CHAR;
+                  input, left, right: INTEGER; line: CARDINAL) ;
+BEGIN
+   IF left = right
+   THEN
+      printf ("pass: %s (%d) = %d\n", name, input, left)
+   ELSE
+      printf ("fail: %s (%d) # %d (should be %d)\n", name, input, left, right) ;
+      exitcode := 1
+   END
+END Assert ;
+
+
+(*
+   runtests - 
+*)
+
+PROCEDURE runtests ;
+VAR
+   c     : CARDINAL ;
+   l     : LONGCARD ;
+   result: INTEGER ;
+BEGIN
+   c := 16 ;
+   result := ctz (c) ;
+   Assert ("ctz", c, result, 4, __LINE__) ;
+   c := 4 ;
+   result := ctz (c) ;   
+   Assert ("ctz", c, result, 2, __LINE__) ;   
+   c := 14 ;
+   result := ctz (c) ;   
+   Assert ("ctz", c, result, 1, __LINE__) ; 
+   l := 16 ;
+   result := ctzll (l) ;   
+   Assert ("ctzll", l, result, 4, __LINE__) ;
+   l := 4 ;
+   result := ctzll (l) ;   
+   Assert ("ctzll", l, result, 2, __LINE__) ;   
+   l := 14 ;
+   result := ctzll (l) ;   
+   Assert ("ctzll", l, result, 1, __LINE__) ;
+
+   IF SIZE (c) = 4
+   THEN
+      c := 16 ;
+      result := clz (c) ;
+      Assert ("clz", c, result, 27, __LINE__) ;
+      c := 4 ;
+      result := clz (c) ;   
+      Assert ("clz", c, result, 29, __LINE__) ;   
+      c := 14 ;
+      result := clz (c) ;   
+      Assert ("clz", c, result, 28, __LINE__) ;
+      IF SIZE (l) = 8
+      THEN
+         l := 16 ;
+         result := clzll (l) ;   
+         Assert ("clzll", l, result, 59, __LINE__) ;
+         l := 4 ;
+         result := clzll (l) ;   
+         Assert ("clzll", l, result, 61, __LINE__) ;   
+         l := 14 ;
+         result := clzll (l) ;   
+         Assert ("ctzll", l, result, 60, __LINE__)
+      END
+   END
+END runtests ;
+
+
+VAR
+   exitcode: INTEGER ;
+BEGIN
+   exitcode := 0 ;
+   runtests ;
+   IF exitcode = 0
+   THEN
+      printf ("all tests pass!\n")
+   END ;
+   exit (exitcode)
+END testbitfns.
diff --git a/gcc/testsuite/gm2/iso/run/pass/except9.mod b/gcc/testsuite/gm2/iso/run/pass/except9.mod
new file mode 100644
index 0000000000000000000000000000000000000000..e5f9482b511ff39431564aa8793c7ba1e571d83c
--- /dev/null
+++ b/gcc/testsuite/gm2/iso/run/pass/except9.mod
@@ -0,0 +1,78 @@
+(* Copyright (C) 2025 Free Software Foundation, Inc. *)
+(* This file is part of GNU Modula-2.
+
+GNU Modula-2 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 2, or (at your option) any later
+version.
+
+GNU Modula-2 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 gm2; see the file COPYING.  If not, write to the Free Software
+Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
+
+MODULE except9 ;
+
+FROM libc IMPORT printf ;
+FROM Storage IMPORT ALLOCATE, DEALLOCATE ;
+FROM SYSTEM IMPORT ADR, WORD ;
+
+
+PROCEDURE fly (debug: BOOLEAN) ;
+BEGIN
+   printf("fly main body\n") ;
+   IF 4 DIV ip^ = 4
+   THEN
+      printf("yes it worked\n")
+   ELSE
+      printf("no it failed\n")
+   END
+END fly ;
+
+(*
+ *   a GNU M2 version of the Modula-2 example given in the ISO standard.
+ *   This is a hand translation of the equivalent except.c file in this
+ *   directory which is written to prove that the underlying runtime system
+ *   will work with the GCC exception handling trees.
+ *)
+
+PROCEDURE tryFlying (debug: BOOLEAN) ;
+BEGIN
+   printf("tryFlying main body\n");  
+   fly (debug) ;
+EXCEPT
+   printf("inside tryFlying exception routine\n") ;
+   IF (ip#NIL) AND (ip^=0)
+   THEN
+      ip^ := 1 ;
+      RETRY
+   END
+END tryFlying ;
+
+
+PROCEDURE keepFlying (debug: BOOLEAN) ;
+BEGIN
+   printf("keepFlying main body\n") ;
+   tryFlying (debug) ;
+EXCEPT
+   printf("inside keepFlying exception routine\n") ;
+   IF ip=NIL
+   THEN
+      NEW(ip) ;
+      ip^ := 0 ;
+      RETRY
+   END
+END keepFlying ;
+
+
+VAR
+   ip: POINTER TO INTEGER ;
+BEGIN
+   ip := NIL ;
+   keepFlying (FALSE) ;
+   printf("all done\n")
+END except9.
diff --git a/gcc/testsuite/gm2/iso/run/pass/lazyunique.mod b/gcc/testsuite/gm2/iso/run/pass/lazyunique.mod
new file mode 100644
index 0000000000000000000000000000000000000000..5e4a310b0627d7fcb726228acf4eb6d3adda8cab
--- /dev/null
+++ b/gcc/testsuite/gm2/iso/run/pass/lazyunique.mod
@@ -0,0 +1,87 @@
+MODULE lazyunique ;  (*!m2iso+gm2*)
+
+FROM Storage IMPORT ALLOCATE ;
+FROM libc IMPORT printf, exit ;
+
+TYPE
+   List = POINTER TO RECORD
+                        next : List ;
+                        value: INTEGER ;
+                     END ;
+
+   Array = ARRAY [0..3] OF INTEGER ;
+
+CONST
+   Unsorted = Array {0, 2, 1, 1} ;
+
+VAR
+   head: List ;
+
+
+PROCEDURE Display ;
+VAR
+   p: List ;
+BEGIN
+   p := head^.next ;
+   printf ("\nunique data\n");
+   printf ("===========\n");   
+   WHILE p # NIL DO
+      printf ("%d\n", p^.value);
+      p := p^.next
+   END
+END Display ;
+
+
+PROCEDURE Add (VAR p: List; val: INTEGER) ;
+BEGIN
+   NEW (p) ;
+   WITH p^ DO
+      value := val ;
+      next := NIL
+   END
+END Add ;
+
+
+PROCEDURE Unique (val: INTEGER) ;
+VAR
+   p: List ;
+BEGIN
+   printf ("new value %d\n", val);
+   p := head ;
+   (* The following line may cause an exception accessing next or value.  *)
+   WHILE p^.next^.value # val DO
+      p := p^.next
+   END
+EXCEPT
+   (* Now fixup.  Determine the source of the exception and retry.  *)
+   IF head = NIL
+   THEN
+      printf ("list was empty, add sentinal\n");
+      Add (head, -1) ;
+      RETRY  (* Jump back to the begin statement.  *)      
+   ELSIF p^.next = NIL
+   THEN
+      printf ("growing the list\n");
+      Add (p^.next, val) ;
+      RETRY  (* Jump back to the begin statement.  *)
+   ELSE
+      printf ("should never reach here!\n");   
+   END
+END Unique ;
+
+
+PROCEDURE unique ;
+VAR
+   i: CARDINAL ;
+BEGIN
+   FOR i := 0 TO HIGH (Unsorted) DO
+      Unique (Unsorted[i])
+   END ;
+   Display
+END unique ;
+
+
+BEGIN
+   head := NIL ;
+   unique
+END lazyunique.
diff --git a/gcc/testsuite/gm2/pim/run/pass/dectest.mod b/gcc/testsuite/gm2/pim/run/pass/dectest.mod
new file mode 100644
index 0000000000000000000000000000000000000000..41d4744aff08a3d3de09c494430252e055f41fed
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/run/pass/dectest.mod
@@ -0,0 +1,10 @@
+MODULE dectest ;  
+
+VAR
+   c: CARDINAL ;
+BEGIN
+   c := 20 ;
+   WHILE c > 1 DO
+      DEC (c)
+   END
+END dectest.
diff --git a/gcc/testsuite/gm2/pim/run/pass/inctest.mod b/gcc/testsuite/gm2/pim/run/pass/inctest.mod
new file mode 100644
index 0000000000000000000000000000000000000000..c4d9d2e0a358a76d331b751a753d463e8140e5c2
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/run/pass/inctest.mod
@@ -0,0 +1,10 @@
+MODULE inctest ;  
+
+VAR
+   c: CARDINAL ;
+BEGIN
+   c := 0 ;
+   WHILE c < 20 DO
+      INC (c)
+   END
+END inctest.
diff --git a/gcc/testsuite/gm2/pim/run/pass/printtypesize.mod b/gcc/testsuite/gm2/pim/run/pass/printtypesize.mod
new file mode 100644
index 0000000000000000000000000000000000000000..690c4c1878470d43faba1fd52b010127204d8c93
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/run/pass/printtypesize.mod
@@ -0,0 +1,15 @@
+MODULE printtypesize ;  
+
+FROM libc IMPORT printf ;
+FROM SYSTEM IMPORT SIZE, CSIZE_T, COFF_T ;
+
+BEGIN
+   printf ("SIZE (CHAR) = %d bytes\n", SIZE (CHAR));
+   printf ("SIZE (INTEGER) = %d bytes\n", SIZE (INTEGER));
+   printf ("SIZE (CARDINAL) = %d bytes\n", SIZE (CARDINAL));
+   printf ("SIZE (BITSET) = %d bytes\n", SIZE (BITSET));
+   printf ("SIZE (LONGINT) = %d bytes\n", SIZE (LONGINT));
+   printf ("SIZE (LONGCARD) = %d bytes\n", SIZE (LONGCARD));
+   printf ("SIZE (CSIZE_T) = %d bytes\n", SIZE (CSIZE_T));
+   printf ("SIZE (COFF_T) = %d bytes\n", SIZE (COFF_T));   
+END printtypesize.
diff --git a/gcc/testsuite/gnat.dg/warn33.adb b/gcc/testsuite/gnat.dg/warn33.adb
new file mode 100644
index 0000000000000000000000000000000000000000..779e2d12cfcf58a4924d6370e3e5409f1c750d58
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/warn33.adb
@@ -0,0 +1,9 @@
+--  { dg-do compile }
+
+with Warn33_Pkg; use Warn33_Pkg;
+
+procedure Warn33 is
+  Var : DerT;
+begin
+  Var := 1.0 - Var; -- { dg-warning "may be referenced before" }
+end;
diff --git a/gcc/testsuite/gnat.dg/warn33_pkg.ads b/gcc/testsuite/gnat.dg/warn33_pkg.ads
new file mode 100644
index 0000000000000000000000000000000000000000..326fda85f98180e682485270ab72d6cb3c80702d
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/warn33_pkg.ads
@@ -0,0 +1,7 @@
+package Warn33_Pkg is
+
+  type GenT is delta 1.0 range 1.0 .. 10.0;
+  function "-" (X : GenT; Y : GenT) return GenT;
+  type DerT is new GenT;
+
+end Warn33_Pkg;
diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h b/gcc/testsuite/jit.dg/all-non-failing-tests.h
index b566925fd3dd7f90f8a5f0808daa076a424cc56f..add5619aebd4b6710aaa75377a822dcc99947d29 100644
--- a/gcc/testsuite/jit.dg/all-non-failing-tests.h
+++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h
@@ -344,6 +344,13 @@
 #undef create_code
 #undef verify_code
 
+/* test-pr117886-write-reproducer.c.  */
+#define create_code create_code_pr117886_write_reproducer
+#define verify_code verify_code_pr117886_write_reproducer
+#include "test-pr117886-write-reproducer.c"
+#undef create_code
+#undef verify_code
+
 /* test-pure-attribute.c: This can't be in the testcases array as it needs
    the `-O3` flag.  */
 
@@ -603,6 +610,9 @@ const struct testcase testcases[] = {
   {"pr95314_rvalue_reuse",
    create_code_pr95314_rvalue_reuse,
    verify_code_pr95314_rvalue_reuse},
+  {"pr117886_write_reproducer",
+   create_code_pr117886_write_reproducer,
+   verify_code_pr117886_write_reproducer},
   {"reading_struct ",
    create_code_reading_struct ,
    verify_code_reading_struct },
diff --git a/gcc/testsuite/jit.dg/test-pr117886-write-reproducer.c b/gcc/testsuite/jit.dg/test-pr117886-write-reproducer.c
new file mode 100644
index 0000000000000000000000000000000000000000..5018b0ea3eda7c9b72e13a66c7399263800450c0
--- /dev/null
+++ b/gcc/testsuite/jit.dg/test-pr117886-write-reproducer.c
@@ -0,0 +1,103 @@
+/* Verify that we can generate and compile reproducers for
+   gcc_jit_context_new_array_constructor
+   when the values are lvalues */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "libgccjit.h"
+#include "harness.h"
+
+/* 
+   int foo[3];
+
+   void test (void)
+   {
+     int a = 1;
+     int b = 2;
+     int c = 3;
+     foo = {a,b,c};
+   }
+*/
+
+void
+create_code (gcc_jit_context *ctxt, void *user_data)
+{
+  gcc_jit_type *int_type
+    = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
+  gcc_jit_type *void_type
+    = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
+
+  gcc_jit_type *arr_type = gcc_jit_context_new_array_type (ctxt,
+							   0,
+							   int_type,
+							   3);
+  gcc_jit_lvalue *global_intarr_123 = gcc_jit_context_new_global (
+								  ctxt, NULL,
+								  GCC_JIT_GLOBAL_EXPORTED,
+								  arr_type,
+								  "global_intarr_123");
+
+  gcc_jit_function *func =
+    gcc_jit_context_new_function (ctxt, NULL,
+				  GCC_JIT_FUNCTION_EXPORTED,
+				  void_type,
+				  "initialize_intarr_123",
+				  0, NULL, 0);
+  gcc_jit_lvalue *a
+    = gcc_jit_function_new_local (func, NULL, int_type, "a");
+  gcc_jit_lvalue *b
+    = gcc_jit_function_new_local (func, NULL, int_type, "b");
+  gcc_jit_lvalue *c
+    = gcc_jit_function_new_local (func, NULL, int_type, "c");
+
+  gcc_jit_block *bb =
+    gcc_jit_function_new_block (func, "initial");
+
+  gcc_jit_block_add_assignment (bb, NULL,
+				a, gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 1));
+  gcc_jit_block_add_assignment (bb, NULL,
+				b, gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 2));
+  gcc_jit_block_add_assignment (bb, NULL,
+				c, gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 3));
+     
+  gcc_jit_rvalue *values[] = {(gcc_jit_rvalue *)a,
+			      (gcc_jit_rvalue *)b,
+			      (gcc_jit_rvalue *)c};
+  gcc_jit_rvalue *ctor = gcc_jit_context_new_array_constructor (ctxt,
+								0,
+								arr_type,
+								3,
+								values);
+  gcc_jit_block_add_assignment (bb, NULL,
+				global_intarr_123,
+				ctor);
+
+  gcc_jit_block_end_with_void_return (bb, NULL);  
+}
+
+void
+verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
+{
+  CHECK_NON_NULL (result);
+
+  typedef void (*my_fn_type) (void);
+  my_fn_type initialize_intarr_123
+    = (my_fn_type)gcc_jit_result_get_code (result, "initialize_intarr_123");
+  CHECK_NON_NULL (initialize_intarr_123);
+
+  {
+    int *foo = gcc_jit_result_get_global (result, "global_intarr_123");
+    CHECK_NON_NULL (foo);
+
+    CHECK_VALUE (foo[0], 0);
+    CHECK_VALUE (foo[1], 0);
+    CHECK_VALUE (foo[2], 0);
+
+    initialize_intarr_123 ();
+
+    CHECK_VALUE (foo[0], 1);
+    CHECK_VALUE (foo[1], 2);
+    CHECK_VALUE (foo[2], 3);
+  }
+}
diff --git a/gcc/testsuite/lib/gm2-dg.exp b/gcc/testsuite/lib/gm2-dg.exp
index 62081f8632528990e803ee6437e0bed31386e971..eaed554014f8fbe26e1f66ceefe70ab74ed8b9bb 100644
--- a/gcc/testsuite/lib/gm2-dg.exp
+++ b/gcc/testsuite/lib/gm2-dg.exp
@@ -15,6 +15,7 @@
 # <http://www.gnu.org/licenses/>.
 
 load_lib gcc-dg.exp
+load_lib gm2.exp
 
 # Define gm2 callbacks for dg.exp.
 
@@ -75,3 +76,4 @@ proc gm2-dg-runtest { testcases flags default-extra-flags } {
 	}
     }
 }
+
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 9ad1e1965bbd10de537a21d34acc4bd9e8153d65..60e24129bd5858dadd91084a8b222f514ad9418c 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1854,6 +1854,20 @@ proc check_effective_target_fortran_integer_16 { } {
     }]
 }
 
+# Check if long double on the target defaults to the IBM extended format.
+
+proc check_effective_target_long_double_is_ibm128 { } {
+    if { ![istarget powerpc*-*-*] } {
+      return 0
+    }
+
+    return [check_no_compiler_messages long_double_is_ibm128 assembly {
+      #ifndef __LONG_DOUBLE_IBM128__
+      #error "__LONG_DOUBLE_IBM128__ not defined"
+      #endif
+    }]
+}
+
 # Return 1 if we can statically link libgfortran, 0 otherwise.
 #
 # When the target name changes, replace the cached result.
diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.33.3-index-out-of-range.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.33.3-index-out-of-range.sarif
new file mode 100644
index 0000000000000000000000000000000000000000..ef22614776c531845f03a644aa4457d1dbb5912b
--- /dev/null
+++ b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.33.3-index-out-of-range.sarif
@@ -0,0 +1,32 @@
+{
+    "version": "2.1.0",
+    "runs": [
+	{
+	    "tool": {
+		"driver": {
+		    "name": "placeholder"
+		}
+	    },
+	    "results": [
+		{
+		    "message": {"text": "placeholder"},
+		    "locations": [
+			{
+			    "logicalLocations": [
+				{
+				    "index": 42 // { dg-error "index value 42 is out of range for theRun.logicalLocations \\\[SARIF v2.1.0 §3.33.3\\\]" }
+				}
+			    ]
+			}
+		    ]
+		}
+	    ],
+	    "logicalLocations": []
+	}
+    ]
+}
+
+/* { dg-begin-multiline-output "" }
+   17 |                                     "index": 42
+      |                                              ^~
+   { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-valid/spec-example-4.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/spec-example-4.sarif
index 27a0767bd0ef20e1397f9b2c104c5bd101059d70..c0f0fd50e0e9aa46cc4fed1e2bf399940882aac1 100644
--- a/gcc/testsuite/sarif-replay.dg/2.1.0-valid/spec-example-4.sarif
+++ b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/spec-example-4.sarif
@@ -749,7 +749,7 @@
 /* { dg-begin-multiline-output "" }
 In function 'collections::list::add':
 collections/list.h:15:9: error: Variable "ptr" was used without being initialized. It was declared here. [C2001]
-  events 1-3
+  'add': events 1-3
 ......
    { dg-end-multiline-output "" } */
 /* { dg-begin-multiline-output "" }
diff --git a/gcc/toplev.cc b/gcc/toplev.cc
index d45a12cab45f75d801d2500bee4afa9353ae25cd..e03af8b18056dfa2a8ac19cf74352a2b5bcab83d 100644
--- a/gcc/toplev.cc
+++ b/gcc/toplev.cc
@@ -2333,6 +2333,8 @@ toplev::main (int argc, char **argv)
 		  UNKNOWN_LOCATION, global_dc,
 		  targetm.target_option.override);
 
+  file_cache::tune (param_file_cache_files, param_file_cache_lines);
+
   handle_common_deferred_options ();
 
   init_local_tick ();
diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
index 27a4b2b5b1665bc93ce2ae9365f3c20b451c5c89..7015189a2de833d71f5826f35db6de72c3d8ee68 100644
--- a/gcc/tree-eh.cc
+++ b/gcc/tree-eh.cc
@@ -2762,11 +2762,16 @@ tree_could_trap_p (tree expr)
 	  if (TREE_CODE (base) == STRING_CST)
 	    return maybe_le (TREE_STRING_LENGTH (base), off);
 	  tree size = DECL_SIZE_UNIT (base);
+	  tree refsz = TYPE_SIZE_UNIT (TREE_TYPE (expr));
 	  if (size == NULL_TREE
+	      || refsz == NULL_TREE
 	      || !poly_int_tree_p (size)
-	      || maybe_le (wi::to_poly_offset (size), off))
+	      || !poly_int_tree_p (refsz)
+	      || maybe_le (wi::to_poly_offset (size), off)
+	      || maybe_gt (off + wi::to_poly_offset (refsz),
+			   wi::to_poly_offset (size)))
 	    return true;
-	  /* Now we are sure the first byte of the access is inside
+	  /* Now we are sure the whole base of the access is inside
 	     the object.  */
 	  return false;
 	}
diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc
index 7c0e4a868e513c0893c40f08dd11ef9175066bd0..fc0cd3952d569be989ec31f2b581ffd66d2ddc2f 100644
--- a/gcc/tree-loop-distribution.cc
+++ b/gcc/tree-loop-distribution.cc
@@ -2178,25 +2178,32 @@ loop_distribution::pg_add_dependence_edges (struct graph *rdg, int dir,
 		 gcc.dg/tree-ssa/pr94969.c.  */
 	      if (DDR_NUM_DIST_VECTS (ddr) != 1)
 		this_dir = 2;
-	      /* If the overlap is exact preserve stmt order.  */
-	      else if (lambda_vector_zerop (DDR_DIST_VECT (ddr, 0),
-					    DDR_NB_LOOPS (ddr)))
-		;
-	      /* Else as the distance vector is lexicographic positive swap
-		 the dependence direction.  */
 	      else
 		{
-		  if (DDR_REVERSED_P (ddr))
-		    this_dir = -this_dir;
-		  this_dir = -this_dir;
-
+		  /* If the overlap is exact preserve stmt order.  */
+		  if (lambda_vector_zerop (DDR_DIST_VECT (ddr, 0),
+					   DDR_NB_LOOPS (ddr)))
+		    ;
+		  /* Else as the distance vector is lexicographic positive swap
+		     the dependence direction.  */
+		  else
+		    {
+		      if (DDR_REVERSED_P (ddr))
+			this_dir = -this_dir;
+		      this_dir = -this_dir;
+		    }
 		  /* When then dependence distance of the innermost common
-		     loop of the DRs is zero we have a conflict.  */
+		     loop of the DRs is zero we have a conflict.  This is
+		     due to wonky dependence analysis which sometimes
+		     ends up using a zero distance in place of unknown.  */
 		  auto l1 = gimple_bb (DR_STMT (dr1))->loop_father;
 		  auto l2 = gimple_bb (DR_STMT (dr2))->loop_father;
 		  int idx = index_in_loop_nest (find_common_loop (l1, l2)->num,
 						DDR_LOOP_NEST (ddr));
-		  if (DDR_DIST_VECT (ddr, 0)[idx] == 0)
+		  if (DDR_DIST_VECT (ddr, 0)[idx] == 0
+		      /* Unless it is the outermost loop which is the one
+			 we eventually distribute.  */
+		      && idx != 0)
 		    this_dir = 2;
 		}
 	    }
diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc
index 3cf4eb53a15e1e30bb21347c0735ed5c2d37a280..a2a4f5bfa2f19eb579c250584523316085d53d19 100644
--- a/gcc/tree-pretty-print.cc
+++ b/gcc/tree-pretty-print.cc
@@ -1172,7 +1172,7 @@ dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
 	}
       if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
 	  && OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P (clause))
-	pp_string (pp, "[implicit]");
+	pp_string (pp, " [runtime_implicit]");
       pp_right_paren (pp);
       break;
 
diff --git a/gcc/tree-ssa-dse.cc b/gcc/tree-ssa-dse.cc
index 753d7ef148ba1cf12d6bb48287244a8ac2e18fcf..bc632e384841dcef1a2e92231635e5e81062767a 100644
--- a/gcc/tree-ssa-dse.cc
+++ b/gcc/tree-ssa-dse.cc
@@ -1396,8 +1396,10 @@ dse_optimize_call (gimple_stmt_iterator *gsi, sbitmap live_bytes)
   if (!node)
     return false;
 
-  if (stmt_could_throw_p (cfun, stmt)
-      && !cfun->can_delete_dead_exceptions)
+  if ((stmt_could_throw_p (cfun, stmt)
+       && !cfun->can_delete_dead_exceptions)
+      || ((gimple_call_flags (stmt) & ECF_NORETURN)
+	  && gimple_call_ctrl_altering_p (stmt)))
     return false;
 
   /* If return value is used the call is not dead.  */
diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc
index de8d5ae623357945cb419e2d44fdf2f8cc66d46a..9ce88134414203b5160ccf1524d17e5812bc7abc 100644
--- a/gcc/tree-ssa-loop-niter.cc
+++ b/gcc/tree-ssa-loop-niter.cc
@@ -2238,6 +2238,8 @@ build_cltz_expr (tree src, bool leading, bool define_at_zero)
 			      build_int_cst (integer_type_node, prec));
 	}
     }
+  else if (fn == NULL_TREE)
+    return NULL_TREE;
   else if (prec == 2 * lli_prec)
     {
       tree src1 = fold_convert (long_long_unsigned_type_node,
@@ -4757,7 +4759,14 @@ maybe_lower_iteration_bound (class loop *loop)
           FOR_EACH_EDGE (e, ei, bb->succs)
 	    {
 	      if (loop_exit_edge_p (loop, e)
-		  || e == loop_latch_edge (loop))
+		  || e == loop_latch_edge (loop)
+		  /* When exiting an inner loop, verify it is finite.  */
+		  || (!flow_bb_inside_loop_p (bb->loop_father, e->dest)
+		      && !finite_loop_p (bb->loop_father))
+		  /* When we enter an irreducible region and the entry
+		     does not contain a bounding stmt assume it might be
+		     infinite.  */
+		  || (bb->flags & BB_IRREDUCIBLE_LOOP))
 		{
 		  found_exit = true;
 		  break;
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index 64d3ba9e1607a4e46d5f3c8746109ee749047902..f67f52d2d69abf01b1c5ca1e0c55658c820d54ca 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -3646,7 +3646,9 @@ cond_if_else_store_replacement_1 (basic_block then_bb, basic_block else_bb,
       || else_assign == NULL
       || !gimple_assign_single_p (else_assign)
       || gimple_clobber_p (else_assign)
-      || gimple_has_volatile_ops (else_assign))
+      || gimple_has_volatile_ops (else_assign)
+      || stmt_references_abnormal_ssa_name (then_assign)
+      || stmt_references_abnormal_ssa_name (else_assign))
     return false;
 
   lhs = gimple_assign_lhs (then_assign);
diff --git a/gcc/tree-ssa-sink.cc b/gcc/tree-ssa-sink.cc
index e79762b9848b2c418013d750257194a7971e6557..959e0d5c6bea18ff6ef1eea74bb579dda66f000b 100644
--- a/gcc/tree-ssa-sink.cc
+++ b/gcc/tree-ssa-sink.cc
@@ -36,6 +36,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cfgloop.h"
 #include "tree-eh.h"
 #include "tree-ssa-live.h"
+#include "tree-dfa.h"
 
 /* TODO:
    1. Sinking store only using scalar promotion (IE without moving the RHS):
@@ -516,7 +517,8 @@ sink_common_stores_to_bb (basic_block bb)
 	      gimple *def = SSA_NAME_DEF_STMT (arg);
 	      if (! is_gimple_assign (def)
 		  || stmt_can_throw_internal (cfun, def)
-		  || (gimple_phi_arg_edge (phi, i)->flags & EDGE_ABNORMAL))
+		  || (gimple_phi_arg_edge (phi, i)->flags & EDGE_ABNORMAL)
+		  || stmt_references_abnormal_ssa_name (def))
 		{
 		  /* ???  We could handle some cascading with the def being
 		     another PHI.  We'd have to insert multiple PHIs for
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index edd7d4d8763039861d5c238410494f6926785b2c..03426207879fe506f7d31c61512c74fe27fb8281 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -2171,6 +2171,7 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo)
 		  if ((STMT_VINFO_DEF_TYPE (stmt_info) == vect_internal_def
 		       || (STMT_VINFO_DEF_TYPE (stmt_info)
 			   == vect_double_reduction_def))
+		      && ! PURE_SLP_STMT (stmt_info)
 		      && !vectorizable_lc_phi (loop_vinfo,
 					       stmt_info, NULL, NULL))
 		    return opt_result::failure_at (phi, "unsupported phi\n");
@@ -7770,9 +7771,10 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
 	{
 	  /* For SLP we arrive here for both the inner loop LC PHI and
 	     the outer loop PHI.  The latter is what we want to analyze
-	     the reduction with.  */
+	     the reduction with.  The LC PHI is handled by
+	     vectorizable_lc_phi.  */
 	  gcc_assert (slp_node);
-	  return true;
+	  return gimple_phi_num_args (as_a <gphi *> (stmt_info->stmt)) == 2;
 	}
       use_operand_p use_p;
       gimple *use_stmt;
@@ -11574,7 +11576,8 @@ vectorizable_live_operation (vec_info *vinfo, stmt_vec_info stmt_info,
 
       /* There a no further out-of-loop uses of lhs by LC-SSA construction.  */
       FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, lhs)
-	gcc_assert (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)));
+	gcc_assert (is_gimple_debug (use_stmt)
+		    || flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)));
     }
   else
     {
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index 5aebf9505485b6b7f7abded876822f2518ef9503..6fc97d1b6ef91ee4293aee6d64beb317f5094d3f 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -1405,15 +1405,8 @@ vect_recog_sad_pattern (vec_info *vinfo,
       tree abd_oprnd0 = gimple_call_arg (abd_stmt, 0);
       tree abd_oprnd1 = gimple_call_arg (abd_stmt, 1);
 
-      if (gimple_call_internal_fn (abd_stmt) == IFN_ABD)
-	{
-	  if (!vect_look_through_possible_promotion (vinfo, abd_oprnd0,
-						     &unprom[0])
-	      || !vect_look_through_possible_promotion (vinfo, abd_oprnd1,
-							&unprom[1]))
-	    return NULL;
-	}
-      else if (gimple_call_internal_fn (abd_stmt) == IFN_VEC_WIDEN_ABD)
+      if (gimple_call_internal_fn (abd_stmt) == IFN_ABD
+	  || gimple_call_internal_fn (abd_stmt) == IFN_VEC_WIDEN_ABD)
 	{
 	  unprom[0].op = abd_oprnd0;
 	  unprom[0].type = TREE_TYPE (abd_oprnd0);
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 5d9a206f8f584f1fcf0d05cbeda7b9a9b13ec0f7..ac1733004b68943d3fe0d789996c5056cd5400fb 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -10846,7 +10846,7 @@ vectorizable_slp_permutation_1 (vec_info *vinfo, gimple_stmt_iterator *gsi,
       for (unsigned i = 0; i < perm.length (); ++i)
 	dump_printf (MSG_NOTE, " op%u[%u]", perm[i].first, perm[i].second);
       if (repeating_p)
-	dump_printf (MSG_NOTE, " (repeat %d)\n", SLP_TREE_LANES (node));
+	dump_printf (MSG_NOTE, " (repeat %d)", SLP_TREE_LANES (node));
       dump_printf (MSG_NOTE, "\n");
       dump_printf_loc (MSG_NOTE, vect_location, "as");
       for (unsigned i = 0; i < vperm.length (); ++i)
@@ -10884,9 +10884,15 @@ vectorizable_slp_permutation_1 (vec_info *vinfo, gimple_stmt_iterator *gsi,
      vectors to check during analysis, but we need to generate NOUTPUTS
      vectors during transformation.  */
   unsigned total_nelts = olanes;
-  if (repeating_p && gsi)
-    total_nelts = (total_nelts / unpack_factor) * noutputs;
-  for (unsigned i = 0; i < total_nelts; ++i)
+  unsigned process_nelts = olanes;
+  if (repeating_p)
+    {
+      total_nelts = (total_nelts / unpack_factor) * noutputs;
+      if (gsi)
+	process_nelts = total_nelts;
+    }
+  unsigned last_ei = (total_nelts - 1) % process_nelts;
+  for (unsigned i = 0; i < process_nelts; ++i)
     {
       /* VI is the input vector index when generating code for REPEATING_P.  */
       unsigned vi = i / olanes * (pack_p ? 2 : 1);
@@ -10960,7 +10966,7 @@ vectorizable_slp_permutation_1 (vec_info *vinfo, gimple_stmt_iterator *gsi,
 	    }
 
 	  if (!identity_p)
-	    nperms++;
+	    nperms += CEIL (total_nelts, process_nelts) - (ei > last_ei);
 	  if (gsi)
 	    {
 	      if (second_vec.first == -1U)
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog
index 69f1718a58faaf48525eecc395251d5c7513c8ee..c5d5f67ddd1ddbf168c26ef7b92f9a014176be39 100644
--- a/libbacktrace/ChangeLog
+++ b/libbacktrace/ChangeLog
@@ -1,3 +1,17 @@
+2025-01-30  Ian Lance Taylor  <iant@golang.org>
+
+	* elf.c (elf_fetch_bits): Add casts to avoid potentially shifting
+	a value farther than its type size.
+	(elf_fetch_bits_backward): Likewise.
+	(elf_uncompress_lzma_block): Likewise.
+	(elf_uncompress_lzma): Likewise.
+
+2025-01-28  Richard Earnshaw  <rearnsha@arm.com>
+
+	* configure.ac: Always check if the compiler supports __sync
+	operations.
+	* configure: Regenerated.
+
 2024-12-14  Ian Lance Taylor  <iant@golang.org>
 
 	PR libbacktrace/117812
diff --git a/libbacktrace/configure b/libbacktrace/configure
index db491a782349698a324eb726067d5e182d1ebe6b..0ecdd3ec0a3d97d6783a553be879fdf6fb6659a4 100755
--- a/libbacktrace/configure
+++ b/libbacktrace/configure
@@ -12760,6 +12760,29 @@ else
   if test -n "${with_target_subdir}"; then
    case "${host}" in
    hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;;
+   arm*-*-eabi*)
+     # Older versions of the Arm architecture lack the necessary instructions
+     # for these constructs, so check whether we can use them.
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int i;
+int
+main ()
+{
+__sync_bool_compare_and_swap (&i, i, i);
+                         __sync_lock_test_and_set (&i, 1);
+                         __sync_lock_release (&i);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  libbacktrace_cv_sys_sync=yes
+else
+  libbacktrace_cv_sys_sync=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext;;
    *) libbacktrace_cv_sys_sync=yes ;;
    esac
  else
diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
index b700bf9d4f948a7008c304fc3efe5f698856d8d6..75b3a7536f1e8788e08377b50d0116f006e30ad8 100644
--- a/libbacktrace/configure.ac
+++ b/libbacktrace/configure.ac
@@ -199,6 +199,16 @@ AC_CACHE_CHECK([__sync extensions],
 [if test -n "${with_target_subdir}"; then
    case "${host}" in
    hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;;
+   arm*-*-eabi*)
+     # Older versions of the Arm architecture lack the necessary instructions
+     # for these constructs, so check whether we can use them.
+     AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM([int i;],
+                        [__sync_bool_compare_and_swap (&i, i, i);
+                         __sync_lock_test_and_set (&i, 1);
+                         __sync_lock_release (&i);])],
+       [libbacktrace_cv_sys_sync=yes],
+       [libbacktrace_cv_sys_sync=no]);;
    *) libbacktrace_cv_sys_sync=yes ;;
    esac
  else
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index a450f3535c6616f5548e90e46850a65ae322afb1..d766fa41a61c3f16e893ce094c5157044728b48b 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -1147,7 +1147,10 @@ elf_fetch_bits (const unsigned char **ppin, const unsigned char *pinend,
   next = __builtin_bswap32 (next);
 #endif
 #else
-  next = pin[0] | (pin[1] << 8) | (pin[2] << 16) | (pin[3] << 24);
+  next = ((uint32_t)pin[0]
+	  | ((uint32_t)pin[1] << 8)
+	  | ((uint32_t)pin[2] << 16)
+	  | ((uint32_t)pin[3] << 24));
 #endif
 
   val |= (uint64_t)next << bits;
@@ -1198,7 +1201,10 @@ elf_fetch_bits_backward (const unsigned char **ppin,
   next = __builtin_bswap32 (next);
 #endif
 #else
-  next = pin[0] | (pin[1] << 8) | (pin[2] << 16) | (pin[3] << 24);
+  next = ((uint32_t)pin[0]
+	  | ((uint32_t)pin[1] << 8)
+	  | ((uint32_t)pin[2] << 16)
+	  | ((uint32_t)pin[3] << 24));
 #endif
 
   val <<= 32;
@@ -5872,10 +5878,10 @@ elf_uncompress_lzma_block (const unsigned char *compressed,
 	  /* The byte at compressed[off] is ignored for some
 	     reason.  */
 
-	  code = ((compressed[off + 1] << 24)
-		  + (compressed[off + 2] << 16)
-		  + (compressed[off + 3] << 8)
-		  + compressed[off + 4]);
+	  code = ((uint32_t)(compressed[off + 1] << 24)
+		  + ((uint32_t)compressed[off + 2] << 16)
+		  + ((uint32_t)compressed[off + 3] << 8)
+		  + (uint32_t)compressed[off + 4]);
 	  off += 5;
 
 	  /* This is the main LZMA decode loop.  */
@@ -6198,10 +6204,10 @@ elf_uncompress_lzma_block (const unsigned char *compressed,
 	  return 0;
 	}
       computed_crc = elf_crc32 (0, uncompressed, uncompressed_offset);
-      stream_crc = (compressed[off]
-		    | (compressed[off + 1] << 8)
-		    | (compressed[off + 2] << 16)
-		    | (compressed[off + 3] << 24));
+      stream_crc = ((uint32_t)compressed[off]
+		    | ((uint32_t)compressed[off + 1] << 8)
+		    | ((uint32_t)compressed[off + 2] << 16)
+		    | ((uint32_t)compressed[off + 3] << 24));
       if (computed_crc != stream_crc)
 	{
 	  elf_uncompress_failed ();
@@ -6336,10 +6342,10 @@ elf_uncompress_lzma (struct backtrace_state *state,
 
   /* Before that is the size of the index field, which precedes the
      footer.  */
-  index_size = (compressed[offset - 4]
-		| (compressed[offset - 3] << 8)
-		| (compressed[offset - 2] << 16)
-		| (compressed[offset - 1] << 24));
+  index_size = ((size_t)compressed[offset - 4]
+		| ((size_t)compressed[offset - 3] << 8)
+		| ((size_t)compressed[offset - 2] << 16)
+		| ((size_t)compressed[offset - 1] << 24));
   index_size = (index_size + 1) * 4;
   offset -= 4;
 
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 3df7c5255fefc320692cdcac3c503990f83860e1..b61a78b47f35e06b2252fa94fc133ec427191672 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,16 @@
+2025-01-30  Georg-Johann Lay  <avr@gjlay.de>
+
+	* config/avr/t-avr (LIB1ASMFUNCS): Add _strlen_memx.
+	* config/avr/lib1funcs.S <L_strlen_memx, __strlen_memx>: Implement.
+
+2025-01-28  Richard Earnshaw  <rearnsha@arm.com>
+
+	PR target/118642
+	* config/arm/sync-none.specs (link): Only add the defsym if
+	libgcc will be used.
+	* config/arm/sync-dmb.specs: Likewise.
+	* config/arm/sync-cp15dmb.specs: Likewise.
+
 2025-01-17  Monk Chiang  <monk.chiang@sifive.com>
 
 	* config/riscv/crti.S: Add lpad instructions.
diff --git a/libgcc/config/arm/sync-cp15dmb.specs b/libgcc/config/arm/sync-cp15dmb.specs
index 0bb64b97a0da9908e4c5fce007a267c28b84d405..47bf68b6b99c479c5dbafe1944abfa4de83ba550 100644
--- a/libgcc/config/arm/sync-cp15dmb.specs
+++ b/libgcc/config/arm/sync-cp15dmb.specs
@@ -1,4 +1,4 @@
 %rename link sync_sync_link
 
 *link:
---defsym=__sync_synchronize=__sync_synchronize_cp15dmb %(sync_sync_link)
+%{!nostdlib|lgcc: --defsym=__sync_synchronize=__sync_synchronize_cp15dmb} %(sync_sync_link)
diff --git a/libgcc/config/arm/sync-dmb.specs b/libgcc/config/arm/sync-dmb.specs
index 13e59bdd22d9b77cec49814cf6360e6b1f188cb9..cadad6d4626b99cc03ad01c8a8b9fd325601bd9c 100644
--- a/libgcc/config/arm/sync-dmb.specs
+++ b/libgcc/config/arm/sync-dmb.specs
@@ -1,4 +1,4 @@
 %rename link sync_sync_link
 
 *link:
---defsym=__sync_synchronize=__sync_synchronize_dmb %(sync_sync_link)
+%{!nostdlib|lgcc: --defsym=__sync_synchronize=__sync_synchronize_dmb} %(sync_sync_link)
diff --git a/libgcc/config/arm/sync-none.specs b/libgcc/config/arm/sync-none.specs
index 0aa49602c8b62046e541a5c186f510a55f1b0a65..46071ca7b04bc7e9e89bd1deb0080cff98ecaabf 100644
--- a/libgcc/config/arm/sync-none.specs
+++ b/libgcc/config/arm/sync-none.specs
@@ -1,4 +1,4 @@
 %rename link sync_sync_link
 
 *link:
---defsym=__sync_synchronize=__sync_synchronize_none %(sync_sync_link)
+%{!nostdlib|lgcc: --defsym=__sync_synchronize=__sync_synchronize_none} %(sync_sync_link)
diff --git a/libgcc/config/avr/lib1funcs.S b/libgcc/config/avr/lib1funcs.S
index 580f511eb94cd93ea2c260273380a0ebe5be62c4..96f20ca8e64687b68f9d85ff7ca70148e5fbefb1 100644
--- a/libgcc/config/avr/lib1funcs.S
+++ b/libgcc/config/avr/lib1funcs.S
@@ -2755,6 +2755,24 @@ ENDF __fload_4
 #endif /* L_fload_{1|2|3|4} */
 #endif /* if !defined (__AVR_TINY__) */
 
+
+#if !defined (__AVR_TINY__)
+#if defined (L_strlen_memx)
+DEFUN __strlen_memx
+#ifdef __AVR_ERRATA_SKIP_JMP_CALL__
+    tst     r24
+    brmi 1f
+#else
+    sbrs    r24, 7
+#endif
+    XJMP    strlen_PF           ; AVR-LibC
+1:  wmov    24, 22
+    XJMP    strlen              ; AVR-LibC
+ENDF __strlen_memx
+#endif /* L_strlen_memx */
+#endif /* if !defined (__AVR_TINY__) */
+
+
 #if !defined (__AVR_TINY__)
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; memcopy from Address Space __memx to RAM
diff --git a/libgcc/config/avr/t-avr b/libgcc/config/avr/t-avr
index e9fdb98d77652ab6661e15bdc693fb82ce079ea3..f98d48fc013ed692cc3013228ef4ba20b1a54f10 100644
--- a/libgcc/config/avr/t-avr
+++ b/libgcc/config/avr/t-avr
@@ -33,7 +33,8 @@ LIB1ASMFUNCS = \
 	_popcountsi2 \
 	_popcountqi2 \
 	_bswapsi2 \
-	_fmul _fmuls _fmulsu
+	_fmul _fmuls _fmulsu \
+	_strlen_memx
 
 # The below functions either use registers that are not present
 # in tiny core, or use a different register convention (don't save
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 982b4c72f7a417b2ca1eb8110a1d7de833b1088f..f65163e0fb6f605f00d33e240f3ac2a8dbaec67c 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,41 @@
+2025-02-04  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+	* Makefile.am: Add files for unsigned exponentiation.
+	* Makefile.in: Regenerate.
+	* gfortran.map: Add functions for unsigned exponentiation.
+	* generated/pow_m16_m1.c: New file.
+	* generated/pow_m16_m16.c: New file.
+	* generated/pow_m16_m2.c: New file.
+	* generated/pow_m16_m4.c: New file.
+	* generated/pow_m16_m8.c: New file.
+	* generated/pow_m1_m1.c: New file.
+	* generated/pow_m1_m16.c: New file.
+	* generated/pow_m1_m2.c: New file.
+	* generated/pow_m1_m4.c: New file.
+	* generated/pow_m1_m8.c: New file.
+	* generated/pow_m2_m1.c: New file.
+	* generated/pow_m2_m16.c: New file.
+	* generated/pow_m2_m2.c: New file.
+	* generated/pow_m2_m4.c: New file.
+	* generated/pow_m2_m8.c: New file.
+	* generated/pow_m4_m1.c: New file.
+	* generated/pow_m4_m16.c: New file.
+	* generated/pow_m4_m2.c: New file.
+	* generated/pow_m4_m4.c: New file.
+	* generated/pow_m4_m8.c: New file.
+	* generated/pow_m8_m1.c: New file.
+	* generated/pow_m8_m16.c: New file.
+	* generated/pow_m8_m2.c: New file.
+	* generated/pow_m8_m4.c: New file.
+	* generated/pow_m8_m8.c: New file.
+	* m4/powu.m4: New file.
+
+2025-01-24  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+	PR libfortran/118571
+	* io/write.c (write_utf8_char4): Adjust the src_len to the
+	format width w_len when greater than zero.
+
 2025-01-17  Harald Anlauf  <anlauf@gmx.de>
 
 	PR libfortran/118536
diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am
index f58af5890d92cee95d31ee7d22bc31695f4a5281..52bd6ea641f068512d12c53388208fa51c09fdfe 100644
--- a/libgfortran/Makefile.am
+++ b/libgfortran/Makefile.am
@@ -874,6 +874,33 @@ generated/pow_c10_i16.c \
 generated/pow_c16_i16.c \
 generated/pow_c17_i16.c
 
+i_powu_c = \
+generated/pow_m1_m1.c \
+generated/pow_m1_m2.c \
+generated/pow_m1_m4.c \
+generated/pow_m1_m8.c \
+generated/pow_m1_m16.c \
+generated/pow_m2_m1.c \
+generated/pow_m2_m2.c \
+generated/pow_m2_m4.c \
+generated/pow_m2_m8.c \
+generated/pow_m2_m16.c \
+generated/pow_m4_m1.c \
+generated/pow_m4_m2.c \
+generated/pow_m4_m4.c \
+generated/pow_m4_m8.c \
+generated/pow_m4_m16.c \
+generated/pow_m8_m1.c \
+generated/pow_m8_m2.c \
+generated/pow_m8_m4.c \
+generated/pow_m8_m8.c \
+generated/pow_m8_m16.c \
+generated/pow_m16_m1.c \
+generated/pow_m16_m2.c \
+generated/pow_m16_m4.c \
+generated/pow_m16_m8.c \
+generated/pow_m16_m16.c
+
 i_pack_c = \
 generated/pack_i1.c \
 generated/pack_i2.c \
@@ -956,7 +983,7 @@ gfor_built_src= $(i_all_c) $(i_any_c) $(i_count_c) $(i_maxloc0_c) \
 	$(i_minloc1s_c) $(i_maxloc2s_c) $(i_minloc2s_c) $(i_maxvals_c) \
 	$(i_maxval0s_c) $(i_minval0s_c) $(i_maxval1s_c) $(i_minval1s_c) \
 	$(i_findloc0_c) $(i_findloc0s_c) $(i_findloc1_c) $(i_findloc1s_c) \
-	$(i_findloc2s_c) $(i_isobinding_c)
+	$(i_findloc2s_c) $(i_isobinding_c) $(i_powu_c)
 
 # Machine generated specifics
 gfor_built_specific_src= \
@@ -1376,6 +1403,9 @@ $(in_unpack_c): m4/in_unpack.m4 $(I_M4_DEPS)
 $(i_pow_c): m4/pow.m4 $(I_M4_DEPS)
 	$(M4) -Dfile=$@ -I$(srcdir)/m4 pow.m4 > $@
 
+$(i_powu_c): m4/powu.m4 $(I_M4_DEPS)
+	$(M4) -Dfile=$@ -I$(srcdir)/m4 powu.m4 > $@
+
 $(i_pack_c): m4/pack.m4 $(I_M4_DEPS)
 	$(M4) -Dfile=$@ -I$(srcdir)/m4 pack.m4 > $@
 
diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in
index f9a1864832d45e470793683b987f1544e2ee2425..9b9ed2f86ba49680788e6c146d1743a7ceef6213 100644
--- a/libgfortran/Makefile.in
+++ b/libgfortran/Makefile.in
@@ -540,7 +540,20 @@ am__objects_49 = generated/findloc1_i1.lo generated/findloc1_i2.lo \
 am__objects_50 = generated/findloc1_s1.lo generated/findloc1_s4.lo
 am__objects_51 = generated/findloc2_s1.lo generated/findloc2_s4.lo
 am__objects_52 = runtime/ISO_Fortran_binding.lo
-am__objects_53 = $(am__objects_4) $(am__objects_5) $(am__objects_6) \
+am__objects_53 = generated/pow_m1_m1.lo generated/pow_m1_m2.lo \
+	generated/pow_m1_m4.lo generated/pow_m1_m8.lo \
+	generated/pow_m1_m16.lo generated/pow_m2_m1.lo \
+	generated/pow_m2_m2.lo generated/pow_m2_m4.lo \
+	generated/pow_m2_m8.lo generated/pow_m2_m16.lo \
+	generated/pow_m4_m1.lo generated/pow_m4_m2.lo \
+	generated/pow_m4_m4.lo generated/pow_m4_m8.lo \
+	generated/pow_m4_m16.lo generated/pow_m8_m1.lo \
+	generated/pow_m8_m2.lo generated/pow_m8_m4.lo \
+	generated/pow_m8_m8.lo generated/pow_m8_m16.lo \
+	generated/pow_m16_m1.lo generated/pow_m16_m2.lo \
+	generated/pow_m16_m4.lo generated/pow_m16_m8.lo \
+	generated/pow_m16_m16.lo
+am__objects_54 = $(am__objects_4) $(am__objects_5) $(am__objects_6) \
 	$(am__objects_7) $(am__objects_8) $(am__objects_9) \
 	$(am__objects_10) $(am__objects_11) $(am__objects_12) \
 	$(am__objects_13) $(am__objects_14) $(am__objects_15) \
@@ -556,16 +569,16 @@ am__objects_53 = $(am__objects_4) $(am__objects_5) $(am__objects_6) \
 	$(am__objects_43) $(am__objects_44) $(am__objects_45) \
 	$(am__objects_46) $(am__objects_47) $(am__objects_48) \
 	$(am__objects_49) $(am__objects_50) $(am__objects_51) \
-	$(am__objects_52)
-@LIBGFOR_MINIMAL_FALSE@am__objects_54 = io/close.lo io/file_pos.lo \
+	$(am__objects_52) $(am__objects_53)
+@LIBGFOR_MINIMAL_FALSE@am__objects_55 = io/close.lo io/file_pos.lo \
 @LIBGFOR_MINIMAL_FALSE@	io/format.lo io/inquire.lo \
 @LIBGFOR_MINIMAL_FALSE@	io/intrinsics.lo io/list_read.lo \
 @LIBGFOR_MINIMAL_FALSE@	io/lock.lo io/open.lo io/read.lo \
 @LIBGFOR_MINIMAL_FALSE@	io/transfer.lo io/transfer128.lo \
 @LIBGFOR_MINIMAL_FALSE@	io/unit.lo io/unix.lo io/write.lo \
 @LIBGFOR_MINIMAL_FALSE@	io/fbuf.lo io/async.lo
-am__objects_55 = io/size_from_kind.lo $(am__objects_54)
-@LIBGFOR_MINIMAL_FALSE@am__objects_56 = intrinsics/access.lo \
+am__objects_56 = io/size_from_kind.lo $(am__objects_55)
+@LIBGFOR_MINIMAL_FALSE@am__objects_57 = intrinsics/access.lo \
 @LIBGFOR_MINIMAL_FALSE@	intrinsics/c99_functions.lo \
 @LIBGFOR_MINIMAL_FALSE@	intrinsics/chdir.lo intrinsics/chmod.lo \
 @LIBGFOR_MINIMAL_FALSE@	intrinsics/clock.lo \
@@ -589,8 +602,8 @@ am__objects_55 = io/size_from_kind.lo $(am__objects_54)
 @LIBGFOR_MINIMAL_FALSE@	intrinsics/system_clock.lo \
 @LIBGFOR_MINIMAL_FALSE@	intrinsics/time.lo intrinsics/umask.lo \
 @LIBGFOR_MINIMAL_FALSE@	intrinsics/unlink.lo
-@IEEE_SUPPORT_TRUE@am__objects_57 = ieee/ieee_helper.lo
-am__objects_58 = intrinsics/associated.lo intrinsics/abort.lo \
+@IEEE_SUPPORT_TRUE@am__objects_58 = ieee/ieee_helper.lo
+am__objects_59 = intrinsics/associated.lo intrinsics/abort.lo \
 	intrinsics/args.lo intrinsics/cshift0.lo \
 	intrinsics/eoshift0.lo intrinsics/eoshift2.lo \
 	intrinsics/erfc_scaled.lo intrinsics/extends_type_of.lo \
@@ -605,12 +618,12 @@ am__objects_58 = intrinsics/associated.lo intrinsics/abort.lo \
 	intrinsics/selected_real_kind.lo intrinsics/trigd.lo \
 	intrinsics/unpack_generic.lo runtime/in_pack_generic.lo \
 	runtime/in_unpack_generic.lo runtime/in_pack_class.lo \
-	runtime/in_unpack_class.lo $(am__objects_56) $(am__objects_57)
-@IEEE_SUPPORT_TRUE@am__objects_59 = ieee/ieee_arithmetic.lo \
+	runtime/in_unpack_class.lo $(am__objects_57) $(am__objects_58)
+@IEEE_SUPPORT_TRUE@am__objects_60 = ieee/ieee_arithmetic.lo \
 @IEEE_SUPPORT_TRUE@	ieee/ieee_exceptions.lo \
 @IEEE_SUPPORT_TRUE@	ieee/ieee_features.lo
-am__objects_60 =
-am__objects_61 = generated/_abs_c4.lo generated/_abs_c8.lo \
+am__objects_61 =
+am__objects_62 = generated/_abs_c4.lo generated/_abs_c8.lo \
 	generated/_abs_c10.lo generated/_abs_c16.lo \
 	generated/_abs_c17.lo generated/_abs_i4.lo \
 	generated/_abs_i8.lo generated/_abs_i16.lo \
@@ -679,7 +692,7 @@ am__objects_61 = generated/_abs_c4.lo generated/_abs_c8.lo \
 	generated/_aint_r17.lo generated/_anint_r4.lo \
 	generated/_anint_r8.lo generated/_anint_r10.lo \
 	generated/_anint_r16.lo generated/_anint_r17.lo
-am__objects_62 = generated/_sign_i4.lo generated/_sign_i8.lo \
+am__objects_63 = generated/_sign_i4.lo generated/_sign_i8.lo \
 	generated/_sign_i16.lo generated/_sign_r4.lo \
 	generated/_sign_r8.lo generated/_sign_r10.lo \
 	generated/_sign_r16.lo generated/_sign_r17.lo \
@@ -694,13 +707,13 @@ am__objects_62 = generated/_sign_i4.lo generated/_sign_i8.lo \
 	generated/_mod_r4.lo generated/_mod_r8.lo \
 	generated/_mod_r10.lo generated/_mod_r16.lo \
 	generated/_mod_r17.lo
-am__objects_63 = generated/misc_specifics.lo
-am__objects_64 = $(am__objects_61) $(am__objects_62) $(am__objects_63) \
+am__objects_64 = generated/misc_specifics.lo
+am__objects_65 = $(am__objects_62) $(am__objects_63) $(am__objects_64) \
 	intrinsics/dprod_r8.lo intrinsics/f2c_specifics.lo \
 	intrinsics/random_init.lo
-am_libgfortran_la_OBJECTS = $(am__objects_3) $(am__objects_53) \
-	$(am__objects_55) $(am__objects_58) $(am__objects_59) \
-	$(am__objects_60) $(am__objects_64)
+am_libgfortran_la_OBJECTS = $(am__objects_3) $(am__objects_54) \
+	$(am__objects_56) $(am__objects_59) $(am__objects_60) \
+	$(am__objects_61) $(am__objects_65)
 libgfortran_la_OBJECTS = $(am_libgfortran_la_OBJECTS)
 AM_V_P = $(am__v_P_@AM_V@)
 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -1667,6 +1680,33 @@ generated/pow_c10_i16.c \
 generated/pow_c16_i16.c \
 generated/pow_c17_i16.c
 
+i_powu_c = \
+generated/pow_m1_m1.c \
+generated/pow_m1_m2.c \
+generated/pow_m1_m4.c \
+generated/pow_m1_m8.c \
+generated/pow_m1_m16.c \
+generated/pow_m2_m1.c \
+generated/pow_m2_m2.c \
+generated/pow_m2_m4.c \
+generated/pow_m2_m8.c \
+generated/pow_m2_m16.c \
+generated/pow_m4_m1.c \
+generated/pow_m4_m2.c \
+generated/pow_m4_m4.c \
+generated/pow_m4_m8.c \
+generated/pow_m4_m16.c \
+generated/pow_m8_m1.c \
+generated/pow_m8_m2.c \
+generated/pow_m8_m4.c \
+generated/pow_m8_m8.c \
+generated/pow_m8_m16.c \
+generated/pow_m16_m1.c \
+generated/pow_m16_m2.c \
+generated/pow_m16_m4.c \
+generated/pow_m16_m8.c \
+generated/pow_m16_m16.c
+
 i_pack_c = \
 generated/pack_i1.c \
 generated/pack_i2.c \
@@ -1749,7 +1789,7 @@ gfor_built_src = $(i_all_c) $(i_any_c) $(i_count_c) $(i_maxloc0_c) \
 	$(i_minloc1s_c) $(i_maxloc2s_c) $(i_minloc2s_c) $(i_maxvals_c) \
 	$(i_maxval0s_c) $(i_minval0s_c) $(i_maxval1s_c) $(i_minval1s_c) \
 	$(i_findloc0_c) $(i_findloc0s_c) $(i_findloc1_c) $(i_findloc1s_c) \
-	$(i_findloc2s_c) $(i_isobinding_c)
+	$(i_findloc2s_c) $(i_isobinding_c) $(i_powu_c)
 
 
 # Machine generated specifics
@@ -3315,6 +3355,56 @@ generated/findloc2_s4.lo: generated/$(am__dirstamp) \
 	generated/$(DEPDIR)/$(am__dirstamp)
 runtime/ISO_Fortran_binding.lo: runtime/$(am__dirstamp) \
 	runtime/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m1_m1.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m1_m2.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m1_m4.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m1_m8.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m1_m16.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m2_m1.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m2_m2.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m2_m4.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m2_m8.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m2_m16.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m4_m1.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m4_m2.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m4_m4.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m4_m8.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m4_m16.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m8_m1.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m8_m2.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m8_m4.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m8_m8.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m8_m16.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m16_m1.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m16_m2.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m16_m4.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m16_m8.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
+generated/pow_m16_m16.lo: generated/$(am__dirstamp) \
+	generated/$(DEPDIR)/$(am__dirstamp)
 io/$(am__dirstamp):
 	@$(MKDIR_P) io
 	@: > io/$(am__dirstamp)
@@ -4347,6 +4437,31 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_i8_i16.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_i8_i4.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_i8_i8.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m16_m1.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m16_m16.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m16_m2.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m16_m4.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m16_m8.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m1_m1.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m1_m16.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m1_m2.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m1_m4.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m1_m8.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m2_m1.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m2_m16.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m2_m2.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m2_m4.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m2_m8.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m4_m1.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m4_m16.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m4_m2.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m4_m4.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m4_m8.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m8_m1.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m8_m16.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m8_m2.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m8_m4.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_m8_m8.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_r10_i16.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_r10_i8.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@generated/$(DEPDIR)/pow_r16_i16.Plo@am__quote@
@@ -5084,6 +5199,9 @@ include/ISO_Fortran_binding.h: $(srcdir)/ISO_Fortran_binding.h
 @MAINTAINER_MODE_TRUE@$(i_pow_c): m4/pow.m4 $(I_M4_DEPS)
 @MAINTAINER_MODE_TRUE@	$(M4) -Dfile=$@ -I$(srcdir)/m4 pow.m4 > $@
 
+@MAINTAINER_MODE_TRUE@$(i_powu_c): m4/powu.m4 $(I_M4_DEPS)
+@MAINTAINER_MODE_TRUE@	$(M4) -Dfile=$@ -I$(srcdir)/m4 powu.m4 > $@
+
 @MAINTAINER_MODE_TRUE@$(i_pack_c): m4/pack.m4 $(I_M4_DEPS)
 @MAINTAINER_MODE_TRUE@	$(M4) -Dfile=$@ -I$(srcdir)/m4 pack.m4 > $@
 
diff --git a/libgfortran/generated/pow_m16_m1.c b/libgfortran/generated/pow_m16_m1.c
new file mode 100644
index 0000000000000000000000000000000000000000..167aca04ef142b4037bf5391f8c0bef158af5af4
--- /dev/null
+++ b/libgfortran/generated/pow_m16_m1.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_16) && defined (HAVE_GFC_UINTEGER_1)
+
+GFC_UINTEGER_16 pow_m16_m1 (GFC_UINTEGER_16 x, GFC_UINTEGER_1 n);
+export_proto(pow_m16_m1);
+
+inline static GFC_UINTEGER_16
+power_simple_m16_m1 (GFC_UINTEGER_16 x, GFC_UINTEGER_1 n)
+{
+  GFC_UINTEGER_16 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_16
+pow_m16_m1 (GFC_UINTEGER_16 x, GFC_UINTEGER_1 n)
+{
+  const GFC_UINTEGER_16 mask = (GFC_UINTEGER_16) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m16_m1 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m16_m1 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m16_m16.c b/libgfortran/generated/pow_m16_m16.c
new file mode 100644
index 0000000000000000000000000000000000000000..c548186dc0a0673b632076c44764f1697894de46
--- /dev/null
+++ b/libgfortran/generated/pow_m16_m16.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_16) && defined (HAVE_GFC_UINTEGER_16)
+
+GFC_UINTEGER_16 pow_m16_m16 (GFC_UINTEGER_16 x, GFC_UINTEGER_16 n);
+export_proto(pow_m16_m16);
+
+inline static GFC_UINTEGER_16
+power_simple_m16_m16 (GFC_UINTEGER_16 x, GFC_UINTEGER_16 n)
+{
+  GFC_UINTEGER_16 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_16
+pow_m16_m16 (GFC_UINTEGER_16 x, GFC_UINTEGER_16 n)
+{
+  const GFC_UINTEGER_16 mask = (GFC_UINTEGER_16) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m16_m16 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m16_m16 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m16_m2.c b/libgfortran/generated/pow_m16_m2.c
new file mode 100644
index 0000000000000000000000000000000000000000..6f0a8425133d7118204e842ebe037a97af8f82b5
--- /dev/null
+++ b/libgfortran/generated/pow_m16_m2.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_16) && defined (HAVE_GFC_UINTEGER_2)
+
+GFC_UINTEGER_16 pow_m16_m2 (GFC_UINTEGER_16 x, GFC_UINTEGER_2 n);
+export_proto(pow_m16_m2);
+
+inline static GFC_UINTEGER_16
+power_simple_m16_m2 (GFC_UINTEGER_16 x, GFC_UINTEGER_2 n)
+{
+  GFC_UINTEGER_16 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_16
+pow_m16_m2 (GFC_UINTEGER_16 x, GFC_UINTEGER_2 n)
+{
+  const GFC_UINTEGER_16 mask = (GFC_UINTEGER_16) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m16_m2 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m16_m2 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m16_m4.c b/libgfortran/generated/pow_m16_m4.c
new file mode 100644
index 0000000000000000000000000000000000000000..21c49284b28607cda7dc81e78aa1a76a8c5c5d47
--- /dev/null
+++ b/libgfortran/generated/pow_m16_m4.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_16) && defined (HAVE_GFC_UINTEGER_4)
+
+GFC_UINTEGER_16 pow_m16_m4 (GFC_UINTEGER_16 x, GFC_UINTEGER_4 n);
+export_proto(pow_m16_m4);
+
+inline static GFC_UINTEGER_16
+power_simple_m16_m4 (GFC_UINTEGER_16 x, GFC_UINTEGER_4 n)
+{
+  GFC_UINTEGER_16 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_16
+pow_m16_m4 (GFC_UINTEGER_16 x, GFC_UINTEGER_4 n)
+{
+  const GFC_UINTEGER_16 mask = (GFC_UINTEGER_16) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m16_m4 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m16_m4 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m16_m8.c b/libgfortran/generated/pow_m16_m8.c
new file mode 100644
index 0000000000000000000000000000000000000000..c35636b268412e3f4ceae7ffbf34400dd66b7558
--- /dev/null
+++ b/libgfortran/generated/pow_m16_m8.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_16) && defined (HAVE_GFC_UINTEGER_8)
+
+GFC_UINTEGER_16 pow_m16_m8 (GFC_UINTEGER_16 x, GFC_UINTEGER_8 n);
+export_proto(pow_m16_m8);
+
+inline static GFC_UINTEGER_16
+power_simple_m16_m8 (GFC_UINTEGER_16 x, GFC_UINTEGER_8 n)
+{
+  GFC_UINTEGER_16 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_16
+pow_m16_m8 (GFC_UINTEGER_16 x, GFC_UINTEGER_8 n)
+{
+  const GFC_UINTEGER_16 mask = (GFC_UINTEGER_16) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m16_m8 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m16_m8 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m1_m1.c b/libgfortran/generated/pow_m1_m1.c
new file mode 100644
index 0000000000000000000000000000000000000000..f4737afa3dbad27248d68bf6fbc1ae0a18b0a623
--- /dev/null
+++ b/libgfortran/generated/pow_m1_m1.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_1) && defined (HAVE_GFC_UINTEGER_1)
+
+GFC_UINTEGER_1 pow_m1_m1 (GFC_UINTEGER_1 x, GFC_UINTEGER_1 n);
+export_proto(pow_m1_m1);
+
+inline static GFC_UINTEGER_1
+power_simple_m1_m1 (GFC_UINTEGER_1 x, GFC_UINTEGER_1 n)
+{
+  GFC_UINTEGER_1 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_1
+pow_m1_m1 (GFC_UINTEGER_1 x, GFC_UINTEGER_1 n)
+{
+  const GFC_UINTEGER_1 mask = (GFC_UINTEGER_1) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m1_m1 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m1_m1 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m1_m16.c b/libgfortran/generated/pow_m1_m16.c
new file mode 100644
index 0000000000000000000000000000000000000000..a8a5bf8d1654ca3b2f64d3a4b0ce86520be57a01
--- /dev/null
+++ b/libgfortran/generated/pow_m1_m16.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_1) && defined (HAVE_GFC_UINTEGER_16)
+
+GFC_UINTEGER_1 pow_m1_m16 (GFC_UINTEGER_1 x, GFC_UINTEGER_16 n);
+export_proto(pow_m1_m16);
+
+inline static GFC_UINTEGER_1
+power_simple_m1_m16 (GFC_UINTEGER_1 x, GFC_UINTEGER_16 n)
+{
+  GFC_UINTEGER_1 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_1
+pow_m1_m16 (GFC_UINTEGER_1 x, GFC_UINTEGER_16 n)
+{
+  const GFC_UINTEGER_1 mask = (GFC_UINTEGER_1) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m1_m16 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m1_m16 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m1_m2.c b/libgfortran/generated/pow_m1_m2.c
new file mode 100644
index 0000000000000000000000000000000000000000..ff1a2c605721489078db0a29d9dad7b5b308df58
--- /dev/null
+++ b/libgfortran/generated/pow_m1_m2.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_1) && defined (HAVE_GFC_UINTEGER_2)
+
+GFC_UINTEGER_1 pow_m1_m2 (GFC_UINTEGER_1 x, GFC_UINTEGER_2 n);
+export_proto(pow_m1_m2);
+
+inline static GFC_UINTEGER_1
+power_simple_m1_m2 (GFC_UINTEGER_1 x, GFC_UINTEGER_2 n)
+{
+  GFC_UINTEGER_1 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_1
+pow_m1_m2 (GFC_UINTEGER_1 x, GFC_UINTEGER_2 n)
+{
+  const GFC_UINTEGER_1 mask = (GFC_UINTEGER_1) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m1_m2 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m1_m2 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m1_m4.c b/libgfortran/generated/pow_m1_m4.c
new file mode 100644
index 0000000000000000000000000000000000000000..96d9d2a7c8d74b64622ba8c3316b7faff779e335
--- /dev/null
+++ b/libgfortran/generated/pow_m1_m4.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_1) && defined (HAVE_GFC_UINTEGER_4)
+
+GFC_UINTEGER_1 pow_m1_m4 (GFC_UINTEGER_1 x, GFC_UINTEGER_4 n);
+export_proto(pow_m1_m4);
+
+inline static GFC_UINTEGER_1
+power_simple_m1_m4 (GFC_UINTEGER_1 x, GFC_UINTEGER_4 n)
+{
+  GFC_UINTEGER_1 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_1
+pow_m1_m4 (GFC_UINTEGER_1 x, GFC_UINTEGER_4 n)
+{
+  const GFC_UINTEGER_1 mask = (GFC_UINTEGER_1) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m1_m4 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m1_m4 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m1_m8.c b/libgfortran/generated/pow_m1_m8.c
new file mode 100644
index 0000000000000000000000000000000000000000..9162f5ba3d7d4076979d19f387f07b081da8fca1
--- /dev/null
+++ b/libgfortran/generated/pow_m1_m8.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_1) && defined (HAVE_GFC_UINTEGER_8)
+
+GFC_UINTEGER_1 pow_m1_m8 (GFC_UINTEGER_1 x, GFC_UINTEGER_8 n);
+export_proto(pow_m1_m8);
+
+inline static GFC_UINTEGER_1
+power_simple_m1_m8 (GFC_UINTEGER_1 x, GFC_UINTEGER_8 n)
+{
+  GFC_UINTEGER_1 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_1
+pow_m1_m8 (GFC_UINTEGER_1 x, GFC_UINTEGER_8 n)
+{
+  const GFC_UINTEGER_1 mask = (GFC_UINTEGER_1) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m1_m8 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m1_m8 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m2_m1.c b/libgfortran/generated/pow_m2_m1.c
new file mode 100644
index 0000000000000000000000000000000000000000..713721d3ac610c0412c30e70b2e57483eec341f1
--- /dev/null
+++ b/libgfortran/generated/pow_m2_m1.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_2) && defined (HAVE_GFC_UINTEGER_1)
+
+GFC_UINTEGER_2 pow_m2_m1 (GFC_UINTEGER_2 x, GFC_UINTEGER_1 n);
+export_proto(pow_m2_m1);
+
+inline static GFC_UINTEGER_2
+power_simple_m2_m1 (GFC_UINTEGER_2 x, GFC_UINTEGER_1 n)
+{
+  GFC_UINTEGER_2 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_2
+pow_m2_m1 (GFC_UINTEGER_2 x, GFC_UINTEGER_1 n)
+{
+  const GFC_UINTEGER_2 mask = (GFC_UINTEGER_2) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m2_m1 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m2_m1 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m2_m16.c b/libgfortran/generated/pow_m2_m16.c
new file mode 100644
index 0000000000000000000000000000000000000000..8006f9d13f0df3e6b92fd799d000a6575cfae4fb
--- /dev/null
+++ b/libgfortran/generated/pow_m2_m16.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_2) && defined (HAVE_GFC_UINTEGER_16)
+
+GFC_UINTEGER_2 pow_m2_m16 (GFC_UINTEGER_2 x, GFC_UINTEGER_16 n);
+export_proto(pow_m2_m16);
+
+inline static GFC_UINTEGER_2
+power_simple_m2_m16 (GFC_UINTEGER_2 x, GFC_UINTEGER_16 n)
+{
+  GFC_UINTEGER_2 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_2
+pow_m2_m16 (GFC_UINTEGER_2 x, GFC_UINTEGER_16 n)
+{
+  const GFC_UINTEGER_2 mask = (GFC_UINTEGER_2) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m2_m16 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m2_m16 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m2_m2.c b/libgfortran/generated/pow_m2_m2.c
new file mode 100644
index 0000000000000000000000000000000000000000..4d01c22083a8f5249266b0a1b7aae39176415034
--- /dev/null
+++ b/libgfortran/generated/pow_m2_m2.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_2) && defined (HAVE_GFC_UINTEGER_2)
+
+GFC_UINTEGER_2 pow_m2_m2 (GFC_UINTEGER_2 x, GFC_UINTEGER_2 n);
+export_proto(pow_m2_m2);
+
+inline static GFC_UINTEGER_2
+power_simple_m2_m2 (GFC_UINTEGER_2 x, GFC_UINTEGER_2 n)
+{
+  GFC_UINTEGER_2 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_2
+pow_m2_m2 (GFC_UINTEGER_2 x, GFC_UINTEGER_2 n)
+{
+  const GFC_UINTEGER_2 mask = (GFC_UINTEGER_2) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m2_m2 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m2_m2 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m2_m4.c b/libgfortran/generated/pow_m2_m4.c
new file mode 100644
index 0000000000000000000000000000000000000000..c044e2bae9449bfc17b91ed300f5dce32b7544b1
--- /dev/null
+++ b/libgfortran/generated/pow_m2_m4.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_2) && defined (HAVE_GFC_UINTEGER_4)
+
+GFC_UINTEGER_2 pow_m2_m4 (GFC_UINTEGER_2 x, GFC_UINTEGER_4 n);
+export_proto(pow_m2_m4);
+
+inline static GFC_UINTEGER_2
+power_simple_m2_m4 (GFC_UINTEGER_2 x, GFC_UINTEGER_4 n)
+{
+  GFC_UINTEGER_2 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_2
+pow_m2_m4 (GFC_UINTEGER_2 x, GFC_UINTEGER_4 n)
+{
+  const GFC_UINTEGER_2 mask = (GFC_UINTEGER_2) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m2_m4 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m2_m4 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m2_m8.c b/libgfortran/generated/pow_m2_m8.c
new file mode 100644
index 0000000000000000000000000000000000000000..ec50d1c888ba5b21802a6859141c217158840670
--- /dev/null
+++ b/libgfortran/generated/pow_m2_m8.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_2) && defined (HAVE_GFC_UINTEGER_8)
+
+GFC_UINTEGER_2 pow_m2_m8 (GFC_UINTEGER_2 x, GFC_UINTEGER_8 n);
+export_proto(pow_m2_m8);
+
+inline static GFC_UINTEGER_2
+power_simple_m2_m8 (GFC_UINTEGER_2 x, GFC_UINTEGER_8 n)
+{
+  GFC_UINTEGER_2 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_2
+pow_m2_m8 (GFC_UINTEGER_2 x, GFC_UINTEGER_8 n)
+{
+  const GFC_UINTEGER_2 mask = (GFC_UINTEGER_2) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m2_m8 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m2_m8 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m4_m1.c b/libgfortran/generated/pow_m4_m1.c
new file mode 100644
index 0000000000000000000000000000000000000000..2915e0d755d2ddbd6775657cfeca96c436fa1695
--- /dev/null
+++ b/libgfortran/generated/pow_m4_m1.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_4) && defined (HAVE_GFC_UINTEGER_1)
+
+GFC_UINTEGER_4 pow_m4_m1 (GFC_UINTEGER_4 x, GFC_UINTEGER_1 n);
+export_proto(pow_m4_m1);
+
+inline static GFC_UINTEGER_4
+power_simple_m4_m1 (GFC_UINTEGER_4 x, GFC_UINTEGER_1 n)
+{
+  GFC_UINTEGER_4 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_4
+pow_m4_m1 (GFC_UINTEGER_4 x, GFC_UINTEGER_1 n)
+{
+  const GFC_UINTEGER_4 mask = (GFC_UINTEGER_4) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m4_m1 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m4_m1 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m4_m16.c b/libgfortran/generated/pow_m4_m16.c
new file mode 100644
index 0000000000000000000000000000000000000000..400047ba3d873f37a9d7b9c38c86aa1e9fcad27d
--- /dev/null
+++ b/libgfortran/generated/pow_m4_m16.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_4) && defined (HAVE_GFC_UINTEGER_16)
+
+GFC_UINTEGER_4 pow_m4_m16 (GFC_UINTEGER_4 x, GFC_UINTEGER_16 n);
+export_proto(pow_m4_m16);
+
+inline static GFC_UINTEGER_4
+power_simple_m4_m16 (GFC_UINTEGER_4 x, GFC_UINTEGER_16 n)
+{
+  GFC_UINTEGER_4 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_4
+pow_m4_m16 (GFC_UINTEGER_4 x, GFC_UINTEGER_16 n)
+{
+  const GFC_UINTEGER_4 mask = (GFC_UINTEGER_4) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m4_m16 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m4_m16 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m4_m2.c b/libgfortran/generated/pow_m4_m2.c
new file mode 100644
index 0000000000000000000000000000000000000000..40b51dd21d556b26eaae388a5a951bb216838592
--- /dev/null
+++ b/libgfortran/generated/pow_m4_m2.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_4) && defined (HAVE_GFC_UINTEGER_2)
+
+GFC_UINTEGER_4 pow_m4_m2 (GFC_UINTEGER_4 x, GFC_UINTEGER_2 n);
+export_proto(pow_m4_m2);
+
+inline static GFC_UINTEGER_4
+power_simple_m4_m2 (GFC_UINTEGER_4 x, GFC_UINTEGER_2 n)
+{
+  GFC_UINTEGER_4 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_4
+pow_m4_m2 (GFC_UINTEGER_4 x, GFC_UINTEGER_2 n)
+{
+  const GFC_UINTEGER_4 mask = (GFC_UINTEGER_4) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m4_m2 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m4_m2 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m4_m4.c b/libgfortran/generated/pow_m4_m4.c
new file mode 100644
index 0000000000000000000000000000000000000000..45cc6934baae4c5262b3df28efaf87dbe59975c5
--- /dev/null
+++ b/libgfortran/generated/pow_m4_m4.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_4) && defined (HAVE_GFC_UINTEGER_4)
+
+GFC_UINTEGER_4 pow_m4_m4 (GFC_UINTEGER_4 x, GFC_UINTEGER_4 n);
+export_proto(pow_m4_m4);
+
+inline static GFC_UINTEGER_4
+power_simple_m4_m4 (GFC_UINTEGER_4 x, GFC_UINTEGER_4 n)
+{
+  GFC_UINTEGER_4 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_4
+pow_m4_m4 (GFC_UINTEGER_4 x, GFC_UINTEGER_4 n)
+{
+  const GFC_UINTEGER_4 mask = (GFC_UINTEGER_4) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m4_m4 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m4_m4 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m4_m8.c b/libgfortran/generated/pow_m4_m8.c
new file mode 100644
index 0000000000000000000000000000000000000000..d03e86bec5c9b9fbd1cba49244d320ac8c7ec69c
--- /dev/null
+++ b/libgfortran/generated/pow_m4_m8.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_4) && defined (HAVE_GFC_UINTEGER_8)
+
+GFC_UINTEGER_4 pow_m4_m8 (GFC_UINTEGER_4 x, GFC_UINTEGER_8 n);
+export_proto(pow_m4_m8);
+
+inline static GFC_UINTEGER_4
+power_simple_m4_m8 (GFC_UINTEGER_4 x, GFC_UINTEGER_8 n)
+{
+  GFC_UINTEGER_4 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_4
+pow_m4_m8 (GFC_UINTEGER_4 x, GFC_UINTEGER_8 n)
+{
+  const GFC_UINTEGER_4 mask = (GFC_UINTEGER_4) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m4_m8 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m4_m8 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m8_m1.c b/libgfortran/generated/pow_m8_m1.c
new file mode 100644
index 0000000000000000000000000000000000000000..dd9c8b20512dc056514f69807499205072749581
--- /dev/null
+++ b/libgfortran/generated/pow_m8_m1.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_8) && defined (HAVE_GFC_UINTEGER_1)
+
+GFC_UINTEGER_8 pow_m8_m1 (GFC_UINTEGER_8 x, GFC_UINTEGER_1 n);
+export_proto(pow_m8_m1);
+
+inline static GFC_UINTEGER_8
+power_simple_m8_m1 (GFC_UINTEGER_8 x, GFC_UINTEGER_1 n)
+{
+  GFC_UINTEGER_8 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_8
+pow_m8_m1 (GFC_UINTEGER_8 x, GFC_UINTEGER_1 n)
+{
+  const GFC_UINTEGER_8 mask = (GFC_UINTEGER_8) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m8_m1 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m8_m1 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m8_m16.c b/libgfortran/generated/pow_m8_m16.c
new file mode 100644
index 0000000000000000000000000000000000000000..fe973e5b5a8fe42e16877d5bd1805287f69e40cd
--- /dev/null
+++ b/libgfortran/generated/pow_m8_m16.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_8) && defined (HAVE_GFC_UINTEGER_16)
+
+GFC_UINTEGER_8 pow_m8_m16 (GFC_UINTEGER_8 x, GFC_UINTEGER_16 n);
+export_proto(pow_m8_m16);
+
+inline static GFC_UINTEGER_8
+power_simple_m8_m16 (GFC_UINTEGER_8 x, GFC_UINTEGER_16 n)
+{
+  GFC_UINTEGER_8 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_8
+pow_m8_m16 (GFC_UINTEGER_8 x, GFC_UINTEGER_16 n)
+{
+  const GFC_UINTEGER_8 mask = (GFC_UINTEGER_8) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m8_m16 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m8_m16 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m8_m2.c b/libgfortran/generated/pow_m8_m2.c
new file mode 100644
index 0000000000000000000000000000000000000000..adf3e778b46b6829ae802d0a1d8a2bf660f7890a
--- /dev/null
+++ b/libgfortran/generated/pow_m8_m2.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_8) && defined (HAVE_GFC_UINTEGER_2)
+
+GFC_UINTEGER_8 pow_m8_m2 (GFC_UINTEGER_8 x, GFC_UINTEGER_2 n);
+export_proto(pow_m8_m2);
+
+inline static GFC_UINTEGER_8
+power_simple_m8_m2 (GFC_UINTEGER_8 x, GFC_UINTEGER_2 n)
+{
+  GFC_UINTEGER_8 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_8
+pow_m8_m2 (GFC_UINTEGER_8 x, GFC_UINTEGER_2 n)
+{
+  const GFC_UINTEGER_8 mask = (GFC_UINTEGER_8) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m8_m2 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m8_m2 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m8_m4.c b/libgfortran/generated/pow_m8_m4.c
new file mode 100644
index 0000000000000000000000000000000000000000..0833ba001c117d3dc0d82c8aca0ff90e7188507e
--- /dev/null
+++ b/libgfortran/generated/pow_m8_m4.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_8) && defined (HAVE_GFC_UINTEGER_4)
+
+GFC_UINTEGER_8 pow_m8_m4 (GFC_UINTEGER_8 x, GFC_UINTEGER_4 n);
+export_proto(pow_m8_m4);
+
+inline static GFC_UINTEGER_8
+power_simple_m8_m4 (GFC_UINTEGER_8 x, GFC_UINTEGER_4 n)
+{
+  GFC_UINTEGER_8 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_8
+pow_m8_m4 (GFC_UINTEGER_8 x, GFC_UINTEGER_4 n)
+{
+  const GFC_UINTEGER_8 mask = (GFC_UINTEGER_8) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m8_m4 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m8_m4 (x, n);
+}
+
+#endif
diff --git a/libgfortran/generated/pow_m8_m8.c b/libgfortran/generated/pow_m8_m8.c
new file mode 100644
index 0000000000000000000000000000000000000000..d21899bf0adb965a32248f47d36d2755fc291613
--- /dev/null
+++ b/libgfortran/generated/pow_m8_m8.c
@@ -0,0 +1,79 @@
+/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+#if defined (HAVE_GFC_UINTEGER_8) && defined (HAVE_GFC_UINTEGER_8)
+
+GFC_UINTEGER_8 pow_m8_m8 (GFC_UINTEGER_8 x, GFC_UINTEGER_8 n);
+export_proto(pow_m8_m8);
+
+inline static GFC_UINTEGER_8
+power_simple_m8_m8 (GFC_UINTEGER_8 x, GFC_UINTEGER_8 n)
+{
+  GFC_UINTEGER_8 pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler's theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+GFC_UINTEGER_8
+pow_m8_m8 (GFC_UINTEGER_8 x, GFC_UINTEGER_8 n)
+{
+  const GFC_UINTEGER_8 mask = (GFC_UINTEGER_8) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_m8_m8 (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_m8_m8 (x, n);
+}
+
+#endif
diff --git a/libgfortran/gfortran.map b/libgfortran/gfortran.map
index 851df211eeee75b63d13aa25807371afae1c5dda..159a862e90a5866b6dc8ab13619fcfe3003a90c0 100644
--- a/libgfortran/gfortran.map
+++ b/libgfortran/gfortran.map
@@ -1998,4 +1998,29 @@ GFORTRAN_15 {
     _gfortran_sminloc1_8_m4;
     _gfortran_sminloc1_8_m8;
     _gfortran_report_exception;
+    _gfortran_pow_m1_m1;
+    _gfortran_pow_m1_m2;
+    _gfortran_pow_m1_m4;
+    _gfortran_pow_m1_m8;
+    _gfortran_pow_m1_m16;
+    _gfortran_pow_m2_m1;
+    _gfortran_pow_m2_m2;
+    _gfortran_pow_m2_m4;
+    _gfortran_pow_m2_m8;
+    _gfortran_pow_m2_m16;
+    _gfortran_pow_m4_m1;
+    _gfortran_pow_m4_m2;
+    _gfortran_pow_m4_m4;
+    _gfortran_pow_m4_m8;
+    _gfortran_pow_m4_m16;
+    _gfortran_pow_m8_m1;
+    _gfortran_pow_m8_m2;
+    _gfortran_pow_m8_m4;
+    _gfortran_pow_m8_m8;
+    _gfortran_pow_m8_m16;
+    _gfortran_pow_m16_m1;
+    _gfortran_pow_m16_m2;
+    _gfortran_pow_m16_m4;
+    _gfortran_pow_m16_m8;
+    _gfortran_pow_m16_m16;
 } GFORTRAN_14;
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 54312bf67e9cdfa2f96699a87ce49ab7c5fe2f87..b36c5bef09e91ea7f88a45c7cf2c11adac6bc1c1 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -177,7 +177,9 @@ write_utf8_char4 (st_parameter_dt *dtp, gfc_char4_t *source,
       break;
     }
 
-  /* Now process the remaining characters, one at a time.  */
+  /* Now process the remaining characters, one at a time. We need to
+     adjust the src_len if the user has specified a field width.  */
+  src_len = w_len > 0 ? w_len : src_len;
   for (j = k; j < src_len; j++)
     {
       c = source[j];
diff --git a/libgfortran/m4/powu.m4 b/libgfortran/m4/powu.m4
new file mode 100644
index 0000000000000000000000000000000000000000..d8bc375437d43bc3d7cac361aad0657a7e959d65
--- /dev/null
+++ b/libgfortran/m4/powu.m4
@@ -0,0 +1,80 @@
+`/* Support routines for the intrinsic power (**) operator
+   for UNSIGNED, using modulo arithmetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Thomas Koenig.
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran 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 of the License, or (at your option) any later version.
+
+Libgfortran 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
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"'
+
+include(iparm.m4)dnl
+
+/* Use Binary Method to calculate the powi. This is not an optimal but
+   a simple and reasonable arithmetic. See section 4.6.3, "Evaluation of
+   Powers" of Donald E. Knuth, "Seminumerical Algorithms", Vol. 2, "The Art
+   of Computer Programming", 3rd Edition, 1998.  */
+
+`#if defined (HAVE_'rtype_name`) && defined (HAVE_'atype_name`)'
+
+rtype_name `pow_'rtype_code`_'atype_code` ('rtype_name` x, 'atype_name` n);
+export_proto(pow_'rtype_code`_'atype_code`);
+
+inline static 'rtype_name`
+power_simple_'rtype_code`_'atype_code` ('rtype_name` x, 'atype_name` n)
+{
+  'rtype_name` pow = 1;
+  for (;;)
+    {
+      if (n & 1)
+	pow *= x;
+      n >>= 1;
+      if (n)
+	x *= x;
+      else
+	break;
+    }
+  return pow; 
+}
+
+/* For odd x, Euler''`s theorem tells us that x**(2^(m-1)) = 1 mod 2^m.
+   For even x, we use the fact that (2*x)^m = 0 mod 2^m.  */
+
+'rtype_name`
+pow_'rtype_code`_'atype_code` ('rtype_name` x, 'atype_name` n)
+{
+  const 'rtype_name` mask = ('rtype_name`) (-1) / 2;
+  if (n == 0)
+    return 1;
+
+  if  (x == 0)
+    return 0;
+
+  if (x & 1)
+    return power_simple_'rtype_code`_'atype_code` (x, n & mask);
+
+  if (n > sizeof (x) * 8)
+    return 0;
+
+  return power_simple_'rtype_code`_'atype_code` (x, n);
+}
+
+#endif'
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 7905b48fce206adf9660985ae68fc3227f0be86f..97b622d2ce35b902a4cbc45a9474da4f029cbf50 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,33 @@
+2025-01-30  Sandra Loosemore  <sloosemore@baylibre.com>
+
+	* libgomp.texi (OpenMP 5.0): Mark metadirective and declare variant
+	as implemented.
+	(OpenMP 5.1): Mark target_device as supported.
+	Add changed interaction between declare target and OpenMP context
+	and dynamic selector support.
+	(OpenMP 5.2): Mark otherwise clause as supported, note that
+	default is also still accepted.
+
+2025-01-30  Sandra Loosemore  <sloosemore@baylibre.com>
+	    Kwok Cheung Yeung  <kcy@codesourcery.com>
+	    Sandra Loosemore  <sandra@codesourcery.com>
+	    Tobias Burnus  <tobias@codesourcery.com>
+	    Paul-Antoine Arras  <pa@codesourcery.com>
+
+	PR middle-end/112779
+	PR middle-end/113904
+	* testsuite/libgomp.fortran/metadirective-1.f90: New.
+	* testsuite/libgomp.fortran/metadirective-2.f90: New.
+	* testsuite/libgomp.fortran/metadirective-3.f90: New.
+	* testsuite/libgomp.fortran/metadirective-4.f90: New.
+	* testsuite/libgomp.fortran/metadirective-5.f90: New.
+	* testsuite/libgomp.fortran/metadirective-6.f90: New.
+
+2025-01-30  Tobias Burnus  <tburnus@baylibre.com>
+
+	* libgomp.texi (Impl. Status): Update for accumpulated changes
+	related to 'dispatch' and interop.
+
 2025-01-16  Sandra Loosemore  <sloosemore@baylibre.com>
 	    Kwok Cheung Yeung  <kcy@codesourcery.com>
 	    Sandra Loosemore  <sandra@codesourcery.com>
diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index 7d8cd70287eef6d345ab35a5c3fd86389f6c4df0..d1cf9be47ca5275505917f7326943c0b05cde528 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -192,9 +192,8 @@ The OpenMP 4.5 specification is fully supported.
 @item Array shaping @tab N @tab
 @item Array sections with non-unit strides in C and C++ @tab N @tab
 @item Iterators @tab Y @tab
-@item @code{metadirective} directive @tab N @tab
-@item @code{declare variant} directive
-      @tab P @tab @emph{simd} traits not handled correctly
+@item @code{metadirective} directive @tab Y @tab
+@item @code{declare variant} directive @tab Y @tab
 @item @var{target-offload-var} ICV and @code{OMP_TARGET_OFFLOAD}
       env variable @tab Y @tab
 @item Nested-parallel changes to @var{max-active-levels-var} ICV @tab Y @tab
@@ -289,12 +288,13 @@ The OpenMP 4.5 specification is fully supported.
 @headitem Description @tab Status @tab Comments
 @item OpenMP directive as C++ attribute specifiers @tab Y @tab
 @item @code{omp_all_memory} reserved locator @tab Y @tab
-@item @emph{target_device trait} in OpenMP Context @tab N @tab
-@item @code{target_device} selector set in context selectors @tab N @tab
+@item @emph{target_device trait} in OpenMP Context @tab Y
+@item @code{target_device} selector set in context selectors @tab Y @tab
 @item C/C++'s @code{declare variant} directive: elision support of
       preprocessed code @tab N @tab
 @item @code{declare variant}: new clauses @code{adjust_args} and
-      @code{append_args} @tab P @tab Only @code{adjust_args}
+      @code{append_args} @tab P @tab For @code{append_args}, all interop objects
+      must be specified in the @code{interop} clause of @code{dispatch}
 @item @code{dispatch} construct @tab Y @tab
 @item device-specific ICV settings with environment variables @tab Y @tab
 @item @code{assume} and @code{assumes} directives @tab Y @tab
@@ -315,7 +315,7 @@ The OpenMP 4.5 specification is fully supported.
 @item Indirect calls to the device version of a procedure or function in
       @code{target} regions @tab Y @tab
 @item @code{interop} directive @tab N @tab
-@item @code{omp_interop_t} object support in runtime routines @tab N @tab
+@item @code{omp_interop_t} object support in runtime routines @tab Y @tab
 @item @code{nowait} clause in @code{taskwait} directive @tab Y @tab
 @item Extensions to the @code{atomic} directive @tab Y @tab
 @item @code{seq_cst} clause on a @code{flush} construct @tab Y @tab
@@ -366,6 +366,13 @@ to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
 @item @code{device_type(nohost)}/@code{device_type(host)} for variables @tab N @tab
 @item @code{present} modifier to the @code{map}, @code{to} and @code{from}
       clauses @tab Y @tab
+@item Changed interaction between @code{declare target} and OpenMP context
+      @tab Y @tab
+@item Dynamic selector support in @code{metadirective} @tab Y @tab
+@item Dynamic selector support in @code{declare variant} @tab P
+      @tab Fortran rejects non-constant expressions in dynamic selectors;
+      C/C++ reject expressions using argument variables.
+      (@uref{https://gcc.gnu.org/PR113904,PR113904})
 @end multitable
 
 
@@ -407,14 +414,16 @@ to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
 @item New @code{allocators} directive for Fortran @tab Y @tab
 @item Deprecation of @code{allocate} directive for Fortran
       allocatables/pointers @tab N @tab
-@item Optional paired @code{end} directive with @code{dispatch} @tab N @tab
+@item Optional paired @code{end} directive with @code{dispatch} @tab Y @tab
 @item New @code{memspace} and @code{traits} modifiers for @code{uses_allocators}
       @tab N @tab
 @item Deprecation of traits array following the allocator_handle expression in
       @code{uses_allocators} @tab N @tab
 @item New @code{otherwise} clause as alias for @code{default} on metadirectives
-      @tab N @tab
-@item Deprecation of @code{default} clause on metadirectives @tab N @tab
+      @tab Y @tab
+@item Deprecation of @code{default} clause on metadirectives @tab N
+      @tab Both @code{otherwise} and @code{default} are accepted
+      without diagnostics.
 @item Deprecation of delimited form of @code{declare target} @tab N @tab
 @item Reproducible semantics changed for @code{order(concurrent)} @tab N @tab
 @item @code{allocate} and @code{firstprivate} clauses on @code{scope}
@@ -440,7 +449,7 @@ to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
       @code{OMP_TARGET_OFFLOAD=mandatory} @tab Y @tab
 @item @code{all} as @emph{implicit-behavior} for @code{defaultmap} @tab Y @tab
 @item @emph{interop_types} in any position of the modifier list for the @code{init} clause
-      of the @code{interop} construct @tab N @tab
+      of the @code{interop} construct @tab Y @tab
 @item Invoke virtual member functions of C++ objects created on the host device
       on other devices @tab N @tab
 @item @code{mapper} as map-type modifier in @code{declare mapper} @tab N @tab
@@ -483,7 +492,7 @@ to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
       @tab N @tab
 @item @emph{directive-name-modifier} accepted in all clauses @tab N @tab
 @item Extension of @code{interop} operation of @code{append_args}, allowing
-      all modifiers of the @code{init} clause @tab N @tab
+      all modifiers of the @code{init} clause @tab Y @tab
 @item New argument-free version of @code{depobj} with repeatable clauses and
       the @code{init} clause @tab N @tab
 @item Undeprecate omitting the argument to the @code{depend} clause of
@@ -575,7 +584,7 @@ to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
 @item @code{target_data} as composite construct @tab N @tab
 @item @code{nowait} clause with reverse-offload @code{target} directives
       @tab N @tab
-@item Extended @emph{prefer-type} modifier to  @code{init} clause @tab N @tab
+@item Extended @emph{prefer-type} modifier to @code{init} clause @tab Y @tab
 @item Boolean argument to @code{nowait} and @code{nogroup} may be non constant
       @tab N @tab
 @item @code{memscope} clause to @code{atomic} and @code{flush} @tab N @tab
@@ -596,7 +605,7 @@ to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
       @code{omp_set_device_teams_thread_limit} routines @tab N @tab
 @item @code{omp_target_memset} and @code{omp_target_memset_async} routines
       @tab N @tab
-@item Fortran version of the interop runtime routines @tab N @tab
+@item Fortran version of the interop runtime routines @tab Y @tab
 @item Routines for obtaining memory spaces/allocators for shared/device memory
       @tab N @tab
 @item @code{omp_get_memspace_num_resources} routine @tab N @tab
diff --git a/libgomp/testsuite/libgomp.fortran/metadirective-1.f90 b/libgomp/testsuite/libgomp.fortran/metadirective-1.f90
new file mode 100644
index 0000000000000000000000000000000000000000..7b3e09f7c2a5016f2432be86332c07e2055b4b7c
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/metadirective-1.f90
@@ -0,0 +1,61 @@
+! { dg-do run }
+
+program test
+  implicit none
+
+  integer, parameter :: N = 100
+  integer :: x(N), y(N), z(N)
+  integer :: i
+
+  do i = 1, N
+    x(i) = i;
+    y(i) = -i;
+  end do
+
+  call f (x, y, z)
+
+  do i = 1, N
+    if (z(i) .ne. x(i) * y(i)) stop 1
+  end do
+
+  ! -----
+  do i = 1, N
+    x(i) = i;
+    y(i) = -i;
+  end do
+
+  call g (x, y, z)
+
+  do i = 1, N
+    if (z(i) .ne. x(i) * y(i)) stop 1
+  end do
+
+contains
+  subroutine f (x, y, z)
+    integer :: x(N), y(N), z(N)
+
+    !$omp target map (to: x, y) map(from: z)
+      block
+      !$omp metadirective &
+		!$omp& when(device={arch("nvptx")}: teams loop) &
+		!$omp& default(parallel loop)
+	do i = 1, N
+	  z(i) = x(i) * y(i)
+	enddo
+      end block
+  end subroutine
+  subroutine g (x, y, z)
+    integer :: x(N), y(N), z(N)
+
+    !$omp target map (to: x, y) map(from: z)
+    block
+      !$omp metadirective &
+		!$omp& when(device={arch("nvptx")}: teams loop) &
+		!$omp& default(parallel loop)
+	do i = 1, N
+	  z(i) = x(i) * y(i)
+	enddo
+    end block
+    !$omp end target
+  end subroutine
+end program
diff --git a/libgomp/testsuite/libgomp.fortran/metadirective-2.f90 b/libgomp/testsuite/libgomp.fortran/metadirective-2.f90
new file mode 100644
index 0000000000000000000000000000000000000000..8018b1a35a1b6e227d97f071e354bfa6ce3a1c4e
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/metadirective-2.f90
@@ -0,0 +1,38 @@
+! { dg-do run }
+
+program test
+  implicit none
+  integer, parameter :: N = 100
+  real, parameter :: PI_CONST = 2.0*acos(0.0)
+  real, parameter :: E_CONST = exp(1.0)
+  real, parameter :: EPSILON = 0.001
+  integer :: i
+  real :: a(N)
+
+  !$omp target map(from: a)
+    call f (a, PI_CONST)
+  !$omp end target
+
+  do i = 1, N
+    if (abs (a(i) - (PI_CONST * i)) .gt. EPSILON) stop 1
+  end do
+
+  call f (a, E_CONST)
+
+  do i = 1, N
+    if (abs (a(i) - (E_CONST * i)) .gt. EPSILON) stop 2
+  end do
+contains
+  subroutine f (a, x)
+    integer :: i
+    real :: a(N), x
+    !$omp declare target
+
+    !$omp metadirective &
+    !$omp&  when (construct={target}: distribute parallel do ) &
+    !$omp&  default(parallel do simd)
+      do i = 1, N
+	a(i) = x * i
+      end do
+  end subroutine
+end program
diff --git a/libgomp/testsuite/libgomp.fortran/metadirective-3.f90 b/libgomp/testsuite/libgomp.fortran/metadirective-3.f90
new file mode 100644
index 0000000000000000000000000000000000000000..693c40bca5ab671806d2caea4d959899bc16f3c7
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/metadirective-3.f90
@@ -0,0 +1,29 @@
+! { dg-do run }
+
+program test
+  implicit none
+
+  integer, parameter :: N = 100
+  integer :: a(N)
+  integer :: res
+
+  if (f (a, .false.)) stop 1
+  if (.not. f (a, .true.)) stop 2
+contains
+  logical function f (a, flag)
+    integer :: a(N)
+    logical :: flag
+    logical :: res = .false.
+    integer :: i
+    f = .false.
+    !$omp metadirective &
+    !$omp&  when (user={condition(.not. flag)}: &
+    !$omp&	 target teams distribute parallel do &
+    !$omp&		map(from: a(1:N)) private(res)) &
+    !$omp&  default(parallel do)
+      do i = 1, N
+	a(i) = i
+	f = .true.
+     end do
+  end function
+end program
diff --git a/libgomp/testsuite/libgomp.fortran/metadirective-4.f90 b/libgomp/testsuite/libgomp.fortran/metadirective-4.f90
new file mode 100644
index 0000000000000000000000000000000000000000..04fdf61489c9caa62c4cd8bc152b7de2db043613
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/metadirective-4.f90
@@ -0,0 +1,46 @@
+! { dg-do run }
+
+program test
+  use omp_lib
+
+  implicit none
+  integer, parameter :: N = 100
+  integer :: a(N)
+  logical :: is_parallel, is_static
+
+  ! is_static is always set if run_parallel is false.
+  call f (a, .false., .false., is_parallel, is_static)
+  if (is_parallel .or. .not. is_static) stop 1
+
+  call f (a, .false., .true., is_parallel, is_static)
+  if (is_parallel .or. .not. is_static) stop 2
+
+  call f (a, .true., .false., is_parallel, is_static)
+  if (.not. is_parallel .or. is_static) stop 3
+
+  call f (a, .true., .true., is_parallel, is_static)
+  if (.not. is_parallel .or. .not. is_static) stop 4
+contains
+  subroutine f (a, run_parallel, run_static, is_parallel, is_static)
+    integer :: a(N)
+    logical, intent(in) :: run_parallel, run_static
+    logical, intent(out) :: is_parallel, is_static
+    integer :: i
+
+    is_parallel = .false.
+    is_static = .false.
+
+    !$omp begin metadirective when(user={condition(run_parallel)}: parallel)
+      if (omp_in_parallel ()) is_parallel = .true.
+
+      !$omp metadirective &
+      !$omp&  when(construct={parallel}, user={condition(.not. run_static)}: &
+      !$omp&       do schedule(guided) private(is_static)) &
+      !$omp&  when(construct={parallel}: do schedule(static))
+	do i = 1, N
+	  a(i) = i
+	  is_static = .true.
+	end do
+    !$omp end metadirective
+  end subroutine
+end program
diff --git a/libgomp/testsuite/libgomp.fortran/metadirective-5.f90 b/libgomp/testsuite/libgomp.fortran/metadirective-5.f90
new file mode 100644
index 0000000000000000000000000000000000000000..3992286dc08e9cee41014f5cdef26d7872717626
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/metadirective-5.f90
@@ -0,0 +1,44 @@
+! { dg-do run }
+
+program main
+  use omp_lib
+
+  implicit none
+
+  integer, parameter :: N = 100
+  integer :: a(N)
+  integer :: on_device_count = 0
+  integer :: i
+
+  do i = 1, N
+    a(i) = i
+  end do
+
+  do i = 0, omp_get_num_devices ()
+    on_device_count = on_device_count + f (a, i)
+  end do
+
+  if (on_device_count .ne. omp_get_num_devices ()) stop 1
+
+  do i = 1, N
+    if (a(i) .ne. 2 * i) stop 2;
+  end do
+contains
+  integer function f (a, num)
+    integer, intent(inout) :: a(N)
+    integer, intent(in) :: num
+    integer :: on_device
+    integer :: i
+
+    on_device = 0
+    !$omp metadirective &
+    !$omp&  when (target_device={device_num(num), kind("gpu")}: &
+    !$omp&    target parallel do map(to: a(1:N)), map(from: on_device)) &
+    !$omp&  default (parallel do private(on_device))
+      do i = 1, N
+        a(i) = a(i) + i
+        on_device = 1
+      end do
+    f = on_device;
+  end function
+end program
diff --git a/libgomp/testsuite/libgomp.fortran/metadirective-6.f90 b/libgomp/testsuite/libgomp.fortran/metadirective-6.f90
new file mode 100644
index 0000000000000000000000000000000000000000..436fdbade2f3a584529242c4135eeaf9f1c79ed0
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/metadirective-6.f90
@@ -0,0 +1,58 @@
+! { dg-do compile }
+
+program test
+  implicit none
+
+  integer, parameter :: N = 100
+  integer :: x(N), y(N), z(N)
+  integer :: i
+
+contains
+  subroutine f (x, y, z)
+    integer :: x(N), y(N), z(N)
+
+    !$omp target map (to: x, y) map(from: z)  ! { dg-error "OMP TARGET region at .1. with a nested TEAMS at .2. may not contain any other statement, declaration or directive outside of the single TEAMS construct" }
+      block
+      !$omp metadirective &
+		!$omp& when(device={arch("nvptx")}: teams loop) &
+		!$omp& default(parallel loop)  ! { dg-error "\\(1\\)" }
+ ! FIXME: The line above should be the same error as above but some fails here with -fno-diagnostics-show-caret
+ ! Seems as if some gcc/testsuite/ fix is missing for libgomp/testsuite
+	do i = 1, N
+	  z(i) = x(i) * y(i)
+	enddo
+       z(N) = z(N) + 1  ! <<< invalid
+      end block
+  end subroutine
+
+  subroutine f2 (x, y, z)
+    integer :: x(N), y(N), z(N)
+
+    !$omp target map (to: x, y) map(from: z)  ! { dg-error "OMP TARGET region at .1. with a nested TEAMS may not contain any other statement, declaration or directive outside of the single TEAMS construct" }
+      block
+      integer :: i ! << invalid
+      !$omp metadirective &
+		!$omp& when(device={arch("nvptx")}: teams loop) &
+		!$omp& default(parallel loop)
+	do i = 1, N
+	  z(i) = x(i) * y(i)
+	enddo
+      end block
+  end subroutine
+  subroutine g (x, y, z)
+    integer :: x(N), y(N), z(N)
+
+    !$omp target map (to: x, y) map(from: z)  ! { dg-error "OMP TARGET region at .1. with a nested TEAMS may not contain any other statement, declaration or directive outside of the single TEAMS construct" }
+    block
+      !$omp metadirective &   ! <<<< invalid
+		!$omp& when(device={arch("nvptx")}: flush) &
+		!$omp& default(nothing)
+       !$omp teams loop
+	do i = 1, N
+	  z(i) = x(i) * y(i)
+	enddo
+    end block
+    !$omp end target
+  end subroutine
+
+end program
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index d2358a323d924dbc4c6793f92267acaacf56c89f..97f64b248596a73a827940da7963f030d9c1e650 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,66 @@
+2025-01-31  Patrick Palka  <ppalka@redhat.com>
+
+	PR libstdc++/118156
+	* include/std/flat_map (_Flat_map_impl::_M_insert): Generalized
+	version of insert taking heterogenous iterator/sentinel pair.
+	(_Flat_map_impl::insert): Dispatch to _M_insert.
+	(_Flat_map_impl::insert_range): Likewise.
+	(flat_map): Export _Flat_map_impl::insert_range.
+	(flat_multimap): Likewise.
+	* include/std/flat_set (_Flat_set_impl::insert_range):
+	Reimplement directly, not in terms of insert.
+	(flat_set): Export _Flat_set_impl::insert_range.
+	(flat_multiset): Likewise.
+	* testsuite/23_containers/flat_map/1.cc (test06): New test.
+	* testsuite/23_containers/flat_multimap/1.cc (test06): New test.
+	* testsuite/23_containers/flat_multiset/1.cc (test06): New test.
+	* testsuite/23_containers/flat_set/1.cc (test06): New test.
+
+2025-01-31  Patrick Palka  <ppalka@redhat.com>
+
+	* include/bits/stl_bvector.h (vector<bool>::insert_range):
+	Consistently return an iterator pointing to the first element
+	inserted.
+	* include/bits/vector.tcc (vector::insert_range): Likewise.
+	* testsuite/23_containers/vector/bool/modifiers/insert/insert_range.cc:
+	Verify insert_range return values.
+	* testsuite/23_containers/vector/modifiers/insert/insert_range.cc:
+	Likewise.
+
+2025-01-30  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/98749
+	* include/std/latch (latch::max()): Ensure the return value is
+	representable as the return type.
+	(latch::latch(ptrdiff_t)): Add assertion.
+	(latch::count_down): Fix copy & pasted duplicate assertion. Use
+	std::cmp_equal to compare __platform_wait_t and ptrdiff_t
+	values.
+	(latch::_M_a): Use defined constant for alignment.
+	* testsuite/30_threads/latch/1.cc: Check max(). Check constant
+	initialization works for values in the valid range. Check
+	alignment.
+
+2025-01-29  Patrick Palka  <ppalka@redhat.com>
+
+	PR libstdc++/118413
+	* include/std/ranges (views::__adaptor::_Partial): Adjust
+	constraints on the "simple" partial specializations to require
+	is_trivially_copy_constructible_v instead of
+	is_trivially_copyable_v.
+	* testsuite/std/ranges/adaptors/adjacent_transform/1.cc (test04):
+	Extend P2494R2 test.
+	* testsuite/std/ranges/adaptors/transform.cc (test09): Likewise.
+
+2025-01-27  Andreas Schwab  <schwab@suse.de>
+
+	PR libstdc++/118563
+	* testsuite/util/testsuite_abi.cc (check_version): Add
+	CXXABI_1.3.16.
+	* config/abi/pre/gnu.ver (CXXABI_1.3.14) [__riscv]: Exclude
+	typeinfo for bfloat16_t.
+	(CXXABI_1.3.16) [__riscv]: Add it here.
+
 2025-01-23  Jan Hubicka  <jh@suse.cz>
 
 	PR target/80813
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index f7641974ec4da2ffad9a54feb341d52ad3856372..adadc62e3533959a6d0d0c439d2e776d227aeb50 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -2852,10 +2852,15 @@ CXXABI_1.3.13 {
 CXXABI_1.3.14 {
 
     # typeinfo for _Float{16,32,64,128,32x,64x,128x} and
-    # __bf16
-    _ZTIDF[0-9]*[_bx];
-    _ZTIPDF[0-9]*[_bx];
-    _ZTIPKDF[0-9]*[_bx];
+    # __bf16/bfloat16_t
+    _ZTIDF[0-9]*[_x];
+    _ZTIPDF[0-9]*[_x];
+    _ZTIPKDF[0-9]*[_x];
+#ifndef __riscv
+    _ZTIDF16b;
+    _ZTIPDF16b;
+    _ZTIPKDF16b;
+#endif
     _ZTIu6__bf16;
     _ZTIPu6__bf16;
     _ZTIPKu6__bf16;
@@ -2869,6 +2874,16 @@ CXXABI_1.3.15 {
 
 } CXXABI_1.3.14;
 
+#ifdef __riscv
+CXXABI_1.3.16 {
+
+    _ZTIDF16b;
+    _ZTIPDF16b;
+    _ZTIPKDF16b;
+
+} CXXABI_1.3.15;
+#endif
+
 # Symbols in the support library (libsupc++) supporting transactional memory.
 CXXABI_TM_1 {
 
diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h
index 961e4a252996276266809f9709706fd0f2f4130e..2292eec54ad748c33b28a30a164a4214933c6f4b 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -1341,9 +1341,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 		      std::copy_backward(__pos._M_const_cast(), end(),
 					 this->_M_impl._M_finish
 					   + difference_type(__n));
-		      auto __i = ranges::copy(__rg, __pos._M_const_cast()).out;
+		      ranges::copy(__rg, __pos._M_const_cast());
 		      this->_M_impl._M_finish += difference_type(__n);
-		      return __i;
+		      return __pos._M_const_cast();
 		    }
 		  else
 		    {
@@ -1355,9 +1355,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 		      iterator __i = _M_copy_aligned(__begin,
 						     __pos._M_const_cast(),
 						     __start);
-		      __i = ranges::copy(__rg, __i).out;
+		      iterator __j = ranges::copy(__rg, __i).out;
 		      iterator __finish = std::copy(__pos._M_const_cast(),
-						    __end, __i);
+						    __end, __j);
 		      this->_M_deallocate();
 		      this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
 		      this->_M_impl._M_start = __start;
diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc
index 4f4c366080bea216252f49b9c3a29231fce60feb..acb2f5fca1e779c4788adcbb00feaa586eb05305 100644
--- a/libstdc++-v3/include/bits/vector.tcc
+++ b/libstdc++-v3/include/bits/vector.tcc
@@ -984,8 +984,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       {
 	if (__pos == cend())
 	  {
+	    const auto __ins_idx = size();
 	    append_range(std::forward<_Rg>(__rg));
-	    return end();
+	    return begin() + __ins_idx;
 	  }
 
 	if constexpr (ranges::forward_range<_Rg>)
diff --git a/libstdc++-v3/include/std/flat_map b/libstdc++-v3/include/std/flat_map
index 1ecc2e7f6e7e43bd1318363d9b170d6b6e8b00cd..405caa8a81bfa444f63d80261bf8ec8f00015851 100644
--- a/libstdc++-v3/include/std/flat_map
+++ b/libstdc++-v3/include/std/flat_map
@@ -538,9 +538,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	insert(const_iterator __position, _Arg&& __x)
 	{ return emplace_hint(__position, std::forward<_Arg>(__x)); }
 
-      template<__has_input_iter_cat _InputIterator>
+    private:
+      template<typename _Iter, typename _Sent>
 	void
-	insert(_InputIterator __first, _InputIterator __last)
+	_M_insert(_Iter __first, _Sent __last)
 	{
 	  // FIXME: This implementation fails its complexity requirements.
 	  // We can't idiomatically implement an efficient version (as in the
@@ -574,6 +575,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 	}
 
+    public:
+      template<__has_input_iter_cat _InputIterator>
+	void
+	insert(_InputIterator __first, _InputIterator __last)
+	{ _M_insert(std::move(__first), std::move(__last)); }
+
       template<__has_input_iter_cat _InputIterator>
 	void
 	insert(__sorted_t, _InputIterator __first, _InputIterator __last)
@@ -585,7 +592,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       template<__detail::__container_compatible_range<value_type> _Rg>
 	void
 	insert_range(_Rg&& __rg)
-	{ insert(ranges::begin(__rg), ranges::end(__rg)); }
+	{ _M_insert(ranges::begin(__rg), ranges::end(__rg)); }
 
       void
       insert(initializer_list<value_type> __il)
@@ -1181,7 +1188,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       using _Impl::emplace;
       using _Impl::emplace_hint;
       using _Impl::insert;
-      // using _Impl::insert_range;
+      using _Impl::insert_range;
       using _Impl::extract;
       using _Impl::replace;
       using _Impl::erase;
@@ -1460,7 +1467,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       using _Impl::emplace;
       using _Impl::emplace_hint;
       using _Impl::insert;
-      // using _Impl::insert_range;
+      using _Impl::insert_range;
       using _Impl::extract;
       using _Impl::replace;
       using _Impl::erase;
diff --git a/libstdc++-v3/include/std/flat_set b/libstdc++-v3/include/std/flat_set
index 3e1347a6a0ae71684febe2cfd0869256167ce6ff..9240f2b9a2ebc75863c5d0fab312dd5e0b1ae42c 100644
--- a/libstdc++-v3/include/std/flat_set
+++ b/libstdc++-v3/include/std/flat_set
@@ -475,7 +475,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       template<__detail::__container_compatible_range<value_type> _Rg>
 	void
 	insert_range(_Rg&& __rg)
-	{ insert(ranges::begin(__rg), ranges::end(__rg)); }
+	{
+	  auto __guard = _M_make_clear_guard();
+	  typename container_type::iterator __it;
+	  if constexpr (requires { _M_cont.insert_range(_M_cont.end(), __rg); })
+	    __it = _M_cont.insert_range(_M_cont.end(), __rg);
+	  else if constexpr (ranges::common_range<_Rg>)
+	    __it = _M_cont.insert(_M_cont.end(), ranges::begin(__rg), ranges::end(__rg));
+	  else
+	    {
+	      size_type __n = size();
+	      auto __first = ranges::begin(__rg);
+	      auto __last = ranges::end(__rg);
+	      for (; __first != __last; ++__first)
+		_M_cont.emplace_back(*__first);
+	      __it = _M_cont.begin() + __n;
+	    }
+	  std::sort(__it, _M_cont.end(), _M_comp);
+	  std::inplace_merge(_M_cont.begin(), __it, _M_cont.end(), _M_comp);
+	  if constexpr (!_Multi)
+	    _M_unique();
+	  __guard._M_disable();
+	}
 
       void
       insert(initializer_list<value_type> __il)
@@ -808,7 +829,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       using _Impl::emplace;
       using _Impl::emplace_hint;
       using _Impl::insert;
-      // using _Impl::insert_range;
+      using _Impl::insert_range;
       using _Impl::extract;
       using _Impl::replace;
       using _Impl::erase;
@@ -947,7 +968,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       using _Impl::emplace;
       using _Impl::emplace_hint;
       using _Impl::insert;
-      // using _Impl::insert_range;
+      using _Impl::insert_range;
       using _Impl::extract;
       using _Impl::replace;
       using _Impl::erase;
diff --git a/libstdc++-v3/include/std/latch b/libstdc++-v3/include/std/latch
index 9220580613d28f8f4e018925fd4f96ec774a42e8..cf648545629da66cce7fc1c18bab10c4119ddfad 100644
--- a/libstdc++-v3/include/std/latch
+++ b/libstdc++-v3/include/std/latch
@@ -41,6 +41,7 @@
 #ifdef __cpp_lib_latch // C++ >= 20 && atomic_wait
 #include <bits/atomic_base.h>
 #include <ext/numeric_traits.h>
+#include <utility> // cmp_equal, cmp_less_equal, etc.
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -51,24 +52,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   public:
     static constexpr ptrdiff_t
     max() noexcept
-    { return __gnu_cxx::__int_traits<__detail::__platform_wait_t>::__max; }
+    {
+      using __gnu_cxx::__int_traits;
+      constexpr auto __max = __int_traits<__detail::__platform_wait_t>::__max;
+      if constexpr (std::cmp_less(__max, __PTRDIFF_MAX__))
+	return __max;
+      return __PTRDIFF_MAX__;
+    }
 
-    constexpr explicit latch(ptrdiff_t __expected) noexcept
-      : _M_a(__expected) { }
+    constexpr explicit
+    latch(ptrdiff_t __expected) noexcept
+    : _M_a(__expected)
+    { __glibcxx_assert(__expected >= 0 && __expected <= max()); }
 
     ~latch() = default;
+
     latch(const latch&) = delete;
     latch& operator=(const latch&) = delete;
 
     _GLIBCXX_ALWAYS_INLINE void
     count_down(ptrdiff_t __update = 1)
     {
-      __glibcxx_assert(__update >= 0);
-      auto const __old = __atomic_impl::fetch_sub(&_M_a,
-				    __update, memory_order::release);
-      __glibcxx_assert(__update >= 0);
-      if (__old == static_cast<__detail::__platform_wait_t>(__update))
+      __glibcxx_assert(__update >= 0 && __update <= max());
+      auto const __old = __atomic_impl::fetch_sub(&_M_a, __update,
+						  memory_order::release);
+      if (std::cmp_equal(__old, __update))
 	__atomic_impl::notify_all(&_M_a);
+      else
+	__glibcxx_assert(std::cmp_less(__update, __old));
     }
 
     _GLIBCXX_ALWAYS_INLINE bool
@@ -90,9 +101,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 
   private:
-    // This alignas is not redundant, it increases the alignment for
-    // long long on x86.
-    alignas(__alignof__(__detail::__platform_wait_t)) __detail::__platform_wait_t _M_a;
+    alignas(__detail::__platform_wait_alignment)
+      __detail::__platform_wait_t _M_a;
   };
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index ad69a94b21fb81de6d55f573f2bb2f6ce6ceeb77..5c795a90fbc29ddbacbed8c32a753a06e6662c62 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -1145,7 +1145,7 @@ namespace views::__adaptor
   // which makes overload resolution failure diagnostics more concise.
   template<typename _Adaptor, typename... _Args>
     requires __adaptor_has_simple_extra_args<_Adaptor, _Args...>
-      && (is_trivially_copyable_v<_Args> && ...)
+      && (is_trivially_copy_constructible_v<_Args> && ...)
     struct _Partial<_Adaptor, _Args...> : _RangeAdaptorClosure<_Partial<_Adaptor, _Args...>>
     {
       tuple<_Args...> _M_args;
@@ -1176,7 +1176,7 @@ namespace views::__adaptor
   // where _Adaptor accepts a single extra argument.
   template<typename _Adaptor, typename _Arg>
     requires __adaptor_has_simple_extra_args<_Adaptor, _Arg>
-      && is_trivially_copyable_v<_Arg>
+      && is_trivially_copy_constructible_v<_Arg>
     struct _Partial<_Adaptor, _Arg> : _RangeAdaptorClosure<_Partial<_Adaptor, _Arg>>
     {
       _Arg _M_arg;
diff --git a/libstdc++-v3/scripts/extract_symvers.pl b/libstdc++-v3/scripts/extract_symvers.pl
index e0e6e5b70c4a75b62cc3f03f414305f9b4a2de2a..fb18e11a1b3ef5caa159193c7ea0a2b1caf353c9 100644
--- a/libstdc++-v3/scripts/extract_symvers.pl
+++ b/libstdc++-v3/scripts/extract_symvers.pl
@@ -34,8 +34,18 @@ while (<PVS>) {
     # Remove trailing semicolon.
     s/;$//;
 
-    # shared object, dash, version, symbol, [size]
-    (undef, undef, $version, $symbol, $size) = split;
+    if (/\[WEAK\]/) {
+	# Allow for weak versions like
+	# libstdc++.so.6.0.34 -	CXXABI_1.3.16 [WEAK]: {CXXABI_1.3.15};
+	#
+	# shared object, dash, version "[WEAK]", symbol, [size]
+	(undef, undef, $version, undef, $symbol, $size) = split;
+    } else {
+	# libstdc++.so.6.0.34 -	CXXABI_1.3.16: {CXXABI_1.3.15};
+	#
+	# shared object, dash, version, symbol, [size]
+	(undef, undef, $version, $symbol, $size) = split;
+    }
 
     # Remove colon separator from version field.
     $version =~ s/:$//;
diff --git a/libstdc++-v3/testsuite/23_containers/flat_map/1.cc b/libstdc++-v3/testsuite/23_containers/flat_map/1.cc
index 111cafaa6ba1de79db7f1ff439108cd5784ca078..00254dc2ee623982f2782b761661f0784bef5f6a 100644
--- a/libstdc++-v3/testsuite/23_containers/flat_map/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/flat_map/1.cc
@@ -164,6 +164,22 @@ test05()
   VERIFY( std::ranges::equal(m | std::views::values, (int[]){-1, -2, -3, -4, -5}) );
 }
 
+void
+test06()
+{
+  // PR libstdc++/118156 - flat_foo::insert_range cannot handle non-common ranges
+  std::flat_map<int, int> m;
+  auto r = std::views::zip(std::views::iota(1), std::views::iota(2)) | std::views::take(5);
+  static_assert(!std::ranges::common_range<decltype(r)>);
+  m.insert_range(r);
+  VERIFY( std::ranges::equal(m | std::views::keys, (int[]){1, 2, 3, 4, 5}) );
+  VERIFY( std::ranges::equal(m | std::views::values, (int[]){2, 3, 4, 5, 6}) );
+  m.clear();
+  m.insert_range(r | std::views::reverse);
+  VERIFY( std::ranges::equal(m | std::views::keys, (int[]){1, 2, 3, 4, 5}) );
+  VERIFY( std::ranges::equal(m | std::views::values, (int[]){2, 3, 4, 5, 6}) );
+}
+
 int
 main()
 {
@@ -175,4 +191,5 @@ main()
   test03();
   test04();
   test05();
+  test06();
 }
diff --git a/libstdc++-v3/testsuite/23_containers/flat_multimap/1.cc b/libstdc++-v3/testsuite/23_containers/flat_multimap/1.cc
index 08f4bbc38fd2a54a18d4fffb9a3137419b7c7571..38650a81bcffbba5342b1e499c5a41925e32589c 100644
--- a/libstdc++-v3/testsuite/23_containers/flat_multimap/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/flat_multimap/1.cc
@@ -138,6 +138,21 @@ test05()
   VERIFY( std::ranges::equal(m | std::views::keys, (int[]){1, 2, 3, 3, 4, 5}) );
   VERIFY( std::ranges::equal(m | std::views::values, (int[]){-1, -2, -3, 3, -4, -5}) );
 }
+void
+test06()
+{
+  // PR libstdc++/118156 - flat_foo::insert_range cannot handle non-common ranges
+  std::flat_multimap<int, int> m;
+  auto r = std::views::zip(std::views::iota(1), std::views::iota(2)) | std::views::take(5);
+  static_assert(!std::ranges::common_range<decltype(r)>);
+  m.insert_range(r);
+  VERIFY( std::ranges::equal(m | std::views::keys, (int[]){1, 2, 3, 4, 5}) );
+  VERIFY( std::ranges::equal(m | std::views::values, (int[]){2, 3, 4, 5, 6}) );
+  m.clear();
+  m.insert_range(r | std::views::reverse);
+  VERIFY( std::ranges::equal(m | std::views::keys, (int[]){1, 2, 3, 4, 5}) );
+  VERIFY( std::ranges::equal(m | std::views::values, (int[]){2, 3, 4, 5, 6}) );
+}
 
 int
 main()
@@ -150,4 +165,5 @@ main()
   test03();
   test04();
   test05();
+  test06();
 }
diff --git a/libstdc++-v3/testsuite/23_containers/flat_multiset/1.cc b/libstdc++-v3/testsuite/23_containers/flat_multiset/1.cc
index 82958f7939bc04eea3ea279d56132a73b54016d0..910f5dca5be426b8903beee844bf6dbba47d6a04 100644
--- a/libstdc++-v3/testsuite/23_containers/flat_multiset/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/flat_multiset/1.cc
@@ -2,6 +2,7 @@
 
 #include <flat_set>
 #include <deque>
+#include <ranges>
 #include <vector>
 #include <testsuite_allocator.h>
 #include <testsuite_hooks.h>
@@ -128,6 +129,20 @@ test05()
   VERIFY( std::ranges::equal(m, (int[]){1, 2, 3, 3, 4, 5}) );
 }
 
+void
+test06()
+{
+  // PR libstdc++/118156 - flat_foo::insert_range cannot handle non-common ranges
+  std::flat_multiset<int> s;
+  auto r = std::views::iota(1) | std::views::take(5);
+  static_assert(!std::ranges::common_range<decltype(r)>);
+  s.insert_range(r);
+  VERIFY( std::ranges::equal(s, (int[]){1, 2, 3, 4, 5}) );
+  s.clear();
+  s.insert_range(r | std::views::reverse);
+  VERIFY( std::ranges::equal(s, (int[]){1, 2, 3, 4, 5}) );
+}
+
 int
 main()
 {
@@ -137,4 +152,5 @@ main()
   test03();
   test04();
   test05();
+  test06();
 }
diff --git a/libstdc++-v3/testsuite/23_containers/flat_set/1.cc b/libstdc++-v3/testsuite/23_containers/flat_set/1.cc
index 325b1263aa35b8891c5e8f01e274348e118c8369..f0eaac936bf6301dcc9803311cab6ea9d346a20a 100644
--- a/libstdc++-v3/testsuite/23_containers/flat_set/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/flat_set/1.cc
@@ -7,6 +7,7 @@
 #endif
 
 #include <deque>
+#include <ranges>
 #include <vector>
 #include <testsuite_allocator.h>
 #include <testsuite_hooks.h>
@@ -143,6 +144,20 @@ test05()
   VERIFY( std::ranges::equal(m, (int[]){1, 2, 3, 4, 5}) );
 }
 
+void
+test06()
+{
+  // PR libstdc++/118156 - flat_foo::insert_range cannot handle non-common ranges
+  std::flat_set<int> s;
+  auto r = std::views::iota(1) | std::views::take(5);
+  static_assert(!std::ranges::common_range<decltype(r)>);
+  s.insert_range(r);
+  VERIFY( std::ranges::equal(s, (int[]){1, 2, 3, 4, 5}) );
+  s.clear();
+  s.insert_range(r | std::views::reverse);
+  VERIFY( std::ranges::equal(s, (int[]){1, 2, 3, 4, 5}) );
+}
+
 int
 main()
 {
@@ -152,4 +167,5 @@ main()
   test03();
   test04();
   test05();
+  test06();
 }
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/insert_range.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/insert_range.cc
index 4f4835746ea44c1204d67617782f589a6773e7fb..5c65610667d5066d44189083ccbc770e95c61a55 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/insert_range.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/insert_range.cc
@@ -35,16 +35,22 @@ do_test()
   VERIFY( eq(v, a) );
   v.clear();
   v.shrink_to_fit();
-  v.insert_range(v.begin(), Range(a, a+3));
-  v.insert_range(v.end(), Range(a+6, a+9));
-  v.insert_range(v.begin()+3, Range(a+3, a+6));
+  auto it = v.insert_range(v.begin(), Range(a, a+3));
+  VERIFY( it == v.begin() );
+  it = v.insert_range(v.end(), Range(a+6, a+9));
+  VERIFY( it == v.begin()+3 );
+  it = v.insert_range(v.begin()+3, Range(a+3, a+6));
+  VERIFY( it == v.begin()+3 );
   VERIFY( eq(v, a) );
   v.resize(3);
-  v.insert_range(v.begin()+1, Range(a+4, a+9));
-  v.insert_range(v.begin()+1, Range(a+1, a+4));
+  it = v.insert_range(v.begin()+1, Range(a+4, a+9));
+  VERIFY( it == v.begin()+1 );
+  it = v.insert_range(v.begin()+1, Range(a+1, a+4));
+  VERIFY( it == v.begin()+1 );
   v.resize(9);
   VERIFY( eq(v, a) );
-  v.insert_range(v.begin(), Range(a, a));
+  it = v.insert_range(v.begin(), Range(a, a));
+  VERIFY( it == v.begin() );
   VERIFY( eq(v, a) );
 }
 
diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/insert_range.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/insert_range.cc
index 68218e94f28b28060f37a24071eab226d24ad41d..5907143512676a8cd66596f1543a68a60a255ecc 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/insert_range.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/insert_range.cc
@@ -39,16 +39,22 @@ do_test()
   VERIFY( eq(v, a) );
   v.clear();
   v.shrink_to_fit();
-  v.insert_range(v.begin(), Range(a, a+3));
-  v.insert_range(v.end(), Range(a+6, a+9));
-  v.insert_range(v.begin()+3, Range(a+3, a+6));
+  auto it = v.insert_range(v.begin(), Range(a, a+3));
+  VERIFY( it == v.begin() );
+  it = v.insert_range(v.end(), Range(a+6, a+9));
+  VERIFY( it == v.begin()+3 );
+  it = v.insert_range(v.begin()+3, Range(a+3, a+6));
+  VERIFY( it == v.begin()+3 );
   VERIFY( eq(v, a) );
   v.resize(3);
-  v.insert_range(v.begin()+1, Range(a+4, a+9));
-  v.insert_range(v.begin()+1, Range(a+1, a+4));
+  it = v.insert_range(v.begin()+1, Range(a+4, a+9));
+  VERIFY( it == v.begin()+1 );
+  it = v.insert_range(v.begin()+1, Range(a+1, a+4));
+  VERIFY( it == v.begin()+1 );
   v.resize(9);
   VERIFY( eq(v, a) );
-  v.insert_range(v.begin() + 6, Range(a, a));
+  it = v.insert_range(v.begin() + 6, Range(a, a));
+  VERIFY( it == v.begin() + 6 );
   VERIFY( eq(v, a) );
 }
 
diff --git a/libstdc++-v3/testsuite/30_threads/latch/1.cc b/libstdc++-v3/testsuite/30_threads/latch/1.cc
index 20c40254c0e640ea01ff14affdd7c451353f0122..29984cbf354e77f427932e28bbc8e54a0cbacb07 100644
--- a/libstdc++-v3/testsuite/30_threads/latch/1.cc
+++ b/libstdc++-v3/testsuite/30_threads/latch/1.cc
@@ -22,6 +22,16 @@
 
 #ifndef __cpp_lib_latch
 # error "Feature-test macro for latch missing in <latch>"
-#elif __cpp_lib_latch!= 201907L
+#elif __cpp_lib_latch != 201907L
 # error "Feature-test macro for latch has wrong value in <latch>"
 #endif
+
+static_assert(std::latch::max() > 0);
+
+constinit std::latch l0(0);
+constinit std::latch l1(1);
+constinit std::latch l2(std::latch::max());
+
+#ifdef _GLIBCXX_RELEASE
+static_assert(alignof(std::latch) == std::__detail::__platform_wait_alignment);
+#endif
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc
index a5791b3da702a2b511091bdf7c1faf368f89409a..772e4b3b6a0d15d15eeca317b370d541e8e23cd2 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc
@@ -110,6 +110,7 @@ test04()
   };
   // P2494R2 Relaxing range adaptors to allow for move only types
   static_assert( requires { views::pairwise_transform(x, move_only{}); } );
+  static_assert( requires { x | views::pairwise_transform(move_only{}); } );
 }
 
 int
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc
index dfc91fb5e1fb0bd12b3fe9153623461fbe60bae4..934d2f65dcf0e15efff3f75504110135010c2555 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc
@@ -191,8 +191,10 @@ test09()
 #if __cpp_lib_ranges >= 202207L
   // P2494R2 Relaxing range adaptors to allow for move only types
   static_assert( requires { transform(x, move_only{}); } );
+  static_assert( requires { x | transform(move_only{}); } ); // PR libstdc++/118413
 #else
   static_assert( ! requires { transform(x, move_only{}); } );
+  static_assert( ! requires { x | transform(move_only{}); } );
 #endif
 }
 
diff --git a/libstdc++-v3/testsuite/util/testsuite_abi.cc b/libstdc++-v3/testsuite/util/testsuite_abi.cc
index dcf5b1a4e0b10a338865fd96eca71e37fe553b6d..1b4044c9518881bc9f42898b5c6acf60696fd84c 100644
--- a/libstdc++-v3/testsuite/util/testsuite_abi.cc
+++ b/libstdc++-v3/testsuite/util/testsuite_abi.cc
@@ -237,6 +237,9 @@ check_version(symbol& test, bool added)
       known_versions.push_back("CXXABI_1.3.13");
       known_versions.push_back("CXXABI_1.3.14");
       known_versions.push_back("CXXABI_1.3.15");
+#ifdef __riscv
+      known_versions.push_back("CXXABI_1.3.16");
+#endif
       known_versions.push_back("CXXABI_IEEE128_1.3.13");
       known_versions.push_back("CXXABI_TM_1");
       known_versions.push_back("CXXABI_FLOAT128");