summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2558.c
blob: 46b3b036724e04386c0ab417898f014e96495f37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* bug-2807.c
   Sign of % operand lost in redundancy elimination.
 */

#include <testfwk.h>

#include <stdint.h>

uint16_t x;

static inline uint16_t llvm_srem_u16(int16_t a, int16_t b) {
  uint16_t r = a % b;
  return r;
}

static inline uint16_t returnx(void)
{
  return x;
}

void foo(void)
{
  x=llvm_srem_u16(x,returnx());
}

void testBug(void)
{
  x = (unsigned)(-1);
  foo();
  ASSERT (x == (unsigned)(-23) % (unsigned)(-23));
}