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(
149
149
}
150
150
151
151
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 ) ;
153
153
fx. bcx . ins ( ) . select ( is_not_nan, val, zero)
154
154
} else if from_ty. is_float ( ) && to_ty. is_float ( ) {
155
155
// float -> float
Original file line number Diff line number Diff line change @@ -167,6 +167,15 @@ pub(crate) fn codegen_icmp_imm(
167
167
}
168
168
}
169
169
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
+
170
179
pub ( crate ) fn type_min_max_value (
171
180
bcx : & mut FunctionBuilder < ' _ > ,
172
181
ty : Type ,
Original file line number Diff line number Diff line change @@ -278,8 +278,14 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
278
278
fx. bcx . ins ( ) . iadd ( tagged_discr, delta)
279
279
} ;
280
280
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
+ } ;
283
289
let discr = fx. bcx . ins ( ) . select ( is_niche, tagged_discr, untagged_variant) ;
284
290
let res = CValue :: by_val ( discr, dest_layout) ;
285
291
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>(
713
713
714
714
let res_type =
715
715
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 ) ;
717
717
718
718
let lanes = match fx. tcx . sess . target . endian {
719
719
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