[GHC] #9430: implement more arithmetic operations natively in the LLVM backend

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.9 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Moderate (less | Type of failure: Runtime than a day) | performance bug Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- There are a number of arithmetic operations that have native implementations on x86 but use the generic fallback on LLVM. Implementing these with LLVM intrinsics could improve small Integer performance on ARM substantially! {{{ MO_Add2 @llvm.uadd.with.overflow.* MO_AddIntC @llvm.sadd.with.overflow.* MO_SubIntC @llvm.ssub.with.overflow.* MO_U_Mul2 mul i64/i128? MO_U_QuotRem2 udiv i64/i128? }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.9 Component: Compiler | Keywords: (LLVM) | Architecture: Unknown/Multiple Resolution: | Difficulty: Moderate (less Operating System: | than a day) Unknown/Multiple | Blocked By: Type of failure: Runtime | Related Tickets: performance bug | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by rwbarton): I probably won't get around to this myself in the near future. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.9 Component: Compiler | Keywords: (LLVM) | Architecture: Unknown/Multiple Resolution: | Difficulty: Moderate (less Operating System: | than a day) Unknown/Multiple | Blocked By: Type of failure: Runtime | Related Tickets: performance bug | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by rwbarton): In fact, with these changes it may end up making sense to build integer- gmp with LLVM anywhere we can. (At least if split-objs worked with LLVM: #8300.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: michalt Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by michalt): * owner: => michalt Comment: This looks like a nice way to learn more about LLVM backend, so I've started working on adding support for: `MO_Add2` and `MO_{Add,Sub}IntC`. I hope to send something out within the next few days. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: michalt Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by michalt): Sent out Phab:D991 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9430: implement more arithmetic operations natively in the LLVM backend
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner: michalt
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler (LLVM) | Version: 7.9
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: michalt Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by bgamari): It looks like we're still looking for someone to contribute support for `MO_U_Mul2` and `MO_U_QuotRem2`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: michalt Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by michalt): Sorry I wasn't clear in the previous message - I'm actually planning to implement support for the two remaining operations as well (hopefully I'll have some time over the weekend). I just wanted to split the work into two parts since I'm not very familiar with the codebase. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: michalt Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by bgamari): Ahh, great! Looking forward to reviewing the next patch. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9430: implement more arithmetic operations natively in the LLVM backend
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner: michalt
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler (LLVM) | Version: 7.9
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: michalt Type: feature request | Status: closed Priority: normal | Milestone: 7.12.1 Component: Compiler (LLVM) | Version: 7.9 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime | Test Case: performance bug | primops/should_run/T9430 Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * testcase: => primops/should_run/T9430 * status: new => closed * resolution: => fixed * milestone: => 7.12.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime | Test Case: performance bug | primops/should_run/T9430 Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by michalt): * status: closed => new * owner: michalt => * resolution: fixed => * milestone: 7.12.1 => Comment: I was also planning to add support for MO_U_QuotRem2 (using `udiv` and `urem`), so let's not close this just yet. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: michalt Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime | Test Case: performance bug | primops/should_run/T9430 Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by michalt): * owner: => michalt -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9430: implement more arithmetic operations natively in the LLVM backend
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner: michalt
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler (LLVM) | Version: 7.9
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Runtime | Test Case:
performance bug | primops/should_run/T9430
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: michalt Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime | Test Case: performance bug | primops/should_run/T9430 Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by bgamari): Here is the current state of things as I understand them. ||= MachOp =||= LLVM construct =||= commit =|| || MO_Add2 || @llvm.uadd.with.overflow.* || b1d1c652908ecd7bfcf13cf2e5dd06ac7926992c/ghc || || MO_AddIntC || @llvm.sadd.with.overflow.* || b1d1c652908ecd7bfcf13cf2e5dd06ac7926992c/ghc || || MO_SubIntC || @llvm.ssub.with.overflow.* || b1d1c652908ecd7bfcf13cf2e5dd06ac7926992c/ghc || || MO_U_Mul2 || mul i64/i128? || TODO || || MO_U_QuotRem2 || udiv i64/i128? || 92f5385d8b2be50848a2496199a481f299f4b53a/ghc || -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: michalt Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime | Test Case: performance bug | primops/should_run/T9430 Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): But MO_U_Mul2 was done in 82ffc80d (comment:9) right? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9430: implement more arithmetic operations natively in the LLVM backend -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: michalt Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.9 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime | Test Case: performance bug | primops/should_run/T9430 Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by michalt): * status: new => closed * resolution: => fixed Comment: Replying to [comment:15 rwbarton]:
But MO_U_Mul2 was done in 82ffc80d (comment:9) right?
Yes, I think the 3 commits now cover all the ops in the ticket (first commit for the `llvm.*.with.overflow` ones, and then one for each of `MO_U_{Mul2,QuotRem2}`). So I hope it's ok to close it. :-) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9430#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC