| Issue |
164589
|
| Summary |
[DAG] SimplifyDemandedBits - ICMP_SLT(X,0) - only sign mask of X is required
|
| Labels |
good first issue,
missed-optimization,
llvm:SelectionDAG
|
| Assignees |
|
| Reporter |
RKSimon
|
Similar to what we did in #163981 for X86ISD::PCMPGT - when we are testing for a negative value, then we only need to demand the signbit
```ll
define <4 x i32> @select(<4 x i32> %x, <4 x i32> %y, <4 x i32> %a, <4 x i32> %b) {
%umax = tail call <4 x i32> @llvm.umax.v4i32(<4 x i32> %x, <4 x i32> %y)
%cmp = icmp sge <4 x i32> %umax, zeroinitializer
%res = select <4 x i1> %cmp, <4 x i32> %a, <4 x i32> %b
ret <4 x i32> %res
}
```
llvm -mcpu=x86-64-v4
```asm
select: # @select
vpmaxud %xmm1, %xmm0, %xmm0
vpxor %xmm1, %xmm1, %xmm1
vpcmpnltd %xmm1, %xmm0, %k1
vpblendmd %xmm2, %xmm3, %xmm0 {%k1}
retq
```
the VPMAXUD is unnecessary - could be:
```asm
select: # @select
vpor %xmm1, %xmm0, %xmm0
vpxor %xmm1, %xmm1, %xmm1
vpcmpnltd %xmm1, %xmm0, %k1
vpblendmd %xmm2, %xmm3, %xmm0 {%k1}
retq
```
We already have the ISD::UMAX -> ISD::OR simplification in place but we don't recursively call SimplifyDemandedBits from the ISD::SETCC node
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs