[llvm] [Transforms] LoopIdiomRecognize recognize strlen and wcslen (PR #108985)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 2 08:59:17 PDT 2024
================
@@ -0,0 +1,293 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -passes='loop-idiom' < %s -S | FileCheck %s
+
+declare void @use(ptr)
+
+define i64 @valid_strlen_1(ptr %0) {
+; CHECK-LABEL: define i64 @valid_strlen_1(
+; CHECK-SAME: ptr [[TMP0:%.*]]) {
+; CHECK-NEXT: [[STRLEN:%.*]] = call i64 @strlen(ptr [[TMP0]])
+; CHECK-NEXT: [[DOTLCSSA:%.*]] = getelementptr i8, ptr [[TMP0]], i64 [[STRLEN]]
+; CHECK-NEXT: br label %[[BB2:.*]]
+; CHECK: [[BB2]]:
+; CHECK-NEXT: [[TMP8:%.*]] = icmp eq i8 poison, 0
+; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds i8, ptr poison, i64 1
+; CHECK-NEXT: br i1 true, label %[[BB5:.*]], label %[[BB2]]
+; CHECK: [[BB5]]:
+; CHECK-NEXT: [[TMP12:%.*]] = ptrtoint ptr [[DOTLCSSA]] to i64
+; CHECK-NEXT: [[TMP13:%.*]] = ptrtoint ptr [[TMP0]] to i64
+; CHECK-NEXT: [[TMP14:%.*]] = sub i64 [[TMP12]], [[TMP13]]
+; CHECK-NEXT: ret i64 [[TMP14]]
+;
+ br label %2
+
+2: ; preds = %2, %1
----------------
Meinersbur wrote:
Could you run `opt -passes=instnamer -S` over the file? This often helps with tracking the origin of an instruction when FileCheck fails.
https://github.com/llvm/llvm-project/pull/108985
More information about the llvm-commits
mailing list