[llvm] [LLVM][LangRef] Remove "n > 0" restriction from get.active.lanes.mask. (PR #152140)

Sam Parker via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 6 05:07:26 PDT 2025


sparker-arm wrote:

I'm sorry, I'm not really following... I don't seem to remember non-zeros being a problem, SCEV can normally tell you this with `IsLoopEntryGuardedByCond`. The problem was at the other end of the value scale. 

Originally, the intrinsic was defined using the backend-taken-count (BTC), the loop trip count - 1, whereas we actually wanted the loop trip count. But it was very difficult to prove that BTC wasn't MAX, which could cause overflow while performing the +1 to calculate the trip count. Conversely, if my memory is correct, we needed to be able to reconstruct in terms of BTC, so you _could_ wrap around zero performing the -1.

Though, it doesn't mean this is still the case.

Looking at SelectionDAGBuilder, it's using a UADDSAT so no overflow is going to happen. So, maybe this change is okay.

I haven't looked at the final backend pass in years, and I can't remember if there's any assumptions there about non-zero values. @davemgreen is really the only person who will have any form of recent memory about it.

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


More information about the llvm-commits mailing list