This is an archive of the discontinued LLVM Phabricator instance.

[APInt] Optimize APInt creation from uint64_t
ClosedPublic

Authored by craig.topper on Feb 28 2017, 11:51 PM.

Details

Summary

This patch moves the clearUnusedBits calls into the two different initialization paths for APInt from a uint64_t. This allows the compiler to better optimize the clearing of the unused bits for the single word case. And it puts the clearing for the multi word case into the initSlowCase function to save code. In the common case of initializing with 0 this allows the clearing to be completely optimized out for the single word case.

On my local x86 build this is showing a ~45kb reduction in the size of the opt binary.

Diff Detail

Event Timeline

craig.topper created this revision.Feb 28 2017, 11:51 PM
hans accepted this revision.Mar 1 2017, 8:40 AM

lgtm

include/llvm/ADT/APInt.h
246

Maybe it's just me, but I always find } else to look weird. I'd suggest putting braces around the else-branch too.

This revision is now accepted and ready to land.Mar 1 2017, 8:40 AM
This revision was automatically updated to reflect the committed changes.