[all-commits] [llvm/llvm-project] bedbb5: [InstCombine] Add additional tests for select oper...
Nikita Popov via All-commits
all-commits at lists.llvm.org
Tue Jan 19 11:34:36 PST 2021
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: bedbb58203cd67a46f64a0182dc1e6717b3c536c
https://github.com/llvm/llvm-project/commit/bedbb58203cd67a46f64a0182dc1e6717b3c536c
Author: Nikita Popov <nikita.ppv at gmail.com>
Date: 2021-01-19 (Tue, 19 Jan 2021)
Changed paths:
M llvm/test/Transforms/InstCombine/select-binop-cmp.ll
Log Message:
-----------
[InstCombine] Add additional tests for select operand replacement (NFC)
In particular, add tests for speculatable and non-speculatable
instructions.
Commit: 21443381c00d9d5ddd6a73f2f839dc4872d79463
https://github.com/llvm/llvm-project/commit/21443381c00d9d5ddd6a73f2f839dc4872d79463
Author: Nikita Popov <nikita.ppv at gmail.com>
Date: 2021-01-19 (Tue, 19 Jan 2021)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
M llvm/test/Transforms/InstCombine/select-binop-cmp.ll
M llvm/test/Transforms/InstCombine/select-safe-transforms.ll
Log Message:
-----------
Reapply [InstCombine] Replace one-use select operand based on condition
Relative to the original change, this adds a check that the
instruction on which we're replacing operands is safe to speculatively
execute, because that's what we're effectively doing. We're executing
the instruction with the replaced operand, which is fine if it's pure,
but not fine if can cause side-effects or UB (aka is not speculatable).
Additionally, we cannot (generally) replace operands in phi nodes,
as these may refer to a different loop iteration. This is also covered
by the speculation check.
-----
InstCombine already performs a fold where X == Y ? f(X) : Z is
transformed to X == Y ? f(Y) : Z if f(Y) simplifies. However,
if f(X) only has one use, then we can always directly replace the
use inside the instruction. To actually be profitable, limit it to
the case where Y is a non-expr constant.
This could be further extended to replace uses further up a one-use
instruction chain, but for now this only looks one level up.
Among other things, this also subsumes D94860.
Differential Revision: https://reviews.llvm.org/D94862
Compare: https://github.com/llvm/llvm-project/compare/a23178690987...21443381c00d
More information about the All-commits
mailing list