Skip to content

Commit 1c7bc51

Browse files
agrabezhigcbot
authored andcommitted
Enabling CustomPasses for OpenCL
Conservatively clear the NSW NUW flags, since they may not be preserved by the reassociation on CustomSafeOptPass
1 parent 272ad43 commit 1c7bc51

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

IGC/AdaptorOCL/DriverInfoOCL.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace TC
4040
bool enableVISAPreRAScheduler() const override { return true; }
4141

4242
bool NeedWAToTransformA32MessagesToA64() const override{ return true; }
43-
bool WADisableCustomPass() const override { return true; }
43+
bool WADisableCustomPass() const override { return false; }
4444
bool WAEnableMemOpt2ForOCL() const override { return true; }
4545

4646
unsigned int GetLoopUnrollThreshold() const override { return 1280; }

IGC/Compiler/CustomSafeOptPass.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,14 @@ void CustomSafeOptPass::visitBinaryOperator(BinaryOperator& I)
13791379
if (nextInst->getOperand(i) == &I)
13801380
{
13811381
Value* newAdd = BinaryOperator::CreateAdd(src0imm ? I.getOperand(1) : I.getOperand(0), nextInst->getOperand(1 - i), "", nextInst);
1382+
1383+
// Conservatively clear the NSW NUW flags, since they may not be
1384+
// preserved by the reassociation.
1385+
bool IsNUW = isa<OverflowingBinaryOperator>(I) && I.hasNoUnsignedWrap() && nextInst->hasNoUnsignedWrap();
1386+
cast<BinaryOperator>(newAdd)->setHasNoUnsignedWrap(IsNUW);
1387+
nextInst->setHasNoUnsignedWrap(IsNUW);
1388+
nextInst->setHasNoSignedWrap(false);
1389+
13821390
nextInst->setOperand(0, newAdd);
13831391
nextInst->setOperand(1, I.getOperand(src0imm ? 0 : 1));
13841392
break;

0 commit comments

Comments
 (0)