[all-commits] [llvm/llvm-project] 2b7830: [DAGCombiner] Freeze maybe poison operands when fo...

Björn Pettersson via All-commits all-commits at lists.llvm.org
Mon Jul 22 08:20:08 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2b78303e3f78c1eeb4b1362933290c490ce5fff6
      https://github.com/llvm/llvm-project/commit/2b78303e3f78c1eeb4b1362933290c490ce5fff6
  Author: Björn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2024-07-22 (Mon, 22 Jul 2024)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    M llvm/test/CodeGen/AArch64/complex-deinterleaving-reductions-predicated-scalable.ll
    M llvm/test/CodeGen/AArch64/fast-isel-select.ll
    M llvm/test/CodeGen/AArch64/intrinsic-cttz-elts-sve.ll
    M llvm/test/CodeGen/AArch64/sve-fp-int-min-max.ll
    M llvm/test/CodeGen/AMDGPU/div_i128.ll
    M llvm/test/CodeGen/AMDGPU/divergence-driven-trunc-to-i1.ll
    M llvm/test/CodeGen/AMDGPU/fptoi.i128.ll
    M llvm/test/CodeGen/AMDGPU/rem_i128.ll
    M llvm/test/CodeGen/NVPTX/i128.ll
    M llvm/test/CodeGen/RISCV/pr84653_pr85190.ll
    M llvm/test/CodeGen/SystemZ/pr60413.ll
    M llvm/test/CodeGen/VE/Scalar/max.ll
    M llvm/test/CodeGen/VE/Scalar/min.ll
    M llvm/test/CodeGen/X86/combine-pmadd.ll
    M llvm/test/CodeGen/X86/div-rem-pair-recomposition-signed.ll
    M llvm/test/CodeGen/X86/pr64589.ll
    M llvm/test/CodeGen/X86/vector-compare-all_of.ll
    M llvm/test/CodeGen/X86/vector-compare-any_of.ll

  Log Message:
  -----------
  [DAGCombiner] Freeze maybe poison operands when folding select to logic (#84924)

Just like for regular IR we need to treat SELECT as conditionally
blocking poison in SelectionDAG. So (unless the condition itself is
poison) the result is only poison if the selected true/false value is
poison.
Thus, when doing DAG combines that turn SELECT into arithmetic/logical
operations (e.g. AND/OR) we need to make sure that the new operations
aren't more poisonous. One way to do that is to use FREEZE to make
sure the operands aren't posion.

This patch aims at fixing the kind of miscompiles reported in
  https://github.com/llvm/llvm-project/issues/84653
and
  https://github.com/llvm/llvm-project/issues/85190

Solution is to make sure that we insert FREEZE, if needed to make
the fold sound, when using the foldBoolSelectToLogic and
foldVSelectToSignBitSplatMask DAG combines.



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