Skip to content

Commit

Permalink
[llvm] Simplified and add support for type u1 in logical not operation
Browse files Browse the repository at this point in the history
ghstack-source-id: e8f589ecbc23e83b16419aaa7f13164d843894ff
Pull Request resolved: #8005
  • Loading branch information
listerily committed May 15, 2023
1 parent 61ff6e0 commit f4e0d94
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
8 changes: 1 addition & 7 deletions taichi/codegen/amdgpu/codegen_amdgpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 0 additions & 6 deletions taichi/codegen/cuda/codegen_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion taichi/codegen/llvm/codegen_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions taichi/runtime/llvm/runtime_module/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f4e0d94

Please sign in to comment.