Extract process_constant.
This commit is contained in:
parent
be9668d398
commit
b22742e8f3
1 changed files with 44 additions and 34 deletions
|
@ -356,18 +356,15 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If we expect `lhs ?= A`, we have an opportunity if we assume `constant == A`.
|
||||||
#[instrument(level = "trace", skip(self))]
|
#[instrument(level = "trace", skip(self))]
|
||||||
fn process_operand(
|
fn process_constant(
|
||||||
&mut self,
|
&mut self,
|
||||||
bb: BasicBlock,
|
bb: BasicBlock,
|
||||||
lhs: PlaceIndex,
|
lhs: PlaceIndex,
|
||||||
rhs: &Operand<'tcx>,
|
constant: OpTy<'tcx>,
|
||||||
state: &mut State<ConditionSet<'a>>,
|
state: &mut State<ConditionSet<'a>>,
|
||||||
) -> Option<!> {
|
) {
|
||||||
match rhs {
|
|
||||||
// If we expect `lhs ?= A`, we have an opportunity if we assume `constant == A`.
|
|
||||||
Operand::Constant(constant) => {
|
|
||||||
let constant = self.ecx.eval_mir_constant(&constant.const_, None, None).ok()?;
|
|
||||||
self.map.for_each_projection_value(
|
self.map.for_each_projection_value(
|
||||||
lhs,
|
lhs,
|
||||||
constant,
|
constant,
|
||||||
|
@ -394,15 +391,28 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
|
||||||
&& let Immediate::Scalar(Scalar::Int(int)) = *imm
|
&& let Immediate::Scalar(Scalar::Int(int)) = *imm
|
||||||
{
|
{
|
||||||
conditions.iter_matches(int).for_each(|c: Condition| {
|
conditions.iter_matches(int).for_each(|c: Condition| {
|
||||||
self.opportunities.push(ThreadingOpportunity {
|
self.opportunities
|
||||||
chain: vec![bb],
|
.push(ThreadingOpportunity { chain: vec![bb], target: c.target })
|
||||||
target: c.target,
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "trace", skip(self))]
|
||||||
|
fn process_operand(
|
||||||
|
&mut self,
|
||||||
|
bb: BasicBlock,
|
||||||
|
lhs: PlaceIndex,
|
||||||
|
rhs: &Operand<'tcx>,
|
||||||
|
state: &mut State<ConditionSet<'a>>,
|
||||||
|
) -> Option<!> {
|
||||||
|
match rhs {
|
||||||
|
// If we expect `lhs ?= A`, we have an opportunity if we assume `constant == A`.
|
||||||
|
Operand::Constant(constant) => {
|
||||||
|
let constant = self.ecx.eval_mir_constant(&constant.const_, None, None).ok()?;
|
||||||
|
self.process_constant(bb, lhs, constant, state);
|
||||||
|
}
|
||||||
// Transfer the conditions on the copied rhs.
|
// Transfer the conditions on the copied rhs.
|
||||||
Operand::Move(rhs) | Operand::Copy(rhs) => {
|
Operand::Move(rhs) | Operand::Copy(rhs) => {
|
||||||
let rhs = self.map.find(rhs.as_ref())?;
|
let rhs = self.map.find(rhs.as_ref())?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue