OSDN Git Service

[GlobalISel] Avoid translating synthetic constants to new G_CONSTANTS.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Wed, 15 Mar 2017 19:21:11 +0000 (19:21 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Wed, 15 Mar 2017 19:21:11 +0000 (19:21 +0000)
commit924375d273ef90b399590498f58392590627b5df
treef84cbf67110f1ae4ff5a6d3b7595aabfd327863f
parentbde5be06dbc1d6873d50205b0aebd48c71c8294f
[GlobalISel] Avoid translating synthetic constants to new G_CONSTANTS.

Currently, we create a G_CONSTANT for every "synthetic" integer
constant operand (for instance, for the G_GEP offset).
Instead, share the G_CONSTANTs we might have created by going through
the ValueToVReg machinery.

When we're emitting synthetic constants, we do need to get Constants from
the context.  One could argue that we shouldn't modify the context at
all (for instance, this means that we're going to use a tad more memory
if the constant wasn't used elsewhere), but constants are mostly
harmless.  We currently do this for extractvalue and all.

For constant fcmp, this does mean we'll emit an extra COPY, which is not
necessarily more optimal than an extra materialized constant.
But that preserves the current intended design of uniqued G_CONSTANTs,
and the rematerialization problem exists elsewhere and should be
resolved with a single coherent solution.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297875 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/GlobalISel/IRTranslator.cpp
test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
test/CodeGen/AArch64/GlobalISel/dynamic-alloca.ll
test/CodeGen/AArch64/GlobalISel/translate-gep.ll