diff options
author | Chris Lattner <sabre@nondot.org> | 2010-01-02 21:50:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-01-02 21:50:18 +0000 |
commit | b4f82b4b4f5b9bb67f10375aa633302fddce82ce (patch) | |
tree | d471a3cd24947f404f4702d01310297619b56b16 /test/Transforms | |
parent | 1c91fae649734abe6f8271862fe3ba917e191279 (diff) | |
download | external_llvm-b4f82b4b4f5b9bb67f10375aa633302fddce82ce.zip external_llvm-b4f82b4b4f5b9bb67f10375aa633302fddce82ce.tar.gz external_llvm-b4f82b4b4f5b9bb67f10375aa633302fddce82ce.tar.bz2 |
Teach the table lookup optimization to generate range compares
when a consequtive sequence of elements all satisfies the
predicate. Like the double compare case, this generates better
code than the magic constant case and generalizes to more than
32/64 element array lookups.
Here are some examples where it triggers. From 403.gcc, most
accesses to the rtx_class array are handled, e.g.:
@rtx_class = constant [153 x i8] c"xxxxxmmmmmmmmxxxxxxxxxxxxmxxxxxxiiixxxxxxxxxxxxxxxxxxxooxooooooxxoooooox3x2c21c2222ccc122222ccccaaaaaa<<<<<<<<<<<<<<<<<<111111111111bbooxxxxxxxxxxcc2211x", align 32 ; <[153 x i8]*> [#uses=547]
%142 = icmp eq i8 %141, 105
@rtx_class = constant [153 x i8] c"xxxxxmmmmmmmmxxxxxxxxxxxxmxxxxxxiiixxxxxxxxxxxxxxxxxxxooxooooooxxoooooox3x2c21c2222ccc122222ccccaaaaaa<<<<<<<<<<<<<<<<<<111111111111bbooxxxxxxxxxxcc2211x", align 32 ; <[153 x i8]*> [#uses=543]
%165 = icmp eq i8 %164, 60
Also, most of the 59-element arrays (mode_class/rid_to_yy, etc)
optimized before are actually range compares. This lets 32-bit
machines optimize them.
400.perlbmk has stuff like this:
400.perlbmk: PL_regkind, even for 32-bit:
@PL_regkind = constant [62 x i8] c"\00\00\02\02\02\06\06\06\06\09\09\0B\0B\0D\0E\0E\0E\11\12\12\14\14\16\16\18\18\1A\1A\1C\1C\1E\1F !!!$$&'((((,-.///88886789:;8$", align 32 ; <[62 x i8]*> [#uses=4]
%811 = icmp ne i8 %810, 33
@PL_utf8skip = constant [256 x i8] c"\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\04\04\04\04\04\04\04\04\05\05\05\05\06\06\07\0D", align 32 ; <[256 x i8]*> [#uses=94]
%12 = icmp ult i8 %10, 2
etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92426 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r-- | test/Transforms/InstCombine/load-cmp.ll | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/test/Transforms/InstCombine/load-cmp.ll b/test/Transforms/InstCombine/load-cmp.ll index fabafed..69e13cb 100644 --- a/test/Transforms/InstCombine/load-cmp.ll +++ b/test/Transforms/InstCombine/load-cmp.ll @@ -2,7 +2,8 @@ @G16 = internal constant [10 x i16] [i16 35, i16 82, i16 69, i16 81, i16 85, i16 73, i16 82, i16 69, i16 68, i16 0] -@GD = internal constant [3 x double] [double 1.0, double 4.0, double -20.0] +@GD = internal constant [6 x double] + [double -10.0, double 1.0, double 4.0, double 2.0, double -20.0, double -40.0] define i1 @test1(i32 %X) { %P = getelementptr [10 x i16]* @G16, i32 0, i32 %X @@ -25,12 +26,12 @@ define i1 @test2(i32 %X) { } define i1 @test3(i32 %X) { - %P = getelementptr [3 x double]* @GD, i32 0, i32 %X + %P = getelementptr [6 x double]* @GD, i32 0, i32 %X %Q = load double* %P %R = fcmp oeq double %Q, 1.0 ret i1 %R ; CHECK: @test3 -; CHECK-NEXT: %R = icmp eq i32 %X, 0 +; CHECK-NEXT: %R = icmp eq i32 %X, 1 ; CHECK-NEXT: ret i1 %R } @@ -57,3 +58,25 @@ define i1 @test5(i32 %X) { ; CHECK-NEXT: %R = or i1 ; CHECK-NEXT: ret i1 %R } + +define i1 @test6(i32 %X) { + %P = getelementptr [6 x double]* @GD, i32 0, i32 %X + %Q = load double* %P + %R = fcmp ogt double %Q, 0.0 + ret i1 %R +; CHECK: @test6 +; CHECK-NEXT: add i32 %X, -1 +; CHECK-NEXT: %R = icmp ult i32 {{.*}}, 3 +; CHECK-NEXT: ret i1 %R +} + +define i1 @test7(i32 %X) { + %P = getelementptr [6 x double]* @GD, i32 0, i32 %X + %Q = load double* %P + %R = fcmp olt double %Q, 0.0 + ret i1 %R +; CHECK: @test7 +; CHECK-NEXT: add i32 %X, -1 +; CHECK-NEXT: %R = icmp ugt i32 {{.*}}, 2 +; CHECK-NEXT: ret i1 %R +} |