[all-commits] [llvm/llvm-project] 48caa0: [LAA] Analyze pointers forked by a phi (#65834)

Allen via All-commits all-commits at lists.llvm.org
Mon Sep 18 18:17:02 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 48caa0723c89b9da10ea081f490282a7e370a06f
  Author: Allen <zhongyunde at huawei.com>
  Date:   2023-09-19 (Tue, 19 Sep 2023)

  Changed paths:
    M llvm/lib/Analysis/LoopAccessAnalysis.cpp
    M llvm/test/Analysis/LoopAccessAnalysis/forked-pointers.ll

  Log Message:
  [LAA] Analyze pointers forked by a phi (#65834)

Given a function like the following: https://godbolt.org/z/T9c99fr88
1161_noReadWrite(int *Preds) {
  for (int i = 0; i < LEN_1D-1; ++i) {
    if (Preds[i] != 0)
      b[i] = c[i] + 1;
      a[i] = i * i;

LLVM will optimize the IR to a single store by a phi instruction:

      %1 = load ptr, ptr @a, align 64
      %2 = load ptr, ptr @b, align 64
      %.sink = phi ptr [ %1, %if.then ], [ %2, %if.else ]
      %add.sink = phi double [ %add, %if.then ], [ %conv8, %if.else ]
%arrayidx7 = getelementptr inbounds double, ptr %.sink, i64 %indvars.iv
      store double %add.sink, ptr %arrayidx7, align 8

LAA is currently unable to analyze such IR, since ScalarEvolution will
return a SCEVUnknown for the forked pointer operand of the store.

This patch adds initial optional support for analyzing both
possibilities for the pointer and allowing LAA to generate runtime
checks for the bounds if required, refers to D108699, but here address
the phi node.

Fixes https://github.com/llvm/llvm-project/issues/64888

Reviewed By: huntergr-arm, fhahn
Differential Revision: https://reviews.llvm.org/D158965

More information about the All-commits mailing list