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

            Bug ID: 46897
           Summary: Failure to recognise commutable binop intrinsics
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: llvm-...@redking.me.uk
                CC: lebedev...@gmail.com, llvm-bugs@lists.llvm.org,
                    spatel+l...@rotateright.com

define <2 x i64> @smax(<2 x i64> %a, <2 x i64> %b) {
  %x = call <2 x i64> @llvm.smax.v2i64(<2 x i64> %a, <2 x i64> %b)
  %y = call <2 x i64> @llvm.smax.v2i64(<2 x i64> %b, <2 x i64> %a)
  %o = or <2 x i64> %x, %y
  ret <2 x i64> %o
}
declare <2 x i64> @llvm.smax.v2i64(<2 x i64>, <2 x i64>)

opt -O3

define <2 x i64> @smax(<2 x i64> %a, <2 x i64> %b) {
  %x = tail call <2 x i64> @llvm.smax.v2i64(<2 x i64> %a, <2 x i64> %b)
  %y = tail call <2 x i64> @llvm.smax.v2i64(<2 x i64> %b, <2 x i64> %a)
  %o = or <2 x i64> %x, %y
  ret <2 x i64> %o
}

but we should be able to recognise that %x and %y are equivalent:

define <2 x i64> @smax(<2 x i64> %a, <2 x i64> %b) {
  %x = tail call <2 x i64> @llvm.smax.v2i64(<2 x i64> %a, <2 x i64> %b)
  ret <2 x i64> %x
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to