Hi, The attached patch is the basic support for conditional compare (CCMP). It adds a set of keywords on TREE to represent CCMP:
DEFTREECODE (TRUTH_ANDIF_LT_EXPR, "truth_andif_lt_expr", tcc_ccomparison, 3) DEFTREECODE (TRUTH_ANDIF_LE_EXPR, "truth_andif_le_expr", tcc_ccomparison, 3) DEFTREECODE (TRUTH_ANDIF_GT_EXPR, "truth_andif_gt_expr", tcc_ccomparison, 3) DEFTREECODE (TRUTH_ANDIF_GE_EXPR, "truth_andif_ge_expr", tcc_ccomparison, 3) DEFTREECODE (TRUTH_ANDIF_EQ_EXPR, "truth_andif_eq_expr", tcc_ccomparison, 3) DEFTREECODE (TRUTH_ANDIF_NE_EXPR, "truth_andif_ne_expr", tcc_ccomparison, 3) DEFTREECODE (TRUTH_ORIF_LT_EXPR, "truth_orif_lt_expr", tcc_ccomparison, 3) DEFTREECODE (TRUTH_ORIF_LE_EXPR, "truth_orif_le_expr", tcc_ccomparison, 3) DEFTREECODE (TRUTH_ORIF_GT_EXPR, "truth_orif_gt_expr", tcc_ccomparison, 3) DEFTREECODE (TRUTH_ORIF_GE_EXPR, "truth_orif_ge_expr", tcc_ccomparison, 3) DEFTREECODE (TRUTH_ORIF_EQ_EXPR, "truth_orif_eq_expr", tcc_ccomparison, 3) DEFTREECODE (TRUTH_ORIF_NE_EXPR, "truth_orif_ne_expr", tcc_ccomparison, 3) To distinguish others, the patch dumps CCMP as && to "?&&" || to "?||" A CCMP operator has three operands: two are from the compare and the other is from the result of previous compare. To reuse current codes, the result of previous compare is in TREE_OPERAND (ccmp, 2)/gimple_assign_rhs3. e.g. r = (a > b) && (c > d) with CCMP, it will be t1 = GT_EXPR (a, b) r = TRUTH_ANDIF_GT_EXPR (c, d, t1) The patch does not include ops to expand CCMP to RTL. It just roll CCMP back to BIT operators. So with a dummy "conditional_compare", we can test the patch in any port. In the patch, dummy conditional_compare for i386 and arm are added for test. Bootstrap on x86-64 and ARM Chromebook. No ICE and runtime errors in regression tests. Thanks! -Zhenqiang ChangeLog: 2013-08-21 Zhenqiang Chen <zhenqiang.c...@linaro.org> * tree.def: Add conditional compare ops: TRUTH_ANDIF_LT_EXPR, TRUTH_ANDIF_LE_EXPR, TRUTH_ANDIF_GT_EXPR, TRUTH_ANDIF_GE_EXPR, TRUTH_ANDIF_EQ_EXPR, TRUTH_ANDIF_NE_EXPR, TRUTH_ORIF_LT_EXPR, TRUTH_ORIF_LE_EXPR, TRUTH_ORIF_GT_EXPR, TRUTH_ORIF_GE_EXPR, TRUTH_ORIF_EQ_EXPR, TRUTH_ORIF_NE_EXPR. * tree.h: Add misc utils for conditional compare. * tree.c (tree_node_structure_for_code, tree_code_size, record_node_allocation_statistics, contains_placeholder_p, find_placeholder_in_expr, substitute_in_expr, substitute_placeholder_in_expr, stabilize_reference_1, build2_stat, simple_cst_equal): Handle conditional compare. (get_code_from_ccompare_expr): New added. (generate_ccompare_code ): New added. * c-family/c-pretty-print.c (pp_c_expression): Handle conditional compare. * cp/error.c (dump_expr): Likewise. * cp/semantics.c (cxx_eval_constant_expression): Likewise. (potential_constant_expression_1): Likewise. (cxx_eval_ccmp_expression): New added. * cfgexpand.c (expand_debug_expr): Handle conditional compare. * expr.c (safe_from_p, expand_expr_real_2): Likewise. (expand_ccmp_to_bitop): New added. * gimple-pretty-print.c (dump_ccomparison_rhs): New added. (dump_gimple_assign): Handle conditional compare. * print-tree.c (print_node): Likewise * tree-dump.c (dequeue_and_dump): Likewise. * tree-pretty-print.c (dump_generic_node, op_code_prio): Likewise. * gimple.c (recalculate_side_effects): Likewise. (get_gimple_rhs_num_ops): Likewise * gimplify.c (goa_stabilize_expr, gimplify_expr, gimple_boolify): Likewise. * tree-inline.c (estimate_operator_cost): Likewise. * tree-ssa-operands.c (get_expr_operands): Likewise. * tree-ssa-loop-niter.c (get_val_for): Likewise. * tree-cfg.c (verify_gimple_assign_ternary): Likewise. (verify_gimple_comparison_operands): New added. (verify_gimple_comparison): Call verify_gimple_comparison_operands. * fold-const.c (fold_truth_andor): Generate conditinal compare. * lra-constraints.c (remove_inheritance_pseudos): Initialize variable "set" to NULL_RTX.
basic-conditional-compare-support.patch
Description: Binary data