Skip to content

Commit 98189bc

Browse files
committed
better codegen of isa(). ref #7060
1 parent cb9fca4 commit 98189bc

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/codegen.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,22 +1599,28 @@ static Value *emit_known_call(jl_value_t *ff, jl_value_t **args, size_t nargs,
15991599
else if (f->fptr == &jl_f_isa && nargs==2) {
16001600
jl_value_t *arg = expr_type(args[1], ctx); rt1 = arg;
16011601
jl_value_t *ty = expr_type(args[2], ctx); rt2 = ty;
1602-
if (jl_is_type_type(ty) && !jl_is_typevar(jl_tparam0(ty))) {
1602+
if (arg == jl_bottom_type) {
1603+
JL_GC_POP();
1604+
emit_expr(args[1], ctx);
1605+
return UndefValue::get(T_int1);
1606+
}
1607+
if (jl_is_type_type(ty) && !jl_has_typevars(jl_tparam0(ty))) {
16031608
jl_value_t *tp0 = jl_tparam0(ty);
1604-
if (arg != jl_bottom_type && jl_subtype(arg, tp0, 0)) {
1609+
if (jl_subtype(arg, tp0, 0)) {
16051610
JL_GC_POP();
16061611
return ConstantInt::get(T_int1,1);
16071612
}
1608-
if (!jl_is_tuple(tp0) && jl_is_leaf_type(tp0) &&
1609-
!jl_is_type_type(tp0)) {
1613+
if (!jl_is_tuple(tp0) && !jl_is_type_type(tp0)) {
16101614
if (jl_is_leaf_type(arg)) {
16111615
JL_GC_POP();
16121616
return ConstantInt::get(T_int1,0);
16131617
}
1614-
Value *arg1 = emit_expr(args[1], ctx);
1615-
JL_GC_POP();
1616-
return builder.CreateICmpEQ(emit_typeof(arg1),
1617-
literal_pointer_val(tp0));
1618+
if (jl_is_leaf_type(tp0)) {
1619+
Value *arg1 = emit_expr(args[1], ctx);
1620+
JL_GC_POP();
1621+
return builder.CreateICmpEQ(emit_typeof(arg1),
1622+
literal_pointer_val(tp0));
1623+
}
16181624
}
16191625
}
16201626
}

0 commit comments

Comments
 (0)