[PATCH] D32563: Add LiveRangeShrink pass to shrink live range within BB.

Andrea Di Biagio via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 1 04:26:42 PDT 2017


andreadb added a comment.

In all the new test cases, the problem is indirectly caused by the presence of function calls in the reassociated expression.
Your patch is essentially trying to solve a register pressure problem at LLVM IR level by pre-scheduling instructions. However, as Sanjay pointed out, this design can be a bit fragile since later passes may undo your canonicalization.

My understanding is that the `pre-RA-scheduler` pass should be responsible for finding a good schedule that minimizes register pressure in preparation for regalloc.
Do you know why `pre-RA-scheduler` is unable to find a good schedule for your particular case?

If I pass ‘test2()’ to llc (with flag `-pre-RA-sched=list-ilp -mtriple=x86_64-unknown-unknown`) then I get the expected schedule of call/add instructions.

  test2:
          pushq   %r14
          pushq   %rbx
          pushq   %rax
          callq   foo
          movl    %eax, %r14d
          callq   foo
          movl    %eax, %ebx
          addq    %r14, %rbx
          callq   foo
          movl    %eax, %eax
          addq    %rbx, %rax
          addq    $8, %rsp
          popq    %rbx
          popq    %r14
          retq


https://reviews.llvm.org/D32563





More information about the llvm-commits mailing list