[PATCH] Improved udivmodsi4 with support for ARMv4

Saleem Abdulrasool compnerd at compnerd.org
Thu Jan 23 20:07:57 PST 2014



================
Comment at: lib/arm/udivmodsi4.S:22
@@ +21,3 @@
+#else
+#define	JMP(r)	mov	pc, r
+#endif
----------------
bx is supported as of ARMv4T, I take it that you want to support pre-T versions of ARMv4?

================
Comment at: lib/arm/udivmodsi4.S:59
@@ +58,3 @@
+#  ifdef __ARM_FEATURE_CLZ
+	clz	ip, r0
+	clz	r3, r1
----------------
I think adding a reminder that due to the previous comparison, r0 >= r1 will hold would be nice.

================
Comment at: lib/arm/udivmodsi4.S:111
@@ +110,3 @@
+
+	block(31)
+	block(30)
----------------
Can you please rewrite the loop unrolling as:

    .macro block shift
      cmp r0, r1, lsl # \shift
      addhs r3, r3, #(1 << \shift)
      subhs r0, r0, r1, lsl # \shift
    .endm

    .Lround = 31
    .rept 31
      block .Lround
      .Lround = .Lround - 1
    .endr
    LOCAL_LABEL(div0block):
      block 0

The net effect is identical, but it is much simpler to maintain IMO.

================
Comment at: lib/arm/udivsi3.S:1
@@ -1,2 +1,2 @@
-/*===-- udivsi3.S - 32-bit unsigned integer divide ------------------------===//
+/*===-- udivmodsi4.S - 32-bit unsigned integer divide and modulus ---------===//
  *
----------------
I think that this update is incorrect.

================
Comment at: lib/arm/udivsi3.S:19
@@ +18,3 @@
+
+#ifdef ARM_HAS_BX
+#define	JMP(r)		bx	r
----------------
Similar comments apply as previous file.

================
Comment at: lib/arm/umodsi3.S:1
@@ -1,2 +1,2 @@
-/*===-- umodsi3.S - 32-bit unsigned integer modulus -----------------------===//
+/*===-- udivmodsi4.S - 32-bit unsigned integer divide and modulus ---------===//
  *
----------------
Again, implementing a different routine here.

================
Comment at: lib/arm/umodsi3.S:10
@@ -9,4 +9,3 @@
  *
- * This file implements the __umodsi3 (32-bit unsigned integer modulus) 
- * function for the ARM architecture.  A naive digit-by-digit computation is
- * employed for simplicity.
+ * This file implements the __udivmodsi4 (32-bit unsigned integer divide and
+ * modulus) function for the ARM 32-bit architecture.
----------------
The comment does not match the function again.

================
Comment at: lib/arm/umodsi3.S:19
@@ -22,3 +18,3 @@
 
-.syntax unified
-.align 3
+#ifdef ARM_HAS_BX
+#define	JMP(r)		bx	r
----------------
Similar things as the previous two files.


http://llvm-reviews.chandlerc.com/D2595



More information about the llvm-commits mailing list