Files
llvm/test/CodeGen/X86
Roman Lebedev c285223daf [CodeGen][SelectionDAG] More efficient code for X % C == 0 (SREM case)
Summary:
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.

One huge caveat: this signed case is only valid for positive divisors.

While we can freely negate negative divisors, we can't negate `INT_MIN`,
so for now if `INT_MIN` is encountered, we bailout.
As a follow-up, it should be possible to handle that more gracefully
via extra `and`+`setcc`+`select`.

This passes llvm's test-suite, and from cursory(!) cross-examination
the folds (the assembly) match those of GCC, and manual checking via alive
did not reveal any issues (other than the `INT_MIN` case)

Reviewers: RKSimon, spatel, hermord, craig.topper, xbolva00

Reviewed By: RKSimon, xbolva00

Subscribers: xbolva00, thakis, javed.absar, hiraditya, dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D65366

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368702 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-13 14:57:37 +00:00
..
2019-08-09 21:11:20 +00:00
2018-04-07 19:50:09 +00:00
2019-01-17 10:49:01 +00:00
2019-02-13 17:30:03 +00:00
2019-06-27 20:37:12 +00:00
2019-04-08 13:58:50 +00:00
2019-05-06 09:46:50 +00:00
2019-05-06 09:46:50 +00:00
2019-05-06 09:46:50 +00:00
2019-05-06 09:46:50 +00:00
2019-05-06 09:46:50 +00:00
2019-05-06 09:46:50 +00:00
2019-05-06 09:46:50 +00:00
2019-02-21 15:30:28 +00:00
2018-11-16 19:35:00 +00:00
2018-10-26 23:50:23 +00:00
2019-02-26 16:55:10 +00:00
2019-08-12 01:29:46 +00:00
2018-10-26 23:50:23 +00:00
2019-06-25 14:46:52 +00:00
2019-01-24 18:34:00 +00:00
2018-10-15 05:31:24 +00:00
2018-01-14 19:07:41 +00:00
2019-03-15 21:17:53 +00:00
2019-03-15 21:17:53 +00:00
2018-10-26 12:33:56 +00:00
2019-04-15 17:38:47 +00:00
2019-04-15 17:38:47 +00:00
2019-04-15 17:38:47 +00:00
2019-04-03 12:33:16 +00:00
2018-02-06 18:18:49 +00:00
2019-02-26 16:55:10 +00:00
2019-05-06 09:46:50 +00:00
2019-05-06 09:46:50 +00:00
2019-03-29 17:35:56 +00:00
2019-06-17 09:13:29 +00:00
2019-05-06 19:29:24 +00:00
2019-03-15 21:17:53 +00:00
2018-07-23 20:19:10 +00:00
2018-08-30 06:01:05 +00:00
2019-03-08 19:16:26 +00:00
2018-04-13 11:37:06 +00:00
2018-02-11 13:12:50 +00:00
2019-01-26 13:56:53 +00:00
2018-01-08 13:21:24 +00:00
2019-06-17 09:13:29 +00:00
2018-05-10 07:26:05 +00:00
2018-05-10 07:26:05 +00:00
2018-01-19 12:05:58 +00:00
2019-04-08 13:58:50 +00:00
2019-03-15 21:17:53 +00:00
2019-03-02 02:44:16 +00:00
2019-06-18 23:31:10 +00:00