[PATCH] D32423: Simplify barriers of null and undef
Piotr Padlewski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 24 11:57:47 PDT 2017
Prazek updated this revision to Diff 96437.
Prazek marked 4 inline comments as done.
Prazek added a comment.
moved to constant folder
https://reviews.llvm.org/D32423
Files:
lib/Analysis/ConstantFolding.cpp
test/Transforms/InstCombine/invariant.group.ll
Index: test/Transforms/InstCombine/invariant.group.ll
===================================================================
--- /dev/null
+++ test/Transforms/InstCombine/invariant.group.ll
@@ -0,0 +1,17 @@
+; RUN: opt -instcombine -S < %s | FileCheck %s
+
+; 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 i8* @llvm.invariant.group.barrier(i8*)
Index: lib/Analysis/ConstantFolding.cpp
===================================================================
--- lib/Analysis/ConstantFolding.cpp
+++ lib/Analysis/ConstantFolding.cpp
@@ -1379,6 +1379,7 @@
case Intrinsic::fma:
case Intrinsic::fmuladd:
case Intrinsic::copysign:
+ case Intrinsic::invariant_group_barrier:
case Intrinsic::round:
case Intrinsic::masked_load:
case Intrinsic::sadd_with_overflow:
@@ -1769,7 +1770,14 @@
if (isa<UndefValue>(Operands[0])) {
if (IntrinsicID == Intrinsic::bswap ||
- IntrinsicID == Intrinsic::bitreverse)
+ IntrinsicID == Intrinsic::bitreverse ||
+ IntrinsicID == Intrinsic::invariant_group_barrier)
+ return Operands[0];
+ return nullptr;
+ }
+
+ if (isa<ConstantPointerNull>(Operands[0])) {
+ if (IntrinsicID == Intrinsic::invariant_group_barrier)
return Operands[0];
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32423.96437.patch
Type: text/x-patch
Size: 1621 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170424/cc1b362e/attachment.bin>
More information about the llvm-commits
mailing list