llvm-project/llvm/lib
Chris Lattner d3e6ae263c 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.

llvm-svn: 11964
2004-02-28 21:28:10 +00:00
..
Analysis Only clone global nodes between graphs if both graphs have the global. 2004-02-27 20:05:15 +00:00
AsmParser It turns out that the two dimensional vectors were causing big slowdowns 2004-02-09 21:03:38 +00:00
Bytecode This debugging hook is no longer needed. 2004-02-09 17:20:52 +00:00
CodeGen Rename member function to be consistent with the rest. 2004-02-27 06:11:15 +00:00
Debugger "fix" a nasty race condition 2004-01-14 21:18:03 +00:00
ExecutionEngine remove obsolete comment 2004-02-26 07:59:22 +00:00
Support Make sure that at least one virtual method is defined in a .cpp file to avoid 2004-02-26 07:24:18 +00:00
Target Change this so that LLC actually tries to run the code generator, though it will 2004-02-28 20:21:45 +00:00
Transforms Implement switch->br and br->switch folding by ripping out the switch->switch 2004-02-28 21:28:10 +00:00
VMCore Fix Regression/Assembler/2004-02-27-SelfUseAssertError.ll 2004-02-27 17:28:25 +00:00
Makefile CBackend is no longer here 2004-02-13 23:29:37 +00:00