diff --git a/gcc/dojump.cc b/gcc/dojump.cc index 2af0cd1aca3b6af13d5d8799094ee93f18022296..8eaf1be49cd12298e61c6946ae79ca9de6197864 100644 --- a/gcc/dojump.cc +++ b/gcc/dojump.cc @@ -605,7 +605,17 @@ do_jump (tree exp, rtx_code_label *if_false_label, /* Fall through and generate the normal code. */ default: normal: - temp = expand_normal (exp); + tree cmp = exp; + /* If the expression is a truth type then explicitly generate an & 1 + to indicate to the target that it's a zero-one values type. This + allows the target to further optimize the comparison should it + choose to. */ + if (tree_zero_one_valued_p (exp)) + { + type = TREE_TYPE (exp); + cmp = build2 (BIT_AND_EXPR, type, exp, build_int_cstu (type, 1)); + } + temp = expand_normal (cmp); do_pending_stack_adjust (); /* The RTL optimizers prefer comparisons against pseudos. */ if (GET_CODE (temp) == SUBREG) diff --git a/gcc/tree.h b/gcc/tree.h index 8f8a9660c9e0605eb516de194640b8c1b531b798..be3d2dee82f692e81082cf21c878c10f9fe9e1f1 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4690,6 +4690,7 @@ extern tree signed_or_unsigned_type_for (int, tree); extern tree signed_type_for (tree); extern tree unsigned_type_for (tree); extern bool is_truth_type_for (tree, tree); +extern bool tree_zero_one_valued_p (tree); extern tree truth_type_for (tree); extern tree build_pointer_type_for_mode (tree, machine_mode, bool); extern tree build_pointer_type (tree);