[llvm] [WIP][Don't merge] New test for untested SPIRVInstructionSelector case (PR #186069)

via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 12 02:58:38 PDT 2026


https://github.com/ambergorzynski created https://github.com/llvm/llvm-project/pull/186069

[This line](https://github.com/ambergorzynski/llvm-project/blob/main/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp#L2454) is untested by the existing test suite (checked using coverage and inserting an `abort` at that line).

We propose a new test for the untested logical `eq` case, similarly to the `neq` case added [here](https://github.com/llvm/llvm-project/commit/e45c8b6555c866cd0412b42fce0439e927ca3ba2).

>From 00d9d883de870a354ef9da6e78a0a49b2370b338 Mon Sep 17 00:00:00 2001
From: agorzyns <amber.gorzynski at amd.com>
Date: Thu, 12 Mar 2026 03:50:20 -0500
Subject: [PATCH 1/2] [NFC][SPIRV] Add abort to demonstrate test

---
 llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
index 3e50e4a0e8c80..1d3ecbee08e48 100644
--- a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
@@ -2450,8 +2450,10 @@ static unsigned getPtrCmpOpcode(unsigned Pred) {
 static unsigned getBoolCmpOpcode(unsigned PredNum) {
   auto Pred = static_cast<CmpInst::Predicate>(PredNum);
   switch (Pred) {
-  case CmpInst::ICMP_EQ:
+  case CmpInst::ICMP_EQ: {
+    abort();
     return SPIRV::OpLogicalEqual;
+  }
   case CmpInst::ICMP_NE:
     return SPIRV::OpLogicalNotEqual;
   default:

>From 124097c941b9a729fae85bf3167de413d6350516 Mon Sep 17 00:00:00 2001
From: agorzyns <amber.gorzynski at amd.com>
Date: Thu, 12 Mar 2026 03:51:08 -0500
Subject: [PATCH 2/2] [NFC][SPIRV] Add test for untested
 SPIRVInstructionSelector LogicalEq case

---
 llvm/test/CodeGen/SPIRV/instructions/icmp.ll | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/llvm/test/CodeGen/SPIRV/instructions/icmp.ll b/llvm/test/CodeGen/SPIRV/instructions/icmp.ll
index 0d8778af9e5b0..13e4fd2d3d5f2 100644
--- a/llvm/test/CodeGen/SPIRV/instructions/icmp.ll
+++ b/llvm/test/CodeGen/SPIRV/instructions/icmp.ll
@@ -23,6 +23,7 @@
 ; CHECK-DAG: OpName [[v3UGE:%.*]] "test_v3_uge"
 ; CHECK-DAG: OpName [[v3SGE:%.*]] "test_v3_sge"
 ; CHECK-DAG: OpName [[v16NE:%.*]] "test_v16_ne"
+; CHECK-DAG: OpName [[v16EQ:%.*]] "test_v16_eq"
 
 ; CHECK:      [[EQ]] = OpFunction
 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter
@@ -274,3 +275,14 @@ define spir_func <16 x i1> @test_v16_ne() {
   %A = icmp ne <16 x i1> zeroinitializer, zeroinitializer
   ret <16 x i1> %A
 }
+
+; CHECK:      [[v16EQ]] = OpFunction
+; CHECK-NEXT: OpLabel
+; CHECK-NEXT: [[R:%.*]] = OpLogicalEqual {{%.+}} {{%.*}} {{%.*}}
+; CHECK-NEXT: OpReturnValue [[R]]
+; CHECK-NEXT: OpFunctionEnd
+define spir_func <16 x i1> @test_v16_eq() {
+entry:
+  %A = icmp eq <16 x i1> zeroinitializer, zeroinitializer
+  ret <16 x i1> %A
+}



More information about the llvm-commits mailing list