llvm-6502/lib
Chris Lattner d7115b01a0 Implement shift.ll:test23. If we are shifting right then immediately truncating
the result, turn signed shift rights into unsigned shift rights if possible.

This leads to later simplification and happens *often* in 176.gcc.  For example,
this testcase:

struct xxx { unsigned int code : 8; };
enum codes { A, B, C, D, E, F };
int foo(struct xxx *P) {
  if ((enum codes)P->code == A)
     bar();
}

used to be compiled to:

int %foo(%struct.xxx* %P) {
        %tmp.1 = getelementptr %struct.xxx* %P, int 0, uint 0           ; <uint*> [#uses=1]
        %tmp.2 = load uint* %tmp.1              ; <uint> [#uses=1]
        %tmp.3 = cast uint %tmp.2 to int                ; <int> [#uses=1]
        %tmp.4 = shl int %tmp.3, ubyte 24               ; <int> [#uses=1]
        %tmp.5 = shr int %tmp.4, ubyte 24               ; <int> [#uses=1]
        %tmp.6 = cast int %tmp.5 to sbyte               ; <sbyte> [#uses=1]
        %tmp.8 = seteq sbyte %tmp.6, 0          ; <bool> [#uses=1]
        br bool %tmp.8, label %then, label %UnifiedReturnBlock

Now it is compiled to:

        %tmp.1 = getelementptr %struct.xxx* %P, int 0, uint 0           ; <uint*> [#uses=1]
        %tmp.2 = load uint* %tmp.1              ; <uint> [#uses=1]
        %tmp.2 = cast uint %tmp.2 to sbyte              ; <sbyte> [#uses=1]
        %tmp.8 = seteq sbyte %tmp.2, 0          ; <bool> [#uses=1]
        br bool %tmp.8, label %then, label %UnifiedReturnBlock

which is the difference between this:

foo:
        subl $4, %esp
        movl 8(%esp), %eax
        movl (%eax), %eax
        shll $24, %eax
        sarl $24, %eax
        testb %al, %al
        jne .LBBfoo_2

and this:

foo:
        subl $4, %esp
        movl 8(%esp), %eax
        movl (%eax), %eax
        testb %al, %al
        jne .LBBfoo_2

This occurs 3243 times total in the External tests, 215x in povray,
6x in each f2c'd program, 1451x in 176.gcc, 7x in crafty, 20x in perl,
25x in gap, 3x in m88ksim, 25x in ijpeg.

Maybe this will cause a little jump on gcc tommorow :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21715 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-06 04:18:52 +00:00
..
Analysis Remove extra blank line 2005-05-05 23:43:47 +00:00
Archive Remove vim settings from source code; people should use llvm/utils/vim/vimrc 2005-05-05 22:33:09 +00:00
AsmParser Remove support for 1.0 style varargs 2005-05-02 19:07:27 +00:00
Bytecode Remove vim settings from source code; people should use llvm/utils/vim/vimrc 2005-05-05 22:33:09 +00:00
CodeGen * Order #includes alphabetically 2005-05-05 23:45:17 +00:00
Debugger Remove trailing whitespace 2005-04-21 22:36:52 +00:00
ExecutionEngine Convert tabs to spaces 2005-04-22 04:08:30 +00:00
Linker Remove trailing whitespace 2005-04-21 22:55:34 +00:00
Support * Order #includes as per style guide 2005-04-22 19:13:22 +00:00
System Remove vim settings from source code; people should use llvm/utils/vim/vimrc 2005-05-05 22:33:09 +00:00
Target fix typo 2005-05-04 19:25:37 +00:00
Transforms Implement shift.ll:test23. If we are shifting right then immediately truncating 2005-05-06 04:18:52 +00:00
VMCore Implement count leading zeros (ctlz), count trailing zeros (cttz), and count 2005-05-03 17:19:30 +00:00
Makefile Add the Linker library 2004-11-14 21:54:41 +00:00