[llvm-commits] [llvm] r80184 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/select-i8.ll test/CodeGen/X86/subclass-coalesce.ll
Dan Gohman
gohman at apple.com
Wed Aug 26 17:14:12 PDT 2009
Author: djg
Date: Wed Aug 26 19:14:12 2009
New Revision: 80184
URL: http://llvm.org/viewvc/llvm-project?rev=80184&view=rev
Log:
Expand i8 selects into control flow instead of 16-bit conditional
moves. This avoids the need to promote the operands (or implicitly
extend them, a partial register update condition), and can reduce
i8 register pressure. This substantially speeds up code such as
write_hex in lib/Support/raw_ostream.cpp.
subclass-coalesce.ll is too trivial and no longer tests what it was
originally intended to test.
Added:
llvm/trunk/test/CodeGen/X86/select-i8.ll
Removed:
llvm/trunk/test/CodeGen/X86/subclass-coalesce.ll
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/lib/Target/X86/X86InstrInfo.td
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=80184&r1=80183&r2=80184&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Aug 26 19:14:12 2009
@@ -276,9 +276,9 @@
setOperationAction(ISD::BSWAP , MVT::i16 , Expand);
// These should be promoted to a larger select which is supported.
- setOperationAction(ISD::SELECT , MVT::i1 , Promote);
- setOperationAction(ISD::SELECT , MVT::i8 , Promote);
+ setOperationAction(ISD::SELECT , MVT::i1 , Promote);
// X86 wants to expand cmov itself.
+ setOperationAction(ISD::SELECT , MVT::i8 , Custom);
setOperationAction(ISD::SELECT , MVT::i16 , Custom);
setOperationAction(ISD::SELECT , MVT::i32 , Custom);
setOperationAction(ISD::SELECT , MVT::f32 , Custom);
@@ -7707,6 +7707,7 @@
const TargetInstrInfo *TII = getTargetMachine().getInstrInfo();
switch (MI->getOpcode()) {
default: assert(false && "Unexpected instr type to insert");
+ case X86::CMOV_GR8:
case X86::CMOV_V1I64:
case X86::CMOV_FR32:
case X86::CMOV_FR64:
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=80184&r1=80183&r2=80184&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Wed Aug 26 19:14:12 2009
@@ -1035,6 +1035,18 @@
// Conditional moves
let Uses = [EFLAGS] in {
let isCommutable = 1 in {
+
+// X86 doesn't have 8-bit conditional moves. Use a customDAGSchedInserter to
+// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
+// however that requires promoting the operands, and can induce additional
+// i8 register pressure.
+let usesCustomDAGSchedInserter = 1 in
+def CMOV_GR8 : I<0, Pseudo,
+ (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
+ "#CMOV_GR8 PSEUDO!",
+ [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
+ imm:$cond, EFLAGS))]>;
+
def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
"cmovb\t{$src2, $dst|$dst, $src2}",
Added: llvm/trunk/test/CodeGen/X86/select-i8.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/select-i8.ll?rev=80184&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/select-i8.ll (added)
+++ llvm/trunk/test/CodeGen/X86/select-i8.ll Wed Aug 26 19:14:12 2009
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s | llc -march=x86 > %t
+; RUN: not grep movz %t
+; RUN: not grep cmov %t
+; RUN: grep movb %t | count 2
+
+; Don't try to use a 16-bit conditional move to do an 8-bit select,
+; because it isn't worth it. Just use a branch instead.
+
+define i8 @foo(i1 inreg %c, i8 inreg %a, i8 inreg %b) {
+ %d = select i1 %c, i8 %a, i8 %b
+ ret i8 %d
+}
Removed: llvm/trunk/test/CodeGen/X86/subclass-coalesce.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/subclass-coalesce.ll?rev=80183&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/subclass-coalesce.ll (original)
+++ llvm/trunk/test/CodeGen/X86/subclass-coalesce.ll (removed)
@@ -1,17 +0,0 @@
-; RUN: llvm-as < %s | llc -march=x86 -stats |& grep {Number of cross class joins performed}
-
- at mem.6 = external global i64 ; <i64*> [#uses=1]
-
-define i64 @attachFunc() nounwind {
-entry:
- %tmp64.i = add i64 0, 72 ; <i64> [#uses=1]
- %tmp68.i = load i64* @mem.6, align 8 ; <i64> [#uses=1]
- %tmp70.i = icmp sgt i64 %tmp64.i, %tmp68.i ; <i1> [#uses=1]
- br i1 %tmp70.i, label %bb73.i, label %bb116
-
-bb73.i: ; preds = %entry
- br label %bb116
-
-bb116: ; preds = %bb73.i, %entry
- ret i64 %tmp68.i
-}
More information about the llvm-commits
mailing list