[llvm-commits] [llvm] r41759 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/volatile_store.ll
Chris Lattner
sabre at nondot.org
Thu Sep 6 22:33:03 PDT 2007
Author: lattner
Date: Fri Sep 7 00:33:03 2007
New Revision: 41759
URL: http://llvm.org/viewvc/llvm-project?rev=41759&view=rev
Log:
Don't zap back to back volatile load/stores
Added:
llvm/trunk/test/Transforms/InstCombine/volatile_store.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=41759&r1=41758&r2=41759&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Fri Sep 7 00:33:03 2007
@@ -9066,7 +9066,7 @@
// 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;
Added: llvm/trunk/test/Transforms/InstCombine/volatile_store.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/volatile_store.ll?rev=41759&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/volatile_store.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/volatile_store.ll Fri Sep 7 00:33:03 2007
@@ -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}
+
+ at 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
+}
More information about the llvm-commits
mailing list