Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,248
    • Issues 5,248
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 576
    • Merge requests 576
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16258
Closed
Open
Issue created Jan 30, 2019 by Peter Trommler@trommler🥁Developer

PowerPC Big-Endian: ArithInt16, ArithInt8, ArithWord16, and ArithWord8 fail

The tests were run on a PowerMac G5 running Linux, PowerMacs are big-endian.

I reduced the issue to this program where I get the incorrect answer 25132:

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}

module Main where

import GHC.Exts

main :: IO ()
main = do
    putStrLn $ show (apply2 plusInt16# (50) (50))

apply2 :: (Int16# -> Int16# -> Int16#) -> Int -> Int -> Int
apply2 op (I# a) (I# b) =
    let (# sa, sb #) = (# narrowInt16# a, narrowInt16# b #)
        r = op sa sb
    in I# (extendInt16# r)
{-# NOINLINE apply2 #-}

Curiously, when I inline plusInt16# and remove the op parameter the result is correct.

The test passes on little-endian PowerPC 64-bit.

Note: This bug is different from #16222 (closed), which deals with the C calling convention.

Edited Mar 10, 2019 by Peter Trommler
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking