Merge e7ee08b47783f80e2eb76e944beb4ad5829157f6 on remote branch

Change-Id: I54c65828a24aa16a65d930f3220c403320f9aea2
diff --git a/Android.bp b/Android.bp
index e58f54f..3aaa01b 100644
--- a/Android.bp
+++ b/Android.bp
@@ -12,6 +12,23 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    default_applicable_licenses: ["external_FP16_license"],
+}
+
+// Added automatically by a large-scale-change
+// See: http://go/android-license-faq
+license {
+    name: "external_FP16_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-MIT",
+    ],
+    license_text: [
+        "LICENSE",
+    ],
+}
+
 cc_library_headers {
     name: "fp16_headers",
     export_include_dirs: ["include"],
@@ -110,4 +127,3 @@
         "general-tests",
     ],
 }
-
diff --git a/include/fp16/fp16.h b/include/fp16/fp16.h
index 2b61fff..a283d67 100644
--- a/include/fp16/fp16.h
+++ b/include/fp16/fp16.h
@@ -64,7 +64,7 @@
 	_BitScanReverse(&nonsign_bsr, (unsigned long) nonsign);
 	uint32_t renorm_shift = (uint32_t) nonsign_bsr ^ 31;
 #else
-	uint32_t renorm_shift = __builtin_clz(nonsign);
+	uint32_t renorm_shift = nonsign ? __builtin_clz(nonsign) : 32;
 #endif
 	renorm_shift = renorm_shift > 5 ? renorm_shift - 5 : 0;
 	/*
@@ -293,7 +293,7 @@
 	_BitScanReverse(&nonsign_bsr, (unsigned long) nonsign);
 	uint32_t renorm_shift = (uint32_t) nonsign_bsr ^ 31;
 #else
-	uint32_t renorm_shift = __builtin_clz(nonsign);
+	uint32_t renorm_shift = nonsign ? __builtin_clz(nonsign) : 32;
 #endif
 	renorm_shift = renorm_shift > 5 ? renorm_shift - 5 : 0;
 	/*