diff options
author | Uros Bizjak <ubizjak@gmail.com> | 2017-05-12 21:04:05 +0200 |
---|---|---|
committer | Uros Bizjak <uros@gcc.gnu.org> | 2017-05-12 21:04:05 +0200 |
commit | 4f0473fe89e68bf7c09542ee5c3684da25a5b435 (patch) | |
tree | 4c30e423d62fc42b58f267231981db14ab16fd32 | |
parent | 88ce9dc38a0590608dd036e08758b478f8ca429c (diff) | |
download | gcc-4f0473fe89e68bf7c09542ee5c3684da25a5b435.zip gcc-4f0473fe89e68bf7c09542ee5c3684da25a5b435.tar.gz gcc-4f0473fe89e68bf7c09542ee5c3684da25a5b435.tar.bz2 |
compare-elim.c (try_eliminate_compare): Canonicalize operation with embedded compare to [(set (reg:CCM) (compare:CCM...
* compare-elim.c (try_eliminate_compare): Canonicalize
operation with embedded compare to
[(set (reg:CCM) (compare:CCM (operation) (immediate)))
(set (reg) (operation)].
* config/i386/i386.c (TARGET_FLAGS_REGNUM): New define.
From-SVN: r247992
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/compare-elim.c | 30 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 2 |
3 files changed, 32 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cc9f7a3..1e14b039 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,14 @@ 2017-05-12 Uros Bizjak <ubizjak@gmail.com> + * compare-elim.c (try_eliminate_compare): Canonicalize + operation with embedded compare to + [(set (reg:CCM) (compare:CCM (operation) (immediate))) + (set (reg) (operation)]. + + * config/i386/i386.c (TARGET_FLAGS_REGNUM): New define. + +2017-05-12 Uros Bizjak <ubizjak@gmail.com> + PR target/80723 * config/i386/i386.c (ix86_rtx_cost) [case PLUS]: Ignore the cost of adding a carry flag for ADC instruction. diff --git a/gcc/compare-elim.c b/gcc/compare-elim.c index 22aedf5..69b1de7 100644 --- a/gcc/compare-elim.c +++ b/gcc/compare-elim.c @@ -45,9 +45,9 @@ along with GCC; see the file COPYING3. If not see (3) If an insn of form (2) can usefully set the flags, there is another pattern of the form - [(set (reg) (operation) - (set (reg:CCM) (compare:CCM (operation) (immediate)))] - + [(set (reg:CCM) (compare:CCM (operation) (immediate))) + (set (reg) (operation)] + The mode CCM will be chosen as if by SELECT_CC_MODE. Note that unlike NOTICE_UPDATE_CC, we do not handle memory operands. @@ -582,7 +582,7 @@ equivalent_reg_at_start (rtx reg, rtx_insn *end, rtx_insn *start) static bool try_eliminate_compare (struct comparison *cmp) { - rtx x, flags, in_a, in_b, cmp_src; + rtx flags, in_a, in_b, cmp_src; /* We must have found an interesting "clobber" preceding the compare. */ if (cmp->prev_clobber == NULL) @@ -628,7 +628,8 @@ try_eliminate_compare (struct comparison *cmp) Validate that PREV_CLOBBER itself does in fact refer to IN_A. Do recall that we've already validated the shape of PREV_CLOBBER. */ rtx_insn *insn = cmp->prev_clobber; - x = XVECEXP (PATTERN (insn), 0, 0); + + rtx x = XVECEXP (PATTERN (insn), 0, 0); if (rtx_equal_p (SET_DEST (x), in_a)) cmp_src = SET_SRC (x); @@ -666,13 +667,24 @@ try_eliminate_compare (struct comparison *cmp) flags = gen_rtx_REG (cmp->orig_mode, targetm.flags_regnum); /* Generate a new comparison for installation in the setter. */ - x = copy_rtx (cmp_src); - x = gen_rtx_COMPARE (GET_MODE (flags), x, in_b); - x = gen_rtx_SET (flags, x); + rtx y = copy_rtx (cmp_src); + y = gen_rtx_COMPARE (GET_MODE (flags), y, in_b); + y = gen_rtx_SET (flags, y); + + /* Canonicalize instruction to: + [(set (reg:CCM) (compare:CCM (operation) (immediate))) + (set (reg) (operation)] */ + rtvec v = rtvec_alloc (2); + RTVEC_ELT (v, 0) = y; + RTVEC_ELT (v, 1) = x; + + rtx pat = gen_rtx_PARALLEL (VOIDmode, v); + /* Succeed if the new instruction is valid. Note that we may have started a change group within maybe_select_cc_mode, therefore we must continue. */ - validate_change (insn, &XVECEXP (PATTERN (insn), 0, 1), x, true); + validate_change (insn, &PATTERN (insn), pat, true); + if (!apply_change_group ()) return false; diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index b5bdcd6..a0d9207 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -51826,6 +51826,8 @@ ix86_run_selftests (void) #undef TARGET_ADDRESS_COST #define TARGET_ADDRESS_COST ix86_address_cost +#undef TARGET_FLAGS_REGNUM +#define TARGET_FLAGS_REGNUM FLAGS_REG #undef TARGET_FIXED_CONDITION_CODE_REGS #define TARGET_FIXED_CONDITION_CODE_REGS ix86_fixed_condition_code_regs #undef TARGET_CC_MODES_COMPATIBLE |