summaryrefslogtreecommitdiff
path: root/lib/Target/README.txt
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-12-12 23:23:43 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-12-12 23:23:43 +0000
commitbcae205a4bcd57689d9775752ece20fc3805c34a (patch)
tree92dd6310c755062f1f6e267bfccf78942ba1e37d /lib/Target/README.txt
parent15554733874838516215ae5eb01ca5313ec10b97 (diff)
downloadllvm-bcae205a4bcd57689d9775752ece20fc3805c34a.tar.gz
llvm-bcae205a4bcd57689d9775752ece20fc3805c34a.tar.bz2
llvm-bcae205a4bcd57689d9775752ece20fc3805c34a.tar.xz
More info on this transformation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91230 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/README.txt')
-rw-r--r--lib/Target/README.txt17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/Target/README.txt b/lib/Target/README.txt
index 2917f71869..e1772c2ead 100644
--- a/lib/Target/README.txt
+++ b/lib/Target/README.txt
@@ -801,8 +801,21 @@ void bar(unsigned n) {
true();
}
-I think this basically amounts to a dag combine to simplify comparisons against
-multiply hi's into a comparison against the mullo.
+This is equivalent to the following, where 2863311531 is the multiplicative
+inverse of 3, and 1431655766 is ((2^32)-1)/3+1:
+void bar(unsigned n) {
+ if (n * 2863311531U < 1431655766U)
+ true();
+}
+
+The same transformation can work with an even modulo with the addition of a
+rotate: rotate the result of the multiply to the right by the number of bits
+which need to be zero for the condition to be true, and shrink the compare RHS
+by the same amount. Unless the target supports rotates, though, that
+transformation probably isn't worthwhile.
+
+The transformation can also easily be made to work with non-zero equality
+comparisons: just transform, for example, "n % 3 == 1" to "(n-1) % 3 == 0".
//===---------------------------------------------------------------------===//