OSDN Git Service

[InstCombine] Simplify funnel shift with zero/undef operand to shift
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 23 Nov 2018 22:45:08 +0000 (22:45 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 23 Nov 2018 22:45:08 +0000 (22:45 +0000)
commit3c0addf152de02f1d982e0f8ecf18fc8a6d8d501
tree0ce808b4ac1d0db05d8aa7d754e2ab993cde5492
parent7280a87f55f84b3891e59792ed8ebd0c04ce4ab8
[InstCombine] Simplify funnel shift with zero/undef operand to shift

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.

Differential Revision: https://reviews.llvm.org/D54778

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347505 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineCalls.cpp
test/Transforms/InstCombine/fsh.ll