[llvm] [llvm] Don't combine repeated subnormal divisors (PR #149333)

Asher Mancinelli via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 21 18:12:49 PDT 2025


ashermancinelli wrote:

That's right. The transform only introduced a poison in one lane of a vector. All the other elements of the vector happened to be compile-time constants after constant folding, and they were all the same value. SelectionDAG then decided that because all the lanes had the same value or were poisons, it could transform the vector construction from a move into a broadcast, allowing the poisoned lane to take on the value of the other vector elements, which gave a completely wrong answer. [This is an example of the move -> broadcast optimization](https://godbolt.org/z/Tvhb1nfMT). Remove the `-mno-avx2` to see the broadcast instead of the move.

If a divide with a really small divisor (even one that flushes to zero) yields an infinity or unreasonable number at runtime, that makes sense. LLVM optimizing this into a garbage result because it knowingly introduced a poison which poisoned consumers of that operation is not as nice for our users.

https://github.com/llvm/llvm-project/pull/149333


More information about the llvm-commits mailing list