[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:
Florian Hahn 2026-04-06 09:05:38 +01:00 committed by GitHub
parent 63231ebfe7
commit f7cdebb478
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -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:

View File

@ -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, {});