@@ -16754,6 +16754,23 @@ f_constraint_p (const char *constraint)
return seen_f_p && !seen_v_p;
}
+/* Return TRUE iff X is a hard floating-point (and not a vector) register. */
+
+static bool
+s390_hard_fp_reg_p (rtx x)
+{
+ if (!(REG_P (x) && HARD_REGISTER_P (x) && REG_ATTRS (x)))
+ return false;
+
+ tree decl = REG_EXPR (x);
+ if (!(HAS_DECL_ASSEMBLER_NAME_P (decl) && DECL_ASSEMBLER_NAME_SET_P (decl)))
+ return false;
+
+ const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+
+ return name[0] == '*' && name[1] == 'f';
+}
+
/* Implement TARGET_MD_ASM_ADJUST hook in order to fix up "f"
constraints when long doubles are stored in vector registers. */
@@ -16787,9 +16804,23 @@ s390_md_asm_adjust (vec<rtx> &outputs, vec<rtx> &inputs,
gcc_assert (allows_reg);
gcc_assert (!is_inout);
/* Copy output value from a FPR pair into a vector register. */
- rtx fprx2 = gen_reg_rtx (FPRX2mode);
+ rtx fprx2;
push_to_sequence2 (after_md_seq, after_md_end);
- emit_insn (gen_fprx2_to_tf (outputs[i], fprx2));
+ if (s390_hard_fp_reg_p (outputs[i]))
+ {
+ fprx2 = gen_rtx_REG (FPRX2mode, REGNO (outputs[i]));
+ /* The first half is already at the correct location, copy only the
+ * second one. Use gen_rtx_raw_SUBREG() in order to skip subreg
+ * validation - we need to build (subreg:DF (reg:TF %fN) 8), which
+ * will otherwise be rejected by s390_can_change_mode_class(). */
+ emit_move_insn (gen_rtx_raw_SUBREG (DFmode, outputs[i], 8),
+ simplify_gen_subreg (DFmode, fprx2, FPRX2mode, 8));
+ }
+ else
+ {
+ fprx2 = gen_reg_rtx (FPRX2mode);
+ emit_insn (gen_fprx2_to_tf (outputs[i], fprx2));
+ }
after_md_seq = get_insns ();
after_md_end = get_last_insn ();
end_sequence ();
@@ -16813,8 +16844,19 @@ s390_md_asm_adjust (vec<rtx> &outputs, vec<rtx> &inputs,
continue;
gcc_assert (allows_reg);
/* Copy input value from a vector register into a FPR pair. */
- rtx fprx2 = gen_reg_rtx (FPRX2mode);
- emit_insn (gen_tf_to_fprx2 (fprx2, inputs[i]));
+ rtx fprx2;
+ if (s390_hard_fp_reg_p (inputs[i]))
+ {
+ fprx2 = gen_rtx_REG (FPRX2mode, REGNO (inputs[i]));
+ /* Copy only the second half. */
+ emit_move_insn (gen_rtx_raw_SUBREG (DFmode, fprx2, 8),
+ gen_rtx_raw_SUBREG (DFmode, inputs[i], 8));
+ }
+ else
+ {
+ fprx2 = gen_reg_rtx (FPRX2mode);
+ emit_insn (gen_tf_to_fprx2 (fprx2, inputs[i]));
+ }
inputs[i] = fprx2;
input_modes[i] = FPRX2mode;
}
@@ -634,6 +634,14 @@
}
[(set_attr "op_type" "VRR,*")])
+(define_insn "*df_to_tf_1"
+ [(set (subreg:DF (match_operand:TF 0 "nonimmediate_operand" "+v") 8)
+ (match_operand:DF 1 "general_operand" "f"))]
+ "TARGET_VXE"
+ ; M4 == 0 corresponds to %v0[0] = %v0[0]; %v0[1] = %v1[0];
+ "vpdi\t%v0,%v0,%v1,0"
+ [(set_attr "op_type" "VRR")])
+
(define_insn "*vec_ti_to_v1ti"
[(set (match_operand:V1TI 0 "nonimmediate_operand" "=v,v,R, v, v,v")
(vec_duplicate:V1TI (match_operand:TI 1 "general_operand" "v,R,v,j00,jm1,d")))]
new file mode 100644
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=z14 -mzarch --save-temps" } */
+/* { dg-do run { target { s390_z14_hw } } } */
+#include <assert.h>
+#include <stdint.h>
+
+__attribute__ ((noipa)) static long double
+sqxbr (long double x)
+{
+ register long double in asm("f0") = x;
+ register long double out asm("f1");
+
+ asm("sqxbr\t%0,%1" : "=f"(out) : "f"(in));
+ asm("# %0" : "+f"(out));
+
+ return out;
+}
+
+/* { dg-final { scan-assembler-times {\n\tvpdi\t%v2,%v0,%v2,5\n} 1 } } */
+/* { dg-final { scan-assembler-times {\n\tvpdi\t%v1,%v1,%v3,0\n} 2 } } */
+
+int
+main (void)
+{
+ long double x = 0x1.0000000000001p+0L,
+ exp = 1.00000000000000011102230246251564788e+0L;
+ assert (sqxbr (x) == exp);
+}
new file mode 100644
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=z14 -mzarch --save-temps" } */
+/* { dg-do run { target { s390_z14_hw } } } */
+#include <assert.h>
+#include <stdint.h>
+
+__attribute__ ((noipa)) static long double
+sqxbr (long double x)
+{
+ register long double inout asm("f4") = x;
+
+ asm("sqxbr\t%0,%0" : "+f"(inout));
+ asm("# %0" : "+f"(inout));
+
+ return inout;
+}
+
+/* { dg-final { scan-assembler-times {\n\tvpdi\t%v6,%v4,%v6,5\n} 1 } } */
+/* { dg-final { scan-assembler-times {\n\tvpdi\t%v4,%v4,%v6,0\n} 2 } } */
+
+int
+main (void)
+{
+ long double x = 0x1.0000000000001p+0L,
+ exp = 1.00000000000000011102230246251564788e+0L;
+ assert (sqxbr (x) == exp);
+}