llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[SCEV] applyLoopGuards drops information on SCEV builtin_assumes()

Open komalon1 opened this issue 4 years ago • 2 comments

applyLoopGuards tries to rewrite a SCEV expression using assumes. The order of the assumes in the source code affects the rewritten SCEV and sometimes we lose information. An example is https://godbolt.org/z/vYnvKcrME where the vectorizer can't prove tripcount % VF = 0 despite of the assumption with that information. If the order of the assumes is changed as in https://godbolt.org/z/Wf445MMha code is optimized. This is since the assume (tripcount > 0) rewrites a new SCEV that loses the divisibility information. Need to think of a way to conserve the already rewritten expression of a certain value.

komalon1 avatar May 23 '22 06:05 komalon1

Interesting cases! Review to add IR tests available: https://reviews.llvm.org/D126460

fhahn avatar May 26 '22 15:05 fhahn

Possible fix: https://reviews.llvm.org/D126502

fhahn avatar May 26 '22 21:05 fhahn