This is an archive of the discontinued LLVM Phabricator instance.

Insert tbb/tbh optimization where previous jump table resided
ClosedPublic

Authored by stewartd on Dec 11 2014, 10:18 AM.

Details

Summary

The insertion of tbb/tbh instructions should be placed where the previous jump table instruction was, not at the end of the block. It is possible that new water was created after a basic block that ends in a jump table, due to not having a sufficient area within range. In this case, the new water is created at the end of the block and an unconditional branch instruction is added to the end of the basic block. A subsequent Thumb2 optimization of the jump table places a tbb/tbh at the end of the block and erases the existing jump table branch. But this results in the unconditional branch being hit before the jump table ever gets hit.

This patch places the tbb/tbh at the same location as the jump table branch.

Diff Detail

Repository
rL LLVM

Event Timeline

stewartd updated this revision to Diff 17180.Dec 11 2014, 10:18 AM
stewartd retitled this revision from to Insert tbb/tbh optimization where previous jump table resided.
stewartd updated this object.
stewartd edited the test plan for this revision. (Show Details)
stewartd set the repository for this revision to rL LLVM.
stewartd added a subscriber: Unknown Object (MLST).
mcrosier added a subscriber: mcrosier.

Hi Daniel,

The code change looks sensible, but I think the test could be made a bit clearer these days:

test/CodeGen/Thumb2/constant-islands-jump-table.ll
46

There's an @llvm.arm.space intrinsic now. It acts as an "instruction" of the precise size you specify. It's probably clearer and more efficient than putting in just the right number of real instructions.

stewartd added inline comments.Dec 12 2014, 11:36 AM
test/CodeGen/Thumb2/constant-islands-jump-table.ll
46

I didn't know about that! I'll redo the test. Thanks.

stewartd updated this revision to Diff 17243.Dec 12 2014, 12:56 PM
stewartd edited edge metadata.

Updated the test case to use llvm.arm.space

t.p.northover accepted this revision.Dec 12 2014, 1:42 PM
t.p.northover edited edge metadata.

This looks good to me. Thanks for updating it.

Tim.

This revision is now accepted and ready to land.Dec 12 2014, 1:42 PM
mcrosier closed this revision.Dec 12 2014, 3:28 PM

Committed r224165.