[llvm] Removed redundant assert and condition in APInt::SetBits (PR #138038)
Liam Semeria via llvm-commits
llvm-commits at lists.llvm.org
Thu May 1 14:02:58 PDT 2025
https://github.com/liamsemeria updated https://github.com/llvm/llvm-project/pull/138038
>From b1749f17eaf530281ef0ac1180744ece2a3bbf33 Mon Sep 17 00:00:00 2001
From: Liam <liamsemeria at gmail.com>
Date: Wed, 30 Apr 2025 14:42:11 -0700
Subject: [PATCH 1/2] removed redundant assert and condition in APInt::SetBits
---
llvm/include/llvm/ADT/APInt.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 02d58d8c3d31c..4a1205cedf605 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -1366,11 +1366,11 @@ class [[nodiscard]] APInt {
/// This function handles case when \p loBit <= \p hiBit.
void setBits(unsigned loBit, unsigned hiBit) {
assert(hiBit <= BitWidth && "hiBit out of range");
- assert(loBit <= BitWidth && "loBit out of range");
assert(loBit <= hiBit && "loBit greater than hiBit");
if (loBit == hiBit)
return;
if (loBit < APINT_BITS_PER_WORD && hiBit <= APINT_BITS_PER_WORD) {
+ //if (hiBit <= APINT_BITS_PER_WORD) {
uint64_t mask = WORDTYPE_MAX >> (APINT_BITS_PER_WORD - (hiBit - loBit));
mask <<= loBit;
if (isSingleWord())
>From 85ccb4e96802027f1841bacda58c8d596af48c34 Mon Sep 17 00:00:00 2001
From: Liam <liamsemeria at gmail.com>
Date: Thu, 1 May 2025 14:02:45 -0700
Subject: [PATCH 2/2] reinserted assert for lowBits in APInt::SetBits
---
llvm/include/llvm/ADT/APInt.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 4a1205cedf605..c682887fdd182 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -1366,6 +1366,7 @@ class [[nodiscard]] APInt {
/// This function handles case when \p loBit <= \p hiBit.
void setBits(unsigned loBit, unsigned hiBit) {
assert(hiBit <= BitWidth && "hiBit out of range");
+ assert(loBit <= BitWidth && "loBit out of range");
assert(loBit <= hiBit && "loBit greater than hiBit");
if (loBit == hiBit)
return;
More information about the llvm-commits
mailing list