11.1Sjoerg//===-- lshrdi3_test.c - Test __lshrdi3 -----------------------------------===//
21.1Sjoerg//
31.1Sjoerg//                     The LLVM Compiler Infrastructure
41.1Sjoerg//
51.1Sjoerg// This file is dual licensed under the MIT and the University of Illinois Open
61.1Sjoerg// Source Licenses. See LICENSE.TXT for details.
71.1Sjoerg//
81.1Sjoerg//===----------------------------------------------------------------------===//
91.1Sjoerg//
101.1Sjoerg// This file tests __lshrdi3 for the compiler_rt library.
111.1Sjoerg//
121.1Sjoerg//===----------------------------------------------------------------------===//
131.1Sjoerg
141.1Sjoerg#include "int_lib.h"
151.1Sjoerg#include <stdio.h>
161.1Sjoerg
171.1Sjoerg// Returns: logical a >> b
181.1Sjoerg
191.1Sjoerg// Precondition:  0 <= b < bits_in_dword
201.1Sjoerg
211.1Sjoergdi_int __lshrdi3(di_int a, si_int b);
221.1Sjoerg
231.1Sjoergint test__lshrdi3(di_int a, si_int b, di_int expected)
241.1Sjoerg{
251.1Sjoerg    di_int x = __lshrdi3(a, b);
261.1Sjoerg    if (x != expected)
271.1Sjoerg        printf("error in __lshrdi3: %llX >> %d = %llX, expected %llX\n",
281.1Sjoerg               a, b, __lshrdi3(a, b), expected);
291.1Sjoerg    return x != expected;
301.1Sjoerg}
311.1Sjoerg
321.1Sjoergchar assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
331.1Sjoerg
341.1Sjoergint main()
351.1Sjoerg{
361.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 0, 0x123456789ABCDEFLL))
371.1Sjoerg        return 1;
381.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 1, 0x91A2B3C4D5E6F7LL))
391.1Sjoerg        return 1;
401.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 2, 0x48D159E26AF37BLL))
411.1Sjoerg        return 1;
421.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 3, 0x2468ACF13579BDLL))
431.1Sjoerg        return 1;
441.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 4, 0x123456789ABCDELL))
451.1Sjoerg        return 1;
461.1Sjoerg
471.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 28, 0x12345678LL))
481.1Sjoerg        return 1;
491.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 29, 0x91A2B3CLL))
501.1Sjoerg        return 1;
511.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 30, 0x48D159ELL))
521.1Sjoerg        return 1;
531.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 31, 0x2468ACFLL))
541.1Sjoerg        return 1;
551.1Sjoerg
561.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 32, 0x1234567LL))
571.1Sjoerg        return 1;
581.1Sjoerg
591.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 33, 0x91A2B3LL))
601.1Sjoerg        return 1;
611.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 34, 0x48D159LL))
621.1Sjoerg        return 1;
631.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 35, 0x2468ACLL))
641.1Sjoerg        return 1;
651.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 36, 0x123456LL))
661.1Sjoerg        return 1;
671.1Sjoerg
681.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 60, 0))
691.1Sjoerg        return 1;
701.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 61, 0))
711.1Sjoerg        return 1;
721.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 62, 0))
731.1Sjoerg        return 1;
741.1Sjoerg    if (test__lshrdi3(0x0123456789ABCDEFLL, 63, 0))
751.1Sjoerg        return 1;
761.1Sjoerg
771.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 0, 0xFEDCBA9876543210LL))
781.1Sjoerg        return 1;
791.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 1, 0x7F6E5D4C3B2A1908LL))
801.1Sjoerg        return 1;
811.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 2, 0x3FB72EA61D950C84LL))
821.1Sjoerg        return 1;
831.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 3, 0x1FDB97530ECA8642LL))
841.1Sjoerg        return 1;
851.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 4, 0xFEDCBA987654321LL))
861.1Sjoerg        return 1;
871.1Sjoerg
881.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 28, 0xFEDCBA987LL))
891.1Sjoerg        return 1;
901.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 29, 0x7F6E5D4C3LL))
911.1Sjoerg        return 1;
921.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 30, 0x3FB72EA61LL))
931.1Sjoerg        return 1;
941.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 31, 0x1FDB97530LL))
951.1Sjoerg        return 1;
961.1Sjoerg
971.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 32, 0xFEDCBA98LL))
981.1Sjoerg        return 1;
991.1Sjoerg
1001.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 33, 0x7F6E5D4CLL))
1011.1Sjoerg        return 1;
1021.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 34, 0x3FB72EA6LL))
1031.1Sjoerg        return 1;
1041.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 35, 0x1FDB9753LL))
1051.1Sjoerg        return 1;
1061.1Sjoerg    if (test__lshrdi3(0xFEDCBA9876543210LL, 36, 0xFEDCBA9LL))
1071.1Sjoerg        return 1;
1081.1Sjoerg
1091.1Sjoerg    if (test__lshrdi3(0xAEDCBA9876543210LL, 60, 0xALL))
1101.1Sjoerg        return 1;
1111.1Sjoerg    if (test__lshrdi3(0xAEDCBA9876543210LL, 61, 0x5LL))
1121.1Sjoerg        return 1;
1131.1Sjoerg    if (test__lshrdi3(0xAEDCBA9876543210LL, 62, 0x2LL))
1141.1Sjoerg        return 1;
1151.1Sjoerg    if (test__lshrdi3(0xAEDCBA9876543210LL, 63, 0x1LL))
1161.1Sjoerg        return 1;
1171.1Sjoerg    return 0;
1181.1Sjoerg}
119