Legalize [su]extend.i64 to iconst/sshr_imm + iconcat.

This was already done for [su]extend.i128, and is necessary for
codegen for 32-bit x86.
This commit is contained in:
whitequark
2020-04-28 05:23:42 +00:00
committed by iximeow
parent 14bdaf3ce3
commit 162fcd3d75
4 changed files with 70 additions and 7 deletions

View File

@@ -213,8 +213,8 @@ pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGro
// embedded as part of arguments), so use a custom legalization for now.
narrow.custom_legalize(iconst, "narrow_iconst");
{
let inst = uextend.bind(I128).bind(I64);
for &(ty, ty_half) in &[(I128, I64), (I64, I32)] {
let inst = uextend.bind(ty).bind(ty_half);
narrow.legalize(
def!(a = inst(x)),
vec![
@@ -224,12 +224,12 @@ pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGro
);
}
{
let inst = sextend.bind(I128).bind(I64);
for &(ty, ty_half, shift) in &[(I128, I64, 63), (I64, I32, 31)] {
let inst = sextend.bind(ty).bind(ty_half);
narrow.legalize(
def!(a = inst(x)),
vec![
def!(ah = sshr_imm(x, Literal::constant(&imm.imm64, 63))), // splat sign bit to whole number
def!(ah = sshr_imm(x, Literal::constant(&imm.imm64, shift))), // splat sign bit to whole number
def!(a = iconcat(x, ah)),
],
);