mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-14 04:05:17 +02:00
OpcodeDispatcher: optimize bextr's (1 << x) - 1
little algebraic trick I cribbed from llvm Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
This commit is contained in:
1 parent
c9461d9997
commit
f66085f4a7
1 file changed
+4
-4
@@ -2138,12 +2138,12 @@ void OpDispatchBuilder::BEXTRBMIOp(OpcodeArgs) {
|
||||
Length, MaxSrcBitOp);
|
||||
|
||||
// Now build up the mask
|
||||
// (1 << SanitizedLength) - 1
|
||||
auto One = _Constant(SrcSize, 1);
|
||||
auto Mask = _Sub(IR::SizeToOpSize(Size), _Lshl(IR::SizeToOpSize(Size), One, SanitizedLength), One);
|
||||
// (1 << SanitizedLength) - 1 = ~(~0 << SanitizedLength)
|
||||
auto AllOnes = _Constant(~0ull);
|
||||
auto InvertedMask = _Lshl(IR::SizeToOpSize(Size), AllOnes, SanitizedLength);
|
||||
|
||||
// Now put it all together and make the result.
|
||||
auto Dest = _And(IR::SizeToOpSize(Size), SanitizedShifted, Mask);
|
||||
auto Dest = _Andn(IR::SizeToOpSize(Size), SanitizedShifted, InvertedMask);
|
||||
|
||||
// Finally store the result.
|
||||
StoreResult(GPRClass, Op, Dest, -1);
|
||||
|
||||
Reference in new issue
Block a user