- maybe_comparison (MO_U_Gt _) rep = Just (MO_U_Gt rep)
- maybe_comparison (MO_U_Ge _) rep = Just (MO_U_Ge rep)
- maybe_comparison (MO_U_Lt _) rep = Just (MO_U_Lt rep)
- maybe_comparison (MO_U_Le _) rep = Just (MO_U_Le rep)
- maybe_comparison (MO_S_Gt _) rep = Just (MO_S_Gt rep)
- maybe_comparison (MO_S_Ge _) rep = Just (MO_S_Ge rep)
- maybe_comparison (MO_S_Lt _) rep = Just (MO_S_Lt rep)
- maybe_comparison (MO_S_Le _) rep = Just (MO_S_Le rep)
- maybe_comparison (MO_Eq _) rep = Just (MO_Eq rep)
- maybe_comparison _ _ = Nothing
+ -- careful (#2080): if the original comparison was signed, but
+ -- we were doing an unsigned widen, then we must do an
+ -- unsigned comparison at the smaller size.
+ maybe_comparison (MO_U_Gt _) rep _ = Just (MO_U_Gt rep)
+ maybe_comparison (MO_U_Ge _) rep _ = Just (MO_U_Ge rep)
+ maybe_comparison (MO_U_Lt _) rep _ = Just (MO_U_Lt rep)
+ maybe_comparison (MO_U_Le _) rep _ = Just (MO_U_Le rep)
+ maybe_comparison (MO_Eq _) rep _ = Just (MO_Eq rep)
+ maybe_comparison (MO_S_Gt _) rep True = Just (MO_S_Gt rep)
+ maybe_comparison (MO_S_Ge _) rep True = Just (MO_S_Ge rep)
+ maybe_comparison (MO_S_Lt _) rep True = Just (MO_S_Lt rep)
+ maybe_comparison (MO_S_Le _) rep True = Just (MO_S_Le rep)
+ maybe_comparison (MO_S_Gt _) rep False = Just (MO_U_Gt rep)
+ maybe_comparison (MO_S_Ge _) rep False = Just (MO_U_Ge rep)
+ maybe_comparison (MO_S_Lt _) rep False = Just (MO_U_Lt rep)
+ maybe_comparison (MO_S_Le _) rep False = Just (MO_U_Le rep)
+ maybe_comparison _ _ _ = Nothing