diff --git a/cranelift/codegen/src/machinst/lower.rs b/cranelift/codegen/src/machinst/lower.rs index 32dfaa336c..6a42f3a2b6 100644 --- a/cranelift/codegen/src/machinst/lower.rs +++ b/cranelift/codegen/src/machinst/lower.rs @@ -913,6 +913,7 @@ impl<'func, I: VCodeInst> Lower<'func, I> { // the code-motion. if self.cur_scan_entry_color.is_some() && self.value_uses[val] == 1 + && self.value_lowered_uses[val] == 0 && self.num_outputs(src_inst) == 1 && self .side_effect_inst_entry_colors diff --git a/cranelift/filetests/filetests/isa/x64/load-op.clif b/cranelift/filetests/filetests/isa/x64/load-op.clif index 87069262ed..77e4b05420 100644 --- a/cranelift/filetests/filetests/isa/x64/load-op.clif +++ b/cranelift/filetests/filetests/isa/x64/load-op.clif @@ -44,3 +44,18 @@ block0(v0: i64, v1: i8): ; nextln: addl %esi, %r12d return v3 } + +function %no_merge_if_lookback_use(i64, i64) -> i64 { +block0(v0: i64, v1: i64): + v2 = load.i64 v0 + v3 = iadd.i64 v2, v0 + store.i64 v3, v1 + v4 = load.i64 v3 + return v4 + ; check: movq 0(%rdi), %r12 + ; nextln: movq %r12, %r13 + ; nextln: addq %rdi, %r13 + ; nextln: movq %r13, 0(%rsi) + ; nextln: movq 0(%r12,%rdi,1), %r12 + ; nextln: movq %r12, %rax +}