[PATCH] D32423: Simplify barriers of null and undef
Piotr Padlewski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 24 02:34:08 PDT 2017
Prazek created this revision.
This might be useful because clang will add
barriers for pointer comparisons.
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
@@ -483,6 +483,20 @@
ret void
}
+; CHECK-LABEL: define i8* @siplifyNullBarrier()
+define i8* @siplifyNullBarrier() {
+; CHECK: ret i8* null
+ %b2 = call i8* @llvm.invariant.group.barrier(i8* null)
+ ret i8* %b2
+}
+
+; CHECK-LABEL: define i8* @siplifyUndefBarrier()
+define i8* @siplifyUndefBarrier() {
+; CHECK: 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.96358.patch
Type: text/x-patch
Size: 1268 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170424/d713ec50/attachment.bin>
More information about the llvm-commits
mailing list