[PATCH] D76057: [Reassociate] recognize more than one pairs for later CSE - NFC
ChenZheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 12 04:30:17 PDT 2020
shchenz created this revision.
shchenz added reviewers: spatel, lebedev.ri, efriedma, qcolombet, mcrosier, davide, dsanders.
Herald added subscribers: llvm-commits, wuzish, kosarev, hiraditya.
Herald added a project: LLVM.
Motivated case:
void foo(int a, int b, int c, int d, int* res1, int* res2, int* res3)
{
*res1 = a + b + c + d;
*res2 = b + c;
*res3 = a + d;
}
There are two common expressions `a+d` & `c+d`, currently `Reassociate` can recognize one of them.
It gets:
%add = add i32 %b, %c
%add.1 = add i32 %add, %a
%add.2 = add i32 %add.1, %d
store i32 %add, i32*res2, align 4, !tbaa !2
store i32 %add.2, i32* %res1, align 4, !tbaa !2
%add.3 = add nsw i32 %a, %d
store i32 %add.3, i32* %res3, align 4, !tbaa !2
ret void
But we expect:
%add1 = add i32 %d, %a
%add = add i32 %c, %b
%add2 = add i32 %add, %add1
store i32 %add2, i32* %res1, align 4, !tbaa !2
store i32 %add, i32* %res2, align 4, !tbaa !2
store i32 %add1, i32* %res3, align 4, !tbaa !2
ret void
This is first part to recognize more than one pattern. This is NFC.
Changes about rewriting these common expressions will be posted in following patches.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76057
Files:
llvm/include/llvm/Transforms/Scalar/Reassociate.h
llvm/lib/Transforms/Scalar/Reassociate.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76057.249882.patch
Type: text/x-patch
Size: 5855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200312/f2fbbeb0/attachment.bin>
More information about the llvm-commits
mailing list