[PATCH] D66890: [IndVarSimplify] Do not use SCEV expander for IVCount in LFTR when possible.

Alexander Us via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 29 03:01:12 PDT 2019


aus_intel added a comment.

1. There is https://reviews.llvm.org/D41578 which disabled caching of SCEV if it lost flags which, in my understanding, causes this problem. There is also analysis that SCEV should generate poison but it doesn't handle loop invariants (and I assume that changing of it can trigger longer compilation time). With all of these, I decided that it is better to just avoid use of expander if it is possible.

2. I noticed that early CSE can handle simple cases like this (simple add: c++ - https://godbolt.org/z/yBcf8L, opt with indvars and cse - https://godbolt.org/z/_s-Z9P). However, I have an example when CSE (or anyone else) does not remove extra instructions (c++ - https://godbolt.org/z/vc2Wf5, opt - https://godbolt.org/z/so9zTE). So it seems that there is no cleanup for this code when -O2 is passed. Moreover, if cleanup is done it loses flags from instructions too (is this ok?).

3. Moreover, now I discovered that there is a problem in different pass: loop strength reduction. It uses SCEV expander to rewrite values and it again can generate extra instructions even when nothing is changed inside loop (https://godbolt.org/z/gYx2Ke). Initially I didn't noticed that because some backends do not use codegen passes that added with TargetPassConfig so this pass was not added by default (opt do not run LSR too). Seems, that I should file a bug on this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66890/new/

https://reviews.llvm.org/D66890





More information about the llvm-commits mailing list