[llvm] [LV][RFC] Generating conditional VPBB that will be skip when the mask is inactive in VPlan. (PR #141900)

Slava Zakharin via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 5 13:07:24 PDT 2025


vzakhari wrote:

Hi @ElvisWang123 and @npanchen, thank you for working on this!

I just want to post some information to support this change.  I tried this patch with Flang compiler on zen4 with setting `PreferControlFlow` to `true`.  481.wrf benchmark sped up by 36%. I guess this might be related to the following loop, but I did not confirm that:
```
DO 823 II=N1STAR,N1END
  IF ( icmask(II,JJ) ) THEN
    OV(II,JJ)=(MXM(II,JJ)-W(II,JJ))/(-PN(F(II,JJ,1))+         &
      PP(F(II,JJ,0))+EP)
    UN(II,JJ)=(W(II,JJ)-MN(II,JJ))/(PP(F(II,JJ,1))-             &
      PN(F(II,JJ,0))+EP)
  ENDIF
823 CONTINUE
```

It looks like the AOCC compiler also has a similar optimization, which they call BOSCC (https://reviews.llvm.org/D139074). Some performance results of BOSCC for 481.wrf are also reported in https://github.com/llvm/llvm-project/issues/137213.

So this change seems to be profitable for multiple benchmarks and multiple architectures, and it will be great to land it in llvm.

On the downside, I got a few failures on other benchmarks, and they are all related to `VPlan cost model and legacy cost model disagreed` assertion.  I can provide reproducers, if you would like to look at them.

https://github.com/llvm/llvm-project/pull/141900


More information about the llvm-commits mailing list