[llvm-bugs] [Bug 47409] New: [NewGVN] missed matching of commutative intrinsics

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 3 09:55:46 PDT 2020


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

            Bug ID: 47409
           Summary: [NewGVN] missed matching of commutative intrinsics
           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

-gvn understands commutative intrinsics, but -newgvn does not. See
https://reviews.llvm.org/D86798 and commits linked from there for more details.

Example from llvm/test/Transforms/NewGVN:

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 -newgvn
...
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
}

-- 
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/7490f88c/attachment.html>


More information about the llvm-bugs mailing list