From: Robin Dapp <rdapp@linux.ibm.com>
To: gcc-patches@gcc.gnu.org
Cc: krebbel@linux.ibm.com, iii@linux.ibm.com
Subject: [PATCH 2/6] ifcvt: Allow constants operands in noce_convert_multiple_sets.
Date: Wed, 14 Nov 2018 13:08:00 -0000 [thread overview]
Message-ID: <20181114130752.5057-3-rdapp@linux.ibm.com> (raw)
In-Reply-To: <20181114130752.5057-1-rdapp@linux.ibm.com>
This patch checks whether the current target supports conditional moves
with immediate then/else operands and allows noce_convert_multiple_sets
to deal with constants subsequently.
Also, minor refactoring is performed.
--
gcc/ChangeLog:
2018-11-14 Robin Dapp <rdapp@linux.ibm.com>
* ifcvt.c (have_const_cmov): New function.
(noce_convert_multiple_sets): Allow constants if supported.
(bb_ok_for_noce_convert_multiple_sets): Likewise.
(check_cond_move_block): Refactor.
---
gcc/ifcvt.c | 46 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 36 insertions(+), 10 deletions(-)
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index ddf077fa051..660bb46eb1c 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -3077,6 +3077,27 @@ bb_valid_for_noce_process_p (basic_block test_bb, rtx cond,
return false;
}
+/* Check if we have a movcc pattern that accepts constants as then/else
+ operand (op 2/3). */
+static bool
+have_const_cmov (machine_mode mode)
+{
+ enum insn_code icode;
+ if ((icode = direct_optab_handler (movcc_optab, mode))
+ != CODE_FOR_nothing)
+ {
+ if (insn_data[(int) icode].operand[2].predicate
+ && (insn_data[(int) icode].operand[2].predicate
+ (const1_rtx, insn_data[(int) icode].operand[2].mode)))
+ if (insn_data[(int) icode].operand[3].predicate
+ && (insn_data[(int) icode].operand[3].predicate
+ (const1_rtx, insn_data[(int) icode].operand[3].mode)))
+ return true;
+ }
+
+ return false;
+}
+
/* We have something like:
if (x > y)
@@ -3194,7 +3215,12 @@ noce_convert_multiple_sets (struct noce_if_info *if_info)
we'll end up trying to emit r4:HI = cond ? (r1:SI) : (r3:HI).
Wrap the two cmove operands into subregs if appropriate to prevent
that. */
- if (GET_MODE (new_val) != GET_MODE (temp))
+
+ /* Check if we can emit a cmove with constant operands. */
+ bool allow_constants = have_const_cmov (GET_MODE (target));
+
+ if (!(allow_constants && CONST_INT_P (new_val))
+ && GET_MODE (new_val) != GET_MODE (temp))
{
machine_mode src_mode = GET_MODE (new_val);
machine_mode dst_mode = GET_MODE (temp);
@@ -3205,7 +3231,8 @@ noce_convert_multiple_sets (struct noce_if_info *if_info)
}
new_val = lowpart_subreg (dst_mode, new_val, src_mode);
}
- if (GET_MODE (old_val) != GET_MODE (temp))
+ if (!(allow_constants && CONST_INT_P (old_val))
+ && GET_MODE (old_val) != GET_MODE (temp))
{
machine_mode src_mode = GET_MODE (old_val);
machine_mode dst_mode = GET_MODE (temp);
@@ -3339,9 +3366,10 @@ bb_ok_for_noce_convert_multiple_sets (basic_block test_bb)
if (!REG_P (dest))
return false;
- if (!(REG_P (src)
- || (GET_CODE (src) == SUBREG && REG_P (SUBREG_REG (src))
- && subreg_lowpart_p (src))))
+ if (!((REG_P (src)
+ || (have_const_cmov (GET_MODE (dest)) && CONST_INT_P (src)))
+ || (GET_CODE (src) == SUBREG && REG_P (SUBREG_REG (src))
+ && subreg_lowpart_p (src))))
return false;
/* Destination must be appropriate for a conditional write. */
@@ -3689,7 +3717,7 @@ check_cond_move_block (basic_block bb,
{
rtx set, dest, src;
- if (!NONDEBUG_INSN_P (insn) || JUMP_P (insn))
+ if (!active_insn_p (insn))
continue;
set = single_set (insn);
if (!set)
@@ -3705,10 +3733,8 @@ check_cond_move_block (basic_block bb,
if (!CONSTANT_P (src) && !register_operand (src, VOIDmode))
return FALSE;
- if (side_effects_p (src) || side_effects_p (dest))
- return FALSE;
-
- if (may_trap_p (src) || may_trap_p (dest))
+ /* Check for side effects and trapping. */
+ if (!noce_operand_ok (src) || !noce_operand_ok (dest))
return FALSE;
/* Don't try to handle this if the source register was
--
2.17.0
next prev parent reply other threads:[~2018-11-14 13:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-14 13:08 [PATCH 0/6] If conversion with multiple sets Robin Dapp
2018-11-14 13:08 ` [PATCH 4/6] S/390: Implement noce_conversion_profitable_p Robin Dapp
2018-11-14 13:08 ` [PATCH 5/6] ifcvt: Only created temporaries as needed Robin Dapp
2018-11-14 21:41 ` Jeff Law
2018-11-15 11:38 ` Robin Dapp
2018-11-21 0:21 ` Jeff Law
2018-11-14 13:08 ` [PATCH 1/6] ifcvt: Store the number of created cmovs Robin Dapp
2018-11-14 20:22 ` Jeff Law
2018-11-14 13:08 ` [PATCH 6/6] S/390: Add test for noce_convert_multiple_sets Robin Dapp
2018-11-14 13:08 ` [PATCH 3/6] ifcvt: Use enum instead of transform_name string Robin Dapp
2018-11-14 13:08 ` Robin Dapp [this message]
2018-11-14 21:38 ` [PATCH 2/6] ifcvt: Allow constants operands in noce_convert_multiple_sets Jeff Law
2018-11-15 11:37 ` Robin Dapp
2018-12-01 17:33 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181114130752.5057-3-rdapp@linux.ibm.com \
--to=rdapp@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=iii@linux.ibm.com \
--cc=krebbel@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).