1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[InstCombine] collectBitParts - add bitreverse intrinsic support.

This commit is contained in:
Simon Pilgrim 2020-10-26 14:26:14 +00:00
parent 50512eeb69
commit dfaaccca5a
2 changed files with 15 additions and 6 deletions

View File

@ -2947,6 +2947,20 @@ collectBitParts(Value *V, bool MatchBSwaps, bool MatchBitReversals,
return Result;
}
// BITREVERSE - most likely due to us previous matching a partial
// bitreverse.
if (match(V, m_BitReverse(m_Value(X)))) {
const auto &Res =
collectBitParts(X, MatchBSwaps, MatchBitReversals, BPS, Depth + 1);
if (!Res)
return Result;
Result = BitPart(Res->Provider, BitWidth);
for (unsigned BitIdx = 0; BitIdx < BitWidth; ++BitIdx)
Result->Provenance[(BitWidth - 1) - BitIdx] = Res->Provenance[BitIdx];
return Result;
}
// BSWAP - most likely due to us previous matching a partial bswap.
if (match(V, m_BSwap(m_Value(X)))) {
const auto &Res =

View File

@ -537,12 +537,7 @@ declare <2 x i32> @llvm.bswap.v2i32(<2 x i32>)
define i16 @partial_bitreverse(i16 %x) {
; CHECK-LABEL: @partial_bitreverse(
; CHECK-NEXT: [[REV:%.*]] = call i16 @llvm.bitreverse.i16(i16 [[X:%.*]])
; CHECK-NEXT: [[LO:%.*]] = and i16 [[REV]], 255
; CHECK-NEXT: [[HI:%.*]] = and i16 [[REV]], -256
; CHECK-NEXT: [[REVLO:%.*]] = call i16 @llvm.bitreverse.i16(i16 [[LO]])
; CHECK-NEXT: [[REVHI:%.*]] = call i16 @llvm.bitreverse.i16(i16 [[HI]])
; CHECK-NEXT: [[OR:%.*]] = call i16 @llvm.fshl.i16(i16 [[REVHI]], i16 [[REVLO]], i16 8)
; CHECK-NEXT: [[OR:%.*]] = call i16 @llvm.bswap.i16(i16 [[X:%.*]])
; CHECK-NEXT: ret i16 [[OR]]
;
%rev= call i16 @llvm.bitreverse.i16(i16 %x)