From: "Martin Liška" <mliska@suse.cz>
To: Jeff Law <law@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix bitmap_bit_in_range_p (PR tree-optimization/82493).
Date: Fri, 13 Oct 2017 13:13:00 -0000 [thread overview]
Message-ID: <d0e5ec85-1e70-3551-2610-1f4e3b3b4170@suse.cz> (raw)
In-Reply-To: <467ec34e-7af8-b5b8-264a-a336bd810e49@suse.cz>
[-- Attachment #1: Type: text/plain, Size: 867 bytes --]
On 10/13/2017 10:01 AM, Martin Liška wrote:
> On 10/12/2017 11:54 PM, Jeff Law wrote:
>> On 10/11/2017 12:13 AM, Martin Liška wrote:
>>> 2017-10-10 Martin Liska <mliska@suse.cz>
>>>
>>> PR tree-optimization/82493
>>> * sbitmap.c (bitmap_bit_in_range_p): Fix the implementation.
>>> (test_range_functions): New function.
>>> (sbitmap_c_tests): Likewise.
>>> * selftest-run-tests.c (selftest::run_tests): Run new tests.
>>> * selftest.h (sbitmap_c_tests): New function.
>> I went ahead and committed this along with a patch to fix the off-by-one
>> error in live_bytes_read. Bootstrapped and regression tested on x86.
>>
>> Actual patch attached for archival purposes.
>>
>> Jeff
>>
>
> Thanks.
>
> I'll carry on and write another set of unit tests.
>
> Martin
>
Sending patch candidate, may I install it after it finishes regression tests?
Martin
[-- Attachment #2: 0001-Add-selftests-for-bitmap_set_range.patch --]
[-- Type: text/x-patch, Size: 2915 bytes --]
From 6114004455ffc534cdb895eb74b2018cea4b704a Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Fri, 13 Oct 2017 13:18:47 +0200
Subject: [PATCH 1/2] Add selftests for bitmap_set_range.
gcc/ChangeLog:
2017-10-13 Martin Liska <mliska@suse.cz>
* sbitmap.c (bitmap_bit_in_range_p_checking): New function.
(test_set_range): Likewise.
(test_range_functions): Rename to ...
(test_bit_in_range): ... this.
(sbitmap_c_tests): Add new test.
---
gcc/sbitmap.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 57 insertions(+), 3 deletions(-)
diff --git a/gcc/sbitmap.c b/gcc/sbitmap.c
index baef4d05f0d..fdcf5393e53 100644
--- a/gcc/sbitmap.c
+++ b/gcc/sbitmap.c
@@ -823,11 +823,64 @@ namespace selftest {
/* Selftests for sbitmaps. */
+/* Checking function that uses both bitmap_bit_in_range_p and
+ loop of bitmap_bit_p and verifies consistent results. */
-/* Verify range functions for sbitmap. */
+static bool
+bitmap_bit_in_range_p_checking (sbitmap s, unsigned int start,
+ unsigned end)
+{
+ bool r1 = bitmap_bit_in_range_p (s, start, end);
+ bool r2 = false;
+
+ for (unsigned int i = start; i <= end; i++)
+ if (bitmap_bit_p (s, i))
+ {
+ r2 = true;
+ break;
+ }
+
+ ASSERT_EQ (r1, r2);
+ return r1;
+}
+
+/* Verify bitmap_set_range functions for sbitmap. */
+
+static void
+test_set_range ()
+{
+ sbitmap s = sbitmap_alloc (16);
+ bitmap_clear (s);
+
+ bitmap_set_range (s, 0, 1);
+ ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 0, 0));
+ ASSERT_FALSE (bitmap_bit_in_range_p_checking (s, 1, 15));
+ bitmap_set_range (s, 15, 1);
+ ASSERT_FALSE (bitmap_bit_in_range_p_checking (s, 1, 14));
+ ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 15, 15));
+
+ s = sbitmap_alloc (1024);
+ bitmap_clear (s);
+ bitmap_set_range (s, 512, 1);
+ ASSERT_FALSE (bitmap_bit_in_range_p_checking (s, 0, 511));
+ ASSERT_FALSE (bitmap_bit_in_range_p_checking (s, 513, 1023));
+ ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 512, 512));
+ ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 508, 512));
+ ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 508, 513));
+ ASSERT_FALSE (bitmap_bit_in_range_p_checking (s, 508, 511));
+
+ bitmap_clear (s);
+ bitmap_set_range (s, 512, 64);
+ ASSERT_FALSE (bitmap_bit_in_range_p_checking (s, 0, 511));
+ ASSERT_FALSE (bitmap_bit_in_range_p_checking (s, 512 + 64, 1023));
+ ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 512, 512));
+ ASSERT_TRUE (bitmap_bit_in_range_p_checking (s, 512 + 63, 512 + 63));
+}
+
+/* Verify bitmap_bit_in_range_p functions for sbitmap. */
static void
-test_range_functions ()
+test_bit_in_range ()
{
sbitmap s = sbitmap_alloc (1024);
bitmap_clear (s);
@@ -900,7 +953,8 @@ test_range_functions ()
void
sbitmap_c_tests ()
{
- test_range_functions ();
+ test_set_range ();
+ test_bit_in_range ();
}
} // namespace selftest
--
2.14.2
next prev parent reply other threads:[~2017-10-13 13:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 6:15 Martin Liška
2017-10-11 17:58 ` Jeff Law
2017-10-12 4:48 ` Jeff Law
2017-10-12 22:16 ` Jeff Law
2017-10-13 8:01 ` Martin Liška
2017-10-13 13:13 ` Martin Liška [this message]
2017-10-13 14:17 ` Jeff Law
2017-10-13 13:03 ` Martin Liška
2017-10-13 15:04 ` Jeff Law
2017-10-16 12:15 ` Martin Liška
2017-10-16 14:53 ` Jeff Law
2017-10-17 17:33 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d0e5ec85-1e70-3551-2610-1f4e3b3b4170@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).