[all-commits] [llvm/llvm-project] f0faea: [InstSimplify] fold exact divide to poison if it i...

Sanjay Patel via All-commits all-commits at lists.llvm.org
Thu Dec 29 07:30:11 PST 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f0faea571403eb75a1d2d0dceca1dd52a7824d33
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-12-29 (Thu, 29 Dec 2022)

  Changed paths:
    M llvm/include/llvm/Analysis/InstructionSimplify.h
    M llvm/lib/Analysis/InstructionSimplify.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
    M llvm/test/Transforms/InstCombine/udiv-simplify.ll
    M llvm/test/Transforms/InstSimplify/div.ll

  Log Message:
  [InstSimplify] fold exact divide to poison if it is known to not divide evenly

This is related to the discussion in D140665. I was looking over the demanded
bits implementation in IR and noticed that we just bail out of a potential
fold if a udiv is exact:

Also, see tests added with 7f0c11509e8f.

Then, I saw that we could lose a fold to poison if we zap the exact with that
transform, so this patch tries to catch that as a preliminary step.

Alive2 proofs:
https://alive2.llvm.org/ce/z/-tz_RK (trailing zeros must be "less-than")
https://alive2.llvm.org/ce/z/c9CMsJ (general proof and specific example)

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

More information about the All-commits mailing list