This is an archive of the discontinued LLVM Phabricator instance.

Prevent the scalarizer from caching incorrect entries
ClosedPublic

Authored by frasercrmck on Jul 28 2015, 5:08 AM.

Details

Summary

As described in https://llvm.org/bugs/show_bug.cgi?id=24248, the scalarizer can cache incorrect entries when walking up a chain of insertelement instructions. This occurs when it encounters more than one instruction that it is not actively searching for, as it unconditionally caches every element it finds. The fix is to only cache the first element that it isn't searching for so we don't overwrite correct entries.

Diff Detail

Repository
rL LLVM

Event Timeline

frasercrmck retitled this revision from to Prevent the scalarizer from caching incorrect entries.
frasercrmck updated this object.
frasercrmck added a reviewer: hfinkel.
frasercrmck added a subscriber: llvm-commits.

Adding Hal as he subscribed to the bug.

hfinkel accepted this revision.Aug 9 2015, 10:52 PM
hfinkel edited edge metadata.
hfinkel added inline comments.
test/Transforms/Scalarizer/cache-bug.ll
16

We don't need to check the entire output here, we only need to check for the function name, this line, and perhaps the absence of the bad output (just to make it clear what is being tested). I'd write this:

; CHECK-LABEL: @func
; CHECK-NOT: phi i32 [ %x, %entry ], [ %inc.pos.y, %loop ]
; CHECK: phi i32 [ %inc, %entry ], [ %inc.pos.y, %loop ]
; CHECK: ret void

The problem with including the whole output verbatim is that any future simplifications, or even changes to how the variables are named, will break the test.

Otherwise, LGTM.

This revision is now accepted and ready to land.Aug 9 2015, 10:52 PM
This revision was automatically updated to reflect the committed changes.