Don't perform gvn on instructions with other_side_effects().

This commit is contained in:
Dan Gohman
2017-08-08 14:14:59 -07:00
parent 8546cabc8f
commit 79d8aa366d
2 changed files with 12 additions and 1 deletions

View File

@@ -0,0 +1,11 @@
test simple-gvn
function %other_side_effects(i32) -> i32 {
ebb0(v0: i32):
regmove v0, %10 -> %20
regmove v0, %10 -> %20
regmove v0, %20 -> %10
; check: regmove v0, %10 -> %20
; check: regmove v0, %10 -> %20
return v0
}

View File

@@ -8,7 +8,7 @@ use std::collections::HashMap;
/// Test whether the given opcode is unsafe to even consider for GVN.
fn trivially_unsafe_for_gvn(opcode: Opcode) -> bool {
opcode.is_call() || opcode.is_branch() || opcode.is_terminator() || opcode.is_return() ||
opcode.can_trap()
opcode.can_trap() || opcode.other_side_effects()
}
/// Perform simple GVN on `func`.