[all-commits] [llvm/llvm-project] 1e072a: [CGP] [CodeGenPrepare] Folding `urem` with loop in...
goldsteinn via All-commits
all-commits at lists.llvm.org
Thu Oct 31 07:14:54 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1e072ae289d77c3c9704a9ae832c076a303c435b
https://github.com/llvm/llvm-project/commit/1e072ae289d77c3c9704a9ae832c076a303c435b
Author: goldsteinn <35538541+goldsteinn at users.noreply.github.com>
Date: 2024-10-31 (Thu, 31 Oct 2024)
Changed paths:
M llvm/lib/CodeGen/CodeGenPrepare.cpp
M llvm/test/Transforms/CodeGenPrepare/X86/fold-loop-of-urem.ll
Log Message:
-----------
[CGP] [CodeGenPrepare] Folding `urem` with loop invariant value plus offset (#104724)
This extends the existing fold:
```
for(i = Start; i < End; ++i)
Rem = (i nuw+- IncrLoopInvariant) u% RemAmtLoopInvariant;
```
->
```
Rem = (Start nuw+- IncrLoopInvariant) % RemAmtLoopInvariant;
for(i = Start; i < End; ++i, ++rem)
Rem = rem == RemAmtLoopInvariant ? 0 : Rem;
```
To work with a non-zero `IncrLoopInvariant`.
This is a common usage in cases such as:
```
for(i = 0; i < N; ++i)
if ((i + 1) % X) == 0)
do_something_occasionally_but_not_first_iter();
```
Alive2 w/ i4/unrolled 6x (needs to be ran locally due to timeout):
https://alive2.llvm.org/ce/z/6tgyN3
Exhaust proof over all uint8_t combinations in C++:
https://godbolt.org/z/WYa561388
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