/* PR target/118696 */ /* { dg-do run } */ /* { dg-options "-O2" } */ #if __CHAR_BIT__ == 8 #if __SIZEOF_INT128__ == 16 && __SIZEOF_LONG_LONG__ == 8 #define D __int128 #define S long long #define M 0x8000000000000000ULL #define C 64 #elif __SIZEOF_LONG_LONG__ == 8 && __SIZEOF_INT__ == 4 #define D long long #define S int #define M 0x80000000U #define C 32 #endif #endif #ifdef D static inline D combine (unsigned S x, unsigned S y) { return (unsigned D) x << C | y; } __attribute__((noipa)) D smin (D x, D y) { return x < y ? x : y; } __attribute__((noipa)) D smax (D x, D y) { return x > y ? x : y; } __attribute__((noipa)) unsigned D umin (unsigned D x, unsigned D y) { return x < y ? x : y; } __attribute__((noipa)) unsigned D umax (unsigned D x, unsigned D y) { return x > y ? x : y; } #endif int main () { #ifdef D unsigned S vals[] = { 0, 12, 42, M, M | 12, M | 42 }; unsigned char expected[] = { 4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,0,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,0,0,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,4,3,3,3,3,3,3,3,3,3,3,3, 3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,4,3,3,3,3,3,3, 3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,4,3, 3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0, 0,0,0,4,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,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0,0,0,0,0,0,0,0,4 }; int m = 0; for (int i = 0; i < 6; ++i) for (int j = 0; j < 6; ++j) for (int k = 0; k < 6; ++k) for (int l = 0; l < 6; ++l) { D a = combine (vals[i], vals[j]); D b = combine (vals[k], vals[l]); int r = 0; r |= (smin (a, b) == a) * 1; r |= (smin (a, b) == b) * 2; r |= (smax (a, b) == a) * 4; r |= (smax (a, b) == b) * 8; r |= (umin (a, b) == a) * 16; r |= (umin (a, b) == b) * 32; r |= (umax (a, b) == a) * 64; r |= (umax (a, b) == b) * 128; switch (r) { case 102: r = 0; break; case 105: r = 1; break; case 150: r = 2; break; case 153: r = 3; break; case 255: r = 4; break; default: __builtin_abort (); } if (r != expected[m++]) __builtin_abort (); } #endif }