Skip to content

Commit 167b623

Browse files
committed
[BOLT][NFC] Use isInt<> instead of range checks
Summary: Reuse LLVM isInt check Reviewed By: maksfb FBD33945182
1 parent abc6716 commit 167b623

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,13 +1873,9 @@ class X86MCPlusBuilder : public MCPlusBuilder {
18731873
NewOpcode = Check.second;
18741874
if (Check.first == NOCHECK)
18751875
break;
1876-
if (Check.first == CHECK8 &&
1877-
ImmVal >= std::numeric_limits<int8_t>::min() &&
1878-
ImmVal <= std::numeric_limits<int8_t>::max())
1876+
if (Check.first == CHECK8 && isInt<8>(ImmVal))
18791877
break;
1880-
if (Check.first == CHECK32 &&
1881-
ImmVal >= std::numeric_limits<int32_t>::min() &&
1882-
ImmVal <= std::numeric_limits<int32_t>::max())
1878+
if (Check.first == CHECK32 && isInt<32>(ImmVal))
18831879
break;
18841880
}
18851881
if (NewOpcode == Inst.getOpcode())
@@ -3012,12 +3008,9 @@ class X86MCPlusBuilder : public MCPlusBuilder {
30123008
NewOpcode = Check.second;
30133009
if (Check.first == NOCHECK)
30143010
break;
3015-
if (Check.first == CHECK8 && Imm >= std::numeric_limits<int8_t>::min() &&
3016-
Imm <= std::numeric_limits<int8_t>::max())
3011+
if (Check.first == CHECK8 && isInt<8>(Imm))
30173012
break;
3018-
if (Check.first == CHECK32 &&
3019-
Imm >= std::numeric_limits<int32_t>::min() &&
3020-
Imm <= std::numeric_limits<int32_t>::max())
3013+
if (Check.first == CHECK32 && isInt<32>(Imm))
30213014
break;
30223015
}
30233016
if (NewOpcode == Inst.getOpcode())

0 commit comments

Comments
 (0)