Mercurial > hg > CbC > CbC_llvm
comparison llvm/lib/IR/ConstantRange.cpp @ 223:5f17cb93ff66 llvm-original
LLVM13 (2021/7/18)
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 18 Jul 2021 22:43:00 +0900 |
parents | 79ff65ed7e25 |
children | c4bab56944e8 |
comparison
equal
deleted
inserted
replaced
222:81f6424ef0e3 | 223:5f17cb93ff66 |
---|---|
1219 | 1219 |
1220 ConstantRange ConstantRange::urem(const ConstantRange &RHS) const { | 1220 ConstantRange ConstantRange::urem(const ConstantRange &RHS) const { |
1221 if (isEmptySet() || RHS.isEmptySet() || RHS.getUnsignedMax().isNullValue()) | 1221 if (isEmptySet() || RHS.isEmptySet() || RHS.getUnsignedMax().isNullValue()) |
1222 return getEmpty(); | 1222 return getEmpty(); |
1223 | 1223 |
1224 if (const APInt *RHSInt = RHS.getSingleElement()) { | |
1225 // UREM by null is UB. | |
1226 if (RHSInt->isNullValue()) | |
1227 return getEmpty(); | |
1228 // Use APInt's implementation of UREM for single element ranges. | |
1229 if (const APInt *LHSInt = getSingleElement()) | |
1230 return {LHSInt->urem(*RHSInt)}; | |
1231 } | |
1232 | |
1224 // L % R for L < R is L. | 1233 // L % R for L < R is L. |
1225 if (getUnsignedMax().ult(RHS.getUnsignedMin())) | 1234 if (getUnsignedMax().ult(RHS.getUnsignedMin())) |
1226 return *this; | 1235 return *this; |
1227 | 1236 |
1228 // L % R is <= L and < R. | 1237 // L % R is <= L and < R. |
1231 } | 1240 } |
1232 | 1241 |
1233 ConstantRange ConstantRange::srem(const ConstantRange &RHS) const { | 1242 ConstantRange ConstantRange::srem(const ConstantRange &RHS) const { |
1234 if (isEmptySet() || RHS.isEmptySet()) | 1243 if (isEmptySet() || RHS.isEmptySet()) |
1235 return getEmpty(); | 1244 return getEmpty(); |
1245 | |
1246 if (const APInt *RHSInt = RHS.getSingleElement()) { | |
1247 // SREM by null is UB. | |
1248 if (RHSInt->isNullValue()) | |
1249 return getEmpty(); | |
1250 // Use APInt's implementation of SREM for single element ranges. | |
1251 if (const APInt *LHSInt = getSingleElement()) | |
1252 return {LHSInt->srem(*RHSInt)}; | |
1253 } | |
1236 | 1254 |
1237 ConstantRange AbsRHS = RHS.abs(); | 1255 ConstantRange AbsRHS = RHS.abs(); |
1238 APInt MinAbsRHS = AbsRHS.getUnsignedMin(); | 1256 APInt MinAbsRHS = AbsRHS.getUnsignedMin(); |
1239 APInt MaxAbsRHS = AbsRHS.getUnsignedMax(); | 1257 APInt MaxAbsRHS = AbsRHS.getUnsignedMax(); |
1240 | 1258 |