@@ -2506,10 +2506,6 @@ IGC_INITIALIZE_PASS_END(GenSpecificPattern, PASS_FLAG2, PASS_DESCRIPTION2, PASS_
2506
2506
2507
2507
char GenSpecificPattern::ID = 0;
2508
2508
2509
- // m_Add is able to match add and equivalent sub instructions.
2510
- // This predicate is useful for patterns where only add should be matched:
2511
- bool isActualAddInstr (const Instruction* inst) { return inst && inst->getOpcode () == Instruction::Add; }
2512
-
2513
2509
GenSpecificPattern::GenSpecificPattern () : FunctionPass(ID)
2514
2510
{
2515
2511
initializeGenSpecificPatternPass (*PassRegistry::getPassRegistry ());
@@ -2747,24 +2743,6 @@ void GenSpecificPattern::createBitcastExtractInsertPattern(BinaryOperator& I, Va
2747
2743
I.eraseFromParent ();
2748
2744
}
2749
2745
2750
- void GenSpecificPattern::createAddcIntrinsicPattern (Instruction& ZEI, Value* val1, Value* val2, Instruction& addInst)
2751
- {
2752
- IRBuilder<> Builder (&addInst);
2753
-
2754
- SmallVector<Value*, 2 > packed_res_params;
2755
- packed_res_params.push_back (val1);
2756
- packed_res_params.push_back (val2);
2757
- Type* types[] = { IGCLLVM::FixedVectorType::get (val1->getType (), 2 ), val1->getType () };
2758
- Function* addcIntrinsic = llvm::GenISAIntrinsic::getDeclaration (ZEI.getModule (), GenISAIntrinsic::GenISA_uaddc, types);
2759
- Value* newVal = Builder.CreateCall (addcIntrinsic, packed_res_params);
2760
- CallInst* packed_res_call = cast<CallInst>(newVal);
2761
-
2762
- Value* result = Builder.CreateExtractElement (packed_res_call, Builder.getInt32 (0 ));
2763
- Value* carryFlag = Builder.CreateExtractElement (packed_res_call, Builder.getInt32 (1 ));
2764
- ZEI.replaceAllUsesWith (carryFlag);
2765
- addInst.replaceAllUsesWith (result);
2766
- }
2767
-
2768
2746
void GenSpecificPattern::visitBinaryOperator (BinaryOperator& I)
2769
2747
{
2770
2748
if (I.getOpcode () == Instruction::Or)
@@ -3570,61 +3548,8 @@ void GenSpecificPattern::visitZExtInst(ZExtInst& ZEI)
3570
3548
if (!Cmp)
3571
3549
return ;
3572
3550
3573
- using namespace llvm ::PatternMatch;
3574
- CmpInst::Predicate pred;
3575
- Instruction* I1 = nullptr ;
3576
- Instruction* I2 = nullptr ;
3577
- Instruction* I3 = nullptr ;
3578
- ConstantInt* C1, *C2;
3579
-
3580
- /*
3581
- * from
3582
- * %add = add i32 %0, 1
3583
- * %cmp = icmp eq i32 %0, -1
3584
- * %conv = zext i1 %cmp to i32
3585
- * to
3586
- * %call = call <2 x i32> @llvm.genx.GenISA.uaddc.v2i32.i32(i32 %0, i32 1)
3587
- * %zext.0 = extractelement <2 x i32> %call, i32 0 --> result
3588
- * %zext.1 = extractelement <2 x i32> %call, i32 1 --> carry
3589
- */
3590
- auto addcPattern1 = m_Cmp (pred, m_Instruction (I1), m_ConstantInt (C2));
3591
- auto addcPattern2 = m_Add (m_Instruction (I2), m_ConstantInt (C1));
3592
-
3593
- /*
3594
- * from
3595
- * %add.1 = add i32 %1, %conv
3596
- * %cmp.1 = icmp ult i32 %add.1, %1
3597
- * %conv.1 = zext i1 %cmp.1 to i32
3598
- * to
3599
- * %call.1 = call <2 x i32> @llvm.genx.GenISA.uaddc.v2i32.i32(i32 %1, i32 %zext.1)
3600
- * %zext.2 = extractelement <2 x i32> %call.1, i32 0 --> result
3601
- * %zext.3 = extractelement <2 x i32> %call.1, i32 1 --> carry
3602
- */
3603
- auto addcPattern3 = m_Cmp (pred, m_Add (m_Instruction (I1), m_Instruction (I2)), m_Instruction (I3));
3604
-
3605
- if (match (Cmp, addcPattern1) && pred == CmpInst::Predicate::ICMP_EQ && C2->isMinusOne ())
3606
- {
3607
- for (auto U : I1->users ())
3608
- {
3609
- Instruction* inst = dyn_cast<Instruction>(U);
3610
- if (isActualAddInstr (inst) && match (inst, addcPattern2) && I1 == I2)
3611
- {
3612
- createAddcIntrinsicPattern (ZEI, I1, C1, *inst);
3613
- return ;
3614
- }
3615
- }
3616
- }
3617
- else if (match (Cmp, addcPattern3) && I1 == I3 && pred == CmpInst::Predicate::ICMP_ULT)
3618
- {
3619
- Instruction* inst = dyn_cast<Instruction>(Cmp->getOperand (0 ));
3620
- if (isActualAddInstr (inst))
3621
- {
3622
- createAddcIntrinsicPattern (ZEI, I1, I2, *inst);
3623
- return ;
3624
- }
3625
- }
3626
-
3627
3551
IRBuilder<> Builder (&ZEI);
3552
+
3628
3553
Value* S = Builder.CreateSExt (Cmp, ZEI.getType ());
3629
3554
Value* N = Builder.CreateNeg (S);
3630
3555
ZEI.replaceAllUsesWith (N);
0 commit comments