@@ -1148,7 +1148,7 @@ Value *LibCallSimplifier::optimizeStrCSpn(CallInst *CI, IRBuilderBase &B) {
1148
1148
Value *LibCallSimplifier::optimizeStrStr (CallInst *CI, IRBuilderBase &B) {
1149
1149
// fold strstr(x, x) -> x.
1150
1150
if (CI->getArgOperand (0 ) == CI->getArgOperand (1 ))
1151
- return B. CreateBitCast ( CI->getArgOperand (0 ), CI-> getType () );
1151
+ return CI->getArgOperand (0 );
1152
1152
1153
1153
// fold strstr(a, b) == a -> strncmp(a, b, strlen(b)) == 0
1154
1154
if (isOnlyUsedInEqualityComparison (CI, CI->getArgOperand (0 ))) {
@@ -1176,7 +1176,7 @@ Value *LibCallSimplifier::optimizeStrStr(CallInst *CI, IRBuilderBase &B) {
1176
1176
1177
1177
// fold strstr(x, "") -> x.
1178
1178
if (HasStr2 && ToFindStr.empty ())
1179
- return B. CreateBitCast ( CI->getArgOperand (0 ), CI-> getType () );
1179
+ return CI->getArgOperand (0 );
1180
1180
1181
1181
// If both strings are known, constant fold it.
1182
1182
if (HasStr1 && HasStr2) {
@@ -1186,16 +1186,13 @@ Value *LibCallSimplifier::optimizeStrStr(CallInst *CI, IRBuilderBase &B) {
1186
1186
return Constant::getNullValue (CI->getType ());
1187
1187
1188
1188
// strstr("abcd", "bc") -> gep((char*)"abcd", 1)
1189
- Value *Result = CI->getArgOperand (0 );
1190
- Result =
1191
- B.CreateConstInBoundsGEP1_64 (B.getInt8Ty (), Result, Offset, " strstr" );
1192
- return B.CreateBitCast (Result, CI->getType ());
1189
+ return B.CreateConstInBoundsGEP1_64 (B.getInt8Ty (), CI->getArgOperand (0 ),
1190
+ Offset, " strstr" );
1193
1191
}
1194
1192
1195
1193
// fold strstr(x, "y") -> strchr(x, 'y').
1196
1194
if (HasStr2 && ToFindStr.size () == 1 ) {
1197
- Value *StrChr = emitStrChr (CI->getArgOperand (0 ), ToFindStr[0 ], B, TLI);
1198
- return StrChr ? B.CreateBitCast (StrChr, CI->getType ()) : nullptr ;
1195
+ return emitStrChr (CI->getArgOperand (0 ), ToFindStr[0 ], B, TLI);
1199
1196
}
1200
1197
1201
1198
annotateNonNullNoUndefBasedOnAccess (CI, {0 , 1 });
0 commit comments