[Pixman] [PATCH v2 2/3] build: use '-mloongson-mmi' for Loongson MMI.

Shiyou Yin yinshiyou-hf at loongson.cn
Sat Feb 22 13:26:53 UTC 2020

>-----Original Message-----
>From: Adam Jackson [mailto:ajax at redhat.com]
>Sent: Friday, February 21, 2020 11:33 PM
>To: Yin Shiyou; pixman at lists.freedesktop.org
>Subject: Re: [Pixman] [PATCH v2 2/3] build: use '-mloongson-mmi' for Loongson MMI.
>On Thu, 2020-02-20 at 22:23 +0800, Yin Shiyou wrote:
>> It's suggested to use '-mloongson-mmi' to enable MMI.
>> To keep compatible with old processor, '-mloongson-mmi' will be
>> setted for Loongson-3A only.
>The pattern we've used for other CPUs is to build support for as many
>ISA extensions as possible, unless they are explicitly disabled.
>Distributions tend to want to set their own minimum ISA levels, and if
>they wanted to assert -mloongson-mmi they would already have added it
>to CFLAGS globally.
>Do you have any performance data for this change?
>If setting -mloongson-mmi means the compiler can do useful
>autovectorization, then that's probably true for other arches too (eg
>amd64 vs avx2), and we should support this kind of thing more
>generically. But as it stands I don't think this patch is a good idea.
First, that's introduce the history of '-march=loongson2f' and '-mloongson-mmi'.
>From loongson2f start, mmi is supported by loongson processor.
Unfortunately, the compiler's support for MMI extention is not standardized.
Gcc compiler use '-march=loongson2f' for loongson2f at first, but from Loongson-3A,
opcode of mmi instruction has changed, and '-march=loongson3a' is in replaced.
>From last year, compile option for mmi instruction has been standardized.
Just like -mmsa for mips MSA. (MMI,LSX,LASX is Loongson SIMD extention.)
-mloongson-mmi   for MMI (-march=loongson3a still works, but -mloongson-mmi is recommended for new processors except Loongson2f. )
-mloongson-sx     for LSX
-mloongson-asx    for LASX

Second, back to this patch itself.
I meet a problem when compile pixman on my Loongson3a with gcc, MMI can't be enabled.
configure check failure: " linking mips:loongson_2f module with previous mips:gs464 modules"
It can be solved by assign LS_CFLAGS="-mloongson-mmi" while config.
So I submit this patch in hope that no need to assign LS_CFLAGS explicitly.
This won't have much impact on performance as I know.

Third, about the compatibility with Loongson2f.
This patch does not change the result of pixman compilation and running on loongson2f.
Before add this patch, LS_CFLAGS will be setted as '-march=loongson2f' by default,
After add this patch, LS_CFLAGS is still setted as '-march=loongson2f' if we compile on the old environment.
It only makes MMI can be enabled without assign LS_CFLAGS explicitly while compiling locally on loongson-3A.

More information about the Pixman mailing list