aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp')
-rw-r--r--llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
index 10f6590..31bf9a9 100644
--- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
@@ -2463,20 +2463,16 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
// Can only check for types of a known size
if (VT == MVT::iPTR)
continue;
- unsigned Size = MVT(VT).getFixedSizeInBits();
- // Make sure that the value is representable for this type.
- if (Size >= 32)
- continue;
+
// Check that the value doesn't use more bits than we have. It must
// either be a sign- or zero-extended equivalent of the original.
- int64_t SignBitAndAbove = II->getValue() >> (Size - 1);
- if (SignBitAndAbove == -1 || SignBitAndAbove == 0 ||
- SignBitAndAbove == 1)
- continue;
-
- TP.error("Integer value '" + Twine(II->getValue()) +
- "' is out of range for type '" + getEnumName(VT) + "'!");
- break;
+ unsigned Width = MVT(VT).getFixedSizeInBits();
+ int64_t Val = II->getValue();
+ if (!isIntN(Width, Val) && !isUIntN(Width, Val)) {
+ TP.error("Integer value '" + Twine(Val) +
+ "' is out of range for type '" + getEnumName(VT) + "'!");
+ break;
+ }
}
return MadeChange;
}