[all-commits] [llvm/llvm-project] 09e3bf: [InstCombine][test] add tests for icmp simplify mi...

RotateRight via All-commits all-commits at lists.llvm.org
Thu Jul 1 14:47:27 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 09e3bf01b3da978b5437bf84c0b0f290974d8743
      https://github.com/llvm/llvm-project/commit/09e3bf01b3da978b5437bf84c0b0f290974d8743
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-07-01 (Thu, 01 Jul 2021)

  Changed paths:
    M llvm/test/Transforms/InstCombine/icmp.ll

  Log Message:
  -----------
  [InstCombine][test] add tests for icmp simplify miscompile (PR50944); NFC


  Commit: 9eb613b2de3163686b1a4bd1160f15ac56a4b083
      https://github.com/llvm/llvm-project/commit/9eb613b2de3163686b1a4bd1160f15ac56a4b083
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-07-01 (Thu, 01 Jul 2021)

  Changed paths:
    M llvm/lib/Analysis/InstructionSimplify.cpp
    M llvm/test/Transforms/InstCombine/icmp.ll

  Log Message:
  -----------
  [InstSimplify] do not propagate poison from select arm to icmp user

This is the cause of the miscompile in:
https://llvm.org/PR50944

The problem has likely existed for some time, but it was made visible with:
5af8bacc94024 ( D104661 )
handleOtherCmpSelSimplifications() assumed it can convert select of
constants to bool logic ops, but that does not work with poison.
We had a very similar construct in InstCombine, so the fix here
mimics the fix there.

The bug is in instsimplify, but I'm not sure how to reproduce it outside of
instcombine. The reason this is visible in instcombine is because we have a
hack (FIXME) to bypass simplification of a select when it has an icmp user:
https://github.com/llvm/llvm-project/blob/955f12589940634acc6c9901e8b25534808f691c/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp#L2632

So we get to an unusual case where we are trying to simplify an instruction
that has an operand that would have already simplified if we had processed
it in normal order.

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


Compare: https://github.com/llvm/llvm-project/compare/e4b9fecd392f...9eb613b2de31


More information about the All-commits mailing list