File tree Expand file tree Collapse file tree 4 files changed +19
-4
lines changed
Expand file tree Collapse file tree 4 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ pub(crate) fn clif_int_or_float_cast(
149149 }
150150
151151 let is_not_nan = fx. bcx . ins ( ) . fcmp ( FloatCC :: Equal , from, from) ;
152- let zero = fx. bcx . ins ( ) . iconst ( to_ty , 0 ) ;
152+ let zero = type_zero_value ( & mut fx. bcx , to_ty ) ;
153153 fx. bcx . ins ( ) . select ( is_not_nan, val, zero)
154154 } else if from_ty. is_float ( ) && to_ty. is_float ( ) {
155155 // float -> float
Original file line number Diff line number Diff line change @@ -167,6 +167,15 @@ pub(crate) fn codegen_icmp_imm(
167167 }
168168}
169169
170+ pub ( crate ) fn type_zero_value ( bcx : & mut FunctionBuilder < ' _ > , ty : Type ) -> Value {
171+ if ty == types:: I128 {
172+ let zero = bcx. ins ( ) . iconst ( types:: I64 , 0 ) ;
173+ bcx. ins ( ) . iconcat ( zero, zero)
174+ } else {
175+ bcx. ins ( ) . iconst ( ty, 0 )
176+ }
177+ }
178+
170179pub ( crate ) fn type_min_max_value (
171180 bcx : & mut FunctionBuilder < ' _ > ,
172181 ty : Type ,
Original file line number Diff line number Diff line change @@ -278,8 +278,14 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
278278 fx. bcx . ins ( ) . iadd ( tagged_discr, delta)
279279 } ;
280280
281- let untagged_variant =
282- fx. bcx . ins ( ) . iconst ( cast_to, i64:: from ( untagged_variant. as_u32 ( ) ) ) ;
281+ let untagged_variant = if cast_to == types:: I128 {
282+ let zero = fx. bcx . ins ( ) . iconst ( types:: I64 , 0 ) ;
283+ let untagged_variant =
284+ fx. bcx . ins ( ) . iconst ( types:: I64 , i64:: from ( untagged_variant. as_u32 ( ) ) ) ;
285+ fx. bcx . ins ( ) . iconcat ( untagged_variant, zero)
286+ } else {
287+ fx. bcx . ins ( ) . iconst ( cast_to, i64:: from ( untagged_variant. as_u32 ( ) ) )
288+ } ;
283289 let discr = fx. bcx . ins ( ) . select ( is_niche, tagged_discr, untagged_variant) ;
284290 let res = CValue :: by_val ( discr, dest_layout) ;
285291 dest. write_cvalue ( fx, res) ;
Original file line number Diff line number Diff line change @@ -713,7 +713,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
713713
714714 let res_type =
715715 Type :: int_with_byte_size ( u16:: try_from ( expected_bytes) . unwrap ( ) ) . unwrap ( ) ;
716- let mut res = fx. bcx . ins ( ) . iconst ( res_type , 0 ) ;
716+ let mut res = type_zero_value ( & mut fx. bcx , res_type ) ;
717717
718718 let lanes = match fx. tcx . sess . target . endian {
719719 Endian :: Big => Box :: new ( 0 ..lane_count) as Box < dyn Iterator < Item = u64 > > ,
You can’t perform that action at this time.
0 commit comments