Skip to content

Commit 7a8ed97

Browse files
committed
For PR9438:
--- Merging r127350 into '.': D test/CodeGen/X86/2009-03-11-CoalescerBug.ll --- Merging r127351 into '.': A test/CodeGen/X86/2011-03-09-Physreg-Coalescing.ll U test/CodeGen/X86/fold-pcmpeqd-2.ll U lib/CodeGen/SimpleRegisterCoalescing.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_29@127384 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent ec2be4d commit 7a8ed97

File tree

4 files changed

+37
-91
lines changed

4 files changed

+37
-91
lines changed

lib/CodeGen/SimpleRegisterCoalescing.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,9 +1038,7 @@ bool SimpleRegisterCoalescing::JoinCopy(CopyRec &TheCopy, bool &Again) {
10381038
const TargetRegisterClass *RC = mri_->getRegClass(CP.getSrcReg());
10391039
unsigned Threshold = allocatableRCRegs_[RC].count() * 2;
10401040
unsigned Length = li_->getApproximateInstructionCount(JoinVInt);
1041-
if (Length > Threshold &&
1042-
std::distance(mri_->use_nodbg_begin(CP.getSrcReg()),
1043-
mri_->use_nodbg_end()) * Threshold < Length) {
1041+
if (Length > Threshold) {
10441042
// Before giving up coalescing, if definition of source is defined by
10451043
// trivial computation, try rematerializing it.
10461044
if (!CP.isFlipped() &&

test/CodeGen/X86/2009-03-11-CoalescerBug.ll

Lines changed: 0 additions & 85 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: llc -mcpu=yonah < %s
2+
; PR9438
3+
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
4+
target triple = "i386-unknown-freebsd9.0"
5+
6+
; The 'call fastcc' ties down %ebx, %ecx, and %edx.
7+
; A MUL8r ties down %al, leaving no GR32_ABCD registers available.
8+
; The coalescer can easily overallocate physical registers,
9+
; and register allocation fails.
10+
11+
declare fastcc i8* @save_string(i8* %d, i8* nocapture %s) nounwind
12+
13+
define i32 @cvtchar(i8* nocapture %sp) nounwind {
14+
%temp.i = alloca [2 x i8], align 1
15+
%tmp1 = load i8* %sp, align 1
16+
%div = udiv i8 %tmp1, 10
17+
%rem = urem i8 %div, 10
18+
%arrayidx.i = getelementptr inbounds [2 x i8]* %temp.i, i32 0, i32 0
19+
store i8 %rem, i8* %arrayidx.i, align 1
20+
%call.i = call fastcc i8* @save_string(i8* %sp, i8* %arrayidx.i) nounwind
21+
ret i32 undef
22+
}

test/CodeGen/X86/fold-pcmpeqd-2.ll

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
; RUN: llc < %s -mtriple=i386-apple-darwin -mcpu=yonah | not grep pcmpeqd
2-
; RUN: llc < %s -mtriple=x86_64-apple-darwin | grep pcmpeqd | count 1
1+
; RUN: llc < %s -mtriple=i386-apple-darwin -mcpu=yonah | FileCheck %s
2+
; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
33

4-
; This testcase should need to spill the -1 value on x86-32,
4+
; This testcase should need to spill the -1 value on both x86-32 and x86-64,
55
; so it shouldn't use pcmpeqd to materialize an all-ones vector; it
66
; should use a constant-pool load instead.
77

8+
; Constant pool all-ones vector:
9+
; CHECK: .long 4294967295
10+
; CHECK-NEXT: .long 4294967295
11+
; CHECK-NEXT: .long 4294967295
12+
; CHECK-NEXT: .long 4294967295
13+
14+
; No pcmpeqd instructions, everybody uses the constant pool.
15+
; CHECK: program_1:
16+
; CHECK-NOT: pcmpeqd
17+
818
%struct.__ImageExecInfo = type <{ <4 x i32>, <4 x float>, <2 x i64>, i8*, i8*, i8*, i32, i32, i32, i32, i32 }>
919
%struct._cl_image_format_t = type <{ i32, i32, i32 }>
1020
%struct._image2d_t = type <{ i8*, %struct._cl_image_format_t, i32, i32, i32, i32, i32, i32 }>
@@ -57,6 +67,7 @@ forbody: ; preds = %forcond
5767
%bitcast11.i6 = bitcast <4 x float> %tmp83 to <4 x i32> ; <<4 x i32>> [#uses=1]
5868
%not.i7 = xor <4 x i32> zeroinitializer, < i32 -1, i32 -1, i32 -1, i32 -1 > ; <<4 x i32>> [#uses=1]
5969
%andnps.i8 = and <4 x i32> %bitcast11.i6, %not.i7 ; <<4 x i32>> [#uses=1]
70+
call void null(<4 x float> %mul313, <4 x float> %cmpunord.i11, <4 x float> %tmp83, <4 x float> zeroinitializer, %struct.__ImageExecInfo* null, <4 x i32> zeroinitializer) nounwind
6071
%orps.i9 = or <4 x i32> %andnps.i8, %andps.i5 ; <<4 x i32>> [#uses=1]
6172
%bitcast17.i10 = bitcast <4 x i32> %orps.i9 to <4 x float> ; <<4 x float>> [#uses=1]
6273
%tmp84 = call <4 x float> @llvm.x86.sse.min.ps(<4 x float> %mul313, <4 x float> zeroinitializer) nounwind ; <<4 x float>> [#uses=1]

0 commit comments

Comments
 (0)