llvm-6502/lib/Transforms
Chris Lattner 542f149f00 Implement switch->br and br->switch folding by ripping out the switch->switch
and br->br code and generalizing it.  This allows us to compile code like this:

int test(Instruction *I) {
  if (isa<CastInst>(I))
    return foo(7);
  else if (isa<BranchInst>(I))
    return foo(123);
  else if (isa<UnwindInst>(I))
    return foo(1241);
  else if (isa<SetCondInst>(I))
    return foo(1);
  else if (isa<VAArgInst>(I))
    return foo(42);
  return foo(-1);
}

into:

int %_Z4testPN4llvm11InstructionE("struct.llvm::Instruction"* %I) {
entry:
        %tmp.1.i.i.i.i.i.i.i = getelementptr "struct.llvm::Instruction"* %I, long 0, ubyte 4            ; <uint*> [#uses=1]
        %tmp.2.i.i.i.i.i.i.i = load uint* %tmp.1.i.i.i.i.i.i.i          ; <uint> [#uses=2]
        %tmp.2.i.i.i.i.i.i = seteq uint %tmp.2.i.i.i.i.i.i.i, 27                ; <bool> [#uses=0]
        switch uint %tmp.2.i.i.i.i.i.i.i, label %endif.0 [
                 uint 27, label %then.0
                 uint 2, label %then.1
                 uint 5, label %then.2
                 uint 14, label %then.3
                 uint 15, label %then.3
                 uint 16, label %then.3
                 uint 17, label %then.3
                 uint 18, label %then.3
                 uint 19, label %then.3
                 uint 32, label %then.4
        ]
...

As well as handling the cases in 176.gcc and many other programs more effectively.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11964 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-28 21:28:10 +00:00
..
Hello Finegrainify namespacification 2004-01-09 06:12:26 +00:00
Instrumentation Remove dependence on return type of ConstantStruct::get 2004-02-15 04:07:32 +00:00
IPO setcond instructions don't have aliasing implications. 2004-02-27 18:09:25 +00:00
Scalar Rename AddUsesToWorkList -> AddUsersToWorkList, as that is what it does. 2004-02-28 05:22:00 +00:00
Utils Implement switch->br and br->switch folding by ripping out the switch->switch 2004-02-28 21:28:10 +00:00
ExprTypeConvert.cpp Start using the new and improve interface to FunctionType arguments 2004-02-09 04:14:01 +00:00
LevelRaise.cpp Adjust to the changed StructType interface. In particular, getElementTypes() is gone. 2004-02-09 04:37:31 +00:00
Makefile Added LLVM copyright notice to Makefiles. 2003-10-20 22:26:57 +00:00
TransformInternals.cpp Adjust to the changed StructType interface. In particular, getElementTypes() is gone. 2004-02-09 04:37:31 +00:00
TransformInternals.h Put all LLVM code into the llvm namespace, as per bug 109. 2003-11-11 22:41:34 +00:00