[PATCH] D51589: DAG: Fold extract_vector_elt (scalar_to_vector), K to undef
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 3 05:44:55 PDT 2018
arsenm created this revision.
arsenm added a reviewer: RKSimon.
Herald added a subscriber: wdng.
This was unconditionally folding this to the source operand,
even if the access was out of bounds. Use undef instead of
the extract is not the first element.
This helps with some cases where 3-vectors are legalized
and avoids processing the 4th component.
Avoids regressions in a future commit.
https://reviews.llvm.org/D51589
Files:
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -15237,7 +15237,13 @@
if (InVec.isUndef())
return DAG.getUNDEF(NVT);
+ SDValue EltNo = N->getOperand(1);
+ ConstantSDNode *ConstEltNo = dyn_cast<ConstantSDNode>(EltNo);
+
if (InVec.getOpcode() == ISD::SCALAR_TO_VECTOR) {
+ if (ConstEltNo && !ConstEltNo->getAPIntValue().isNullValue())
+ return DAG.getUNDEF(NVT);
+
// Check if the result type doesn't match the inserted element type. A
// SCALAR_TO_VECTOR may truncate the inserted element and the
// EXTRACT_VECTOR_ELT may widen the extracted vector.
@@ -15249,9 +15255,6 @@
return InOp;
}
- SDValue EltNo = N->getOperand(1);
- ConstantSDNode *ConstEltNo = dyn_cast<ConstantSDNode>(EltNo);
-
// extract_vector_elt of out-of-bounds element -> UNDEF
if (ConstEltNo && ConstEltNo->getAPIntValue().uge(VT.getVectorNumElements()))
return DAG.getUNDEF(NVT);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51589.163700.patch
Type: text/x-patch
Size: 1073 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180903/056a3571/attachment.bin>
More information about the llvm-commits
mailing list