[llvm] [SelectionDAG][X86] Handle `llvm.type.test` in DAGBuilder (PR #142939)

Evgenii Kudriashov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 5 03:47:50 PDT 2025


================
@@ -7384,6 +7384,22 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
     setValue(&I, getValue(I.getOperand(0)));
     return;
 
+  case Intrinsic::type_test:
+  case Intrinsic::public_type_test: {
+    bool AllUsersAreAssume = llvm::all_of(I.users(), [](const User *U) {
+      if (const auto *call = dyn_cast<CallInst>(U)) {
+        return call->getIntrinsicID() == Intrinsic::assume;
+      }
+      return false;
+    });
+
+    if (AllUsersAreAssume)
+      setValue(&I, DAG.getUNDEF(MVT::i1));
+    else
+      setValue(&I, DAG.getConstant(1, sdl, MVT::i1));
+    return;
+  }
----------------
e-kud wrote:

Why not to follow other check logic?
https://github.com/llvm/llvm-project/blob/736bd91c9c82219514c72ba2772948b99ac33330/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp#L7516-L7520

Because now we introduce indeterministic behavior. In both cases we don't follow the real semantic of the intrinsic because it should've been lowered. But at least we will have deterministic execution.

https://github.com/llvm/llvm-project/pull/142939


More information about the llvm-commits mailing list