[PATCH] D64512: [InstCombine] Dropping redundant masking before left-shift [0/5] (PR42563)
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 12 14:29:31 PDT 2019
lebedev.ri marked 2 inline comments as done.
lebedev.ri added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp:73
+// There are many variants to this pattern:
+// a) (x & ((1 << MaskShAmt) - 1)) << ShiftShAmt
+// All these patterns can be simplified to just:
----------------
Been thinking about this, and while the case where `ShiftShAmt` is a constant will already work,
the case where mask is constant, is another case here:
https://rise4fun.com/Alive/mc8
Will add that in some next follow-up patch.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp:103-104
+ unsigned BitWidth = X->getType()->getScalarSizeInBits();
+ if (!match(SumOfShAmts, m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_UGE,
+ APInt(BitWidth, BitWidth))))
+ return nullptr;
----------------
It may be possible to use `SimplifyICmpInst()` here, to catch more cases, may look into that after patchset.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64512/new/
https://reviews.llvm.org/D64512
More information about the llvm-commits
mailing list