Canonicalize floats before branch, in Operator::Return too.

This commit is contained in:
Nick Lewycky
2020-07-10 16:55:22 -07:00
parent cc081ffff6
commit c1e3b445a1
2 changed files with 14 additions and 2 deletions

View File

@ -1723,12 +1723,13 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
.ok_or_else(|| CompileError::Codegen("not currently in a block".to_string()))?; .ok_or_else(|| CompileError::Codegen("not currently in a block".to_string()))?;
let frame = self.state.outermost_frame()?; let frame = self.state.outermost_frame()?;
self.builder.build_unconditional_branch(*frame.br_dest());
for phi in frame.phis().to_vec().iter().rev() { for phi in frame.phis().to_vec().iter().rev() {
let (arg, info) = self.state.pop1_extra()?; let (arg, info) = self.state.pop1_extra()?;
let arg = self.apply_pending_canonicalization(arg, info); let arg = self.apply_pending_canonicalization(arg, info);
phi.add_incoming(&[(&arg, current_block)]); phi.add_incoming(&[(&arg, current_block)]);
} }
let frame = self.state.outermost_frame()?;
self.builder.build_unconditional_branch(*frame.br_dest());
self.state.reachable = false; self.state.reachable = false;
} }

View File

@ -193,7 +193,7 @@
(assert_return (invoke "nan-canonicalization-f64-func-call-indirect" (i64.const 0x7ff8000000000001)) (i64.const 0x7ff8000000000001)) (assert_return (invoke "nan-canonicalization-f64-func-call-indirect" (i64.const 0x7ff8000000000001)) (i64.const 0x7ff8000000000001))
(assert_return (invoke "nan-canonicalization-f64-func-call-indirect-cncl" (i64.const 0x7ff8000000000001)) (i64.const 0x7ff8000000000000)) (assert_return (invoke "nan-canonicalization-f64-func-call-indirect-cncl" (i64.const 0x7ff8000000000001)) (i64.const 0x7ff8000000000000))
;; Test canonicalization is done before `else` operator. ;; Test canonicalization is done before branch in `else` operator.
(module (module
(func (;0;) (func (;0;)
(local f64) (local f64)
@ -208,3 +208,14 @@
return return
) )
) )
;; Test canonicalization is done before branch in `return` operator.
(module
(func (;0;) (result f64)
(local f64)
f64.const 0x0p+0
local.get 0
f64.mul
return
)
)