summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaicheng Wu <haicheng@codeaurora.org>2016-02-17 21:00:06 +0000
committerHaicheng Wu <haicheng@codeaurora.org>2016-02-17 21:00:06 +0000
commit57e1a3e6eed86f689ef8f4bcdbdfda2bd7f52c4d (patch)
treef5d1b7fe7f22fb9ed3eb880922afb6dc1fec5737
parent394f1d4159d217113ef6e58ae9fec555838d8fed (diff)
downloadbcm5719-llvm-57e1a3e6eed86f689ef8f4bcdbdfda2bd7f52c4d.tar.gz
bcm5719-llvm-57e1a3e6eed86f689ef8f4bcdbdfda2bd7f52c4d.zip
[LIR] Avoid turning non-temporal stores into memset
This is to fix PR26645. llvm-svn: 261149
-rw-r--r--llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp4
-rw-r--r--llvm/test/Transforms/LoopIdiom/nontemporal_store.ll31
2 files changed, 35 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index 900cdae41d4..85b185b39b5 100644
--- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -314,6 +314,10 @@ bool LoopIdiomRecognize::isLegalStore(StoreInst *SI, bool &ForMemset,
if (!SI->isSimple())
return false;
+ // Avoid merging nontemporal stores.
+ if (SI->getMetadata(LLVMContext::MD_nontemporal))
+ return false;
+
Value *StoredVal = SI->getValueOperand();
Value *StorePtr = SI->getPointerOperand();
diff --git a/llvm/test/Transforms/LoopIdiom/nontemporal_store.ll b/llvm/test/Transforms/LoopIdiom/nontemporal_store.ll
new file mode 100644
index 00000000000..297f3d3851f
--- /dev/null
+++ b/llvm/test/Transforms/LoopIdiom/nontemporal_store.ll
@@ -0,0 +1,31 @@
+; RUN: opt -loop-idiom < %s -S | FileCheck %s
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.bigBlock_t = type { [256 x <4 x float>] }
+
+; CHECK-LABEL: @test(
+; CHECK-NOT: llvm.memset
+define void @test(%struct.bigBlock_t* %p) {
+entry:
+ %0 = getelementptr inbounds %struct.bigBlock_t, %struct.bigBlock_t* %p, i64 0, i32 0, i64 0, i64 0
+ br label %for.body
+
+for.body: ; preds = %entry, %for.body
+ %index.02 = phi i32 [ 0, %entry ], [ %add, %for.body ]
+ %dst.01 = phi float* [ %0, %entry ], [ %add.ptr2, %for.body ]
+ %cast.i5 = bitcast float* %dst.01 to <4 x float>*
+ store <4 x float> zeroinitializer, <4 x float>* %cast.i5, align 16, !nontemporal !0
+ %add.ptr1 = getelementptr inbounds float, float* %dst.01, i64 4
+ %cast.i = bitcast float* %add.ptr1 to <4 x float>*
+ store <4 x float> zeroinitializer, <4 x float>* %cast.i, align 16, !nontemporal !0
+ %add.ptr2 = getelementptr inbounds float, float* %dst.01, i64 8
+ %add = add nuw nsw i32 %index.02, 32
+ %cmp = icmp ult i32 %add, 4096
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end: ; preds = %for.body
+ ret void
+}
+
+!0 = !{i32 1}
OpenPOWER on IntegriCloud