[aarch64-port-dev ] Another reproducer for AArch64 HS

Andrew Haley aph at redhat.com
Thu Sep 12 09:22:44 PDT 2013


Argh!  I completely messed that up.  I got the encodings the wrong
way round, and was decoding what I should have been encoding.  So it
returned false except for values of zero.

This one is right, I swear.

Andrew.


# HG changeset patch
# User aph
# Date 1379002844 -3600
# Node ID 4afcbbbfaf7a4018766521e2b580c167c9c1f1e3
# Parent  5e4c8854ea19ea3c673847d9f66d5184a1aa601c
Fix the fix for operand_valid_for_float_immediate.

diff -r 5e4c8854ea19 -r 4afcbbbfaf7a src/cpu/aarch64/vm/assembler_aarch64.cpp
--- a/src/cpu/aarch64/vm/assembler_aarch64.cpp	Thu Sep 12 16:04:07 2013 +0100
+++ b/src/cpu/aarch64/vm/assembler_aarch64.cpp	Thu Sep 12 17:20:44 2013 +0100
@@ -1480,33 +1480,26 @@
   return encode_logical_immediate(is32, imm) != 0xffffffff;
 }

-static jlong doubleToLongBits(jdouble d) {
+static uint64_t doubleTo64Bits(jdouble d) {
   union {
     jdouble double_value;
-    jlong double_bits;
+    uint64_t double_bits;
   };

   double_value = d;
   return double_bits;
 }

-static jint floatToIntBits(jfloat f) {
-  union {
-    jfloat float_value;
-    jint float_bits;
-  };
+bool Assembler::operand_valid_for_float_immediate(double imm) {
+  // If imm is all zero bits we can use ZR as the source of a
+  // floating-point value.
+  if (doubleTo64Bits(imm) == 0)
+    return true;

-  float_value = f;
-  return float_bits;
-}
-
-bool Assembler::operand_valid_for_float_immediate(double imm) {
-  // We try to encode the immediate value then we convert the encoded
-  // back and make sure it's the exact same bit pattern
-
-  unsigned result = fp_immediate_for_encoding(floatToIntBits(imm), true);
-  return doubleToLongBits(imm)
-    == doubleToLongBits(encoding_for_fp_immediate(result));
+  // Otherwise try to encode imm then convert the encoded value back
+  // and make sure it's the exact same bit pattern.
+  unsigned result = encoding_for_fp_immediate(imm);
+  return doubleTo64Bits(imm) == fp_immediate_for_encoding(result, true);
 }

 int AbstractAssembler::code_fill_byte() {




More information about the aarch64-port-dev mailing list