Match a bswap or bitreverse idiom and replace it with an intrinsic.

Synopsis

Declared in <llvm/Transforms/Utils/Local.h>

bool
recognizeBSwapOrBitReverseIdiom(
    Instruction* I,
    bool MatchBSwaps,
    bool MatchBitReversals,
    SmallVectorImpl<Instruction*>& InsertedInsts);

Description

Try to match a bswap or bitreverse idiom.

If an idiom is matched, an intrinsic call is inserted before I. Any added instructions are returned in InsertedInsts. They will all have been added to a basic block.

A bitreverse idiom normally requires around 2*BW nodes to be searched (where BW is the bitwidth of the integer type). A bswap idiom requires anywhere up to BW / 4 nodes to be searched, so is significantly faster.

This function returns true on a successful match or false otherwise.

Return Value

True if a bswap or bitreverse idiom was matched.

Parameters

Name

Description

I

Instruction that may root a bswap or bitreverse idiom.

MatchBSwaps

Whether to match bswap idioms.

MatchBitReversals

Whether to match bitreverse idioms.

InsertedInsts

Instructions inserted for a successful match.

Created with MrDocs