| ... | @@ -3831,10 +3831,14 @@ static LLVMValueRef ir_render_load_ptr(CodeGen *g, Stage1Air *executable, | ... | @@ -3831,10 +3831,14 @@ static LLVMValueRef ir_render_load_ptr(CodeGen *g, Stage1Air *executable, |
| 3831 | LLVMValueRef shift_amt_val = LLVMConstInt(LLVMTypeOf(containing_int), shift_amt, false); | 3831 | LLVMValueRef shift_amt_val = LLVMConstInt(LLVMTypeOf(containing_int), shift_amt, false); |
| 3832 | LLVMValueRef shifted_value = LLVMBuildLShr(g->builder, containing_int, shift_amt_val, ""); | 3832 | LLVMValueRef shifted_value = LLVMBuildLShr(g->builder, containing_int, shift_amt_val, ""); |
| 3833 | | 3833 | |
| | 3834 | LLVMTypeRef same_size_int = LLVMIntType(size_in_bits); |
| | 3835 | LLVMValueRef mask = LLVMConstAllOnes(LLVMIntType(size_in_bits)); |
| | 3836 | mask = LLVMConstZExt(mask, LLVMTypeOf(containing_int)); |
| | 3837 | LLVMValueRef masked_value = LLVMBuildAnd(g->builder, shifted_value, mask, ""); |
| | 3838 | |
| 3834 | if (handle_is_ptr(g, child_type)) { | 3839 | if (handle_is_ptr(g, child_type)) { |
| 3835 | LLVMValueRef result_loc = ir_llvm_value(g, instruction->result_loc); | 3840 | LLVMValueRef result_loc = ir_llvm_value(g, instruction->result_loc); |
| 3836 | LLVMTypeRef same_size_int = LLVMIntType(size_in_bits); | 3841 | LLVMValueRef truncated_int = LLVMBuildTrunc(g->builder, masked_value, same_size_int, ""); |
| 3837 | LLVMValueRef truncated_int = LLVMBuildTrunc(g->builder, shifted_value, same_size_int, ""); | | |
| 3838 | LLVMValueRef bitcasted_ptr = LLVMBuildBitCast(g->builder, result_loc, | 3842 | LLVMValueRef bitcasted_ptr = LLVMBuildBitCast(g->builder, result_loc, |
| 3839 | LLVMPointerType(same_size_int, 0), ""); | 3843 | LLVMPointerType(same_size_int, 0), ""); |
| 3840 | LLVMBuildStore(g->builder, truncated_int, bitcasted_ptr); | 3844 | LLVMBuildStore(g->builder, truncated_int, bitcasted_ptr); |
| ... | @@ -3842,12 +3846,11 @@ static LLVMValueRef ir_render_load_ptr(CodeGen *g, Stage1Air *executable, | ... | @@ -3842,12 +3846,11 @@ static LLVMValueRef ir_render_load_ptr(CodeGen *g, Stage1Air *executable, |
| 3842 | } | 3846 | } |
| 3843 | | 3847 | |
| 3844 | if (child_type->id == ZigTypeIdFloat) { | 3848 | if (child_type->id == ZigTypeIdFloat) { |
| 3845 | LLVMTypeRef same_size_int = LLVMIntType(size_in_bits); | 3849 | LLVMValueRef truncated_int = LLVMBuildTrunc(g->builder, masked_value, same_size_int, ""); |
| 3846 | LLVMValueRef truncated_int = LLVMBuildTrunc(g->builder, shifted_value, same_size_int, ""); | | |
| 3847 | return LLVMBuildBitCast(g->builder, truncated_int, get_llvm_type(g, child_type), ""); | 3850 | return LLVMBuildBitCast(g->builder, truncated_int, get_llvm_type(g, child_type), ""); |
| 3848 | } | 3851 | } |
| 3849 | | 3852 | |
| 3850 | return LLVMBuildTrunc(g->builder, shifted_value, get_llvm_type(g, child_type), ""); | 3853 | return LLVMBuildTrunc(g->builder, masked_value, get_llvm_type(g, child_type), ""); |
| 3851 | } | 3854 | } |
| 3852 | | 3855 | |
| 3853 | static bool value_is_all_undef_array(CodeGen *g, ZigValue *const_val, size_t len) { | 3856 | static bool value_is_all_undef_array(CodeGen *g, ZigValue *const_val, size_t len) { |