Skip to content

Commit 00960f9

Browse files
committed
[AArch64] xor -1 can be mvn, so make it free
1 parent 6cb942c commit 00960f9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ InstructionCost AArch64TTIImpl::getIntImmCostInst(unsigned Opcode, unsigned Idx,
443443
case Instruction::Store:
444444
ImmIdx = 0;
445445
break;
446+
case Instruction::Xor:
447+
if (Idx == 1 && (BitSize == 32 || BitSize == 64) && Imm.isAllOnes())
448+
return TTI::TCC_Free; // xor a, -1 can be folded to MVN
449+
[[fallthrough]];
446450
case Instruction::Add:
447451
case Instruction::Sub:
448452
case Instruction::Mul:
@@ -452,7 +456,6 @@ InstructionCost AArch64TTIImpl::getIntImmCostInst(unsigned Opcode, unsigned Idx,
452456
case Instruction::SRem:
453457
case Instruction::And:
454458
case Instruction::Or:
455-
case Instruction::Xor:
456459
case Instruction::ICmp:
457460
ImmIdx = 1;
458461
break;

0 commit comments

Comments
 (0)