Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp =================================================================== --- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -517,7 +517,11 @@ MaskAndBranchFoldingIsLegal = true; EnableExtLdPromotion = true; + // Set required alignment. setMinFunctionAlignment(2); + // Set preferred alignments. + setPrefFunctionAlignment(STI.getPrefFunctionAlignment()); + setPrefLoopAlignment(STI.getPrefLoopAlignment()); setHasExtractBitsInsn(true); Index: llvm/lib/Target/AArch64/AArch64Subtarget.h =================================================================== --- llvm/lib/Target/AArch64/AArch64Subtarget.h +++ llvm/lib/Target/AArch64/AArch64Subtarget.h @@ -86,6 +86,8 @@ uint16_t PrefetchDistance = 0; uint16_t MinPrefetchStride = 1; unsigned MaxPrefetchIterationsAhead = UINT_MAX; + unsigned PrefFunctionAlignment = 0; + unsigned PrefLoopAlignment = 0; // ReserveX18 - X18 is not available as a general purpose register. bool ReserveX18; @@ -195,6 +197,8 @@ unsigned getMaxPrefetchIterationsAhead() const { return MaxPrefetchIterationsAhead; } + unsigned getPrefFunctionAlignment() const { return PrefFunctionAlignment; } + unsigned getPrefLoopAlignment() const { return PrefLoopAlignment; } /// CPU has TBI (top byte of addresses is ignored during HW address /// translation) and OS enables it. Index: llvm/lib/Target/AArch64/AArch64Subtarget.cpp =================================================================== --- llvm/lib/Target/AArch64/AArch64Subtarget.cpp +++ llvm/lib/Target/AArch64/AArch64Subtarget.cpp @@ -63,14 +63,17 @@ case CortexA57: MaxInterleaveFactor = 4; break; + case ExynosM1: + PrefFunctionAlignment = 4; + PrefLoopAlignment = 3; + break; case Kryo: MaxInterleaveFactor = 4; VectorInsertExtractBaseCost = 2; break; - case Others: break; case CortexA35: break; case CortexA53: break; - case ExynosM1: break; + case Others: break; } }