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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to