[PATCH] D68739: [GISel] Allow ConstantFoldBinOp to consider G_FCONSTANT binary representation for combines

Marcello Maggioni via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 9 15:23:51 PDT 2019


kariddi created this revision.
kariddi added reviewers: aditya_nandakumar, qcolombet, volkan.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

In GlobalISel there's no different type representing Floats or Ints , but just bag of bits types (s16,s32,s64...).

When IRTranslator generates code like this:

%v = bitcast float 1.0 to i32
%v2 = and i32 %x, %v

It will translate the code to

%0_(s32) = G_FCONSTANT float 1.0
%1_(s32) = G_AND %X(s32), %0(s32)

Because a G_BITCAST from s32 to s32 doesn't make sense in this case ...

So from this behavior its clear that IRTranslator considers the output of "G_FCONSTANT" just a bag of bits the origin of which was a float constant.

Currently though in the constant folder we don't consider constants coming from G_FCONSTANTs for folding purposes as the folder considers them "float data" .
In reality though we should consider them like the "untyped bit representation"of a float and it should participate in any constant folding involving "integer" data.


Repository:
  rL LLVM

https://reviews.llvm.org/D68739

Files:
  llvm/include/llvm/CodeGen/GlobalISel/Utils.h
  llvm/lib/CodeGen/GlobalISel/Utils.cpp
  llvm/unittests/CodeGen/GlobalISel/ConstantFoldingTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68739.224187.patch
Type: text/x-patch
Size: 12450 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191009/d22b7ff8/attachment.bin>


More information about the llvm-commits mailing list