[all-commits] [llvm/llvm-project] fae7d6: [InstCombine] add tests with nsw/nuw for mul-of-se...

RotateRight via All-commits all-commits at lists.llvm.org
Tue Oct 12 09:57:53 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fae7d6886e4ed8d75a8efa6f74562a314d2762aa
      https://github.com/llvm/llvm-project/commit/fae7d6886e4ed8d75a8efa6f74562a314d2762aa
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-10-12 (Tue, 12 Oct 2021)

  Changed paths:
    M llvm/test/Transforms/InstCombine/mul-inseltpoison.ll

  Log Message:
  -----------
  [InstCombine] add tests with nsw/nuw for mul-of-select; NFC


  Commit: 7a2949647a3c6bbeebe439a078d66b986e12fce2
      https://github.com/llvm/llvm-project/commit/7a2949647a3c6bbeebe439a078d66b986e12fce2
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-10-12 (Tue, 12 Oct 2021)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
    M llvm/test/Transforms/InstCombine/mul-inseltpoison.ll

  Log Message:
  -----------
  [InstCombine] propagate no-wrap flag through select-of-mul fold

This may not be obvious, but Alive2 agrees:
https://alive2.llvm.org/ce/z/Ld9qNT

If the mul has "nsw", then -1 * INT_MIN is poison, so the
negate can also have "nsw" because 0 - INT_MIN is poison.

If the mul has "nuw", then that means the "OtherOp" can only
be 0 or 1 (anything else multiplied by 0xfff... would wrap).
So the replacement negate must be "nsw" because it is either
"0-0" or "0-1".

This is another regression noticed with a planned follow-up
to D111410.


Compare: https://github.com/llvm/llvm-project/compare/5f4f5da634ce...7a2949647a3c


More information about the All-commits mailing list