@@ -5247,6 +5247,59 @@ Instruction* cs6475_optimizer(Instruction *I, InstCombinerImpl &IC, LazyValueInf
5247
5247
}
5248
5248
}
5249
5249
// END JOHN REGEHR
5250
+
5251
+ // BEGIN JACOB KNOWLTON
5252
+ {
5253
+ Value *X1 = nullptr ;
5254
+ Value *X2 = nullptr ;
5255
+ // >= case
5256
+ ICmpInst::Predicate Pred1 = ICmpInst::ICMP_SGE;
5257
+ if (match (I, m_ICmp (Pred1, m_Value (X), m_Value (Y)))) {
5258
+ if (match (Y, m_ConstantInt (C))) {
5259
+ if (C->isZero ()) {
5260
+ if (match (X, m_Mul (m_Value (X1), m_Value (X2)))) {
5261
+ auto Mul1 = dyn_cast<BinaryOperator>(X);
5262
+ if (Mul1->hasNoSignedWrap ()) {
5263
+ if (match (X1, m_Mul (m_Specific (X2), m_ConstantInt (C))) || match (X1, m_Shl (m_Specific (X2), m_ConstantInt (C)))) {
5264
+ auto Mul2 = dyn_cast<BinaryOperator>(X1);
5265
+ if (Mul2->hasNoSignedWrap ()) {
5266
+ if (C->getUniqueInteger ().isNonNegative ()) {
5267
+ log_optzn (" Jacob Knowlton" );
5268
+ ICmpInst::Predicate Pred3 = ICmpInst::ICMP_EQ;
5269
+ return new ICmpInst (Pred3, ConstantInt::getTrue (I->getContext ()), ConstantInt::getTrue (I->getContext ()));
5270
+ }
5271
+ }
5272
+ }
5273
+ }
5274
+ }
5275
+ }
5276
+ }
5277
+ }
5278
+ // > case
5279
+ ICmpInst::Predicate Pred2 = ICmpInst::ICMP_SGT;
5280
+ if (match (I, m_ICmp (Pred2, m_Value (X), m_Value (Y)))) {
5281
+ if (match (Y, m_ConstantInt (C))) {
5282
+ if (C->isMinusOne ()) {
5283
+ if (match (X, m_Mul (m_Value (X1), m_Value (X2)))) {
5284
+ auto Mul1 = dyn_cast<BinaryOperator>(X);
5285
+ if (Mul1->hasNoSignedWrap ()) {
5286
+ if (match (X1, m_Mul (m_Specific (X2), m_ConstantInt (C))) || match (X1, m_Shl (m_Specific (X2), m_ConstantInt (C)))) {
5287
+ auto Mul2 = dyn_cast<BinaryOperator>(X1);
5288
+ if (Mul2->hasNoSignedWrap ()) {
5289
+ if (C->getUniqueInteger ().isNonNegative ()) {
5290
+ log_optzn (" Jacob Knowlton" );
5291
+ ICmpInst::Predicate Pred3 = ICmpInst::ICMP_EQ;
5292
+ return new ICmpInst (Pred3, ConstantInt::getTrue (I->getContext ()), ConstantInt::getTrue (I->getContext ()));
5293
+ }
5294
+ }
5295
+ }
5296
+ }
5297
+ }
5298
+ }
5299
+ }
5300
+ }
5301
+ }
5302
+ // END JACOB KNOWLTON
5250
5303
5251
5304
// BEGIN BRENSEN VILLEGAS
5252
5305
{
0 commit comments