[PATCH] [OPENMP] Fix use of unsigned counters in loops with zero trip count.

Alexey Bataev a.bataev at hotmail.com
Mon Apr 20 02:05:24 PDT 2015


Hi rjmccall, hfinkel, fraggamuffin, ejstotzer,

Patch fixes bugs in codegen for loops with unsigned counters and zero trip count. Previously preconditions for all loops were built using logic (Upper - Lower) > 0. But if the loop is a loop with zero trip count, then Upper - Lower is < 0 only for signed integer, for unsigned we're running into an underflow situation.
In this patch we're using original Lower<Upper condition to check that loop body can be executed at least once. Also this allows to skip code generation for loops, if it is known that preconditions for the loop are always false.

http://reviews.llvm.org/D9103

Files:
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/for_codegen.cpp
  test/OpenMP/for_firstprivate_codegen.cpp
  test/OpenMP/for_lastprivate_codegen.cpp
  test/OpenMP/parallel_for_codegen.cpp
  test/OpenMP/simd_codegen.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9103.24002.patch
Type: text/x-patch
Size: 25730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150420/3d63ea31/attachment.bin>


More information about the cfe-commits mailing list