[llvm] 0152f01 - Reapply "[RISCVGatherScatterLowering] Minor code cleanup [NFC]"
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Fri May 12 17:33:15 PDT 2023
Author: Philip Reames
Date: 2023-05-12T17:33:07-07:00
New Revision: 0152f013f6256aaeebb6c98b123ab958d931018b
URL: https://github.com/llvm/llvm-project/commit/0152f013f6256aaeebb6c98b123ab958d931018b
DIFF: https://github.com/llvm/llvm-project/commit/0152f013f6256aaeebb6c98b123ab958d931018b.diff
LOG: Reapply "[RISCVGatherScatterLowering] Minor code cleanup [NFC]"
This was reverted in 4e84149c0aea0e9f16c51cc92f50d90992b13d57 due to a problem report which has been confirmed to be misattributed.
Original commit message:
Use a switch to avoid repeat tests on the opcode, and factor out some common code out of another switch. (Not all branches had both common bits, but the one which didn't left the values unchanged and their starting value is the respective operand - so storing it back is a nop.)
Added:
Modified:
llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp b/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
index ceefc261090b..5e527c60ca5f 100644
--- a/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
@@ -235,16 +235,21 @@ bool RISCVGatherScatterLowering::matchStridedRecurrence(Value *Index, Loop *L,
if (!BO)
return false;
- if (BO->getOpcode() != Instruction::Add &&
- BO->getOpcode() != Instruction::Or &&
- BO->getOpcode() != Instruction::Mul &&
- BO->getOpcode() != Instruction::Shl)
- return false;
-
- // We need to be able to treat Or as Add.
- if (BO->getOpcode() == Instruction::Or &&
- !haveNoCommonBitsSet(BO->getOperand(0), BO->getOperand(1), *DL))
+ switch (BO->getOpcode()) {
+ default:
return false;
+ case Instruction::Or:
+ // We need to be able to treat Or as Add.
+ if (!haveNoCommonBitsSet(BO->getOperand(0), BO->getOperand(1), *DL))
+ return false;
+ break;
+ case Instruction::Add:
+ break;
+ case Instruction::Shl:
+ break;
+ case Instruction::Mul:
+ break;
+ }
// We should have one operand in the loop and one splat.
Value *OtherOp;
@@ -298,7 +303,6 @@ bool RISCVGatherScatterLowering::matchStridedRecurrence(Value *Index, Loop *L,
Start = SplatOp;
else
Start = Builder.CreateAdd(Start, SplatOp, "start");
- BasePtr->setIncomingValue(StartBlock, Start);
break;
}
case Instruction::Mul: {
@@ -313,8 +317,6 @@ bool RISCVGatherScatterLowering::matchStridedRecurrence(Value *Index, Loop *L,
Stride = SplatOp;
else
Stride = Builder.CreateMul(Stride, SplatOp, "stride");
- Inc->setOperand(StepIndex, Step);
- BasePtr->setIncomingValue(StartBlock, Start);
break;
}
case Instruction::Shl: {
@@ -323,12 +325,12 @@ bool RISCVGatherScatterLowering::matchStridedRecurrence(Value *Index, Loop *L,
Start = Builder.CreateShl(Start, SplatOp, "start");
Step = Builder.CreateShl(Step, SplatOp, "step");
Stride = Builder.CreateShl(Stride, SplatOp, "stride");
- Inc->setOperand(StepIndex, Step);
- BasePtr->setIncomingValue(StartBlock, Start);
break;
}
}
+ Inc->setOperand(StepIndex, Step);
+ BasePtr->setIncomingValue(StartBlock, Start);
return true;
}
More information about the llvm-commits
mailing list