[llvm-bugs] [Bug 44565] New: [X86] Failure to use MOVMSK reduction result for branches
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jan 16 03:23:06 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=44565
Bug ID: 44565
Summary: [X86] Failure to use MOVMSK reduction result for
branches
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, spatel+llvm at rotateright.com
https://godbolt.org/z/GLDirF
If we are selecting between 2 values using a comparison reduction then we use
the all_of/any_of MOVMSK result directly:
define i32 @select(<2 x double> %a0) {
%1 = fcmp ogt <2 x double> %a0, zeroinitializer
%2 = extractelement <2 x i1> %1, i32 0
%3 = extractelement <2 x i1> %1, i32 1
%4 = and i1 %2, %3
%5 = select i1 %4, i32 42, i32 88
ret i32 %5
}
select: # @select
vxorpd %xmm1, %xmm1, %xmm1
vcmpltpd %xmm0, %xmm1, %xmm0
vmovmskpd %xmm0, %eax
cmpb $3, %al
movl $42, %ecx
movl $88, %eax
cmovel %ecx, %eax
retq
But if we decided to create a branch instead then the MOVMSK bits are used
separately, meaning we end up with 2 compares+jmps instead:
define i32 @jmp(<2 x double> %a0) {
%1 = fcmp ogt <2 x double> %a0, zeroinitializer
%2 = extractelement <2 x i1> %1, i32 0
%3 = extractelement <2 x i1> %1, i32 1
%4 = and i1 %2, %3
br i1 %4, label %foo, label %bar
foo:
ret i32 42
bar:
ret i32 88
}
jmp: # @jmp
vxorpd %xmm1, %xmm1, %xmm1
vcmpltpd %xmm0, %xmm1, %xmm0
vmovmskpd %xmm0, %eax
testb $1, %al
je .LBB1_3
shrb %al
je .LBB1_3
movl $42, %eax
retq
.LBB1_3: # %bar
movl $88, %eax
retq
when I think it could be:
jmp: # @jmp
vxorpd %xmm1, %xmm1, %xmm1
vcmpltpd %xmm0, %xmm1, %xmm0
vmovmskpd %xmm0, %eax
cmp $3, %al
jne .LBB1_3
movl $42, %eax
retq
.LBB1_3: # %bar
movl $88, %eax
retq
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200116/6049c536/attachment-0001.html>
More information about the llvm-bugs
mailing list