[APInt] Add compare/compareSigned methods that return -1, 0, 1. Reimplement slt/ult and friends using them
ClosedPublic

Authored by craig.topper on Apr 20 2017, 11:40 PM.

Details

Summary

Currently sle and ule have to call slt/ult and eq to get the proper answer. This results in extra code for both calls and additional scans of multiword APInts.

This patch replaces slt/ult with a compareSigned/compare that can return -1, 0, or 1 so we can cover all the comparison functions with a single call.

While I was there I removed the activeBits calls and other checks at the start of the slow part of ult. Both of the activeBits calls potentially scan through each of the APInts separately. I can't imagine that's any better than just scanning them in parallel and doing the compares.

These changes seem to be good for about a 7-8k reduction on the size of the opt binary on my local x86-64 build.

Diff Detail

Repository
rL LLVM
craig.topper created this revision.Apr 20 2017, 11:40 PM

Just use tcCompare to implement the slow case compare code.

RKSimon added inline comments.Apr 21 2017, 2:14 AM
lib/Support/APInt.cpp
392 ↗(On Diff #96102)

Better to call tcCompare directly?

Address Simon's comment.

hans accepted this revision.Apr 21 2017, 9:18 AM

lgtm

This revision is now accepted and ready to land.Apr 21 2017, 9:18 AM
This revision was automatically updated to reflect the committed changes.