diff --git a/IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp b/IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp index 6bb16a3c805b..ecc7a499647c 100644 --- a/IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp +++ b/IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp @@ -949,8 +949,7 @@ static void addKernelAttrsFromMetadata(VISAKernel &Kernel, Kernel.AddKernelAttribute("NBarrierCnt", sizeof(BarrierCnt), &BarrierCnt); } - // Default number of registers. - unsigned NumGRF = 128; + int NumGRF = -1; // Set by compile option. if (BC->isAutoLargeGRFMode()) NumGRF = 0; @@ -962,7 +961,9 @@ static void addKernelAttrsFromMetadata(VISAKernel &Kernel, if (NumGRFPerKernel == 0 || Subtarget->isValidGRFSize(NumGRFPerKernel)) NumGRF = NumGRFPerKernel; } - Kernel.AddKernelAttribute("NumGRF", sizeof(NumGRF), &NumGRF); + + if (NumGRF != -1) + Kernel.AddKernelAttribute("NumGRF", sizeof(NumGRF), &NumGRF); } // Legalize name for using as filename or in visa asm diff --git a/IGC/VectorCompiler/test/CisaBuilder/grf_size.ll b/IGC/VectorCompiler/test/CisaBuilder/grf_size.ll index db60f905e8a7..a06e37d04a01 100644 --- a/IGC/VectorCompiler/test/CisaBuilder/grf_size.ll +++ b/IGC/VectorCompiler/test/CisaBuilder/grf_size.ll @@ -27,12 +27,12 @@ define dllexport spir_kernel void @test_auto(i32 %arg) #0 { ret void } -; CHECK: .kernel_attr NumGRF=128 +; CHECK-NOT: .kernel_attr NumGRF define dllexport spir_kernel void @test_default(i32 %arg) #0 { ret void } -; CHECK: .kernel_attr NumGRF=128 +; CHECK-NOT: .kernel_attr NumGRF define dllexport spir_kernel void @test_invalid(i32 %arg) #0 { ret void }