1 Pull in r200141 from upstream llvm trunk (by Jakob Stoklund Olesen):
3 Clean up the Legal/Expand logic for SPARC popc.
5 Introduced here: http://svnweb.freebsd.org/changeset/base/262261
7 Index: lib/Target/Sparc/SparcSubtarget.cpp
8 ===================================================================
9 --- lib/Target/Sparc/SparcSubtarget.cpp
10 +++ lib/Target/Sparc/SparcSubtarget.cpp
11 @@ -41,6 +41,10 @@ SparcSubtarget::SparcSubtarget(const std::string &
13 // Parse features string.
14 ParseSubtargetFeatures(CPUName, FS);
16 + // Popc is a v9-only instruction.
22 Index: lib/Target/Sparc/SparcISelLowering.cpp
23 ===================================================================
24 --- lib/Target/Sparc/SparcISelLowering.cpp
25 +++ lib/Target/Sparc/SparcISelLowering.cpp
26 @@ -1461,8 +1461,8 @@ SparcTargetLowering::SparcTargetLowering(TargetMac
27 setOperationAction(ISD::BR_CC, MVT::i64, Custom);
28 setOperationAction(ISD::SELECT_CC, MVT::i64, Custom);
30 - if (Subtarget->usePopc())
31 - setOperationAction(ISD::CTPOP, MVT::i64, Legal);
32 + setOperationAction(ISD::CTPOP, MVT::i64,
33 + Subtarget->usePopc() ? Legal : Expand);
34 setOperationAction(ISD::CTTZ , MVT::i64, Expand);
35 setOperationAction(ISD::CTTZ_ZERO_UNDEF, MVT::i64, Expand);
36 setOperationAction(ISD::CTLZ , MVT::i64, Expand);
37 @@ -1518,7 +1518,6 @@ SparcTargetLowering::SparcTargetLowering(TargetMac
38 setOperationAction(ISD::FSINCOS, MVT::f32, Expand);
39 setOperationAction(ISD::FREM , MVT::f32, Expand);
40 setOperationAction(ISD::FMA , MVT::f32, Expand);
41 - setOperationAction(ISD::CTPOP, MVT::i32, Expand);
42 setOperationAction(ISD::CTTZ , MVT::i32, Expand);
43 setOperationAction(ISD::CTTZ_ZERO_UNDEF, MVT::i32, Expand);
44 setOperationAction(ISD::CTLZ , MVT::i32, Expand);
45 @@ -1568,8 +1567,8 @@ SparcTargetLowering::SparcTargetLowering(TargetMac
47 setStackPointerRegisterToSaveRestore(SP::O6);
49 - if (Subtarget->isV9() && Subtarget->usePopc())
50 - setOperationAction(ISD::CTPOP, MVT::i32, Legal);
51 + setOperationAction(ISD::CTPOP, MVT::i32,
52 + Subtarget->usePopc() ? Legal : Expand);
54 if (Subtarget->isV9() && Subtarget->hasHardQuad()) {
55 setOperationAction(ISD::LOAD, MVT::f128, Legal);
56 Index: test/CodeGen/SPARC/64bit.ll
57 ===================================================================
58 --- test/CodeGen/SPARC/64bit.ll
59 +++ test/CodeGen/SPARC/64bit.ll
61 -; RUN: llc < %s -march=sparcv9 -disable-sparc-delay-filler -disable-sparc-leaf-proc | FileCheck %s
62 -; RUN: llc < %s -march=sparcv9 | FileCheck %s -check-prefix=OPT
63 +; RUN: llc < %s -march=sparcv9 -mattr=+popc -disable-sparc-delay-filler -disable-sparc-leaf-proc | FileCheck %s
64 +; RUN: llc < %s -march=sparcv9 -mattr=+popc | FileCheck %s -check-prefix=OPT
67 ; CHECK: or %g0, %i1, %i0