[all-commits] [llvm/llvm-project] e8fe15: [InstCombine] Add exact flags for ext idiom `shr (...

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Thu Nov 16 01:30:16 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e8fe15ccf1a0e3fab66200471b2e7d9cd7228f4b
      https://github.com/llvm/llvm-project/commit/e8fe15ccf1a0e3fab66200471b2e7d9cd7228f4b
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2023-11-16 (Thu, 16 Nov 2023)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
    M llvm/test/Transforms/InstCombine/canonicalize-low-bit-mask-v4-and-icmp-eq-to-icmp-ule.ll
    M llvm/test/Transforms/InstCombine/canonicalize-low-bit-mask-v4-and-icmp-ne-to-icmp-ugt.ll
    M llvm/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll
    M llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-d.ll
    M llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-e.ll
    M llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-d.ll
    M llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-e.ll
    M llvm/test/Transforms/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-d.ll
    M llvm/test/Transforms/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-e.ll
    M llvm/test/Transforms/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-f.ll
    M llvm/test/Transforms/InstCombine/redundant-left-shift-input-masking-variant-d.ll
    M llvm/test/Transforms/InstCombine/redundant-left-shift-input-masking-variant-e.ll
    M llvm/test/Transforms/InstCombine/redundant-left-shift-input-masking-variant-f.ll
    M llvm/test/Transforms/InstCombine/redundant-right-shift-input-masking.ll
    M llvm/test/Transforms/InstCombine/sext.ll
    M llvm/test/Transforms/InstCombine/shift-by-signext.ll
    M llvm/test/Transforms/InstCombine/trunc-inseltpoison.ll
    M llvm/test/Transforms/InstCombine/trunc.ll
    M llvm/test/Transforms/InstCombine/variable-signext-of-variable-high-bit-extraction.ll
    M llvm/test/Transforms/PhaseOrdering/two-shifts-by-sext.ll

  Log Message:
  -----------
  [InstCombine] Add exact flags for ext idiom `shr (shl X, Y), Y` (#72483)

This patch adds exact flags for sext/zext idiom `shr (shl X, Y), Y`.
Alive2: https://alive2.llvm.org/ce/z/xYFpfB

We can generalize it to handle pattern `shr (shl X, Y), Z` with `Y u>=
Z` (e.g., non-splat vectors). But I don't think it's worth the effort.

This missed optimization is discovered with the help of
https://github.com/AliveToolkit/alive2/pull/962.




More information about the All-commits mailing list