[llvm-bugs] [Bug 51566] New: Missing transformation rotate(x) == 0 to x == 0
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Aug 20 14:51:09 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51566
Bug ID: 51566
Summary: Missing transformation rotate(x) == 0 to x == 0
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at lists.llvm.org
bool test1(unsigned long long x)
{
unsigned long long r = (x << 32) | (x >> 32);
return r != 0;
}
bool test2(unsigned long long x)
{
unsigned long long r = (x << 32) | (x >> 32);
return r == ~0ULL;
}
Trunk -O3:
test1(unsigned long long): # @test1(unsigned long
long)
rol rdi, 32
test rdi, rdi
setne al
ret
test2(unsigned long long): # @test2(unsigned long
long)
rol rdi, 32
cmp rdi, -1
sete al
ret
test3(unsigned long long): # @test3(unsigned long
long)
rol rdi, 32
test rdi, rdi
setne al
ret
Current codegen:
https://godbolt.org/z/q78xxhWe4
----------------------------------------
define i1 @src(i64 %0) {
%1:
%2 = fshr i64 %0, i64 %0, i64 32
%3 = icmp ne i64 %2, 0
ret i1 %3
}
=>
define i1 @tgt(i64 %0) {
%1:
%2 = icmp ne i64 %0, 0
ret i1 %2
}
Transformation seems to be correct!
----------------------------------------
define i1 @src(i64 %0) {
%1:
%2 = fshr i64 %0, i64 %0, i64 32
%3 = icmp ne i64 %2, -1
ret i1 %3
}
=>
define i1 @tgt(i64 %0) {
%1:
%2 = icmp ne i64 %0, -1
ret i1 %2
}
Transformation seems to be correct!
Alive:
https://alive2.llvm.org/ce/z/kmrBvv
--
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/20210820/a8c9b3eb/attachment.html>
More information about the llvm-bugs
mailing list