This is an archive of the discontinued LLVM Phabricator instance.

Add DAG optimisation for FP16_TO_FP
ClosedPublic

Authored by olista01 on Aug 19 2015, 6:25 AM.

Details

Reviewers
olista01
Summary

The FP16_TO_FP node only uses the bottom 16 bits of its input, so the
following pattern can be optimised by removing the AND:

(FP16_TO_FP (AND op, 0xffff)) -> (FP16_TO_FP op)

This is a common pattern for ARM targets when functions have __fp16
arguments, as they are passed as floats (so that they get passed in the
correct registers), but then bitcast and truncated to ignore the top 16
bits.

Diff Detail

Event Timeline

olista01 updated this revision to Diff 32544.Aug 19 2015, 6:25 AM
olista01 retitled this revision from to Add DAG optimisation for FP16_TO_FP.
olista01 updated this object.
olista01 set the repository for this revision to rL LLVM.
olista01 added a subscriber: llvm-commits.

Apart from my comment, looks good.

lib/CodeGen/SelectionDAG/DAGCombiner.cpp
12987

Is this always (op & 0xffff) or can you also have (0xffff & op)?

olista01 added inline comments.Aug 24 2015, 2:39 AM
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
12987

visitAND canonicalises ANDs to have the constant (if there is one) on the RHS, so this isn't necessary.

olista01 accepted this revision.Aug 24 2015, 2:48 AM
olista01 added a reviewer: olista01.
This revision is now accepted and ready to land.Aug 24 2015, 2:48 AM
olista01 closed this revision.Aug 24 2015, 2:49 AM

Thanks, committed revision 245832.

Could you also have a look at the related clang patch, D12148?