[turboshaft] fix incorrect 32-bit comparison

32-bit comparisons were sometimes done on 64-bit. This was an issue in
cases where the upper 32 bits contained invalid bits, such as after a
Bitcast.

Fixed: chromium:1383204
Change-Id: Ie930dd579c01297b5717da8407fd9765586306ee
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4020422
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Darius Mercadier <dmercadier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84268}
This commit is contained in:
Darius M 2022-11-11 14:06:07 +01:00 committed by V8 LUCI CQ
parent 6578f7fc29
commit 8abf7a1ec9

View File

@ -6,6 +6,7 @@
#define V8_COMPILER_TURBOSHAFT_OPERATION_MATCHING_H_
#include "src/compiler/turboshaft/operations.h"
#include "src/compiler/turboshaft/representations.h"
namespace v8 ::internal::compiler::turboshaft {
@ -106,8 +107,26 @@ class OperationMatching {
default:
return false;
}
if (unsigned_constant) *unsigned_constant = op->integral();
if (signed_constant) *signed_constant = op->signed_integral();
if (unsigned_constant) {
switch (rep.value()) {
case WordRepresentation::Word32():
*unsigned_constant = static_cast<uint32_t>(op->integral());
break;
case WordRepresentation::Word64():
*unsigned_constant = op->integral();
break;
}
}
if (signed_constant) {
switch (rep.value()) {
case WordRepresentation::Word32():
*signed_constant = static_cast<int32_t>(op->signed_integral());
break;
case WordRepresentation::Word64():
*signed_constant = op->signed_integral();
break;
}
}
return true;
}