This is an archive of the discontinued LLVM Phabricator instance.

[NoTTI] reject negative scale in addressing mode
ClosedPublic

Authored by jingyue on May 6 2015, 11:27 AM.

Details

Summary

I noticed this bug when deubging a WIP on LSR. I wonder whether and how we
should add a regression test for this.

Diff Detail

Repository
rL LLVM

Event Timeline

jingyue updated this revision to Diff 25073.May 6 2015, 11:27 AM
jingyue retitled this revision from to [NoTTI] reject negative scale in addressing mode.
jingyue updated this object.
jingyue edited the test plan for this revision. (Show Details)
jingyue added a reviewer: atrick.
jingyue added a subscriber: Unknown Object (MLST).

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

atrick requested changes to this revision.May 6 2015, 5:02 PM
atrick edited edge metadata.

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.

This revision now requires changes to proceed.May 6 2015, 5:02 PM
jingyue updated this revision to Diff 25124.May 6 2015, 9:01 PM
jingyue edited edge metadata.

added an LSR test that exposes this bug

jingyue updated this revision to Diff 25349.May 8 2015, 11:10 AM
jingyue edited edge metadata.

Forgot the RUN line

This revision was automatically updated to reflect the committed changes.