[all-commits] [llvm/llvm-project] cad9f9: [Polly] Don't generate inter-iteration noalias met...

Michael Kruse via All-commits all-commits at lists.llvm.org
Mon Sep 20 20:20:34 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cad9f98a2ad98fecf663e9ce39502b8e43676fc9
      https://github.com/llvm/llvm-project/commit/cad9f98a2ad98fecf663e9ce39502b8e43676fc9
  Author: Michael Kruse <llvm-project at meinersbur.de>
  Date:   2021-09-20 (Mon, 20 Sep 2021)

  Changed paths:
    M polly/include/polly/CodeGen/IRBuilder.h
    M polly/lib/CodeGen/IRBuilder.cpp
    M polly/lib/CodeGen/IslNodeBuilder.cpp
    M polly/lib/Transform/MatmulOptimizer.cpp
    M polly/test/ScheduleOptimizer/ensure-correct-tile-sizes.ll
    M polly/test/ScheduleOptimizer/mat_mul_pattern_data_layout_2.ll
    R polly/test/ScheduleOptimizer/pattern-matching-based-opts_10.ll
    M polly/test/ScheduleOptimizer/pattern-matching-based-opts_13.ll
    M polly/test/ScheduleOptimizer/pattern-matching-based-opts_14.ll
    M polly/test/ScheduleOptimizer/pattern-matching-based-opts_3.ll
    M polly/test/ScheduleOptimizer/pattern-matching-based-opts_5.ll

  Log Message:
  -----------
  [Polly] Don't generate inter-iteration noalias metadata.

This metadata was intended to mark all accesses within an iteration to be pairwise non-aliasing, in this case because every memory of a base pointer is touched (read or write) at most once. This is typical for 'sweeps' over all data. The stated motivation from D30606 is to ensure that unrolled iterations are considered non-aliasing.

Rhe implemention had multiple issues:

 * The structure of the noalias metadata was malformed. D110026 added check in the verifier for this metadata, and the tests were failing since then.

 * This is not true for the outer loops of the BLIS matrix multiplication, where it was being inserted. Each element of A, B, C is accessed multiple times, as often as the loop not used as an index is iterating.

 * Scopes were added to SecondLevelOtherAliasScopeList (used for the !noalias scop list) on-the-fly when another SCEV was seen. This meant that previously visited instructions would not be updated with alias scopes that are only seen later, missing out those SCEVs they should not be aliasing with.

 * Since the !noalias scope list would ideally consists of all other SCEV for this base pointer, we might run quickly into scalability issues. Especially after unrolling there would probably at least once SCEV per instruction and unroll instance.

 * The inter-iteration noalias base pointer was not removed after leaving the loop marked with it, effectively marking everything after it to noalias as well.

A solution I considered was to mark each instruction as non-aliasing with its own scope. The instruction itself would obviously alias itself, but such construction might also be considered invalid. Duplicating the instruction (e.g. due to speculation) would mark the instruction non-aliasing with its clone. I don't want to go into this territory, especially since the original motivation of determining unrolled instances as noalias based on SCEV is the what scev-aa does as well.

This effectively reverts D30606 and D35761.




More information about the All-commits mailing list