Skip to content

Commit b2bfc59

Browse files
committed
Codegen: don't pun fptoui/fptosi source or uitofp/sitofp destination
1 parent f604ddc commit b2bfc59

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/intrinsics.cpp

+16-10
Original file line numberDiff line numberDiff line change
@@ -676,17 +676,23 @@ static jl_cgval_t generic_cast(
676676
Type *to = bitstype_to_llvm((jl_value_t*)jlto, ctx.builder.getContext(), true);
677677
Type *vt = bitstype_to_llvm(v.typ, ctx.builder.getContext(), true);
678678

679-
// fptrunc fpext depend on the specific floating point format to work
680-
// correctly, and so do not pun their argument types.
679+
// fptrunc and fpext depend on the specific floating point
680+
// format to work correctly, and so do not pun their argument types.
681681
if (!(f == fpext || f == fptrunc)) {
682-
if (toint)
683-
to = INTT(to, DL);
684-
else
685-
to = FLOATT(to);
686-
if (fromint)
687-
vt = INTT(vt, DL);
688-
else
689-
vt = FLOATT(vt);
682+
// uitofp/sitofp require a specific float type argument
683+
if (!(f == uitofp || f == sitofp)){
684+
if (toint)
685+
to = INTT(to, DL);
686+
else
687+
to = FLOATT(to);
688+
}
689+
// fptoui/fptosi require a specific float value argument
690+
if (!(f == fptoui || f == fptosi)) {
691+
if (fromint)
692+
vt = INTT(vt, DL);
693+
else
694+
vt = FLOATT(vt);
695+
}
690696
}
691697

692698
if (!to || !vt)

0 commit comments

Comments
 (0)