[PATCH] D91415: [InstCombine] add multi-use demanded bits fold for add with low-bit mask

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 13 04:55:08 PST 2020


spatel created this revision.
spatel added reviewers: lebedev.ri, RKSimon, Bhramar.vatsa, craig.topper.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: LLVM.
spatel requested review of this revision.

I noticed an `add` example like the one from D91343 <https://reviews.llvm.org/D91343>, so here's a similar patch.
The logic is based on existing code for the single-use demanded bits fold. But I only matched a constant instead of using compute known bits on the operands because that was the motivating pattern.

I think this will allow removing a special-case (but incomplete) dedicated fold within visitAnd(), but I need to untangle the existing code to be sure.

https://rise4fun.com/Alive/V6fP

  Name: add with low mask 
  Pre: (C1 & (-1 u>> countLeadingZeros(C2))) == 0
  %a = add i8 %x, C1
  %r = and i8 %a, C2
  =>
  %r = and i8 %x, C2


https://reviews.llvm.org/D91415

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  llvm/test/Transforms/InstCombine/and.ll
  llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll
  llvm/test/Transforms/LoopVectorize/if-conversion-nest.ll
  llvm/test/Transforms/LoopVectorize/runtime-check.ll
  llvm/test/Transforms/PhaseOrdering/X86/vdiv.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91415.305006.patch
Type: text/x-patch
Size: 7281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201113/cc07eb47/attachment.bin>


More information about the llvm-commits mailing list