Opened 12 months ago

Last modified 4 months ago

#8871 new bug

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

Reported by: kgardas Owned by:
Priority: normal Milestone:
Component: Compiler (CodeGen) Version: 7.9
Keywords: Cc: jstolarek, simonmar
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

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 )

Attachments (2)

T7507.opt-cmm-sparc-reg-ncg (44.2 KB) - added by kgardas 12 months ago.
T7507.cmm-sparc-reg-ncg.xz (14.5 KB) - added by kgardas 12 months ago.

Download all attachments as: .zip

Change History (8)

comment:1 follow-up: Changed 12 months ago by simonpj

Are you using -O? Can you give your command line and output of -ddump-cmm?

Changed 12 months ago by kgardas

Changed 12 months ago by kgardas

comment:2 in reply to: ↑ 1 Changed 12 months ago by kgardas

Replying to 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...

comment:3 Changed 12 months ago 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 <[email protected]>
Date:   Sun Feb 23 22:00:57 2014 +0100

    Use U+2018 instead of U+201B quote mark in compiler messages
    
    This matches GCC's choice of Unicode quotation marks (i.e. U+2018 and U+2019)
    and therefore looks more familiar on the console. This addresses #2507.
    
    Signed-off-by: Herbert Valerio Riedel <[email protected]>

comment:4 Changed 12 months ago by simonpj

  • Cc jstolarek simonmar added

comment:5 Changed 12 months ago 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.

comment:6 Changed 4 months ago by thomie

  • Component changed from Compiler to Compiler (CodeGen)
  • Type of failure changed from Other to Runtime performance bug
Note: See TracTickets for help on using tickets.