From cd900d72db7b0ab3e16cf41e63d13828e4c48712 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 23 Mar 2020 15:19:02 -0700 Subject: [PATCH] Add tests showing no interference between jump tables and constants --- .../filetests/isa/x86/simd-vconst-rodata.clif | 20 ++++++++++++++ .../filetests/isa/x86/simd-vconst-run.clif | 26 ++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/cranelift/filetests/filetests/isa/x86/simd-vconst-rodata.clif b/cranelift/filetests/filetests/isa/x86/simd-vconst-rodata.clif index f6b8732a9e..3488ad06b6 100644 --- a/cranelift/filetests/filetests/isa/x86/simd-vconst-rodata.clif +++ b/cranelift/filetests/filetests/isa/x86/simd-vconst-rodata.clif @@ -17,3 +17,23 @@ block0: } ; sameln: [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0] + + +; Since both jump tables and constants are emitted after the function body, it is important that they do not interfere. +; This test shows that even in the presence of jump tables, constants are emitted correctly +function %vconst_with_jumptables() { +jt0 = jump_table [block0] + +block10: + v10 = iconst.i64 0 + br_table v10, block1, jt0 +block0: + jump block11 +block1: + jump block11 +block11: + v11 = vconst.i8x16 [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] + return +} + +; sameln: [1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10] diff --git a/cranelift/filetests/filetests/isa/x86/simd-vconst-run.clif b/cranelift/filetests/filetests/isa/x86/simd-vconst-run.clif index 553e5bb6ac..d8caca45f8 100644 --- a/cranelift/filetests/filetests/isa/x86/simd-vconst-run.clif +++ b/cranelift/filetests/filetests/isa/x86/simd-vconst-run.clif @@ -17,5 +17,29 @@ block0: v6 = band v4, v5 return v6 } - +; run + +; Since both jump tables and constants are emitted after the function body, it is important that any RIP-relative +; addressing of constants is not incorrect in the presence of jump tables. This test confirms that, even when both +; jump tables and constants are emitted, the constant addressing works correctly. +function %vconst_with_jumptables() -> b1 { +jt0 = jump_table [block0] + +block10: + v10 = iconst.i64 0 + br_table v10, block1, jt0 +block0: + v0 = iconst.i64 100 + jump block11(v0) +block1: + v1 = iconst.i64 101 + jump block11(v1) +block11(v11: i64): + v12 = icmp_imm eq v11, 100 ; We should have jumped through block 0. + v13 = vconst.i32x4 [1 2 3 4] + v14 = extractlane.i32x4 v13, 1 ; Extract the second element... + v15 = icmp_imm eq v14, 2 ; ...which should be the value 2. + v16 = band v12, v15 + return v16 +} ; run