[PATCH] D66338: [CGP] Drop no op intrinsic calls
Dávid Bolvanský via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 17 09:34:33 PDT 2019
xbolva00 updated this revision to Diff 215747.
xbolva00 retitled this revision from "[CGP] Drop llvm.assume calls" to "[CGP] Drop no op intrinsic calls".
xbolva00 added a comment.
Moved to optimizeCallInst.
Drop var.annotation and sideeffect intrinsics too.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66338/new/
https://reviews.llvm.org/D66338
Files:
lib/CodeGen/CodeGenPrepare.cpp
test/Transforms/CodeGenPrepare/drop-intrinsics.ll
Index: test/Transforms/CodeGenPrepare/drop-intrinsics.ll
===================================================================
--- test/Transforms/CodeGenPrepare/drop-intrinsics.ll
+++ test/Transforms/CodeGenPrepare/drop-intrinsics.ll
@@ -0,0 +1,37 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -codegenprepare -S %s | FileCheck %s
+
+declare i32 @foo()
+declare i8* @bar()
+declare void @llvm.assume(i1)
+declare void @llvm.sideeffect()
+declare void @llvm.var.annotation(i8*, i8*, i8*, i32)
+
+define void @drop_llvm_assume() {
+; CHECK-LABEL: @drop_llvm_assume(
+; CHECK-NEXT: ret void
+;
+ %call = tail call i32 @foo() #0
+ %cmp = icmp eq i32 %call, 1
+ call void @llvm.assume(i1 %cmp)
+ ret void
+}
+
+define void @drop_llvm_sideeffect() {
+; CHECK-LABEL: @drop_llvm_sideeffect(
+; CHECK-NEXT: ret void
+;
+ call void @llvm.sideeffect()
+ ret void
+}
+
+define void @drop_llvm_var_annotation() {
+; CHECK-LABEL: @drop_llvm_var_annotation(
+; CHECK-NEXT: ret void
+;
+ %s = call i8* @bar() #0
+ call void @llvm.var.annotation(i8* %s, i8* null, i8* null, i32 0)
+ ret void
+}
+
+attributes #0 = { nounwind readnone }
Index: lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- lib/CodeGen/CodeGenPrepare.cpp
+++ lib/CodeGen/CodeGenPrepare.cpp
@@ -1853,6 +1853,17 @@
if (II) {
switch (II->getIntrinsicID()) {
default: break;
+ case Intrinsic::sideeffect: {
+ II->eraseFromParent();
+ return true;
+ }
+ case Intrinsic::assume:
+ case Intrinsic::var_annotation: {
+ Value *Arg = II->getOperand(0);
+ II->eraseFromParent();
+ RecursivelyDeleteTriviallyDeadInstructions(Arg);
+ return true;
+ }
case Intrinsic::experimental_widenable_condition: {
// Give up on future widening oppurtunties so that we can fold away dead
// paths and merge blocks before going into block-local instruction
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66338.215747.patch
Type: text/x-patch
Size: 1975 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190817/14cdcb98/attachment.bin>
More information about the llvm-commits
mailing list