I'm submitting a new revision since i don't understand how to reclaim/reopen/take over the existing one, D50222.

There is no such action in "Add Action" menu...

This implements an optimization described in Hacker's Delight 10-17: when `C` is constant,

the result of `X % C == 0` can be computed more cheaply without actually calculating the remainder.

The motivation is discussed here: https://bugs.llvm.org/show_bug.cgi?id=35479.

Original patch D50222 by @hermord (Dmytro Shynkevych)

Notes:

- In principle, it's possible to also handle the
`X % C1 == C2`case, as discussed on bugzilla. This seems to require an extra branch on overflow, so I refrained from implementing this for now. - An explicit check for when the
`REM`can be reduced to just its LHS is included: the`X % C`== 0 optimization breaks`test1`in`test/CodeGen/X86/jump_sign.ll`otherwise. I hadn't managed to find a better way to not generate worse output in this case. - The
`test/CodeGen/X86/jump_sign.ll`regresses, and is being fixed by a followup patch D63390.