llvm-mirror/lib/Transforms/Utils
Chris Lattner 8ccddbd123 Fold code like:
if (C)
    V1 |= V2;

into:
  Vx = V1 | V2;
  V1 = select C, V1, Vx

when the expression can be evaluated unconditionally and is *cheap* to
execute.  This limited form of if conversion is quite handy in lots of cases.
For example, it turns this testcase into straight-line code:

int in0 ; int in1 ; int in2 ; int in3 ;
int in4 ; int in5 ; int in6 ; int in7 ;
int in8 ; int in9 ; int in10; int in11;
int in12; int in13; int in14; int in15;
long output;

void mux(void) {
  output =
      (in0   ?  0x00000001 : 0) | (in1   ?  0x00000002 : 0) |
      (in2   ?  0x00000004 : 0) | (in3   ?  0x00000008 : 0) |
      (in4   ?  0x00000010 : 0) | (in5   ?  0x00000020 : 0) |
      (in6   ?  0x00000040 : 0) | (in7   ?  0x00000080 : 0) |
      (in8   ?  0x00000100 : 0) | (in9   ?  0x00000200 : 0) |
      (in10  ?  0x00000400 : 0) | (in11  ?  0x00000800 : 0) |
      (in12  ?  0x00001000 : 0) | (in13  ?  0x00002000 : 0) |
      (in14  ?  0x00004000 : 0) | (in15  ?  0x00008000 : 0) ;
}

llvm-svn: 12798
2004-04-09 22:50:22 +00:00
..
BasicBlockUtils.cpp Finegrainify namespacification 2004-01-09 06:12:26 +00:00
BreakCriticalEdges.cpp Fix bug: test/Regression/Transforms/LowerInvoke/2004-02-29-PHICrash.llx 2004-02-29 22:24:41 +00:00
CloneFunction.cpp Minor speedup, don't query ValueMap each time through the loop 2004-02-04 21:44:26 +00:00
CloneModule.cpp Finegrainify namespacification 2004-01-09 06:12:26 +00:00
CloneTrace.cpp Give CloneBasicBlock an optional function argument to specify which function 2004-02-04 01:19:43 +00:00
CodeExtractor.cpp Fix bug: CodeExtractor/2004-03-17-MissedLiveIns.ll 2004-03-18 05:56:32 +00:00
DemoteRegToStack.cpp Fix PR310 and TailDup/2004-04-01-DemoteRegToStack.llx 2004-04-01 20:28:45 +00:00
InlineFunction.cpp Fix compilation of 126.gcc: intrinsic functions cannot throw, so they are not 2004-02-13 16:47:35 +00:00
Linker.cpp Fix linking of constant expr casts due to type resolution changes. With 2004-03-31 02:58:28 +00:00
Local.cpp Add constant folding wrapper support for select instructions. 2004-03-12 05:53:03 +00:00
Makefile Added LLVM copyright notice to Makefiles. 2003-10-20 22:26:57 +00:00
PromoteMemoryToRegister.cpp Implement ScalarRepl/select_promote.ll 2004-04-08 19:59:34 +00:00
SimplifyCFG.cpp Fold code like: 2004-04-09 22:50:22 +00:00
UnifyFunctionExitNodes.cpp Minor cleanups and simplifications 2003-11-21 16:52:05 +00:00
ValueMapper.cpp Adjustments to support the new ConstantAggregateZero class 2004-02-15 05:55:15 +00:00
ValueMapper.h Finegrainify namespacification 2004-01-09 06:12:26 +00:00