A few fixes are needed after the change to get_base_reg of
r16-6333-gac64ceb33bf05b. First we need to use the correct target mode
of the operand, this means if we are doing a subreg of QI mode, using
QImode for the conditional move.
Second we also need to use the original operands instead of the ones
removing the subreg still.
Pushed as obvious after a bootstrap/test on x86_64-linux-gnu.
PR rtl-optimization/123267
gcc/ChangeLog:
* ifcvt.cc (noce_try_cond_zero_arith): Pass the original operands
of a instead of the stripped off values. The mode of the operand
which is being used.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr123267-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
start_sequence ();
- target = gen_reg_rtx (mode);
+ target = gen_reg_rtx (GET_MODE (XEXP (a, op != AND)));
/* AND requires !cond, instead we swap ops around. */
target = noce_emit_cmove (if_info, target, GET_CODE (if_info->cond),
XEXP (if_info->cond, 0), XEXP (if_info->cond, 1),
- op != AND ? a_op1 : const0_rtx,
- op != AND ? const0_rtx : a_op0);
+ op != AND ? XEXP (a, 1) : const0_rtx,
+ op != AND ? const0_rtx : XEXP (a, 0));
if (!target)
goto end_seq_n_fail;
--- /dev/null
+/* { dg-do compile } */
+
+/* PR rtl-optimization/123267 */
+
+int j(long e, int k, int i) {
+ return (i&-3) == 0 ? k : k - e;
+}