LoopVectorizer: integer division is not a reduction operation
authorArnold Schwaighofer <aschwaighofer@apple.com>
Fri, 12 Apr 2013 15:15:19 +0000 (15:15 +0000)
committerArnold Schwaighofer <aschwaighofer@apple.com>
Fri, 12 Apr 2013 15:15:19 +0000 (15:15 +0000)
commitf9cea17f750eea65da0b5a270f57ba2f39908ccc
tree162904609406d3768c86cf1486fccd2e731917d0
parent755eb32a398c8c47540bc73c5cc8c12076b639f7
LoopVectorizer: integer division is not a reduction operation

Don't classify idiv/udiv as a reduction operation. Integer division is lossy.
For example : (1 / 2) * 4 != 4/2.

Example:

int a[] = { 2, 5, 2, 2}
int x = 80;

for()
  x /= a[i];

Scalar:
  x /= 2 // = 40
  x /= 5 // = 8
  x /= 2 // = 4
  x /= 2 // = 2

Vectorized:

 <80, 1> / <2,5> //= <40,0>
 <40, 0> / <2,2> //= <20,0>

 20*0 = 0

radar://13640654

llvm-svn: 179381
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/no_idiv_reduction.ll [new file with mode: 0644]