[GHC] #8871: No-op assignment I64[BaseReg + 784] = I64[BaseReg + 784]; is generated into optimized Cmm

#8871: No-op assignment I64[BaseReg + 784] = I64[BaseReg + 784]; is generated into optimized Cmm ------------------------------------+------------------------------------- Reporter: kgardas | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: Other Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- Hello, on SPARC and I also guess on PPC it's possible to get following line in optimized Cmm code: {{{ I64[BaseReg + 784] = I64[BaseReg + 784]; }}} this line is then translated by NCG wasting 5 isns on SPARC at least. Don't know PPC. I'm not sure if this is possible to duplicate this on i386 due to fewer regs. Generally speaking you need to have 32bit target with more regs available. Interesting fact is that such line is not presented in non-optimized Cmm, but is presented in optimized one. Both optimized and non-optimized Cmms attached. Both get from compiling T7507 testcase by stage1 compiler on SPARC: {{{ /home/karel/vcs/ghc-src/ghc-sparc-reg_ncg/inplace/bin/ghc-stage1 -fforce- recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -fno-ghci-history -c T7507.hs -O -ddump-opt-cmm > T7507.opt-cmm- sparc-reg-ncg }}} Of course non-opt Cmm is got by -ddump-cmm instead of -ddump-opt-cmm. If you need more simplified testcase, then following code is usable too: {{{ module Main where import Data.Int main = print ( ( 2 ^ 6 ) :: Int64 ) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8871 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8871: No-op assignment I64[BaseReg + 784] = I64[BaseReg + 784]; is generated into optimized Cmm -------------------------------------+------------------------------------ Reporter: kgardas | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: Other | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): Are you using -O? Can you give your command line and output of `-ddump- cmm`? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8871#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8871: No-op assignment I64[BaseReg + 784] = I64[BaseReg + 784]; is generated into optimized Cmm -------------------------------------+------------------------------------ Reporter: kgardas | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: Other | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by kgardas): Replying to [comment:1 simonpj]:
Are you using -O? Can you give your command line and output of `-ddump- cmm`?
Yes, see the command-line and also see attached files. BTW, I'm able to also reproduce this on PPC 32bit as I wrote. This is by using my simplified example above: {{{ $ grep "I64" T7507d_64-O-ppc.opt-cmm|grep Base I64[BaseReg + 784] = _s317::I64; I64[BaseReg + 784] = _s31d::I64; I64[BaseReg + 784] = 1 :: W64; I64[BaseReg + 784] = I64[BaseReg + 784]; I64[Hp - 4] = I64[BaseReg + 784]; I64[Sp - 8] = I64[BaseReg + 784]; }}} you see the line in the middle of grep... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8871#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8871: No-op assignment I64[BaseReg + 784] = I64[BaseReg + 784]; is generated into
optimized Cmm
-------------------------------------+------------------------------------
Reporter: kgardas | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.9
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: Other | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by kgardas):
Also for your reference this is slightly out-dated HEAD (master branch)
where the last patch is:
{{{
commit 018676c7f883886b388652c913c99a10d2591b0b
Author: Herbert Valerio Riedel

#8871: No-op assignment I64[BaseReg + 784] = I64[BaseReg + 784]; is generated into optimized Cmm -------------------------------------+------------------------------------ Reporter: kgardas | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: Other | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by simonpj): * cc: jstolarek, simonmar (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8871#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8871: No-op assignment I64[BaseReg + 784] = I64[BaseReg + 784]; is generated into optimized Cmm -------------------------------------+------------------------------------ Reporter: kgardas | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: Other | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonmar): Yes, this is just a missing optimisation. I didn't implement it because I hadn't seen any code that needed it, until now. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8871#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8871: No-op assignment I64[BaseReg + 784] = I64[BaseReg + 784]; is generated into optimized Cmm -------------------------------------+------------------------------------- Reporter: kgardas | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 (CodeGen) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Runtime | Related Tickets: performance bug | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thomie): * failure: Other => Runtime performance bug * component: Compiler => Compiler (CodeGen) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8871#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8871: No-op assignment I64[BaseReg + 784] = I64[BaseReg + 784]; is generated into optimized Cmm -------------------------------------+------------------------------------- Reporter: kgardas | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 (CodeGen) | Resolution: | Keywords: CodeGen Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: => CodeGen -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8871#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC