[all-commits] [llvm/llvm-project] f03b06: [InstCombine] fold mul with decremented "shl -1" f...

Sanjay Patel via All-commits all-commits at lists.llvm.org
Wed Nov 2 06:30:16 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f03b069c5b70b59a9cb391a4c41250083aa6b2b4
      https://github.com/llvm/llvm-project/commit/f03b069c5b70b59a9cb391a4c41250083aa6b2b4
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-11-02 (Wed, 02 Nov 2022)

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

  Log Message:
  -----------
  [InstCombine] fold mul with decremented "shl -1" factor (2nd try)

This is a corrected version of:
bc886e9b587b

I made a copy-paste error that created an "add" instead of the
intended "sub" on that attempt. The regression tests showed the
bug, but I overlooked that.

As I said in a comment on issue #58717, the bug reports resulting
from the botched patch confirm that the pattern does occur in
many real-world applications, so hopefully eliminating the multiply
results in better code.

I added one more regression test in this version of the patch,
and here's an Alive2 proof to show that exact example:
https://alive2.llvm.org/ce/z/dge7VC

Original commit message:

This is a sibling to:
6064e92b0a84
...but we canonicalize the shl+add to shl+xor,
so the pattern is different than I expected:
https://alive2.llvm.org/ce/z/8CX16e

I have not found any patterns that are safe
to propagate no-wrap, so that is not included
here.

Differential Revision: https://reviews.llvm.org/D137157




More information about the All-commits mailing list