[all-commits] [llvm/llvm-project] acec07: [OpenMP] Fix partial unrolling off-by-one.

Michael Kruse via All-commits all-commits at lists.llvm.org
Fri May 20 13:20:13 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: acec07005e038ab2891f235ae60ba2f0236bb952
      https://github.com/llvm/llvm-project/commit/acec07005e038ab2891f235ae60ba2f0236bb952
  Author: Michael Kruse <llvm-project at meinersbur.de>
  Date:   2022-05-20 (Fri, 20 May 2022)

  Changed paths:
    M clang/lib/Sema/SemaOpenMP.cpp
    M clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c
    M clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c
    M clang/test/OpenMP/unroll_codegen_for_collapse_outer.cpp
    M clang/test/OpenMP/unroll_codegen_for_partial.cpp
    M clang/test/OpenMP/unroll_codegen_parallel_for_factor.cpp
    M clang/test/OpenMP/unroll_codegen_tile_for.cpp
    M clang/test/OpenMP/unroll_codegen_unroll_for.cpp
    M clang/test/OpenMP/unroll_codegen_unroll_for_attr.cpp

  Log Message:
  -----------
  [OpenMP] Fix partial unrolling off-by-one.

Even though the comment description is ".unroll_inner.iv < NumIterations", the code emitted a BO_LE ('<=') operator for the inner loop that is to be unrolled. This lead to one additional copy of the body code in a partially unrolled. It only manifests when the unrolled loop is consumed by another loop-associated construct. Fix by using the BO_LT operator instead.

The condition for the outer loop and the corresponding code for tiling correctly used BO_LT already.

Fixes #55236




More information about the All-commits mailing list