OSDN Git Service

[APInt] Add compare/compareSigned methods that return -1, 0, 1. Reimplement slt/ult...
authorCraig Topper <craig.topper@gmail.com>
Fri, 21 Apr 2017 16:13:15 +0000 (16:13 +0000)
committerCraig Topper <craig.topper@gmail.com>
Fri, 21 Apr 2017 16:13:15 +0000 (16:13 +0000)
commitfe916169d7dbe14901bbed36eff6131c8b6039e1
tree5e42143fe995eada1884e06dca07d7413da145c8
parent4059808ff6473ea38862d2ea4cc7cb03a35f5b24
[APInt] Add compare/compareSigned methods that return -1, 0, 1. Reimplement slt/ult and friends using them

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. Now we just share the code with tcCompare.

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.

Differential Revision: https://reviews.llvm.org/D32339

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300995 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ADT/APInt.h
lib/Support/APInt.cpp