On Wed, Oct 18, 2023 at 11:23:49AM +0100, Richard Sandiford wrote: > > --- a/gcc/cse.cc > > +++ b/gcc/cse.cc > > @@ -4951,8 +4951,14 @@ cse_insn (rtx_insn *insn) > > && is_a <scalar_int_mode> (mode, &int_mode) > > && (extend_op = load_extend_op (int_mode)) != UNKNOWN) > > { > > +#if GCC_VERSION >= 5000 > > struct rtx_def memory_extend_buf; > > rtx memory_extend_rtx = &memory_extend_buf; > > +#else > > + alignas (alignof (rtx_def)) unsigned char > > + memory_extended_buf[sizeof (rtx_def)]; > > Looks like the simpler "alignas (rtx_def)" should work.
It does. > LGTM otherwise FWIW. Here is what I'm bootstrapping/regtesting on gcc112 now (i.e. with 4.8.5 as system compiler), added details what bug we are working around. The reduced testcase on which I've bisected it is: struct poly_int { poly_int() = default; template <typename ...T> poly_int(const T &...) {} }; union rtunion { poly_int rt_subregrt_rtx; }; struct rtx_def { rtunion fld; }; void cse_insn() { rtx_def memory_extend_buf; } or even with just template <typename> poly_int(); line in there. Bet gcc 4.8/4.9 was unhappy about the template variadic ctor accepting empty pack and being like the default ctor but not defaulted in that case. Making it guaranteed that it has at least one argument say through template <typename U, typename ...T> poly_int(const U &, const T &...) {} fixes it for 4.8/4.9 as well. 2023-10-18 Jakub Jelinek <ja...@redhat.com> PR bootstrap/111852 * cse.cc (cse_insn): Add workaround for GCC 4.8-4.9, instead of using rtx_def type for memory_extend_buf, use unsigned char arrayy with size of rtx_def and its alignment. --- gcc/cse.cc.jj 2023-06-20 08:57:38.339505245 +0200 +++ gcc/cse.cc 2023-10-18 13:20:30.555836778 +0200 @@ -4951,8 +4951,15 @@ cse_insn (rtx_insn *insn) && is_a <scalar_int_mode> (mode, &int_mode) && (extend_op = load_extend_op (int_mode)) != UNKNOWN) { +#if GCC_VERSION >= 5000 struct rtx_def memory_extend_buf; rtx memory_extend_rtx = &memory_extend_buf; +#else + /* Workaround GCC < 5 bug, fixed in r5-3834 as part of PR63362 + fix. */ + alignas (rtx_def) unsigned char memory_extended_buf[sizeof (rtx_def)]; + rtx memory_extend_rtx = (rtx) &memory_extended_buf[0]; +#endif /* Set what we are trying to extend and the operation it might have been extended with. */ Jakub