This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/64454] optimize (x%5)%5
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 12 Jan 2015 21:05:16 +0000
- Subject: [Bug tree-optimization/64454] optimize (x%5)%5
- Auto-submitted: auto-generated
- References: <bug-64454-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64454
--- Comment #6 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #5)
> The reason for tree_int_cst_sgn (vr->min) >= 0 was that I don't want to let
> 0 through and for negative values, handling those would require computing
> absolute value, but as match.pd already folds x % -5 already into x % 5,
> there is no need to bother with it, so I'm just trying to play safe.
I don't think we are talking about the same thing. Restricting to positive op1
is good. What I find a little strange is:
+ if (TYPE_UNSIGNED (TREE_TYPE (op0))
+ || tree_int_cst_sgn (vr->min) >= 0
+ || tree_int_cst_lt (fold_unary (NEGATE_EXPR, TREE_TYPE (op1), op1),
+ vr->min))
where condition 2: min>=0 is more restrictive than condition 3: min>-op1 (since
op1 is known to be positive) so we could skip condition 2.