[InstCombine] add nuw to any (1<<x)
authorSanjay Patel <spatel@rotateright.com>
Thu, 15 Dec 2022 16:41:22 +0000 (11:41 -0500)
committerSanjay Patel <spatel@rotateright.com>
Thu, 15 Dec 2022 17:03:47 +0000 (12:03 -0500)
commitd4493dd1ed58ac3f1eab0c4ca6e363e2b15bfd1c
treed3e0715fa8006561b713c7133af86142571501cf
parentae05bd99d3b197eda419963ac8118295068eb19d
[InstCombine] add nuw to any (1<<x)

https://alive2.llvm.org/ce/z/9EjDKE

This was mentioned as a missing fold in D139598.

It can unlock follow-on folds in some cases.
This verifies one of the changed tests:
https://alive2.llvm.org/ce/z/B_btDM
41 files changed:
llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
llvm/test/Transforms/InstCombine/and-or-icmps.ll
llvm/test/Transforms/InstCombine/and2.ll
llvm/test/Transforms/InstCombine/apint-shl-trunc.ll
llvm/test/Transforms/InstCombine/canonicalize-low-bit-mask-v2-and-icmp-eq-to-icmp-ule.ll
llvm/test/Transforms/InstCombine/canonicalize-low-bit-mask-v2-and-icmp-ne-to-icmp-ugt.ll
llvm/test/Transforms/InstCombine/canonicalize-low-bit-mask-v3-and-icmp-eq-to-icmp-ule.ll
llvm/test/Transforms/InstCombine/canonicalize-low-bit-mask-v3-and-icmp-ne-to-icmp-ugt.ll
llvm/test/Transforms/InstCombine/canonicalize-low-bit-mask-v4-and-icmp-eq-to-icmp-ule.ll
llvm/test/Transforms/InstCombine/canonicalize-low-bit-mask-v4-and-icmp-ne-to-icmp-ugt.ll
llvm/test/Transforms/InstCombine/conditional-variable-length-signext-after-high-bit-extract.ll
llvm/test/Transforms/InstCombine/div-shift.ll
llvm/test/Transforms/InstCombine/get-lowbitmask-upto-and-including-bit.ll
llvm/test/Transforms/InstCombine/icmp-trunc.ll
llvm/test/Transforms/InstCombine/icmp-uge-of-add-of-shl-one-by-bits-to-allones-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll
llvm/test/Transforms/InstCombine/icmp-uge-of-not-of-shl-allones-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll
llvm/test/Transforms/InstCombine/icmp-ugt-of-shl-1-by-bits-and-val-to-icmp-eq-of-lshr-val-by-bits-and-0.ll
llvm/test/Transforms/InstCombine/icmp-ule-of-shl-1-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll
llvm/test/Transforms/InstCombine/icmp-ult-of-add-of-shl-one-by-bits-to-allones-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll
llvm/test/Transforms/InstCombine/icmp-ult-of-not-of-shl-allones-by-bits-and-val-to-icmp-ne-of-lshr-val-by-bits-and-0.ll
llvm/test/Transforms/InstCombine/icmp.ll
llvm/test/Transforms/InstCombine/memchr.ll
llvm/test/Transforms/InstCombine/mul-inseltpoison.ll
llvm/test/Transforms/InstCombine/mul.ll
llvm/test/Transforms/InstCombine/onehot_merge.ll
llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-after-truncation-variant-a.ll
llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-a.ll
llvm/test/Transforms/InstCombine/redundant-left-shift-input-masking-after-truncation-variant-a.ll
llvm/test/Transforms/InstCombine/redundant-left-shift-input-masking-variant-a.ll
llvm/test/Transforms/InstCombine/rem.ll
llvm/test/Transforms/InstCombine/select-ctlz-to-cttz.ll
llvm/test/Transforms/InstCombine/set-lowbits-mask-canonicalize.ll
llvm/test/Transforms/InstCombine/shift-add.ll
llvm/test/Transforms/InstCombine/shift-direction-in-bit-test.ll
llvm/test/Transforms/InstCombine/shift.ll
llvm/test/Transforms/InstCombine/shl-sub.ll
llvm/test/Transforms/InstCombine/strchr-1.ll
llvm/test/Transforms/InstCombine/sub-of-negatible-inseltpoison.ll
llvm/test/Transforms/InstCombine/sub-of-negatible.ll
llvm/test/Transforms/InstCombine/xor.ll
llvm/test/Transforms/InstCombine/zext.ll