Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Jan 18, 2024
1 parent 8f8c1b6 commit 4e3dcda
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions enzyme/Enzyme/CacheUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,17 @@ void RemoveRedundantIVs(
// https://github.com/llvm/llvm-project/pull/78199
if (auto addrec = dyn_cast<SCEVAddRecExpr>(S)) {
if (addrec->getLoop()->getHeader() == Header) {
if (auto add_or_mul = dyn_cast<BinaryOperator>(NewIV)) {
if (auto add_or_mul = dyn_cast<BinaryOperator>(NewIV))
if (add_or_mul->getOpcode() == Instruction::Add || add_or_mul->getOpcode() == Instruction::Mul)
{
if (addrec->getNoWrapFlags(llvm::SCEV::FlagNUW))
add_or_mul->setHasNoUnsignedWrap(true);
if (addrec->getNoWrapFlags(llvm::SCEV::FlagNSW))
add_or_mul->setHasNoSignedWrap(true);
for (int i=0; i<2; i++) {
if (auto mul = dyn_cast<BinaryOperator>(add_or_mul->getOperand(i))) {
if (auto mul = dyn_cast<BinaryOperator>(add_or_mul->getOperand(i)))
if (mul->getOpcode() == Instruction::Add || mul->getOpcode() == Instruction::Mul)
{
if (addrec->getNoWrapFlags(llvm::SCEV::FlagNUW))
mul->setHasNoUnsignedWrap(true);
if (addrec->getNoWrapFlags(llvm::SCEV::FlagNSW))
Expand Down

0 comments on commit 4e3dcda

Please sign in to comment.