[PATCH] D118542: [Clang][OpenMPIRBuilder] Fix off-by-one error when dividing by stepsize.

Michael Kruse via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 29 12:45:30 PST 2022


Meinersbur created this revision.
Meinersbur added reviewers: kiranchandramohan, ftynse, peixin, jdoerfert, clementval, Leporacanthicus, kiranktp, arnamoy10, bryanpkc, Chuanfeng, AMDChirag, anchu-rajendran, SouraVX, fghanim, jdenny, MatsPetersson, ABataev.
Herald added subscribers: zzheng, guansong, yaxunl.
Meinersbur requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118542

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/irbuilder_for_unsigned.c
  clang/test/OpenMP/irbuilder_for_unsigned_down.c
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118542.404300.patch
Type: text/x-patch
Size: 26850 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220129/e693013f/attachment-0001.bin>


More information about the cfe-commits mailing list