[all-commits] [llvm/llvm-project] 8b22bb: [DivRemPairs] Do not freeze poisons that can't be ...

Krzysztof Drewniak via All-commits all-commits at lists.llvm.org
Mon May 20 08:44:39 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8b22bb8a62a259e35ccc49fb2f50077a2772cf2f
      https://github.com/llvm/llvm-project/commit/8b22bb8a62a259e35ccc49fb2f50077a2772cf2f
  Author: Krzysztof Drewniak <Krzysztof.Drewniak at amd.com>
  Date:   2024-05-20 (Mon, 20 May 2024)

  Changed paths:
    M llvm/lib/Transforms/Scalar/DivRemPairs.cpp
    M llvm/test/Transforms/DivRemPairs/AMDGPU/div-rem-pairs.ll

  Log Message:
  -----------
  [DivRemPairs] Do not freeze poisons that can't be undef (#92627)

Per comments in DivRemPairs, the rewrite from
```llvm
    %div = div %X, %Y
    %rem = rem %X, %Y
```
to
```llvm
    %div = div %X, %Y
    %.mul = mul %div, %Y
    %rem = sub %X, %mul
```
is unsound when %X or %Y are undef.

However, it is known to be sound if %X or %Y are poison but can't be
undef, since both the pre- and post-rewrite %rem are `poison`.

Additionally, proofs: https://alive2.llvm.org/ce/z/xtNQ8j

A comment in the pass listed a TODO for changing a usage of
isGuaranteedNotToBeUndefOrPoison() in the pass to something that only
detects undef. Such a function has been implemented since the time that
TODO was written, but has not been used.

Therefore, this commit updates DivRemPairs to use
isGuaranteedNotToBeUndef() instead.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list