summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-09-07 05:33:03 +0000
committerChris Lattner <sabre@nondot.org>2007-09-07 05:33:03 +0000
commit85a51e0060d1081571bd961eb5205cdaa2efbf5b (patch)
tree99eb3fc0fef2d4d65d83f3e1a6b7cd87bcf8c0d5
parente2f23a3abf7518a27a3e4e0342093190496d1b9f (diff)
downloadbcm5719-llvm-85a51e0060d1081571bd961eb5205cdaa2efbf5b.tar.gz
bcm5719-llvm-85a51e0060d1081571bd961eb5205cdaa2efbf5b.zip
Don't zap back to back volatile load/stores
llvm-svn: 41759
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp2
-rw-r--r--llvm/test/Transforms/InstCombine/volatile_store.ll14
2 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 26df55531a8..f9abafa34c0 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -9066,7 +9066,7 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
// the pointer we're loading and is producing the pointer we're storing,
// then *this* store is dead (X = load P; store X -> P).
if (LoadInst *LI = dyn_cast<LoadInst>(BBI)) {
- if (LI == Val && LI->getOperand(0) == Ptr) {
+ if (LI == Val && LI->getOperand(0) == Ptr && !SI.isVolatile()) {
EraseInstFromFunction(SI);
++NumCombined;
return 0;
diff --git a/llvm/test/Transforms/InstCombine/volatile_store.ll b/llvm/test/Transforms/InstCombine/volatile_store.ll
new file mode 100644
index 00000000000..09651ba302d
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/volatile_store.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {volatile store}
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {volatile load}
+
+@x = weak global i32 0 ; <i32*> [#uses=2]
+
+define void @self_assign_1() {
+entry:
+ %tmp = volatile load i32* @x ; <i32> [#uses=1]
+ volatile store i32 %tmp, i32* @x
+ br label %return
+
+return: ; preds = %entry
+ ret void
+}
OpenPOWER on IntegriCloud