https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118843
--- Comment #3 from chenglulu <chenglulu at loongson dot cn> ---
(In reply to Xi Ruoyao from comment #2)
> We have
>
> if (TARGET_HARD_FLOAT && ISA_HAS_FRECIPE)
> builtin_define ("__loongarch_frecipe");
>
> where the logic seems correct. But __loongarch_frecipe is also in
> la_evo_macro_name and it can get defined by:
>
> for (int i = 0; i < N_EVO_FEATURES; i++)
> if (la_target.isa.evolution & la_evo_feature_masks[i])
> {
> builtin_define (la_evo_macro_name[i]);
>
> ... ...
>
> Maybe we can just do
>
> if (!TARGET_HARD_FLOAT)
> cpp_undef ("__loongarch_frecipe");
>
> after the loop above (and remove the useless if block on the top).
I tried to make some changes, and the test went smoothly without any issues.
for (int i = 0; i < N_EVO_FEATURES; i++)
{
builtin_undef (la_evo_macro_name[i]);
if (la_target.isa.evolution & la_evo_feature_masks[i]
&& (la_evo_feature_masks[i] ^ OPTION_MASK_ISA_FRECIPE
|| TARGET_HARD_FLOAT))
{
builtin_define (la_evo_macro_name[i]);
int major = la_evo_version_major[i],
minor = la_evo_version_minor[i];
max_v_major = major > max_v_major ? major : max_v_major;
max_v_minor = major == max_v_major
? (minor > max_v_minor ? minor : max_v_minor) : max_v_minor;
}
}