[PATCH] D27573: [X86] Fix bug in r288804.
Ayman Musa via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 8 07:29:19 PST 2016
aymanmus created this revision.
aymanmus added reviewers: mkuper, RKSimon, spatel, zvi.
aymanmus added a subscriber: llvm-commits.
When creating the load from constant pool, check if there was already a load to the same constant, and abort if found.
The additional use of the load will prevent the pattern from memory folding the broadcast.
https://reviews.llvm.org/D27573
Files:
lib/Target/X86/X86ISelLowering.cpp
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -6394,6 +6394,7 @@
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
LLVMContext *Ctx = DAG.getContext();
MVT PVT = TLI.getPointerTy(DAG.getDataLayout());
+ SDValue Brdcst;
if (Subtarget.hasAVX()) {
if (SplatBitSize <= 64 && Subtarget.hasAVX2() &&
!(SplatBitSize == 64 && Subtarget.is32Bit())) {
@@ -6410,9 +6411,8 @@
CVT, dl, DAG.getEntryNode(), CP,
MachinePointerInfo::getConstantPool(DAG.getMachineFunction()),
Alignment);
- SDValue Brdcst = DAG.getNode(X86ISD::VBROADCAST, dl,
+ Brdcst = DAG.getNode(X86ISD::VBROADCAST, dl,
MVT::getVectorVT(CVT, Repeat), Ld);
- return DAG.getBitcast(VT, Brdcst);
} else if (SplatBitSize == 32 || SplatBitSize == 64) {
// Splatted value can fit in one FLOAT constant in constant pool.
// Load the constant and broadcast it.
@@ -6432,9 +6432,8 @@
CVT, dl, DAG.getEntryNode(), CP,
MachinePointerInfo::getConstantPool(DAG.getMachineFunction()),
Alignment);
- SDValue Brdcst = DAG.getNode(X86ISD::VBROADCAST, dl,
+ Brdcst = DAG.getNode(X86ISD::VBROADCAST, dl,
MVT::getVectorVT(CVT, Repeat), Ld);
- return DAG.getBitcast(VT, Brdcst);
} else if (SplatBitSize > 64) {
// Load the vector of constants and broadcast it.
MVT CVT = VT.getScalarType();
@@ -6447,9 +6446,15 @@
MVT::getVectorVT(CVT, NumElm), dl, DAG.getEntryNode(), VCP,
MachinePointerInfo::getConstantPool(DAG.getMachineFunction()),
Alignment);
- SDValue Brdcst = DAG.getNode(X86ISD::SUBV_BROADCAST, dl, VT, Ld);
- return DAG.getBitcast(VT, Brdcst);
+ Brdcst = DAG.getNode(X86ISD::SUBV_BROADCAST, dl, VT, Ld);
+ } else {
+ return SDValue();
}
+ // If the load already had a use, we can't fold it into the broadcast.
+ // So fallback to the original state.
+ if (!Ld.hasOneUse())
+ return SDValue();
+ return DAG.getBitcast(VT, Brdcst);
}
}
return SDValue();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27573.80760.patch
Type: text/x-patch
Size: 2439 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161208/d02abc59/attachment.bin>
More information about the llvm-commits
mailing list