Commit 3615301b authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[csa] Optimize CodeStubAssembler::DecodeWord

Only use shifts in case masking has no effects.

Change-Id: I0b8b759ce9c9689917745e81345ceb3e16e994c3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2875085Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarPatrick Thier <pthier@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74472}
parent d3dd3407
......@@ -7721,15 +7721,25 @@ TNode<Object> CodeStubAssembler::OrdinaryToPrimitive(
TNode<Uint32T> CodeStubAssembler::DecodeWord32(TNode<Word32T> word32,
uint32_t shift, uint32_t mask) {
DCHECK_EQ((mask >> shift) << shift, mask);
return Unsigned(Word32And(Word32Shr(word32, static_cast<int>(shift)),
Int32Constant(mask >> shift)));
if ((std::numeric_limits<uint32_t>::max() >> shift) ==
((std::numeric_limits<uint32_t>::max() & mask) >> shift)) {
return Unsigned(Word32Shr(word32, static_cast<int>(shift)));
} else {
return Unsigned(Word32And(Word32Shr(word32, static_cast<int>(shift)),
Int32Constant(mask >> shift)));
}
}
TNode<UintPtrT> CodeStubAssembler::DecodeWord(TNode<WordT> word, uint32_t shift,
uintptr_t mask) {
DCHECK_EQ((mask >> shift) << shift, mask);
return Unsigned(WordAnd(WordShr(word, static_cast<int>(shift)),
IntPtrConstant(mask >> shift)));
if ((std::numeric_limits<uintptr_t>::max() >> shift) ==
((std::numeric_limits<uintptr_t>::max() & mask) >> shift)) {
return Unsigned(WordShr(word, static_cast<int>(shift)));
} else {
return Unsigned(WordAnd(WordShr(word, static_cast<int>(shift)),
IntPtrConstant(mask >> shift)));
}
}
TNode<Word32T> CodeStubAssembler::UpdateWord32(TNode<Word32T> word,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment