[all-commits] [llvm/llvm-project] 796fa6: [InstCombine] Invert `add A, sext(B) --> sub A, ze...
Roman Lebedev via All-commits
all-commits at lists.llvm.org
Thu Dec 5 10:21:58 PST 2019
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 796fa662f12851494303558e0d36b239c55343e7
https://github.com/llvm/llvm-project/commit/796fa662f12851494303558e0d36b239c55343e7
Author: Roman Lebedev <lebedev.ri at gmail.com>
Date: 2019-12-05 (Thu, 05 Dec 2019)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
M llvm/test/Transforms/InstCombine/apint-shift.ll
M llvm/test/Transforms/InstCombine/logical-select.ll
M llvm/test/Transforms/InstCombine/select.ll
M llvm/test/Transforms/InstCombine/shift.ll
M llvm/test/Transforms/InstCombine/zext-bool-add-sub.ll
Log Message:
-----------
[InstCombine] Invert `add A, sext(B) --> sub A, zext(B)` canonicalization (to `sub A, zext B -> add A, sext B`)
Summary:
D68408 proposes to greatly improve our negation sinking abilities.
But in current canonicalization, we produce `sub A, zext(B)`,
which we will consider non-canonical and try to sink that negation,
undoing the existing canonicalization.
So unless we explicitly stop producing previous canonicalization,
we will have two conflicting folds, and will end up endlessly looping.
This inverts canonicalization, and adds back the obvious fold
that we'd miss:
* `sub [nsw] Op0, sext/zext (bool Y) -> add [nsw] Op0, zext/sext (bool Y)`
https://rise4fun.com/Alive/xx4
* `sext(bool) + C -> bool ? C - 1 : C`
https://rise4fun.com/Alive/fBl
It is obvious that `@ossfuzz_9880()` / `@lshr_out_of_range()`/`@ashr_out_of_range()`
(oss-fuzz 4871) are no longer folded as much, though those aren't really worrying.
Reviewers: spatel, efriedma, t.p.northover, hfinkel
Reviewed By: spatel
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71064
More information about the All-commits
mailing list