This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/24574] a!=0?a/10:0 is not reduced to a/10
- From: "rguenther at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 13 Jul 2016 07:47:50 +0000
- Subject: [Bug tree-optimization/24574] a!=0?a/10:0 is not reduced to a/10
- Auto-submitted: auto-generated
- References: <bug-24574-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24574
--- Comment #4 from rguenther at suse dot de <rguenther at suse dot de> ---
On Tue, 12 Jul 2016, glisse at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24574
>
> --- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
> Makes sense, I don't know why I didn't add divisions in the original patch.
> *_MOD_EXPR, shifts and rotates should work as well with 0 on the left, max with
> INT_MAX, etc, I was quite minimalist there.
>
> Of course, if I had gone with the simpler approach of folding the operation
> after replacement (here 0 / 10) and comparing that with the PHI argument, we
> wouldn't need the neutral/absorbing logic at all :-(
Yeah, but folding would happily create undefined behavior from, say,
if (x != INT_MIN)
x = x * -1;
as folding folds INT_MIN * -1 to INT_MIN (ok, maybe with TREE_OVERFLOW
set, but I'm not sure we want to rely on that).
Re-testing with mod and shift/rotates added.