[all-commits] [llvm/llvm-project] 155e3a: [InstCombine] Add tests for reassosiating `(add/su...

goldsteinn via All-commits all-commits at lists.llvm.org
Tue Aug 27 11:43:43 PDT 2024


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

  Changed paths:
    A llvm/test/Transforms/InstCombine/fold-add-sub.ll

  Log Message:
  -----------
  [InstCombine] Add tests for reassosiating `(add/sub (sub/add) (sub/add))`; NFC


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

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineInternal.h
    M llvm/test/Transforms/InstCombine/fold-add-sub.ll

  Log Message:
  -----------
  [InstCombine] Simplify `(add/sub (sub/add) (sub/add))` irrelivant of use-count

Added folds:
    - `(add (sub X, Y), (sub Z, X))` -> `(sub Z, Y)`
    - `(sub (add X, Y), (add X, Z))` -> `(sub Y, Z)`

The fold typically is handled in the `Reassosiate` pass, but it fails
if the inner `sub`/`add` are multi-use. Less importantly, Reassosiate
doesn't propagate flags correctly.

This patch adds the fold explicitly the InstCombine

Proofs: https://alive2.llvm.org/ce/z/p6JyRP

Closes #105866


Compare: https://github.com/llvm/llvm-project/compare/ff81f9fbaeb3...a6edcea211a3

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