mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-21 05:21:28 +00:00
X86: Use bitset to manage a bag of bits. NFC.
Doesn't matter in terms of memory usage or perf here, but it's a neat simplification. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229672 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
227affe405
commit
e8a0a78bad
@ -5828,13 +5828,12 @@ static SDValue LowerBuildVectorv4x32(SDValue Op, SelectionDAG &DAG,
|
|||||||
const X86Subtarget *Subtarget,
|
const X86Subtarget *Subtarget,
|
||||||
const TargetLowering &TLI) {
|
const TargetLowering &TLI) {
|
||||||
// Find all zeroable elements.
|
// Find all zeroable elements.
|
||||||
bool Zeroable[4];
|
std::bitset<4> Zeroable;
|
||||||
for (int i=0; i < 4; ++i) {
|
for (int i=0; i < 4; ++i) {
|
||||||
SDValue Elt = Op->getOperand(i);
|
SDValue Elt = Op->getOperand(i);
|
||||||
Zeroable[i] = (Elt.getOpcode() == ISD::UNDEF || X86::isZeroNode(Elt));
|
Zeroable[i] = (Elt.getOpcode() == ISD::UNDEF || X86::isZeroNode(Elt));
|
||||||
}
|
}
|
||||||
assert(std::count_if(&Zeroable[0], &Zeroable[4],
|
assert(Zeroable.size() - Zeroable.count() > 1 &&
|
||||||
[](bool M) { return !M; }) > 1 &&
|
|
||||||
"We expect at least two non-zero elements!");
|
"We expect at least two non-zero elements!");
|
||||||
|
|
||||||
// We only know how to deal with build_vector nodes where elements are either
|
// We only know how to deal with build_vector nodes where elements are either
|
||||||
@ -5920,10 +5919,7 @@ static SDValue LowerBuildVectorv4x32(SDValue Op, SelectionDAG &DAG,
|
|||||||
V2 = DAG.getNode(ISD::BITCAST, SDLoc(V2), MVT::v4f32, V2);
|
V2 = DAG.getNode(ISD::BITCAST, SDLoc(V2), MVT::v4f32, V2);
|
||||||
|
|
||||||
// Ok, we can emit an INSERTPS instruction.
|
// Ok, we can emit an INSERTPS instruction.
|
||||||
unsigned ZMask = 0;
|
unsigned ZMask = Zeroable.to_ulong();
|
||||||
for (int i = 0; i < 4; ++i)
|
|
||||||
if (Zeroable[i])
|
|
||||||
ZMask |= 1 << i;
|
|
||||||
|
|
||||||
unsigned InsertPSMask = EltMaskIdx << 6 | EltIdx << 4 | ZMask;
|
unsigned InsertPSMask = EltMaskIdx << 6 | EltIdx << 4 | ZMask;
|
||||||
assert((InsertPSMask & ~0xFFu) == 0 && "Invalid mask!");
|
assert((InsertPSMask & ~0xFFu) == 0 && "Invalid mask!");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user