[InstrSimplify,NewGVN] Add option to ignore additional instr info when simplifying.
authorFlorian Hahn <florian.hahn@arm.com>
Fri, 17 Aug 2018 14:39:04 +0000 (14:39 +0000)
committerFlorian Hahn <florian.hahn@arm.com>
Fri, 17 Aug 2018 14:39:04 +0000 (14:39 +0000)
commit19f9e32f07fc33aefe15bd4dc2669c471fd1bdf7
treebcbaae575c1413569b7aab4e0e048a519e0cb32c
parent70560ba8db05609565051b7c4fb178806117218a
[InstrSimplify,NewGVN] Add option to ignore additional instr info when simplifying.

NewGVN uses InstructionSimplify for simplifications of leaders of
congruence classes. It is not guaranteed that the metadata or other
flags/keywords (like nsw or exact) of the leader is available for all members
in a congruence class, so we cannot use it for simplification.

This patch adds a InstrInfoQuery struct with a boolean field
UseInstrInfo (which defaults to true to keep the current behavior as
default) and a set of helper methods to get metadata/keywords for a
given instruction, if UseInstrInfo is true. The whole thing might need a
better name, to avoid confusion with TargetInstrInfo but I am not sure
what a better name would be.

The current patch threads through InstrInfoQuery to the required
places, which is messier then it would need to be, if
InstructionSimplify and ValueTracking would share the same Query struct.

The reason I added it as a separate struct is that it can be shared
between InstructionSimplify and ValueTracking's query objects. Also,
some places do not need a full query object, just the InstrInfoQuery.

It also updates some interfaces that do not take a Query object, but a
set of optional parameters to take an additional boolean UseInstrInfo.

See https://bugs.llvm.org/show_bug.cgi?id=37540.

Reviewers: dberlin, davide, efriedma, sebpop, hiraditya

Reviewed By: hiraditya

Differential Revision: https://reviews.llvm.org/D47143

llvm-svn: 340031
llvm/include/llvm/Analysis/InstructionSimplify.h
llvm/include/llvm/Analysis/ValueTracking.h
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/Transforms/Scalar/NewGVN.cpp
llvm/test/Transforms/NewGVN/pr33185.ll