2 * Copyright 2011 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
9 // use volatile to confuse llmv optimizer
10 volatile long long s64a = 0x12345678;
11 volatile long long s64b = 0x1;
13 volatile unsigned long long u64a = 0x12345678;
14 volatile unsigned long long u64b = 0x1;
16 volatile int s32a = 0x1234;
17 volatile int s32b = 0x1;
19 volatile unsigned int u32a = 0x1234;
20 volatile unsigned int u32b = 0x1;
22 volatile int failures = 0;
24 template<typename Integer> void Check(const char* mode, Integer a, Integer b) {
25 for (int i = 0; i < 16; ++i) {
27 // this relies on b == 1
30 printf("failure in mult %s %d\n", mode, i);
33 c += failures; /* hopefully a nop */
34 Integer div = c / (b + 1);
35 b += failures; /* hopefully a nop */
36 Integer rem = c % (b + 1);
37 b += failures; /* hopefully a nop */
38 if (div * (b + 1) + rem != c) {
40 printf("failure in div/mod %s %d\n", mode, i);
48 Check<int>("s32", s32a, s32b);
49 Check<unsigned int>("u32", u32a, u32b);
50 Check<long long>("s64", s64a, s64b);
51 Check<unsigned long long>("u64", u64a, u64b);