[PATCH] D39352: [SimplifyCFG] Don't do if-conversion if there is a long dependence chain

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 28 14:59:44 PST 2017


Carrot added a comment.

The performance regression of https://reviews.llvm.org/P8055 is not because of missing adc instruction.

Slow version:

.LBB0_65:

  movzbl  (%rdx), %esi
  movq    %rsi, %rdi
  shrq    $3, %rdi
  andl    $24, %edi
  movq    32(%rsp,%rdi), %rdi
  btq     %rsi, %rdi
  jae     .LBB0_67
  
  addq    $1, %rbx

.LBB0_67:

  addq    $1, %rdx
  cmpq    %rdx, %r13
  jne     .LBB0_65

Fast version:

.LBB0_65:

  movzbl  (%rdx), %esi
  movq    %rsi, %rdi
  shrq    $3, %rdi
  andl    $24, %edi
  movq    32(%rsp,%rdi), %rdi
  btq     %rsi, %rdi
  adcq    $0, %rbx                                 // result of if conversion
  addq    $1, %rdx
  cmpq    %rdx, %r13
  jne     .LBB0_65

The result of if conversion %rbx is not used in later in BB67, so although there is long dependence chain in BB65, it does not prevent the processor execute instructions in BB67 and later BBs. For the branch version, it doesn't make instructions in BB67 executed earlier, but it bring extra penalty of branch misprediction, so it is slower.

In function FindLongDependenceChain, I should also check the result of if-conversion can really delay other instructions in BB2, if not, like in this case, we should do if-conversion.


Repository:
  rL LLVM

https://reviews.llvm.org/D39352





More information about the llvm-commits mailing list