https://bugs.llvm.org/show_bug.cgi?id=45898
Bug ID: 45898
Summary: Failure to combine rotate through a select
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected]
Not sure whether this can be done in instcombine or must wait until DAG.
https://c.godbolt.org/z/Pam6xk
#include <stdint.h>
uint8_t rotl_2(uint8_t x) {
uint8_t Xlo = (x<<2);
uint8_t Xhi = (x>>6);
uint8_t Xrot = Xlo|Xhi;
return (x < 128 ? Xrot : Xlo);
}
we have a conditional use of a rotate pattern, which unfortunately gets broken
up by the select
define zeroext i8 @rotl_2(i8 zeroext %0) {
%2 = shl i8 %0, 2
%3 = lshr i8 %0, 6
%4 = icmp slt i8 %0, 0
%5 = select i1 %4, i8 0, i8 %3
%6 = or i8 %5, %2
ret i8 %6
}
resulting in:
rotl_2:
leal (,%rdi,4), %ecx
movl %edi, %eax
shrb $6, %al
xorl %edx, %edx
testb %dil, %dil
movzbl %al, %eax
cmovsl %edx, %eax
orb %cl, %al
retq
while gcc manages:
rotl_2:
movl %edi, %edx
leal 0(,%rdi,4), %eax
rolb $2, %dl
testb %dil, %dil
cmovns %edx, %eax
ret
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs