https://bugs.llvm.org/show_bug.cgi?id=44973
Bug ID: 44973
Summary: [DAG] Missing constant fold in avg pattern
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: unassignedb...@nondot.org
Reporter: llvm-...@redking.me.uk
CC: lebedev...@gmail.com, llvm-bugs@lists.llvm.org,
nikita....@gmail.com, spatel+l...@rotateright.com
So, I was trying to improve the codegen in llvm\test\CodeGen\X86\avg.ll for the
'not_avg_v16i8_wide_constants' test case as its incredibly inefficient wrt
demandedbits and shuffle combining:
Then I discovered this: https://gcc.godbolt.org/z/WbMDbA
define void @not_avg_v16i8_wide_constants(<16 x i8>* %a, <16 x i8>* %b, <16 x
i8>* %c) {
%1 = load <16 x i8>, <16 x i8>* %a
%2 = load <16 x i8>, <16 x i8>* %b
%3 = zext <16 x i8> %1 to <16 x i128>
%4 = zext <16 x i8> %2 to <16 x i128>
%5 = add nuw nsw <16 x i128> %3, <i128 -1, i128 -1, i128 -1, i128 -1, i128
-1, i128 -1, i128 -1, i128 -1, i128 -1, i128 -1, i128 -1, i128 -1, i128 -1,
i128 -1, i128 -1, i128 -1>
%6 = add nuw nsw <16 x i128> %5, %4
%7 = lshr <16 x i128> %6, <i128 1, i128 1, i128 1, i128 1, i128 1, i128 1,
i128 1, i128 1, i128 1, i128 1, i128 1, i128 1, i128 1, i128 1, i128 1, i128 1>
%8 = trunc <16 x i128> %7 to <16 x i8>
store <16 x i8> %8, <16 x i8>* %c, align 4
ret void
}
-mcpu=btver2 -instsimplify
define void @not_avg_v16i8_wide_constants(<16 x i8>* %a, <16 x i8>* %b, <16 x
i8>* %c) {
store <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8
-1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>, <16 x i8>* %c, align 4
ret void
}
So, it looks like we're missing some constant folding / value tracking in
DAG....
--
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