[all-commits] [llvm/llvm-project] fe1529: [InstCombine] fold exact sdiv to ashr

Sanjay Patel via All-commits all-commits at lists.llvm.org
Sat Oct 8 06:54:52 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fe15290e0cf5d2bcdefca2e81ef6ff8155a2f7a8
      https://github.com/llvm/llvm-project/commit/fe15290e0cf5d2bcdefca2e81ef6ff8155a2f7a8
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-10-08 (Sat, 08 Oct 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
    M llvm/test/Transforms/InstCombine/sdiv-exact-by-power-of-two.ll

  Log Message:
  -----------
  [InstCombine] fold exact sdiv to ashr

sdiv exact X, (1<<ShAmt) --> ashr exact X, ShAmt (if shl is non-negative)

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

It would probably be better to use ValueTracking to replace this
and the existing transform above it, but the analysis does not
account for the no-wrap properly, and it's not immediately clear
to me how to fix it.




More information about the All-commits mailing list