|
24 | 24 | #include "llvm/ADT/iterator.h" |
25 | 25 | #include "llvm/ADT/iterator_range.h" |
26 | 26 | #include "llvm/IR/CFG.h" |
| 27 | +#include "llvm/IR/CmpPredicate.h" |
27 | 28 | #include "llvm/IR/Constant.h" |
28 | 29 | #include "llvm/IR/DerivedTypes.h" |
29 | 30 | #include "llvm/IR/GEPNoWrapFlags.h" |
@@ -1203,38 +1204,78 @@ class ICmpInst: public CmpInst { |
1203 | 1204 | #endif |
1204 | 1205 | } |
1205 | 1206 |
|
| 1207 | + /// @returns the predicate along with samesign information. |
| 1208 | + CmpPredicate getCmpPredicate() const { |
| 1209 | + return {getPredicate(), hasSameSign()}; |
| 1210 | + } |
| 1211 | + |
| 1212 | + /// @returns the inverse predicate along with samesign information: static |
| 1213 | + /// variant. |
| 1214 | + static CmpPredicate getInverseCmpPredicate(CmpPredicate Pred) { |
| 1215 | + return {getInversePredicate(Pred), Pred.hasSameSign()}; |
| 1216 | + } |
| 1217 | + |
| 1218 | + /// @returns the inverse predicate along with samesign information. |
| 1219 | + CmpPredicate getInverseCmpPredicate() const { |
| 1220 | + return getInverseCmpPredicate(getCmpPredicate()); |
| 1221 | + } |
| 1222 | + |
| 1223 | + /// @returns the swapped predicate along with samesign information: static |
| 1224 | + /// variant. |
| 1225 | + static CmpPredicate getSwappedCmpPredicate(CmpPredicate Pred) { |
| 1226 | + return {getSwappedPredicate(Pred), Pred.hasSameSign()}; |
| 1227 | + } |
| 1228 | + |
| 1229 | + /// @returns the swapped predicate along with samesign information. |
| 1230 | + CmpPredicate getSwappedCmpPredicate() const { |
| 1231 | + return getSwappedPredicate(getCmpPredicate()); |
| 1232 | + } |
| 1233 | + |
1206 | 1234 | /// For example, EQ->EQ, SLE->SLE, UGT->SGT, etc. |
1207 | 1235 | /// @returns the predicate that would be the result if the operand were |
1208 | 1236 | /// regarded as signed. |
1209 | | - /// Return the signed version of the predicate. |
1210 | | - Predicate getSignedPredicate() const { |
1211 | | - return getSignedPredicate(getPredicate()); |
| 1237 | + /// Return the signed version of the predicate along with samesign |
| 1238 | + /// information. |
| 1239 | + CmpPredicate getSignedPredicate() const { |
| 1240 | + return getSignedPredicate(getCmpPredicate()); |
1212 | 1241 | } |
1213 | 1242 |
|
1214 | | - /// Return the signed version of the predicate: static variant. |
1215 | | - static Predicate getSignedPredicate(Predicate pred); |
| 1243 | + /// Return the signed version of the predicate along with samesign |
| 1244 | + /// information: static variant. |
| 1245 | + static CmpPredicate getSignedPredicate(CmpPredicate Pred) { |
| 1246 | + return {CmpInst::getSignedPredicate(Pred), Pred.hasSameSign()}; |
| 1247 | + } |
1216 | 1248 |
|
1217 | 1249 | /// For example, EQ->EQ, SLE->ULE, UGT->UGT, etc. |
1218 | 1250 | /// @returns the predicate that would be the result if the operand were |
1219 | 1251 | /// regarded as unsigned. |
1220 | | - /// Return the unsigned version of the predicate. |
1221 | | - Predicate getUnsignedPredicate() const { |
1222 | | - return getUnsignedPredicate(getPredicate()); |
| 1252 | + /// Return the unsigned version of the predicate along with samesign |
| 1253 | + /// information. |
| 1254 | + CmpPredicate getUnsignedPredicate() const { |
| 1255 | + return getUnsignedPredicate(getCmpPredicate()); |
1223 | 1256 | } |
1224 | 1257 |
|
1225 | | - /// Return the unsigned version of the predicate: static variant. |
1226 | | - static Predicate getUnsignedPredicate(Predicate pred); |
| 1258 | + /// Return the unsigned version of the predicate along with samesign |
| 1259 | + /// information: static variant. |
| 1260 | + static CmpPredicate getUnsignedPredicate(CmpPredicate Pred) { |
| 1261 | + return {CmpInst::getUnsignedPredicate(Pred), Pred.hasSameSign()}; |
| 1262 | + } |
1227 | 1263 |
|
1228 | | - /// For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->Failed assert |
| 1264 | + /// For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->EQ |
1229 | 1265 | /// @returns the unsigned version of the signed predicate pred or |
1230 | | - /// the signed version of the signed predicate pred. |
1231 | | - static Predicate getFlippedSignednessPredicate(Predicate pred); |
| 1266 | + /// the signed version of the signed predicate pred, along with |
| 1267 | + /// samesign information. |
| 1268 | + /// Static variant. |
| 1269 | + static CmpPredicate getFlippedSignednessPredicate(CmpPredicate Pred) { |
| 1270 | + return {CmpInst::getFlippedSignednessPredicate(Pred), Pred.hasSameSign()}; |
| 1271 | + } |
1232 | 1272 |
|
1233 | | - /// For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->Failed assert |
| 1273 | + /// For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->EQ |
1234 | 1274 | /// @returns the unsigned version of the signed predicate pred or |
1235 | | - /// the signed version of the signed predicate pred. |
1236 | | - Predicate getFlippedSignednessPredicate() const { |
1237 | | - return getFlippedSignednessPredicate(getPredicate()); |
| 1275 | + /// the signed version of the signed predicate pred, along with |
| 1276 | + /// samesign information. |
| 1277 | + CmpPredicate getFlippedSignednessPredicate() const { |
| 1278 | + return getFlippedSignednessPredicate(getCmpPredicate()); |
1238 | 1279 | } |
1239 | 1280 |
|
1240 | 1281 | void setSameSign(bool B = true) { |
|
0 commit comments