[llvm-dev] Strange behaviour of post-legalising optimisations(?)

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Wed Jun 5 10:33:58 PDT 2019


Hi Joan,

On Wed, 5 Jun 2019 at 08:58, Joan Lluch via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> Any ideas about why this happens?. Particularly, what could cause this change of behaviour just by adding an ‘if’ before the ‘for’?  Note that the IR code for the for ‘for’ body is IDENTICAL in both cases, so this is definitely a LLVM thing.

If you run "llc -print-after-all" you should be able to see which pass
first introduces the behaviour you don't like. In this case it seems
to be "Loop Strength Reduction", in
lib/Transforms/Scalar/LoopStrengthReduce.cpp. It makes use of a lot of
hooks in TargetTransformInfo (search for "TTI.") when making its
decisions and if you haven't implemented versions of those matching
your target its heuristics are going to get this kind of thing wrong.

Beyond that I'm just guessing, but isLegalAddressingMode looks like it
could be a critical one for your case (it's the only thing you've
mentioned being able to do neatly).

Cheers.

Tim.


More information about the llvm-dev mailing list