2 REQUIRED_ARGS: -mcpu=native
3 PERMUTE_ARGS: -O -inline
6 import core.stdc.stdio;
45 printf("x == %d\n", x);
54 for (i = 0; i < 10; i++)
56 for (j = 0; j < 10; j++)
63 printf("i = %d, j = %d\n", i, j);
68 ///////////////////////
94 void teststringswitch()
98 printf("i = %d\n", i);
102 printf("i = %d\n", i);
106 printf("i = %d\n", i);
110 printf("i = %d\n", i);
115 ///////////////////////
147 ///////////////////////
149 align (1) struct Foo1
180 printf("%d\n", Foo1.sizeof);
181 assert(Foo1.a.offsetof == 0);
182 assert(Foo1.b.offsetof == 4);
183 assert(Foo1.c.offsetof == 5);
184 assert(Foo1.sizeof == 13);
186 assert(Foo2.a.offsetof == 0);
187 assert(Foo2.b.offsetof == 4);
188 assert(Foo2.c.offsetof == 8);
189 assert(Foo2.sizeof == 16);
191 assert(Foo3.a.offsetof == 0);
192 assert(Foo3.b.offsetof == 4);
193 assert(Foo3.c.offsetof == 8);
194 assert(Foo3.b.sizeof == 1);
195 assert(Foo3.sizeof == 16);
197 assert(Foo4.sizeof == 16);
200 ///////////////////////
202 size_t cond11565(size_t val)
204 return val ? size_t.max : 0;
209 assert(cond11565(true) == size_t.max);
212 ///////////////////////
214 int[3] array1 = [1:1,2,0:3];
218 assert(array1[0] == 3);
219 assert(array1[1] == 1);
220 assert(array1[2] == 2);
223 ///////////////////////
225 void test13023(ulong n)
227 static void func(bool b) {}
237 ///////////////////////
239 struct U { int a; union { char c; int d; } long b; }
241 U f = { b:3, d:2, a:1 };
249 assert(f.sizeof == 16);
250 assert(U.sizeof == 16);
254 ///////////////////////
258 __gshared ulong[4][] vectors =
264 [10_000_000_000L, 11_000_000_000L, 0, 10_000_000_000L],
265 [11_000_000_000L, 10_000_000_000L, 1, 1_000_000_000L],
266 [11_000_000_000L, 11_000_000_000L, 1, 0],
267 [10_000_000_000L, 10, 1_000_000_000L, 0],
268 [0x8000_0000_0000_0000, 0x8000_0000_0000_0000, 1, 0],
269 [0x8000_0000_0000_0001, 0x8000_0000_0000_0001, 1, 0],
270 [0x8000_0001_0000_0000, 0x8000_0001_0000_0000, 1, 0],
271 [0x8000_0001_0000_0000, 0x8000_0000_0000_0000, 1, 0x1_0000_0000],
272 [0x8000_0001_0000_0000, 0x8000_0000_8000_0000, 1, 0x8000_0000],
273 [0x8000_0000_0000_0000, 0x7FFF_FFFF_FFFF_FFFF, 1, 1],
274 [0x8000_0000_0000_0000, 0x8000_0000_0000_0001, 0, 0x8000_0000_0000_0000],
275 [0x8000_0000_0000_0000, 0x8000_0001_0000_0000, 0, 0x8000_0000_0000_0000],
278 for (size_t i = 0; i < vectors.length; i++)
280 ulong q = vectors[i][0] / vectors[i][1];
281 if (q != vectors[i][2])
282 printf("[%d] %lld / %lld = %lld, should be %lld\n",
283 vectors[i][0], vectors[i][1], q, vectors[i][2]);
285 ulong r = vectors[i][0] % vectors[i][1];
286 if (r != vectors[i][3])
287 printf("[%d] %lld %% %lld = %lld, should be %lld\n",
288 i, vectors[i][0], vectors[i][1], r, vectors[i][3]);
292 ////////////////////////////////////////////////////////////////////////
305 uint udiv14007(uint x)
320 uint umod14007(uint x)
325 uint uremquo10(uint x)
327 return (x / 10) | (x % 10);
330 uint uremquo14(uint x)
332 return (x / 14) | (x % 14);
335 uint uremquo14007(uint x)
337 return (x / 14007) | (x % 14007);
342 ulong uldiv10(ulong x)
347 ulong uldiv14(ulong x)
352 ulong uldiv14007(ulong x)
357 ulong ulmod10(ulong x)
362 ulong ulmod14(ulong x)
367 ulong ulmod14007(ulong x)
372 ulong ulremquo10(ulong x)
374 return (x / 10) | (x % 10);
377 ulong ulremquo14(ulong x)
379 return (x / 14) | (x % 14);
382 ulong ulremquo14007(ulong x)
384 return (x / 14007) | (x % 14007);
391 static uint x10 = 10;
392 static uint x14 = 14;
393 static uint x14007 = 14007;
397 r = udiv10(u); assert(r == u/x10);
398 r = udiv14(u); assert(r == u/x14);
399 r = udiv14007(u); assert(r == u/x14007);
400 r = umod10(u); assert(r == u%x10);
401 r = umod14(u); assert(r == u%x14);
402 r = umod14007(u); assert(r == u%x14007);
403 r = uremquo10(u); assert(r == ((u/10)|(u%x10)));
404 r = uremquo14(u); assert(r == ((u/14)|(u%x14)));
405 r = uremquo14007(u); assert(r == ((u/14007)|(u%x14007)));
408 static ulong y10 = 10;
409 static ulong y14 = 14;
410 static ulong y14007 = 14007;
414 r = uldiv10(u); assert(r == u/y10);
415 r = uldiv14(u); assert(r == u/y14);
416 r = uldiv14007(u); assert(r == u/y14007);
417 r = ulmod10(u); assert(r == u%y10);
418 r = ulmod14(u); assert(r == u%y14);
419 r = ulmod14007(u); assert(r == u%y14007);
420 r = ulremquo10(u); assert(r == ((u/10)|(u%y10)));
421 r = ulremquo14(u); assert(r == ((u/14)|(u%y14)));
422 r = ulremquo14007(u); assert(r == ((u/14007)|(u%y14007)));
427 ////////////////////////////////////////////////////////////////////////
431 void test12095(int k)
434 e ? k || assert(0) : !e || vfunc();
435 e ? k || assert(0) : e && vfunc();
436 !e ? !e || vfunc() : k || assert(0);
440 ////////////////////////////////////////////////////////////////////////
443 bool test3918a( float t, real u )
449 bool test3918b( real t, float u )
457 assert(test3918a(float.nan, real.nan));
458 assert(test3918b(real.nan, float.nan));
461 ////////////////////////////////////////////////////////////////////////
496 return (x / 10) | (x % 10);
501 return (x / 14) | (x % 14);
504 int remquo14007(int x)
506 return (x / 14007) | (x % 14007);
543 return (x / -10) | (x % -10);
548 return (x / -14) | (x % -14);
551 int mremquo14007(int x)
553 return (x / -14007) | (x % -14007);
569 long ldiv14007(long x)
584 long lmod14007(long x)
589 long lremquo10(long x)
591 return (x / 10) | (x % 10);
594 long lremquo14(long x)
596 return (x / 14) | (x % 14);
599 long lremquo14007(long x)
601 return (x / 14007) | (x % 14007);
618 long mldiv14007(long x)
633 long mlmod14007(long x)
638 long mlremquo10(long x)
640 return (x / -10) | (x % -10);
643 long mlremquo14(long x)
645 return (x / -14) | (x % -14);
648 long mlremquo14007(long x)
650 return (x / -14007) | (x % -14007);
660 static int x14007 = 14007;
664 r = div10(u); assert(r == u/x10);
665 r = div14(u); assert(r == u/x14);
666 r = div14007(u); assert(r == u/x14007);
667 r = mod10(u); assert(r == u%x10);
668 r = mod14(u); assert(r == u%x14);
669 r = mod14007(u); assert(r == u%x14007);
670 r = remquo10(u); assert(r == ((u/x10)|(u%x10)));
671 r = remquo14(u); assert(r == ((u/x14)|(u%x14)));
672 r = remquo14007(u); assert(r == ((u/x14007)|(u%x14007)));
675 static int t10 = -10;
676 static int t14 = -14;
677 static int t14007 = -14007;
681 r = mdiv10(u); assert(r == u/t10);
682 r = mdiv14(u); assert(r == u/t14);
683 r = mdiv14007(u); assert(r == u/t14007);
684 r = mmod10(u); assert(r == u%t10);
685 r = mmod14(u); assert(r == u%t14);
686 r = mmod14007(u); assert(r == u%t14007);
687 r = mremquo10(u); assert(r == ((u/t10)|(u%t10)));
688 r = mremquo14(u); assert(r == ((u/t14)|(u%t14)));
689 r = mremquo14007(u); assert(r == ((u/t14007)|(u%t14007)));
692 static long y10 = 10;
693 static long y14 = 14;
694 static long y14007 = 14007;
698 r = ldiv10(u); assert(r == u/y10);
699 r = ldiv14(u); assert(r == u/y14);
700 r = ldiv14007(u); assert(r == u/y14007);
701 r = lmod10(u); assert(r == u%y10);
702 r = lmod14(u); assert(r == u%y14);
703 r = lmod14007(u); assert(r == u%y14007);
704 r = lremquo10(u); assert(r == ((u/y10)|(u%y10)));
705 r = lremquo14(u); assert(r == ((u/y14)|(u%y14)));
706 r = lremquo14007(u); assert(r == ((u/y14007)|(u%y14007)));
709 static long z10 = -10;
710 static long z14 = -14;
711 static long z14007 = -14007;
715 r = mldiv10(u); assert(r == u/z10);
716 r = mldiv14(u); assert(r == u/z14);
717 r = mldiv14007(u); assert(r == u/z14007);
718 r = mlmod10(u); assert(r == u%z10);
719 r = mlmod14(u); assert(r == u%z14);
720 r = mlmod14007(u); assert(r == u%z14007);
721 r = mlremquo10(u); assert(r == ((u/z10)|(u%z10)));
722 r = mlremquo14(u); assert(r == ((u/z14)|(u%z14)));
723 r = mlremquo14007(u); assert(r == ((u/z14007)|(u%z14007)));
727 ////////////////////////////////////////////////////////////////////////
730 T docond1(T)(T l, ubyte thresh, ubyte val) {
735 T docond2(T)(T l, ubyte thresh, ubyte val) {
736 l -= (thresh >= val);
740 T docond3(T)(T l, ubyte thresh, ubyte val) {
741 l += (thresh >= val);
745 T docond4(T)(T l, ubyte thresh, ubyte val) {
752 assert(docond1!ubyte(10,3,5) == 11);
753 assert(docond1!ushort(10,3,5) == 11);
754 assert(docond1!uint(10,3,5) == 11);
755 assert(docond1!ulong(10,3,5) == 11);
757 assert(docond2!ubyte(10,3,5) == 10);
758 assert(docond2!ushort(10,3,5) == 10);
759 assert(docond2!uint(10,3,5) == 10);
760 assert(docond2!ulong(10,3,5) == 10);
762 assert(docond3!ubyte(10,3,5) == 10);
763 assert(docond3!ushort(10,3,5) == 10);
764 assert(docond3!uint(10,3,5) == 10);
765 assert(docond3!ulong(10,3,5) == 10);
767 assert(docond4!ubyte(10,3,5) == 9);
768 assert(docond4!ushort(10,3,5) == 9);
769 assert(docond4!uint(10,3,5) == 9);
770 assert(docond4!ulong(10,3,5) == 9);
773 assert(docond1!ubyte(10,5,3) == 10);
774 assert(docond1!ushort(10,5,3) == 10);
775 assert(docond1!uint(10,5,3) == 10);
776 assert(docond1!ulong(10,5,3) == 10);
778 assert(docond2!ubyte(10,5,3) == 9);
779 assert(docond2!ushort(10,5,3) == 9);
780 assert(docond2!uint(10,5,3) == 9);
781 assert(docond2!ulong(10,5,3) == 9);
783 assert(docond3!ubyte(10,5,3) == 11);
784 assert(docond3!ushort(10,5,3) == 11);
785 assert(docond3!uint(10,5,3) == 11);
786 assert(docond3!ulong(10,5,3) == 11);
788 assert(docond4!ubyte(10,5,3) == 10);
789 assert(docond4!ushort(10,5,3) == 10);
790 assert(docond4!uint(10,5,3) == 10);
791 assert(docond4!ulong(10,5,3) == 10);
794 ////////////////////////////////////////////////////////////////////////
801 void foo8658(S8658 s)
809 for(int i = 0; i < 1000; i++)
813 ////////////////////////////////////////////////////////////////////////
837 assert(neg(3) == -3);
838 assert(com(3) == -4);
839 assert(com(3.0f) == -4.0f);
840 assert(com2(3) == -4);
843 ////////////////////////////////////////////////////////////////////////
847 return ((((((((((cast(int) c <= 32 || cast(int) c == 46) || cast(int) c == 44)
848 || cast(int) c == 58) || cast(int) c == 59) || cast(int) c == 60)
849 || cast(int) c == 62) || cast(int) c == 34) || cast(int) c == 92)
850 || cast(int) c == 39) != 0);
855 return ((((((((((c <= 32 || c == 46) || c == 44)
856 || c == 58) || c == 59) || c == 60)
857 || c == 62) || c == 34) || c == 92)
863 assert(oror1(0) == 1);
864 assert(oror1(32) == 1);
865 assert(oror1(46) == 1);
866 assert(oror1(44) == 1);
867 assert(oror1(58) == 1);
868 assert(oror1(59) == 1);
869 assert(oror1(60) == 1);
870 assert(oror1(62) == 1);
871 assert(oror1(34) == 1);
872 assert(oror1(92) == 1);
873 assert(oror1(39) == 1);
874 assert(oror1(33) == 0);
875 assert(oror1(61) == 0);
876 assert(oror1(93) == 0);
877 assert(oror1(255) == 0);
879 assert(oror2(0) == 1);
880 assert(oror2(32) == 1);
881 assert(oror2(46) == 1);
882 assert(oror2(44) == 1);
883 assert(oror2(58) == 1);
884 assert(oror2(59) == 1);
885 assert(oror2(60) == 1);
886 assert(oror2(62) == 1);
887 assert(oror2(34) == 1);
888 assert(oror2(92) == 1);
889 assert(oror2(39) == 1);
890 assert(oror2(33) == 0);
891 assert(oror2(61) == 0);
892 assert(oror2(93) == 0);
893 assert(oror2(255) == 0);
896 ////////////////////////////////////////////////////////////////////////
898 bool bt1(int p, int a, int b)
900 return p && ((1 << b) & a);
903 bool bt2(int p, long a, long b)
905 return p && ((1L << b) & a);
910 assert(bt1(1,7,2) == 1);
911 assert(bt1(1,7,3) == 0);
913 assert(bt2(1,0x7_0000_0000,2+32) == 1);
914 assert(bt2(1,0x7_0000_0000,3+32) == 0);
917 ////////////////////////////////////////////////////////////////////////
930 ////////////////////////////////////////////////////////////////////////
934 return (c > 32 && c != 46 && c != 44
935 && c != 58 && c != 59
936 && c != 60 && c != 62
937 && c != 34 && c != 92
943 return (c > 32 && c != 46 && c != 44
944 && c != 58 && c != 59
945 && c != 60 && c != 62
946 && c != 34 && c != 92
950 int foox3() { return 1; }
967 assert(andand1(0) == 0);
968 assert(andand1(32) == 0);
969 assert(andand1(46) == 0);
970 assert(andand1(44) == 0);
971 assert(andand1(58) == 0);
972 assert(andand1(59) == 0);
973 assert(andand1(60) == 0);
974 assert(andand1(62) == 0);
975 assert(andand1(34) == 0);
976 assert(andand1(92) == 0);
977 assert(andand1(39) == 0);
978 assert(andand1(33) == 1);
979 assert(andand1(61) == 1);
980 assert(andand1(93) == 1);
981 assert(andand1(255) == 1);
983 assert(andand2(0) == false);
984 assert(andand2(32) == false);
985 assert(andand2(46) == false);
986 assert(andand2(44) == false);
987 assert(andand2(58) == false);
988 assert(andand2(59) == false);
989 assert(andand2(60) == false);
990 assert(andand2(62) == false);
991 assert(andand2(34) == false);
992 assert(andand2(92) == false);
993 assert(andand2(39) == false);
994 assert(andand2(33) == true);
995 assert(andand2(61) == true);
996 assert(andand2(93) == true);
997 assert(andand2(255) == true);
999 assert(andand3(6) == 3);
1000 assert(andand3(30) == 4);
1003 ////////////////////////////////////////////////////////////////////////
1005 bool bittest11508(char c)
1007 return c=='_' || c=='-' || c=='+' || c=='.';
1012 assert(bittest11508('_'));
1015 ////////////////////////////////////////////////////////////////////////
1019 return x | (x<<8) | (x<<16) | (x<<24) | (x * 3);
1022 void testor_combine()
1024 printf("%x\n", or1(1));
1025 assert(or1(5) == 5 * (0x1010101 | 3));
1028 ////////////////////////////////////////////////////////////////////////
1032 return ((i+1)>>1)<<1;
1037 assert(shrshl(6) == 6);
1038 assert(shrshl(7) == 8);
1041 ////////////////////////////////////////////////////////////////////////
1048 void formatTest(S1 s, double re, double im)
1050 assert(s.val.re == re);
1051 assert(s.val.im == im);
1057 formatTest(s, 3, 2.25);
1060 ////////////////////////////////////////////////////////////////////////
1062 bool bt10715(in uint[] ary, size_t bitnum)
1064 return !!(ary[bitnum >> 5] & 1 << (bitnum & 31)); // uses bt
1067 bool neg_bt10715(in uint[] ary, size_t bitnum)
1069 return !(ary[bitnum >> 5] & 1 << (bitnum & 31)); // does not use bt
1074 static uint[2] a1 = [0x1001_1100, 0x0220_0012];
1076 if ( bt10715(a1,30)) assert(0);
1077 if (!bt10715(a1,8)) assert(0);
1078 if ( bt10715(a1,30+32)) assert(0);
1079 if (!bt10715(a1,1+32)) assert(0);
1081 if (!neg_bt10715(a1,30)) assert(0);
1082 if ( neg_bt10715(a1,8)) assert(0);
1083 if (!neg_bt10715(a1,30+32)) assert(0);
1084 if ( neg_bt10715(a1,1+32)) assert(0);
1087 ////////////////////////////////////////////////////////////////////////
1089 ptrdiff_t compare12164(A12164* rhsPA, A12164* zis)
1093 return ptrdiff_t.min;
1105 assert(compare12164(&a, &b));
1108 ////////////////////////////////////////////////////////////////////////
1110 int foo10678(char[5] txt)
1112 return txt[0] + txt[1] + txt[4];
1117 char[5] hello = void;
1121 int i = foo10678(hello);
1125 ////////////////////////////////////////////////////////////////////////
1131 assert(c == 'P' || c == 'M');
1140 S12051(i < ip.length ? 'P' : 'M');
1144 ////////////////////////////////////////////////////////////////////////
1146 void bug7565( double x) { assert(x == 3); }
1155 ////////////////////////////////////////////////////////////////////////
1157 int bug8525(int[] devt)
1162 ////////////////////////////////////////////////////////////////////////
1164 void func13190(int) {}
1172 __gshared Struct13190* table13190 =
1180 for (int i = 0; table13190[i].a; i++)
1182 ulong tbl = table13190[i].a;
1192 ////////////////////////////////////////////////////////////////////////
1194 double foo13485(double c, double d)
1196 // This must not be optimized to c += (d + d)
1204 enum double d = 0X1P+1023;
1205 assert(foo13485(-d, d) == d);
1208 ////////////////////////////////////////////////////////////////////////
1210 void test12833a(int a)
1212 long x = cast(long)a;
1214 switch (cast(int)(cast(ushort)(x >> 16 & 65535L)))
1229 test12833a(0x1_0000);
1232 /***********************************************/
1243 if (arr[0].f != 3.0) assert(0);
1244 if (arr[0].g != 4.0) assert(0);
1247 ////////////////////////////////////////////////////////////////////////
1248 // https://issues.dlang.org/show_bug.cgi?id=12057
1250 bool prop12057(real x) { return false; }
1251 double f12057(real) { return double.init; }
1254 real fc = f12057(real.init);
1255 if (fc == 0 || fc.prop12057) {}
1259 ////////////////////////////////////////////////////////////////////////
1261 long modulo24 (long ticks)
1263 ticks %= 864000000000;
1265 ticks += 864000000000;
1271 assert (modulo24(-141600000000) == 722400000000);
1275 ////////////////////////////////////////////////////////////////////////
1281 int test13969(const S13969* f) {
1282 return 0 % ((f.y > 0) ? f.x / f.y : f.x / -f.y);
1285 ////////////////////////////////////////////////////////////////////////
1290 assert(arr14436 == null);
1291 arr14436 = [1, 2, 3];
1292 assert(arr14436 != null);
1295 ////////////////////////////////////////////////////////////////////////
1299 auto a = toString(14);
1301 printf("a.ptr = %p, a.length = %d\n", a.ptr, cast(int)a.length);
1305 auto toString(int value)
1307 uint mValue = value;
1309 char[int.sizeof * 3] buffer = void;
1310 size_t index = buffer.length;
1314 uint div = cast(int)(mValue / 10);
1315 char mod = mValue % 10 + '0';
1316 buffer[--index] = mod; // Line 22
1320 //printf("buffer.ptr = %p, index = %d\n", buffer.ptr, cast(int)index);
1321 return dup(buffer[index .. $]);
1324 char[] dup(char[] a)
1326 //printf("a.ptr = %p, a.length = %d\n", a.ptr, cast(int)a.length);
1327 a[0] = 1; // segfault
1331 ////////////////////////////////////////////////////////////////////////
1333 int stripLeft(int str, int dc)
1346 if (stripLeft(3, 1) != 3) // fails with -O
1351 ////////////////////////////////////////////////////////////////////////
1355 void test(cdouble v)
1357 auto x2 = cdouble(v);
1363 ////////////////////////////////////////////////////////////////////////
1370 b = (b.ptr + b.length - 5)[0 .. b.ptr + b.length - 1 - a.ptr];
1371 assert(b.ptr == a.ptr + 1);
1372 assert(b.length == 5);
1375 ////////////////////////////////////////////////////////////////////////
1387 static Foo[1] fun() { Foo[1] a; return a; }
1389 auto result = fun();
1390 assert(result[0].a == 8);
1391 assert(result[0].b == 7);
1394 ////////////////////////////////////////////////////////////////////////
1402 static assert((Foo[4]).sizeof == 16);
1404 static Foo[4] fun() { Foo[4] a; return a; }
1406 auto result = fun();
1407 assert(result[0].b == 7);
1408 assert(result[1].b == 7);
1409 assert(result[2].b == 7);
1410 assert(result[3].b == 7);
1413 ////////////////////////////////////////////////////////////////////////
1415 void[] calloc15272(size_t bc) nothrow pure
1423 void[] scache = cast(void[])"abc";
1425 void[]* buckets = &scache;
1426 *buckets = calloc15272(count)[0 .. count];
1429 /*****************************************
1430 * https://issues.dlang.org/show_bug.cgi?id=15861
1435 double val = 4286853117.;
1438 assert(val == 4286853117.);
1442 ////////////////////////////////////////////////////////////////////////
1444 // https://issues.dlang.org/show_bug.cgi?id=15629 comment 3
1450 int value = a[0] >= 0 ? a[0] : -a[0];
1455 void writeln(int v, int[] a)
1459 ////////////////////////////////////////////////////////////////////////
1461 real binPosPow2() { return 1.0L; }
1465 return 1.0L/binPosPow2();
1470 assert(binPow2() == 1.0L);
1473 ////////////////////////////////////////////////////////////////////////
1474 // https://issues.dlang.org/show_bug.cgi?id=13474
1477 double sumKBN(double s = 0.0)
1479 import std.math : fabs;
1481 foreach(double x; [1, 1e100, 1, -1e100])
1485 if(s.fabs >= x.fabs)
1500 double multiply(double a) { return a * 10000; }
1505 assert(r == sumKBN());
1508 ////////////////////////////////////////////////////////////////////////
1509 // https://issues.dlang.org/show_bug.cgi?id=16699
1511 ulong[1] parseDateRange()
1526 ulong[1] range = parseDateRange();
1527 assert(range[0] == 6);
1530 ////////////////////////////////////////////////////////////////////////
1532 // https://issues.dlang.org/show_bug.cgi?id=16102
1534 struct S16102 { ~this() { } }
1544 assert( f16102() == [1] );
1547 ////////////////////////////////////////////////////////////////////////
1550 /* Test the pattern:
1551 * replace ((i / C1) / C2) with (i / (C1 * C2))
1552 * when e1 is 0 or 1 and (i2-i1) is a power of 2.
1555 void divdiv(T, T C1, T C2)(T i)
1557 auto a = (i / C1) / C2;
1558 auto b = i / (C1 * C2);
1559 if (a != b) assert(0);
1564 divdiv!(int,10,20)(30);
1565 divdiv!(uint,10,20)(30);
1566 divdiv!(long,10,20)(30);
1567 divdiv!(ulong,10,20)(30);
1569 divdiv!(int,-10,20)(30);
1570 divdiv!(long,-10,20)(30);
1572 divdiv!(int,-10,-20)(-30);
1573 divdiv!(long,-10,-20)(-30);
1576 ////////////////////////////////////////////////////////////////////////
1578 void test5a(ulong x, ulong y)
1596 test5a(uint.max + 1L, uint.max);
1599 ////////////////////////////////////////////////////////////////////////
1601 /* Test the pattern:
1602 * replace (e ? i1 : i2) with (i1 + e * (i2 - i1))
1603 * when e1 is 0 or 1 and (i2-i1) is a power of 2.
1608 return (i % 2 != 0) ? 4 : 2;
1613 return (i % 2 != 0) ? 2 : 4;
1616 bool bar6(bool b) { return b; }
1620 return bar6(b) ? 16 : 8;
1625 return bar6(b) ? 8 : 16;
1630 if (foo61(0) != 2) assert(0);
1631 if (foo61(1) != 4) assert(0);
1632 if (foo62(0) != 4) assert(0);
1633 if (foo62(1) != 2) assert(0);
1634 if (foo63(0) != 8) assert(0);
1635 if (foo63(1) != 16) assert(0);
1636 if (foo64(0) != 16) assert(0);
1637 if (foo64(1) != 8) assert(0);
1640 ////////////////////////////////////////////////////////////////////////
1642 int dataflow(int b) {
1656 void testeqeqranges()
1658 int i = dataflow(4);
1663 ////////////////////////////////////////////////////////////////////////
1701 test13023(0x10_0000_0000);
1723 printf("Success\n");