[all-commits] [llvm/llvm-project] f16125: [CodeGenPrepare][X86] Add tests for folding `urem`...

goldsteinn via All-commits all-commits at lists.llvm.org
Sun Aug 18 15:58:57 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f16125a13ce725b1e936468e08257c0fbb80c0fa
      https://github.com/llvm/llvm-project/commit/f16125a13ce725b1e936468e08257c0fbb80c0fa
  Author: Noah Goldstein <goldstein.w.n at gmail.com>
  Date:   2024-08-18 (Sun, 18 Aug 2024)

  Changed paths:
    A llvm/test/CodeGen/X86/fold-loop-of-urem.ll
    A llvm/test/Transforms/CodeGenPrepare/X86/fold-loop-of-urem.ll

  Log Message:
  -----------
  [CodeGenPrepare][X86] Add tests for folding `urem` with loop invariant value; NFC


  Commit: c64ce8bf283120fd145a57d0e61f9697f719139d
      https://github.com/llvm/llvm-project/commit/c64ce8bf283120fd145a57d0e61f9697f719139d
  Author: Noah Goldstein <goldstein.w.n at gmail.com>
  Date:   2024-08-18 (Sun, 18 Aug 2024)

  Changed paths:
    M llvm/lib/CodeGen/CodeGenPrepare.cpp
    M llvm/test/CodeGen/X86/fold-loop-of-urem.ll
    M llvm/test/Transforms/CodeGenPrepare/X86/fold-loop-of-urem.ll

  Log Message:
  -----------
  [CodeGenPrepare] Folding `urem` with loop invariant value

```
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;
```

In its current state, only if `IncrLoopInvariant` and `Start` both
being zero.

Alive2 seemed unable to prove this (see:
https://alive2.llvm.org/ce/z/ATGDp3 which is clearly wrong but still
checks out...) so wrote an exhaustive test here:
https://godbolt.org/z/WYa561388

Closes #96625


Compare: https://github.com/llvm/llvm-project/compare/1a6bf94407af...c64ce8bf2831

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