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

            Bug ID: 48816
           Summary: Failure to simplify trunc(abs(sext(x))) -> abs(x)
           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,
                    nikita....@gmail.com, nunoplo...@sapo.pt,
                    spatel+l...@rotateright.com

Noticed while investigating the quality of vectorization for:

https://github.com/WojciechMula/toys/blob/master/autovectorization-tests/transform_abs.cpp

(see http://0x80.pl/notesen/2021-01-18-autovectorization-gcc-clang.html for the
full list).

Due to promotions in the c code, for the "transform_abs_epi8" pattern we end up
with this:

  %20 = load <32 x i8>, <32 x i8>* %19
  %21 = sext <32 x i8> %20 to <32 x i32>
  %22 = call <32 x i32> @llvm.abs.v32i32(<32 x i32> %21, i1 true)
  %23 = trunc <32 x i32> %22 to <32 x i8>

https://gcc.godbolt.org/z/qoYv6s

AFAICT we should be able to remove the sext/trunc and use a v32i8 abs as long
as we clear the "is_int_min_poison" flag:

https://alive2.llvm.org/ce/z/Fvwhka

  %23 = call <32 x i8> @llvm.abs.v32i8(<32 x i8> %20, i1 false)

What are the implications of clearing the poison flag as part of such a fold?

-- 
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