diff --git a/taichi/codegen/amdgpu/codegen_amdgpu.cpp b/taichi/codegen/amdgpu/codegen_amdgpu.cpp index 9d4f4ac10b39f..5b2431ef54eb5 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 dd5b821675908..b39586b3b446a 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 30cd0f5aa382f..d649e83b4f6b8 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) @@ -210,6 +209,11 @@ void TaskCodeGenLLVM::emit_extra_unary(UnaryOpStmt *stmt) { llvm_val[stmt] = builder->CreateIntrinsic(llvm::Intrinsic::ctpop, {input_type}, {input}); } + else if (op == UnaryOpType::logic_not) { + llvm_val[stmt] = builder->CreateSelect(builder->CreateIsNull(input), + tlctx->get_constant(true), + tlctx->get_constant(false)); + } else { TI_P(unary_op_type_name(op)); TI_NOT_IMPLEMENTED diff --git a/taichi/runtime/llvm/runtime_module/runtime.cpp b/taichi/runtime/llvm/runtime_module/runtime.cpp index 460beb145e7e7..53547922a2e85 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)