This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR31096
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: "Hurugalawadi, Naveen" <Naveen dot Hurugalawadi at caviumnetworks dot com>
- Cc: "ramana dot radhakrishnan at foss dot arm dot com" <ramana dot radhakrishnan at foss dot arm dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 7 Apr 2016 13:28:30 +0200 (CEST)
- Subject: Re: [PATCH] Fix PR31096
- Authentication-results: sourceware.org; auth=none
- References: <SN2PR0701MB102491E5EF1A9EE96C8619688E990 at SN2PR0701MB1024 dot namprd07 dot prod dot outlook dot com>,<alpine dot DEB dot 2 dot 20 dot 1603311120300 dot 1831 at laptop-mg dot saclay dot inria dot fr> <SN2PR0701MB102429781DD227528814D7888E9E0 at SN2PR0701MB1024 dot namprd07 dot prod dot outlook dot com>,<alpine dot DEB dot 2 dot 20 dot 1604051114350 dot 1896 at laptop-mg dot saclay dot inria dot fr> <CO2PR07MB2694EDC68D383E78CA227D768E900 at CO2PR07MB2694 dot namprd07 dot prod dot outlook dot com>
- Reply-to: gcc-patches at gcc dot gnu dot org
On Thu, 7 Apr 2016, Hurugalawadi, Naveen wrote:
+/* Fold A * 10 == B * 10 into A == B. */
+(for cmp (eq ne)
+ (simplify
+ (cmp (mult:c @0 @1) (mult:c @2 @1))
+ (if (TYPE_OVERFLOW_UNDEFINED (type)
type is the return type of the comparison. The relevant type here is
TREE_TYPE (@0). Maybe add a testcase with unsigned, to check that it
does not transform?
+ && !integer_zerop (@1))
+ (cmp @0 @2))))
!integer_zerop is not a promise that the variable is not zero, it just
says that we don't know for sure that it is zero. integer_nonzerop would
work. Or writing (cmp (mult @0 INTEGER_CST@1) (mult @2 @1)), but
then !wi::eq_p (@1, 0) would be a better test.
To make it more general (not limited to constants), you could probably
use tree_expr_nonzero_p, and at some point someone would enhance
tree_single_nonzero_warnv_p by checking VRP information for SSA_NAME.
The other transformation has similar issues.
--
Marc Glisse