1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 04:22:57 +02:00
llvm-mirror/test/CodeGen
Evan Cheng c5f50f7322 SimplifyCFG has stopped duplicating returns into predecessors to canonicalize IR
to have single return block (at least getting there) for optimizations. This
is general goodness but it would prevent some tailcall optimizations.
One specific case is code like this:
int f1(void);
int f2(void);
int f3(void);
int f4(void);
int f5(void);
int f6(void);
int foo(int x) {
  switch(x) {
  case 1: return f1();
  case 2: return f2();
  case 3: return f3();
  case 4: return f4();
  case 5: return f5();
  case 6: return f6();
  }
}

=>
LBB0_2:                                 ## %sw.bb
  callq   _f1
  popq    %rbp
  ret
LBB0_3:                                 ## %sw.bb1
  callq   _f2
  popq    %rbp
  ret
LBB0_4:                                 ## %sw.bb3
  callq   _f3
  popq    %rbp
  ret

This patch teaches codegenprep to duplicate returns when the return value
is a phi and where the phi operands are produced by tail calls followed by
an unconditional branch:

sw.bb7:                                           ; preds = %entry
  %call8 = tail call i32 @f5() nounwind
  br label %return
sw.bb9:                                           ; preds = %entry
  %call10 = tail call i32 @f6() nounwind
  br label %return
return:
  %retval.0 = phi i32 [ %call10, %sw.bb9 ], [ %call8, %sw.bb7 ], ... [ 0, %entry ]
  ret i32 %retval.0

This allows codegen to generate better code like this:

LBB0_2:                                 ## %sw.bb
        jmp     _f1                     ## TAILCALL
LBB0_3:                                 ## %sw.bb1
        jmp     _f2                     ## TAILCALL
LBB0_4:                                 ## %sw.bb3
        jmp     _f3                     ## TAILCALL

rdar://9147433

llvm-svn: 127953
2011-03-19 17:17:39 +00:00
..
Alpha
ARM Match a few more obvious patterns to revsh. rdar://9147637. 2011-03-18 21:52:42 +00:00
Blackfin Be nice to Xcore and the XMOS assembler and avoid quoting section names 2011-03-04 20:03:14 +00:00
CBackend
CellSPU Roll r127459 back in: 2011-03-11 21:52:04 +00:00
CPP
Generic Make this test x86 specific because the ARM backend can't handle it. 2011-02-28 12:30:47 +00:00
MBlaze
Mips Revert "Re-enable test and hope to silence the buildbots", still broken. 2011-03-09 22:48:46 +00:00
MSP430
PowerPC Fix mistyped CHECK lines. 2011-03-09 22:07:31 +00:00
PTX PTX: Fix various codegen issues 2011-03-18 19:24:28 +00:00
SPARC
SystemZ
Thumb Roll r127459 back in: 2011-03-11 21:52:04 +00:00
Thumb2 Roll r127459 back in: 2011-03-11 21:52:04 +00:00
X86 SimplifyCFG has stopped duplicating returns into predecessors to canonicalize IR 2011-03-19 17:17:39 +00:00
XCore Add XCore intrinsic for setpsc. 2011-03-17 18:42:05 +00:00