[all-commits] [llvm/llvm-project] ee0bf6: [InstCombine] try to fold mul by neg-power-of-2 to...

Sanjay Patel via All-commits all-commits at lists.llvm.org
Wed Sep 21 12:17:37 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ee0bf6472291bd40687046ab2990f987a022a940
      https://github.com/llvm/llvm-project/commit/ee0bf6472291bd40687046ab2990f987a022a940
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-09-21 (Wed, 21 Sep 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
    M llvm/test/Transforms/InstCombine/add.ll
    M llvm/test/Transforms/InstCombine/neg-alloca.ll
    M llvm/test/Transforms/Reassociate/basictest.ll

  Log Message:
  -----------
  [InstCombine] try to fold mul by neg-power-of-2 to shl

`(A * -2**C) + B --> B - (A << C)`

https://alive2.llvm.org/ce/z/A6BWkf

This inverts what Negator was doing before:
D134310 / 0f32a5dea0e9

Analysis and codegen are generally better without multiply,
so we should favor this form even if we trade add for sub
(because those are generally equivalent cost operations).




More information about the All-commits mailing list