This is an archive of the discontinued LLVM Phabricator instance.

If-conversion incorrectly calculates liveness of redefined registers
ClosedPublic

Authored by kparzysz on Aug 5 2016, 7:48 AM.

Details

Summary

The if-convert-diamond function in the if-conversion initialized Redefs with the live-ins from the first of the two predicated blocks. This may not reflect the liveness of the defined registers correctly, since a register defined in the first block may be live across the other predicated block. The testcase illustrates this situation.

Diff Detail

Repository
rL LLVM

Event Timeline

kparzysz updated this revision to Diff 66948.Aug 5 2016, 7:48 AM
kparzysz updated this revision to Diff 66955.
kparzysz retitled this revision from to If-conversion incorrectly calculates liveness of redefined registers.
kparzysz updated this object.
kparzysz added a reviewer: MatzeB.
kparzysz set the repository for this revision to rL LLVM.
kparzysz added a subscriber: llvm-commits.

Remove a leftover debug statement.

MatzeB accepted this revision.Aug 10 2016, 6:27 PM
MatzeB edited edge metadata.

LGTM. That was a subtle issue, thanks.

Some nitpicks below:

lib/CodeGen/IfConversion.cpp
1434–1435 ↗(On Diff #66955)

I don't understand the new comment (the old comment was pretty bad too though).

How about something in the line of:

// - BB2 live-in regs need implicit uses before being redefined by BB1 instructions.
// - BB1 live-out regs need implicit uses before being redefined by BB2 instructions;
//    We start with BB1 live-ins so we have the live-out regs after tracking the BB1 instructions.
test/CodeGen/Hexagon/ifcvt-impuse-livein.mir
1 ↗(On Diff #66955)

Nice small and to the point test!

Would be nice if you could add one sentence about what is tested.
I would also recommend a # CHECK-LABEL: name: foo (just in case more tests get added later).

16 ↗(On Diff #66955)

The %r1 livein looks unnecessary.

This revision is now accepted and ready to land.Aug 10 2016, 6:27 PM
kparzysz marked 3 inline comments as done.Aug 11 2016, 11:46 AM
This revision was automatically updated to reflect the committed changes.