| Issue |
173368
|
| Summary |
[InstCombine] X86TTIImpl::instCombineIntrinsic - add SimplifyDemandedBits handling for the blendv intrinsics
|
| Labels |
good first issue,
backend:X86,
llvm:instcombine
|
| Assignees |
|
| Reporter |
RKSimon
|
The blendv intrinsics (`Intrinsic::x86_sse41_pblendvb` etc) only demand the MSB of the mask operand, so we should try to call SimplifyDemandedBits to see if we can simplify the code (and more likely fold to a generic select/shuffle):
e.g.
```ll
define <8 x float> @blendv_shift_demanded(<8 x float> %a0, <8 x float> %a1, <8 x i32> %a2) {
%shl = or <8 x i32> %a2, splat (i32 1) ; irrelevant - mask only cares about the MSB
%mask = bitcast <8 x i32> %shl to <8 x float>
%res = tail call <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float> %a0, <8 x float> %a1, <8 x float> %mask)
ret <8 x float> %res
}
```
https://zig.godbolt.org/z/zr3Ev1jbT
blendv_shift_demanded can ignore the `or` instruction as its irrelevant to mask.
Other intrinsics in X86InstCombineIntrinsic.cpp already so something similar - we should probably only need a `IC.SimplifyDemandedBits(&II, 2, APInt::getSignMask(), KnownMask)` call - plus some decent test coverage
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs