[llvm] r279961 - Fixed a bug in type legalizer for masked gather.
Igor Breger via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 29 02:12:32 PDT 2016
Author: ibreger
Date: Mon Aug 29 04:12:31 2016
New Revision: 279961
URL: http://llvm.org/viewvc/llvm-project?rev=279961&view=rev
Log:
Fixed a bug in type legalizer for masked gather.
The problem occurs when the Node doesn't updated in place , UpdateNodeOperation() return the node that already exist.
In this case assert fail in PromoteIntegerOperand() , N have 2 results ( val + chain).
Differential Revision: http://reviews.llvm.org/D23756
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/trunk/test/CodeGen/X86/masked_gather_scatter.ll
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=279961&r1=279960&r2=279961&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Mon Aug 29 04:12:31 2016
@@ -1235,7 +1235,15 @@ SDValue DAGTypeLegalizer::PromoteIntOp_M
NewOps[OpNo] = PromoteTargetBoolean(N->getOperand(OpNo), DataVT);
} else
NewOps[OpNo] = GetPromotedInteger(N->getOperand(OpNo));
- return SDValue(DAG.UpdateNodeOperands(N, NewOps), 0);
+
+ SDValue Res = SDValue(DAG.UpdateNodeOperands(N, NewOps), 0);
+ // updated in place.
+ if (Res.getNode() == N)
+ return Res;
+
+ ReplaceValueWith(SDValue(N, 0), Res.getValue(0));
+ ReplaceValueWith(SDValue(N, 1), Res.getValue(1));
+ return SDValue();
}
SDValue DAGTypeLegalizer::PromoteIntOp_MSCATTER(MaskedScatterSDNode *N,
Modified: llvm/trunk/test/CodeGen/X86/masked_gather_scatter.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/masked_gather_scatter.ll?rev=279961&r1=279960&r2=279961&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/masked_gather_scatter.ll (original)
+++ llvm/trunk/test/CodeGen/X86/masked_gather_scatter.ll Mon Aug 29 04:12:31 2016
@@ -2240,3 +2240,36 @@ define void @test_scatter_16f64(<16 x do
ret void
}
declare void @llvm.masked.scatter.v16f64(<16 x double> %src0, <16 x double*> %ptrs, i32, <16 x i1> %mask)
+
+define <4 x i64> @test_pr28312(<4 x i64*> %p1, <4 x i1> %k, <4 x i1> %k2,<4 x i64> %d) {
+; SKX-LABEL: test_pr28312:
+; SKX: # BB#0:
+; SKX-NEXT: vpslld $31, %xmm1, %xmm1
+; SKX-NEXT: vptestmd %xmm1, %xmm1, %k1
+; SKX-NEXT: vpgatherqq (,%ymm0), %ymm1 {%k1}
+; SKX-NEXT: vpaddq %ymm1, %ymm1, %ymm0
+; SKX-NEXT: vpaddq %ymm0, %ymm1, %ymm0
+; SKX-NEXT: retq
+;
+; KNL_64-LABEL: test_pr28312:
+; KNL_64: # BB#0:
+; KNL_64-NEXT: # kill: %YMM0<def> %YMM0<kill> %ZMM0<def>
+; KNL_64-NEXT: vpslld $31, %xmm1, %xmm1
+; KNL_64-NEXT: vpsrad $31, %xmm1, %xmm1
+; KNL_64-NEXT: vpmovsxdq %xmm1, %ymm1
+; KNL_64-NEXT: vpxord %zmm2, %zmm2, %zmm2
+; KNL_64-NEXT: vinserti64x4 $0, %ymm1, %zmm2, %zmm1
+; KNL_64-NEXT: vpsllq $63, %zmm1, %zmm1
+; KNL_64-NEXT: vptestmq %zmm1, %zmm1, %k1
+; KNL_64-NEXT: vpgatherqq (,%zmm0), %zmm1 {%k1}
+; KNL_64-NEXT: vpaddq %ymm1, %ymm1, %ymm0
+; KNL_64-NEXT: vpaddq %ymm0, %ymm1, %ymm0
+; KNL_64-NEXT: retq
+ %g1 = call <4 x i64> @llvm.masked.gather.v4i64(<4 x i64*> %p1, i32 8, <4 x i1> %k, <4 x i64> undef)
+ %g2 = call <4 x i64> @llvm.masked.gather.v4i64(<4 x i64*> %p1, i32 8, <4 x i1> %k, <4 x i64> undef)
+ %g3 = call <4 x i64> @llvm.masked.gather.v4i64(<4 x i64*> %p1, i32 8, <4 x i1> %k, <4 x i64> undef)
+ %a = add <4 x i64> %g1, %g2
+ %b = add <4 x i64> %a, %g3
+ ret <4 x i64> %b
+}
+declare <4 x i64> @llvm.masked.gather.v4i64(<4 x i64*>, i32, <4 x i1>, <4 x i64>)
More information about the llvm-commits
mailing list