https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116887
--- Comment #8 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to chenglulu from comment #7)
> I trimmed the test case and found that the error was caused by the following
> statement:
>
> ;; basic block 8, loop depth 1
> ;; pred: 7
> if (l_7 == &_rtld_globalD.3739._dl_rtld_mapD.3732)
> goto <bb 9>; [INV]
> else
> goto <bb 10>; [INV]
> ;; succ: 9
>
> The following patches can fix the problem, but I don't know the exact reason
> yet.
>
> diff --git a/gcc/config/loongarch/loongarch.cc
> b/gcc/config/loongarch/loongarch.cc
> index f956ee4b119..3438eafaedc 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -2529,7 +2529,7 @@ loongarch_const_insns (rtx x)
> {
> if (IMM12_INT (offset))
> return n + 1;
> - else if (!targetm.cannot_force_const_mem (GET_MODE (x), x))
> + else
> return n + 1 + loongarch_integer_cost (INTVAL (offset));
> }
> }
It seems like a previous attempt to fix PR 52999: r186919. But it was then
reverted and changed to TARGET_SECTION_TYPE_FLAGS in r188031.
So which is better? Maybe we'll need to dig some history from the mail list...