Fixing a corner-case bug in strchr and strrchr lib call optimizations where

the input character is not converted to char before comparing with zero.

The patch was discussed in this thread:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130812/184069.html



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188489 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Yunzhong Gao
2013-08-15 20:58:59 +00:00
parent 14c41370e3
commit b187b69170
3 changed files with 24 additions and 2 deletions
+11
View File
@@ -52,3 +52,14 @@ define void @test_simplify4(i32 %chr) {
store i8* %dst, i8** @chp
ret void
}
define void @test_simplify5() {
; CHECK: store i8* getelementptr inbounds ([14 x i8]* @hello, i32 0, i32 13)
; CHECK-NOT: call i8* @strchr
; CHECK: ret void
%src = getelementptr [14 x i8]* @hello, i32 0, i32 0
%dst = call i8* @strchr(i8* %src, i32 65280)
store i8* %dst, i8** @chp
ret void
}
+11
View File
@@ -42,6 +42,17 @@ define void @test_simplify3() {
ret void
}
define void @test_simplify4() {
; CHECK: store i8* getelementptr inbounds ([14 x i8]* @hello, i32 0, i32 13)
; CHECK-NOT: call i8* @strrchr
; CHECK: ret void
%src = getelementptr [14 x i8]* @hello, i32 0, i32 0
%dst = call i8* @strrchr(i8* %src, i32 65280)
store i8* %dst, i8** @chp
ret void
}
define void @test_nosimplify1(i32 %chr) {
; CHECK-LABEL: @test_nosimplify1(
; CHECK: call i8* @strrchr