Index: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -508,7 +508,7 @@ do { Value *P = Worklist.pop_back_val(); - P = P->stripPointerCasts(); + P = P->stripPointerCasts(/*LookThroughNoAlias*/true); if (!Visited.insert(P).second) continue; Index: test/Transforms/InstCombine/mem-gep-zidx.ll =================================================================== --- test/Transforms/InstCombine/mem-gep-zidx.ll +++ test/Transforms/InstCombine/mem-gep-zidx.ll @@ -32,6 +32,22 @@ ; CHECK: ret void } +define void @test2a(i32 signext %x, i64 %v) #0 { +entry: + %p = alloca i64 + %pa = call i64* @llvm.noalias.p0i64(i64* %p, metadata !1) + %idxprom = sext i32 %x to i64 + %arrayidx = getelementptr inbounds i64, i64* %pa, i64 %idxprom + store i64 %v, i64* %arrayidx + call void @foo(i64* %pa) + ret void + +; CHECK-LABEL: @test2a +; CHECK: %p = alloca i64 +; CHECK: store i64 %v, i64* %pa +; CHECK: ret void +} + define signext i32 @test3(i32 signext %x, i1 %y) #0 { entry: %idxprom = sext i32 %x to i64 @@ -46,3 +62,8 @@ attributes #0 = { nounwind readnone } +declare i64* @llvm.noalias.p0i64(i64*, metadata) nounwind + +!0 = !{!0, !"some domain"} +!1 = !{!1, !0, !"some scope"} +