For srem x, y, if abs(constant range of x) less than abs(constant
range of y), we can simplify it as:
srem x, y => x if y is guaranteed to be positive.
'srem x, y => -x' if y is guaranteed to be negative.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Actually, this shows that this is not correct as implemented: You should always simplify to LHS, independent of RHS sign. srem result has the same sign as LHS, not RHS.
Comment Actions
LGTM
llvm/test/Transforms/CorrelatedValuePropagation/srem.ll | ||
---|---|---|
539–540 | nit: I think it would be cleaner to return i32 %rem from these tests, rather than using in an icmp that doesn't really seem relevant. |
nit: I think it would be cleaner to return i32 %rem from these tests, rather than using in an icmp that doesn't really seem relevant.