[all-commits] [llvm/llvm-project] b812e5: [SCEV] Consolidate code for proving wrap flags of ...

Philip Reames via All-commits all-commits at lists.llvm.org
Mon Aug 12 11:40:46 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b812e57ac301c7f88171cc73e213b70078727b16
      https://github.com/llvm/llvm-project/commit/b812e57ac301c7f88171cc73e213b70078727b16
  Author: Philip Reames <preames at rivosinc.com>
  Date:   2024-08-12 (Mon, 12 Aug 2024)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/ScalarEvolution/trip-count-implied-addrec.ll
    M llvm/test/Analysis/ScalarEvolution/trip-count-scalable-stride.ll

  Log Message:
  -----------
  [SCEV] Consolidate code for proving wrap flags of controlling finite IVs (#101404)

The canAssumeNoSelfWrap routine in howManyLessThans was doing two subtly
inter-related things. First, it was proving no-self-wrap. This exactly
duplicates the existing logic in the caller. Second, it was establishing
the precondition for the nw->nsw/nuw inference. Specifically, we need to
know that *this* exit must be taken for the inference to be sound.
Otherwise, another (possible abnormal) exit could be taken in the
iteration where this IV would become poison.

This change moves all of that logic into the caller, and caches the
resulting nuw/nsw flags in the AddRec. This centralizes the logic in one
place, and makes it clear that it all depends on controlling the sole
exit.

We do loose a couple cases with SCEV predication. Specifically, if SCEV
predication was able to convert e.g. zext(addrec) into an addrec(zext)
using predication, but didn't record the nuw fact on the new addrec,
then the consuming code can no longer fix this up. I don't think this
case particularly matters.

---------

Co-authored-by: Nikita Popov <github at npopov.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list