From b1fb4d7c35de6d50aa02529ce0418b3ee00d35a4 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Mon, 29 Aug 2022 22:22:12 -0700 Subject: [PATCH] Fix lowering issue in x64 vany_true: sinking and using original value. (#4815) The x64 lowring of `vany_true` both sinks mergeable loads and uses the original register. This PR fixes the lowering to force the value into a register first. Ideally we should solve the issue by catching this in the ISLE type system, as described in #4745, but this resolves the issue for now. Fixes #4807. --- cranelift/codegen/src/isa/x64/lower.isle | 3 ++- tests/misc_testsuite/simd/issue4807.wast | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/misc_testsuite/simd/issue4807.wast diff --git a/cranelift/codegen/src/isa/x64/lower.isle b/cranelift/codegen/src/isa/x64/lower.isle index 1c413f148a..23f18a73f0 100644 --- a/cranelift/codegen/src/isa/x64/lower.isle +++ b/cranelift/codegen/src/isa/x64/lower.isle @@ -3640,7 +3640,8 @@ ;; Rules for `vany_true` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule (lower (vany_true val)) - (with_flags (x64_ptest val val) (x64_setcc (CC.NZ)))) + (let ((val Xmm val)) + (with_flags (x64_ptest val val) (x64_setcc (CC.NZ))))) ;; Rules for `vall_true` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/tests/misc_testsuite/simd/issue4807.wast b/tests/misc_testsuite/simd/issue4807.wast new file mode 100644 index 0000000000..da12904404 --- /dev/null +++ b/tests/misc_testsuite/simd/issue4807.wast @@ -0,0 +1,8 @@ + (module + (func (result i32) + global.get 0 + v128.any_true + ) + (global (;0;) (mut v128) v128.const i64x2 0 0) +) +