]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/ppc64: leverage AND operation to calculate remainder
authorAndy Pan <panjf2000@gmail.com>
Sun, 5 Apr 2020 14:21:11 +0000 (22:21 +0800)
committerLynn Boger <laboger@linux.vnet.ibm.com>
Thu, 9 Apr 2020 15:56:51 +0000 (15:56 +0000)
Change-Id: I03e2a573eb778591071db4f783585a5d71a14c03
Reviewed-on: https://go-review.googlesource.com/c/go/+/227005
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
src/cmd/internal/obj/ppc64/asm9.go

index 90bee3d9b6c241fdb6594abe13381588962d5842..288e5f336064517bfa4131a4d7bc7b105765586b 100644 (file)
@@ -54,7 +54,8 @@ type ctxt9 struct {
 // Instruction layout.
 
 const (
-       funcAlign = 16
+       funcAlign     = 16
+       funcAlignMask = funcAlign - 1
 )
 
 const (
@@ -622,11 +623,11 @@ var xcmp [C_NCLASS][C_NCLASS]bool
 func addpad(pc, a int64, ctxt *obj.Link) int {
        switch a {
        case 8:
-               if pc%8 != 0 {
+               if pc&7 != 0 {
                        return 4
                }
        case 16:
-               switch pc % 16 {
+               switch pc & 15 {
                case 4, 12:
                        return 4
                case 8:
@@ -735,8 +736,8 @@ func span9(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
                c.cursym.Size = pc
        }
 
-       if pc%funcAlign != 0 {
-               pc += funcAlign - (pc % funcAlign)
+       if r := pc & funcAlignMask; r != 0 {
+               pc += funcAlign - r
        }
 
        c.cursym.Size = pc