public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: "Martin Liška" <mliska@suse.cz>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix bitmap_bit_in_range_p (PR tree-optimization/82493).
Date: Wed, 11 Oct 2017 17:58:00 -0000	[thread overview]
Message-ID: <7ab58da7-d08a-0015-a7d2-09ef73e93d46@redhat.com> (raw)
In-Reply-To: <9c9fd60f-cb7a-e702-aabb-9e31dca6a92a@suse.cz>

On 10/11/2017 12:13 AM, Martin Liška wrote:
> Hi.
> 
> This fixes some implementations mistakes in sbitmap.c (bitmap_bit_in_range_p). There's reference
> to implementation one can take inspiration from:
> https://www.cs.umd.edu/class/sum2003/cmsc311/Notes/BitOp/bitRange.html
> 
> Problem with our implementation is that one can't do:
> (SBITMAP_ELT_TYPE)1 << SBITMAP_ELT_BITS (that would overflow)
> Thus I do conditionally ~(SBITMAP_ELT_TYPE)0 at some places in the code.
> 
> I also added quite some unit tests for the method. But another questions pop up:
> 1) there are missing boundary asserts (or checking asserts) in sbitmap.c
> 2) we should probably include test-cases also for other functions
> 
> I can work on that (probably later) if desired?
> 
> And my patch breaks ssa-dse-26.c test-case, because now it properly returns true for:
> 
> #0  bitmap_bit_in_range_p (bmap=0x21c4940, start=0, end=8) at ../../gcc/sbitmap.c:326
> #1  0x0000000000d618f5 in live_bytes_read (use_ref=..., ref=0x7fffffffd480, live=0x21c4940) at ../../gcc/tree-ssa-dse.c:496
> #2  0x0000000000d61c4d in dse_classify_store (ref=0x7fffffffd480, stmt=0x155553ea7d70, use_stmt=0x7fffffffd470, byte_tracking_enabled=true, live_bytes=0x21c4940) at ../../gcc/tree-ssa-dse.c:594
> #3  0x0000000000d6235b in dse_dom_walker::dse_optimize_stmt (this=0x7fffffffd5c0, gsi=0x7fffffffd530) at ../../gcc/tree-ssa-dse.c:820
> #4  0x0000000000d62461 in dse_dom_walker::before_dom_children (this=0x7fffffffd5c0, bb=0x155553d76270) at ../../gcc/tree-ssa-dse.c:852
> #5  0x00000000013b1698 in dom_walker::walk (this=0x7fffffffd5c0, bb=0x155553d76270) at ../../gcc/domwalk.c:308
> #6  0x0000000000d625ac in (anonymous namespace)::pass_dse::execute (this=0x21d58c0, fun=0x155553eac0b0) at ../../gcc/tree-ssa-dse.c:906
> #7  0x0000000000b27441 in execute_one_pass (pass=pass@entry=0x21d58c0) at ../../gcc/passes.c:2495
> #8  0x0000000000b27d01 in execute_pass_list_1 (pass=0x21d58c0) at ../../gcc/passes.c:2584
> #9  0x0000000000b27d13 in execute_pass_list_1 (pass=0x21d5480) at ../../gcc/passes.c:2585
> #10 0x0000000000b27d55 in execute_pass_list (fn=<optimized out>, pass=<optimized out>) at ../../gcc/passes.c:2595
> #11 0x0000000000b26681 in do_per_function_toporder (callback=callback@entry=0xb27d40 <execute_pass_list(function*, opt_pass*)>, data=0x21d5300) at ../../gcc/passes.c:1737
> #12 0x0000000000b283d7 in execute_ipa_pass_list (pass=0x21d52a0) at ../../gcc/passes.c:2935
> #13 0x00000000007d29d2 in ipa_passes () at ../../gcc/cgraphunit.c:2399
> #14 symbol_table::compile (this=this@entry=0x155553d6e100) at ../../gcc/cgraphunit.c:2534
> #15 0x00000000007d5277 in symbol_table::compile (this=0x155553d6e100) at ../../gcc/cgraphunit.c:2695
> #16 symbol_table::finalize_compilation_unit (this=0x155553d6e100) at ../../gcc/cgraphunit.c:2692
> #17 0x0000000000c118ac in compile_file () at ../../gcc/toplev.c:481
> #18 0x0000000000c13eee in do_compile () at ../../gcc/toplev.c:2037
> #19 0x0000000000c141da in toplev::main (this=0x7fffffffd85e, argc=21, argv=0x7fffffffd958) at ../../gcc/toplev.c:2172
> #20 0x000000000061aeab in main (argc=21, argv=0x7fffffffd958) at ../../gcc/main.c:39
> 
> (gdb) p debug(bmap)
> n_bits = 256, set = {8 9 10 11 12 13 14 15 }
> 
> Jeff can you please help me?
> Apart from that the patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
> 
> Ready to be installed?
> Martin
> 
> Thanks,
> Martin
> 
> gcc/ChangeLog:
> 
> 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.
Go ahead and install.  I'll dig into the -26 testcase.

jeff

  reply	other threads:[~2017-10-11 17:37 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 [this message]
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
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=7ab58da7-d08a-0015-a7d2-09ef73e93d46@redhat.com \
    --to=law@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    /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).