This is an archive of the discontinued LLVM Phabricator instance.

Don't fold (select C, (gep Ptr, Idx), Ptr) if C is vector but Idx is scalar
ClosedPublic

Authored by kongyi on Sep 22 2021, 1:06 AM.

Details

Summary

The folding rule (select C, (gep Ptr, Idx), Ptr) -> (gep Ptr, (select C, Idx, 0)) creates a malformed select if C is a vector while Idx is scalar.

SELECT VecC, ScalarIdx, 0

We could splat Idx to a vector but it defeats the purpose of optimisation. Don't apply the folding rule in this case.

This fixes a regression from commit d561b6fbdbe6d1da05fd92003a4ac1e37bf4b8bc.

Diff Detail

Event Timeline

kongyi created this revision.Sep 22 2021, 1:06 AM
kongyi requested review of this revision.Sep 22 2021, 1:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 22 2021, 1:06 AM
RKSimon accepted this revision.Sep 22 2021, 2:34 AM

LGTM with one minor

llvm/test/Transforms/InstCombine/select-gep.ll
260

newline

This revision is now accepted and ready to land.Sep 22 2021, 2:34 AM
kongyi closed this revision.Sep 22 2021, 3:13 AM

Landed d0746f2e9bbf08f52196ae12f25d0ef7edcbbe4c (forgot to add the Phabricator link)