[llvm-bugs] [Bug 32464] New: More efficient remainder lowering

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 29 14:40:08 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32464

            Bug ID: 32464
           Summary: More efficient remainder lowering
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: AArch64
          Assignee: unassignedbugs at nondot.org
          Reporter: davide at freebsd.org
                CC: efriedma at codeaurora.org, llvm-bugs at lists.llvm.org,
                    mcrosier at codeaurora.org, t.p.northover at gmail.com

Given the following IR:

> cat remainder.ll
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64--linux-gnu"

define i32 @tinky(i32 %j) local_unnamed_addr #0 {
entry:
  %rem = srem i32 %j, 255
  ret i32 %rem
}

attributes #0 = { norecurse nounwind readnone
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false"
"less-precise-fpmad"="false" "no-frame-pointer-elim"="true"
"no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false"
"no-jump-tables"="false" "no-nans-fp-math"="false"
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="cortex-a53"
"target-features"="+crc,-crypto,-fp-armv8,-neon" "unsafe-fp-math"="false"
"use-soft-float"="false" }

!llvm.ident = !{!0}


Fast-isel seems to generate slightly faster/shorter code than SelectionDAG:

> C:\Users\fluttershy\work\llvm-msvc\Debug\bin\llc.exe -O3 -mcpu=cortex-a53 remainder.ll -o - -fast-isel
        .text
        .file   "remainder.ll"
        .globl  tinky
        .p2align        2
        .type   tinky, at function
tinky:                                  // @tinky
// BB#0:                                // %entry
        orr     w8, wzr, #0xff
        sdiv    w9, w0, w8
        msub    w0, w9, w8, w0
        ret
.Lfunc_end0:
        .size   tinky, .Lfunc_end0-tinky


        .ident  "clang version 5.0.0 (trunk 298784) (llvm/trunk 298825)"
        .section        ".note.GNU-stack","", at progbits


> C:\Users\fluttershy\work\llvm-msvc\Debug\bin\llc.exe -O3 -mcpu=cortex-a53 remainder.ll -o -
        .text
        .file   "remainder.ll"
        .globl  tinky
        .p2align        2
        .type   tinky, at function
tinky:                                  // @tinky
// BB#0:                                // %entry
        orr     w8, wzr, #0xff
        sdiv    w8, w0, w8
        lsl     w9, w8, #8
        sub             w8, w9, w8
        sub             w0, w0, w8
        ret
.Lfunc_end0:
        .size   tinky, .Lfunc_end0-tinky


        .ident  "clang version 5.0.0 (trunk 298784) (llvm/trunk 298825)"
        .section        ".note.GNU-stack","", at progbits

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170329/8084650e/attachment.html>


More information about the llvm-bugs mailing list