src/share/vm/opto/divnode.cpp

Thu, 05 Feb 2009 11:42:10 -0800

author
never
date
Thu, 05 Feb 2009 11:42:10 -0800
changeset 979
82a980778b92
parent 839
78c058bc5cdc
child 1002
bbef4344adb2
permissions
-rw-r--r--

6793828: G1: invariant: queues are empty when activated
Reviewed-by: jrose, kvn

duke@435 1 /*
xdono@631 2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 // Portions of code courtesy of Clifford Click
duke@435 26
duke@435 27 // Optimization - Graph Style
duke@435 28
duke@435 29 #include "incls/_precompiled.incl"
duke@435 30 #include "incls/_divnode.cpp.incl"
duke@435 31 #include <math.h>
duke@435 32
rasbold@580 33 //----------------------magic_int_divide_constants-----------------------------
rasbold@580 34 // Compute magic multiplier and shift constant for converting a 32 bit divide
rasbold@580 35 // by constant into a multiply/shift/add series. Return false if calculations
rasbold@580 36 // fail.
rasbold@580 37 //
rasbold@580 38 // Borrowed almost verbatum from Hacker's Delight by Henry S. Warren, Jr. with
rasbold@580 39 // minor type name and parameter changes.
rasbold@580 40 static bool magic_int_divide_constants(jint d, jint &M, jint &s) {
rasbold@580 41 int32_t p;
rasbold@580 42 uint32_t ad, anc, delta, q1, r1, q2, r2, t;
rasbold@580 43 const uint32_t two31 = 0x80000000L; // 2**31.
rasbold@580 44
rasbold@580 45 ad = ABS(d);
rasbold@580 46 if (d == 0 || d == 1) return false;
rasbold@580 47 t = two31 + ((uint32_t)d >> 31);
rasbold@580 48 anc = t - 1 - t%ad; // Absolute value of nc.
rasbold@580 49 p = 31; // Init. p.
rasbold@580 50 q1 = two31/anc; // Init. q1 = 2**p/|nc|.
rasbold@580 51 r1 = two31 - q1*anc; // Init. r1 = rem(2**p, |nc|).
rasbold@580 52 q2 = two31/ad; // Init. q2 = 2**p/|d|.
rasbold@580 53 r2 = two31 - q2*ad; // Init. r2 = rem(2**p, |d|).
rasbold@580 54 do {
rasbold@580 55 p = p + 1;
rasbold@580 56 q1 = 2*q1; // Update q1 = 2**p/|nc|.
rasbold@580 57 r1 = 2*r1; // Update r1 = rem(2**p, |nc|).
rasbold@580 58 if (r1 >= anc) { // (Must be an unsigned
rasbold@580 59 q1 = q1 + 1; // comparison here).
rasbold@580 60 r1 = r1 - anc;
rasbold@580 61 }
rasbold@580 62 q2 = 2*q2; // Update q2 = 2**p/|d|.
rasbold@580 63 r2 = 2*r2; // Update r2 = rem(2**p, |d|).
rasbold@580 64 if (r2 >= ad) { // (Must be an unsigned
rasbold@580 65 q2 = q2 + 1; // comparison here).
rasbold@580 66 r2 = r2 - ad;
rasbold@580 67 }
rasbold@580 68 delta = ad - r2;
rasbold@580 69 } while (q1 < delta || (q1 == delta && r1 == 0));
rasbold@580 70
rasbold@580 71 M = q2 + 1;
rasbold@580 72 if (d < 0) M = -M; // Magic number and
rasbold@580 73 s = p - 32; // shift amount to return.
rasbold@580 74
rasbold@580 75 return true;
rasbold@580 76 }
rasbold@580 77
rasbold@580 78 //--------------------------transform_int_divide-------------------------------
rasbold@580 79 // Convert a division by constant divisor into an alternate Ideal graph.
rasbold@580 80 // Return NULL if no transformation occurs.
rasbold@580 81 static Node *transform_int_divide( PhaseGVN *phase, Node *dividend, jint divisor ) {
duke@435 82
duke@435 83 // Check for invalid divisors
rasbold@580 84 assert( divisor != 0 && divisor != min_jint,
rasbold@580 85 "bad divisor for transforming to long multiply" );
duke@435 86
duke@435 87 bool d_pos = divisor >= 0;
rasbold@580 88 jint d = d_pos ? divisor : -divisor;
duke@435 89 const int N = 32;
duke@435 90
duke@435 91 // Result
rasbold@580 92 Node *q = NULL;
duke@435 93
duke@435 94 if (d == 1) {
rasbold@580 95 // division by +/- 1
rasbold@580 96 if (!d_pos) {
rasbold@580 97 // Just negate the value
duke@435 98 q = new (phase->C, 3) SubINode(phase->intcon(0), dividend);
duke@435 99 }
rasbold@580 100 } else if ( is_power_of_2(d) ) {
rasbold@580 101 // division by +/- a power of 2
duke@435 102
duke@435 103 // See if we can simply do a shift without rounding
duke@435 104 bool needs_rounding = true;
duke@435 105 const Type *dt = phase->type(dividend);
duke@435 106 const TypeInt *dti = dt->isa_int();
rasbold@580 107 if (dti && dti->_lo >= 0) {
rasbold@580 108 // we don't need to round a positive dividend
duke@435 109 needs_rounding = false;
rasbold@580 110 } else if( dividend->Opcode() == Op_AndI ) {
rasbold@580 111 // An AND mask of sufficient size clears the low bits and
rasbold@580 112 // I can avoid rounding.
kvn@835 113 const TypeInt *andconi_t = phase->type( dividend->in(2) )->isa_int();
kvn@835 114 if( andconi_t && andconi_t->is_con() ) {
kvn@835 115 jint andconi = andconi_t->get_con();
kvn@835 116 if( andconi < 0 && is_power_of_2(-andconi) && (-andconi) >= d ) {
kvn@835 117 dividend = dividend->in(1);
kvn@835 118 needs_rounding = false;
kvn@835 119 }
duke@435 120 }
duke@435 121 }
duke@435 122
duke@435 123 // Add rounding to the shift to handle the sign bit
rasbold@580 124 int l = log2_intptr(d-1)+1;
rasbold@580 125 if (needs_rounding) {
rasbold@580 126 // Divide-by-power-of-2 can be made into a shift, but you have to do
rasbold@580 127 // more math for the rounding. You need to add 0 for positive
rasbold@580 128 // numbers, and "i-1" for negative numbers. Example: i=4, so the
rasbold@580 129 // shift is by 2. You need to add 3 to negative dividends and 0 to
rasbold@580 130 // positive ones. So (-7+3)>>2 becomes -1, (-4+3)>>2 becomes -1,
rasbold@580 131 // (-2+3)>>2 becomes 0, etc.
rasbold@580 132
rasbold@580 133 // Compute 0 or -1, based on sign bit
rasbold@580 134 Node *sign = phase->transform(new (phase->C, 3) RShiftINode(dividend, phase->intcon(N - 1)));
rasbold@580 135 // Mask sign bit to the low sign bits
rasbold@580 136 Node *round = phase->transform(new (phase->C, 3) URShiftINode(sign, phase->intcon(N - l)));
rasbold@580 137 // Round up before shifting
rasbold@580 138 dividend = phase->transform(new (phase->C, 3) AddINode(dividend, round));
duke@435 139 }
duke@435 140
rasbold@580 141 // Shift for division
duke@435 142 q = new (phase->C, 3) RShiftINode(dividend, phase->intcon(l));
duke@435 143
rasbold@580 144 if (!d_pos) {
duke@435 145 q = new (phase->C, 3) SubINode(phase->intcon(0), phase->transform(q));
rasbold@580 146 }
rasbold@580 147 } else {
rasbold@580 148 // Attempt the jint constant divide -> multiply transform found in
rasbold@580 149 // "Division by Invariant Integers using Multiplication"
rasbold@580 150 // by Granlund and Montgomery
rasbold@580 151 // See also "Hacker's Delight", chapter 10 by Warren.
rasbold@580 152
rasbold@580 153 jint magic_const;
rasbold@580 154 jint shift_const;
rasbold@580 155 if (magic_int_divide_constants(d, magic_const, shift_const)) {
rasbold@580 156 Node *magic = phase->longcon(magic_const);
rasbold@580 157 Node *dividend_long = phase->transform(new (phase->C, 2) ConvI2LNode(dividend));
rasbold@580 158
rasbold@580 159 // Compute the high half of the dividend x magic multiplication
rasbold@580 160 Node *mul_hi = phase->transform(new (phase->C, 3) MulLNode(dividend_long, magic));
rasbold@580 161
rasbold@580 162 if (magic_const < 0) {
rasbold@580 163 mul_hi = phase->transform(new (phase->C, 3) RShiftLNode(mul_hi, phase->intcon(N)));
rasbold@580 164 mul_hi = phase->transform(new (phase->C, 2) ConvL2INode(mul_hi));
rasbold@580 165
rasbold@580 166 // The magic multiplier is too large for a 32 bit constant. We've adjusted
rasbold@580 167 // it down by 2^32, but have to add 1 dividend back in after the multiplication.
rasbold@580 168 // This handles the "overflow" case described by Granlund and Montgomery.
rasbold@580 169 mul_hi = phase->transform(new (phase->C, 3) AddINode(dividend, mul_hi));
rasbold@580 170
rasbold@580 171 // Shift over the (adjusted) mulhi
rasbold@580 172 if (shift_const != 0) {
rasbold@580 173 mul_hi = phase->transform(new (phase->C, 3) RShiftINode(mul_hi, phase->intcon(shift_const)));
rasbold@580 174 }
rasbold@580 175 } else {
rasbold@580 176 // No add is required, we can merge the shifts together.
rasbold@580 177 mul_hi = phase->transform(new (phase->C, 3) RShiftLNode(mul_hi, phase->intcon(N + shift_const)));
rasbold@580 178 mul_hi = phase->transform(new (phase->C, 2) ConvL2INode(mul_hi));
rasbold@580 179 }
rasbold@580 180
rasbold@580 181 // Get a 0 or -1 from the sign of the dividend.
rasbold@580 182 Node *addend0 = mul_hi;
rasbold@580 183 Node *addend1 = phase->transform(new (phase->C, 3) RShiftINode(dividend, phase->intcon(N-1)));
rasbold@580 184
rasbold@580 185 // If the divisor is negative, swap the order of the input addends;
rasbold@580 186 // this has the effect of negating the quotient.
rasbold@580 187 if (!d_pos) {
rasbold@580 188 Node *temp = addend0; addend0 = addend1; addend1 = temp;
rasbold@580 189 }
rasbold@580 190
rasbold@580 191 // Adjust the final quotient by subtracting -1 (adding 1)
rasbold@580 192 // from the mul_hi.
rasbold@580 193 q = new (phase->C, 3) SubINode(addend0, addend1);
rasbold@580 194 }
duke@435 195 }
duke@435 196
rasbold@580 197 return q;
rasbold@580 198 }
duke@435 199
rasbold@580 200 //---------------------magic_long_divide_constants-----------------------------
rasbold@580 201 // Compute magic multiplier and shift constant for converting a 64 bit divide
rasbold@580 202 // by constant into a multiply/shift/add series. Return false if calculations
rasbold@580 203 // fail.
rasbold@580 204 //
rasbold@580 205 // Borrowed almost verbatum from Hacker's Delight by Henry S. Warren, Jr. with
rasbold@580 206 // minor type name and parameter changes. Adjusted to 64 bit word width.
rasbold@580 207 static bool magic_long_divide_constants(jlong d, jlong &M, jint &s) {
rasbold@580 208 int64_t p;
rasbold@580 209 uint64_t ad, anc, delta, q1, r1, q2, r2, t;
rasbold@580 210 const uint64_t two63 = 0x8000000000000000LL; // 2**63.
rasbold@580 211
rasbold@580 212 ad = ABS(d);
rasbold@580 213 if (d == 0 || d == 1) return false;
rasbold@580 214 t = two63 + ((uint64_t)d >> 63);
rasbold@580 215 anc = t - 1 - t%ad; // Absolute value of nc.
rasbold@580 216 p = 63; // Init. p.
rasbold@580 217 q1 = two63/anc; // Init. q1 = 2**p/|nc|.
rasbold@580 218 r1 = two63 - q1*anc; // Init. r1 = rem(2**p, |nc|).
rasbold@580 219 q2 = two63/ad; // Init. q2 = 2**p/|d|.
rasbold@580 220 r2 = two63 - q2*ad; // Init. r2 = rem(2**p, |d|).
rasbold@580 221 do {
rasbold@580 222 p = p + 1;
rasbold@580 223 q1 = 2*q1; // Update q1 = 2**p/|nc|.
rasbold@580 224 r1 = 2*r1; // Update r1 = rem(2**p, |nc|).
rasbold@580 225 if (r1 >= anc) { // (Must be an unsigned
rasbold@580 226 q1 = q1 + 1; // comparison here).
rasbold@580 227 r1 = r1 - anc;
rasbold@580 228 }
rasbold@580 229 q2 = 2*q2; // Update q2 = 2**p/|d|.
rasbold@580 230 r2 = 2*r2; // Update r2 = rem(2**p, |d|).
rasbold@580 231 if (r2 >= ad) { // (Must be an unsigned
rasbold@580 232 q2 = q2 + 1; // comparison here).
rasbold@580 233 r2 = r2 - ad;
rasbold@580 234 }
rasbold@580 235 delta = ad - r2;
rasbold@580 236 } while (q1 < delta || (q1 == delta && r1 == 0));
rasbold@580 237
rasbold@580 238 M = q2 + 1;
rasbold@580 239 if (d < 0) M = -M; // Magic number and
rasbold@580 240 s = p - 64; // shift amount to return.
rasbold@580 241
rasbold@580 242 return true;
rasbold@580 243 }
rasbold@580 244
rasbold@580 245 //---------------------long_by_long_mulhi--------------------------------------
rasbold@580 246 // Generate ideal node graph for upper half of a 64 bit x 64 bit multiplication
rasbold@580 247 static Node *long_by_long_mulhi( PhaseGVN *phase, Node *dividend, jlong magic_const) {
rasbold@580 248 // If the architecture supports a 64x64 mulhi, there is
rasbold@580 249 // no need to synthesize it in ideal nodes.
rasbold@580 250 if (Matcher::has_match_rule(Op_MulHiL)) {
rasbold@580 251 Node *v = phase->longcon(magic_const);
rasbold@580 252 return new (phase->C, 3) MulHiLNode(dividend, v);
duke@435 253 }
duke@435 254
rasbold@580 255 const int N = 64;
duke@435 256
rasbold@580 257 Node *u_hi = phase->transform(new (phase->C, 3) RShiftLNode(dividend, phase->intcon(N / 2)));
rasbold@580 258 Node *u_lo = phase->transform(new (phase->C, 3) AndLNode(dividend, phase->longcon(0xFFFFFFFF)));
rasbold@580 259
rasbold@580 260 Node *v_hi = phase->longcon(magic_const >> N/2);
rasbold@580 261 Node *v_lo = phase->longcon(magic_const & 0XFFFFFFFF);
rasbold@580 262
rasbold@580 263 Node *hihi_product = phase->transform(new (phase->C, 3) MulLNode(u_hi, v_hi));
rasbold@580 264 Node *hilo_product = phase->transform(new (phase->C, 3) MulLNode(u_hi, v_lo));
rasbold@580 265 Node *lohi_product = phase->transform(new (phase->C, 3) MulLNode(u_lo, v_hi));
rasbold@580 266 Node *lolo_product = phase->transform(new (phase->C, 3) MulLNode(u_lo, v_lo));
rasbold@580 267
rasbold@580 268 Node *t1 = phase->transform(new (phase->C, 3) URShiftLNode(lolo_product, phase->intcon(N / 2)));
rasbold@580 269 Node *t2 = phase->transform(new (phase->C, 3) AddLNode(hilo_product, t1));
rasbold@729 270
rasbold@729 271 // Construct both t3 and t4 before transforming so t2 doesn't go dead
rasbold@729 272 // prematurely.
rasbold@729 273 Node *t3 = new (phase->C, 3) RShiftLNode(t2, phase->intcon(N / 2));
rasbold@729 274 Node *t4 = new (phase->C, 3) AndLNode(t2, phase->longcon(0xFFFFFFFF));
rasbold@729 275 t3 = phase->transform(t3);
rasbold@729 276 t4 = phase->transform(t4);
rasbold@729 277
rasbold@580 278 Node *t5 = phase->transform(new (phase->C, 3) AddLNode(t4, lohi_product));
rasbold@580 279 Node *t6 = phase->transform(new (phase->C, 3) RShiftLNode(t5, phase->intcon(N / 2)));
rasbold@580 280 Node *t7 = phase->transform(new (phase->C, 3) AddLNode(t3, hihi_product));
rasbold@580 281
rasbold@580 282 return new (phase->C, 3) AddLNode(t7, t6);
rasbold@580 283 }
rasbold@580 284
rasbold@580 285
rasbold@580 286 //--------------------------transform_long_divide------------------------------
rasbold@580 287 // Convert a division by constant divisor into an alternate Ideal graph.
rasbold@580 288 // Return NULL if no transformation occurs.
rasbold@580 289 static Node *transform_long_divide( PhaseGVN *phase, Node *dividend, jlong divisor ) {
rasbold@580 290 // Check for invalid divisors
rasbold@580 291 assert( divisor != 0L && divisor != min_jlong,
rasbold@580 292 "bad divisor for transforming to long multiply" );
rasbold@580 293
rasbold@580 294 bool d_pos = divisor >= 0;
rasbold@580 295 jlong d = d_pos ? divisor : -divisor;
rasbold@580 296 const int N = 64;
rasbold@580 297
rasbold@580 298 // Result
rasbold@580 299 Node *q = NULL;
rasbold@580 300
rasbold@580 301 if (d == 1) {
rasbold@580 302 // division by +/- 1
rasbold@580 303 if (!d_pos) {
rasbold@580 304 // Just negate the value
rasbold@580 305 q = new (phase->C, 3) SubLNode(phase->longcon(0), dividend);
rasbold@580 306 }
rasbold@580 307 } else if ( is_power_of_2_long(d) ) {
rasbold@580 308
rasbold@580 309 // division by +/- a power of 2
rasbold@580 310
rasbold@580 311 // See if we can simply do a shift without rounding
rasbold@580 312 bool needs_rounding = true;
rasbold@580 313 const Type *dt = phase->type(dividend);
rasbold@580 314 const TypeLong *dtl = dt->isa_long();
rasbold@580 315
rasbold@580 316 if (dtl && dtl->_lo > 0) {
rasbold@580 317 // we don't need to round a positive dividend
rasbold@580 318 needs_rounding = false;
rasbold@580 319 } else if( dividend->Opcode() == Op_AndL ) {
rasbold@580 320 // An AND mask of sufficient size clears the low bits and
rasbold@580 321 // I can avoid rounding.
kvn@835 322 const TypeLong *andconl_t = phase->type( dividend->in(2) )->isa_long();
kvn@835 323 if( andconl_t && andconl_t->is_con() ) {
kvn@835 324 jlong andconl = andconl_t->get_con();
kvn@835 325 if( andconl < 0 && is_power_of_2_long(-andconl) && (-andconl) >= d ) {
kvn@835 326 dividend = dividend->in(1);
kvn@835 327 needs_rounding = false;
kvn@835 328 }
rasbold@580 329 }
rasbold@580 330 }
rasbold@580 331
rasbold@580 332 // Add rounding to the shift to handle the sign bit
rasbold@580 333 int l = log2_long(d-1)+1;
rasbold@580 334 if (needs_rounding) {
rasbold@580 335 // Divide-by-power-of-2 can be made into a shift, but you have to do
rasbold@580 336 // more math for the rounding. You need to add 0 for positive
rasbold@580 337 // numbers, and "i-1" for negative numbers. Example: i=4, so the
rasbold@580 338 // shift is by 2. You need to add 3 to negative dividends and 0 to
rasbold@580 339 // positive ones. So (-7+3)>>2 becomes -1, (-4+3)>>2 becomes -1,
rasbold@580 340 // (-2+3)>>2 becomes 0, etc.
rasbold@580 341
rasbold@580 342 // Compute 0 or -1, based on sign bit
rasbold@580 343 Node *sign = phase->transform(new (phase->C, 3) RShiftLNode(dividend, phase->intcon(N - 1)));
rasbold@580 344 // Mask sign bit to the low sign bits
rasbold@580 345 Node *round = phase->transform(new (phase->C, 3) URShiftLNode(sign, phase->intcon(N - l)));
rasbold@580 346 // Round up before shifting
rasbold@580 347 dividend = phase->transform(new (phase->C, 3) AddLNode(dividend, round));
rasbold@580 348 }
rasbold@580 349
rasbold@580 350 // Shift for division
rasbold@580 351 q = new (phase->C, 3) RShiftLNode(dividend, phase->intcon(l));
rasbold@580 352
rasbold@580 353 if (!d_pos) {
rasbold@580 354 q = new (phase->C, 3) SubLNode(phase->longcon(0), phase->transform(q));
rasbold@580 355 }
rasbold@580 356 } else {
rasbold@580 357 // Attempt the jlong constant divide -> multiply transform found in
rasbold@580 358 // "Division by Invariant Integers using Multiplication"
rasbold@580 359 // by Granlund and Montgomery
rasbold@580 360 // See also "Hacker's Delight", chapter 10 by Warren.
rasbold@580 361
rasbold@580 362 jlong magic_const;
rasbold@580 363 jint shift_const;
rasbold@580 364 if (magic_long_divide_constants(d, magic_const, shift_const)) {
rasbold@580 365 // Compute the high half of the dividend x magic multiplication
rasbold@580 366 Node *mul_hi = phase->transform(long_by_long_mulhi(phase, dividend, magic_const));
rasbold@580 367
rasbold@580 368 // The high half of the 128-bit multiply is computed.
rasbold@580 369 if (magic_const < 0) {
rasbold@580 370 // The magic multiplier is too large for a 64 bit constant. We've adjusted
rasbold@580 371 // it down by 2^64, but have to add 1 dividend back in after the multiplication.
rasbold@580 372 // This handles the "overflow" case described by Granlund and Montgomery.
rasbold@580 373 mul_hi = phase->transform(new (phase->C, 3) AddLNode(dividend, mul_hi));
rasbold@580 374 }
rasbold@580 375
rasbold@580 376 // Shift over the (adjusted) mulhi
rasbold@580 377 if (shift_const != 0) {
rasbold@580 378 mul_hi = phase->transform(new (phase->C, 3) RShiftLNode(mul_hi, phase->intcon(shift_const)));
rasbold@580 379 }
rasbold@580 380
rasbold@580 381 // Get a 0 or -1 from the sign of the dividend.
rasbold@580 382 Node *addend0 = mul_hi;
rasbold@580 383 Node *addend1 = phase->transform(new (phase->C, 3) RShiftLNode(dividend, phase->intcon(N-1)));
rasbold@580 384
rasbold@580 385 // If the divisor is negative, swap the order of the input addends;
rasbold@580 386 // this has the effect of negating the quotient.
rasbold@580 387 if (!d_pos) {
rasbold@580 388 Node *temp = addend0; addend0 = addend1; addend1 = temp;
rasbold@580 389 }
rasbold@580 390
rasbold@580 391 // Adjust the final quotient by subtracting -1 (adding 1)
rasbold@580 392 // from the mul_hi.
rasbold@580 393 q = new (phase->C, 3) SubLNode(addend0, addend1);
rasbold@580 394 }
duke@435 395 }
duke@435 396
rasbold@580 397 return q;
duke@435 398 }
duke@435 399
duke@435 400 //=============================================================================
duke@435 401 //------------------------------Identity---------------------------------------
duke@435 402 // If the divisor is 1, we are an identity on the dividend.
duke@435 403 Node *DivINode::Identity( PhaseTransform *phase ) {
duke@435 404 return (phase->type( in(2) )->higher_equal(TypeInt::ONE)) ? in(1) : this;
duke@435 405 }
duke@435 406
duke@435 407 //------------------------------Idealize---------------------------------------
duke@435 408 // Divides can be changed to multiplies and/or shifts
duke@435 409 Node *DivINode::Ideal(PhaseGVN *phase, bool can_reshape) {
duke@435 410 if (in(0) && remove_dead_region(phase, can_reshape)) return this;
kvn@740 411 // Don't bother trying to transform a dead node
kvn@740 412 if( in(0) && in(0)->is_top() ) return NULL;
duke@435 413
duke@435 414 const Type *t = phase->type( in(2) );
duke@435 415 if( t == TypeInt::ONE ) // Identity?
duke@435 416 return NULL; // Skip it
duke@435 417
duke@435 418 const TypeInt *ti = t->isa_int();
duke@435 419 if( !ti ) return NULL;
duke@435 420 if( !ti->is_con() ) return NULL;
rasbold@580 421 jint i = ti->get_con(); // Get divisor
duke@435 422
duke@435 423 if (i == 0) return NULL; // Dividing by zero constant does not idealize
duke@435 424
duke@435 425 set_req(0,NULL); // Dividing by a not-zero constant; no faulting
duke@435 426
duke@435 427 // Dividing by MININT does not optimize as a power-of-2 shift.
duke@435 428 if( i == min_jint ) return NULL;
duke@435 429
rasbold@580 430 return transform_int_divide( phase, in(1), i );
duke@435 431 }
duke@435 432
duke@435 433 //------------------------------Value------------------------------------------
duke@435 434 // A DivINode divides its inputs. The third input is a Control input, used to
duke@435 435 // prevent hoisting the divide above an unsafe test.
duke@435 436 const Type *DivINode::Value( PhaseTransform *phase ) const {
duke@435 437 // Either input is TOP ==> the result is TOP
duke@435 438 const Type *t1 = phase->type( in(1) );
duke@435 439 const Type *t2 = phase->type( in(2) );
duke@435 440 if( t1 == Type::TOP ) return Type::TOP;
duke@435 441 if( t2 == Type::TOP ) return Type::TOP;
duke@435 442
duke@435 443 // x/x == 1 since we always generate the dynamic divisor check for 0.
duke@435 444 if( phase->eqv( in(1), in(2) ) )
duke@435 445 return TypeInt::ONE;
duke@435 446
duke@435 447 // Either input is BOTTOM ==> the result is the local BOTTOM
duke@435 448 const Type *bot = bottom_type();
duke@435 449 if( (t1 == bot) || (t2 == bot) ||
duke@435 450 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
duke@435 451 return bot;
duke@435 452
duke@435 453 // Divide the two numbers. We approximate.
duke@435 454 // If divisor is a constant and not zero
duke@435 455 const TypeInt *i1 = t1->is_int();
duke@435 456 const TypeInt *i2 = t2->is_int();
duke@435 457 int widen = MAX2(i1->_widen, i2->_widen);
duke@435 458
duke@435 459 if( i2->is_con() && i2->get_con() != 0 ) {
duke@435 460 int32 d = i2->get_con(); // Divisor
duke@435 461 jint lo, hi;
duke@435 462 if( d >= 0 ) {
duke@435 463 lo = i1->_lo/d;
duke@435 464 hi = i1->_hi/d;
duke@435 465 } else {
duke@435 466 if( d == -1 && i1->_lo == min_jint ) {
duke@435 467 // 'min_jint/-1' throws arithmetic exception during compilation
duke@435 468 lo = min_jint;
duke@435 469 // do not support holes, 'hi' must go to either min_jint or max_jint:
duke@435 470 // [min_jint, -10]/[-1,-1] ==> [min_jint] UNION [10,max_jint]
duke@435 471 hi = i1->_hi == min_jint ? min_jint : max_jint;
duke@435 472 } else {
duke@435 473 lo = i1->_hi/d;
duke@435 474 hi = i1->_lo/d;
duke@435 475 }
duke@435 476 }
duke@435 477 return TypeInt::make(lo, hi, widen);
duke@435 478 }
duke@435 479
duke@435 480 // If the dividend is a constant
duke@435 481 if( i1->is_con() ) {
duke@435 482 int32 d = i1->get_con();
duke@435 483 if( d < 0 ) {
duke@435 484 if( d == min_jint ) {
duke@435 485 // (-min_jint) == min_jint == (min_jint / -1)
duke@435 486 return TypeInt::make(min_jint, max_jint/2 + 1, widen);
duke@435 487 } else {
duke@435 488 return TypeInt::make(d, -d, widen);
duke@435 489 }
duke@435 490 }
duke@435 491 return TypeInt::make(-d, d, widen);
duke@435 492 }
duke@435 493
duke@435 494 // Otherwise we give up all hope
duke@435 495 return TypeInt::INT;
duke@435 496 }
duke@435 497
duke@435 498
duke@435 499 //=============================================================================
duke@435 500 //------------------------------Identity---------------------------------------
duke@435 501 // If the divisor is 1, we are an identity on the dividend.
duke@435 502 Node *DivLNode::Identity( PhaseTransform *phase ) {
duke@435 503 return (phase->type( in(2) )->higher_equal(TypeLong::ONE)) ? in(1) : this;
duke@435 504 }
duke@435 505
duke@435 506 //------------------------------Idealize---------------------------------------
duke@435 507 // Dividing by a power of 2 is a shift.
duke@435 508 Node *DivLNode::Ideal( PhaseGVN *phase, bool can_reshape) {
duke@435 509 if (in(0) && remove_dead_region(phase, can_reshape)) return this;
kvn@740 510 // Don't bother trying to transform a dead node
kvn@740 511 if( in(0) && in(0)->is_top() ) return NULL;
duke@435 512
duke@435 513 const Type *t = phase->type( in(2) );
rasbold@580 514 if( t == TypeLong::ONE ) // Identity?
duke@435 515 return NULL; // Skip it
duke@435 516
rasbold@580 517 const TypeLong *tl = t->isa_long();
rasbold@580 518 if( !tl ) return NULL;
rasbold@580 519 if( !tl->is_con() ) return NULL;
rasbold@580 520 jlong l = tl->get_con(); // Get divisor
rasbold@580 521
rasbold@580 522 if (l == 0) return NULL; // Dividing by zero constant does not idealize
rasbold@580 523
rasbold@580 524 set_req(0,NULL); // Dividing by a not-zero constant; no faulting
duke@435 525
duke@435 526 // Dividing by MININT does not optimize as a power-of-2 shift.
rasbold@580 527 if( l == min_jlong ) return NULL;
duke@435 528
rasbold@580 529 return transform_long_divide( phase, in(1), l );
duke@435 530 }
duke@435 531
duke@435 532 //------------------------------Value------------------------------------------
duke@435 533 // A DivLNode divides its inputs. The third input is a Control input, used to
duke@435 534 // prevent hoisting the divide above an unsafe test.
duke@435 535 const Type *DivLNode::Value( PhaseTransform *phase ) const {
duke@435 536 // Either input is TOP ==> the result is TOP
duke@435 537 const Type *t1 = phase->type( in(1) );
duke@435 538 const Type *t2 = phase->type( in(2) );
duke@435 539 if( t1 == Type::TOP ) return Type::TOP;
duke@435 540 if( t2 == Type::TOP ) return Type::TOP;
duke@435 541
duke@435 542 // x/x == 1 since we always generate the dynamic divisor check for 0.
duke@435 543 if( phase->eqv( in(1), in(2) ) )
duke@435 544 return TypeLong::ONE;
duke@435 545
duke@435 546 // Either input is BOTTOM ==> the result is the local BOTTOM
duke@435 547 const Type *bot = bottom_type();
duke@435 548 if( (t1 == bot) || (t2 == bot) ||
duke@435 549 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
duke@435 550 return bot;
duke@435 551
duke@435 552 // Divide the two numbers. We approximate.
duke@435 553 // If divisor is a constant and not zero
duke@435 554 const TypeLong *i1 = t1->is_long();
duke@435 555 const TypeLong *i2 = t2->is_long();
duke@435 556 int widen = MAX2(i1->_widen, i2->_widen);
duke@435 557
duke@435 558 if( i2->is_con() && i2->get_con() != 0 ) {
duke@435 559 jlong d = i2->get_con(); // Divisor
duke@435 560 jlong lo, hi;
duke@435 561 if( d >= 0 ) {
duke@435 562 lo = i1->_lo/d;
duke@435 563 hi = i1->_hi/d;
duke@435 564 } else {
duke@435 565 if( d == CONST64(-1) && i1->_lo == min_jlong ) {
duke@435 566 // 'min_jlong/-1' throws arithmetic exception during compilation
duke@435 567 lo = min_jlong;
duke@435 568 // do not support holes, 'hi' must go to either min_jlong or max_jlong:
duke@435 569 // [min_jlong, -10]/[-1,-1] ==> [min_jlong] UNION [10,max_jlong]
duke@435 570 hi = i1->_hi == min_jlong ? min_jlong : max_jlong;
duke@435 571 } else {
duke@435 572 lo = i1->_hi/d;
duke@435 573 hi = i1->_lo/d;
duke@435 574 }
duke@435 575 }
duke@435 576 return TypeLong::make(lo, hi, widen);
duke@435 577 }
duke@435 578
duke@435 579 // If the dividend is a constant
duke@435 580 if( i1->is_con() ) {
duke@435 581 jlong d = i1->get_con();
duke@435 582 if( d < 0 ) {
duke@435 583 if( d == min_jlong ) {
duke@435 584 // (-min_jlong) == min_jlong == (min_jlong / -1)
duke@435 585 return TypeLong::make(min_jlong, max_jlong/2 + 1, widen);
duke@435 586 } else {
duke@435 587 return TypeLong::make(d, -d, widen);
duke@435 588 }
duke@435 589 }
duke@435 590 return TypeLong::make(-d, d, widen);
duke@435 591 }
duke@435 592
duke@435 593 // Otherwise we give up all hope
duke@435 594 return TypeLong::LONG;
duke@435 595 }
duke@435 596
duke@435 597
duke@435 598 //=============================================================================
duke@435 599 //------------------------------Value------------------------------------------
duke@435 600 // An DivFNode divides its inputs. The third input is a Control input, used to
duke@435 601 // prevent hoisting the divide above an unsafe test.
duke@435 602 const Type *DivFNode::Value( PhaseTransform *phase ) const {
duke@435 603 // Either input is TOP ==> the result is TOP
duke@435 604 const Type *t1 = phase->type( in(1) );
duke@435 605 const Type *t2 = phase->type( in(2) );
duke@435 606 if( t1 == Type::TOP ) return Type::TOP;
duke@435 607 if( t2 == Type::TOP ) return Type::TOP;
duke@435 608
duke@435 609 // Either input is BOTTOM ==> the result is the local BOTTOM
duke@435 610 const Type *bot = bottom_type();
duke@435 611 if( (t1 == bot) || (t2 == bot) ||
duke@435 612 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
duke@435 613 return bot;
duke@435 614
duke@435 615 // x/x == 1, we ignore 0/0.
duke@435 616 // Note: if t1 and t2 are zero then result is NaN (JVMS page 213)
jrose@566 617 // Does not work for variables because of NaN's
duke@435 618 if( phase->eqv( in(1), in(2) ) && t1->base() == Type::FloatCon)
duke@435 619 if (!g_isnan(t1->getf()) && g_isfinite(t1->getf()) && t1->getf() != 0.0) // could be negative ZERO or NaN
duke@435 620 return TypeF::ONE;
duke@435 621
duke@435 622 if( t2 == TypeF::ONE )
duke@435 623 return t1;
duke@435 624
duke@435 625 // If divisor is a constant and not zero, divide them numbers
duke@435 626 if( t1->base() == Type::FloatCon &&
duke@435 627 t2->base() == Type::FloatCon &&
duke@435 628 t2->getf() != 0.0 ) // could be negative zero
duke@435 629 return TypeF::make( t1->getf()/t2->getf() );
duke@435 630
duke@435 631 // If the dividend is a constant zero
duke@435 632 // Note: if t1 and t2 are zero then result is NaN (JVMS page 213)
duke@435 633 // Test TypeF::ZERO is not sufficient as it could be negative zero
duke@435 634
duke@435 635 if( t1 == TypeF::ZERO && !g_isnan(t2->getf()) && t2->getf() != 0.0 )
duke@435 636 return TypeF::ZERO;
duke@435 637
duke@435 638 // Otherwise we give up all hope
duke@435 639 return Type::FLOAT;
duke@435 640 }
duke@435 641
duke@435 642 //------------------------------isA_Copy---------------------------------------
duke@435 643 // Dividing by self is 1.
duke@435 644 // If the divisor is 1, we are an identity on the dividend.
duke@435 645 Node *DivFNode::Identity( PhaseTransform *phase ) {
duke@435 646 return (phase->type( in(2) ) == TypeF::ONE) ? in(1) : this;
duke@435 647 }
duke@435 648
duke@435 649
duke@435 650 //------------------------------Idealize---------------------------------------
duke@435 651 Node *DivFNode::Ideal(PhaseGVN *phase, bool can_reshape) {
duke@435 652 if (in(0) && remove_dead_region(phase, can_reshape)) return this;
kvn@740 653 // Don't bother trying to transform a dead node
kvn@740 654 if( in(0) && in(0)->is_top() ) return NULL;
duke@435 655
duke@435 656 const Type *t2 = phase->type( in(2) );
duke@435 657 if( t2 == TypeF::ONE ) // Identity?
duke@435 658 return NULL; // Skip it
duke@435 659
duke@435 660 const TypeF *tf = t2->isa_float_constant();
duke@435 661 if( !tf ) return NULL;
duke@435 662 if( tf->base() != Type::FloatCon ) return NULL;
duke@435 663
duke@435 664 // Check for out of range values
duke@435 665 if( tf->is_nan() || !tf->is_finite() ) return NULL;
duke@435 666
duke@435 667 // Get the value
duke@435 668 float f = tf->getf();
duke@435 669 int exp;
duke@435 670
duke@435 671 // Only for special case of dividing by a power of 2
duke@435 672 if( frexp((double)f, &exp) != 0.5 ) return NULL;
duke@435 673
duke@435 674 // Limit the range of acceptable exponents
duke@435 675 if( exp < -126 || exp > 126 ) return NULL;
duke@435 676
duke@435 677 // Compute the reciprocal
duke@435 678 float reciprocal = ((float)1.0) / f;
duke@435 679
duke@435 680 assert( frexp((double)reciprocal, &exp) == 0.5, "reciprocal should be power of 2" );
duke@435 681
duke@435 682 // return multiplication by the reciprocal
duke@435 683 return (new (phase->C, 3) MulFNode(in(1), phase->makecon(TypeF::make(reciprocal))));
duke@435 684 }
duke@435 685
duke@435 686 //=============================================================================
duke@435 687 //------------------------------Value------------------------------------------
duke@435 688 // An DivDNode divides its inputs. The third input is a Control input, used to
jrose@566 689 // prevent hoisting the divide above an unsafe test.
duke@435 690 const Type *DivDNode::Value( PhaseTransform *phase ) const {
duke@435 691 // Either input is TOP ==> the result is TOP
duke@435 692 const Type *t1 = phase->type( in(1) );
duke@435 693 const Type *t2 = phase->type( in(2) );
duke@435 694 if( t1 == Type::TOP ) return Type::TOP;
duke@435 695 if( t2 == Type::TOP ) return Type::TOP;
duke@435 696
duke@435 697 // Either input is BOTTOM ==> the result is the local BOTTOM
duke@435 698 const Type *bot = bottom_type();
duke@435 699 if( (t1 == bot) || (t2 == bot) ||
duke@435 700 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
duke@435 701 return bot;
duke@435 702
duke@435 703 // x/x == 1, we ignore 0/0.
duke@435 704 // Note: if t1 and t2 are zero then result is NaN (JVMS page 213)
duke@435 705 // Does not work for variables because of NaN's
duke@435 706 if( phase->eqv( in(1), in(2) ) && t1->base() == Type::DoubleCon)
duke@435 707 if (!g_isnan(t1->getd()) && g_isfinite(t1->getd()) && t1->getd() != 0.0) // could be negative ZERO or NaN
duke@435 708 return TypeD::ONE;
duke@435 709
duke@435 710 if( t2 == TypeD::ONE )
duke@435 711 return t1;
duke@435 712
rasbold@839 713 #if defined(IA32)
rasbold@839 714 if (!phase->C->method()->is_strict())
rasbold@839 715 // Can't trust native compilers to properly fold strict double
rasbold@839 716 // division with round-to-zero on this platform.
rasbold@839 717 #endif
rasbold@839 718 {
rasbold@839 719 // If divisor is a constant and not zero, divide them numbers
rasbold@839 720 if( t1->base() == Type::DoubleCon &&
rasbold@839 721 t2->base() == Type::DoubleCon &&
rasbold@839 722 t2->getd() != 0.0 ) // could be negative zero
rasbold@839 723 return TypeD::make( t1->getd()/t2->getd() );
rasbold@839 724 }
duke@435 725
duke@435 726 // If the dividend is a constant zero
duke@435 727 // Note: if t1 and t2 are zero then result is NaN (JVMS page 213)
duke@435 728 // Test TypeF::ZERO is not sufficient as it could be negative zero
duke@435 729 if( t1 == TypeD::ZERO && !g_isnan(t2->getd()) && t2->getd() != 0.0 )
duke@435 730 return TypeD::ZERO;
duke@435 731
duke@435 732 // Otherwise we give up all hope
duke@435 733 return Type::DOUBLE;
duke@435 734 }
duke@435 735
duke@435 736
duke@435 737 //------------------------------isA_Copy---------------------------------------
duke@435 738 // Dividing by self is 1.
duke@435 739 // If the divisor is 1, we are an identity on the dividend.
duke@435 740 Node *DivDNode::Identity( PhaseTransform *phase ) {
duke@435 741 return (phase->type( in(2) ) == TypeD::ONE) ? in(1) : this;
duke@435 742 }
duke@435 743
duke@435 744 //------------------------------Idealize---------------------------------------
duke@435 745 Node *DivDNode::Ideal(PhaseGVN *phase, bool can_reshape) {
duke@435 746 if (in(0) && remove_dead_region(phase, can_reshape)) return this;
kvn@740 747 // Don't bother trying to transform a dead node
kvn@740 748 if( in(0) && in(0)->is_top() ) return NULL;
duke@435 749
duke@435 750 const Type *t2 = phase->type( in(2) );
duke@435 751 if( t2 == TypeD::ONE ) // Identity?
duke@435 752 return NULL; // Skip it
duke@435 753
duke@435 754 const TypeD *td = t2->isa_double_constant();
duke@435 755 if( !td ) return NULL;
duke@435 756 if( td->base() != Type::DoubleCon ) return NULL;
duke@435 757
duke@435 758 // Check for out of range values
duke@435 759 if( td->is_nan() || !td->is_finite() ) return NULL;
duke@435 760
duke@435 761 // Get the value
duke@435 762 double d = td->getd();
duke@435 763 int exp;
duke@435 764
duke@435 765 // Only for special case of dividing by a power of 2
duke@435 766 if( frexp(d, &exp) != 0.5 ) return NULL;
duke@435 767
duke@435 768 // Limit the range of acceptable exponents
duke@435 769 if( exp < -1021 || exp > 1022 ) return NULL;
duke@435 770
duke@435 771 // Compute the reciprocal
duke@435 772 double reciprocal = 1.0 / d;
duke@435 773
duke@435 774 assert( frexp(reciprocal, &exp) == 0.5, "reciprocal should be power of 2" );
duke@435 775
duke@435 776 // return multiplication by the reciprocal
duke@435 777 return (new (phase->C, 3) MulDNode(in(1), phase->makecon(TypeD::make(reciprocal))));
duke@435 778 }
duke@435 779
duke@435 780 //=============================================================================
duke@435 781 //------------------------------Idealize---------------------------------------
duke@435 782 Node *ModINode::Ideal(PhaseGVN *phase, bool can_reshape) {
duke@435 783 // Check for dead control input
kvn@740 784 if( in(0) && remove_dead_region(phase, can_reshape) ) return this;
kvn@740 785 // Don't bother trying to transform a dead node
kvn@740 786 if( in(0) && in(0)->is_top() ) return NULL;
duke@435 787
duke@435 788 // Get the modulus
duke@435 789 const Type *t = phase->type( in(2) );
duke@435 790 if( t == Type::TOP ) return NULL;
duke@435 791 const TypeInt *ti = t->is_int();
duke@435 792
duke@435 793 // Check for useless control input
duke@435 794 // Check for excluding mod-zero case
duke@435 795 if( in(0) && (ti->_hi < 0 || ti->_lo > 0) ) {
duke@435 796 set_req(0, NULL); // Yank control input
duke@435 797 return this;
duke@435 798 }
duke@435 799
duke@435 800 // See if we are MOD'ing by 2^k or 2^k-1.
duke@435 801 if( !ti->is_con() ) return NULL;
duke@435 802 jint con = ti->get_con();
duke@435 803
duke@435 804 Node *hook = new (phase->C, 1) Node(1);
duke@435 805
duke@435 806 // First, special check for modulo 2^k-1
duke@435 807 if( con >= 0 && con < max_jint && is_power_of_2(con+1) ) {
duke@435 808 uint k = exact_log2(con+1); // Extract k
duke@435 809
duke@435 810 // Basic algorithm by David Detlefs. See fastmod_int.java for gory details.
duke@435 811 static int unroll_factor[] = { 999, 999, 29, 14, 9, 7, 5, 4, 4, 3, 3, 2, 2, 2, 2, 2, 1 /*past here we assume 1 forever*/};
duke@435 812 int trip_count = 1;
duke@435 813 if( k < ARRAY_SIZE(unroll_factor)) trip_count = unroll_factor[k];
duke@435 814
duke@435 815 // If the unroll factor is not too large, and if conditional moves are
duke@435 816 // ok, then use this case
duke@435 817 if( trip_count <= 5 && ConditionalMoveLimit != 0 ) {
duke@435 818 Node *x = in(1); // Value being mod'd
duke@435 819 Node *divisor = in(2); // Also is mask
duke@435 820
duke@435 821 hook->init_req(0, x); // Add a use to x to prevent him from dying
duke@435 822 // Generate code to reduce X rapidly to nearly 2^k-1.
duke@435 823 for( int i = 0; i < trip_count; i++ ) {
rasbold@580 824 Node *xl = phase->transform( new (phase->C, 3) AndINode(x,divisor) );
rasbold@580 825 Node *xh = phase->transform( new (phase->C, 3) RShiftINode(x,phase->intcon(k)) ); // Must be signed
rasbold@580 826 x = phase->transform( new (phase->C, 3) AddINode(xh,xl) );
rasbold@580 827 hook->set_req(0, x);
duke@435 828 }
duke@435 829
duke@435 830 // Generate sign-fixup code. Was original value positive?
duke@435 831 // int hack_res = (i >= 0) ? divisor : 1;
duke@435 832 Node *cmp1 = phase->transform( new (phase->C, 3) CmpINode( in(1), phase->intcon(0) ) );
duke@435 833 Node *bol1 = phase->transform( new (phase->C, 2) BoolNode( cmp1, BoolTest::ge ) );
duke@435 834 Node *cmov1= phase->transform( new (phase->C, 4) CMoveINode(bol1, phase->intcon(1), divisor, TypeInt::POS) );
duke@435 835 // if( x >= hack_res ) x -= divisor;
duke@435 836 Node *sub = phase->transform( new (phase->C, 3) SubINode( x, divisor ) );
duke@435 837 Node *cmp2 = phase->transform( new (phase->C, 3) CmpINode( x, cmov1 ) );
duke@435 838 Node *bol2 = phase->transform( new (phase->C, 2) BoolNode( cmp2, BoolTest::ge ) );
duke@435 839 // Convention is to not transform the return value of an Ideal
duke@435 840 // since Ideal is expected to return a modified 'this' or a new node.
duke@435 841 Node *cmov2= new (phase->C, 4) CMoveINode(bol2, x, sub, TypeInt::INT);
duke@435 842 // cmov2 is now the mod
duke@435 843
duke@435 844 // Now remove the bogus extra edges used to keep things alive
duke@435 845 if (can_reshape) {
duke@435 846 phase->is_IterGVN()->remove_dead_node(hook);
duke@435 847 } else {
duke@435 848 hook->set_req(0, NULL); // Just yank bogus edge during Parse phase
duke@435 849 }
duke@435 850 return cmov2;
duke@435 851 }
duke@435 852 }
duke@435 853
duke@435 854 // Fell thru, the unroll case is not appropriate. Transform the modulo
duke@435 855 // into a long multiply/int multiply/subtract case
duke@435 856
duke@435 857 // Cannot handle mod 0, and min_jint isn't handled by the transform
duke@435 858 if( con == 0 || con == min_jint ) return NULL;
duke@435 859
duke@435 860 // Get the absolute value of the constant; at this point, we can use this
duke@435 861 jint pos_con = (con >= 0) ? con : -con;
duke@435 862
duke@435 863 // integer Mod 1 is always 0
duke@435 864 if( pos_con == 1 ) return new (phase->C, 1) ConINode(TypeInt::ZERO);
duke@435 865
duke@435 866 int log2_con = -1;
duke@435 867
duke@435 868 // If this is a power of two, they maybe we can mask it
duke@435 869 if( is_power_of_2(pos_con) ) {
duke@435 870 log2_con = log2_intptr((intptr_t)pos_con);
duke@435 871
duke@435 872 const Type *dt = phase->type(in(1));
duke@435 873 const TypeInt *dti = dt->isa_int();
duke@435 874
duke@435 875 // See if this can be masked, if the dividend is non-negative
duke@435 876 if( dti && dti->_lo >= 0 )
duke@435 877 return ( new (phase->C, 3) AndINode( in(1), phase->intcon( pos_con-1 ) ) );
duke@435 878 }
duke@435 879
duke@435 880 // Save in(1) so that it cannot be changed or deleted
duke@435 881 hook->init_req(0, in(1));
duke@435 882
duke@435 883 // Divide using the transform from DivI to MulL
rasbold@580 884 Node *result = transform_int_divide( phase, in(1), pos_con );
rasbold@580 885 if (result != NULL) {
rasbold@580 886 Node *divide = phase->transform(result);
duke@435 887
rasbold@580 888 // Re-multiply, using a shift if this is a power of two
rasbold@580 889 Node *mult = NULL;
duke@435 890
rasbold@580 891 if( log2_con >= 0 )
rasbold@580 892 mult = phase->transform( new (phase->C, 3) LShiftINode( divide, phase->intcon( log2_con ) ) );
rasbold@580 893 else
rasbold@580 894 mult = phase->transform( new (phase->C, 3) MulINode( divide, phase->intcon( pos_con ) ) );
duke@435 895
rasbold@580 896 // Finally, subtract the multiplied divided value from the original
rasbold@580 897 result = new (phase->C, 3) SubINode( in(1), mult );
rasbold@580 898 }
duke@435 899
duke@435 900 // Now remove the bogus extra edges used to keep things alive
duke@435 901 if (can_reshape) {
duke@435 902 phase->is_IterGVN()->remove_dead_node(hook);
duke@435 903 } else {
duke@435 904 hook->set_req(0, NULL); // Just yank bogus edge during Parse phase
duke@435 905 }
duke@435 906
duke@435 907 // return the value
duke@435 908 return result;
duke@435 909 }
duke@435 910
duke@435 911 //------------------------------Value------------------------------------------
duke@435 912 const Type *ModINode::Value( PhaseTransform *phase ) const {
duke@435 913 // Either input is TOP ==> the result is TOP
duke@435 914 const Type *t1 = phase->type( in(1) );
duke@435 915 const Type *t2 = phase->type( in(2) );
duke@435 916 if( t1 == Type::TOP ) return Type::TOP;
duke@435 917 if( t2 == Type::TOP ) return Type::TOP;
duke@435 918
duke@435 919 // We always generate the dynamic check for 0.
duke@435 920 // 0 MOD X is 0
duke@435 921 if( t1 == TypeInt::ZERO ) return TypeInt::ZERO;
duke@435 922 // X MOD X is 0
duke@435 923 if( phase->eqv( in(1), in(2) ) ) return TypeInt::ZERO;
duke@435 924
duke@435 925 // Either input is BOTTOM ==> the result is the local BOTTOM
duke@435 926 const Type *bot = bottom_type();
duke@435 927 if( (t1 == bot) || (t2 == bot) ||
duke@435 928 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
duke@435 929 return bot;
duke@435 930
duke@435 931 const TypeInt *i1 = t1->is_int();
duke@435 932 const TypeInt *i2 = t2->is_int();
duke@435 933 if( !i1->is_con() || !i2->is_con() ) {
duke@435 934 if( i1->_lo >= 0 && i2->_lo >= 0 )
duke@435 935 return TypeInt::POS;
duke@435 936 // If both numbers are not constants, we know little.
duke@435 937 return TypeInt::INT;
duke@435 938 }
duke@435 939 // Mod by zero? Throw exception at runtime!
duke@435 940 if( !i2->get_con() ) return TypeInt::POS;
duke@435 941
duke@435 942 // We must be modulo'ing 2 float constants.
duke@435 943 // Check for min_jint % '-1', result is defined to be '0'.
duke@435 944 if( i1->get_con() == min_jint && i2->get_con() == -1 )
duke@435 945 return TypeInt::ZERO;
duke@435 946
duke@435 947 return TypeInt::make( i1->get_con() % i2->get_con() );
duke@435 948 }
duke@435 949
duke@435 950
duke@435 951 //=============================================================================
duke@435 952 //------------------------------Idealize---------------------------------------
duke@435 953 Node *ModLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
duke@435 954 // Check for dead control input
kvn@740 955 if( in(0) && remove_dead_region(phase, can_reshape) ) return this;
kvn@740 956 // Don't bother trying to transform a dead node
kvn@740 957 if( in(0) && in(0)->is_top() ) return NULL;
duke@435 958
duke@435 959 // Get the modulus
duke@435 960 const Type *t = phase->type( in(2) );
duke@435 961 if( t == Type::TOP ) return NULL;
rasbold@580 962 const TypeLong *tl = t->is_long();
duke@435 963
duke@435 964 // Check for useless control input
duke@435 965 // Check for excluding mod-zero case
rasbold@580 966 if( in(0) && (tl->_hi < 0 || tl->_lo > 0) ) {
duke@435 967 set_req(0, NULL); // Yank control input
duke@435 968 return this;
duke@435 969 }
duke@435 970
duke@435 971 // See if we are MOD'ing by 2^k or 2^k-1.
rasbold@580 972 if( !tl->is_con() ) return NULL;
rasbold@580 973 jlong con = tl->get_con();
rasbold@580 974
rasbold@580 975 Node *hook = new (phase->C, 1) Node(1);
duke@435 976
duke@435 977 // Expand mod
rasbold@580 978 if( con >= 0 && con < max_jlong && is_power_of_2_long(con+1) ) {
rasbold@580 979 uint k = log2_long(con); // Extract k
rasbold@580 980
duke@435 981 // Basic algorithm by David Detlefs. See fastmod_long.java for gory details.
duke@435 982 // Used to help a popular random number generator which does a long-mod
duke@435 983 // of 2^31-1 and shows up in SpecJBB and SciMark.
duke@435 984 static int unroll_factor[] = { 999, 999, 61, 30, 20, 15, 12, 10, 8, 7, 6, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 /*past here we assume 1 forever*/};
duke@435 985 int trip_count = 1;
duke@435 986 if( k < ARRAY_SIZE(unroll_factor)) trip_count = unroll_factor[k];
duke@435 987
rasbold@580 988 // If the unroll factor is not too large, and if conditional moves are
rasbold@580 989 // ok, then use this case
rasbold@580 990 if( trip_count <= 5 && ConditionalMoveLimit != 0 ) {
rasbold@580 991 Node *x = in(1); // Value being mod'd
rasbold@580 992 Node *divisor = in(2); // Also is mask
duke@435 993
rasbold@580 994 hook->init_req(0, x); // Add a use to x to prevent him from dying
rasbold@580 995 // Generate code to reduce X rapidly to nearly 2^k-1.
rasbold@580 996 for( int i = 0; i < trip_count; i++ ) {
duke@435 997 Node *xl = phase->transform( new (phase->C, 3) AndLNode(x,divisor) );
duke@435 998 Node *xh = phase->transform( new (phase->C, 3) RShiftLNode(x,phase->intcon(k)) ); // Must be signed
duke@435 999 x = phase->transform( new (phase->C, 3) AddLNode(xh,xl) );
duke@435 1000 hook->set_req(0, x); // Add a use to x to prevent him from dying
rasbold@580 1001 }
rasbold@580 1002
rasbold@580 1003 // Generate sign-fixup code. Was original value positive?
rasbold@580 1004 // long hack_res = (i >= 0) ? divisor : CONST64(1);
rasbold@580 1005 Node *cmp1 = phase->transform( new (phase->C, 3) CmpLNode( in(1), phase->longcon(0) ) );
rasbold@580 1006 Node *bol1 = phase->transform( new (phase->C, 2) BoolNode( cmp1, BoolTest::ge ) );
rasbold@580 1007 Node *cmov1= phase->transform( new (phase->C, 4) CMoveLNode(bol1, phase->longcon(1), divisor, TypeLong::LONG) );
rasbold@580 1008 // if( x >= hack_res ) x -= divisor;
rasbold@580 1009 Node *sub = phase->transform( new (phase->C, 3) SubLNode( x, divisor ) );
rasbold@580 1010 Node *cmp2 = phase->transform( new (phase->C, 3) CmpLNode( x, cmov1 ) );
rasbold@580 1011 Node *bol2 = phase->transform( new (phase->C, 2) BoolNode( cmp2, BoolTest::ge ) );
rasbold@580 1012 // Convention is to not transform the return value of an Ideal
rasbold@580 1013 // since Ideal is expected to return a modified 'this' or a new node.
rasbold@580 1014 Node *cmov2= new (phase->C, 4) CMoveLNode(bol2, x, sub, TypeLong::LONG);
rasbold@580 1015 // cmov2 is now the mod
rasbold@580 1016
rasbold@580 1017 // Now remove the bogus extra edges used to keep things alive
rasbold@580 1018 if (can_reshape) {
rasbold@580 1019 phase->is_IterGVN()->remove_dead_node(hook);
rasbold@580 1020 } else {
rasbold@580 1021 hook->set_req(0, NULL); // Just yank bogus edge during Parse phase
rasbold@580 1022 }
rasbold@580 1023 return cmov2;
duke@435 1024 }
rasbold@580 1025 }
duke@435 1026
rasbold@580 1027 // Fell thru, the unroll case is not appropriate. Transform the modulo
rasbold@580 1028 // into a long multiply/int multiply/subtract case
rasbold@580 1029
rasbold@580 1030 // Cannot handle mod 0, and min_jint isn't handled by the transform
rasbold@580 1031 if( con == 0 || con == min_jlong ) return NULL;
rasbold@580 1032
rasbold@580 1033 // Get the absolute value of the constant; at this point, we can use this
rasbold@580 1034 jlong pos_con = (con >= 0) ? con : -con;
rasbold@580 1035
rasbold@580 1036 // integer Mod 1 is always 0
rasbold@580 1037 if( pos_con == 1 ) return new (phase->C, 1) ConLNode(TypeLong::ZERO);
rasbold@580 1038
rasbold@580 1039 int log2_con = -1;
rasbold@580 1040
rasbold@580 1041 // If this is a power of two, they maybe we can mask it
rasbold@580 1042 if( is_power_of_2_long(pos_con) ) {
rasbold@580 1043 log2_con = log2_long(pos_con);
rasbold@580 1044
rasbold@580 1045 const Type *dt = phase->type(in(1));
rasbold@580 1046 const TypeLong *dtl = dt->isa_long();
rasbold@580 1047
rasbold@580 1048 // See if this can be masked, if the dividend is non-negative
rasbold@580 1049 if( dtl && dtl->_lo >= 0 )
rasbold@580 1050 return ( new (phase->C, 3) AndLNode( in(1), phase->longcon( pos_con-1 ) ) );
duke@435 1051 }
rasbold@580 1052
rasbold@580 1053 // Save in(1) so that it cannot be changed or deleted
rasbold@580 1054 hook->init_req(0, in(1));
rasbold@580 1055
rasbold@580 1056 // Divide using the transform from DivI to MulL
rasbold@580 1057 Node *result = transform_long_divide( phase, in(1), pos_con );
rasbold@580 1058 if (result != NULL) {
rasbold@580 1059 Node *divide = phase->transform(result);
rasbold@580 1060
rasbold@580 1061 // Re-multiply, using a shift if this is a power of two
rasbold@580 1062 Node *mult = NULL;
rasbold@580 1063
rasbold@580 1064 if( log2_con >= 0 )
rasbold@580 1065 mult = phase->transform( new (phase->C, 3) LShiftLNode( divide, phase->intcon( log2_con ) ) );
rasbold@580 1066 else
rasbold@580 1067 mult = phase->transform( new (phase->C, 3) MulLNode( divide, phase->longcon( pos_con ) ) );
rasbold@580 1068
rasbold@580 1069 // Finally, subtract the multiplied divided value from the original
rasbold@580 1070 result = new (phase->C, 3) SubLNode( in(1), mult );
rasbold@580 1071 }
rasbold@580 1072
rasbold@580 1073 // Now remove the bogus extra edges used to keep things alive
rasbold@580 1074 if (can_reshape) {
rasbold@580 1075 phase->is_IterGVN()->remove_dead_node(hook);
rasbold@580 1076 } else {
rasbold@580 1077 hook->set_req(0, NULL); // Just yank bogus edge during Parse phase
rasbold@580 1078 }
rasbold@580 1079
rasbold@580 1080 // return the value
rasbold@580 1081 return result;
duke@435 1082 }
duke@435 1083
duke@435 1084 //------------------------------Value------------------------------------------
duke@435 1085 const Type *ModLNode::Value( PhaseTransform *phase ) const {
duke@435 1086 // Either input is TOP ==> the result is TOP
duke@435 1087 const Type *t1 = phase->type( in(1) );
duke@435 1088 const Type *t2 = phase->type( in(2) );
duke@435 1089 if( t1 == Type::TOP ) return Type::TOP;
duke@435 1090 if( t2 == Type::TOP ) return Type::TOP;
duke@435 1091
duke@435 1092 // We always generate the dynamic check for 0.
duke@435 1093 // 0 MOD X is 0
duke@435 1094 if( t1 == TypeLong::ZERO ) return TypeLong::ZERO;
duke@435 1095 // X MOD X is 0
duke@435 1096 if( phase->eqv( in(1), in(2) ) ) return TypeLong::ZERO;
duke@435 1097
duke@435 1098 // Either input is BOTTOM ==> the result is the local BOTTOM
duke@435 1099 const Type *bot = bottom_type();
duke@435 1100 if( (t1 == bot) || (t2 == bot) ||
duke@435 1101 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
duke@435 1102 return bot;
duke@435 1103
duke@435 1104 const TypeLong *i1 = t1->is_long();
duke@435 1105 const TypeLong *i2 = t2->is_long();
duke@435 1106 if( !i1->is_con() || !i2->is_con() ) {
duke@435 1107 if( i1->_lo >= CONST64(0) && i2->_lo >= CONST64(0) )
duke@435 1108 return TypeLong::POS;
duke@435 1109 // If both numbers are not constants, we know little.
duke@435 1110 return TypeLong::LONG;
duke@435 1111 }
duke@435 1112 // Mod by zero? Throw exception at runtime!
duke@435 1113 if( !i2->get_con() ) return TypeLong::POS;
duke@435 1114
duke@435 1115 // We must be modulo'ing 2 float constants.
duke@435 1116 // Check for min_jint % '-1', result is defined to be '0'.
duke@435 1117 if( i1->get_con() == min_jlong && i2->get_con() == -1 )
duke@435 1118 return TypeLong::ZERO;
duke@435 1119
duke@435 1120 return TypeLong::make( i1->get_con() % i2->get_con() );
duke@435 1121 }
duke@435 1122
duke@435 1123
duke@435 1124 //=============================================================================
duke@435 1125 //------------------------------Value------------------------------------------
duke@435 1126 const Type *ModFNode::Value( PhaseTransform *phase ) const {
duke@435 1127 // Either input is TOP ==> the result is TOP
duke@435 1128 const Type *t1 = phase->type( in(1) );
duke@435 1129 const Type *t2 = phase->type( in(2) );
duke@435 1130 if( t1 == Type::TOP ) return Type::TOP;
duke@435 1131 if( t2 == Type::TOP ) return Type::TOP;
duke@435 1132
duke@435 1133 // Either input is BOTTOM ==> the result is the local BOTTOM
duke@435 1134 const Type *bot = bottom_type();
duke@435 1135 if( (t1 == bot) || (t2 == bot) ||
duke@435 1136 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
duke@435 1137 return bot;
duke@435 1138
jrose@566 1139 // If either number is not a constant, we know nothing.
jrose@566 1140 if ((t1->base() != Type::FloatCon) || (t2->base() != Type::FloatCon)) {
jrose@566 1141 return Type::FLOAT; // note: x%x can be either NaN or 0
jrose@566 1142 }
jrose@566 1143
jrose@566 1144 float f1 = t1->getf();
jrose@566 1145 float f2 = t2->getf();
jrose@566 1146 jint x1 = jint_cast(f1); // note: *(int*)&f1, not just (int)f1
jrose@566 1147 jint x2 = jint_cast(f2);
jrose@566 1148
duke@435 1149 // If either is a NaN, return an input NaN
jrose@566 1150 if (g_isnan(f1)) return t1;
jrose@566 1151 if (g_isnan(f2)) return t2;
duke@435 1152
jrose@566 1153 // If an operand is infinity or the divisor is +/- zero, punt.
jrose@566 1154 if (!g_isfinite(f1) || !g_isfinite(f2) || x2 == 0 || x2 == min_jint)
duke@435 1155 return Type::FLOAT;
duke@435 1156
duke@435 1157 // We must be modulo'ing 2 float constants.
duke@435 1158 // Make sure that the sign of the fmod is equal to the sign of the dividend
jrose@566 1159 jint xr = jint_cast(fmod(f1, f2));
jrose@566 1160 if ((x1 ^ xr) < 0) {
jrose@566 1161 xr ^= min_jint;
duke@435 1162 }
jrose@566 1163
jrose@566 1164 return TypeF::make(jfloat_cast(xr));
duke@435 1165 }
duke@435 1166
duke@435 1167
duke@435 1168 //=============================================================================
duke@435 1169 //------------------------------Value------------------------------------------
duke@435 1170 const Type *ModDNode::Value( PhaseTransform *phase ) const {
duke@435 1171 // Either input is TOP ==> the result is TOP
duke@435 1172 const Type *t1 = phase->type( in(1) );
duke@435 1173 const Type *t2 = phase->type( in(2) );
duke@435 1174 if( t1 == Type::TOP ) return Type::TOP;
duke@435 1175 if( t2 == Type::TOP ) return Type::TOP;
duke@435 1176
duke@435 1177 // Either input is BOTTOM ==> the result is the local BOTTOM
duke@435 1178 const Type *bot = bottom_type();
duke@435 1179 if( (t1 == bot) || (t2 == bot) ||
duke@435 1180 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
duke@435 1181 return bot;
duke@435 1182
jrose@566 1183 // If either number is not a constant, we know nothing.
jrose@566 1184 if ((t1->base() != Type::DoubleCon) || (t2->base() != Type::DoubleCon)) {
jrose@566 1185 return Type::DOUBLE; // note: x%x can be either NaN or 0
duke@435 1186 }
duke@435 1187
jrose@566 1188 double f1 = t1->getd();
jrose@566 1189 double f2 = t2->getd();
jrose@566 1190 jlong x1 = jlong_cast(f1); // note: *(long*)&f1, not just (long)f1
jrose@566 1191 jlong x2 = jlong_cast(f2);
duke@435 1192
jrose@566 1193 // If either is a NaN, return an input NaN
jrose@566 1194 if (g_isnan(f1)) return t1;
jrose@566 1195 if (g_isnan(f2)) return t2;
duke@435 1196
jrose@566 1197 // If an operand is infinity or the divisor is +/- zero, punt.
jrose@566 1198 if (!g_isfinite(f1) || !g_isfinite(f2) || x2 == 0 || x2 == min_jlong)
duke@435 1199 return Type::DOUBLE;
duke@435 1200
duke@435 1201 // We must be modulo'ing 2 double constants.
jrose@566 1202 // Make sure that the sign of the fmod is equal to the sign of the dividend
jrose@566 1203 jlong xr = jlong_cast(fmod(f1, f2));
jrose@566 1204 if ((x1 ^ xr) < 0) {
jrose@566 1205 xr ^= min_jlong;
jrose@566 1206 }
jrose@566 1207
jrose@566 1208 return TypeD::make(jdouble_cast(xr));
duke@435 1209 }
duke@435 1210
duke@435 1211 //=============================================================================
duke@435 1212
duke@435 1213 DivModNode::DivModNode( Node *c, Node *dividend, Node *divisor ) : MultiNode(3) {
duke@435 1214 init_req(0, c);
duke@435 1215 init_req(1, dividend);
duke@435 1216 init_req(2, divisor);
duke@435 1217 }
duke@435 1218
duke@435 1219 //------------------------------make------------------------------------------
duke@435 1220 DivModINode* DivModINode::make(Compile* C, Node* div_or_mod) {
duke@435 1221 Node* n = div_or_mod;
duke@435 1222 assert(n->Opcode() == Op_DivI || n->Opcode() == Op_ModI,
duke@435 1223 "only div or mod input pattern accepted");
duke@435 1224
duke@435 1225 DivModINode* divmod = new (C, 3) DivModINode(n->in(0), n->in(1), n->in(2));
duke@435 1226 Node* dproj = new (C, 1) ProjNode(divmod, DivModNode::div_proj_num);
duke@435 1227 Node* mproj = new (C, 1) ProjNode(divmod, DivModNode::mod_proj_num);
duke@435 1228 return divmod;
duke@435 1229 }
duke@435 1230
duke@435 1231 //------------------------------make------------------------------------------
duke@435 1232 DivModLNode* DivModLNode::make(Compile* C, Node* div_or_mod) {
duke@435 1233 Node* n = div_or_mod;
duke@435 1234 assert(n->Opcode() == Op_DivL || n->Opcode() == Op_ModL,
duke@435 1235 "only div or mod input pattern accepted");
duke@435 1236
duke@435 1237 DivModLNode* divmod = new (C, 3) DivModLNode(n->in(0), n->in(1), n->in(2));
duke@435 1238 Node* dproj = new (C, 1) ProjNode(divmod, DivModNode::div_proj_num);
duke@435 1239 Node* mproj = new (C, 1) ProjNode(divmod, DivModNode::mod_proj_num);
duke@435 1240 return divmod;
duke@435 1241 }
duke@435 1242
duke@435 1243 //------------------------------match------------------------------------------
duke@435 1244 // return result(s) along with their RegMask info
duke@435 1245 Node *DivModINode::match( const ProjNode *proj, const Matcher *match ) {
duke@435 1246 uint ideal_reg = proj->ideal_reg();
duke@435 1247 RegMask rm;
duke@435 1248 if (proj->_con == div_proj_num) {
duke@435 1249 rm = match->divI_proj_mask();
duke@435 1250 } else {
duke@435 1251 assert(proj->_con == mod_proj_num, "must be div or mod projection");
duke@435 1252 rm = match->modI_proj_mask();
duke@435 1253 }
duke@435 1254 return new (match->C, 1)MachProjNode(this, proj->_con, rm, ideal_reg);
duke@435 1255 }
duke@435 1256
duke@435 1257
duke@435 1258 //------------------------------match------------------------------------------
duke@435 1259 // return result(s) along with their RegMask info
duke@435 1260 Node *DivModLNode::match( const ProjNode *proj, const Matcher *match ) {
duke@435 1261 uint ideal_reg = proj->ideal_reg();
duke@435 1262 RegMask rm;
duke@435 1263 if (proj->_con == div_proj_num) {
duke@435 1264 rm = match->divL_proj_mask();
duke@435 1265 } else {
duke@435 1266 assert(proj->_con == mod_proj_num, "must be div or mod projection");
duke@435 1267 rm = match->modL_proj_mask();
duke@435 1268 }
duke@435 1269 return new (match->C, 1)MachProjNode(this, proj->_con, rm, ideal_reg);
duke@435 1270 }

mercurial