Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,247
    • Issues 4,247
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 398
    • Merge Requests 398
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #18668

Closed
Open
Opened Sep 08, 2020 by Richard Eisenberg@raeDeveloper

Confusing printing of unsaturated primops in RULE firings

I have

{-# LANGUAGE MagicHash #-}

module Main where

import GHC.Exts

five = I# (2# +# 3#)

{-# RULES "funky" (+#) = (*#) #-}

main :: IO ()
main = print five

When I ghc -O Scratch.hs -main-is Scratch -fforce-recomp -ddump-rule-rewrites, I get

Loaded package environment from /Users/rae/.ghc/x86_64-darwin-8.10.1/environments/default
[1 of 1] Compiling Scratch          ( Scratch.hs, Scratch.o, Scratch.dyn_o )
Rule fired
    Rule: funky
    Module: (Scratch)
    Before: GHC.Prim.+# ValArg 2# ValArg 3#
    After:  GHC.Prim.*#
    Cont:   Stop[BoringCtxt] GHC.Prim.Int#
Rule fired
    Rule: *#
    Module: (BUILTIN)
    Before: GHC.Prim.*# ValArg 2# ValArg 3#
    After:  6#
    Cont:   Stop[BoringCtxt] GHC.Prim.Int#
Rule fired
    Rule: Class op show
    Module: (BUILTIN)
    Before: GHC.Show.show TyArg GHC.Types.Int ValArg GHC.Show.$fShowInt
    After:  GHC.Show.$fShowInt_$cshow
    Cont:   ApplyToVal nodup x_aN7
            Stop[BoringCtxt] GHC.Base.String
Linking Scratch ...
ld: warning: directory not found for option '-L/opt/local/lib/'
ld: warning: text-based stub file /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libQuadrature.tbd and library file /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libQuadrature.dylib are out of sync. Falling back to library file for linking.
rae:14:29:21 ~/temp> 

Note the first rule rewrite. It says

    Before: GHC.Prim.+# ValArg 2# ValArg 3#
    After:  GHC.Prim.*#

Eek! At first, I thought we were bound for a core-lint error. Actually, all is well: it's just a printing problem. But I was thrown off the scent of some other misbehavior by this one.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#18668