[PATCH] D37418: [X86] Use btc/btr/bts to implement xor/and/or that affects a single bit in the upper 32-bits of a 64-bit operation.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 27 16:05:28 PST 2018
craig.topper added a comment.
The h-register trick is coming from this code in X86ISelDAGToDAG.cpp
// For example, "testl %eax, $2048" to "testb %ah, $8".
if (isShiftedUInt<8, 8>(Mask) &&
(!(Mask & 0x8000) || hasNoSignedComparisonUses(Node))) {
// Shift the immediate right by 8 bits.
SDValue ShiftedImm = CurDAG->getTargetConstant(Mask >> 8, dl, MVT::i8);
SDValue Reg = N0.getOperand(0);
// Extract the h-register.
SDValue Subreg = CurDAG->getTargetExtractSubreg(X86::sub_8bit_hi, dl,
MVT::i8, Reg);
// Emit a testb. The EXTRACT_SUBREG becomes a COPY that can only
// target GR8_NOREX registers, so make sure the register class is
// forced.
SDNode *NewNode = CurDAG->getMachineNode(X86::TEST8ri_NOREX, dl,
MVT::i32, Subreg, ShiftedImm);
// Replace SUB|CMP with TEST, since SUB has two outputs while TEST has
// one, do not call ReplaceAllUsesWith.
ReplaceUses(SDValue(Node, (Opcode == X86ISD::SUB ? 1 : 0)),
SDValue(NewNode, 0));
CurDAG->RemoveDeadNode(Node);
return;
}
Repository:
rL LLVM
https://reviews.llvm.org/D37418
More information about the llvm-commits
mailing list