diff options
author | Chris Lattner <sabre@nondot.org> | 2010-12-17 06:20:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-12-17 06:20:15 +0000 |
commit | e27db74a60c44d2b5d2700ecde11b1adce0d0d59 (patch) | |
tree | 656f8aebf6c4dccb96f57e8e42b09bab6bcfe742 /include/llvm/Support/ConstantRange.h | |
parent | 1139d5090ab96e24342f12a6a6817d5898358e1e (diff) | |
download | llvm-e27db74a60c44d2b5d2700ecde11b1adce0d0d59.tar.gz llvm-e27db74a60c44d2b5d2700ecde11b1adce0d0d59.tar.bz2 llvm-e27db74a60c44d2b5d2700ecde11b1adce0d0d59.tar.xz |
improve switch formation to handle small range
comparisons formed by comparisons. For example,
this:
void foo(unsigned x) {
if (x == 0 || x == 1 || x == 3 || x == 4 || x == 6)
bar();
}
compiles into:
_foo: ## @foo
## BB#0: ## %entry
cmpl $6, %edi
ja LBB0_2
## BB#1: ## %entry
movl %edi, %eax
movl $91, %ecx
btq %rax, %rcx
jb LBB0_3
instead of:
_foo: ## @foo
## BB#0: ## %entry
cmpl $2, %edi
jb LBB0_4
## BB#1: ## %switch.early.test
cmpl $6, %edi
ja LBB0_3
## BB#2: ## %switch.early.test
movl %edi, %eax
movl $88, %ecx
btq %rax, %rcx
jb LBB0_4
This catches a bunch of cases in GCC, which look like this:
%804 = load i32* @which_alternative, align 4, !tbaa !0
%805 = icmp ult i32 %804, 2
%806 = icmp eq i32 %804, 3
%or.cond121 = or i1 %805, %806
%807 = icmp eq i32 %804, 4
%or.cond124 = or i1 %or.cond121, %807
br i1 %or.cond124, label %.thread, label %808
turning this into a range comparison.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122045 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/ConstantRange.h')
-rw-r--r-- | include/llvm/Support/ConstantRange.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/llvm/Support/ConstantRange.h b/include/llvm/Support/ConstantRange.h index 96e770951f..ced3a2cf2d 100644 --- a/include/llvm/Support/ConstantRange.h +++ b/include/llvm/Support/ConstantRange.h @@ -54,7 +54,7 @@ public: /// @brief Initialize a range of values explicitly. This will assert out if /// Lower==Upper and Lower != Min or Max value for its type. It will also /// assert out if the two APInt's are not the same bit width. - ConstantRange(const APInt& Lower, const APInt& Upper); + ConstantRange(const APInt &Lower, const APInt &Upper); /// makeICmpRegion - Produce the smallest range that contains all values that /// might satisfy the comparison specified by Pred when compared to any value |