[all-commits] [llvm/llvm-project] a1b1c4: [InstCombine] Fix miscompile in negation of select...

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Apr 23 18:56:48 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a1b1c4a6d1d52916c5d885170a5f54632d579cdc
      https://github.com/llvm/llvm-project/commit/a1b1c4a6d1d52916c5d885170a5f54632d579cdc
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2024-04-24 (Wed, 24 Apr 2024)

  Changed paths:
    M llvm/include/llvm/Analysis/ValueTracking.h
    M llvm/lib/Analysis/ValueTracking.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
    M llvm/test/Transforms/InstCombine/sub-of-negatible.ll

  Log Message:
  -----------
  [InstCombine] Fix miscompile in negation of select (#89698)

Swapping the operands of a select is not valid if one hand is more
poisonous that the other, because the negation zero contains poison
elements.

Fix this by adding an extra parameter to isKnownNegation() to forbid
poison elements.

I've implemented this using manual checks to avoid needing four variants
for the NeedsNSW/AllowPoison combinations. Maybe there is a better way
to do this...

Fixes https://github.com/llvm/llvm-project/issues/89669.



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