This is an archive of the discontinued LLVM Phabricator instance.

PeepholeOptimizer: Do not form PHI with subreg operands
ClosedPublic

Authored by MatzeB on Dec 1 2017, 4:53 PM.

Details

Summary

When replacing a PHI the PeepholeOptimizer currently takes the register
class of the register at the first operand. This however is not correct
if this argument has a subregister index.

As there is currently no API to query the register class resulting from
applying a subregister index to all registers in a class, we can only
abort in these cases and not perform the transformation.

This changes findNextSource() to require the end of all copy chains to
not use a subregister if there is any PHI in the chain. I had to rewrite
the overly complicated inner loop there to have a good place to insert
the new check.

This fixes https://llvm.org/PR33071 (aka rdar://32262041)

Diff Detail

Repository
rL LLVM

Event Timeline

MatzeB created this revision.Dec 1 2017, 4:53 PM
MatzeB updated this revision to Diff 125415.Dec 4 2017, 2:05 PM

Rebased to ToT and removed a cleanup/refactoring change that sneaked in here by accident.

@bruno: Quentin claims you know this code/loop in this patch better than him, could you take a look?

bruno accepted this revision.Jan 11 2018, 10:03 AM

LGTM

This revision is now accepted and ready to land.Jan 11 2018, 10:03 AM
This revision was automatically updated to reflect the committed changes.