From e9b8d704d385472c68a50aa58413e880dd5d9aae Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 17 Oct 2022 16:46:03 +0200 Subject: [PATCH] [BasicAA] Add test for phi of geps of alloca (NFC) Make sure we continue determining NoAlias in this case, where we have a phi of constant index GEPs based on an alloca. --- llvm/test/Analysis/BasicAA/phi-aa.ll | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/llvm/test/Analysis/BasicAA/phi-aa.ll b/llvm/test/Analysis/BasicAA/phi-aa.ll index 9eb63cf..799bf5b 100644 --- a/llvm/test/Analysis/BasicAA/phi-aa.ll +++ b/llvm/test/Analysis/BasicAA/phi-aa.ll @@ -223,3 +223,26 @@ split: load i32, i32* %ptr.next.phi br label %loop } + +; CHECK-LABEL: phi_of_geps_based_on_alloca +; CHECK: NoAlias: i32* %gep3, i32* %phi +define void @phi_of_geps_based_on_alloca(i1 %c) { + %a = alloca [3 x i32] + %p = bitcast [3 x i32]* %a to i32* + br i1 %c, label %if, label %else + +if: + %gep1 = getelementptr i32, i32* %p, i64 1 + br label %join + +else: + %gep2 = getelementptr i32, i32* %p, i64 2 + br label %join + +join: + %phi = phi i32* [ %gep1, %if ], [ %gep2, %else ] + %gep3 = getelementptr i32, i32* %p, i64 3 + load i32, i32* %phi + load i32, i32* %gep3 + ret void +} -- 2.7.4