Revision ecbb5ea1

b/target-alpha/op_helper.c
158 158

  
159 159
uint64_t helper_subqv (uint64_t op1, uint64_t op2)
160 160
{
161
    uint64_t tmp = op1;
162
    op1 -= op2;
163
    if (unlikely(((~tmp) ^ op1 ^ (-1ULL)) & ((~tmp) ^ op2) & (1ULL << 63))) {
161
    uint64_t res;
162
    res = op1 - op2;
163
    if (unlikely((op1 ^ op2) & (res ^ op1) & (1ULL << 63))) {
164 164
        helper_excp(EXCP_ARITH, EXCP_ARITH_OVERFLOW);
165 165
    }
166
    return op1;
166
    return res;
167 167
}
168 168

  
169 169
uint64_t helper_sublv (uint64_t op1, uint64_t op2)
170 170
{
171
    uint64_t tmp = op1;
172
    op1 = (uint32_t)(op1 - op2);
173
    if (unlikely(((~tmp) ^ op1 ^ (-1UL)) & ((~tmp) ^ op2) & (1UL << 31))) {
171
    uint32_t res;
172
    res = op1 - op2;
173
    if (unlikely((op1 ^ op2) & (res ^ op1) & (1UL << 31))) {
174 174
        helper_excp(EXCP_ARITH, EXCP_ARITH_OVERFLOW);
175 175
    }
176
    return op1;
176
    return res;
177 177
}
178 178

  
179 179
uint64_t helper_mullv (uint64_t op1, uint64_t op2)
b/tests/alpha/Makefile
23 23
test-cmov: test-cmov.o crt.o
24 24
	$(LINK)
25 25

  
26
test-ovf: test-ovf.o crt.o
27
	$(LINK)
28

  
26 29
check: $(TESTS)
27 30
	for f in $(TESTS); do $(SIM) $$f || exit 1; done
28 31

  
b/tests/alpha/test-ovf.c
1
static long test_subqv (long a, long b)
2
{
3
  long res;
4

  
5
  asm ("subq/v %1,%2,%0"
6
       : "=r" (res) : "r" (a), "r" (b));
7
  return res;
8
}
9
static struct {
10
  long (*func)(long, long);
11
  long a;
12
  long b;
13
  long r;
14
} vectors[] =
15
  {
16
    {test_subqv, 0, 0x7d54000, 0xfffffffff82ac000L}
17
  };
18

  
19
int main (void)
20
{
21
  int i;
22

  
23
  for (i = 0; i < sizeof (vectors)/sizeof(vectors[0]); i++)
24
    if ((*vectors[i].func)(vectors[i].a, vectors[i].b) != vectors[i].r) {
25
      write(1, "Failed\n", 7);
26
    }
27
  write(1, "OK\n", 3);
28
  return 0;
29
}

Also available in: Unified diff