Index: llvm/lib/Target/PowerPC/PPCInstr64Bit.td =================================================================== --- llvm/lib/Target/PowerPC/PPCInstr64Bit.td +++ llvm/lib/Target/PowerPC/PPCInstr64Bit.td @@ -1355,6 +1355,10 @@ def : Pat<(i32 (trunc i64:$in)), (EXTRACT_SUBREG $in, sub_32)>; +// RLWINM8 +def : Pat<(and i64:$in, maskimm64:$imm), + (RLWINM8 $in, 0, (MB maskimm64:$imm), (ME maskimm64:$imm))>; + // Implement the 'not' operation with the NOR instruction. // (we could use the default xori pattern, but nor has lower latency on some // cores (such as the A2)). Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td =================================================================== --- llvm/lib/Target/PowerPC/PPCInstrInfo.td +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td @@ -376,6 +376,18 @@ return false; }]>; +def maskimm64 : PatLeaf<(imm), [{ + // maskImm predicate - True if immediate is a run of ones. + unsigned mb, me; + if (N->getValueType(0) == MVT::i64) { + // High 32-bit need to be zero. + uint64_t Mask = (uint64_t)N->getZExtValue(); + return isUInt<32>(Mask) && isRunOfOnes((unsigned)Mask, mb, me); + } + else + return false; +}]>; + def imm32SExt16 : Operand, ImmLeaf