llvm-project/llvm/test/Transforms/LoopIdiom
Craig Topper a3f39ee33d [LoopIdiomRecognize] Add a test case to show incorrect transformation of an infinite loop with side effets into a countable loop using ctlz.
We currently recognize this idiom where x is signed and thus the shift in an ashr.

int cnt = 0;
while (x) {
  x >>= 1; // arithmetic shift right
  ++cnt;
}

and turn it into (bitwidth - ctlz(x)). And if there is anything else in the loop we will create a new loop that runs that many times.

If x is initially negative, the shift result will never be 0 and thus the loop is infinite. If you put something with side effects in the loop, that side effect will now only happen bitwidth times instead of an infinite number of times.

So this transform is only safe for logical shift right (which we don't currently recognize) or if we can prove that x cannot be negative before the loop.

llvm-svn: 331493
2018-05-03 23:50:29 +00:00
..
AMDGPU
ARM
X86 [LoopIdiomRecognize] Add a test case to show incorrect transformation of an infinite loop with side effets into a countable loop using ctlz. 2018-05-03 23:50:29 +00:00
basic-address-space.ll Remove alignment argument from memcpy/memmove/memset in favour of alignment attributes (Step 1) 2018-01-19 17:13:12 +00:00
basic.ll [LoopIdiom] Be more aggressive when setting alignment in memcpy 2018-02-08 17:33:08 +00:00
crash.ll
ctpop-multiple-users-crash.ll
debug-line.ll
int_sideeffect.ll
lir-heurs-multi-block-loop.ll Remove alignment argument from memcpy/memmove/memset in favour of alignment attributes (Step 1) 2018-01-19 17:13:12 +00:00
memset_noidiom.ll
non-canonical-loop.ll
non-integral-pointers.ll
nontemporal_store.ll
pr28196.ll Remove alignment argument from memcpy/memmove/memset in favour of alignment attributes (Step 1) 2018-01-19 17:13:12 +00:00
pr33114.ll
scev-invalidation.ll
struct-custom-dl.ll Adding a width of the GEP index to the Data Layout. 2018-02-14 06:58:08 +00:00
struct.ll
struct_pattern.ll
unordered-atomic-memcpy-noarch.ll
unroll-custom-dl.ll Adding a width of the GEP index to the Data Layout. 2018-02-14 06:58:08 +00:00
unroll.ll
unsafe.ll
unwind.ll