This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Division Optimization in match and simplify
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: "Hurugalawadi, Naveen" <Naveen dot Hurugalawadi at caviumnetworks dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Richard Biener <richard dot guenther at gmail dot com>
- Date: Wed, 4 Nov 2015 09:32:58 +0100 (CET)
- Subject: Re: Division Optimization in match and simplify
- Authentication-results: sourceware.org; auth=none
- References: <BLUPR0701MB10112FDAF6046909BE252FFB8E2A0 at BLUPR0701MB1011 dot namprd07 dot prod dot outlook dot com>
- Reply-to: gcc-patches at gcc dot gnu dot org
(I didn't read everything)
+/* Convert (A/B)/C to A/(B*C) */
+(simplify
+ (rdiv (convert? (rdiv @0 @1)) (convert? @2))
+ (if (flag_reciprocal_math
+ && tree_nop_conversion_p (type, TREE_TYPE (@0))
+ && tree_nop_conversion_p (type, TREE_TYPE (@2)))
+ (rdiv (convert @0) (convert (mult @1 @2)))))
I thought we were mostly using the 'convert?' and tree_nop_conversion_p on
integers, but I could be wrong. For floats, it seems limited to cases
where long double has the same size as double? In any case, the 'convert?'
on @2 seems strange, either useless or not sufficient.
+ (rdiv (REAL_CST@0) (mult (convert? @1) REAL_CST@2))
Here again, the 'convert?' seems useless, (mult @1 REAL_CST@2) would match
just as well.
+(simplify
+ (trunc_div (bit_and (convert? @0) @1) INTEGER_CST@2)
That would probably also work for exact_div.
Again, I don't see the point of this 'convert?'.
+ (if (!TYPE_UNSIGNED (type) && integer_pow2p (@2)
+ && tree_int_cst_sgn (@2) > 0
+ && tree_nop_conversion_p (type, TREE_TYPE (@0)))
+ (with
+ { tree sum = fold_binary (PLUS_EXPR, TREE_TYPE (@2), @2, @1); }
Don't you want to require that @1 is INTEGER_CST? And then you could use
const_binop, or even wi::add.
+ (if (sum && integer_zerop (sum))
+ (rshift (convert @0) { build_int_cst (integer_type_node,
+ wi::exact_log2 (@2)); })))))
--
Marc Glisse