[PATCH] D103173: [DAGCombine][RISCV] Don't try to trunc-store combined vector stores
Fraser Cormack via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 27 02:19:13 PDT 2021
frasercrmck updated this revision to Diff 348191.
frasercrmck added a comment.
- rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103173/new/
https://reviews.llvm.org/D103173
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/rvv/combine-store-fp.ll
Index: llvm/test/CodeGen/RISCV/rvv/combine-store-fp.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rvv/combine-store-fp.ll
@@ -0,0 +1,18 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+d,+experimental-v -verify-machineinstrs -riscv-v-vector-bits-min=128 < %s | FileCheck %s
+; RUN: llc -mtriple=riscv64 -mattr=+d,+experimental-v -verify-machineinstrs -riscv-v-vector-bits-min=128 < %s | FileCheck %s
+
+define void @combine_fp_zero_stores_crash(float* %ptr) {
+; CHECK-LABEL: combine_fp_zero_stores_crash:
+; CHECK: # %bb.0:
+; CHECK-NEXT: addi a0, a0, 4
+; CHECK-NEXT: vsetivli zero, 2, e32,mf2,ta,mu
+; CHECK-NEXT: vmv.v.i v25, 0
+; CHECK-NEXT: vse32.v v25, (a0)
+; CHECK-NEXT: ret
+ %addr1 = getelementptr float, float * %ptr, i64 1
+ %addr2 = getelementptr float, float * %ptr, i64 2
+ store float 0.000000e+00, float * %addr1, align 4
+ store float 0.000000e+00, float * %addr2, align 4
+ ret void
+}
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -8414,7 +8414,7 @@
bool RISCVTargetLowering::allowsMisalignedMemoryAccesses(
EVT VT, unsigned AddrSpace, Align Alignment, MachineMemOperand::Flags Flags,
bool *Fast) const {
- if (!VT.isScalableVector())
+ if (!VT.isVector())
return false;
EVT ElemVT = VT.getVectorElementType();
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -16726,6 +16726,9 @@
if (NumStores < 2)
return false;
+ assert((!UseTrunc || !UseVector) &&
+ "This optimization cannot emit a vector truncating store");
+
// The latest Node in the DAG.
SDLoc DL(StoreNodes[0].MemNode);
@@ -17221,6 +17224,7 @@
bool UseVector = (LastLegalVectorType > LastLegalType) && AllowVectors;
unsigned NumElem = (UseVector) ? LastLegalVectorType : LastLegalType;
+ bool UseTrunc = LastIntegerTrunc && !UseVector;
// Check if we found a legal integer type that creates a meaningful
// merge.
@@ -17251,8 +17255,9 @@
continue;
}
- MadeChange |= mergeStoresOfConstantsOrVecElts(
- StoreNodes, MemVT, NumElem, true, UseVector, LastIntegerTrunc);
+ MadeChange |= mergeStoresOfConstantsOrVecElts(StoreNodes, MemVT, NumElem,
+ /*IsConstantSrc*/ true,
+ UseVector, UseTrunc);
// Remove merged stores for next iteration.
StoreNodes.erase(StoreNodes.begin(), StoreNodes.begin() + NumElem);
@@ -17321,7 +17326,8 @@
}
MadeChange |= mergeStoresOfConstantsOrVecElts(
- StoreNodes, MemVT, NumStoresToMerge, false, true, false);
+ StoreNodes, MemVT, NumStoresToMerge, /*IsConstantSrc*/ false,
+ /*UseVector*/ true, /*UseTrunc*/ false);
StoreNodes.erase(StoreNodes.begin(), StoreNodes.begin() + NumStoresToMerge);
NumConsecutiveStores -= NumStoresToMerge;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103173.348191.patch
Type: text/x-patch
Size: 3313 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210527/234b088f/attachment.bin>
More information about the llvm-commits
mailing list