Add legalization for popcnt.i128 via narrowing, fixes #1116

This commit is contained in:
krk
2019-11-13 20:59:33 +01:00
committed by Benjamin Bouvier
parent 569a57fa7d
commit f7c7245b06
2 changed files with 42 additions and 0 deletions

View File

@@ -275,6 +275,17 @@ pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGro
],
);
narrow.legalize(
def!(a = popcnt.I128(x)),
vec![
def!((xl, xh) = isplit(x)),
def!(e1 = popcnt(xl)),
def!(e2 = popcnt(xh)),
def!(e3 = iadd(e1, e2)),
def!(a = uextend(e3)),
],
);
// TODO(ryzokuken): benchmark this and decide if branching is a faster
// approach than evaluating boolean expressions.