[PATCH] [DAGCombiner] Add support for FCEIL, FFLOOR and FTRUNC vector constant folding

Simon Pilgrim llvm-dev at redking.me.uk
Mon Apr 6 04:46:57 PDT 2015


I've refreshed this patch after realising that I was being a little over the top with the original implementation:

1 - we no longer need to test for the output type being a vector - this can only occur from the folded unary op being a BITCAST (to a non vector type) and no code path requires BITCASTs to treat the VT as a vector anymore. There are plenty of existing test cases that do this (vec -> mmx, vec -> i64 vec -> i128 are examples I found).

2 - we can safely use the existing scalar path for FCEIL/FFLOOR/FTRUNC ops (and avoid all that functional duplication) - if they do fail to fold they will return a FCEIL/FFLOOR/FTRUNC scalar op which will fail the vector test for a UNDEF/CONSTANT/CONSTANTFP result.

3 - despite various suggestions I've not found any floating point constant that fails on the APFloat roundToIntegral - given the patch now uses the existing scalar path that already thoroughly tests this I think we can safely just use that and just accept that its being very, very cautious. I still wonder if its possible to cause it to fail with more exotic float types but haven't found any examples in the DAGCombine or InstCombine float constant folding tests.


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8715

Files:
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  test/CodeGen/X86/vec_floor.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8715.23268.patch
Type: text/x-patch
Size: 3870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150406/b284d761/attachment.bin>


More information about the llvm-commits mailing list