summaryrefslogtreecommitdiff
path: root/testsuite/tests/cmm/opt/T18141.hs
blob: f324f4f6f0705fba0c421bc5eafbdd7b124daa83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{-# LANGUAGE MagicHash #-}

module T18141 where

import GHC.Exts

divInt8# :: Int8# -> Int8# -> Int8#
x# `divInt8#` y#
  | isTrue# (x# `gtInt8#` zero#) && isTrue# (y# `ltInt8#` zero#) =
    ((x# `subInt8#` one#) `quotInt8#` y#) `subInt8#` one#
  | isTrue# (x# `ltInt8#` zero#) && isTrue# (y# `gtInt8#` zero#) =
    ((x# `plusInt8#` one#) `quotInt8#` y#) `subInt8#` one#
  | otherwise = x# `quotInt8#` y#
  where
    zero# = intToInt8# 0#
    one# = intToInt8# 1#