[llvm] [SelectionDAG] Mark LowerTypeTests as required and remove intrinsic handling from #142939 (PR #179249)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 2 07:04:33 PST 2026


https://github.com/keremsahn created https://github.com/llvm/llvm-project/pull/179249

Fixes #179125 

Tests: 
      ThinLTO pipeline --  Running pass: LowerTypeTestsPass on [module]
      LTO pipeline -- Running pass: LowerTypeTestsPass on [module]
                                 Running pass: LowerTypeTestsPass on [module]
      Codegen Regression --    Total Discovered Tests: 5373
                                                     Unsupported      :   78 (1.45%)
                                                        Passed           : 5283 (98.32%)
                                                      Expectedly Failed:   12 (0.22%)
                                                      
This is my first contribution to an OSS, please inform me about what i could do better or what i did wrong

>From 937b75f5fc11fcf6bc1a2f5484d18b0b6001e05d Mon Sep 17 00:00:00 2001
From: keremsahn <keremsahin401 at gmail.com>
Date: Mon, 2 Feb 2026 17:36:24 +0300
Subject: [PATCH] [SelectionDAG] Mark LowerTypeTests as required and remove
 intrinsic handling. Marked LowerTypeTestsPass as required to prevent it from
 being skipped by pass bisection. Intrinsic from #142939 that handling
 llvm.type.test is removed. Updated pr142937.ll to remove the unhandled
 public_type_test case, keeping only the type_test case which is handled by
 LowerTypeTestsPass.

---
 .../llvm/Transforms/IPO/LowerTypeTests.h      |  1 +
 .../SelectionDAG/SelectionDAGBuilder.cpp      |  5 --
 llvm/test/CodeGen/X86/pr142937.ll             | 51 ++++++-------------
 3 files changed, 17 insertions(+), 40 deletions(-)

diff --git a/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h b/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
index a34cbaf72675b..bb8b40955077e 100644
--- a/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
+++ b/llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
@@ -218,6 +218,7 @@ class LowerTypeTestsPass : public PassInfoMixin<LowerTypeTestsPass> {
                          lowertypetests::DropTestKind::None)
       : ExportSummary(ExportSummary), ImportSummary(ImportSummary),
         DropTypeTests(DropTypeTests) {}
+  static bool isRequired() { return true; }
   LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
 
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 52e0d8fefdf2f..49f5494ed894c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -7522,11 +7522,6 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
     setValue(&I, getValue(I.getOperand(0)));
     return;
 
-  case Intrinsic::type_test:
-  case Intrinsic::public_type_test:
-    setValue(&I, getValue(ConstantInt::getTrue(I.getType())));
-    return;
-
   case Intrinsic::assume:
   case Intrinsic::experimental_noalias_scope_decl:
   case Intrinsic::var_annotation:
diff --git a/llvm/test/CodeGen/X86/pr142937.ll b/llvm/test/CodeGen/X86/pr142937.ll
index 8be99e102ff5b..650093d65a25e 100644
--- a/llvm/test/CodeGen/X86/pr142937.ll
+++ b/llvm/test/CodeGen/X86/pr142937.ll
@@ -1,47 +1,32 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
-; RUN: llc < %s -mtriple=i686-- -O0   | FileCheck %s --check-prefix=X86
-; RUN: llc < %s -mtriple=x86_64-- -O0 | FileCheck %s --check-prefix=X64
-
-define void @public_type_test() {
-; X86-LABEL: public_type_test:
-; X86:       # %bb.0: # %bb
-; X86-NEXT:    movb $1, %al
-; X86-NEXT:  # %bb.1: # %bb1
-; X86-NEXT:    retl
-;
-; X64-LABEL: public_type_test:
-; X64:       # %bb.0: # %bb
-; X64-NEXT:    movb $1, %al
-; X64-NEXT:  # %bb.1: # %bb1
-; X64-NEXT:    retq
-bb:
-  %call = call i1 @llvm.public.type.test(ptr null, metadata !"typeinfo")
-  br label %bb1
-
-bb1:
-  call void @llvm.assume(i1 %call)
-  ret void
-}
+; RUN: opt -passes='lowertypetests' -S %s \
+; RUN:   | llc -mtriple=i686--   -O0 | FileCheck %s --check-prefix=X86
+; RUN: opt -passes='lowertypetests' -S %s \
+; RUN:   | llc -mtriple=x86_64-- -O0 | FileCheck %s --check-prefix=X64
 
 define void @type_test() {
 ; X86-LABEL: type_test:
 ; X86:       # %bb.0: # %bb
-; X86-NEXT:    movb $1, %al
+; X86-NEXT:    xorl %eax, %eax
+; X86-NEXT:    # kill: def $al killed $al killed $eax
 ; X86-NEXT:    testb $1, %al
-; X86-NEXT:    jne .LBB1_2
-; X86-NEXT:  # %bb.1: # %bb1
+; X86-NEXT:    jne .LBB0_2
+; X86-NEXT:    jmp .LBB0_1
+; X86-NEXT:  .LBB0_1: # %bb1
 ; X86-NEXT:    ud1l 2(%eax), %eax
-; X86-NEXT:  .LBB1_2: # %bb2
+; X86-NEXT:  .LBB0_2: # %bb2
 ; X86-NEXT:    retl
 ;
 ; X64-LABEL: type_test:
 ; X64:       # %bb.0: # %bb
-; X64-NEXT:    movb $1, %al
+; X64-NEXT:    xorl %eax, %eax
+; X64-NEXT:    # kill: def $al killed $al killed $eax
 ; X64-NEXT:    testb $1, %al
-; X64-NEXT:    jne .LBB1_2
-; X64-NEXT:  # %bb.1: # %bb1
+; X64-NEXT:    jne .LBB0_2
+; X64-NEXT:    jmp .LBB0_1
+; X64-NEXT:  .LBB0_1: # %bb1
 ; X64-NEXT:    ud1l 2(%eax), %eax
-; X64-NEXT:  .LBB1_2: # %bb2
+; X64-NEXT:  .LBB0_2: # %bb2
 ; X64-NEXT:    retq
 bb:
   %call = tail call i1 @llvm.type.test(ptr null, metadata !"typeinfo")
@@ -55,10 +40,6 @@ bb2:
   ret void
 }
 
-declare i1 @llvm.public.type.test(ptr, metadata)
-
-declare void @llvm.assume(i1 noundef)
-
 declare i1 @llvm.type.test(ptr, metadata)
 
 declare void @llvm.ubsantrap(i8 immarg)



More information about the llvm-commits mailing list