[llvm] 432e9f4 - [llvm][LoongArch] Avoid shift overflow (#106785)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 30 13:19:35 PDT 2024


Author: Vitaly Buka
Date: 2024-08-30T13:19:31-07:00
New Revision: 432e9f44101e44bb996c350cf5693038916953f3

URL: https://github.com/llvm/llvm-project/commit/432e9f44101e44bb996c350cf5693038916953f3
DIFF: https://github.com/llvm/llvm-project/commit/432e9f44101e44bb996c350cf5693038916953f3.diff

LOG: [llvm][LoongArch] Avoid shift overflow (#106785)

Follow up fix to #106332

`LoongArchMatInt.cpp:96:33: runtime error: shift exponent 64 is too
large for 64-bit type`
https://lab.llvm.org/buildbot/#/builders/169/builds/2681

Added: 
    

Modified: 
    llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMatInt.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMatInt.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMatInt.cpp
index 6ad2c003558a51..a7823470382756 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMatInt.cpp
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMatInt.cpp
@@ -92,8 +92,9 @@ LoongArchMatInt::InstSeq LoongArchMatInt::generateInstSeq(int64_t Val) {
     break;
   }
 
-  for (uint64_t Msb = 32; Msb < 64; ++Msb) {
-    uint64_t HighMask = ~((1ULL << (Msb + 1)) - 1);
+  uint64_t Msb = 32;
+  uint64_t HighMask = ~((1ULL << (Msb + 1)) - 1);
+  for (; Msb < 64; ++Msb, HighMask = (HighMask << 1) + 1) {
     for (uint64_t Lsb = Msb; Lsb > 0; --Lsb) {
       uint64_t LowMask = (1ULL << Lsb) - 1;
       uint64_t Mask = HighMask | LowMask;


        


More information about the llvm-commits mailing list