A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Cranelift: Tweak cost function to make `imul` more expensive (#12006)
Nick Fitzgeraldd5ef52854168
diff --git a/cranelift/codegen/src/egraph/cost.rs b/cranelift/codegen/src/egraph/cost.rsindex 87ff70a259..1ff56fcd61 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}}