[PATCH] D54778: [InstCombine] Simplify funnel shift with one zero/undef operands to simple shift

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 20 15:45:28 PST 2018


nikic created this revision.
nikic added reviewers: spatel, RKSimon.
Herald added a subscriber: llvm-commits.

The following simplifications are implemented:

- `fshl(X, 0, C) -> shl X, C%BW`
- `fshl(X, undef, C) -> shl X, C%BW` (assuming undef = 0)
- `fshl(0, X, C) -> lshr X, BW-C%BW`
- `fshl(undef, X, C) -> lshr X, BW-C%BW` (assuming undef = 0)
- `fshr(X, 0, C) -> shl X, (BW-C%BW)`
- `fshr(X, undef, C) -> shl X, BW-C%BW` (assuming undef = 0)
- `fshr(0, X, C) -> lshr X, C%BW`
- `fshr(undef, X, C) -> lshr, X, C%BW` (assuming undef = 0)

The simplification is only performed if the shift amount C is constant, because we can explicitly compute C%BW and BW-C%BW in this case.

---

This change has been split off from https://reviews.llvm.org/D54666 and handling for the zero case has been added. Unfortunately that also means new tests :(


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D54778

Files:
  lib/Transforms/InstCombine/InstCombineCalls.cpp
  test/Transforms/InstCombine/fsh.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54778.174851.patch
Type: text/x-patch
Size: 4144 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181120/2544d465/attachment.bin>


More information about the llvm-commits mailing list