This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH combine.c bug: Bad to transform (cmpop (minus A B) 0) into (cmpop A B).
- To: law at cygnus dot com
- Subject: Re: PATCH combine.c bug: Bad to transform (cmpop (minus A B) 0) into (cmpop A B).
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- Date: Tue, 4 Apr 2000 16:30:14 +0200
- CC: hans-peter dot nilsson at axis dot com, gcc-patches at gcc dot gnu dot org
> Date: Mon, 03 Apr 2000 22:57:03 -0600
> From: Jeffrey A Law <law@cygnus.com>
Thanks for reviewing this.
> > * combine.c (simplify_comparison) [MINUS]: Do not replace
> > all (op (minus A B) 0) with (op A B).
> This might be too pessimistic -- shouldn't we allow this transformation
> for any OP that doesn't depend on overflow? That would be EQ, NE, GEU, GTU,
> LEU, and LTU?
As I mentioned, equality comparisons (EQ, NE) are handled by the
code after this deleted code. Since you brought it up, I
thought I should check that the trivial transformations to
equality comparisons were performed for the unsigned
comparisons. To test, I used the (now committed) test case,
tweaked the type of the operands and the comparison operator and
checked what landed in simplify_comparison. It seems the right
conversions were done:
GEU is transformed to "always true"; simplify_comparison is
never called.
GTU is transformed to NE already at .00.rtl; first call to
simplify_comparison for these operands is with NE and the right
transformation is performed.
LEU is likewise transformed to EQ.
LTU is transformed to "always false".
Perhaps I should add this comment in place of the removed code
to avoid future confusion?
/* We used to optimize signed comparisons against zero, but that
was incorrect. Unsigned comparisons against zero (GEU, GTU,
LEU, and LTU) arrive here as equality comparisons. No need
to special-case them. */
Ok to commit with (or without) this comment?
brgds, H-P