[BOLT][NFC] Use isInt<> instead of range checks
authorAmir Ayupov <aaupov@fb.com>
Wed, 2 Feb 2022 17:04:10 +0000 (09:04 -0800)
committerAmir Ayupov <aaupov@fb.com>
Thu, 3 Feb 2022 04:32:05 +0000 (20:32 -0800)
Summary: Reuse LLVM isInt check

Reviewed By: maksfb

FBD33945182

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

index 67efa16..3cac140 100644 (file)
@@ -1873,13 +1873,9 @@ public:
       NewOpcode = Check.second;
       if (Check.first == NOCHECK)
         break;
-      if (Check.first == CHECK8 &&
-          ImmVal >= std::numeric_limits<int8_t>::min() &&
-          ImmVal <= std::numeric_limits<int8_t>::max())
+      if (Check.first == CHECK8 && isInt<8>(ImmVal))
         break;
-      if (Check.first == CHECK32 &&
-          ImmVal >= std::numeric_limits<int32_t>::min() &&
-          ImmVal <= std::numeric_limits<int32_t>::max())
+      if (Check.first == CHECK32 && isInt<32>(ImmVal))
         break;
     }
     if (NewOpcode == Inst.getOpcode())
@@ -3012,12 +3008,9 @@ public:
       NewOpcode = Check.second;
       if (Check.first == NOCHECK)
         break;
-      if (Check.first == CHECK8 && Imm >= std::numeric_limits<int8_t>::min() &&
-          Imm <= std::numeric_limits<int8_t>::max())
+      if (Check.first == CHECK8 && isInt<8>(Imm))
         break;
-      if (Check.first == CHECK32 &&
-          Imm >= std::numeric_limits<int32_t>::min() &&
-          Imm <= std::numeric_limits<int32_t>::max())
+      if (Check.first == CHECK32 && isInt<32>(Imm))
         break;
     }
     if (NewOpcode == Inst.getOpcode())