1 Pull in r198280 from upstream llvm trunk (by Venkatraman Govindaraju):
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.
5 Introduced here: http://svnweb.freebsd.org/changeset/base/262261
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 {
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.
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))>;
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
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
38 declare i32 @llvm.ctpop.i32(i32)
44 +; V9: srl %o0, 0, %o0
46 +; V9-NEXT: popc %o0, %o0
48 +; SPARC64-LABEL: test
49 +; SPARC64: srl %o0, 0, %o0
51 +; SPARC64: popc %o0, %o0
53 define i32 @test(i32 %X) {
54 %Y = call i32 @llvm.ctpop.i32( i32 %X ) ; <i32> [#uses=1]