[llvm-bugs] [Bug 50173] New: Missing fold trunc(ctlz(zext(x))) -> add(ctlz(x), C)
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Apr 29 13:39:31 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50173
Bug ID: 50173
Summary: Missing fold trunc(ctlz(zext(x))) -> add(ctlz(x), C)
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
define i16 @src(i16 %x) {
%z = zext i16 %x to i32
%p = call i32 @llvm.ctlz.i32(i32 %z, i1 false)
%zz = trunc i32 %p to i16
ret i16 %zz
}
define i16 @tgt(i16 %x) {
%p = call i16 @llvm.ctlz.i16(i16 %x, i1 false)
%z = add i16 %p, 16
ret i16 %z
}
declare i32 @llvm.ctlz.i32(i32, i1)
declare i16 @llvm.ctlz.i16(i16, i1)
----------------------------------------
define i16 @src(i16 %x) {
%0:
%z = zext i16 %x to i32
%p = ctlz i32 %z, 0
%zz = trunc i32 %p to i16
ret i16 %zz
}
=>
define i16 @tgt(i16 %x) {
%0:
%p = ctlz i16 %x, 0
%z = add i16 %p, 16
ret i16 %z
}
Transformation seems to be correct!
--
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/20210429/ff8a127d/attachment.html>
More information about the llvm-bugs
mailing list