Skip to content

Commit 4648098

Browse files
committed
[VE] Change inetger constants 32-bit friendly
Correct integer constants like `1UL << 63` to `UINT64_C(1) << 63` in order to make them work on 32-bit machines. Tested on both an i386 and x86_64 machines. Reviewed By: mgorny Differential Revision: https://reviews.llvm.org/D95724
1 parent a9583a1 commit 4648098

File tree

1 file changed

+5
-5
lines changed
  • llvm/lib/Target/VE

1 file changed

+5
-5
lines changed

llvm/lib/Target/VE/VE.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ inline static bool isMImmVal(uint64_t Val) {
334334
return true;
335335
}
336336
// (m)1 patterns
337-
return (Val & (1UL << 63)) && isShiftedMask_64(Val);
337+
return (Val & (UINT64_C(1) << 63)) && isShiftedMask_64(Val);
338338
}
339339

340340
inline static bool isMImm32Val(uint32_t Val) {
@@ -347,14 +347,14 @@ inline static bool isMImm32Val(uint32_t Val) {
347347
return true;
348348
}
349349
// (m)1 patterns
350-
return (Val & (1 << 31)) && isShiftedMask_32(Val);
350+
return (Val & (UINT32_C(1) << 31)) && isShiftedMask_32(Val);
351351
}
352352

353353
/// val2MImm - Convert an integer immediate value to target MImm immediate.
354354
inline static uint64_t val2MImm(uint64_t Val) {
355355
if (Val == 0)
356356
return 0; // (0)1
357-
if (Val & (1UL << 63))
357+
if (Val & (UINT64_C(1) << 63))
358358
return countLeadingOnes(Val); // (m)1
359359
return countLeadingZeros(Val) | 0x40; // (m)0
360360
}
@@ -364,8 +364,8 @@ inline static uint64_t mimm2Val(uint64_t Val) {
364364
if (Val == 0)
365365
return 0; // (0)1
366366
if ((Val & 0x40) == 0)
367-
return (uint64_t)((1L << 63) >> (Val & 0x3f)); // (m)1
368-
return ((uint64_t)(-1L) >> (Val & 0x3f)); // (m)0
367+
return (uint64_t)((INT64_C(1) << 63) >> (Val & 0x3f)); // (m)1
368+
return ((uint64_t)INT64_C(-1) >> (Val & 0x3f)); // (m)0
369369
}
370370

371371
inline unsigned M0(unsigned Val) { return Val + 64; }

0 commit comments

Comments
 (0)