This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/60930] [4.8/4.9/4.10 Regression] Wrong folding of - ((unsigned long long) a * (unsigned long long) (unsigned int)-1)
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 23 Apr 2014 21:22:40 +0000
- Subject: [Bug tree-optimization/60930] [4.8/4.9/4.10 Regression] Wrong folding of - ((unsigned long long) a * (unsigned long long) (unsigned int)-1)
- Auto-submitted: auto-generated
- References: <bug-60930-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60930
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Bill Schmidt from comment #4)
> Created attachment 32664 [details]
> Proposed patch
>
> Here's a patch (for trunk) that solves the problem for powerpc64le without
> regression. If you have time, can you please try this on the ports for
> which the bug was reported? Meantime I'll work on the backport versions.
>
> Thanks,
> Bill
That is a weird check for overflow. If you are looking for multiplication
overflow and want to perform the computation in signed double_int, then
supposedly one would use
bool overflow_p = false;
temp = tree_to_double_int (base_cand->stride).mul_with_sign (tree_to_double_int
(stride_in), false, &overflow_p);
if (!overflow_p)
Not sure about the false, if e.g. both the base_cand->stride and stride_in are
TYPE_UNSIGNED, shouldn't it be true then? What if one of them is signed and
one unsigned?
Alternatively, you could just fold_binary (MULT_EXPR, type, base_cand->stride,
stride_in); and check for TREE_OVERFLOW_P on the result.
Richard, your thoughts on this?