[PATCH] D77076: [InstSimplify] Allow some arithmetic optimizations for add/sub/div/rem look through freeze
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 30 11:24:28 PDT 2020
aqjune created this revision.
aqjune added reviewers: spatel, lebedev.ri, fhahn, nikic.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
aqjune edited the summary of this revision.
aqjune marked an inline comment as done.
aqjune added inline comments.
aqjune edited the summary of this revision.
================
Comment at: llvm/test/Transforms/InstSimplify/add.ll:26
+ ret void
+}
+
----------------
I wrote tests in a way that the result is passed to `call f()` rather than being returned, for brevity of tests.
This is a patch to relieve possible performance degradation after D76483 <https://reviews.llvm.org/D76483>.
I picked a few optimizations for add/sub/div/rem in InstSimplify and made them look through freeze.
For example, `X - X => 0` can be expanded so `X - freeze(X)` and `freeze(X) - X` are also converted.
`m_Specific` takes an additional bool parameter `IgnoreFreeze` which makes it match the value after stripping freeze operations.
This expansion is helpful for expanding InstSimplify to support freeze operations without duplicating code.
Proofs:
X + (Y - freeze(X)) -> Y
http://volta.cs.utah.edu:8080/z/yn2mcx
freeze(X) + (Y - X) -> Y
http://volta.cs.utah.edu:8080/z/EmNlwy
freeze(X) - X -> 0
http://volta.cs.utah.edu:8080/z/JVRhLa
freeze(X) div X -> 1, freeze(X) rem X -> 0
http://volta.cs.utah.edu:8080/z/5F6yCt
(X * freeze(Y)) / Y -> X
http://volta.cs.utah.edu:8080/z/MlbJgN
(X % freeze(Y)) / Y -> 0
http://volta.cs.utah.edu:8080/z/CQNyVN
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77076
Files:
llvm/include/llvm/IR/PatternMatch.h
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/add.ll
llvm/test/Transforms/InstSimplify/div.ll
llvm/test/Transforms/InstSimplify/rem.ll
llvm/test/Transforms/InstSimplify/sub.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77076.253645.patch
Type: text/x-patch
Size: 9292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200330/573d549d/attachment-0001.bin>
More information about the llvm-commits
mailing list