OpcodeDispatcher: add and use AndConst

this skips the constant folding, which saves the branching in the rotate
immediate implementations.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
This commit is contained in:
Alyssa Rosenzweig 2024-01-24 17:49:42 -04:00
parent 974baca09c
commit 34fdb14da1
2 changed files with 12 additions and 2 deletions

View File

@ -2524,7 +2524,7 @@ void OpDispatchBuilder::RCRSmallerOp(OpcodeArgs) {
// x86 masks the shift by 0x3F or 0x1F depending on size of op
OrderedNode *Src = LoadSource(GPRClass, Op, Op->Src[1], Op->Flags, {.AllowUpperGarbage = true});
Src = _And(OpSize::i32Bit, Src, _Constant(Size, 0x1F));
Src = AndConst(OpSize::i32Bit, Src, 0x1F);
// CF only changes if we actually shifted. OF undefined if we didn't shift.
// The result is unchanged if we didn't shift. So branch over the whole thing.
@ -2723,7 +2723,7 @@ void OpDispatchBuilder::RCLSmallerOp(OpcodeArgs) {
// x86 masks the shift by 0x3F or 0x1F depending on size of op
OrderedNode *Src = LoadSource(GPRClass, Op, Op->Src[1], Op->Flags, {.AllowUpperGarbage = true});
Src = _And(OpSize::i32Bit, Src, _Constant(Size, 0x1F));
Src = AndConst(OpSize::i32Bit, Src, 0x1F);
// CF only changes if we actually shifted. OF undefined if we didn't shift.
// The result is unchanged if we didn't shift. So branch over the whole thing.

View File

@ -2130,6 +2130,16 @@ private:
};
}
OrderedNode *AndConst(FEXCore::IR::OpSize Size, OrderedNode *Node, uint64_t Const) {
uint64_t NodeConst;
if (IsValueConstant(WrapNode(Node), &NodeConst)) {
return _Constant(NodeConst & Const);
} else {
return _And(Size, Node, _Constant(Const));
}
}
/** @} */
/** @} */