[VPlan] Mark unary ops as not having side-effects (NFC). (#190554)
Mark unary ops (only FNeg current) to neither read nor write memory, similar to binary and cast ops. Should currently be NFC end-to-end.
This commit is contained in:
parent
63231ebfe7
commit
f7cdebb478
@ -1329,7 +1329,8 @@ void VPInstruction::execute(VPTransformState &State) {
|
||||
}
|
||||
|
||||
bool VPInstruction::opcodeMayReadOrWriteFromMemory() const {
|
||||
if (Instruction::isBinaryOp(getOpcode()) || Instruction::isCast(getOpcode()))
|
||||
if (Instruction::isBinaryOp(getOpcode()) ||
|
||||
Instruction::isUnaryOp(getOpcode()) || Instruction::isCast(getOpcode()))
|
||||
return false;
|
||||
switch (getOpcode()) {
|
||||
case Instruction::GetElementPtr:
|
||||
|
||||
@ -1441,6 +1441,16 @@ TEST_F(VPRecipeTest, MayHaveSideEffectsAndMayReadWriteMemory) {
|
||||
EXPECT_FALSE(Recipe.mayWriteToMemory());
|
||||
EXPECT_FALSE(Recipe.mayReadOrWriteMemory());
|
||||
}
|
||||
{
|
||||
VPValue *Op1 = Plan.getConstantInt(Int32, 1);
|
||||
VPInstruction VPInst(Instruction::FNeg, {Op1},
|
||||
VPIRFlags::getDefaultFlags(Instruction::FNeg));
|
||||
VPRecipeBase &Recipe = VPInst;
|
||||
EXPECT_FALSE(Recipe.mayHaveSideEffects());
|
||||
EXPECT_FALSE(Recipe.mayReadFromMemory());
|
||||
EXPECT_FALSE(Recipe.mayWriteToMemory());
|
||||
EXPECT_FALSE(Recipe.mayReadOrWriteMemory());
|
||||
}
|
||||
{
|
||||
VPValue *Op1 = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 1));
|
||||
VPPredInstPHIRecipe Recipe(Op1, {});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user