This is an archive of the discontinued LLVM Phabricator instance.

[APInt] Implement APInt::intersects without creating a temporary APInt in the multiword case
ClosedPublic

Authored by craig.topper on Apr 19 2017, 4:01 PM.

Details

Summary

This is a simple question we should be able to answer without creating a temporary to hold the AND result. We can also get an early out as soon as we find a word that intersects.

Diff Detail

Event Timeline

craig.topper created this revision.Apr 19 2017, 4:01 PM
hans accepted this revision.Apr 19 2017, 4:17 PM

lgtm!

This revision is now accepted and ready to land.Apr 19 2017, 4:17 PM
davide accepted this revision.Apr 19 2017, 4:21 PM
davide added inline comments.
lib/Support/APInt.cpp
727–728

Shouldn't just pVal[i] & RHS.pVal[i] suffice?

Then at that point you can just rewrite it as :
return llvm::all_of etc..

davide added inline comments.Apr 19 2017, 4:22 PM
lib/Support/APInt.cpp
727–728

Nevermind, you probably can't use any_of as you need the index.

This revision was automatically updated to reflect the committed changes.