[AArch64][GlobalISel] Change G_FCONSTANTs feeding into stores into G_CONSTANTS
authorJessica Paquette <jpaquette@apple.com>
Thu, 16 Jan 2020 00:20:29 +0000 (16:20 -0800)
committerJessica Paquette <jpaquette@apple.com>
Thu, 16 Jan 2020 23:18:44 +0000 (15:18 -0800)
commitb82d18e1e8e6a997f304cbf591e92af02e067fdb
tree47f41b1d3709d874b3252c79308ee91ca61d63fb
parent25b542c61fe364fa86163723b9e35cb7db28bcb4
[AArch64][GlobalISel] Change G_FCONSTANTs feeding into stores into G_CONSTANTS

Given the following situation:

x = G_FCONSTANT (something that can't be materialized)
G_STORE x, some_addr

We know that x must be materialized as at least a single mov. However, at the
time of selection, the G_STORE will have been regbankselected to a FPR store.

So, as a result, you'll get an unnecessary fmov into the G_STORE.

Storing a constant value in a GPR and a constant value in a FPR are the same.
So, whenever you see a G_FCONSTANT that feeds into only G_STORES, so might as
well make it a G_CONSTANT.

This adds a target-specific combine which changes G_FCONSTANTs feeding into
G_STOREs into G_CONSTANTs.

Differential Revision: https://reviews.llvm.org/D72814
llvm/lib/Target/AArch64/AArch64Combine.td
llvm/lib/Target/AArch64/AArch64PreLegalizerCombiner.cpp
llvm/test/CodeGen/AArch64/GlobalISel/combine-fconstant.mir [new file with mode: 0644]