[all-commits] [llvm/llvm-project] 1baa38: [IR][PatternMatch] Only accept poison in getSplatV...

Nikita Popov via All-commits all-commits at lists.llvm.org
Wed Apr 17 23:45:02 PDT 2024


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

  Changed paths:
    M llvm/include/llvm/IR/Constant.h
    M llvm/include/llvm/IR/Constants.h
    M llvm/include/llvm/IR/PatternMatch.h
    M llvm/lib/Analysis/CmpInstAnalysis.cpp
    M llvm/lib/Analysis/InstructionSimplify.cpp
    M llvm/lib/Analysis/ValueTracking.cpp
    M llvm/lib/IR/Constants.cpp
    M llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
    M llvm/lib/Target/X86/X86FixupVectorConstants.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineInternal.h
    M llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
    M llvm/test/Transforms/InstCombine/and-or-icmp-const-icmp.ll
    M llvm/test/Transforms/InstCombine/binop-itofp.ll
    M llvm/test/Transforms/InstCombine/bswap-fold.ll
    M llvm/test/Transforms/InstCombine/bswap.ll
    M llvm/test/Transforms/InstCombine/compare-signs.ll
    M llvm/test/Transforms/InstCombine/fcmp-range-check-idiom.ll
    M llvm/test/Transforms/InstCombine/icmp-fsh.ll
    M llvm/test/Transforms/InstCombine/icmp-power2-and-icmp-shifted-mask.ll
    M llvm/test/Transforms/InstCombine/icmp-vec-inseltpoison.ll
    M llvm/test/Transforms/InstCombine/icmp-vec.ll
    M llvm/test/Transforms/InstCombine/low-bit-splat.ll
    M llvm/test/Transforms/InstCombine/lshr-trunc-sext-to-ashr-sext.ll
    M llvm/test/Transforms/InstCombine/select.ll
    M llvm/test/Transforms/InstCombine/signed-truncation-check.ll
    M llvm/test/Transforms/InstCombine/unsigned-add-lack-of-overflow-check.ll
    M llvm/test/Transforms/InstCombine/xor-ashr.ll
    M llvm/test/Transforms/InstSimplify/cast-unsigned-icmp-cmp-0.ll
    M llvm/test/Transforms/InstSimplify/icmp-constant.ll
    M llvm/test/Transforms/InstSimplify/maxmin_intrinsics.ll
    M llvm/unittests/IR/InstructionsTest.cpp
    M llvm/unittests/IR/PatternMatch.cpp

  Log Message:
  -----------
  [IR][PatternMatch] Only accept poison in getSplatValue() (#89159)

In #88217 a large set of matchers was changed to only accept poison
values in splats, but not undef values. This is because we now use
poison for non-demanded vector elements, and allowing undef can cause
correctness issues.

This patch covers the remaining matchers by changing the AllowUndef
parameter of getSplatValue() to AllowPoison instead. We also carry out
corresponding renames in matchers.

As a followup, we may want to change the default for things like m_APInt
to m_APIntAllowPoison (as this is much less risky when only allowing
poison), but this change doesn't do that.

There is one caveat here: We have a single place
(X86FixupVectorConstants) which does require handling of vector splats
with undefs. This is because this works on backend constant pool
entries, which currently still use undef instead of poison for
non-demanded elements (because SDAG as a whole does not have an explicit
poison representation). As it's just the single use, I've open-coded a
getSplatValueAllowUndef() helper there, to discourage use in any other
places.



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