]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
arm-protos.h (vfp_const_double_for_bits): Declare.
authorRenlin Li <renlin.li@arm.com>
Tue, 24 Dec 2013 15:34:30 +0000 (15:34 +0000)
committerYufeng Zhang <yufeng@gcc.gnu.org>
Tue, 24 Dec 2013 15:34:30 +0000 (15:34 +0000)
gcc/

2013-12-24  Renlin Li  <Renlin.Li@arm.com>

* config/arm/arm-protos.h (vfp_const_double_for_bits): Declare.
* config/arm/constraints.md (Dp): Define new constraint.
* config/arm/predicates.md (const_double_vcvt_power_of_two): Define
new predicate.
* config/arm/arm.c (arm_print_operand): Add print for new fucntion.
(vfp3_const_double_for_bits): New function.
* config/arm/vfp.md (combine_vcvtf2i): Define new instruction.

gcc/testsuite/

2013-12-24  Renlin Li  <Renlin.Li@arm.com>

* gcc.target/arm/fixed_float_conversion.c: New test case.

From-SVN: r206195

gcc/ChangeLog
gcc/config/arm/arm-protos.h
gcc/config/arm/arm.c
gcc/config/arm/constraints.md
gcc/config/arm/predicates.md
gcc/config/arm/vfp.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/fixed_float_conversion.c [new file with mode: 0644]

index cc8c0938eec59bc46b003da809c397cff8f146ae..3e9214a5f32af8722e3df4aecc33a3fc77966f46 100644 (file)
@@ -1,3 +1,13 @@
+2013-12-24  Renlin Li  <Renlin.Li@arm.com>
+
+       * config/arm/arm-protos.h (vfp_const_double_for_bits): Declare.
+       * config/arm/constraints.md (Dp): Define new constraint.
+       * config/arm/predicates.md (const_double_vcvt_power_of_two): Define
+       new predicate.
+       * config/arm/arm.c (arm_print_operand): Add print for new fucntion.
+       (vfp3_const_double_for_bits): New function.
+       * config/arm/vfp.md (combine_vcvtf2i): Define new instruction.
+
 2013-12-23  Hans-Peter Nilsson  <hp@axis.com>
 
        PR target/59203
index 558f13418e617921684a8705f4afdf5293818215..62741cbd1618ffb2922126e83337ca2c3c4e9666 100644 (file)
@@ -276,6 +276,8 @@ struct tune_params
 
 extern const struct tune_params *current_tune;
 extern int vfp3_const_double_for_fract_bits (rtx);
+/* return power of two from operand, otherwise 0.  */
+extern int vfp3_const_double_for_bits (rtx);
 
 extern void arm_emit_coreregs_64bit_shift (enum rtx_code, rtx, rtx, rtx, rtx,
                                           rtx);
index 706846e909f5aa70547c382947724e89900c635d..39d23ccb25139af6b2e690633915ee6252021891 100644 (file)
@@ -21594,7 +21594,11 @@ arm_print_operand (FILE *stream, rtx x, int code)
 
     case 'v':
        gcc_assert (CONST_DOUBLE_P (x));
-       fprintf (stream, "#%d", vfp3_const_double_for_fract_bits (x));
+       int result;
+       result = vfp3_const_double_for_fract_bits (x);
+       if (result == 0)
+         result = vfp3_const_double_for_bits (x);
+       fprintf (stream, "#%d", result);
        return;
 
     /* Register specifier for vld1.16/vst1.16.  Translate the S register
@@ -29707,6 +29711,26 @@ vfp3_const_double_for_fract_bits (rtx operand)
     }
   return 0;
 }
+
+int
+vfp3_const_double_for_bits (rtx operand)
+{
+  REAL_VALUE_TYPE r0;
+
+  if (!CONST_DOUBLE_P (operand))
+    return 0;
+
+  REAL_VALUE_FROM_CONST_DOUBLE (r0, operand);
+  if (exact_real_truncate (DFmode, &r0))
+    {
+      HOST_WIDE_INT value = real_to_integer (&r0);
+      value = value & 0xffffffff;
+      if ((value != 0) && ( (value & (value - 1)) == 0))
+       return int_log2 (value);
+    }
+
+  return 0;
+}
 \f
 /* Emit a memory barrier around an atomic sequence according to MODEL.  */
 
index e2a3099e041ce52d5a5a9d423cd68e74ace3a53e..59ca4b62440e8d4fa6d2a387d1a3f7b9cb8cdcb8 100644 (file)
@@ -31,7 +31,7 @@
 ;; 'H' was previously used for FPA.
 
 ;; The following multi-letter normal constraints have been used:
-;; in ARM/Thumb-2 state: Da, Db, Dc, Dd, Dn, Dl, DL, Do, Dv, Dy, Di, Dt, Dz
+;; in ARM/Thumb-2 state: Da, Db, Dc, Dd, Dn, Dl, DL, Do, Dv, Dy, Di, Dt, Dp, Dz
 ;; in Thumb-1 state: Pa, Pb, Pc, Pd, Pe
 ;; in Thumb-2 state: Pj, PJ, Ps, Pt, Pu, Pv, Pw, Px, Py
 
  (and (match_code "const_double")
       (match_test "TARGET_32BIT && TARGET_VFP_DOUBLE && vfp3_const_double_rtx (op)")))
 
-(define_constraint "Dt" 
+(define_constraint "Dt"
  "@internal
   In ARM/ Thumb2 a const_double which can be used with a vcvt.f32.s32 with fract bits operation"
   (and (match_code "const_double")
        (match_test "TARGET_32BIT && TARGET_VFP && vfp3_const_double_for_fract_bits (op)")))
 
+(define_constraint "Dp"
+ "@internal
+  In ARM/ Thumb2 a const_double which can be used with a vcvt.s32.f32 with bits operation"
+  (and (match_code "const_double")
+       (match_test "TARGET_32BIT && TARGET_VFP && vfp3_const_double_for_bits (op)")))
+
 (define_register_constraint "Ts" "(arm_restrict_it) ? LO_REGS : GENERAL_REGS"
  "For arm_restrict_it the core registers @code{r0}-@code{r7}.  GENERAL_REGS otherwise.")
 
index e151a6b1f883d46af90d369f0d6d2cd0744541cd..641228612f5857a88f7cdbedcb16ce147d438390 100644 (file)
 
 (define_predicate "const_double_vcvt_power_of_two_reciprocal"
   (and (match_code "const_double")
-       (match_test "TARGET_32BIT && TARGET_VFP 
-                          && vfp3_const_double_for_fract_bits (op)")))
+       (match_test "TARGET_32BIT && TARGET_VFP
+                   && vfp3_const_double_for_fract_bits (op)")))
+
+(define_predicate "const_double_vcvt_power_of_two"
+  (and (match_code "const_double")
+       (match_test "TARGET_32BIT && TARGET_VFP
+                   && vfp3_const_double_for_bits (op)")))
 
 (define_predicate "neon_struct_operand"
   (and (match_code "mem")
index 6d0515a92b190b0fbf8b3d632008c95a900d1b6f..8d755fc1dfef16e997d997138cd699f7be124994 100644 (file)
    (set_attr "length" "8")]
 )
 
+(define_insn "*combine_vcvtf2i"
+  [(set (match_operand:SI 0 "s_register_operand" "=r")
+       (fix:SI (fix:SF (mult:SF (match_operand:SF 1 "s_register_operand" "t")
+                                (match_operand 2
+                                "const_double_vcvt_power_of_two" "Dp")))))]
+  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_VFP3 && !flag_rounding_math"
+  "vcvt%?.s32.f32\\t%1, %1, %v2\;vmov%?\\t%0, %1"
+  [(set_attr "predicable" "yes")
+   (set_attr "predicable_short_it" "no")
+   (set_attr "ce_count" "2")
+   (set_attr "type" "f_cvtf2i")
+   (set_attr "length" "8")]
+ )
+
 ;; Store multiple insn used in function prologue.
 (define_insn "*push_multi_vfp"
   [(match_parallel 2 "multi_register_push"
index c0bba43dc395424e5a71f11901fed6afd01a86d8..b7437545132507c1da335b0275b9d68a9d2d1c29 100644 (file)
@@ -1,3 +1,7 @@
+2013-12-24  Renlin Li  <Renlin.Li@arm.com>
+
+       * gcc.target/arm/fixed_float_conversion.c: New test case.
+
 2013-12-23  Bingfeng Mei  <bmei@broadcom.com>
 
        * gcc.dg/vect/vect-neg-store-1.c: New test.
diff --git a/gcc/testsuite/gcc.target/arm/fixed_float_conversion.c b/gcc/testsuite/gcc.target/arm/fixed_float_conversion.c
new file mode 100644 (file)
index 0000000..a8befd0
--- /dev/null
@@ -0,0 +1,19 @@
+/* Check that vcvt is used for fixed and float data conversions.  */
+/* { dg-do compile } */
+/* { dg-options "-O1 -mfpu=vfp3" } */
+/* { dg-require-effective-target arm_vfp_ok } */
+
+float
+fixed_to_float (int i)
+{
+  return ((float) i / (1 << 16));
+}
+
+int
+float_to_fixed (float f)
+{
+  return ((int) (f * (1 << 16)));
+}
+
+/* { dg-final { scan-assembler "vcvt.f32.s32" } } */
+/* { dg-final { scan-assembler "vcvt.s32.f32" } } */