Index: lib/Analysis/BasicAliasAnalysis.cpp =================================================================== --- lib/Analysis/BasicAliasAnalysis.cpp +++ lib/Analysis/BasicAliasAnalysis.cpp @@ -1077,8 +1077,8 @@ // of GetLinearExpression decomposition. In the example above, if Var0 // is zext(%x + 1) we should get V1 == %x and V1Offset == 1. - APInt V0Scale(Width, 0), V0Offset(Width, 0), V1Scale(Width, 1), - V1Offset(Width, 1); + APInt V0Scale(Width, 0), V0Offset(Width, 0), V1Scale(Width, 0), + V1Offset(Width, 0); bool NSW = true, NUW = true; unsigned V0ZExtBits = 0, V0SExtBits = 0, V1ZExtBits = 0, V1SExtBits = 0; const Value *V0 = GetLinearExpression(Var0.V, V0Scale, V0Offset, V0ZExtBits, Index: test/Analysis/BasicAA/bug.23540.ll =================================================================== --- /dev/null +++ test/Analysis/BasicAA/bug.23540.ll @@ -0,0 +1,23 @@ +; RUN: opt < %s -basicaa -licm -S 2>&1 | FileCheck %s +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@c = external global i32 + +; CHECK-LABEL: @f +; CHECK: br label %for.body +; CHECK: br label %for.body +define void @f() { +entry: + br label %for.body + +for.body: + %idxprom = zext i32 undef to i64 + %arrayidx = getelementptr inbounds i32, i32* @c, i64 %idxprom + %0 = load i32, i32* %arrayidx + %add4 = add i32 0, 1 + %idxprom5 = zext i32 %add4 to i64 + %arrayidx6 = getelementptr inbounds i32, i32* @c, i64 %idxprom5 + %1 = load i32, i32* %arrayidx6 + br label %for.body +} \ No newline at end of file