Skip to content

Commit

Permalink
OpcodeDispatcher: Make use of the new Andn IR op where applicable
Browse files Browse the repository at this point in the history
Now that we have the handling in place, we can make use of it to
simplify some operations and resolve some lingering TODO comments.
  • Loading branch information
lioncash committed Nov 3, 2021
1 parent 0b700de commit 49dae08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 4 additions & 6 deletions External/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2134,8 +2134,7 @@ void OpDispatchBuilder::ANDNBMIOp(OpcodeArgs) {
auto* Src1 = LoadSource(GPRClass, Op, Op->Src[0], Op->Flags, -1);
auto* Src2 = LoadSource(GPRClass, Op, Op->Src[1], Op->Flags, -1);

// TODO: This can be replaced with a BIC IR op once it's implemented.
auto Dest = _And(_Not(Src1), Src2);
auto Dest = _Andn(Src2, Src1);

StoreResult(GPRClass, Op, Dest, -1);
GenerateFlags_Logical(Op, Dest, Src1, Src2);
Expand Down Expand Up @@ -2569,8 +2568,7 @@ void OpDispatchBuilder::BTROp(OpcodeArgs) {
Result = _Lshr(Dest, BitSelect);

OrderedNode *BitMask = _Lshl(_Constant(1), BitSelect);
BitMask = _Not(BitMask);
Dest = _And(Dest, BitMask);
Dest = _Andn(Dest, BitMask);
StoreResult(GPRClass, Op, Dest, -1);
}
else {
Expand All @@ -2591,10 +2589,10 @@ void OpDispatchBuilder::BTROp(OpcodeArgs) {
// Now add the addresses together and load the memory
OrderedNode *MemoryLocation = _Add(Dest, Src);
OrderedNode *BitMask = _Lshl(_Constant(1), BitSelect);
BitMask = _Not(BitMask);

if (DestIsLockedMem(Op)) {
HandledLock = true;
BitMask = _Not(BitMask);
// XXX: Technically this can optimize to an AArch64 ldclralb
// We don't current support this IR op though
Result = _AtomicFetchAnd(MemoryLocation, BitMask, 1);
Expand All @@ -2606,7 +2604,7 @@ void OpDispatchBuilder::BTROp(OpcodeArgs) {

// Now shift in to the correct bit location
Result = _Lshr(Value, BitSelect);
Value = _And(Value, BitMask);
Value = _Andn(Value, BitMask);
_StoreMemAutoTSO(GPRClass, 1, MemoryLocation, Value, 1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ void OpDispatchBuilder::SetX87TopTag(OrderedNode *Value, uint32_t Tag) {
OrderedNode *Mask = _Constant(0b11);
auto TopOffset = _Lshl(Value, _Constant(1));
Mask = _Lshl(Mask, TopOffset);
// XXX: This Neg can be removed if we support BIC
Mask = _Not(Mask);
OrderedNode *NewFTW = _And(FTW, Mask);
OrderedNode *NewFTW = _Andn(FTW, Mask);
if (Tag != 0) {
auto TagVal = _Lshl(_Constant(Tag), TopOffset);
NewFTW = _Or(NewFTW, TagVal);
Expand Down

0 comments on commit 49dae08

Please sign in to comment.