Index: lib/Analysis/ValueTracking.cpp =================================================================== --- lib/Analysis/ValueTracking.cpp +++ lib/Analysis/ValueTracking.cpp @@ -2599,7 +2599,7 @@ assert(V); // Look through bitcast instructions and geps. - V = V->stripPointerCasts(); + V = V->stripPointerCasts(/*LookThroughNoAlias*/true); // If the value is a GEP instruction or constant expression, treat it as an // offset. @@ -2682,7 +2682,7 @@ /// the specified pointer, return 'len+1'. If we can't, return 0. static uint64_t GetStringLengthH(Value *V, SmallPtrSetImpl &PHIs) { // Look through noop bitcast instructions. - V = V->stripPointerCasts(); + V = V->stripPointerCasts(/*LookThroughNoAlias*/true); // If this is a PHI node, there are two cases: either we have already seen it // or we haven't. Index: test/Transforms/InstCombine/strlen-1.ll =================================================================== --- test/Transforms/InstCombine/strlen-1.ll +++ test/Transforms/InstCombine/strlen-1.ll @@ -23,6 +23,15 @@ ; CHECK-NEXT: ret i32 5 } +define i32 @test_simplify1a() { +; CHECK-LABEL: @test_simplify1a( + %hello_p = getelementptr [6 x i8], [6 x i8]* @hello, i32 0, i32 0 + %hello_pa = call i8* @llvm.noalias.p0i8(i8* %hello_p, metadata !1) + %hello_l = call i32 @strlen(i8* %hello_pa) + ret i32 %hello_l +; CHECK-NEXT: ret i32 5 +} + define i32 @test_simplify2() { ; CHECK-LABEL: @test_simplify2( %null_p = getelementptr [1 x i8], [1 x i8]* @null, i32 0, i32 0 @@ -107,3 +116,9 @@ ret i32 %a_l ; CHECK-NEXT: ret i32 %a_l } + +declare i8* @llvm.noalias.p0i8(i8*, metadata) nounwind + +!0 = !{!0, !"some domain"} +!1 = !{!1, !0, !"some scope"} +