[PATCH] D27493: [GVNHoist] Invalidate MemDep when an instruction is moved.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 12:07:43 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL288968: [GVNHoist] Invalidate MemDep when an instruction is moved. (authored by efriedma).

Changed prior to commit:
  https://reviews.llvm.org/D27493?vs=80507&id=80639#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27493

Files:
  llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
  llvm/trunk/test/Transforms/GVNHoist/hoist.ll


Index: llvm/trunk/test/Transforms/GVNHoist/hoist.ll
===================================================================
--- llvm/trunk/test/Transforms/GVNHoist/hoist.ll
+++ llvm/trunk/test/Transforms/GVNHoist/hoist.ll
@@ -711,3 +711,36 @@
 ; CHECK: %[[load:.*]] = load i32, i32* %y, align 1
 ; CHECK: %[[phi:.*]] = phi i32 [ %[[load]], %{{.*}} ], [ %[[load]], %{{.*}} ]
 ; CHECK: i32 %[[phi]]
+
+
+declare i8 @pr30991_f() nounwind readonly
+declare void @pr30991_f1(i8)
+define i8 @pr30991(i8* %sp, i8* %word, i1 %b1, i1 %b2) {
+entry:
+  br i1 %b1, label %a, label %b
+
+a:
+  %r0 = load i8, i8* %word, align 1
+  %incdec.ptr = getelementptr i8, i8* %sp, i32 1
+  %rr0 = call i8 @pr30991_f() nounwind readonly
+  call void @pr30991_f1(i8 %r0)
+  ret i8 %rr0
+
+b:
+  br i1 %b2, label %c, label %x
+
+c:
+  %r1 = load i8, i8* %word, align 1
+  %incdec.ptr115 = getelementptr i8, i8* %sp, i32 1
+  %rr1 = call i8 @pr30991_f() nounwind readonly
+  call void @pr30991_f1(i8 %r1)
+  ret i8 %rr1
+
+x:
+  %r2 = load i8, i8* %word, align 1
+  ret i8 %r2
+}
+
+; CHECK-LABEL: define i8 @pr30991
+; CHECK:  %r0 = load i8, i8* %word, align 1
+; CHECK-NEXT:  br i1 %b1, label %a, label %b
Index: llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
+++ llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
@@ -802,6 +802,7 @@
 
         // Move the instruction at the end of HoistPt.
         Instruction *Last = HoistPt->getTerminator();
+        MD->removeInstruction(Repl);
         Repl->moveBefore(Last);
 
         DFSNumber[Repl] = DFSNumber[Last]++;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27493.80639.patch
Type: text/x-patch
Size: 1652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161207/ecfb1d4b/attachment.bin>


More information about the llvm-commits mailing list