diff --git a/taichi/codegen/amdgpu/codegen_amdgpu.cpp b/taichi/codegen/amdgpu/codegen_amdgpu.cpp index 9d4f4ac10b39fa..5b2431ef54eb54 100644 --- a/taichi/codegen/amdgpu/codegen_amdgpu.cpp +++ b/taichi/codegen/amdgpu/codegen_amdgpu.cpp @@ -65,13 +65,7 @@ class TaskCodeGenAMDGPU : public TaskCodeGenLLVM { TI_NOT_IMPLEMENTED \ } \ } - if (op == UnaryOpType::logic_not) { - if (input_taichi_type->is_primitive(PrimitiveTypeID::i32)) { - llvm_val[stmt] = call("logic_not_i32", input); - } else { - TI_NOT_IMPLEMENTED - } - } else if (op == UnaryOpType::abs) { + if (op == UnaryOpType::abs) { if (input_taichi_type->is_primitive(PrimitiveTypeID::f16)) { llvm_val[stmt] = call("__ocml_fasb_f16", input); } else if (input_taichi_type->is_primitive(PrimitiveTypeID::f32)) { diff --git a/taichi/codegen/cuda/codegen_cuda.cpp b/taichi/codegen/cuda/codegen_cuda.cpp index dd5b8216759085..b39586b3b446a5 100644 --- a/taichi/codegen/cuda/codegen_cuda.cpp +++ b/taichi/codegen/cuda/codegen_cuda.cpp @@ -257,12 +257,6 @@ class TaskCodeGenCUDA : public TaskCodeGenLLVM { } else { TI_NOT_IMPLEMENTED } - } else if (op == UnaryOpType::logic_not) { - if (input_taichi_type->is_primitive(PrimitiveTypeID::i32)) { - llvm_val[stmt] = call("logic_not_i32", input); - } else { - TI_NOT_IMPLEMENTED - } } else if (op == UnaryOpType::frexp) { auto stype = tlctx->get_data_type(stmt->ret_type.ptr_removed()); auto res = builder->CreateAlloca(stype); diff --git a/taichi/codegen/llvm/codegen_llvm.cpp b/taichi/codegen/llvm/codegen_llvm.cpp index 30cd0f5aa382f2..829b93399e7e1a 100644 --- a/taichi/codegen/llvm/codegen_llvm.cpp +++ b/taichi/codegen/llvm/codegen_llvm.cpp @@ -197,7 +197,6 @@ void TaskCodeGenLLVM::emit_extra_unary(UnaryOpStmt *stmt) { UNARY_STD(tan) UNARY_STD(tanh) UNARY_STD(sgn) - UNARY_STD(logic_not) UNARY_STD(acos) UNARY_STD(asin) UNARY_STD(cos) @@ -524,6 +523,11 @@ void TaskCodeGenLLVM::visit(UnaryOpStmt *stmt) { } else { llvm_val[stmt] = builder->CreateNeg(input, "neg"); } + } else if (op == UnaryOpType::logic_not) { + llvm_val[stmt] = builder->CreateIsNull(input); + // TODO: (zhantong) remove this zero ext + llvm_val[stmt] = builder->CreateZExt( + llvm_val[stmt], tlctx->get_data_type(PrimitiveType::i32)); } UNARY_INTRINSIC(round) UNARY_INTRINSIC(floor) diff --git a/taichi/runtime/llvm/runtime_module/runtime.cpp b/taichi/runtime/llvm/runtime_module/runtime.cpp index 460beb145e7e77..53547922a2e858 100644 --- a/taichi/runtime/llvm/runtime_module/runtime.cpp +++ b/taichi/runtime/llvm/runtime_module/runtime.cpp @@ -229,10 +229,6 @@ i64 max_i64(i64 a, i64 b) { return a > b ? a : b; } -int32 logic_not_i32(int32 a) { - return !a; -} - float32 sgn_f32(float32 a) { float32 b; if (a > 0)