From c75945146eecf1e1471bac966df28aa121bb5e84 Mon Sep 17 00:00:00 2001 From: listerily Date: Wed, 17 May 2023 14:16:08 +0800 Subject: [PATCH] [llvm] [ir] Fix: type cast for u1 should not truncate [ghstack-poisoned] --- taichi/codegen/llvm/codegen_llvm.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/taichi/codegen/llvm/codegen_llvm.cpp b/taichi/codegen/llvm/codegen_llvm.cpp index bb249983483c4..b6aad87611125 100644 --- a/taichi/codegen/llvm/codegen_llvm.cpp +++ b/taichi/codegen/llvm/codegen_llvm.cpp @@ -376,6 +376,8 @@ void TaskCodeGenLLVM::visit(UnaryOpStmt *stmt) { if (from == to) { llvm_val[stmt] = llvm_val[stmt->operand]; + } else if (to->is_primitive(PrimitiveTypeID::u1)) { + llvm_val[stmt] = builder->CreateIsNotNull(input); } else if (is_real(from.get_element_type()) != is_real(to.get_element_type())) { if (is_real(from.get_element_type()) &&