@@ -56,10 +56,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
56
56
let dest = this. project_index ( & dest, i) ?;
57
57
58
58
// Widen the operands to avoid overflow
59
- let twice_wide_ty = this. get_twice_wide_int_ty ( left. layout . ty ) ;
60
- let twice_wide_layout = this. layout_of ( twice_wide_ty) ?;
61
- let left = this. int_to_int_or_float ( & left, twice_wide_ty) ?;
62
- let right = this. int_to_int_or_float ( & right, twice_wide_ty) ?;
59
+ let twice_wide = this. layout_of ( this. get_twice_wide_int_ty ( left. layout . ty ) ) ?;
60
+ let left = this. int_to_int_or_float ( & left, twice_wide) ?;
61
+ let right = this. int_to_int_or_float ( & right, twice_wide) ?;
63
62
64
63
// Calculate left + right + 1
65
64
let added = this. wrapping_binary_op (
@@ -70,20 +69,20 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
70
69
let added = this. wrapping_binary_op (
71
70
mir:: BinOp :: Add ,
72
71
& added,
73
- & ImmTy :: from_uint ( 1u32 , twice_wide_layout ) ,
72
+ & ImmTy :: from_uint ( 1u32 , twice_wide ) ,
74
73
) ?;
75
74
76
75
// Calculate (left + right + 1) / 2
77
76
let divided = this. wrapping_binary_op (
78
77
mir:: BinOp :: Div ,
79
78
& added,
80
- & ImmTy :: from_uint ( 2u32 , twice_wide_layout ) ,
79
+ & ImmTy :: from_uint ( 2u32 , twice_wide ) ,
81
80
) ?;
82
81
83
82
// Narrow back to the original type
84
83
let res = this. int_to_int_or_float (
85
84
& divided,
86
- dest. layout . ty ,
85
+ dest. layout ,
87
86
) ?;
88
87
this. write_immediate ( * res, & dest) ?;
89
88
}
@@ -106,10 +105,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
106
105
let dest = this. project_index ( & dest, i) ?;
107
106
108
107
// Widen the operands to avoid overflow
109
- let twice_wide_ty = this. get_twice_wide_int_ty ( left. layout . ty ) ;
110
- let twice_wide_layout = this. layout_of ( twice_wide_ty) ?;
111
- let left = this. int_to_int_or_float ( & left, twice_wide_ty) ?;
112
- let right = this. int_to_int_or_float ( & right, twice_wide_ty) ?;
108
+ let twice_wide = this. layout_of ( this. get_twice_wide_int_ty ( left. layout . ty ) ) ?;
109
+ let left = this. int_to_int_or_float ( & left, twice_wide) ?;
110
+ let right = this. int_to_int_or_float ( & right, twice_wide) ?;
113
111
114
112
// Multiply
115
113
let multiplied = this. wrapping_binary_op (
@@ -121,13 +119,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
121
119
let high = this. wrapping_binary_op (
122
120
mir:: BinOp :: Shr ,
123
121
& multiplied,
124
- & ImmTy :: from_uint ( dest. layout . size . bits ( ) , twice_wide_layout ) ,
122
+ & ImmTy :: from_uint ( dest. layout . size . bits ( ) , twice_wide ) ,
125
123
) ?;
126
124
127
125
// Narrow back to the original type
128
126
let res = this. int_to_int_or_float (
129
127
& high,
130
- dest. layout . ty ,
128
+ dest. layout ,
131
129
) ?;
132
130
this. write_immediate ( * res, & dest) ?;
133
131
}
@@ -392,7 +390,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
392
390
let dest = this. project_index ( & dest, i) ?;
393
391
394
392
let res =
395
- this. float_to_int_checked ( op, dest. layout . ty , rnd) . unwrap_or_else ( || {
393
+ this. float_to_int_checked ( op, dest. layout , rnd) . unwrap_or_else ( || {
396
394
// Fallback to minimum acording to SSE2 semantics.
397
395
ImmTy :: from_int ( i32:: MIN , this. machine . layouts . i32 )
398
396
} ) ;
@@ -648,7 +646,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
648
646
let op = this. read_immediate ( & this. project_index ( & op, i) ?) ?;
649
647
let dest = this. project_index ( & dest, i) ?;
650
648
651
- let res = this. float_to_float_or_int ( & op, dest. layout . ty ) ?;
649
+ let res = this. float_to_float_or_int ( & op, dest. layout ) ?;
652
650
this. write_immediate ( * res, & dest) ?;
653
651
}
654
652
// For f32 -> f64, ignore the remaining
@@ -685,7 +683,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
685
683
let dest = this. project_index ( & dest, i) ?;
686
684
687
685
let res =
688
- this. float_to_int_checked ( op, dest. layout . ty , rnd) . unwrap_or_else ( || {
686
+ this. float_to_int_checked ( op, dest. layout , rnd) . unwrap_or_else ( || {
689
687
// Fallback to minimum acording to SSE2 semantics.
690
688
ImmTy :: from_int ( i32:: MIN , this. machine . layouts . i32 )
691
689
} ) ;
@@ -716,7 +714,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
716
714
_ => unreachable ! ( ) ,
717
715
} ;
718
716
719
- let res = this. float_to_int_checked ( op, dest. layout . ty , rnd) . unwrap_or_else ( || {
717
+ let res = this. float_to_int_checked ( op, dest. layout , rnd) . unwrap_or_else ( || {
720
718
// Fallback to minimum acording to SSE semantics.
721
719
ImmTy :: from_int ( dest. layout . size . signed_int_min ( ) , dest. layout )
722
720
} ) ;
@@ -741,7 +739,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
741
739
let dest0 = this. project_index ( & dest, 0 ) ?;
742
740
// `float_to_float_or_int` here will convert from f64 to f32 (cvtsd2ss) or
743
741
// from f32 to f64 (cvtss2sd).
744
- let res0 = this. float_to_float_or_int ( & right0, dest0. layout . ty ) ?;
742
+ let res0 = this. float_to_float_or_int ( & right0, dest0. layout ) ?;
745
743
this. write_immediate ( * res0, & dest0) ?;
746
744
747
745
// Copy remianing from `left`
0 commit comments