[PATCH] D68239: [InstCombine] dropRedundantMaskingOfLeftShiftInput(): change how we deal with mask

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 30 12:36:39 PDT 2019


lebedev.ri created this revision.
lebedev.ri added a reviewer: spatel.
lebedev.ri added a project: LLVM.
Herald added a subscriber: hiraditya.

Currently, we pre-check whether we need to produce a mask or not.
This involves some rather magical constants.
I'd like to extend this fold to also handle the situation
when there's also a `trunc` before outer shift.
That will require another set of magical constants.
It's ugly.

Instead, we can just compute the mask, and check
whether mask is a pass-through (all-ones) or not.
This way we don't need to have any magical numbers.
That's part 1 of the patch.

Part 2 is the `sanitizeUndefsTo()` change.
When we do `ConstantExpr::getZExt()`, that "extends" `undef` to `0`,
which means that for patterns a/b we'd assume that we must not produce
any bits for that channel, while in reality we simply didn't care
about that channel - i.e. we don't need to mask it.
Without this, `@t5_vec_undef()` in
`redundant-left-shift-input-masking-variant-{a,b}.ll` would regress.

Clearly, this also 'fixes` those new `undef` tests in
`partally-redundant-left-shift-input-masking-variant-*.ll`
(and now i have noticed that blatant typo in file name :D)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68239

Files:
  llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
  llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-a.ll
  llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-b.ll
  llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-c.ll
  llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-d.ll
  llvm/test/Transforms/InstCombine/partally-redundant-left-shift-input-masking-variant-e.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68239.222475.patch
Type: text/x-patch
Size: 12918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190930/7cc0a26a/attachment.bin>


More information about the llvm-commits mailing list