[PATCH] D145896: [Metarenamer] Distinguish instruction by opcodes
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 14 21:35:23 PDT 2023
mkazantsev updated this revision to Diff 505360.
mkazantsev retitled this revision from "[Metarenamer] Distinguish phis and other instructions" to "[Metarenamer] Distinguish instruction by opcodes".
mkazantsev edited the summary of this revision.
mkazantsev added a comment.
Distinguished all instructions as Nikita has proposed, added test.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145896/new/
https://reviews.llvm.org/D145896
Files:
llvm/lib/Transforms/Utils/MetaRenamer.cpp
llvm/test/Transforms/MetaRenamer/opcodes.ll
Index: llvm/test/Transforms/MetaRenamer/opcodes.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/MetaRenamer/opcodes.ll
@@ -0,0 +1,45 @@
+; RUN: opt -passes=metarenamer -S < %s | FileCheck %s
+
+define void @opcodes(ptr %p, ptr %arr) {
+; CHECK-LABEL: bb:
+; CHECK: %load = load i32, ptr %arg, align 4
+; CHECK: br label %bb2
+; CHECK-LABEL: bb2: ; preds = %bb5, %bb
+; CHECK: %phi = phi i32 [ %load, %bb ], [ %sub, %bb5 ]
+; CHECK: %icmp = icmp eq i32 %phi, 0
+; CHECK: br i1 %icmp, label %bb8, label %bb3
+; CHECK-LABEL: bb3: ; preds = %bb2
+; CHECK: %sub = sub i32 %phi, 1
+; CHECK: %icmp4 = icmp ult i32 %sub, %load
+; CHECK: br i1 %icmp4, label %bb5, label %bb9
+; CHECK-LABEL: bb5: ; preds = %bb3
+; CHECK: %getelementptr = getelementptr i32, ptr %arg, i32 %phi
+; CHECK: %load6 = load i32, ptr %getelementptr, align 4
+; CHECK: %icmp7 = icmp eq i32 %load6, 0
+; CHECK: br i1 %icmp7, label %bb2, label %bb8
+preheader:
+ %len = load i32, ptr %p
+ br label %loop
+
+loop:
+ %iv = phi i32 [%len, %preheader], [%iv.next, %backedge]
+ %zero_cond = icmp eq i32 %iv, 0
+ br i1 %zero_cond, label %exit, label %range_check_block
+
+range_check_block:
+ %iv.next = sub i32 %iv, 1
+ %range_check = icmp ult i32 %iv.next, %len
+ br i1 %range_check, label %backedge, label %fail
+
+backedge:
+ %el.ptr = getelementptr i32, ptr %p, i32 %iv
+ %el = load i32, ptr %el.ptr
+ %loop.cond = icmp eq i32 %el, 0
+ br i1 %loop.cond, label %loop, label %exit
+
+exit:
+ ret void
+
+fail:
+ unreachable
+}
Index: llvm/lib/Transforms/Utils/MetaRenamer.cpp
===================================================================
--- llvm/lib/Transforms/Utils/MetaRenamer.cpp
+++ llvm/lib/Transforms/Utils/MetaRenamer.cpp
@@ -115,7 +115,7 @@
for (auto &I : BB)
if (!I.getType()->isVoidTy())
- I.setName("inst");
+ I.setName(I.getOpcodeName());
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145896.505360.patch
Type: text/x-patch
Size: 2163 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230315/4ae1fafe/attachment.bin>
More information about the llvm-commits
mailing list