diff options
author | Sergei Barannikov <barannikov88@gmail.com> | 2024-12-14 13:58:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-14 13:58:23 +0300 |
commit | 97c3c32372bb8478c53ab9469585c7c6e531cbd2 (patch) | |
tree | 432a94c9f81d8fb55921f50b33434eafb0de761f /llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp | |
parent | 74fb9928443ce3d176911615e6a0297f074736fe (diff) | |
download | llvm-97c3c32372bb8478c53ab9469585c7c6e531cbd2.zip llvm-97c3c32372bb8478c53ab9469585c7c6e531cbd2.tar.gz llvm-97c3c32372bb8478c53ab9469585c7c6e531cbd2.tar.bz2 |
[TableGen][SystemZ] Correctly check the range of a leaf immediate (#119931)
The "Size >= 32" check probably dates back to when TableGen integers
were 32-bit. Delete it and simplify code by using `isInt`/`isUInt`.
Diffstat (limited to 'llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp')
-rw-r--r-- | llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp | 20 |
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; } |