summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2018-10-01 16:25:50 +0000
committerMatthias Braun <matze@braunis.de>2018-10-01 16:25:50 +0000
commit004fe6bf8304f8bb55f260c0dc7a747ff21da894 (patch)
tree9de8e8575ec27dc8da09e24eb177aa1f3618eaee /llvm/lib/CodeGen/SelectionDAG
parente79451a5171e20c5da16a7f1a619c8851b9c574c (diff)
downloadbcm5719-llvm-004fe6bf8304f8bb55f260c0dc7a747ff21da894.tar.gz
bcm5719-llvm-004fe6bf8304f8bb55f260c0dc7a747ff21da894.zip
DAGCombiner: StoreMerging: Fix bad index calculating when adjusting mismatching vector types
This fixes a case of bad index calculation when merging mismatching vector types. This changes the existing code to just use the existing extract_{subvector|element} and a bitcast (instead of bitcast first and then newly created extract_xxx) so we don't need to adjust any indices in the first place. rdar://44584718 Differential Revision: https://reviews.llvm.org/D52681 llvm-svn: 343493
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 4ad84bc3f88..3872f2d0142 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -13916,26 +13916,17 @@ bool DAGCombiner::MergeStoresOfConstantsOrVecElts(
if ((MemVT != Val.getValueType()) &&
(Val.getOpcode() == ISD::EXTRACT_VECTOR_ELT ||
Val.getOpcode() == ISD::EXTRACT_SUBVECTOR)) {
- SDValue Vec = Val.getOperand(0);
EVT MemVTScalarTy = MemVT.getScalarType();
- SDValue Idx = Val.getOperand(1);
// We may need to add a bitcast here to get types to line up.
- if (MemVTScalarTy != Vec.getValueType()) {
- unsigned Elts = Vec.getValueType().getSizeInBits() /
- MemVTScalarTy.getSizeInBits();
- if (Val.getValueType().isVector() && MemVT.isVector()) {
- unsigned IdxC = cast<ConstantSDNode>(Idx)->getZExtValue();
- unsigned NewIdx =
- ((uint64_t)IdxC * MemVT.getVectorNumElements()) / Elts;
- Idx = DAG.getConstant(NewIdx, SDLoc(Val), Idx.getValueType());
- }
- EVT NewVecTy =
- EVT::getVectorVT(*DAG.getContext(), MemVTScalarTy, Elts);
- Vec = DAG.getBitcast(NewVecTy, Vec);
+ if (MemVTScalarTy != Val.getValueType().getScalarType()) {
+ Val = DAG.getBitcast(MemVT, Val);
+ } else {
+ unsigned OpC = MemVT.isVector() ? ISD::EXTRACT_SUBVECTOR
+ : ISD::EXTRACT_VECTOR_ELT;
+ SDValue Vec = Val.getOperand(0);
+ SDValue Idx = Val.getOperand(1);
+ Val = DAG.getNode(OpC, SDLoc(Val), MemVT, Vec, Idx);
}
- auto OpC = (MemVT.isVector()) ? ISD::EXTRACT_SUBVECTOR
- : ISD::EXTRACT_VECTOR_ELT;
- Val = DAG.getNode(OpC, SDLoc(Val), MemVT, Vec, Idx);
}
Ops.push_back(Val);
}
OpenPOWER on IntegriCloud