Optimize multiple int casts on ptrtoint, into a single cast. Fixed incorrect widening cast from signed -> unsigned.

This commit is contained in:
Christoffer Lerno
2022-01-17 00:45:26 +01:00
parent 23461b179f
commit 99ea0afcbf
6 changed files with 32 additions and 8 deletions

View File

@@ -1300,7 +1300,7 @@ void llvm_emit_cast(GenContext *c, CastKind cast_kind, BEValue *value, Type *to_
llvm_value_rvalue(c, value);
value->value = type_convert_will_trunc(to_type, from_type)
? LLVMBuildTrunc(c->builder, value->value, llvm_get_type(c, to_type), "siuitrunc")
: LLVMBuildZExt(c->builder, value->value, llvm_get_type(c, to_type), "siuiext");
: LLVMBuildSExt(c->builder, value->value, llvm_get_type(c, to_type), "siuiext");
break;
case CAST_SIFP:
llvm_value_rvalue(c, value);