Skip to content

Commit 1326485

Browse files
sys-igcigcbot
authored andcommitted
Changes in code.
1 parent cf76b17 commit 1326485

File tree

3 files changed

+0
-284
lines changed

3 files changed

+0
-284
lines changed

IGC/Compiler/CustomSafeOptPass.cpp

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -120,79 +120,6 @@ void CustomSafeOptPass::visitInstruction(Instruction& I)
120120
// nothing
121121
}
122122

123-
// Searches the following pattern
124-
// %1 = icmp eq i32 %cmpop1, %cmpop2
125-
// %2 = xor i1 %1, true
126-
// ...
127-
// %3 = select i1 %1, i8 0, i8 1
128-
//
129-
// And changes it to:
130-
// %1 = icmp ne i32 %cmpop1, %cmpop2
131-
// ...
132-
// %3 = select i1 %1, i8 1, i8 0
133-
//
134-
// and
135-
//
136-
// Searches the following pattern
137-
// %1 = icmp ule i32 %cmpop1, %cmpop2
138-
// %2 = xor i1 %1, true
139-
// br i1 %1, label %3, label %4
140-
//
141-
// And changes it to:
142-
// %1 = icmp ugt i32 %cmpop1, %cmpop2
143-
// br i1 %1, label %4, label %3
144-
//
145-
// This optimization combines statements regardless of the predicate.
146-
// It will also work if the icmp instruction does not have users, except for the xor, select or branch instruction.
147-
void CustomSafeOptPass::visitXor(Instruction& XorInstr) {
148-
using namespace llvm::PatternMatch;
149-
150-
CmpInst::Predicate Pred;
151-
auto XorPattern = m_c_Xor(m_ICmp(Pred, m_Value(), m_Value()), m_SpecificInt(1));
152-
if (!match(&XorInstr, XorPattern)) {
153-
return;
154-
}
155-
156-
Value* XorOp0 = XorInstr.getOperand(0);
157-
Value* XorOp1 = XorInstr.getOperand(1);
158-
auto ICmpInstr = cast<Instruction>(isa<ICmpInst>(XorOp0) ? XorOp0 : XorOp1);
159-
160-
llvm::SmallVector<Instruction*, 4> UsersList;
161-
162-
for (auto U : ICmpInstr->users()) {
163-
if (isa<SelectInst>(U) || isa<BranchInst>(U)) {
164-
UsersList.push_back(cast<Instruction>(U));
165-
}
166-
else if (U != &XorInstr) {
167-
return;
168-
}
169-
}
170-
171-
IRBuilder<> builder(ICmpInstr);
172-
auto NegatedCmpPred = cast<ICmpInst>(ICmpInstr)->getInversePredicate();
173-
auto NewCmp = cast<ICmpInst>(builder.CreateICmp(NegatedCmpPred, ICmpInstr->getOperand(0), ICmpInstr->getOperand(1)));
174-
175-
for (auto I : UsersList) {
176-
if (SelectInst* S = dyn_cast<SelectInst>(I)) {
177-
S->swapProfMetadata();
178-
Value* TrueVal = S->getTrueValue();
179-
Value* FalseVal = S->getFalseValue();
180-
S->setTrueValue(FalseVal);
181-
S->setFalseValue(TrueVal);
182-
}
183-
else {
184-
IGC_ASSERT(isa<BranchInst>(I));
185-
BranchInst* B = cast<BranchInst>(I);
186-
B->swapSuccessors();
187-
}
188-
}
189-
190-
XorInstr.replaceAllUsesWith(NewCmp);
191-
ICmpInstr->replaceAllUsesWith(NewCmp);
192-
XorInstr.eraseFromParent();
193-
ICmpInstr->eraseFromParent();
194-
}
195-
196123
// Searches for following pattern:
197124
// %cmp = icmp slt i32 %x, %y
198125
// %cond.not = xor i1 %cond, true

IGC/Compiler/CustomSafeOptPass.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ namespace IGC
7070
void dp4WithIdentityMatrix(llvm::ExtractElementInst& I);
7171
bool isIdentityMatrix(llvm::ExtractElementInst& I);
7272
void visitAnd(llvm::BinaryOperator& I);
73-
void visitXor(llvm::Instruction& XorInstr);
7473

7574
//
7675
// IEEE Floating point arithmetic is not associative. Any pattern

IGC/Compiler/tests/CustomSafeOptPass/combine_icmp_with_xor.ll

Lines changed: 0 additions & 210 deletions
This file was deleted.

0 commit comments

Comments
 (0)