This is an archive of the discontinued LLVM Phabricator instance.

IfConversion: Fix bug introduced by rescanning diamonds.
ClosedPublic

Authored by iteratee on Sep 1 2016, 2:25 PM.

Details

Reviewers
davidxl
Summary

Passing the wrong values for predicate-clobbering. Simple to miss.
Added an assert to make this easier to catch in the future.

Diff Detail

Event Timeline

iteratee updated this revision to Diff 70069.Sep 1 2016, 2:25 PM
iteratee retitled this revision from to IfConversion: Fix bug introduced by rescanning diamonds..
iteratee updated this object.
iteratee added a reviewer: davidxl.
iteratee set the repository for this revision to rL LLVM.
iteratee added subscribers: labrinea, jmolloy.

The test case is related, because with the asserts, but without the fix, the test will fail.

It also makes sure that we are correctly re-scanning to find missed opportunities to if-convert.

lib/CodeGen/IfConversion.cpp
1758

This assert would have made the failure occur earlier, making it more obvious what was wrong.

1984

This is the mistake. It should be simple to see that it's correct now.

davidxl edited edge metadata.Sep 1 2016, 3:01 PM

I wonder why the problem was not caught by existing tests?

I wonder why the problem was not caught by existing tests?

In trying to reduce the test case, it seems that pred-clobbering instructions are comparitively rare, except before branches.

It wasn't even caught by any of the buildbots. It showed up compiling openssl for Arm V8 / thumb. It doesn't miscompile for arm V7 / thumb.

In any case, we now have a test that will catch it, and an assert.

You should probably commit the assertion change indepdendently.

lib/CodeGen/IfConversion.cpp
1758

Perhaps : predicate info can not be clobbered by both sides

1984

Is it because after rescanning the TrueBBI value is not updated?

iteratee added inline comments.Sep 1 2016, 3:52 PM
lib/CodeGen/IfConversion.cpp
1984

Yes. (Nor should it be)

Those blocks will be scanned for other kinds of if-conversion, and it would be wrong to change TrueBBI and FalseBBI.

iteratee marked 2 inline comments as done.Sep 2 2016, 10:10 AM

Does this need anything else?

davidxl accepted this revision.Sep 2 2016, 10:13 AM
davidxl edited edge metadata.

lgtm

This revision is now accepted and ready to land.Sep 2 2016, 10:13 AM

Looks to be duplicate of D24181.

Looks to be duplicate of D24181.

Not a duplicate.

This was committed in rL280517

iteratee closed this revision.Oct 12 2016, 3:00 PM