Merge "Add HAS_HW_DIV to control the compilation of __udivsi3."
diff --git a/lib/ExecutionEngine/Android.mk b/lib/ExecutionEngine/Android.mk
index d5a4573..1666f87 100644
--- a/lib/ExecutionEngine/Android.mk
+++ b/lib/ExecutionEngine/Android.mk
@@ -48,6 +48,10 @@
 
 LOCAL_SRC_FILES := $(libbcc_executionengine_SRC_FILES)
 
+ifeq ($(strip $(TARGET_CPU_VARIANT)),cortex-a15)
+LOCAL_CFLAGS += -DHAS_HW_DIV
+endif
+
 include $(LIBBCC_DEVICE_BUILD_MK)
 include $(LIBBCC_GEN_CONFIG_MK)
 include $(LLVM_DEVICE_BUILD_MK)
diff --git a/runtime/lib/divsi3.c b/runtime/lib/divsi3.c
index de1700a..3ab82f0 100644
--- a/runtime/lib/divsi3.c
+++ b/runtime/lib/divsi3.c
@@ -12,7 +12,10 @@
  * ===----------------------------------------------------------------------===
  */
 
-#if !defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8) // gcc >= 4.8 implements this in libgcc
+#if !defined(__GNUC__) || __GNUC__ < 4 || \
+    (__GNUC__ == 4 && __GNUC_MINOR__ < 8 && !defined(HAS_HW_DIV))
+// gcc >= 4.8 implements this in libgcc
+// gcc 4.7 also implements this in libgcc with -mcpu=cortex-a15
 #include "int_lib.h"
 
 su_int __udivsi3(su_int n, su_int d);