This is an archive of the discontinued LLVM Phabricator instance.

[APInt] Simplify the zext and sext methods
ClosedPublic

Authored by craig.topper on Apr 23 2017, 11:53 PM.

Details

Summary

This replaces a hand written copy loop with a call to memcpy for both zext and sext.

For sext, it replaces multiple if/else blocks propagating sign information forward. Now we just do a copy, a sign extension on the last copied word, a memset, and clearUnusedBits.

Diff Detail

Event Timeline

craig.topper created this revision.Apr 23 2017, 11:53 PM
RKSimon edited edge metadata.Apr 24 2017, 3:18 AM

APInt.cpp is very inconsistent with where it uses std::mem* and where it doesn't bother with std:: - is your plan to move over entirely to std::mem* ?

@RKSimon I hadn't given it much thought but I can do an NFC commit to change everything to std:: if you want.

@RKSimon I hadn't given it much thought but I can do an NFC commit to change everything to std:: if you want.

Its more to do with (a) the file is already inconsistent and (b) you're changing some but not all

What is the project prefered way of writing memcpy/memset/memmove? A quick grep shows that they are far more often used without std::

hans accepted this revision.Apr 24 2017, 10:20 AM

What is the project prefered way of writing memcpy/memset/memmove? A quick grep shows that they are far more often used without std::

I don't think the project has a prefered way. I see both plain "memcpy", "std::memcpy" and "::memcpy".

I like the "std::" variant and think it's the most correct one, but I also don't think this matters much.

lgtm

lib/Support/APInt.cpp
955

nit: spaces around -

This revision is now accepted and ready to land.Apr 24 2017, 10:20 AM
This revision was automatically updated to reflect the committed changes.