]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/patches/patch-r262261-llvm-r198280-sparc.diff
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / patches / patch-r262261-llvm-r198280-sparc.diff
1 Pull in r198280 from upstream llvm trunk (by Venkatraman Govindaraju):
2
3   [SparcV9]: Use SRL instead of SLL to clear top 32-bits in ctpop:i32. SLL does not clear top 32 bit, only SRL does.
4
5 Introduced here: http://svnweb.freebsd.org/changeset/base/262261
6
7 Index: lib/Target/Sparc/SparcInstrInfo.td
8 ===================================================================
9 --- lib/Target/Sparc/SparcInstrInfo.td
10 +++ lib/Target/Sparc/SparcInstrInfo.td
11 @@ -967,13 +967,13 @@ let Predicates = [HasV9] in {
12  }
13  
14  // POPCrr - This does a ctpop of a 64-bit register.  As such, we have to clear
15 -// the top 32-bits before using it.  To do this clearing, we use a SLLri X,0.
16 +// the top 32-bits before using it.  To do this clearing, we use a SRLri X,0.
17  let rs1 = 0 in
18    def POPCrr : F3_1<2, 0b101110,
19                      (outs IntRegs:$dst), (ins IntRegs:$src),
20                      "popc $src, $dst", []>, Requires<[HasV9]>;
21  def : Pat<(ctpop i32:$src),
22 -          (POPCrr (SLLri $src, 0))>;
23 +          (POPCrr (SRLri $src, 0))>;
24  
25  //===----------------------------------------------------------------------===//
26  // Non-Instruction Patterns
27 Index: test/CodeGen/SPARC/ctpop.ll
28 ===================================================================
29 --- test/CodeGen/SPARC/ctpop.ll
30 +++ test/CodeGen/SPARC/ctpop.ll
31 @@ -1,8 +1,22 @@
32 -; RUN: llc < %s -march=sparc -mattr=-v9 | not grep popc
33 -; RUN: llc < %s -march=sparc -mattr=+v9 | grep popc
34 +; RUN: llc < %s -march=sparc -mattr=-v9 | FileCheck %s -check-prefix=V8
35 +; RUN: llc < %s -march=sparc -mattr=+v9 | FileCheck %s -check-prefix=V9
36 +; RUN: llc < %s -march=sparcv9 | FileCheck %s -check-prefix=SPARC64
37  
38  declare i32 @llvm.ctpop.i32(i32)
39  
40 +; V8-LABEL: test
41 +; V8-NOT  : popc
42 +
43 +; V9-LABEL: test
44 +; V9:       srl %o0, 0, %o0
45 +; V9-NEXT:  jmp %o7+8
46 +; V9-NEXT:  popc %o0, %o0
47 +
48 +; SPARC64-LABEL: test
49 +; SPARC64:       srl %o0, 0, %o0
50 +; SPARC64:       jmp %o7+8
51 +; SPARC64:       popc %o0, %o0
52 +
53  define i32 @test(i32 %X) {
54          %Y = call i32 @llvm.ctpop.i32( i32 %X )         ; <i32> [#uses=1]
55          ret i32 %Y