This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by ABataev on Apr 20 2015, 2:05 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

ABataev updated this revision to Diff 24002.Apr 20 2015, 2:05 AM
ABataev retitled this revision from to [OPENMP] Fix use of unsigned counters in loops with zero trip count..
ABataev updated this object.
ABataev edited the test plan for this revision. (Show Details)
ABataev added a subscriber: Unknown Object (MLST).
rjmccall edited edge metadata.Apr 21 2015, 12:42 PM

LGTM.

lib/Sema/SemaOpenMP.cpp
2386 ↗(On Diff #24002)

Cute, but more distracting than helpful. :) Maybe "Try to build LB <op> UB, where <op> is <, >, <=, or >=."

John, thanks for the review!

lib/Sema/SemaOpenMP.cpp
2386 ↗(On Diff #24002)

John, thanks, I'll fix this. :)

This revision was automatically updated to reflect the committed changes.