[OPENMP] Fix use of unsigned counters in loops with zero trip count.
authorAlexey Bataev <a.bataev@hotmail.com>
Wed, 22 Apr 2015 11:59:37 +0000 (11:59 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Wed, 22 Apr 2015 11:59:37 +0000 (11:59 +0000)
commit62dbb979c0bd3ab34d0b60b6fedfb66321d81dcf
tree0508793fb5118827e38d856e37c22957cf3ffc41
parent592cee666e17edd4402f355f36af51f41915efbe
[OPENMP] Fix use of unsigned counters in loops with zero trip count.

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.
Differential Revision: http://reviews.llvm.org/D9103

llvm-svn: 235500
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/for_codegen.cpp
clang/test/OpenMP/for_firstprivate_codegen.cpp
clang/test/OpenMP/for_lastprivate_codegen.cpp
clang/test/OpenMP/parallel_for_codegen.cpp
clang/test/OpenMP/simd_codegen.cpp