[llvm] abecf78 - [SPIR-V][NewPM] Do not require RegBankSelect in instruction selection (#225023)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 07:30:42 PDT 2026


Author: Arseniy Obolenskiy
Date: 2026-09-22T16:30:35+02:00
New Revision: abecf784ec30bce9d9163bd2e0d14c4a70094045

URL: https://github.com/llvm/llvm-project/commit/abecf784ec30bce9d9163bd2e0d14c4a70094045
DIFF: https://github.com/llvm/llvm-project/commit/abecf784ec30bce9d9163bd2e0d14c4a70094045.diff

LOG: [SPIR-V][NewPM] Do not require RegBankSelect in instruction selection (#225023)

SPIR-V skips RegBankSelect and keeps virtual registers, so the property
is never set

Match the legacy pipeline

Added: 
    

Modified: 
    llvm/lib/Target/SPIRV/SPIRVCodeGenPassBuilder.cpp
    llvm/test/CodeGen/SPIRV/llc-pipeline.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/SPIRV/SPIRVCodeGenPassBuilder.cpp b/llvm/lib/Target/SPIRV/SPIRVCodeGenPassBuilder.cpp
index 34c8060e97de5..4feb8ee2a4699 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCodeGenPassBuilder.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCodeGenPassBuilder.cpp
@@ -173,7 +173,9 @@ Error SPIRVCodeGenPassBuilder::addRegBankSelect(PassManagerWrapper &PMW) {
 
 Error SPIRVCodeGenPassBuilder::addGlobalInstructionSelect(
     PassManagerWrapper &PMW) {
-  addMachineFunctionPass(InstructionSelectPass(getOptLevel()), PMW);
+  addMachineFunctionPass(
+      InstructionSelectPass(getOptLevel(), /*RequireRegBankSelection=*/false),
+      PMW);
   return Error::success();
 }
 

diff  --git a/llvm/test/CodeGen/SPIRV/llc-pipeline.ll b/llvm/test/CodeGen/SPIRV/llc-pipeline.ll
index 7b85311ef5bda..406641b2aa753 100644
--- a/llvm/test/CodeGen/SPIRV/llc-pipeline.ll
+++ b/llvm/test/CodeGen/SPIRV/llc-pipeline.ll
@@ -7,6 +7,10 @@
 ; RUN:   | FileCheck -match-full-lines -strict-whitespace -check-prefix=SPIRV-Opt %s
 ; RUN:llc -O3 -mtriple=spirv-- -disable-verify -debug-pass=Structure < %s 2>&1 \
 ; RUN:   | FileCheck -match-full-lines -strict-whitespace -check-prefix=SPIRV-Opt %s
+; RUN:llc -O0 -mtriple=spirv-- -enable-new-pm -stop-before=spirv-asm-printer < %s \
+; RUN:   | FileCheck -check-prefix=SPIRV-NPM %s
+; RUN:llc -O3 -mtriple=spirv-- -enable-new-pm -stop-before=spirv-asm-printer < %s \
+; RUN:   | FileCheck -check-prefix=SPIRV-NPM %s
 ; REQUIRES:asserts
 
 ; SPIRV-O0:Target Library Information
@@ -226,6 +230,14 @@
 ; SPIRV-Opt-NEXT:      SPIRV Assembly Printer
 ; SPIRV-Opt-NEXT:      Free MachineFunction
 
+; SPIR-V NewPM skips RegBankSelect, so instruction selection must not require it.
+; SPIRV-NPM:legalized:       true
+; SPIRV-NPM-NEXT:regBankSelected: false
+; SPIRV-NPM-NEXT:selected:        true
+; SPIRV-NPM:%[[#VOID:]]:type = OpTypeVoid
+; SPIRV-NPM:%[[#]]:iid = OpFunction %[[#VOID]], 0, %[[#]]
+; SPIRV-NPM:OpReturn
+
 define void @empty() {
   ret void
 }


        


More information about the llvm-commits mailing list