[PATCH] D32423: Simplify barriers of null and undef

Piotr Padlewski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 24 08:23:22 PDT 2017


Prazek updated this revision to Diff 96400.
Prazek marked 2 inline comments as done.
Prazek added a comment.

- check-next


https://reviews.llvm.org/D32423

Files:
  lib/Analysis/InstructionSimplify.cpp
  test/Transforms/GVN/invariant.group.ll


Index: test/Transforms/GVN/invariant.group.ll
===================================================================
--- test/Transforms/GVN/invariant.group.ll
+++ test/Transforms/GVN/invariant.group.ll
@@ -486,6 +486,20 @@
   ret void
 }
 
+; CHECK-LABEL: define i8* @siplifyNullBarrier()
+define i8* @siplifyNullBarrier() {
+; CHECK-NEXT: ret i8* null
+  %b2 = call i8* @llvm.invariant.group.barrier(i8* null)
+  ret i8* %b2
+}
+
+; CHECK-LABEL: define i8* @siplifyUndefBarrier()
+define i8* @siplifyUndefBarrier() {
+; CHECK-NEXT: ret i8* undef
+  %b2 = call i8* @llvm.invariant.group.barrier(i8* undef)
+  ret i8* %b2
+}
+
 
 declare void @foo(i8*)
 declare void @foo2(i8*, i8)
Index: lib/Analysis/InstructionSimplify.cpp
===================================================================
--- lib/Analysis/InstructionSimplify.cpp
+++ lib/Analysis/InstructionSimplify.cpp
@@ -4429,6 +4429,13 @@
         return *ArgBegin;
       return nullptr;
     }
+    case Intrinsic::invariant_group_barrier: {
+      // invariant.group.barrier(null) -> null
+      // invariant.group.barrier(undef) -> undef
+      if (isa<UndefValue>(*ArgBegin) || isa<ConstantPointerNull>(*ArgBegin))
+        return *ArgBegin;
+      return nullptr;
+    }
     default:
       return nullptr;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32423.96400.patch
Type: text/x-patch
Size: 1278 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170424/eb86b220/attachment.bin>


More information about the llvm-commits mailing list