This is an archive of the discontinued LLVM Phabricator instance.

[LoopStrengthReduce] Ensure that debug intrinsics do not affect LSR's output
ClosedPublic

Authored by StephenTozer on May 24 2021, 9:16 AM.

Details

Summary

Fixes bug 50427: https://bugs.llvm.org/show_bug.cgi?id=50427

During Loop Strength Reduce, if the terminating condition for the loop is not immediately adjacent to the terminating branch and it has more than one use, a clone of the condition will be created just before the terminating branch and will be used as the branch condition. Currently, whether the instructions are "immediately adjacent" is determined by checking whether the next instruction after the condition is the terminating branch; this is incorrect however, as the presence of a debug intrinsic between the two will result in a change to the output. This is fixed by using getNextNonDebugInstruction() instead.

Diff Detail

Event Timeline

StephenTozer created this revision.May 24 2021, 9:16 AM
StephenTozer requested review of this revision.May 24 2021, 9:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2021, 9:16 AM

Any chance of reducing the test case further?

lgtm (some nits/advices on how-to-reduce-test-case inline)

llvm/test/Transforms/LoopStrengthReduce/X86/lsr-cond-dbg.ll
109

!tbaa not needed I guess?

112

All these DILocations with the same scope could be represented as one DILocation metadata, so we can get rid of the rest.

Any chance of reducing the test case further?

I can try - it's already been put through creduce and bugpoint, but there may be some value to be gained from manual editing the file.

Reduced test file by ~25%.

djtodoro accepted this revision.Jun 1 2021, 11:48 PM

lgtm (+ nit)

llvm/test/Transforms/LoopStrengthReduce/X86/lsr-cond-dbg.ll
112

'No newline at end of file"

This revision is now accepted and ready to land.Jun 1 2021, 11:48 PM