This is the mail archive of the
`gcc-patches@gcc.gnu.org`
mailing list for the GCC project.

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |

Other format: | [Raw text] |

*From*: Richard Henderson <rth at redhat dot com>*To*: Andrew Pinski <andrew dot pinski at caviumnetworks dot com>*Cc*: GCC Patches <gcc-patches at gcc dot gnu dot org>*Date*: Tue, 22 May 2012 13:32:44 -0700*Subject*: Re: [PATCH] Try to expand COND_EXPR using addcc*References*: <CA+=Sn1=+Ew_eegQ=Dw4akc6r=5Vr9wyhFLFm9Xowebs8ZMcf1g@mail.gmail.com>

+ /* Handle 0/1 specially because boolean types and precision of one types, + will cause the diff to always be 1. Note this really should have + simplified before reaching here. */ + /* A ? 1 : 0 is just (type)(A!=0). */ + if (integer_zerop (treeop2)&& integer_onep (treeop1)) + { + tree t = fold_convert (TREE_TYPE (treeop0), integer_zero_node); + tree tmp = fold_build2 (NE_EXPR, TREE_TYPE (treeop0), treeop0, t); + tmp = fold_convert (type, tmp); + return expand_normal (tmp); + } + + /* A ? 0 : 1 is just (type)(A==0). */ + if (integer_zerop (treeop1)&& integer_onep (treeop0)) + { + tree t = fold_convert (TREE_TYPE (treeop0), integer_zero_node); + tree tmp = fold_build2 (EQ_EXPR, TREE_TYPE (treeop0), treeop0, t); + tmp = fold_convert (type, tmp); + return expand_normal (tmp); + }

Well, why *don't* you handle them before here? I completely agree that they seem out of place in an _addcc function.

+ /* A ? CST1 : CST2 can be expanded as CST2 + (!A)*(CST1 - CST2) */ + if (TREE_CODE (treeop1) == INTEGER_CST +&& TREE_CODE (treeop2) == INTEGER_CST) + diff = int_const_binop (MINUS_EXPR, treeop1, treeop2);

Here you're bypassing the large amount of logic we've got in e.g. ix86_expand_int_movcc for handling exactly this case, and in more clever ways than you're doing here.

+ /* A ? b : b+c can be expanded as b + (!A)*(c) */ + /* A ? b + c : b can be expanded as b + (!A)*(c) */

What has MULT got to do with it? I think these comments are just confusing.

r~

**References**:**[PATCH] Try to expand COND_EXPR using addcc***From:*Andrew Pinski

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |