This is an archive of the discontinued LLVM Phabricator instance.

MIPS: add build time option to disable madd.fmt
AbandonedPublic

Authored by wzssyqa on Jul 14 2020, 8:16 AM.

Details

Reviewers
atanasyan
Summary

MIPS: add build time option to disable madd.fmt

Some of MIPS CPU has a buggy madd.fmt/msub.fmt insns, Loongson is
an example.

To support all CPUs for a binary Linux distribution - like Debian,
the only choice is to disable madd.fmt/msub.fmt.

So here we add a build time option -DLLVM_DISABLE_MIPS_MADD4.
It does the same thing as the gcc build time option: --with(out)-madd4.

If llvm is built with this option, users can still enable/disable
madd.fmt/msub.fmt by runtime option -mmadd4/-mno-madd4.

Diff Detail

Event Timeline

wzssyqa created this revision.Jul 14 2020, 8:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2020, 8:16 AM
wzssyqa updated this revision to Diff 277854.Jul 14 2020, 8:59 AM
wzssyqa updated this revision to Diff 277857.Jul 14 2020, 9:03 AM

No need to block list r6 since the maddf.fmt has 3 reg operand.

Maybe it's better to switch off generation of the madd.fmt by default if the problem is so wide spread? I'm concerned that AFAIK no one other architectures supported by LLVM has configuration options like the proposed LLVM_DISABLE_MIPS_MADD4.

Maybe it's better to switch off generation of the madd.fmt by default if the problem is so wide spread? I'm concerned that AFAIK no one other architectures supported by LLVM has configuration options like the proposed LLVM_DISABLE_MIPS_MADD4.

currently Loongson is the only known CPU has this problem.
I don't know whether changing the default behavior is a good idea.

I think that we should have a talk with people about: whether and how llvm add some arch-specfied buildtime options.

MaskRay added inline comments.
llvm/lib/Target/Mips/MipsSubtarget.cpp
268

+nomadd4 & -nomadd4 below is fine. However, DisableMadd4 = true; is ok.
Can the disabling done in lib/Driver when the problematic CPUs are detected?

wzssyqa marked 3 inline comments as done.Jul 21 2020, 4:14 AM

For source distributions, like gentoo, it is OK. while for binary distributions like Debian, Fedora, we need to distribute the single binary object to user.

Except the program itself can do auto detect and dispatch different code, we have no way to assume it.
So, the only choice for binary distribution is to disable these insns fully.

wzssyqa abandoned this revision.Aug 15 2023, 12:56 AM

The downstream distribution can disable it by patch.

Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2023, 12:56 AM