Bug 278908 - Upcoming 14.1-RELEASE LLVM -> Worse runtime performance on Zen CPU when optimizing for Zen
Summary: Upcoming 14.1-RELEASE LLVM -> Worse runtime performance on Zen CPU when optim...
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 15.0-CURRENT
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-toolchain (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-11 10:11 UTC by nix23
Modified: 2024-06-15 09:12 UTC (History)
2 users (show)

See Also:
dim: mfc-stable14+
dim: mfc-stable13+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nix23 2024-05-11 10:11:14 UTC
Do we have that fix in llvm for the upcoming release of 14.1?

https://github.com/llvm/llvm-project/issues/90985

https://www.phoronix.com/news/LLVM-Slower-With-AMD-Opts
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2024-05-13 15:11:17 UTC
We're already at 14.1-BETA2, and since this does not appear to be a regression, I would guess it is too late to get in.
Comment 2 nix23 2024-05-15 09:12:05 UTC
(In reply to Dimitry Andric from comment #1)

Thanks for the reply, i will then close the ticket,

Have a nice Day
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-05-25 20:18:42 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=cadd2ca21765ebcb95b77ec94977b4e74e1edc1b

commit cadd2ca21765ebcb95b77ec94977b4e74e1edc1b
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-05-25 17:52:15 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-05-25 19:12:29 +0000

    Merge commit d0be944aa511 from llvm-project (by Simon Pilgrim):

      [X86] Add slow div64 tuning flag to Nehalem target (#91129)

      This appears to have been missed because later cpus don't inherit from Nehalem tuning much.

      Noticed while cleaning up for #90985

    Merge commit 8b400de79eff from llvm-project (by Simon Pilgrim):

      [X86] Enable TuningSlowDivide64 on Barcelona/Bobcat/Bulldozer/Ryzen Families (#91277)

      Despite most AMD cpus having a lower latency for i64 divisions that converge early, we are still better off testing for values representable as i32 and performing a i32 division if possible.

      All AMD cpus appear to have been missed when we added the "idivq-to-divl" attribute - this patch now matches Intel cpu behaviour (and the x86-64/v2/3/4 levels).

      Unfortunately the difference in code scheduling means I've had to stop using the update_llc_test_checks script and just use old-fashioned CHECK-DAG checks for divl/divq pairs.

      Fixes #90985

    This fixes possibly worse runtime performance on AMD Zen hardware, when
    using -march=znver4 (or any other znver), as opposed to -march=x86-64-v4
    or the baseline -march=x86-64. A similar fix is applied for Nehalem.

    PR:             278908
    MFC after:      3 days

 contrib/llvm-project/llvm/lib/Target/X86/X86.td | 6 ++++++
 1 file changed, 6 insertions(+)
Comment 4 Dimitry Andric freebsd_committer freebsd_triage 2024-05-25 20:19:39 UTC
Reopening to track MFCs.
Comment 5 commit-hook freebsd_committer freebsd_triage 2024-05-28 05:28:15 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=ec38746722a15b4376bed274e96ff7b8c31804e1

commit ec38746722a15b4376bed274e96ff7b8c31804e1
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-05-25 17:52:15 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-05-28 05:25:49 +0000

    Merge commit d0be944aa511 from llvm-project (by Simon Pilgrim):

      [X86] Add slow div64 tuning flag to Nehalem target (#91129)

      This appears to have been missed because later cpus don't inherit from Nehalem tuning much.

      Noticed while cleaning up for #90985

    Merge commit 8b400de79eff from llvm-project (by Simon Pilgrim):

      [X86] Enable TuningSlowDivide64 on Barcelona/Bobcat/Bulldozer/Ryzen Families (#91277)

      Despite most AMD cpus having a lower latency for i64 divisions that converge early, we are still better off testing for values representable as i32 and performing a i32 division if possible.

      All AMD cpus appear to have been missed when we added the "idivq-to-divl" attribute - this patch now matches Intel cpu behaviour (and the x86-64/v2/3/4 levels).

      Unfortunately the difference in code scheduling means I've had to stop using the update_llc_test_checks script and just use old-fashioned CHECK-DAG checks for divl/divq pairs.

      Fixes #90985

    This fixes possibly worse runtime performance on AMD Zen hardware, when
    using -march=znver4 (or any other znver), as opposed to -march=x86-64-v4
    or the baseline -march=x86-64. A similar fix is applied for Nehalem.

    PR:             278908
    MFC after:      3 days

    (cherry picked from commit cadd2ca21765ebcb95b77ec94977b4e74e1edc1b)

 contrib/llvm-project/llvm/lib/Target/X86/X86.td | 6 ++++++
 1 file changed, 6 insertions(+)
Comment 6 commit-hook freebsd_committer freebsd_triage 2024-05-28 05:29:20 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a3e6eda7981319113d39caedf79b94b44773970f

commit a3e6eda7981319113d39caedf79b94b44773970f
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-05-25 17:52:15 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-05-28 05:26:46 +0000

    Merge commit d0be944aa511 from llvm-project (by Simon Pilgrim):

      [X86] Add slow div64 tuning flag to Nehalem target (#91129)

      This appears to have been missed because later cpus don't inherit from Nehalem tuning much.

      Noticed while cleaning up for #90985

    Merge commit 8b400de79eff from llvm-project (by Simon Pilgrim):

      [X86] Enable TuningSlowDivide64 on Barcelona/Bobcat/Bulldozer/Ryzen Families (#91277)

      Despite most AMD cpus having a lower latency for i64 divisions that converge early, we are still better off testing for values representable as i32 and performing a i32 division if possible.

      All AMD cpus appear to have been missed when we added the "idivq-to-divl" attribute - this patch now matches Intel cpu behaviour (and the x86-64/v2/3/4 levels).

      Unfortunately the difference in code scheduling means I've had to stop using the update_llc_test_checks script and just use old-fashioned CHECK-DAG checks for divl/divq pairs.

      Fixes #90985

    This fixes possibly worse runtime performance on AMD Zen hardware, when
    using -march=znver4 (or any other znver), as opposed to -march=x86-64-v4
    or the baseline -march=x86-64. A similar fix is applied for Nehalem.

    PR:             278908
    MFC after:      3 days

    (cherry picked from commit cadd2ca21765ebcb95b77ec94977b4e74e1edc1b)

 contrib/llvm-project/llvm/lib/Target/X86/X86.td | 6 ++++++
 1 file changed, 6 insertions(+)
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-05-28 12:04:25 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c56fde6514ee21ccb186267c304ad444463f661c

commit c56fde6514ee21ccb186267c304ad444463f661c
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2024-05-28 11:47:37 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2024-05-28 11:56:43 +0000

    devel/llvm18: misc improvements

    Fix worse runtime performance on Zen CPU when optimizing for Zen. [0]

    Install all standard heaaders with clang.  Historically we've been
    unable to build FreeBSD with the full set due to conflicts and/or
    missing features between the compiler provided headers and
    FreeBSD's headers.  I've verified that I can build world and kernel on
    the main, stable/14, and stable/13 branches for amd64 so let's give it
    another try in broader testing. [1]

    PR:             278908 [0], 274542 [1]

 devel/llvm18/Makefile                              |  2 +-
 .../patch-clang_lib_Headers_CMakeLists.txt (gone)  | 37 ----------
 .../llvm18/files/patch-freebsd-cadd2ca21765 (new)  | 83 ++++++++++++++++++++++
 devel/llvm18/pkg-plist                             | 25 +++++++
 4 files changed, 109 insertions(+), 38 deletions(-)
Comment 8 Dimitry Andric freebsd_committer freebsd_triage 2024-05-30 16:56:09 UTC
The fixes have been MFC'd now, but we're waiting on re@ to approve merging them to releng/14.1, to make sure it ends up in 14.1-RELEASE. Keeping this bug open until that is done.