[PATCH] D85886: [SimplifyLibCalls] Remove over-eager early return in strlen optzns.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 07:20:28 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG419c6948df42: [SimplifyLibCalls] Remove over-eager early return in strlen optzns. (authored by fhahn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85886/new/

https://reviews.llvm.org/D85886

Files:
  llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
  llvm/test/Transforms/InstCombine/strlen-1.ll


Index: llvm/test/Transforms/InstCombine/strlen-1.ll
===================================================================
--- llvm/test/Transforms/InstCombine/strlen-1.ll
+++ llvm/test/Transforms/InstCombine/strlen-1.ll
@@ -223,9 +223,7 @@
 define i1 @strlen0_after_write_to_first_byte_global() {
 ; CHECK-LABEL: @strlen0_after_write_to_first_byte_global(
 ; CHECK-NEXT:    store i8 49, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @a, i32 0, i32 0), align 16
-; CHECK-NEXT:    [[LEN:%.*]] = tail call i32 @strlen(i8* nonnull dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @a, i32 0, i32 0))
-; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[LEN]], 0
-; CHECK-NEXT:    ret i1 [[CMP]]
+; CHECK-NEXT:    ret i1 false
 ;
   store i8 49, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @a, i64 0, i64 0), align 16
   %len = tail call i32 @strlen(i8* nonnull dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @a, i64 0, i64 0))
@@ -236,8 +234,8 @@
 define i1 @strlen0_after_write_to_second_byte_global() {
 ; CHECK-LABEL: @strlen0_after_write_to_second_byte_global(
 ; CHECK-NEXT:    store i8 49, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @a, i32 0, i32 1), align 16
-; CHECK-NEXT:    [[LEN:%.*]] = tail call i32 @strlen(i8* nonnull dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @a, i32 0, i32 0))
-; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[LEN]], 0
+; CHECK-NEXT:    [[STRLENFIRST:%.*]] = load i8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @a, i32 0, i32 0), align 1
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[STRLENFIRST]], 0
 ; CHECK-NEXT:    ret i1 [[CMP]]
 ;
   store i8 49, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @a, i64 0, i64 1), align 16
Index: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -693,8 +693,6 @@
                            Offset);
       }
     }
-
-    return nullptr;
   }
 
   // strlen(x?"foo":"bars") --> x ? 3 : 4


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85886.288324.patch
Type: text/x-patch
Size: 2097 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200827/f4a82956/attachment.bin>


More information about the llvm-commits mailing list