This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/30911] VRP fails to eliminate range checks in Ada code
- From: "baldrick at free dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Mar 2007 09:16:30 -0000
- Subject: [Bug tree-optimization/30911] VRP fails to eliminate range checks in Ada code
- References: <bug-30911-13647@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #42 from baldrick at free dot fr 2007-03-02 09:16 -------
Subject: Re: VRP fails to eliminate range checks in Ada code
> Thaks for the detective work! I sort of expected the fold patch to be weird or
> have no effect - but it was needed only (for the testcase) to get rid of the
> target_first == 128 comparison, as that is confusing VRP. Basically after this
> comparison we conclude target_first != 128 and drop the earlier target_first !=
> 10
> assertion which is the one we can use to optimize the later comparisons.
>
> So the other solution is to simply not record out-of-bounds assertions.
I think fold needs to be fixed, whether or not your fold patch goes in.
After all, fold is clearly willing to do create objects like X^Y which
take values outside of the range of the type. Once such objects are
floating around, any serious use of TYPE_MAX_VALUE or TYPE_MIN_VALUE
(when they are non-trivial) will almost certainly give wrong results,
as shown by your fold patch.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30911