[llvm-commits] [llvm] r91230 - /llvm/trunk/lib/Target/README.txt
Eli Friedman
eli.friedman at gmail.com
Sat Dec 12 15:23:43 PST 2009
Author: efriedma
Date: Sat Dec 12 17:23:43 2009
New Revision: 91230
URL: http://llvm.org/viewvc/llvm-project?rev=91230&view=rev
Log:
More info on this transformation.
Modified:
llvm/trunk/lib/Target/README.txt
Modified: llvm/trunk/lib/Target/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=91230&r1=91229&r2=91230&view=diff
==============================================================================
--- llvm/trunk/lib/Target/README.txt (original)
+++ llvm/trunk/lib/Target/README.txt Sat Dec 12 17:23:43 2009
@@ -801,8 +801,21 @@
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".
//===---------------------------------------------------------------------===//
More information about the llvm-commits
mailing list