diff --git a/cranelift/codegen/src/egraph/cost.rs b/cranelift/codegen/src/egraph/cost.rs index 87ff70a2597e..1ff56fcd61f9 100644 --- a/cranelift/codegen/src/egraph/cost.rs +++ b/cranelift/codegen/src/egraph/cost.rs @@ -131,18 +131,27 @@ impl Cost { | Opcode::Ushr | Opcode::Sshr => Cost::new(3, 0), + // "Expensive" arithmetic. + Opcode::Imul => Cost::new(10, 0), + // Everything else. _ => { + // By default, be slightly more expensive than "simple" + // arithmetic. let mut c = Cost::new(4, 0); + + // And then get more expensive as the opcode does more side + // effects. if op.can_trap() || op.other_side_effects() { - c = c + Cost::new(5, 0); + c = c + Cost::new(10, 0); } if op.can_load() { - c = c + Cost::new(10, 0); + c = c + Cost::new(20, 0); } if op.can_store() { - c = c + Cost::new(20, 0); + c = c + Cost::new(50, 0); } + c } }