nac3core: distinguish i64 and i32 in bool conversion

escape-analysis
ychenfo 2021-12-02 01:02:42 +08:00
parent a91b2d602c
commit 1e6848ab92
1 changed files with 8 additions and 1 deletions

View File

@ -414,7 +414,14 @@ impl TopLevelComposer {
let arg = args[0].1;
if ctx.unifier.unioned(arg_ty, boolean) {
Some(arg)
} else if ctx.unifier.unioned(arg_ty, int32) || ctx.unifier.unioned(arg_ty, int64) {
} else if ctx.unifier.unioned(arg_ty, int32) {
Some(ctx.builder.build_int_compare(
IntPredicate::NE,
ctx.ctx.i32_type().const_zero(),
arg.into_int_value(),
"bool",
).into())
} else if ctx.unifier.unioned(arg_ty, int64) {
Some(ctx.builder.build_int_compare(
IntPredicate::NE,
ctx.ctx.i64_type().const_zero(),