Skip to content

Commit 67a399f

Browse files
committed
[X86] SimplifyDemandedBits - add X86ISD::BLENDV SimplifyMultipleUseDemandedBits handling
Lets us see through multiple use operands
1 parent 7e849fd commit 67a399f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40906,6 +40906,28 @@ bool X86TargetLowering::SimplifyDemandedBitsForTargetNode(
4090640906
Known.One.setHighBits(ShAmt);
4090740907
return false;
4090840908
}
40909+
case X86ISD::BLENDV: {
40910+
SDValue Sel = Op.getOperand(0);
40911+
SDValue LHS = Op.getOperand(1);
40912+
SDValue RHS = Op.getOperand(2);
40913+
40914+
APInt SignMask = APInt::getSignMask(BitWidth);
40915+
SDValue NewSel = SimplifyMultipleUseDemandedBits(
40916+
Sel, SignMask, OriginalDemandedElts, TLO.DAG, Depth + 1);
40917+
SDValue NewLHS = SimplifyMultipleUseDemandedBits(
40918+
LHS, OriginalDemandedBits, OriginalDemandedElts, TLO.DAG, Depth + 1);
40919+
SDValue NewRHS = SimplifyMultipleUseDemandedBits(
40920+
RHS, OriginalDemandedBits, OriginalDemandedElts, TLO.DAG, Depth + 1);
40921+
40922+
if (NewSel || NewLHS || NewRHS) {
40923+
NewSel = NewSel ? NewSel : Sel;
40924+
NewLHS = NewLHS ? NewLHS : LHS;
40925+
NewRHS = NewRHS ? NewRHS : RHS;
40926+
return TLO.CombineTo(Op, TLO.DAG.getNode(X86ISD::BLENDV, SDLoc(Op), VT,
40927+
NewSel, NewLHS, NewRHS));
40928+
}
40929+
break;
40930+
}
4090940931
case X86ISD::PEXTRB:
4091040932
case X86ISD::PEXTRW: {
4091140933
SDValue Vec = Op.getOperand(0);

llvm/test/CodeGen/X86/vselect.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,8 @@ define <2 x i64> @shrunkblend_nonvselectuse(<2 x i1> %cond, <2 x i64> %a, <2 x i
535535
; SSE41-LABEL: shrunkblend_nonvselectuse:
536536
; SSE41: # %bb.0:
537537
; SSE41-NEXT: psllq $63, %xmm0
538-
; SSE41-NEXT: psrad $31, %xmm0
539538
; SSE41-NEXT: blendvpd %xmm0, %xmm1, %xmm2
539+
; SSE41-NEXT: psrad $31, %xmm0
540540
; SSE41-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
541541
; SSE41-NEXT: paddq %xmm2, %xmm0
542542
; SSE41-NEXT: retq

0 commit comments

Comments
 (0)