Skip to content

Commit 0f73eb1

Browse files
committed
LLVM freeze instruction between mask and div 3/?
1 parent b6289c2 commit 0f73eb1

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

third_party/intel/lib/LLVMIR/LLVMIRFreezeMaskedDivRem.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ static bool processPhiNode(PHINode *phiNode, BasicBlock& BB) {
1616
return false;
1717
});
1818

19+
bool Changed = false;
1920
if (phiHasNullValue) {
2021
auto FindUse = llvm::find_if(phiNode->users(), [](auto *U) {
2122
auto *Use = cast<Instruction>(U);
@@ -27,13 +28,15 @@ static bool processPhiNode(PHINode *phiNode, BasicBlock& BB) {
2728
return false;
2829
}
2930
auto *Use = cast<Instruction>(*FindUse);
30-
assert()
31-
llvm::errs() << "Got our user! " << *Use << "\n";
32-
33-
// insert freeze between phi and sdiv
34-
//
31+
if (Use->getOperand(1) == phiNode) {
32+
llvm::errs() << "Got our user! " << *Use << "\n";
33+
llvm::errs() << "Operand 1: " << *Use->getOperand(1) << "\n";
34+
auto *freezePhi = new FreezeInst(phiNode, phiNode->getName() + ".frozen", Use->getIterator());
35+
Use->setOperand(1, freezePhi);
36+
Changed = true;
37+
}
3538
}
36-
return false;
39+
return Changed;
3740
}
3841

3942
static bool runOnFunction(Function& F, const TargetTransformInfo &TTI,

0 commit comments

Comments
 (0)