Skip to content

Commit 82814f6

Browse files
author
Michael Kuperstein
committedAug 11, 2015
Allow PeepholeOptimizer to fold a few more cases
The condition for clearing the folding candidate list was clamped together with the "uninteresting instruction" condition. This is too conservative, e.g. we don't need to clear the list when encountering an IMPLICIT_DEF. Differential Revision: http://reviews.llvm.org/D11591 llvm-svn: 244577
1 parent c186ac7 commit 82814f6

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed
 

‎llvm/lib/CodeGen/PeepholeOptimizer.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -1236,14 +1236,13 @@ bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
12361236

12371237
// If there exists an instruction which belongs to the following
12381238
// categories, we will discard the load candidates.
1239+
if (MI->mayStore() || MI->isCall() || MI->hasUnmodeledSideEffects())
1240+
FoldAsLoadDefCandidates.clear();
1241+
12391242
if (MI->isPosition() || MI->isPHI() || MI->isImplicitDef() ||
12401243
MI->isKill() || MI->isInlineAsm() ||
1241-
MI->hasUnmodeledSideEffects()) {
1242-
FoldAsLoadDefCandidates.clear();
1244+
MI->hasUnmodeledSideEffects())
12431245
continue;
1244-
}
1245-
if (MI->mayStore() || MI->isCall())
1246-
FoldAsLoadDefCandidates.clear();
12471246

12481247
if ((isUncoalescableCopy(*MI) &&
12491248
optimizeUncoalescableCopy(MI, LocalMIs)) ||

‎llvm/test/CodeGen/X86/avx-cvt.ll

+1-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ define float @funcD(i64* nocapture %e) nounwind uwtable readonly ssp {
113113
define void @fpext() nounwind uwtable {
114114
; CHECK-LABEL: fpext:
115115
; CHECK: # BB#0:
116-
; CHECK-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
117-
; CHECK-NEXT: vcvtss2sd %xmm0, %xmm0, %xmm0
116+
; CHECK-NEXT: vcvtss2sd -{{[0-9]+}}(%rsp), %xmm0, %xmm0
118117
; CHECK-NEXT: vmovsd %xmm0, -{{[0-9]+}}(%rsp)
119118
; CHECK-NEXT: retq
120119
%f = alloca float, align 4

‎llvm/test/CodeGen/X86/shift-bmi2.ll

+9-11
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ entry:
3030
%x = load i32, i32* %p
3131
%shl = shl i32 %x, %shamt
3232
; BMI2: shl32p
33-
; Source order scheduling prevents folding, rdar:14208996.
34-
; BMI2: shlxl %{{.+}}, %{{.+}}, %{{.+}}
33+
; BMI2: shlxl %{{.+}}, ({{.+}}), %{{.+}}
3534
; BMI2: ret
3635
; BMI264: shl32p
37-
; BMI264: shlxl %{{.+}}, %{{.+}}, %{{.+}}
36+
; BMI264: shlxl %{{.+}}, ({{.+}}), %{{.+}}
3837
; BMI264: ret
3938
ret i32 %shl
4039
}
@@ -75,7 +74,7 @@ entry:
7574
%x = load i64, i64* %p
7675
%shl = shl i64 %x, %shamt
7776
; BMI264: shl64p
78-
; BMI264: shlxq %{{.+}}, %{{.+}}, %{{.+}}
77+
; BMI264: shlxq %{{.+}}, ({{.+}}), %{{.+}}
7978
; BMI264: ret
8079
ret i64 %shl
8180
}
@@ -107,11 +106,10 @@ entry:
107106
%x = load i32, i32* %p
108107
%shl = lshr i32 %x, %shamt
109108
; BMI2: lshr32p
110-
; Source order scheduling prevents folding, rdar:14208996.
111-
; BMI2: shrxl %{{.+}}, %{{.+}}, %{{.+}}
109+
; BMI2: shrxl %{{.+}}, ({{.+}}), %{{.+}}
112110
; BMI2: ret
113111
; BMI264: lshr32p
114-
; BMI264: shrxl %{{.+}}, %{{.+}}, %{{.+}}
112+
; BMI264: shrxl %{{.+}}, ({{.+}}), %{{.+}}
115113
; BMI264: ret
116114
ret i32 %shl
117115
}
@@ -130,7 +128,7 @@ entry:
130128
%x = load i64, i64* %p
131129
%shl = lshr i64 %x, %shamt
132130
; BMI264: lshr64p
133-
; BMI264: shrxq %{{.+}}, %{{.+}}, %{{.+}}
131+
; BMI264: shrxq %{{.+}}, ({{.+}}), %{{.+}}
134132
; BMI264: ret
135133
ret i64 %shl
136134
}
@@ -153,10 +151,10 @@ entry:
153151
%shl = ashr i32 %x, %shamt
154152
; BMI2: ashr32p
155153
; Source order scheduling prevents folding, rdar:14208996.
156-
; BMI2: sarxl %{{.+}}, %{{.+}}, %{{.+}}
154+
; BMI2: sarxl %{{.+}}, ({{.+}}), %{{.+}}
157155
; BMI2: ret
158156
; BMI264: ashr32p
159-
; BMI264: sarxl %{{.+}}, %{{.+}}, %{{.+}}
157+
; BMI264: sarxl %{{.+}}, ({{.+}}), %{{.+}}
160158
; BMI264: ret
161159
ret i32 %shl
162160
}
@@ -175,7 +173,7 @@ entry:
175173
%x = load i64, i64* %p
176174
%shl = ashr i64 %x, %shamt
177175
; BMI264: ashr64p
178-
; BMI264: sarxq %{{.+}}, %{{.+}}, %{{.+}}
176+
; BMI264: sarxq %{{.+}}, ({{.+}}), %{{.+}}
179177
; BMI264: ret
180178
ret i64 %shl
181179
}

0 commit comments

Comments
 (0)
Please sign in to comment.