[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; RUN: llc < %s -asm-verbose=false -mtriple=x86_64-unknown-linux | FileCheck %s --check-prefix=CHECK --check-prefix=CMOV
|
|
|
|
; RUN: llc < %s -asm-verbose=false -mtriple=i686-unknown-linux | FileCheck %s --check-prefix=CHECK --check-prefix=NOCMOV
|
|
|
|
|
|
|
|
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
|
|
|
|
|
|
|
; Test 2xCMOV patterns exposed after legalization.
|
|
|
|
; One way to do that is with (select (fcmp une/oeq)), which gets
|
|
|
|
; legalized to setp/setne.
|
|
|
|
|
|
|
|
; CHECK-LABEL: test_select_fcmp_oeq_i32:
|
|
|
|
|
|
|
|
; CMOV-NEXT: movl %edi, %eax
|
2018-09-20 02:59:08 +08:00
|
|
|
; CMOV-NEXT: ucomiss %xmm1, %xmm0
|
|
|
|
; CMOV-NEXT: cmovnel %esi, %eax
|
|
|
|
; CMOV-NEXT: cmovpl %esi, %eax
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; CMOV-NEXT: retq
|
|
|
|
|
2015-03-03 09:21:16 +08:00
|
|
|
; NOCMOV-NEXT: flds 8(%esp)
|
|
|
|
; NOCMOV-NEXT: flds 4(%esp)
|
|
|
|
; NOCMOV-NEXT: fucompp
|
|
|
|
; NOCMOV-NEXT: fnstsw %ax
|
|
|
|
; NOCMOV-NEXT: sahf
|
|
|
|
; NOCMOV-NEXT: leal 16(%esp), %eax
|
|
|
|
; NOCMOV-NEXT: jne [[TBB:.LBB[0-9_]+]]
|
|
|
|
; NOCMOV-NEXT: jp [[TBB]]
|
|
|
|
; NOCMOV-NEXT: leal 12(%esp), %eax
|
|
|
|
; NOCMOV-NEXT:[[TBB]]:
|
|
|
|
; NOCMOV-NEXT: movl (%eax), %eax
|
|
|
|
; NOCMOV-NEXT: retl
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
define i32 @test_select_fcmp_oeq_i32(float %a, float %b, i32 %c, i32 %d) #0 {
|
|
|
|
entry:
|
|
|
|
%cmp = fcmp oeq float %a, %b
|
|
|
|
%r = select i1 %cmp, i32 %c, i32 %d
|
|
|
|
ret i32 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: test_select_fcmp_oeq_i64:
|
|
|
|
|
|
|
|
; CMOV-NEXT: movq %rdi, %rax
|
2018-09-20 02:59:08 +08:00
|
|
|
; CMOV-NEXT: ucomiss %xmm1, %xmm0
|
|
|
|
; CMOV-NEXT: cmovneq %rsi, %rax
|
|
|
|
; CMOV-NEXT: cmovpq %rsi, %rax
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; CMOV-NEXT: retq
|
|
|
|
|
|
|
|
; NOCMOV-NEXT: flds 8(%esp)
|
|
|
|
; NOCMOV-NEXT: flds 4(%esp)
|
|
|
|
; NOCMOV-NEXT: fucompp
|
|
|
|
; NOCMOV-NEXT: fnstsw %ax
|
|
|
|
; NOCMOV-NEXT: sahf
|
|
|
|
; NOCMOV-NEXT: leal 20(%esp), %ecx
|
2015-03-03 09:21:16 +08:00
|
|
|
; NOCMOV-NEXT: jne [[TBB:.LBB[0-9_]+]]
|
|
|
|
; NOCMOV-NEXT: jp [[TBB]]
|
|
|
|
; NOCMOV-NEXT: leal 12(%esp), %ecx
|
|
|
|
; NOCMOV-NEXT: [[TBB]]:
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; NOCMOV-NEXT: movl (%ecx), %eax
|
2017-10-08 00:51:19 +08:00
|
|
|
; NOCMOV-NEXT: movl 4(%ecx), %edx
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; NOCMOV-NEXT: retl
|
|
|
|
define i64 @test_select_fcmp_oeq_i64(float %a, float %b, i64 %c, i64 %d) #0 {
|
|
|
|
entry:
|
|
|
|
%cmp = fcmp oeq float %a, %b
|
|
|
|
%r = select i1 %cmp, i64 %c, i64 %d
|
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: test_select_fcmp_une_i64:
|
|
|
|
|
|
|
|
; CMOV-NEXT: movq %rsi, %rax
|
2018-09-20 02:59:08 +08:00
|
|
|
; CMOV-NEXT: ucomiss %xmm1, %xmm0
|
|
|
|
; CMOV-NEXT: cmovneq %rdi, %rax
|
|
|
|
; CMOV-NEXT: cmovpq %rdi, %rax
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; CMOV-NEXT: retq
|
|
|
|
|
|
|
|
; NOCMOV-NEXT: flds 8(%esp)
|
|
|
|
; NOCMOV-NEXT: flds 4(%esp)
|
|
|
|
; NOCMOV-NEXT: fucompp
|
|
|
|
; NOCMOV-NEXT: fnstsw %ax
|
|
|
|
; NOCMOV-NEXT: sahf
|
|
|
|
; NOCMOV-NEXT: leal 12(%esp), %ecx
|
2015-03-03 09:21:16 +08:00
|
|
|
; NOCMOV-NEXT: jne [[TBB:.LBB[0-9_]+]]
|
|
|
|
; NOCMOV-NEXT: jp [[TBB]]
|
|
|
|
; NOCMOV-NEXT: leal 20(%esp), %ecx
|
|
|
|
; NOCMOV-NEXT: [[TBB]]:
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; NOCMOV-NEXT: movl (%ecx), %eax
|
2017-10-08 00:51:19 +08:00
|
|
|
; NOCMOV-NEXT: movl 4(%ecx), %edx
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; NOCMOV-NEXT: retl
|
|
|
|
define i64 @test_select_fcmp_une_i64(float %a, float %b, i64 %c, i64 %d) #0 {
|
|
|
|
entry:
|
|
|
|
%cmp = fcmp une float %a, %b
|
|
|
|
%r = select i1 %cmp, i64 %c, i64 %d
|
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: test_select_fcmp_oeq_f64:
|
|
|
|
|
|
|
|
; CMOV-NEXT: ucomiss %xmm1, %xmm0
|
2015-03-03 09:21:16 +08:00
|
|
|
; CMOV-NEXT: jne [[TBB:.LBB[0-9_]+]]
|
|
|
|
; CMOV-NEXT: jp [[TBB]]
|
|
|
|
; CMOV-NEXT: movaps %xmm2, %xmm3
|
|
|
|
; CMOV-NEXT: [[TBB]]:
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; CMOV-NEXT: movaps %xmm3, %xmm0
|
|
|
|
; CMOV-NEXT: retq
|
|
|
|
|
|
|
|
; NOCMOV-NEXT: flds 8(%esp)
|
|
|
|
; NOCMOV-NEXT: flds 4(%esp)
|
|
|
|
; NOCMOV-NEXT: fucompp
|
|
|
|
; NOCMOV-NEXT: fnstsw %ax
|
|
|
|
; NOCMOV-NEXT: sahf
|
|
|
|
; NOCMOV-NEXT: leal 20(%esp), %eax
|
2015-03-03 09:21:16 +08:00
|
|
|
; NOCMOV-NEXT: jne [[TBB:.LBB[0-9_]+]]
|
|
|
|
; NOCMOV-NEXT: jp [[TBB]]
|
|
|
|
; NOCMOV-NEXT: leal 12(%esp), %eax
|
|
|
|
; NOCMOV-NEXT: [[TBB]]:
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; NOCMOV-NEXT: fldl (%eax)
|
|
|
|
; NOCMOV-NEXT: retl
|
|
|
|
define double @test_select_fcmp_oeq_f64(float %a, float %b, double %c, double %d) #0 {
|
|
|
|
entry:
|
|
|
|
%cmp = fcmp oeq float %a, %b
|
|
|
|
%r = select i1 %cmp, double %c, double %d
|
|
|
|
ret double %r
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: test_select_fcmp_oeq_v4i32:
|
|
|
|
|
|
|
|
; CMOV-NEXT: ucomiss %xmm1, %xmm0
|
2015-03-03 09:21:16 +08:00
|
|
|
; CMOV-NEXT: jne [[TBB:.LBB[0-9_]+]]
|
|
|
|
; CMOV-NEXT: jp [[TBB]]
|
|
|
|
; CMOV-NEXT: movaps %xmm2, %xmm3
|
|
|
|
; CMOV-NEXT: [[TBB]]:
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; CMOV-NEXT: movaps %xmm3, %xmm0
|
|
|
|
; CMOV-NEXT: retq
|
|
|
|
|
|
|
|
; NOCMOV-NEXT: pushl %edi
|
|
|
|
; NOCMOV-NEXT: pushl %esi
|
|
|
|
; NOCMOV-NEXT: flds 20(%esp)
|
2015-03-03 09:21:16 +08:00
|
|
|
; NOCMOV-NEXT: flds 16(%esp)
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; NOCMOV-NEXT: fucompp
|
|
|
|
; NOCMOV-NEXT: fnstsw %ax
|
|
|
|
; NOCMOV-NEXT: sahf
|
2015-03-03 09:21:16 +08:00
|
|
|
; NOCMOV-NEXT: leal 40(%esp), %eax
|
|
|
|
; NOCMOV-NEXT: jne [[TBB:.LBB[0-9_]+]]
|
|
|
|
; NOCMOV-NEXT: jp [[TBB]]
|
|
|
|
; NOCMOV-NEXT: leal 24(%esp), %eax
|
|
|
|
; NOCMOV-NEXT: [[TBB]]:
|
2015-05-19 07:35:09 +08:00
|
|
|
; NOCMOV-NEXT: movl (%eax), %ecx
|
|
|
|
; NOCMOV-NEXT: leal 44(%esp), %edx
|
2015-03-03 09:21:16 +08:00
|
|
|
; NOCMOV-NEXT: jne [[TBB:.LBB[0-9_]+]]
|
|
|
|
; NOCMOV-NEXT: jp [[TBB]]
|
2015-05-19 07:35:09 +08:00
|
|
|
; NOCMOV-NEXT: leal 28(%esp), %edx
|
2015-03-03 09:21:16 +08:00
|
|
|
; NOCMOV-NEXT: [[TBB]]:
|
2015-05-19 07:35:09 +08:00
|
|
|
; NOCMOV-NEXT: movl 12(%esp), %eax
|
|
|
|
; NOCMOV-NEXT: movl (%edx), %edx
|
2015-03-03 09:21:16 +08:00
|
|
|
; NOCMOV-NEXT: leal 48(%esp), %esi
|
|
|
|
; NOCMOV-NEXT: jne [[TBB:.LBB[0-9_]+]]
|
|
|
|
; NOCMOV-NEXT: jp [[TBB]]
|
|
|
|
; NOCMOV-NEXT: leal 32(%esp), %esi
|
|
|
|
; NOCMOV-NEXT: [[TBB]]:
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; NOCMOV-NEXT: movl (%esi), %esi
|
2015-03-03 09:21:16 +08:00
|
|
|
; NOCMOV-NEXT: leal 52(%esp), %edi
|
|
|
|
; NOCMOV-NEXT: jne [[TBB:.LBB[0-9_]+]]
|
|
|
|
; NOCMOV-NEXT: jp [[TBB]]
|
|
|
|
; NOCMOV-NEXT: leal 36(%esp), %edi
|
|
|
|
; NOCMOV-NEXT: [[TBB]]:
|
|
|
|
; NOCMOV-NEXT: movl (%edi), %edi
|
2015-05-19 07:35:09 +08:00
|
|
|
; NOCMOV-NEXT: movl %edi, 12(%eax)
|
|
|
|
; NOCMOV-NEXT: movl %esi, 8(%eax)
|
|
|
|
; NOCMOV-NEXT: movl %edx, 4(%eax)
|
|
|
|
; NOCMOV-NEXT: movl %ecx, (%eax)
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; NOCMOV-NEXT: popl %esi
|
|
|
|
; NOCMOV-NEXT: popl %edi
|
|
|
|
; NOCMOV-NEXT: retl $4
|
|
|
|
define <4 x i32> @test_select_fcmp_oeq_v4i32(float %a, float %b, <4 x i32> %c, <4 x i32> %d) #0 {
|
|
|
|
entry:
|
|
|
|
%cmp = fcmp oeq float %a, %b
|
|
|
|
%r = select i1 %cmp, <4 x i32> %c, <4 x i32> %d
|
|
|
|
ret <4 x i32> %r
|
|
|
|
}
|
|
|
|
|
|
|
|
; Also make sure we catch the original code-sequence of interest:
|
|
|
|
|
|
|
|
; CMOV: [[ONE_F32_LCPI:.LCPI.*]]:
|
|
|
|
; CMOV-NEXT: .long 1065353216
|
|
|
|
|
|
|
|
; CHECK-LABEL: test_zext_fcmp_une:
|
|
|
|
; CMOV-NEXT: ucomiss %xmm1, %xmm0
|
|
|
|
; CMOV-NEXT: movss [[ONE_F32_LCPI]](%rip), %xmm0
|
2015-03-03 09:21:16 +08:00
|
|
|
; CMOV-NEXT: jne [[TBB:.LBB[0-9_]+]]
|
|
|
|
; CMOV-NEXT: jp [[TBB]]
|
|
|
|
; CMOV-NEXT: xorps %xmm0, %xmm0
|
|
|
|
; CMOV-NEXT: [[TBB]]:
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; CMOV-NEXT: retq
|
|
|
|
|
2015-03-03 09:21:16 +08:00
|
|
|
; NOCMOV: jne
|
|
|
|
; NOCMOV-NEXT: jp
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
define float @test_zext_fcmp_une(float %a, float %b) #0 {
|
|
|
|
entry:
|
|
|
|
%cmp = fcmp une float %a, %b
|
|
|
|
%conv1 = zext i1 %cmp to i32
|
|
|
|
%conv2 = sitofp i32 %conv1 to float
|
|
|
|
ret float %conv2
|
|
|
|
}
|
|
|
|
|
|
|
|
; CMOV: [[ONE_F32_LCPI:.LCPI.*]]:
|
|
|
|
; CMOV-NEXT: .long 1065353216
|
|
|
|
|
|
|
|
; CHECK-LABEL: test_zext_fcmp_oeq:
|
|
|
|
; CMOV-NEXT: ucomiss %xmm1, %xmm0
|
|
|
|
; CMOV-NEXT: xorps %xmm0, %xmm0
|
2015-03-03 09:21:16 +08:00
|
|
|
; CMOV-NEXT: jne [[TBB:.LBB[0-9_]+]]
|
|
|
|
; CMOV-NEXT: jp [[TBB]]
|
|
|
|
; CMOV-NEXT: movss [[ONE_F32_LCPI]](%rip), %xmm0
|
|
|
|
; CMOV-NEXT: [[TBB]]:
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
; CMOV-NEXT: retq
|
|
|
|
|
2015-03-03 09:21:16 +08:00
|
|
|
; NOCMOV: jne
|
|
|
|
; NOCMOV-NEXT: jp
|
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
Fold and/or of setcc's to double CMOV:
(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)
When we can't use the CMOV instruction, it might increase branch
mispredicts. When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.
These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).
rdar://19767934
http://reviews.llvm.org/D7634
llvm-svn: 231045
2015-03-03 09:09:14 +08:00
|
|
|
define float @test_zext_fcmp_oeq(float %a, float %b) #0 {
|
|
|
|
entry:
|
|
|
|
%cmp = fcmp oeq float %a, %b
|
|
|
|
%conv1 = zext i1 %cmp to i32
|
|
|
|
%conv2 = sitofp i32 %conv1 to float
|
|
|
|
ret float %conv2
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { nounwind }
|
2016-01-26 06:08:25 +08:00
|
|
|
|
|
|
|
@g8 = global i8 0
|
|
|
|
|
|
|
|
; The following test failed because llvm had a bug where a structure like:
|
|
|
|
;
|
2017-12-07 18:40:31 +08:00
|
|
|
; %12 = CMOV_GR8 %7, %11 ... (lt)
|
|
|
|
; %13 = CMOV_GR8 %12, %11 ... (gt)
|
2016-01-26 06:08:25 +08:00
|
|
|
;
|
|
|
|
; was lowered to:
|
|
|
|
;
|
|
|
|
; The first two cmovs got expanded to:
|
2017-12-05 01:18:51 +08:00
|
|
|
; %bb.0:
|
|
|
|
; JL_1 %bb.9
|
|
|
|
; %bb.7:
|
|
|
|
; JG_1 %bb.9
|
|
|
|
; %bb.8:
|
|
|
|
; %bb.9:
|
|
|
|
; %12 = phi(%7, %bb.8, %11, %bb.0, %12, %bb.7)
|
2017-11-30 20:12:19 +08:00
|
|
|
; %13 = COPY %12
|
|
|
|
; Which was invalid as %12 is not the same value as %13
|
2016-01-26 06:08:25 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: no_cascade_opt:
|
|
|
|
; CMOV-DAG: cmpl %edx, %esi
|
|
|
|
; CMOV-DAG: movb $20, %al
|
|
|
|
; CMOV-DAG: movb $20, %dl
|
2017-03-03 09:00:22 +08:00
|
|
|
; CMOV: jge [[BB2:.LBB[0-9_]+]]
|
|
|
|
; CMOV: jle [[BB3:.LBB[0-9_]+]]
|
|
|
|
; CMOV: [[BB0:.LBB[0-9_]+]]
|
|
|
|
; CMOV: testl %edi, %edi
|
|
|
|
; CMOV: jne [[BB4:.LBB[0-9_]+]]
|
|
|
|
; CMOV: [[BB1:.LBB[0-9_]+]]
|
|
|
|
; CMOV: movb %al, g8(%rip)
|
|
|
|
; CMOV: retq
|
|
|
|
; CMOV: [[BB2]]:
|
2016-05-07 09:11:17 +08:00
|
|
|
; CMOV: movl %ecx, %edx
|
2017-03-03 09:00:22 +08:00
|
|
|
; CMOV: jg [[BB0]]
|
|
|
|
; CMOV: [[BB3]]:
|
2016-05-07 09:11:17 +08:00
|
|
|
; CMOV: movl %edx, %eax
|
2016-01-26 06:08:25 +08:00
|
|
|
; CMOV: testl %edi, %edi
|
2017-03-03 09:00:22 +08:00
|
|
|
; CMOV: je [[BB1]]
|
|
|
|
; CMOV: [[BB4]]:
|
2016-05-07 09:11:17 +08:00
|
|
|
; CMOV: movl %edx, %eax
|
2016-01-26 06:08:25 +08:00
|
|
|
; CMOV: movb %al, g8(%rip)
|
|
|
|
; CMOV: retq
|
|
|
|
define void @no_cascade_opt(i32 %v0, i32 %v1, i32 %v2, i32 %v3) {
|
|
|
|
entry:
|
|
|
|
%c0 = icmp eq i32 %v0, 0
|
|
|
|
%c1 = icmp slt i32 %v1, %v2
|
|
|
|
%c2 = icmp sgt i32 %v1, %v2
|
|
|
|
%trunc = trunc i32 %v3 to i8
|
|
|
|
%sel0 = select i1 %c1, i8 20, i8 %trunc
|
|
|
|
%sel1 = select i1 %c2, i8 20, i8 %sel0
|
|
|
|
%sel2 = select i1 %c0, i8 %sel1, i8 %sel0
|
|
|
|
store volatile i8 %sel2, i8* @g8
|
|
|
|
ret void
|
|
|
|
}
|