+2015-04-07 Yvan Roux <yvan.roux@linaro.org>
+
+ Backport from trunk r217062, r217646, r218658.
+ 2014-12-12 Zhenqiang Chen <zhenqiang.chen@arm.com>
+
+ PR rtl-optimization/63917
+ * ifcvt.c (cc_in_cond): New function.
+ (end_ifcvt_sequence): Make sure new generated insns do not clobber CC.
+ (noce_process_if_block, check_cond_move_block): Check CC references.
+
+ 2014-11-17 Zhenqiang Chen <zhenqiang.chen@arm.com>
+
+ * ifcvt.c (HAVE_cbranchcc4): Define.
+ (noce_emit_cmove, noce_get_alt_condition, noce_get_condition):
+ Use HAVE_cbranchcc4.
+
+ 2014-11-04 Zhenqiang Chen <zhenqiang.chen@arm.com>
+
+ Revert:
+ 2014-11-03 Zhenqiang Chen <zhenqiang.chen@arm.com>
+ * ifcvt.c (noce_emit_cmove, noce_get_alt_condition, noce_get_condition):
+ Allow CC mode if HAVE_cbranchcc4.
+
2015-04-02 Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
Fix testcase backported from trunk
+ 1)
#endif
+#ifndef HAVE_cbranchcc4
+#define HAVE_cbranchcc4 0
+#endif
+
#define IFCVT_MULTIPLE_DUMPS 1
#define NULL_BLOCK ((basic_block) NULL)
0, 0, outmode, y);
}
+/* Return the CC reg if it is used in COND. */
+
+static rtx
+cc_in_cond (rtx cond)
+{
+ if (HAVE_cbranchcc4 && cond
+ && GET_MODE_CLASS (GET_MODE (XEXP (cond, 0))) == MODE_CC)
+ return XEXP (cond, 0);
+
+ return NULL_RTX;
+}
+
/* Return sequence of instructions generated by if conversion. This
function calls end_sequence() to end the current stream, ensures
that are instructions are unshared, recognizable non-jump insns.
{
rtx insn;
rtx seq = get_insns ();
+ rtx cc = cc_in_cond (if_info->cond);
set_used_flags (if_info->x);
set_used_flags (if_info->cond);
allows proper placement of required clobbers. */
for (insn = seq; insn; insn = NEXT_INSN (insn))
if (JUMP_P (insn)
- || recog_memoized (insn) == -1)
+ || recog_memoized (insn) == -1
+ /* Make sure new generated code does not clobber CC. */
+ || (cc && set_of (cc, insn)))
return NULL_RTX;
return seq;
if (! general_operand (cmp_a, GET_MODE (cmp_a))
|| ! general_operand (cmp_b, GET_MODE (cmp_b)))
{
-#if HAVE_cbranchcc4
- if (GET_MODE_CLASS (GET_MODE (cmp_a)) != MODE_CC
+ if (!(HAVE_cbranchcc4)
+ || GET_MODE_CLASS (GET_MODE (cmp_a)) != MODE_CC
|| cmp_b != const0_rtx)
-#endif
return NULL_RTX;
}
{
rtx cond, set, insn;
int reverse;
- int allow_cc_mode = false;
-#if HAVE_cbranchcc4
- allow_cc_mode = true;
-#endif
-
/* If target is already mentioned in the known condition, return it. */
if (reg_mentioned_p (target, if_info->cond))
}
cond = canonicalize_condition (if_info->jump, cond, reverse,
- earliest, target, allow_cc_mode, true);
+ earliest, target, HAVE_cbranchcc4, true);
if (! cond || ! reg_mentioned_p (target, cond))
return NULL;
{
rtx cond, set, tmp;
bool reverse;
- int allow_cc_mode = false;
-#if HAVE_cbranchcc4
- allow_cc_mode = true;
-#endif
if (! any_condjump_p (jump))
return NULL_RTX;
/* Otherwise, fall back on canonicalize_condition to do the dirty
work of manipulating MODE_CC values and COMPARE rtx codes. */
tmp = canonicalize_condition (jump, cond, reverse, earliest,
- NULL_RTX, allow_cc_mode, true);
+ NULL_RTX, HAVE_cbranchcc4, true);
/* We don't handle side-effects in the condition, like handling
REG_INC notes and making sure no duplicate conditions are emitted. */
rtx insn_a, insn_b;
rtx set_a, set_b;
rtx orig_x, x, a, b;
+ rtx cc;
/* We're looking for patterns of the form
if_info->a = a;
if_info->b = b;
+ /* Skip it if the instruction to be moved might clobber CC. */
+ cc = cc_in_cond (cond);
+ if (cc
+ && (set_of (cc, insn_a)
+ || (insn_b && set_of (cc, insn_b))))
+ return FALSE;
+
/* Try optimizations in some approximation of a useful order. */
/* ??? Should first look to see if X is live incoming at all. If it
isn't, we don't need anything but an unconditional set. */
rtx cond)
{
rtx insn;
+ rtx cc = cc_in_cond (cond);
/* We can only handle simple jumps at the end of the basic block.
It is almost impossible to update the CFG otherwise. */
&& modified_between_p (src, insn, NEXT_INSN (BB_END (bb))))
return FALSE;
+ /* Skip it if the instruction to be moved might clobber CC. */
+ if (cc && set_of (cc, insn))
+ return FALSE;
+
slot = pointer_map_insert (vals, (void *) dest);
*slot = (void *) src;