This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH GCC11]Improve uninitialized warning with value range info
- From: Jeff Law <law at redhat dot com>
- To: "bin.cheng" <bin dot cheng at linux dot alibaba dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 13 Jan 2020 14:19:55 -0700
- Subject: Re: [PATCH GCC11]Improve uninitialized warning with value range info
- References: <f54b1952-d4f3-4bad-86b4-8a194a5194ac.bin.cheng@linux.alibaba.com>
- Reply-to: law at redhat dot com
On Wed, 2020-01-08 at 12:58 +0800, bin.cheng wrote:
> Hi,
>
> Function use_pred_not_overlap_with_undef_path_pred of pass_late_warn_uninitialized
> checks if predicate of variable use overlaps with predicate of undefined control flow path.
> For now, it only checks ssa_var comparing against constant, this can be improved where
> ssa_var compares against another ssa_var with value range info, as described in comment:
>
> + /* Check value range info of rhs, do following transforms:
> + flag_var < [min, max] -> flag_var < max
> + flag_var > [min, max] -> flag_var > min
> +
> + We can also transform LE_EXPR/GE_EXPR to LT_EXPR/GT_EXPR:
> + flag_var <= [min, max] -> flag_var < [min, max+1]
> + flag_var >= [min, max] -> flag_var > [min-1, max]
> + if no overflow/wrap. */
>
> This change can avoid some false warning. Bootstrap and test on x86_64, any comment?
>
> Thanks,
> bin
>
> 2020-01-08 Bin Cheng <bin.linux@linux.alibaba.com>
>
> * tree-ssa-uninit.c (find_var_cmp_const): New function.
> (use_pred_not_overlap_with_undef_path_pred): Call above.
Totally agree with Richi in that it's a good idea. I've always
expected that as we make ranges first class citizens that we'd find
more places to use 'em.
Jeff