retdec
|
GNU/GCC instruction idioms. More...
#include <idioms_gcc.h>
Protected Member Functions | |
llvm::Instruction * | exchangeFloatNeg (llvm::BasicBlock::iterator iter) const |
llvm::Instruction * | exchangeXorMinusOne (llvm::BasicBlock::iterator iter) const |
llvm::Instruction * | exchangeSignedModuloByTwo (llvm::BasicBlock::iterator iter) const |
llvm::Instruction * | exchangeCondBitShiftDiv1 (llvm::BasicBlock::iterator iter) const |
llvm::Instruction * | exchangeCondBitShiftDiv2 (llvm::BasicBlock::iterator iter) const |
llvm::Instruction * | exchangeCondBitShiftDiv3 (llvm::BasicBlock::iterator iter) const |
llvm::Instruction * | exchangeCopysign (llvm::BasicBlock::iterator iter) const |
llvm::Instruction * | exchangeFloatAbs (llvm::BasicBlock::iterator iter) const |
int | exchangeCondBitShiftDivMultiBB (llvm::Function &f, llvm::Pass *pass) const |
![]() | |
IdiomsAbstract () | |
void | init (llvm::Module *M, CC_compiler cc, CC_arch arch) |
CC_compiler | getCompiler () const |
CC_arch | getArch () const |
llvm::Module * | getModule () const |
virtual bool | doAnalysis (llvm::Function &, llvm::Pass *)=0 |
virtual | ~IdiomsAbstract ()=default |
bool | findBranchDependingOn (llvm::BranchInst **br, llvm::BasicBlock &bb, const llvm::Value *val) const |
Friends | |
class | IdiomsAnalysis |
Additional Inherited Members | |
![]() | |
static void | eraseInstFromBasicBlock (llvm::Value *val, llvm::BasicBlock *bb) |
static bool | isPowerOfTwo (unsigned x) |
static bool | isPowerOfTwoRepresentable (const llvm::ConstantInt *cnst) |
GNU/GCC instruction idioms.
|
protected |
Exchange (X < 0 ? X + (N-1) : X) a>> log2(N) with X s/ N
iter | value to visit |
|
protected |
Division by negative power of two. Found on PowerPC, e.g. div -4. Exchange 0 - ((X >> shift) | ((X >> 31) & mask))
iter | value to visit |
|
protected |
Division by negative power of two. Found on PowerPC, e.g. div -2. Exchange 0 - ((X >> shift) | (X & mask)) – in case of div -2.
iter | value to visit |
|
protected |
Exchange multi BB idiom, found only when compiling for ARM with -Os.
f | function to visit |
pass | actual pass |
res = n % 2: dec_label: u12 = and i32 n, -2147483647 u13 = icmp slt i32 u12, 0 u11 = sext i1 u13 to i32 u11.u12 = add i32 u11, u12 br i1 u13, label if_true, label after_if
if_true: fold = add i32 u11, n u5 = or i32 fold, -2 u11 = add i32 u5, 1 br label after_if
after_if_8230_3: res = phi i32 [ u11, if_true ], [ u11.u12, dec_label ]
This idiom was found when compiling for ARM with -Os (GCC)
Multi BB idiom. Before branch:
icmp slt /\ ------- ------- / \ and 0 /\ ------- ------- / \ <n> -2147483647
if icmp is true (if_true block)
add /\ ------- ------- / \ or 1 /\ ------- ------- / \ add -2 /\ ------- ------- / \ <n> 1
|
protected |
Exchange X = ((A & 0x7FFFFFFF) | (B & 0x80000000)) with copysignf(A, B) or X = ((fabsf(A)) | (B & 0x80000000)) with copysignf(A, B)
iter | value to visit |
|
protected |
Exchange X & 0x7FFFFFFF with fabsf(X)
iter | value to visit |
|
protected |
Exchange (x ^ -2147483648) with -x
iter | value to visit |
|
protected |
Exchange (((lshr(X, 31) + X) & 1) - lshr(X, 31))) with X % 2
iter | value to visit |
|
protected |
Exchange x ^ -1 with -x - 1
iter | value to visit |
|
friend |