[llvm] r275340 - [DAG] Correctly chain masked loads
Michael Kuperstein via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 13 16:23:40 PDT 2016
Author: mkuper
Date: Wed Jul 13 18:23:40 2016
New Revision: 275340
URL: http://llvm.org/viewvc/llvm-project?rev=275340&view=rev
Log:
[DAG] Correctly chain masked loads
If a masked loads is not added to the chain, it should not reset the chain's
root.
This fixes the remaining part of PR28515.
Added:
llvm/trunk/test/CodeGen/X86/pr28515.ll
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=275340&r1=275339&r2=275340&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Wed Jul 13 18:23:40 2016
@@ -3831,13 +3831,10 @@ void SelectionDAGBuilder::visitMaskedLoa
I.getAAMetadata(AAInfo);
const MDNode *Ranges = I.getMetadata(LLVMContext::MD_range);
- SDValue InChain = DAG.getRoot();
- if (AA->pointsToConstantMemory(MemoryLocation(
- PtrOperand, DAG.getDataLayout().getTypeStoreSize(I.getType()),
- AAInfo))) {
- // Do not serialize (non-volatile) loads of constant memory with anything.
- InChain = DAG.getEntryNode();
- }
+ // Do not serialize masked loads of constant memory with anything.
+ bool AddToChain = !AA->pointsToConstantMemory(MemoryLocation(
+ PtrOperand, DAG.getDataLayout().getTypeStoreSize(I.getType()), AAInfo));
+ SDValue InChain = AddToChain ? DAG.getRoot() : InChain = DAG.getEntryNode();
MachineMemOperand *MMO =
DAG.getMachineFunction().
@@ -3847,8 +3844,10 @@ void SelectionDAGBuilder::visitMaskedLoa
SDValue Load = DAG.getMaskedLoad(VT, sdl, InChain, Ptr, Mask, Src0, VT, MMO,
ISD::NON_EXTLOAD);
- SDValue OutChain = Load.getValue(1);
- DAG.setRoot(OutChain);
+ if (AddToChain) {
+ SDValue OutChain = Load.getValue(1);
+ DAG.setRoot(OutChain);
+ }
setValue(&I, Load);
}
Added: llvm/trunk/test/CodeGen/X86/pr28515.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr28515.ll?rev=275340&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/pr28515.ll (added)
+++ llvm/trunk/test/CodeGen/X86/pr28515.ll Wed Jul 13 18:23:40 2016
@@ -0,0 +1,16 @@
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 | FileCheck %s
+
+ at 0 = private constant [8 x i32] zeroinitializer
+
+; CHECK-LABEL: foo:
+; CHECK: movl %esi, (%rdi)
+; CHECK-NEXT: retq
+define void @foo(i32* %p, i32 %v, <8 x i1> %mask) {
+ store i32 %v, i32* %p
+ %wide.masked.load = call <8 x i32> @llvm.masked.load.v8i32.p0v8i32(<8 x i32>* bitcast (i32* getelementptr ([8 x i32], [8 x i32]* @0, i64 0, i64 0) to <8 x i32>*), i32 4, <8 x i1> %mask, <8 x i32> undef)
+ ret void
+}
+
+declare <8 x i32> @llvm.masked.load.v8i32.p0v8i32(<8 x i32>*, i32, <8 x i1>, <8 x i32>) #0
+
+attributes #0 = { argmemonly nounwind readonly }
More information about the llvm-commits
mailing list