Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b478fcf

Browse files
committed
Use new cast methods
1 parent 630e17d commit b478fcf

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

compiler/rustc_mir_transform/src/dataflow_const_prop.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,26 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'tcx> {
128128
) -> ValueOrPlaceOrRef<Self::Value> {
129129
match rvalue {
130130
Rvalue::Cast(
131-
CastKind::IntToInt
131+
kind @ (CastKind::IntToInt
132132
| CastKind::FloatToInt
133133
| CastKind::FloatToFloat
134-
| CastKind::IntToFloat,
134+
| CastKind::IntToFloat),
135135
operand,
136136
ty,
137-
) => {
138-
let operand = self.eval_operand(operand, state);
139-
match operand {
140-
FlatSet::Elem(operand) => self
141-
.ecx
142-
.misc_cast(&operand, *ty)
143-
.map(|result| ValueOrPlaceOrRef::Value(self.wrap_immediate(result, *ty)))
144-
.unwrap_or(ValueOrPlaceOrRef::top()),
145-
_ => ValueOrPlaceOrRef::top(),
137+
) => match self.eval_operand(operand, state) {
138+
FlatSet::Elem(op) => match kind {
139+
CastKind::IntToInt | CastKind::IntToFloat => {
140+
self.ecx.int_to_int_or_float(&op, *ty)
141+
}
142+
CastKind::FloatToInt | CastKind::FloatToFloat => {
143+
self.ecx.float_to_float_or_int(&op, *ty)
144+
}
145+
_ => unreachable!(),
146146
}
147-
}
147+
.map(|result| ValueOrPlaceOrRef::Value(self.wrap_immediate(result, *ty)))
148+
.unwrap_or(ValueOrPlaceOrRef::top()),
149+
_ => ValueOrPlaceOrRef::top(),
150+
},
148151
Rvalue::BinaryOp(op, box (left, right)) => {
149152
// Overflows must be ignored here.
150153
let (val, _overflow) = self.binary_op(state, *op, left, right);

0 commit comments

Comments
 (0)