I noticed this bug when deubging a WIP on LSR. I wonder whether and how we
should add a regression test for this.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Re: Testing, it might be nice to put this into lib/Analysis/CostModel.cpp and then add a test in test/Analysis/CostModel/no_info.ll
Seems hard in CostModel. I cannot come up with any instruction (e.g. GEP)
that triggers negative scales (unless element sizes can be negative).
This bug was triggered at
http://llvm.org/docs/doxygen/html/LoopStrengthReduce_8cpp_source.html#l01022.
isAMCompletelyFolded considered some SCEV in the form "reg - reg" free. LSR
seems the only place that computes addressing mode from SCEV where negative
scales are possible. I am trying to write an LSR test that can expose this
bug.
Jingyue
Please add comments explaining the behavior that you discovered and rationale. Are you just trying to avoid considering reg - reg to be free, or can scale be < -1?
You should be able to test LSR now with opt -loop-reduce and specifying TTI. I'm not sure off the top of my head the best way to specify TTI, but -mtriple probably works.
Otherwise looks good. Thanks for the fix.