mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
Reimplement BranchFolding change to avoid tail merging for a 1 instruction
common tail, except when the OptimizeForSize function attribute is present. Radar 7338114. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85441 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e841d2f867
commit
2c04dae715
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#define DEBUG_TYPE "branchfolding"
|
#define DEBUG_TYPE "branchfolding"
|
||||||
#include "BranchFolding.h"
|
#include "BranchFolding.h"
|
||||||
|
#include "llvm/Function.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
@ -465,22 +466,23 @@ unsigned BranchFolder::ComputeSameTails(unsigned CurHash,
|
|||||||
CurMPIter!=B && CurMPIter->first==CurHash;
|
CurMPIter!=B && CurMPIter->first==CurHash;
|
||||||
--CurMPIter) {
|
--CurMPIter) {
|
||||||
for (MPIterator I = prior(CurMPIter); I->first==CurHash ; --I) {
|
for (MPIterator I = prior(CurMPIter); I->first==CurHash ; --I) {
|
||||||
unsigned CommonTailLen = ComputeCommonTailLength(
|
unsigned CommonTailLen = ComputeCommonTailLength(CurMPIter->second,
|
||||||
CurMPIter->second,
|
I->second,
|
||||||
I->second,
|
TrialBBI1, TrialBBI2);
|
||||||
TrialBBI1, TrialBBI2);
|
|
||||||
// If we will have to split a block, there should be at least
|
// If we will have to split a block, there should be at least
|
||||||
// minCommonTailLength instructions in common; if not, at worst
|
// minCommonTailLength instructions in common. Otherwise, if we are
|
||||||
// we will be replacing a fallthrough into the common tail with a
|
// optimizing for code size, 1 instruction in common is enough. At
|
||||||
// branch, which at worst breaks even with falling through into
|
// worst we will be replacing a fallthrough into the common tail with a
|
||||||
// the duplicated common tail, so 1 instruction in common is enough.
|
// branch, which at worst breaks even with falling through into the
|
||||||
// We will always pick a block we do not have to split as the common
|
// duplicated common tail. We will always pick a block we do not have
|
||||||
// tail if there is one.
|
// to split as the common tail if there is one. (Empty blocks will get
|
||||||
// (Empty blocks will get forwarded and need not be considered.)
|
// forwarded and need not be considered.)
|
||||||
|
MachineFunction *MF = CurMPIter->second->getParent();
|
||||||
if (CommonTailLen >= minCommonTailLength ||
|
if (CommonTailLen >= minCommonTailLength ||
|
||||||
(CommonTailLen > 0 &&
|
(CommonTailLen > 0 &&
|
||||||
(TrialBBI1==CurMPIter->second->begin() ||
|
MF->getFunction()->hasFnAttr(Attribute::OptimizeForSize) &&
|
||||||
TrialBBI2==I->second->begin()))) {
|
(TrialBBI1 == CurMPIter->second->begin() ||
|
||||||
|
TrialBBI2 == I->second->begin()))) {
|
||||||
if (CommonTailLen > maxCommonTailLength) {
|
if (CommonTailLen > maxCommonTailLength) {
|
||||||
SameTails.clear();
|
SameTails.clear();
|
||||||
maxCommonTailLength = CommonTailLen;
|
maxCommonTailLength = CommonTailLen;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
@.str = internal constant [48 x i8] c"transformed bounds: (%.2f, %.2f), (%.2f, %.2f)\0A\00" ; <[48 x i8]*> [#uses=1]
|
@.str = internal constant [48 x i8] c"transformed bounds: (%.2f, %.2f), (%.2f, %.2f)\0A\00" ; <[48 x i8]*> [#uses=1]
|
||||||
|
|
||||||
define void @minmax(float* %result) nounwind {
|
define void @minmax(float* %result) nounwind optsize {
|
||||||
entry:
|
entry:
|
||||||
%tmp2 = load float* %result, align 4 ; <float> [#uses=6]
|
%tmp2 = load float* %result, align 4 ; <float> [#uses=6]
|
||||||
%tmp4 = getelementptr float* %result, i32 2 ; <float*> [#uses=5]
|
%tmp4 = getelementptr float* %result, i32 2 ; <float*> [#uses=5]
|
||||||
|
@ -6,7 +6,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
|
|||||||
target triple = "x86_64-apple-darwin8"
|
target triple = "x86_64-apple-darwin8"
|
||||||
%struct.BoundaryAlignment = type { [3 x i8], i8, i16, i16, i8, [2 x i8] }
|
%struct.BoundaryAlignment = type { [3 x i8], i8, i16, i16, i8, [2 x i8] }
|
||||||
|
|
||||||
define void @passing2(i64 %str.0, i64 %str.1, i16 signext %s, i32 %j, i8 signext %c, i16 signext %t, i16 signext %u, i8 signext %d) nounwind {
|
define void @passing2(i64 %str.0, i64 %str.1, i16 signext %s, i32 %j, i8 signext %c, i16 signext %t, i16 signext %u, i8 signext %d) nounwind optsize {
|
||||||
entry:
|
entry:
|
||||||
%str_addr = alloca %struct.BoundaryAlignment ; <%struct.BoundaryAlignment*> [#uses=7]
|
%str_addr = alloca %struct.BoundaryAlignment ; <%struct.BoundaryAlignment*> [#uses=7]
|
||||||
%s_addr = alloca i16 ; <i16*> [#uses=1]
|
%s_addr = alloca i16 ; <i16*> [#uses=1]
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
; RUN: grep {asm-printer} | grep {Number of machine instrs printed} | grep 5
|
; RUN: grep {asm-printer} | grep {Number of machine instrs printed} | grep 5
|
||||||
; RUN: grep {leal 1(\%rsi),} %t
|
; RUN: grep {leal 1(\%rsi),} %t
|
||||||
|
|
||||||
define fastcc zeroext i8 @fullGtU(i32 %i1, i32 %i2) nounwind {
|
define fastcc zeroext i8 @fullGtU(i32 %i1, i32 %i2) nounwind optsize {
|
||||||
entry:
|
entry:
|
||||||
%0 = add i32 %i2, 1 ; <i32> [#uses=1]
|
%0 = add i32 %i2, 1 ; <i32> [#uses=1]
|
||||||
%1 = sext i32 %0 to i64 ; <i64> [#uses=1]
|
%1 = sext i32 %0 to i64 ; <i64> [#uses=1]
|
||||||
|
Loading…
Reference in New Issue
Block a user