Only convert power-of-two floor-division with non-negative denominator
authorTobias Grosser <tobias@grosser.es>
Wed, 3 Jun 2015 14:43:01 +0000 (14:43 +0000)
committerTobias Grosser <tobias@grosser.es>
Wed, 3 Jun 2015 14:43:01 +0000 (14:43 +0000)
commit224b16228028554e3594c0b72b3dacf3893d22d6
treebd75077ee5fd0b2f33806b43e5e116021b4572a0
parentaef6d17c8d8b39473557a2177a0d3e188c4704ff
Only convert power-of-two floor-division with non-negative denominator

floord(a,b) === a ashr log_2 (b) holds for positive and negative a's, but
shifting only makes sense for positive values of b. The previous patch did
not consider this as isl currently always produces postive b's. To avoid future
surprises, we check that b is positive and only then apply the optimization.

We also now correctly check the return value of the dyn-cast.

No additional test case, as isl currently does not produce negative
denominators.

Reported-by: David Majnemer <david.majnemer@gmail.com>
llvm-svn: 238927
polly/lib/CodeGen/IslExprBuilder.cpp