[Clang][OpenMPIRBuilder] Fix off-by-one error when dividing by stepsize.
authorMichael Kruse <llvm-project@meinersbur.de>
Mon, 31 Jan 2022 15:49:44 +0000 (09:49 -0600)
committerMichael Kruse <llvm-project@meinersbur.de>
Mon, 31 Jan 2022 23:28:52 +0000 (17:28 -0600)
commit8a9e4f245b66b90839bdf34e91cb0901e3260dad
treeaff11893213a5ce7d07eaaee834ff3ec8791f5f0
parentc7f4c333af2bd7b21dfb58df6cea59b30f6576d7
[Clang][OpenMPIRBuilder] Fix off-by-one error when dividing by stepsize.

When the stepsize does not evenly divide the range's end, round-up to ensure that that last multiple of the stepsize before the reaching the upper boud is reached. For instance, the trip count of

    for (int i = 0; i < 7; i+=5)

is two (i=0 and i=5), not (7-0)/5 == 1.

Reviewed By: peixin

Differential Revision: https://reviews.llvm.org/D118542
12 files changed:
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/irbuilder_for_unsigned.c
clang/test/OpenMP/irbuilder_for_unsigned_down.c [new file with mode: 0644]
clang/test/OpenMP/irbuilder_unroll_full.c
clang/test/OpenMP/irbuilder_unroll_heuristic.c
clang/test/OpenMP/irbuilder_unroll_partial_factor.c
clang/test/OpenMP/irbuilder_unroll_partial_factor_for.c
clang/test/OpenMP/irbuilder_unroll_partial_heuristic.c
clang/test/OpenMP/irbuilder_unroll_partial_heuristic_constant_for.c
clang/test/OpenMP/irbuilder_unroll_partial_heuristic_runtime_for.c
clang/test/OpenMP/irbuilder_unroll_unroll_partial_factor.c
clang/test/OpenMP/irbuilder_unroll_unroll_partial_heuristic.c