From f0d8edecee77d05fb3e670ca5a77ad211116e78a Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Tue, 24 Jan 2023 19:29:54 +0000 Subject: [PATCH] tint: Fix x86 build Fixed: tint:1813 Change-Id: I97b7c0c0a4bfdda2f7e63983caddcfb3a1e19c2f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117215 Reviewed-by: dan sinclair Kokoro: Ben Clayton Auto-Submit: Ben Clayton Commit-Queue: Ben Clayton --- src/tint/ir/binary_test.cc | 10 +++++----- src/tint/ir/bitcast_test.cc | 4 ++-- src/tint/utils/math.h | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/tint/ir/binary_test.cc b/src/tint/ir/binary_test.cc index 68341ad495..b5fba93ca8 100644 --- a/src/tint/ir/binary_test.cc +++ b/src/tint/ir/binary_test.cc @@ -521,15 +521,15 @@ TEST_F(IR_InstructionTest, Binary_Usage) { EXPECT_EQ(instr->GetKind(), Binary::Kind::kAnd); ASSERT_NE(instr->Result(), nullptr); - ASSERT_EQ(instr->Result()->Usage().Length(), 1); + ASSERT_EQ(instr->Result()->Usage().Length(), 1u); EXPECT_EQ(instr->Result()->Usage()[0], instr); ASSERT_NE(instr->LHS(), nullptr); - ASSERT_EQ(instr->LHS()->Usage().Length(), 1); + ASSERT_EQ(instr->LHS()->Usage().Length(), 1u); EXPECT_EQ(instr->LHS()->Usage()[0], instr); ASSERT_NE(instr->RHS(), nullptr); - ASSERT_EQ(instr->RHS()->Usage().Length(), 1); + ASSERT_EQ(instr->RHS()->Usage().Length(), 1u); EXPECT_EQ(instr->RHS()->Usage()[0], instr); } @@ -544,13 +544,13 @@ TEST_F(IR_InstructionTest, Binary_Usage_DuplicateValue) { EXPECT_EQ(instr->GetKind(), Binary::Kind::kAnd); ASSERT_NE(instr->Result(), nullptr); - ASSERT_EQ(instr->Result()->Usage().Length(), 1); + ASSERT_EQ(instr->Result()->Usage().Length(), 1u); EXPECT_EQ(instr->Result()->Usage()[0], instr); ASSERT_EQ(instr->LHS(), instr->RHS()); ASSERT_NE(instr->LHS(), nullptr); - ASSERT_EQ(instr->LHS()->Usage().Length(), 1); + ASSERT_EQ(instr->LHS()->Usage().Length(), 1u); EXPECT_EQ(instr->LHS()->Usage()[0], instr); } diff --git a/src/tint/ir/bitcast_test.cc b/src/tint/ir/bitcast_test.cc index a6924dfda2..ee7bd3d4c5 100644 --- a/src/tint/ir/bitcast_test.cc +++ b/src/tint/ir/bitcast_test.cc @@ -53,11 +53,11 @@ TEST_F(IR_InstructionTest, Bitcast_Usage) { b.builder.Bitcast(b.builder.ir.types.Get(), b.builder.Constant(4_i)); ASSERT_NE(instr->Result(), nullptr); - ASSERT_EQ(instr->Result()->Usage().Length(), 1); + ASSERT_EQ(instr->Result()->Usage().Length(), 1u); EXPECT_EQ(instr->Result()->Usage()[0], instr); ASSERT_NE(instr->Val(), nullptr); - ASSERT_EQ(instr->Val()->Usage().Length(), 1); + ASSERT_EQ(instr->Val()->Usage().Length(), 1u); EXPECT_EQ(instr->Val()->Usage()[0], instr); } diff --git a/src/tint/utils/math.h b/src/tint/utils/math.h index 27dd232904..8bbbcc89cb 100644 --- a/src/tint/utils/math.h +++ b/src/tint/utils/math.h @@ -66,10 +66,10 @@ inline constexpr uint32_t Log2(uint64_t value) { #endif // Non intrinsic (slow) path. Supports constexpr evaluation. - for (size_t clz = 0; clz < 64; clz++) { - size_t bit = 63 - clz; - if (value & (static_cast(1u) << bit)) { - return bit; + for (uint64_t clz = 0; clz < 64; clz++) { + uint64_t bit = 63 - clz; + if (value & (static_cast(1u) << bit)) { + return static_cast(bit); } } return 64;