Index: lib/Target/AArch64/AArch64TargetTransformInfo.cpp =================================================================== --- lib/Target/AArch64/AArch64TargetTransformInfo.cpp +++ lib/Target/AArch64/AArch64TargetTransformInfo.cpp @@ -45,6 +45,9 @@ if (Val == 0 || AArch64_AM::isLogicalImmediate(Val, 64)) return 0; + if (AArch64_AM::isAnyMOVWMovAlias(Val, 64)) + return 1; + if (Val < 0) Val = ~Val; @@ -74,8 +77,7 @@ int64_t Val = Tmp.getSExtValue(); Cost += getIntImmCost(Val); } - // We need at least one instruction to materialze the constant. - return std::max(1, Cost); + return Cost; } int AArch64TTIImpl::getIntImmCost(unsigned Opcode, unsigned Idx,