[PATCH] D41233: [InstCombine] Canonizing 'and' before 'shl'

Omer Paparo Bivas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 05:32:11 PST 2017


opaparo created this revision.
opaparo added reviewers: spatel, craig.topper, AndreiGrischenko, zvi, lsaba, m_zuckerman.

Following a debate that aroused here <https://reviews.llvm.org/D39421>, a new canonical form to a masked shl is introduced. The canonical form will now be:

  define i8 @andshl(i8 %x) {
    %and = and i8 %x, 1
    %shl = shl nuw nsw i8 %and, 3
    ret i8 %shl
  }

instead of:

  define i8 @andshl(i8 %x) {
    %and = shl i8 %x, 3
    %shl = and i8 %and, 8
    ret i8 %shl
  }

Which will result, first and foremost, in smaller constants used by the 'and' instructions.

Some complementary changes are also introduced:

1. InstCombiner::MatchBSwap (under lib/Transforms/InstCombine/InstCombineAndOrXor.cpp) was changed to recognize both the old and new patterns (tests will fail if only one the new pattern is recognized).
2. New features and fine tuning were introduced to InstructionSimplify in order to continue supporting existing test cases as well as enhancing other similar test cases. Those are specified in test/Transforms/InstCombine/select-bitext-bitwise-ops.ll




Repository:
  rL LLVM

https://reviews.llvm.org/D41233

Files:
  lib/Analysis/InstructionSimplify.cpp
  lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  lib/Transforms/InstCombine/InstCombineShifts.cpp
  test/Transforms/InstCombine/2010-11-01-lshr-mask.ll
  test/Transforms/InstCombine/cast.ll
  test/Transforms/InstCombine/or-shifted-masks.ll
  test/Transforms/InstCombine/pr17827.ll
  test/Transforms/InstCombine/rem.ll
  test/Transforms/InstCombine/select-bitext-bitwise-ops.ll
  test/Transforms/InstCombine/select-with-bitwise-ops.ll
  test/Transforms/InstCombine/select.ll
  test/Transforms/InstCombine/shift-shift.ll
  test/Transforms/InstCombine/shift.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41233.126933.patch
Type: text/x-patch
Size: 29091 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171214/f16425a3/attachment.bin>


More information about the llvm-commits mailing list