This is an archive of the discontinued LLVM Phabricator instance.

[ARM] [CodeGen] Do not emit intermediate register for zero FP immediate
ClosedPublic

Authored by sdmitrouk on Sep 23 2014, 12:32 AM.

Details

Summary

This updates check for double precision zero floating point constant to allow use of instruction with immediate value rather than temporary register.
Currently "a == 0.0", where "a" is of "double" type generates:

vmov.i32        d16, #0x0
vcmpe.f64       d0, d16

With this change it becomes:

vcmpe.f64        d0, #0

Diff Detail

Event Timeline

sdmitrouk updated this revision to Diff 13970.Sep 23 2014, 12:32 AM
sdmitrouk retitled this revision from to [ARM] [CodeGen] Do not emit intermediate register for zero FP immediate.
sdmitrouk updated this object.
sdmitrouk edited the test plan for this revision. (Show Details)
sdmitrouk added a reviewer: t.p.northover.
sdmitrouk set the repository for this revision to rL LLVM.
sdmitrouk added a subscriber: Unknown Object (MLST).
sdmitrouk updated this revision to Diff 13972.Sep 23 2014, 12:34 AM

Used wrong diff (without full context) first time.

rengolin added inline comments.
lib/Target/ARM/ARMISelLowering.cpp
3246

I'd say this is a bit too specific on what LowerConstantFP does today, which may change. Wouldn't any fp bitcast work in this case, if the value being casted is zero?

Ping. Also, did my reply to line comment was sent? It has a strange "Not Submitted Yet" label on it.

lib/Target/ARM/ARMISelLowering.cpp
3246

Sure, it would work, but how to check node containing initial value for zero without going through all intermediate nodes? I was looking for a way to generalize this check, but didn't find it.

Hi Sergey,

The inline comments only go live when you click on "Submit" at the bottom of the page. This is to help you make many inline comments and only submit once. So, yeah, I only saw it now. :)

cheers,
--renato

lib/Target/ARM/ARMISelLowering.cpp
3246

I may be wrong, but wouldn't (Op->getValueType(0) == MVT::f32 || Op->getValueType(0) == MVT::f64) get all cases?

I don't expect vector types here, or half-floats...

Hi Renato,

The thing with inline comments wasn't obvious for me :) I'm used to one email per comment.

Regards,
Sergey

lib/Target/ARM/ARMISelLowering.cpp
3246

I see it this way: if we need to check for immediate value the only way to do this is to walk through all intermediate nodes until we get to constant node containing the value.

Catching just zero immediate values or bitcasts to zero will ignore the one created by LowerConstantFP. It's a weird one, but the comment says "don't touch it for zero". isFloatingPointZero is called for arguments of comparison instructions to select special "compare with zero" form and zero argument is represented with such complex structure. I don't see a way to check for this "special zero" without hard-coding whole path to constant node somewhere.

rengolin accepted this revision.Oct 23 2014, 5:18 AM
rengolin added a reviewer: rengolin.

Right. Since you have a test, if this ever stops being true, we'll catch it. I won't bother with "potential other cases" until we know what they are.

LGTM, Thanks!
--renato

This revision is now accepted and ready to land.Oct 23 2014, 5:18 AM

Thanks, Renato!

One more thing, could you please commit it?

Best regards,
Sergey

rengolin closed this revision.Oct 23 2014, 8:43 AM

Committed in r220486.

Thanks!