Revision c3e10c7b target-ppc/op_helper.c

b/target-ppc/op_helper.c
151 151
{
152 152
    T1 = T0;
153 153
    T0 += xer_ca + (-1);
154
    if (likely(!((uint32_t)T1 &
155
                 ((uint32_t)T1 ^ (uint32_t)T0) & (1UL << 31)))) {
156
        xer_ov = 0;
157
    } else {
158
        xer_ov = 1;
159
        xer_so = 1;
160
    }
154
    xer_ov = ((uint32_t)T1 & ((uint32_t)T1 ^ (uint32_t)T0)) >> 31;
155
    xer_so |= xer_ov;
161 156
    if (likely(T1 != 0))
162 157
        xer_ca = 1;
158
    else
159
        xer_ca = 0;
163 160
}
164 161

  
165 162
#if defined(TARGET_PPC64)
......
167 164
{
168 165
    T1 = T0;
169 166
    T0 += xer_ca + (-1);
170
    if (likely(!((uint64_t)T1 &
171
                 ((uint64_t)T1 ^ (uint64_t)T0) & (1ULL << 63)))) {
172
        xer_ov = 0;
173
    } else {
174
        xer_ov = 1;
175
        xer_so = 1;
176
    }
167
    xer_ov = ((uint64_t)T1 & ((uint64_t)T1 ^ (uint64_t)T0)) >> 63;
168
    xer_so |= xer_ov;
177 169
    if (likely(T1 != 0))
178 170
        xer_ca = 1;
171
    else
172
        xer_ca = 0;
179 173
}
180 174
#endif
181 175

  
......
316 310
{
317 311
    T1 = T0;
318 312
    T0 = ~T0 + xer_ca - 1;
319
    if (likely(!((uint32_t)~T1 & ((uint32_t)~T1 ^ (uint32_t)T0) &
320
                 (1UL << 31)))) {
321
        xer_ov = 0;
322
    } else {
323
        xer_ov = 1;
324
        xer_so = 1;
325
    }
313
    xer_ov = ((uint32_t)~T1 & ((uint32_t)~T1 ^ (uint32_t)T0)) >> 31;
314
    xer_so |= xer_ov;
326 315
    if (likely((uint32_t)T1 != UINT32_MAX))
327 316
        xer_ca = 1;
317
    else
318
        xer_ca = 0;
328 319
}
329 320

  
330 321
#if defined(TARGET_PPC64)
......
332 323
{
333 324
    T1 = T0;
334 325
    T0 = ~T0 + xer_ca - 1;
335
    if (likely(!((uint64_t)~T1 & ((uint64_t)~T1 ^ (uint64_t)T0) &
336
                 (1ULL << 63)))) {
337
        xer_ov = 0;
338
    } else {
339
        xer_ov = 1;
340
        xer_so = 1;
341
    }
326
    xer_ov = ((uint64_t)~T1 & ((uint64_t)~T1 ^ (uint64_t)T0)) >> 63;
327
    xer_so |= xer_ov;
342 328
    if (likely((uint64_t)T1 != UINT64_MAX))
343 329
        xer_ca = 1;
330
    else
331
        xer_ca = 0;
344 332
}
345 333
#endif
346 334

  
......
348 336
{
349 337
    T1 = T0;
350 338
    T0 = ~T0 + xer_ca;
351
    if (likely(!(((uint32_t)~T1 ^ UINT32_MAX) &
352
                 ((uint32_t)(~T1) ^ (uint32_t)T0) & (1UL << 31)))) {
353
        xer_ov = 0;
354
    } else {
355
        xer_ov = 1;
356
        xer_so = 1;
357
    }
339
    xer_ov = (((uint32_t)~T1 ^ UINT32_MAX) &
340
              ((uint32_t)(~T1) ^ (uint32_t)T0)) >> 31;
341
    xer_so |= xer_ov;
358 342
    if (likely((uint32_t)T0 >= (uint32_t)~T1)) {
359 343
        xer_ca = 0;
360 344
    } else {
......
367 351
{
368 352
    T1 = T0;
369 353
    T0 = ~T0 + xer_ca;
370
    if (likely(!(((uint64_t)~T1 ^ UINT64_MAX) &
371
                 ((uint64_t)(~T1) ^ (uint64_t)T0) & (1ULL << 63)))) {
372
        xer_ov = 0;
373
    } else {
374
        xer_ov = 1;
375
        xer_so = 1;
376
    }
354
    xer_ov = (((uint64_t)~T1 ^  UINT64_MAX) &
355
              ((uint64_t)(~T1) ^ (uint64_t)T0)) >> 63;
356
    xer_so |= xer_ov;
377 357
    if (likely((uint64_t)T0 >= (uint64_t)~T1)) {
378 358
        xer_ca = 0;
379 359
    } else {
......
1755 1735

  
1756 1736
/*****************************************************************************/
1757 1737
/* Embedded PowerPC specific helpers */
1758
void do_405_check_ov (void)
1759
{
1760
    if (likely((((uint32_t)T1 ^ (uint32_t)T2) >> 31) ||
1761
               !(((uint32_t)T0 ^ (uint32_t)T2) >> 31))) {
1762
        xer_ov = 0;
1763
    } else {
1764
        xer_ov = 1;
1765
        xer_so = 1;
1766
    }
1767
}
1768

  
1769 1738
void do_405_check_sat (void)
1770 1739
{
1771 1740
    if (!likely((((uint32_t)T1 ^ (uint32_t)T2) >> 31) ||

Also available in: Unified diff