diff --git a/test/LLVMIR/freeze-masked-div-rem.ll b/test/LLVMIR/freeze-masked-div-rem.ll index 6d29a2d0f6..0909a0b994 100644 --- a/test/LLVMIR/freeze-masked-div-rem.ll +++ b/test/LLVMIR/freeze-masked-div-rem.ll @@ -15,7 +15,7 @@ if.end: ; CHECK: [[F0:%.*]] = freeze i8 %yy ; CHECK-NEXT: %z = sdiv i8 %x, [[F0:%.*]] %z = sdiv i8 %x, %yy - br i1 %cmp, label %if2.then, label %if2.end + br i1 %cmp, label %if2.then, label %if2.end if2.then: store i8 %z, ptr %v, align 8 @@ -46,7 +46,7 @@ if.end: ; CHECK: [[F1:%.*]] = freeze i8 %bb ; CHECK-NEXT: %zz = sdiv i8 %x, [[F1:%.*]] %zz = sdiv i8 %x, %bb - br i1 %cmp, label %if2.then, label %if2.end + br i1 %cmp, label %if2.then, label %if2.end if2.then: store i8 %z, ptr %v, align 8 @@ -54,4 +54,4 @@ if2.then: if2.end: ret void -} \ No newline at end of file +} diff --git a/third_party/intel/lib/LLVMIR/LLVMIRFreezeMaskedDivRem.cpp b/third_party/intel/lib/LLVMIR/LLVMIRFreezeMaskedDivRem.cpp index b5485e76be..3d860c045b 100644 --- a/third_party/intel/lib/LLVMIR/LLVMIRFreezeMaskedDivRem.cpp +++ b/third_party/intel/lib/LLVMIR/LLVMIRFreezeMaskedDivRem.cpp @@ -6,10 +6,10 @@ using namespace llvm; -static bool processBasicBlock(BasicBlock &BB, PHINode *PhiNode) { +static bool processPhiNode(BasicBlock &BB, PHINode *PhiNode) { if (!any_of(PhiNode->incoming_values(), [](Use &U) { Constant *C = dyn_cast(&U); - return C && C->isNullValue(); + return isa(U) || C && C->isNullValue(); })) { return false; } @@ -34,12 +34,8 @@ static bool runOnFunction(Function &F) { bool Changed = false; for (BasicBlock &BB : F) { - for (Instruction &I : BB) { - if (PHINode *PhiNode = dyn_cast(&I)) { - Changed |= processBasicBlock(BB, PhiNode); - continue; - } - break; + for (PHINode &PhiNode : BB.phis()) { + Changed |= processPhiNode(BB, &PhiNode); } }