Alexandre Isoard
3b88873b05
[SCEV] Add URem support to SCEV
...
In LLVM IR the following code:
%r = urem <ty> %t, %b
is equivalent to
%q = udiv <ty> %t, %b
%s = mul <ty> nuw %q, %b
%r = sub <ty> nuw %t, %q ; (t / b) * b + (t % b) = t
As UDiv, Mul and Sub are already supported by SCEV, URem can be implemented
with minimal effort using that relation:
%r --> (-%b * (%t /u %b)) + %t
We implement two special cases:
- if %b is 1, the result is always 0
- if %b is a power-of-two, we produce a zext/trunc based expression instead
That is, the following code:
%r = urem i32 %t, 65536
Produces:
%r --> (zext i16 (trunc i32 %a to i16) to i32)
Note that while this helps get a tighter bound on the range analysis and the
known-bits analysis, this exposes some normalization shortcoming of SCEVs:
%div = udim i32 %a, 65536
%mul = mul i32 %div, 65536
%rem = urem i32 %a, 65536
%add = add i32 %mul, %rem
Will usually not be reduced.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312329 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-01 14:59:59 +00:00
..
2015-02-27 19:29:02 +00:00
2013-08-22 00:51:19 +00:00
2013-08-22 00:51:19 +00:00
2013-08-22 00:51:19 +00:00
2013-08-22 00:51:19 +00:00
2013-08-22 00:51:19 +00:00
2011-11-29 02:05:23 +00:00
2013-08-22 00:51:19 +00:00
2013-08-22 00:51:19 +00:00
2015-02-27 21:17:42 +00:00
2013-08-22 00:51:19 +00:00
2013-08-22 00:51:19 +00:00
2013-08-22 00:51:19 +00:00
2015-04-16 23:24:18 +00:00
2013-11-06 02:08:26 +00:00
2013-11-06 02:08:26 +00:00
2015-02-27 21:17:42 +00:00
2013-08-22 00:51:19 +00:00
2013-11-06 02:08:26 +00:00
2015-02-27 21:17:42 +00:00
2014-02-16 13:27:39 +00:00
2015-02-27 19:29:02 +00:00
2015-02-27 21:17:42 +00:00
2012-12-30 01:42:34 +00:00
2012-12-30 02:33:22 +00:00
2017-01-15 09:29:27 +00:00
2011-10-05 06:23:32 +00:00
2015-04-16 23:24:18 +00:00
2017-01-15 09:29:27 +00:00
2012-08-17 12:28:26 +00:00
2014-01-27 10:04:03 +00:00
2015-09-09 20:47:30 +00:00
2015-02-27 21:17:42 +00:00
2017-01-15 09:29:27 +00:00
2015-02-27 21:17:42 +00:00
2015-11-19 05:56:52 +00:00
2017-08-03 08:41:30 +00:00
2015-10-07 18:14:25 +00:00
2017-05-26 06:47:04 +00:00
2013-08-22 00:51:19 +00:00
2013-08-22 00:51:19 +00:00
2016-06-30 02:47:28 +00:00
2016-05-11 17:41:41 +00:00
2017-04-24 00:09:46 +00:00
2015-03-26 17:28:26 +00:00
2016-06-08 17:48:36 +00:00
2017-08-04 20:19:46 +00:00
2017-09-01 14:59:59 +00:00
2015-03-20 02:25:00 +00:00
2017-07-08 17:17:30 +00:00
2012-06-28 23:44:57 +00:00
2017-03-31 12:05:30 +00:00
2017-03-31 12:05:30 +00:00
2015-02-09 18:34:55 +00:00
2016-03-09 01:51:44 +00:00
2016-05-29 00:32:17 +00:00
2015-03-18 00:41:29 +00:00
2017-01-15 00:26:18 +00:00
2015-04-01 18:24:06 +00:00
2017-06-30 05:04:09 +00:00
2015-02-27 21:17:42 +00:00
2015-03-09 21:43:39 +00:00
2017-01-26 13:33:17 +00:00
2017-07-23 15:40:19 +00:00
2016-10-20 21:38:39 +00:00
2015-03-09 21:43:39 +00:00
2017-01-11 21:07:15 +00:00
2015-10-22 19:57:19 +00:00
2015-10-22 19:57:38 +00:00
2016-12-19 08:22:17 +00:00
2015-10-30 15:02:28 +00:00
2016-05-29 00:32:17 +00:00
2016-12-19 08:22:17 +00:00
2016-05-25 13:01:33 +00:00
2017-05-22 06:46:04 +00:00
2015-01-22 00:48:47 +00:00
2016-05-29 00:34:42 +00:00
2011-06-19 00:03:46 +00:00
2017-02-14 15:53:12 +00:00
2016-10-21 20:05:21 +00:00
2015-03-13 18:20:45 +00:00
2015-02-24 01:02:42 +00:00
2015-02-27 21:17:42 +00:00
2015-03-13 18:31:19 +00:00
2017-01-18 23:56:42 +00:00
2015-11-02 02:06:01 +00:00
2016-05-29 00:32:17 +00:00
2016-08-09 20:40:03 +00:00
2016-04-08 14:29:09 +00:00
2015-03-09 21:43:43 +00:00
2016-07-11 02:48:23 +00:00
2016-02-20 04:01:45 +00:00
2016-02-09 00:07:08 +00:00
2016-05-03 17:49:57 +00:00
2016-08-09 20:37:50 +00:00
2015-02-25 20:02:59 +00:00
2016-09-14 04:39:50 +00:00
2016-08-25 16:17:18 +00:00
2016-08-25 16:17:18 +00:00
2013-03-26 03:14:53 +00:00
2015-02-27 21:17:42 +00:00
2017-01-31 00:42:42 +00:00
2015-03-09 21:43:39 +00:00
2015-02-27 21:17:42 +00:00
2015-03-13 18:20:45 +00:00
2017-03-23 18:06:09 +00:00
2016-03-03 18:31:23 +00:00
2017-03-23 18:06:09 +00:00
2015-10-28 21:27:14 +00:00
2015-02-27 21:17:42 +00:00
2016-08-05 18:34:14 +00:00
2013-08-05 23:43:18 +00:00
2015-02-27 19:29:02 +00:00
2015-02-27 19:29:02 +00:00
2015-11-19 05:56:52 +00:00
2015-02-27 21:17:42 +00:00
2016-08-05 20:33:49 +00:00
2015-02-27 21:17:42 +00:00
2015-02-27 21:17:42 +00:00
2013-08-05 23:43:18 +00:00
2013-11-06 02:08:26 +00:00
2013-05-31 16:42:41 +00:00
2015-03-09 21:43:39 +00:00
2015-02-27 21:17:42 +00:00
2016-10-21 11:08:48 +00:00
2016-10-21 11:08:48 +00:00
2017-05-22 06:46:04 +00:00
2014-02-11 15:44:32 +00:00
2016-09-16 14:38:13 +00:00
2016-06-09 01:13:59 +00:00
2017-03-20 20:25:46 +00:00
2017-09-01 14:59:59 +00:00
2017-05-03 23:53:38 +00:00
2015-04-16 23:24:18 +00:00
2017-03-16 21:07:38 +00:00