public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/113233] New: LoongArch: target options from LTO objects not respected during linking
@ 2024-01-04 13:02 yangyujie at loongson dot cn
  2024-01-04 13:06 ` [Bug target/113233] " yangyujie at loongson dot cn
                   ` (15 more replies)
  0 siblings, 16 replies; 18+ messages in thread
From: yangyujie at loongson dot cn @ 2024-01-04 13:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113233

            Bug ID: 113233
           Summary: LoongArch: target options from LTO objects not
                    respected during linking
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yangyujie at loongson dot cn
  Target Milestone: ---

Compiling LTO objects with certain target options like -march=, -msimd= have no
effect on the final linked binary, since COLLECT_GCC_OPTIONS from the "linker
GCC" driver always overrides these options.

For instance, running the following command:

$ gcc -S -o- -xc - -msimd=lasx  -O3 <<< "void m2 (float *a, int n) { for (int i
= 0; i < n; i++) a[i] += 1; }" | grep vfadd

outputs SIMD instructions (as enabled by -msimd=lasx):

        xvfadd.s        $xr4,$xr4,$xr0
        xvfadd.s        $xr2,$xr2,$xr0
        xvfadd.s        $xr1,$xr1,$xr0
        xvfadd.s        $xr3,$xr3,$xr0
        vfadd.s $vr1,$vr1,$vr0
        vfadd.s $vr1,$vr1,$vr0
        vfadd.s $vr1,$vr1,$vr0
        vfadd.s $vr1,$vr1,$vr0
        vfadd.s $vr1,$vr1,$vr0
        vfadd.s $vr1,$vr1,$vr0
        vfadd.s $vr0,$vr1,$vr0

However, LTO generates code according to the compiler's default config
(-msimd=none).

Running:
$ gcc -flto -c -o test.o -xc - -msimd=lasx -O3 <<< "void m2 (float *a, int n) {
for (int i = 0; i < n; i++) a[i] += 1; }"

and then:
$ gcc -S -o- -xlto test.o | grep vfadd

outputs nothing, indicating that the final code generation have LSX/LASX
disabled.

While:
$ gcc -S -o- -xlto test.o -mlasx | grep vfadd

outputs the same "vfadd" / "xvfadd" instructions as above.

-------------------------------------------------------------------------------------
Proposed solution: implement option save/restore to enable LTO option
streaming.
-------------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-04-10  4:06 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-04 13:02 [Bug target/113233] New: LoongArch: target options from LTO objects not respected during linking yangyujie at loongson dot cn
2024-01-04 13:06 ` [Bug target/113233] " yangyujie at loongson dot cn
2024-01-04 13:31 ` xry111 at gcc dot gnu.org
2024-01-04 13:49   ` Jan Hubicka
2024-01-04 13:49 ` hubicka at ucw dot cz
2024-01-04 13:51 ` xry111 at gcc dot gnu.org
2024-01-04 13:52 ` xry111 at gcc dot gnu.org
2024-01-05  1:31 ` yangyujie at loongson dot cn
2024-01-11 11:04 ` cvs-commit at gcc dot gnu.org
2024-04-01  3:21 ` cvs-commit at gcc dot gnu.org
2024-04-01  3:23 ` cvs-commit at gcc dot gnu.org
2024-04-01  3:30 ` xry111 at gcc dot gnu.org
2024-04-07  8:37 ` xry111 at gcc dot gnu.org
2024-04-07  8:37 ` xry111 at gcc dot gnu.org
2024-04-09  9:03 ` cvs-commit at gcc dot gnu.org
2024-04-09 10:13 ` xry111 at gcc dot gnu.org
2024-04-10  2:09 ` yangyujie at loongson dot cn
2024-04-10  4:06 ` xry111 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).