Closed
Description
The fact that
Base.mod
andBase.rem
both are lowered to the same HLO operator looks very fishy since they have different semantics in Julia.https://openxla.org/xla/operation_semantics#element-wise_binary_arithmetic_operations
When
Op
isRem
, the sign of the result is taken from the dividend, and the absolute value of the result is always less than the divisor's absolute value.This is the semantic of Julia's
rem
, the opposite ofmod
. See also https://openxla.org/stablehlo/spec#remainder for more details about the operator.
Originally posted by @giordano in #754 (comment)