[AArch64] How to combine a sequence IR cross BasicBlock?

As we known, we can combine the following sequence IR as all of them are in same BasicBlock.
and I also find the SelectionDAG will introduce CopyFromReg to express the node come from other BasicBlock, so we can’t combine them if they are not in same BasicBlock.

Does we have some way to address the issue when sequence IR cross BasicBlock usually?

define i64 @add_cntw(i64 %end) #0 {
  %vscale = call i64 @llvm.vscale.i64()
  %vscale4 = shl i64 %vscale, 2
  %index.next = add nuw nsw i64 %vscale4, %index

  ret i64 %index.next

Find a related reply

In GlobalIsel you always see the whole function. Thus, you can do cross basic block optimisations.