[all-commits] [llvm/llvm-project] b0eeac: [InstCombine] Fold icmp of trunc nuw/nsw (#90436)

Nikita Popov via All-commits all-commits at lists.llvm.org
Thu May 2 19:09:22 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b0eeacb20379f6d80079793b8461f56c240e6570
      https://github.com/llvm/llvm-project/commit/b0eeacb20379f6d80079793b8461f56c240e6570
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2024-05-03 (Fri, 03 May 2024)

  Changed paths:
    M llvm/include/llvm/IR/PatternMatch.h
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/test/Transforms/InstCombine/icmp-of-trunc-ext.ll

  Log Message:
  -----------
  [InstCombine] Fold icmp of trunc nuw/nsw (#90436)

Convert the existing foldICmpTruncWithTruncOrExt() fold to work with
trunc nowrap flags instead of computeKnownBits(). This also allows us to
generalize the fold to work with signed comparisons.

Interestingly, apart from the obvious combinations like signed
predicates with trunc nsw, some non-obvious ones are also legal. For
example for unsigned predicates we can do the transform for two trunc
nsw as well (rather than only trunc nuw).

Proofs: https://alive2.llvm.org/ce/z/ndewwK



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