forked from OSchip/llvm-project
[InstCombine] Add strlen of gep test without inbounds (NFC)
This commit is contained in:
parent
c292b6066c
commit
154609b1df
|
@ -113,8 +113,8 @@ define i32 @test_simplify9(i1 %x) {
|
|||
; Check the case that should be simplified to a sub instruction.
|
||||
; strlen(@hello + x) --> 5 - x
|
||||
|
||||
define i32 @test_simplify10(i32 %x) {
|
||||
; CHECK-LABEL: @test_simplify10(
|
||||
define i32 @test_simplify10_inbounds(i32 %x) {
|
||||
; CHECK-LABEL: @test_simplify10_inbounds(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = sub i32 5, [[X:%.*]]
|
||||
; CHECK-NEXT: ret i32 [[TMP1]]
|
||||
;
|
||||
|
@ -123,6 +123,17 @@ define i32 @test_simplify10(i32 %x) {
|
|||
ret i32 %hello_l
|
||||
}
|
||||
|
||||
define i32 @test_simplify10_no_inbounds(i32 %x) {
|
||||
; CHECK-LABEL: @test_simplify10_no_inbounds(
|
||||
; CHECK-NEXT: [[HELLO_P:%.*]] = getelementptr [6 x i8], [6 x i8]* @hello, i32 0, i32 [[X:%.*]]
|
||||
; CHECK-NEXT: [[HELLO_L:%.*]] = call i32 @strlen(i8* noundef nonnull dereferenceable(1) [[HELLO_P]])
|
||||
; CHECK-NEXT: ret i32 [[HELLO_L]]
|
||||
;
|
||||
%hello_p = getelementptr [6 x i8], [6 x i8]* @hello, i32 0, i32 %x
|
||||
%hello_l = call i32 @strlen(i8* %hello_p)
|
||||
ret i32 %hello_l
|
||||
}
|
||||
|
||||
; strlen(@null_hello_mid + (x & 7)) --> 9 - (x & 7)
|
||||
|
||||
define i32 @test_simplify11(i32 %x) {
|
||||
|
@ -203,7 +214,7 @@ define i32 @test_no_simplify3_on_null_opt(i32 %x) #0 {
|
|||
|
||||
define i32 @test1(i8* %str) {
|
||||
; CHECK-LABEL: @test1(
|
||||
; CHECK-NEXT: [[LEN:%.*]] = tail call i32 @strlen(i8* noundef nonnull dereferenceable(1) [[STR:%.*]]) [[ATTR1:#.*]]
|
||||
; CHECK-NEXT: [[LEN:%.*]] = tail call i32 @strlen(i8* noundef nonnull dereferenceable(1) [[STR:%.*]]) #[[ATTR1:[0-9]+]]
|
||||
; CHECK-NEXT: ret i32 [[LEN]]
|
||||
;
|
||||
%len = tail call i32 @strlen(i8* %str) nounwind
|
||||
|
@ -212,7 +223,7 @@ define i32 @test1(i8* %str) {
|
|||
|
||||
define i32 @test2(i8* %str) #0 {
|
||||
; CHECK-LABEL: @test2(
|
||||
; CHECK-NEXT: [[LEN:%.*]] = tail call i32 @strlen(i8* noundef [[STR:%.*]]) [[ATTR1]]
|
||||
; CHECK-NEXT: [[LEN:%.*]] = tail call i32 @strlen(i8* noundef [[STR:%.*]]) #[[ATTR1]]
|
||||
; CHECK-NEXT: ret i32 [[LEN]]
|
||||
;
|
||||
%len = tail call i32 @strlen(i8* %str) nounwind
|
||||
|
|
Loading…
Reference in New Issue