From d05c3811cd17dc29421c497a3132ebcb64596f52 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 13 Dec 2022 11:03:21 -0500 Subject: [PATCH] ac/llvm: run the LLVM sinking pass because LLVM will stop running it shader-db was run with the sinking pass disabled in LLVM. 58380 shaders in 35438 tests Totals: SGPRS: 2730768 -> 2730768 (0.00 %) VGPRS: 1592932 -> 1592928 (-0.00 %) Spilled SGPRs: 2687 -> 2687 (0.00 %) Spilled VGPRs: 551 -> 551 (0.00 %) Private memory VGPRs: 253 -> 253 (0.00 %) Scratch size: 700 -> 700 (0.00 %) dwords per thread Code Size: 61238872 -> 61238868 (-0.00 %) bytes Max Waves: 849209 -> 849209 (0.00 %) Outputs: 127090 -> 127090 (0.00 %) Patch Outputs: 579 -> 579 (0.00 %) Totals from affected shaders: SGPRS: 440 -> 440 (0.00 %) VGPRS: 396 -> 392 (-1.01 %) Spilled SGPRs: 0 -> 0 (0.00 %) Spilled VGPRs: 0 -> 0 (0.00 %) Private memory VGPRs: 0 -> 0 (0.00 %) Scratch size: 0 -> 0 (0.00 %) dwords per thread Code Size: 49880 -> 49876 (-0.01 %) bytes Max Waves: 105 -> 105 (0.00 %) Outputs: 14 -> 14 (0.00 %) Patch Outputs: 0 -> 0 (0.00 %) Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/amd/llvm/ac_llvm_build.h | 2 ++ src/amd/llvm/ac_llvm_helper.cpp | 8 ++++++++ src/amd/llvm/ac_llvm_util.c | 2 ++ 3 files changed, 12 insertions(+) diff --git a/src/amd/llvm/ac_llvm_build.h b/src/amd/llvm/ac_llvm_build.h index 76f5502..9b8c595 100644 --- a/src/amd/llvm/ac_llvm_build.h +++ b/src/amd/llvm/ac_llvm_build.h @@ -580,6 +580,8 @@ LLVMValueRef ac_build_atomic_rmw(struct ac_llvm_context *ctx, LLVMAtomicRMWBinOp LLVMValueRef ac_build_atomic_cmp_xchg(struct ac_llvm_context *ctx, LLVMValueRef ptr, LLVMValueRef cmp, LLVMValueRef val, const char *sync_scope); +void ac_add_sinking_pass(LLVMPassManagerRef PM); + void ac_export_mrt_z(struct ac_llvm_context *ctx, LLVMValueRef depth, LLVMValueRef stencil, LLVMValueRef samplemask, LLVMValueRef mrt0_alpha, bool is_last, struct ac_export_args *args); diff --git a/src/amd/llvm/ac_llvm_helper.cpp b/src/amd/llvm/ac_llvm_helper.cpp index 71ed11a..66fdef8 100644 --- a/src/amd/llvm/ac_llvm_helper.cpp +++ b/src/amd/llvm/ac_llvm_helper.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -45,6 +46,8 @@ #include "ac_llvm_build.h" #include "util/macros.h" +using namespace llvm; + bool ac_is_llvm_processor_supported(LLVMTargetMachineRef tm, const char *processor) { llvm::TargetMachine *TM = reinterpret_cast(tm); @@ -326,3 +329,8 @@ LLVMValueRef ac_build_atomic_cmp_xchg(struct ac_llvm_context *ctx, LLVMValueRef llvm::AtomicOrdering::SequentiallyConsistent, llvm::AtomicOrdering::SequentiallyConsistent, SSID)); } + +void ac_add_sinking_pass(LLVMPassManagerRef PM) +{ + unwrap(PM)->add(createLoopSinkPass()); +} diff --git a/src/amd/llvm/ac_llvm_util.c b/src/amd/llvm/ac_llvm_util.c index ff936af..832e908 100644 --- a/src/amd/llvm/ac_llvm_util.c +++ b/src/amd/llvm/ac_llvm_util.c @@ -239,6 +239,8 @@ static LLVMPassManagerRef ac_create_passmgr(LLVMTargetLibraryInfoRef target_libr /* This pass should eliminate all the load and store instructions. */ LLVMAddPromoteMemoryToRegisterPass(passmgr); LLVMAddScalarReplAggregatesPass(passmgr); + if (LLVM_VERSION_MAJOR >= 16) + ac_add_sinking_pass(passmgr); LLVMAddLICMPass(passmgr); LLVMAddAggressiveDCEPass(passmgr); LLVMAddCFGSimplificationPass(passmgr); -- 2.7.4