public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/meissner/heads/work017)] Fix bug with 64-bit compares and 128-bit moves.
@ 2020-09-16 0:39 Michael Meissner
0 siblings, 0 replies; only message in thread
From: Michael Meissner @ 2020-09-16 0:39 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:d11c4f3966aa76f6915ef2ecad9d0045ae08cf12
commit d11c4f3966aa76f6915ef2ecad9d0045ae08cf12
Author: Michael Meissner <meissner@linux.ibm.com>
Date: Tue Sep 15 20:39:11 2020 -0400
Fix bug with 64-bit compares and 128-bit moves.
gcc/
2020-09-15 Michael Meissner <meissner@linux.ibm.com>
* config/rs6000/rs6000.md
(mov<FPMASK:mode><FPMASK2:mode>cc_fpmask): Fix bug if we are
moving 128-bit items but the comparison is only 64-bits.
(mov<FPMASK:mode><FPMASK2:mode>cc_invert_fpmask): Likewise.
Diff:
---
gcc/config/rs6000/rs6000.md | 103 +++++++++++++++++++++++++++++---------------
1 file changed, 69 insertions(+), 34 deletions(-)
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index de407dcd151..7fde0a73ece 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -5341,24 +5341,43 @@
(clobber (match_scratch:V2DI 6 "=&<FPMASK2:Fv>"))]
"TARGET_P9_MINMAX"
"#"
- ""
- [(set (match_dup 6)
- (if_then_else:V2DI (match_dup 1)
- (match_dup 7)
- (match_dup 8)))
- (set (match_dup 0)
- (if_then_else:FPMASK (ne (match_dup 6)
- (match_dup 8))
- (match_dup 4)
- (match_dup 5)))]
+ "&& 1"
+ [(pc)]
{
- if (GET_CODE (operands[6]) == SCRATCH)
- operands[6] = gen_reg_rtx (V2DImode);
+ rtx dest = operands[0];
+ rtx cmp = operands[1];
+ rtx cmp_op1 = operands[2];
+ rtx cmp_op2 = operands[3];
+ rtx move_t = operands[4];
+ rtx move_f = operands[5];
+ rtx mask_reg = operands[6];
+ rtx mask_m1 = CONSTM1_RTX (V2DImode);
+ rtx mask_0 = CONST0_RTX (V2DImode);
+ machine_mode move_mode = <FPMASK:MODE>mode;
+ machine_mode compare_mode = <FPMASK2:MODE>mode;
+
+ if (GET_CODE (mask_reg) == SCRATCH)
+ mask_reg = gen_reg_rtx (V2DImode);
+
+ /* Emit the compare and set mask instruction. */
+ emit_insn (gen_fpmask<FPMASK2:mode> (mask_reg, cmp, cmp_op1, cmp_op2,
+ mask_m1, mask_0));
+
+ /* If we have a 64-bit comparison, but an 128-bit move, we need to extend the
+ mask. Because we are using the splat builtin to extend the V2DImode, we
+ need to use element 1 on little endian systems. */
+ if (!FLOAT128_IEEE_P (compare_mode) && FLOAT128_IEEE_P (move_mode))
+ {
+ rtx element = WORDS_BIG_ENDIAN ? const0_rtx : const1_rtx;
+ emit_insn (gen_vsx_xxspltd_v2di (mask_reg, mask_reg, element));
+ }
- operands[7] = CONSTM1_RTX (V2DImode);
- operands[8] = CONST0_RTX (V2DImode);
+ /* Now emit the XXSEL insn. */
+ emit_insn (gen_xxsel<FPMASK:mode> (dest, mask_reg, mask_0, move_t, move_f));
+ DONE;
}
- [(set_attr "length" "8")
+ ;; length is 12 in case we need to add XXPERMDI
+ [(set_attr "length" "12")
(set_attr "type" "vecperm")])
;; Handle inverting the fpmask comparisons.
@@ -5374,31 +5393,47 @@
"TARGET_P9_MINMAX"
"#"
"&& 1"
- [(set (match_dup 6)
- (if_then_else:V2DI (match_dup 9)
- (match_dup 7)
- (match_dup 8)))
- (set (match_dup 0)
- (if_then_else:FPMASK (ne (match_dup 6)
- (match_dup 8))
- (match_dup 5)
- (match_dup 4)))]
+ [(pc)]
{
- rtx op1 = operands[1];
- enum rtx_code cond = reverse_condition_maybe_unordered (GET_CODE (op1));
+ rtx dest = operands[0];
+ rtx old_cmp = operands[1];
+ rtx cmp_op1 = operands[2];
+ rtx cmp_op2 = operands[3];
+ enum rtx_code cond = reverse_condition_maybe_unordered (GET_CODE (old_cmp));
+ rtx cmp_rev = gen_rtx_fmt_ee (cond, CCFPmode, cmp_op1, cmp_op2);
+ rtx move_f = operands[4];
+ rtx move_t = operands[5];
+ rtx mask_reg = operands[6];
+ rtx mask_m1 = CONSTM1_RTX (V2DImode);
+ rtx mask_0 = CONST0_RTX (V2DImode);
+ machine_mode move_mode = <FPMASK:MODE>mode;
+ machine_mode compare_mode = <FPMASK2:MODE>mode;
- if (GET_CODE (operands[6]) == SCRATCH)
- operands[6] = gen_reg_rtx (V2DImode);
+ if (GET_CODE (mask_reg) == SCRATCH)
+ mask_reg = gen_reg_rtx (V2DImode);
- operands[7] = CONSTM1_RTX (V2DImode);
- operands[8] = CONST0_RTX (V2DImode);
+ /* Emit the compare and set mask instruction. */
+ emit_insn (gen_fpmask<FPMASK2:mode> (mask_reg, cmp_rev, cmp_op1, cmp_op2,
+ mask_m1, mask_0));
- operands[9] = gen_rtx_fmt_ee (cond, CCFPmode, operands[2], operands[3]);
+ /* If we have a 64-bit comparison, but an 128-bit move, we need to extend the
+ mask. Because we are using the splat builtin to extend the V2DImode, we
+ need to use element 1 on little endian systems. */
+ if (!FLOAT128_IEEE_P (compare_mode) && FLOAT128_IEEE_P (move_mode))
+ {
+ rtx element = WORDS_BIG_ENDIAN ? const0_rtx : const1_rtx;
+ emit_insn (gen_vsx_xxspltd_v2di (mask_reg, mask_reg, element));
+ }
+
+ /* Now emit the XXSEL insn. */
+ emit_insn (gen_xxsel<FPMASK:mode> (dest, mask_reg, mask_0, move_t, move_f));
+ DONE;
}
- [(set_attr "length" "8")
+ ;; length is 12 in case we need to add XXPERMDI
+ [(set_attr "length" "12")
(set_attr "type" "vecperm")])
-(define_insn "*fpmask<mode>"
+(define_insn "fpmask<mode>"
[(set (match_operand:V2DI 0 "vsx_register_operand" "=<Fv>")
(if_then_else:V2DI
(match_operator:CCFP 1 "fpmask_comparison_operator"
@@ -5414,7 +5449,7 @@
}
[(set_attr "type" "fpcompare")])
-(define_insn "*xxsel<mode>"
+(define_insn "xxsel<mode>"
[(set (match_operand:FPMASK 0 "vsx_register_operand" "=wa")
(if_then_else:FPMASK
(ne (match_operand:V2DI 1 "vsx_register_operand" "wa")
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-16 0:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16 0:39 [gcc(refs/users/meissner/heads/work017)] Fix bug with 64-bit compares and 128-bit moves Michael Meissner
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).