1263320SdimPull in r198280 from upstream llvm trunk (by Venkatraman Govindaraju): 2263320Sdim 3263320Sdim [SparcV9]: Use SRL instead of SLL to clear top 32-bits in ctpop:i32. SLL does not clear top 32 bit, only SRL does. 4263320Sdim 5269012SemasteIntroduced here: http://svnweb.freebsd.org/changeset/base/262261 6263320Sdim 7263320SdimIndex: lib/Target/Sparc/SparcInstrInfo.td 8263320Sdim=================================================================== 9263320Sdim--- lib/Target/Sparc/SparcInstrInfo.td 10263320Sdim+++ lib/Target/Sparc/SparcInstrInfo.td 11263320Sdim@@ -967,13 +967,13 @@ let Predicates = [HasV9] in { 12263320Sdim } 13263320Sdim 14263320Sdim // POPCrr - This does a ctpop of a 64-bit register. As such, we have to clear 15263320Sdim-// the top 32-bits before using it. To do this clearing, we use a SLLri X,0. 16263320Sdim+// the top 32-bits before using it. To do this clearing, we use a SRLri X,0. 17263320Sdim let rs1 = 0 in 18263320Sdim def POPCrr : F3_1<2, 0b101110, 19263320Sdim (outs IntRegs:$dst), (ins IntRegs:$src), 20263320Sdim "popc $src, $dst", []>, Requires<[HasV9]>; 21263320Sdim def : Pat<(ctpop i32:$src), 22263320Sdim- (POPCrr (SLLri $src, 0))>; 23263320Sdim+ (POPCrr (SRLri $src, 0))>; 24263320Sdim 25263320Sdim //===----------------------------------------------------------------------===// 26263320Sdim // Non-Instruction Patterns 27263320SdimIndex: test/CodeGen/SPARC/ctpop.ll 28263320Sdim=================================================================== 29263320Sdim--- test/CodeGen/SPARC/ctpop.ll 30263320Sdim+++ test/CodeGen/SPARC/ctpop.ll 31263320Sdim@@ -1,8 +1,22 @@ 32263320Sdim-; RUN: llc < %s -march=sparc -mattr=-v9 | not grep popc 33263320Sdim-; RUN: llc < %s -march=sparc -mattr=+v9 | grep popc 34263320Sdim+; RUN: llc < %s -march=sparc -mattr=-v9 | FileCheck %s -check-prefix=V8 35263320Sdim+; RUN: llc < %s -march=sparc -mattr=+v9 | FileCheck %s -check-prefix=V9 36263320Sdim+; RUN: llc < %s -march=sparcv9 | FileCheck %s -check-prefix=SPARC64 37263320Sdim 38263320Sdim declare i32 @llvm.ctpop.i32(i32) 39263320Sdim 40263320Sdim+; V8-LABEL: test 41263320Sdim+; V8-NOT : popc 42263320Sdim+ 43263320Sdim+; V9-LABEL: test 44263320Sdim+; V9: srl %o0, 0, %o0 45263320Sdim+; V9-NEXT: jmp %o7+8 46263320Sdim+; V9-NEXT: popc %o0, %o0 47263320Sdim+ 48263320Sdim+; SPARC64-LABEL: test 49263320Sdim+; SPARC64: srl %o0, 0, %o0 50263320Sdim+; SPARC64: jmp %o7+8 51263320Sdim+; SPARC64: popc %o0, %o0 52263320Sdim+ 53263320Sdim define i32 @test(i32 %X) { 54263320Sdim %Y = call i32 @llvm.ctpop.i32( i32 %X ) ; <i32> [#uses=1] 55263320Sdim ret i32 %Y 56