[PATCH] D38663: [X86] Add X86ISD::CMOV to computeKnownBitsForTargetNode and ComputeNumSignBitsForTargetNode.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 6 22:09:10 PDT 2017
craig.topper created this revision.
Implementations based on ISD::SELECT.
https://reviews.llvm.org/D38663
Files:
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/cmovcmov.ll
test/CodeGen/X86/pr32282.ll
Index: test/CodeGen/X86/pr32282.ll
===================================================================
--- test/CodeGen/X86/pr32282.ll
+++ test/CodeGen/X86/pr32282.ll
@@ -28,7 +28,6 @@
; X86-NEXT: cmovnel %ecx, %edx
; X86-NEXT: cmovnel %eax, %ecx
; X86-NEXT: andl $-2, %edx
-; X86-NEXT: andl $2147483647, %ecx # imm = 0x7FFFFFFF
; X86-NEXT: addl $7, %edx
; X86-NEXT: adcxl %eax, %ecx
; X86-NEXT: pushl %ecx
Index: test/CodeGen/X86/cmovcmov.ll
===================================================================
--- test/CodeGen/X86/cmovcmov.ll
+++ test/CodeGen/X86/cmovcmov.ll
@@ -53,8 +53,7 @@
; NOCMOV-NEXT: leal 12(%esp), %ecx
; NOCMOV-NEXT: [[TBB]]:
; NOCMOV-NEXT: movl (%ecx), %eax
-; NOCMOV-NEXT: orl $4, %ecx
-; NOCMOV-NEXT: movl (%ecx), %edx
+; NOCMOV-NEXT: movl 4(%ecx), %edx
; NOCMOV-NEXT: retl
define i64 @test_select_fcmp_oeq_i64(float %a, float %b, i64 %c, i64 %d) #0 {
entry:
@@ -82,8 +81,7 @@
; NOCMOV-NEXT: leal 20(%esp), %ecx
; NOCMOV-NEXT: [[TBB]]:
; NOCMOV-NEXT: movl (%ecx), %eax
-; NOCMOV-NEXT: orl $4, %ecx
-; NOCMOV-NEXT: movl (%ecx), %edx
+; NOCMOV-NEXT: movl 4(%ecx), %edx
; NOCMOV-NEXT: retl
define i64 @test_select_fcmp_une_i64(float %a, float %b, i64 %c, i64 %d) #0 {
entry:
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -27189,6 +27189,19 @@
Known.Zero.setBitsFrom(InBitWidth);
break;
}
+ case X86ISD::CMOV: {
+ DAG.computeKnownBits(Op.getOperand(1), Known, Depth+1);
+ // If we don't know any bits, early out.
+ if (!Known.One && !Known.Zero)
+ break;
+ KnownBits Known2;
+ DAG.computeKnownBits(Op.getOperand(0), Known2, Depth+1);
+
+ // Only known if known in both the LHS and RHS.
+ Known.One &= Known2.One;
+ Known.Zero &= Known2.Zero;
+ break;
+ }
}
}
@@ -27251,6 +27264,13 @@
case X86ISD::VPCOMU:
// Vector compares return zero/all-bits result values.
return VTBits;
+
+ case X86ISD::CMOV: {
+ unsigned Tmp0 = DAG.ComputeNumSignBits(Op.getOperand(0), Depth+1);
+ if (Tmp0 == 1) return 1; // Early out.
+ unsigned Tmp1 = DAG.ComputeNumSignBits(Op.getOperand(1), Depth+1);
+ return std::min(Tmp0, Tmp1);
+ }
}
// Fallback case.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38663.118128.patch
Type: text/x-patch
Size: 2368 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171007/0b798d65/attachment.bin>
More information about the llvm-commits
mailing list