# Changeset View

Changeset View

# Standalone View

Standalone View

# testsuite/tests/codeGen/should_run/cgrun078.hs

- This file was added.

1 | {-# OPTIONS_GHC -mavx #-} | ||||
---|---|---|---|---|---|

2 | {-# LANGUAGE MagicHash #-} | ||||

3 | {-# LANGUAGE UnboxedTuples #-} | ||||

4 | -- !!! test the lifting of unlifted vector types and | ||||

5 | -- defining various typeclass instances for the lifted types | ||||

6 | | ||||

7 | import GHC.Exts | ||||

8 | | ||||

9 | data FloatX4 = FX4# FloatX4# | ||||

10 | | ||||

11 | instance Show FloatX4 where | ||||

12 | show (FX4# f) = case (unpackFloatX4# f) of | ||||

13 | (# a, b, c, d #) -> show ((F# a), (F# b), (F# c), (F# d)) | ||||

14 | | ||||

15 | | ||||

16 | instance Eq FloatX4 where | ||||

17 | (FX4# a) == (FX4# b) | ||||

18 | = case (unpackFloatX4# a) of | ||||

19 | (# a1, a2, a3, a4 #) -> | ||||

20 | case (unpackFloatX4# b) of | ||||

21 | (# b1, b2, b3, b4 #) -> (F# a1) == (F# b1) && | ||||

22 | (F# a2) == (F# b2) && | ||||

23 | (F# a3) == (F# b3) && | ||||

24 | (F# a4) == (F# b4) | ||||

25 | | ||||

26 | data DoubleX2 = DX2# DoubleX2# | ||||

27 | | ||||

28 | instance Show DoubleX2 where | ||||

29 | show (DX2# d) = case (unpackDoubleX2# d) of | ||||

30 | (# a, b #) -> show ((D# a), (D# b)) | ||||

31 | | ||||

32 | | ||||

33 | instance Eq DoubleX2 where | ||||

34 | (DX2# a) == (DX2# b) | ||||

35 | = case (unpackDoubleX2# a) of | ||||

36 | (# a1, a2 #) -> | ||||

37 | case (unpackDoubleX2# b) of | ||||

38 | (# b1, b2 #) -> (D# a1) == (D# b1) && | ||||

39 | (D# a2) == (D# b2) | ||||

40 | | ||||

41 | main :: IO () | ||||

42 | main = do | ||||

43 | print (FX4# (broadcastFloatX4# 1.5#)) | ||||

44 | print $ (FX4# (broadcastFloatX4# 1.5#)) == (FX4# (broadcastFloatX4# 2.5#)) | ||||

45 | print $ (FX4# (broadcastFloatX4# 3.5#)) == (FX4# (broadcastFloatX4# 3.5#)) | ||||

46 | | ||||

47 | print (DX2# (broadcastDoubleX2# 2.5##)) | ||||

48 | print $ (DX2# (broadcastDoubleX2# 1.5##)) == (DX2# (broadcastDoubleX2# 2.5##)) | ||||

49 | print $ (DX2# (broadcastDoubleX2# 3.5##)) == (DX2# (broadcastDoubleX2# 3.5##)) |