Commit 4ea1791
authored
[X86] Truncate unused bit for blendw mask (llvm#178883)
While tuning ProcessBLENDWToBLENDD
https://github.com/mahesh-attarde/llvm-project/blob/07ec2fa1443ccd3cbb55612937f1dddebfe51c15/llvm/lib/Target/X86/X86FixupInstTuning.cpp#L262
we creating mask from `getImm()` which returns 64bit int and APInt
accept 64 bit int.
```
APInt MaskW =
APInt(8, MI.getOperand(NumOperands - 1).getImm(), /*IsSigned=*/false);
```
It fails with MIR for BLENDW instruction that requires8 bit mask 0xAA
from 64 bit Imm.
```
renamable $xmm2 = VPBLENDWrri renamable $xmm1, killed renamable $xmm2, -86
```
APInt construction complains since higher bits of are also set for
transformations where mask bits are set (results in negative values).
https://github.com/mahesh-attarde/llvm-project/blob/07ec2fa1443ccd3cbb55612937f1dddebfe51c15/llvm/include/llvm/ADT/APInt.h#L125
This patch uses implictTruncate from APInt constructor to get around.
other approach could have been using direct mask(same effect as implicit
truncate) `AND` with Imm or use signed version (not applicable since
mask).
This case was generate using bisect so most of test excercises, i tried
with VPBLEND generating IR refuse to generate mask in range 0b10101010,
so patch lacks test.1 parent e438a90 commit 4ea1791
1 file changed
+2
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
| 264 | + | |
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
| |||
0 commit comments