[all-commits] [llvm/llvm-project] 902acd: [InstCombine] Optimize away certain additions usin...

David Majnemer via All-commits all-commits at lists.llvm.org
Mon Oct 28 15:52:51 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 902acde34198bb11cc758dcf3aee00eb1cb09ceb
      https://github.com/llvm/llvm-project/commit/902acde34198bb11cc758dcf3aee00eb1cb09ceb
  Author: David Majnemer <david.majnemer at gmail.com>
  Date:   2024-10-28 (Mon, 28 Oct 2024)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/test/Transforms/InstCombine/and-compare.ll

  Log Message:
  -----------
  [InstCombine] Optimize away certain additions using modular arithmetic

We can turn:
```
  %add = add i8 %arg, C1
  %and = and i8 %add, C2
  %cmp = icmp eq i1 %and, C3
```

into:
```
  %and = and i8 %arg, C2
  %cmp = icmp eq i1 %and, (C3 - C1) & C2
```

This is only worth doing if the sequence is the sole user of the addition
operation.



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