summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2016-07-03 19:37:12 +0000
committerCraig Topper <craig.topper@gmail.com>2016-07-03 19:37:12 +0000
commitd1eca0f32ca5b85af6d17174a2824657a2eeb41b (patch)
treed3c733b3c69f239192786bf20fdd495b504e3031 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent8e826d5abe6131d1de94f8ac0eb42ce66862cd7b (diff)
downloadbcm5719-llvm-d1eca0f32ca5b85af6d17174a2824657a2eeb41b.tar.gz
bcm5719-llvm-d1eca0f32ca5b85af6d17174a2824657a2eeb41b.zip
[CodeGen] Teach OR combine of shuffles involving zero vectors to better handle undef indices.
Undef indices can now be treated as zeros. Or if its undef ORed with zero, we will keep the undef. llvm-svn: 274472
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 0f351975b9d..a8a76311225 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3775,20 +3775,25 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
int M0 = SV0->getMaskElt(i);
int M1 = SV1->getMaskElt(i);
- // Both shuffle indexes are undef. Propagate Undef.
- if (M0 < 0 && M1 < 0) {
+ // Determine if either index is pointing to a zero vector.
+ bool M0Zero = M0 < 0 || (ZeroN00 == (M0 < NumElts));
+ bool M1Zero = M1 < 0 || (ZeroN10 == (M1 < NumElts));
+
+ // If one element is zero and the otherside is undef, keep undef.
+ // This also handles the case that both are undef.
+ if ((M0Zero && M1 < 0) || (M1Zero && M0 < 0)) {
Mask[i] = -1;
continue;
}
- // Determine if either index is pointing to a zero vector.
- bool M0Zero = M0 >= 0 && (ZeroN00 == (M0 < NumElts));
- bool M1Zero = M1 >= 0 && (ZeroN10 == (M1 < NumElts));
+ // Make sure only one of the elements is zero.
if (M0Zero == M1Zero) {
CanFold = false;
break;
}
+ assert((M0 >= 0 || M1 >= 0) && "Undef index!");
+
// We have a zero and non-zero element. If the non-zero came from
// SV0 make the index a LHS index. If it came from SV1, make it
// a RHS index. We need to mod by NumElts because we don't care
OpenPOWER on IntegriCloud