[llvm-bugs] [Bug 47410] New: [EarlyCSE] recognize commutative intrinsics with >2 args

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 3 10:10:43 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47410

            Bug ID: 47410
           Summary: [EarlyCSE] recognize commutative intrinsics with >2
                    args
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org

EarlyCSE was enhanced to recognize intrinsics that are commutative
(https://reviews.llvm.org/D86798), but it is currently restricted to arguments
with exactly 2 args. 

But there are a small set of intrinsics that have commutative first 2 operands
with extra args after that:

declare i16 @llvm.smul.fix.i16(i16, i16, i32)
define i16 @intrinsic_3_args(i16 %x, i16 %y) {
  %m1 = call i16 @llvm.smul.fix.i16(i16 %x, i16 %y, i32 1)
  %m2 = call i16 @llvm.smul.fix.i16(i16 %y, i16 %x, i32 1)
  %r = sub i16 %m1, %m2
  ret i16 %r
}

$ opt commute.ll -S -gvn
define i16 @intrinsic_3_args(i16 %x, i16 %y) {
  %m1 = call i16 @llvm.smul.fix.i16(i16 %x, i16 %y, i32 1)
  ret i16 0
}


$ opt commute.ll -S -early-cse
define i16 @intrinsic_3_args(i16 %x, i16 %y) {
  %m1 = call i16 @llvm.smul.fix.i16(i16 %x, i16 %y, i32 1)
  %m2 = call i16 @llvm.smul.fix.i16(i16 %y, i16 %x, i32 1)
  %r = sub i16 %m1, %m2
  ret i16 %r
}

-- 
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/20200903/fc22b5e7/attachment.html>


More information about the llvm-bugs mailing list