From b20fc421b5afc2ce35cd16c5c92a03207672d708 Mon Sep 17 00:00:00 2001
From: Takano Akio <aljee@hyper.cx>
Date: Wed, 20 Jun 2012 10:56:39 +0900
Subject: [PATCH] add RULES for bitwise logic and shift primops

---
 GHC/Base.lhs |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/GHC/Base.lhs b/GHC/Base.lhs
index f684563..ee5d775 100644
--- a/GHC/Base.lhs
+++ b/GHC/Base.lhs
@@ -803,6 +803,26 @@ iShiftRL# :: Int# -> Int# -> Int#
 a `iShiftRL#` b | b >=# WORD_SIZE_IN_BITS# = 0#
                 | otherwise                = a `uncheckedIShiftRL#` b
 
+{-# RULES
+"or# x# 0##"  forall x#. or# x# 0##  = x#
+"or# 0## x#"  forall x#. or# 0## x#  = x#
+"or# x# x#"   forall x#. or# x# x#   = x#
+"and# x# 0##" forall x#. and# x# 0## = 0##
+"and# 0## x#" forall x#. and# 0## x# = 0##
+"and# x# x#"  forall x#. and# x# x#  = x#
+"xor# x# 0##" forall x#. xor# x# 0## = x#
+"xor# 0## x#" forall x#. xor# 0## x# = x#
+"xor# x# x#"  forall x#. xor# x# x#  = 0##
+  #-}
+
+{-# RULES
+"uncheckedShiftL# x# 0#"   forall x#. uncheckedShiftL# x# 0#   = x#
+"uncheckedShiftRL# x# 0#"  forall x#. uncheckedShiftRL# x# 0#  = x#
+"uncheckedIShiftL# x# 0#"  forall x#. uncheckedIShiftL# x# 0#  = x#
+"uncheckedIShiftRA# x# 0#" forall x#. uncheckedIShiftRA# x# 0# = x#
+"uncheckedIShiftRL# x# 0#" forall x#. uncheckedIShiftRL# x# 0# = x#
+  #-}
+
 #if WORD_SIZE_IN_BITS == 32
 {-# RULES
 "narrow32Int#"  forall x#. narrow32Int#   x# = x#
-- 
1.7.1

