This patch adds support for recognizing more patterns to match to DEXT and CINS instructions.
It finds cases where multiple instructions could be replaced with a single DEXT or CINS instruction. For example, for the following:
define i64 @dext_and32(i64 zeroext %a) {
entry:
%and = and i64 %a, 4294967295 ret i64 %and
}
instead of generating:
0000000000000088 <dext_and32>:
88: 64010001 daddiu at,zero,1 8c: 0001083c dsll32 at,at,0x0 90: 6421ffff daddiu at,at,-1 94: 03e00008 jr ra 98: 00811024 and v0,a0,at 9c: 00000000 nop
the following gets generated:
0000000000000068 <dext_and32>:
68: 03e00008 jr ra 6c: 7c82f803 dext v0,a0,0x0,0x20
Cases that are covered:
DEXT:
- and $src, mask where mask > 0xffff
- zext $src zero extend from i32 to i64
CINS:
- and (shl $src, pos), mask
- shl (and $src, mask), pos
- zext (shl $src, pos) zero extend from i32 to i64