Skip to content

Commit 7cbd5da

Browse files
RKSimonmahesh-attarde
authored andcommitted
[DAG] Add missing Depth argument to isGuaranteedNotToBeUndefOrPoison calls inside SimplifyDemanded methods (llvm#149550)
Ensure we don't exceed the maximum recursion depth
1 parent c73bb33 commit 7cbd5da

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ SDValue TargetLowering::SimplifyMultipleUseDemandedBits(
778778
case ISD::FREEZE: {
779779
SDValue N0 = Op.getOperand(0);
780780
if (DAG.isGuaranteedNotToBeUndefOrPoison(N0, DemandedElts,
781-
/*PoisonOnly=*/false))
781+
/*PoisonOnly=*/false, Depth + 1))
782782
return N0;
783783
break;
784784
}
@@ -3369,7 +3369,8 @@ bool TargetLowering::SimplifyDemandedVectorElts(
33693369
case ISD::FREEZE: {
33703370
SDValue N0 = Op.getOperand(0);
33713371
if (TLO.DAG.isGuaranteedNotToBeUndefOrPoison(N0, DemandedElts,
3372-
/*PoisonOnly=*/false))
3372+
/*PoisonOnly=*/false,
3373+
Depth + 1))
33733374
return TLO.CombineTo(Op, N0);
33743375

33753376
// TODO: Replace this with the general fold from DAGCombiner::visitFREEZE

llvm/test/CodeGen/X86/pr62286.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ define i64 @PR62286(i32 %a) {
4242
; AVX2-LABEL: PR62286:
4343
; AVX2: # %bb.0:
4444
; AVX2-NEXT: vmovd %edi, %xmm0
45-
; AVX2-NEXT: vpaddd %xmm0, %xmm0, %xmm1
46-
; AVX2-NEXT: vpslldq {{.*#+}} xmm0 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm0[0,1,2,3]
47-
; AVX2-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
48-
; AVX2-NEXT: vpblendd {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
45+
; AVX2-NEXT: vpslldq {{.*#+}} xmm1 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm0[0,1,2,3]
46+
; AVX2-NEXT: vpaddd %xmm0, %xmm0, %xmm0
47+
; AVX2-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
48+
; AVX2-NEXT: vpor %xmm0, %xmm1, %xmm0
4949
; AVX2-NEXT: vpmovsxdq %xmm0, %ymm0
5050
; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm1
5151
; AVX2-NEXT: vpaddq %xmm1, %xmm0, %xmm0

0 commit comments

Comments
 (0)