[GlobalISel] Change widenScalar of G_FCONSTANT to mutate into G_CONSTANT.
authorAmara Emerson <amara@apple.com>
Thu, 14 Jul 2022 07:53:59 +0000 (00:53 -0700)
committerAmara Emerson <amara@apple.com>
Thu, 14 Jul 2022 18:05:10 +0000 (11:05 -0700)
commitd4f84df0a008b13d0e8440aec1d63651b7520923
tree5d3755e69c63e15d13dccda246287377c16563b8
parent0a92e0728c8c5b6b36adff6ebaa2b8cddd44298c
[GlobalISel] Change widenScalar of G_FCONSTANT to mutate into G_CONSTANT.

Widening a G_FCONSTANT by extending and then generating G_FPTRUNC doesn't produce
the same result all the time. Instead, we can just transform it to a G_CONSTANT
of the same bit pattern and truncate using a plain G_TRUNC instead.

Fixes https://github.com/llvm/llvm-project/issues/56454

Differential Revision: https://reviews.llvm.org/D129743
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/test/CodeGen/AArch64/GlobalISel/legalize-constant.mir
llvm/test/CodeGen/AArch64/GlobalISel/legalize-fp16-fconstant.mir