public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "kugan at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/64130] vrp: handle non zero constant divided by range cannot be zero. Date: Fri, 19 Jun 2015 11:36:00 -0000 [thread overview] Message-ID: <bug-64130-4-xdxOX1U0hq@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-64130-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64130 --- Comment #10 from kugan at gcc dot gnu.org --- (In reply to Marc Glisse from comment #6) > (In reply to kugan from comment #5) > > I think it should be in from front-end? > > ? Sorry for the confusing terminology. for the case int fsigned(int a) { return 0xffffffffffffffL / a == 0; } 004t.gimple has: int D.4228; long long int D.4229; long long int D.4230; _Bool D.4231; D.4229 = (long long int) a; D.4230 = 72057594037927935 / D.4229; D.4231 = D.4230 == 0; So based on the "x >= maxval(typeof(a)), x / a cannot be 0" the maxval(typeof(a)) is now maxval(long long int) in the case of ARM. Thats why I was asking if it is to be done before gimple is generated. As I see, the above statement does not rely on value ranges. > > > Tried fixing it in VRP like: > > You don't seem to use ranges at all. This might be the right place to > implement the suggestion from comment #2 (though if it does not use ranges, > match.pd would be better), but for the original optimization, what you want > to improve is the computation of the range of a division. When a has range > [0, 4294967295] we compute for 2305843009213693951 / a the range [0, > 2305843009213693951] which is not optimal, the left bound should be > 536870912 not 0. If the good interval is computed, VRP will automatically > fold == 0 to false without extra code. We already get this right when a has > range [1, 4294967295]. How about something like this: --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -3158,7 +3158,14 @@ extract_range_from_binary_expr_1 (value_range_t *vr, type = VR_VARYING; cmp = compare_values (vr0.min, zero); if (cmp == 1) - min = zero; + { + if (vr1.type == VR_RANGE + && !symbolic_range_p (&vr0) + && !symbolic_range_p (&vr1)) + min = int_const_binop (code, vr0.min, vr1.max); + else + min = zero; + } else if (cmp == 0 || cmp == -1) min = vr0.min; else
next prev parent reply other threads:[~2015-06-19 11:36 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-11-30 20:40 [Bug tree-optimization/64130] New: " andi-gcc at firstfloor dot org 2014-11-30 20:47 ` [Bug tree-optimization/64130] " glisse at gcc dot gnu.org 2014-11-30 20:49 ` pinskia at gcc dot gnu.org 2014-11-30 20:57 ` andi-gcc at firstfloor dot org 2014-12-01 9:30 ` rguenth at gcc dot gnu.org 2015-06-18 23:38 ` kugan at gcc dot gnu.org 2015-06-19 7:13 ` pinskia at gcc dot gnu.org 2015-06-19 8:05 ` glisse at gcc dot gnu.org 2015-06-19 11:36 ` kugan at gcc dot gnu.org [this message] 2015-06-29 0:16 ` kugan at gcc dot gnu.org 2015-06-29 8:39 ` rguenth at gcc dot gnu.org
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=bug-64130-4-xdxOX1U0hq@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /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: linkBe 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).