[all-commits] [llvm/llvm-project] de29b8: [InstSimplify] Fix simplifyAndOrWithICmpEq with un...

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Jul 16 02:40:26 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: de29b850f03092195bf21f3a39402adb4ed3c216
      https://github.com/llvm/llvm-project/commit/de29b850f03092195bf21f3a39402adb4ed3c216
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2024-07-16 (Tue, 16 Jul 2024)

  Changed paths:
    M llvm/lib/Analysis/InstructionSimplify.cpp
    M llvm/test/Transforms/InstSimplify/and-or-implied-cond.ll

  Log Message:
  -----------
  [InstSimplify] Fix simplifyAndOrWithICmpEq with undef refinement (#98898)

The final case in Simplify (where Res == Absorber and the predicate is
inverted) is not generally safe when the simplification is a refinement.
In particular, we may simplify assuming a specific value for undef, but
then chose a different one later.

However, it *is* safe to refine poison in this context, unlike in the
equivalent select folds. This is the reason why this fold did not use
AllowRefinement=false in the first place, and using that option would
introduce a lot of test regressions.

This patch takes the middle path of disabling undef refinements in
particular using the getWithoutUndef() SimplifyQuery option. However,
this option doesn't actually work in this case, because the problematic
fold is inside constant folding, and we currently don't propagate this
option all the way from InstSimplify over ConstantFolding to
ConstantFold. Work around this by explicitly checking for undef operands
in simplifyWithOpReplaced().

Finally, make sure that places where AllowRefinement=false also use
Q.getWithoutUndef(). I don't have a specific test case for this (the
original one does not work because we don't simplify selects with
constant condition in this mode in the first place) but this seems like
the correct thing to do to be conservative.

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



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