[llvm-bugs] [Bug 46896] New: InstCombine - extend matchRotate to handle funnel shifts
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jul 29 09:24:21 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46896
Bug ID: 46896
Summary: InstCombine - extend matchRotate to handle funnel
shifts
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: llvm-bugs at lists.llvm.org, spatel+llvm at rotateright.com
matchRotate currently only matches rotations, but should be able to handle
funnel shifts as well with minimal effort:
define i64 @rotvar(i64 %a0, i64 %a1, i64 %a2) {
%m = and i64 %a2, 63
%n = sub i64 0, %m
%s = and i64 %n, 63
%1 = shl i64 %a0, %m
%2 = lshr i64 %a0, %s
%3 = or i64 %1, %2
ret i64 %3
}
define i64 @fshvar(i64 %a0, i64 %a1, i64 %a2) {
%m = and i64 %a2, 63
%n = sub i64 0, %m
%s = and i64 %n, 63
%1 = shl i64 %a0, %m
%2 = lshr i64 %a1, %s
%3 = or i64 %1, %2
ret i64 %3
}
opt -instcombine
define i64 @rotvar(i64 %a0, i64 %a1, i64 %a2) {
%1 = tail call i64 @llvm.fshl.i64(i64 %a0, i64 %a0, i64 %a2)
ret i64 %1
}
define i64 @fshvar(i64 %a0, i64 %a1, i64 %a2) {
%m = and i64 %a2, 63
%n = sub i64 0, %a2
%s = and i64 %n, 63
%1 = shl i64 %a0, %m
%2 = lshr i64 %a1, %s
%3 = or i64 %1, %2
ret i64 %3
}
--
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/20200729/72073b46/attachment-0001.html>
More information about the llvm-bugs
mailing list