-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b6efe9
commit 832bfb7
Showing
1 changed file
with
16 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -782,11 +782,9 @@ static Value *emit_untyped_intrinsic(jl_codectx_t &ctx, intrinsic f, Value **arg | |
|
||
static jl_cgval_t emit_ifelse(jl_codectx_t &ctx, jl_cgval_t c, jl_cgval_t x, jl_cgval_t y, jl_value_t *rt_hint) | ||
{ | ||
Value *isfalse = emit_condition(ctx, c, "ifelse"); // emit the first argument | ||
// emit X and Y arguments | ||
jl_value_t *t1 = x.typ; | ||
jl_value_t *t2 = y.typ; | ||
// check the return value was valid | ||
// handle cases where the condition is irrelevant based on type info | ||
if (t1 == jl_bottom_type && t2 == jl_bottom_type) | ||
return jl_cgval_t(); // undefined | ||
if (t1 == jl_bottom_type) | ||
|
@@ -795,23 +793,23 @@ static jl_cgval_t emit_ifelse(jl_codectx_t &ctx, jl_cgval_t c, jl_cgval_t x, jl_ | |
return x; | ||
|
||
if (t1 != t2) { | ||
// type inference may know something we don't, in which case it may | ||
// be illegal for us to convert to rt_hint. Check first if either | ||
// of the types have empty intersection with the result type, | ||
// in which case, we may use the other one. | ||
if (jl_type_intersection(t1, rt_hint) == jl_bottom_type) { | ||
return y; | ||
} else if (jl_type_intersection(t2, rt_hint) == jl_bottom_type) { | ||
return x; | ||
} | ||
// if they aren't the same type, consider using the expr type | ||
// to instantiate a union-split optimization | ||
x = convert_julia_type(ctx, x, rt_hint); | ||
y = convert_julia_type(ctx, y, rt_hint); | ||
t1 = x.typ; | ||
t2 = y.typ; | ||
// type inference may know something we don't, in which case it may | ||
// be illegal for us to convert to rt_hint. Check first if either | ||
// of the types have empty intersection with the result type, | ||
// in which case, we may use the other one. | ||
if (jl_type_intersection(t1, rt_hint) == jl_bottom_type) | ||
return y; | ||
else if (jl_type_intersection(t2, rt_hint) == jl_bottom_type) | ||
return x; | ||
// if they aren't the same type, consider using the expr type | ||
// to instantiate a union-split optimization | ||
x = convert_julia_type(ctx, x, rt_hint); | ||
y = convert_julia_type(ctx, y, rt_hint); | ||
t1 = x.typ; | ||
t2 = y.typ; | ||
} | ||
|
||
Value *isfalse = emit_condition(ctx, c, "ifelse"); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
JeffBezanson
Author
Member
|
||
Value *ifelse_result; | ||
bool isboxed; | ||
Type *llt1 = julia_type_to_llvm(t1, &isboxed); | ||
|
This is incorrect as long as the condition can have side effects. I also believe
emit_condition
does type checks, so this would create problems for something like aUnion{Int, Bool}
.