This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fix incorrect inbounds on GEP of GEP (PR44425)
ClosedPublic

Authored by nikic on Jan 1 2020, 12:37 PM.

Details

Summary

This fixes https://bugs.llvm.org/show_bug.cgi?id=44425. We need to drop inbounds if one of the GEPs is not inbounds. This was already done when creating a new GEP, but not when modifying in place.

I'll followup with another patch to special-case the zero-index case to address https://bugs.llvm.org/show_bug.cgi?id=44423.

Diff Detail

Event Timeline

nikic created this revision.Jan 1 2020, 12:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 1 2020, 12:37 PM
lebedev.ri accepted this revision.Jan 1 2020, 12:51 PM

This LG, thank you.
I recommend first landing cleanup (isMergedGEPInBounds() thingy) and then the fix.

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
1925

This is the fix i presume?

1942

And this should be a follow-up NFC cleanup.

llvm/test/Transforms/InstCombine/getelementptr.ll
1204

I agree that this was a miscompilation.

This revision is now accepted and ready to land.Jan 1 2020, 12:51 PM
This revision was automatically updated to reflect the committed changes.
nikic added a comment.Jan 1 2020, 1:20 PM

I've moved the addition of the extra function into D72060, as it really only makes sense with the extra logic added there -- otherwise calling the function takes more characters than the logic it contains :)