[llvm-bugs] [Bug 44973] New: [DAG] Missing constant fold in avg pattern
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Feb 20 04:04:23 PST 2020
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: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: lebedev.ri at gmail.com, llvm-bugs at lists.llvm.org,
nikita.ppv at gmail.com, spatel+llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200220/d376a583/attachment-0001.html>
More information about the llvm-bugs
mailing list