[llvm] r198280 - [SparcV9]: Use SRL instead of SLL to clear top 32-bits in ctpop:i32. SLL does not clear top 32 bit, only SRL does.
Venkatraman Govindaraju
venkatra at cs.wisc.edu
Wed Jan 1 11:00:10 PST 2014
Author: venkatra
Date: Wed Jan 1 13:00:10 2014
New Revision: 198280
URL: http://llvm.org/viewvc/llvm-project?rev=198280&view=rev
Log:
[SparcV9]: Use SRL instead of SLL to clear top 32-bits in ctpop:i32. SLL does not clear top 32 bit, only SRL does.
Modified:
llvm/trunk/lib/Target/Sparc/SparcInstrInfo.td
llvm/trunk/test/CodeGen/SPARC/ctpop.ll
Modified: llvm/trunk/lib/Target/Sparc/SparcInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcInstrInfo.td?rev=198280&r1=198279&r2=198280&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/SparcInstrInfo.td (original)
+++ llvm/trunk/lib/Target/Sparc/SparcInstrInfo.td Wed Jan 1 13:00:10 2014
@@ -967,13 +967,13 @@ let Predicates = [HasV9] in {
}
// POPCrr - This does a ctpop of a 64-bit register. As such, we have to clear
-// the top 32-bits before using it. To do this clearing, we use a SLLri X,0.
+// the top 32-bits before using it. To do this clearing, we use a SRLri X,0.
let rs1 = 0 in
def POPCrr : F3_1<2, 0b101110,
(outs IntRegs:$dst), (ins IntRegs:$src),
"popc $src, $dst", []>, Requires<[HasV9]>;
def : Pat<(ctpop i32:$src),
- (POPCrr (SLLri $src, 0))>;
+ (POPCrr (SRLri $src, 0))>;
//===----------------------------------------------------------------------===//
// Non-Instruction Patterns
Modified: llvm/trunk/test/CodeGen/SPARC/ctpop.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SPARC/ctpop.ll?rev=198280&r1=198279&r2=198280&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/SPARC/ctpop.ll (original)
+++ llvm/trunk/test/CodeGen/SPARC/ctpop.ll Wed Jan 1 13:00:10 2014
@@ -1,8 +1,22 @@
-; RUN: llc < %s -march=sparc -mattr=-v9 | not grep popc
-; RUN: llc < %s -march=sparc -mattr=+v9 | grep popc
+; RUN: llc < %s -march=sparc -mattr=-v9 | FileCheck %s -check-prefix=V8
+; RUN: llc < %s -march=sparc -mattr=+v9 | FileCheck %s -check-prefix=V9
+; RUN: llc < %s -march=sparcv9 | FileCheck %s -check-prefix=SPARC64
declare i32 @llvm.ctpop.i32(i32)
+; V8-LABEL: test
+; V8-NOT : popc
+
+; V9-LABEL: test
+; V9: srl %o0, 0, %o0
+; V9-NEXT: jmp %o7+8
+; V9-NEXT: popc %o0, %o0
+
+; SPARC64-LABEL: test
+; SPARC64: srl %o0, 0, %o0
+; SPARC64: jmp %o7+8
+; SPARC64: popc %o0, %o0
+
define i32 @test(i32 %X) {
%Y = call i32 @llvm.ctpop.i32( i32 %X ) ; <i32> [#uses=1]
ret i32 %Y
More information about the llvm-commits
mailing list