This is an archive of the discontinued LLVM Phabricator instance.

[mips] Optimize conditional moves where RHS is zero.
ClosedPublic

Authored by vkalintiris on Feb 27 2015, 10:39 AM.

Details

Summary

When the RHS of a conditional move node is zero, we can utilize the $zero
register by inverting the conditional move instruction and by swapping the
order of its True/False operands.

Diff Detail

Repository
rL LLVM

Event Timeline

vkalintiris retitled this revision from to [mips] Optimize conditional moves where RHS is zero..
vkalintiris updated this object.
vkalintiris edited the test plan for this revision. (Show Details)
vkalintiris added a reviewer: dsanders.
dsanders accepted this revision.Mar 2 2015, 4:16 AM
dsanders edited edge metadata.

LGTM with a couple nits.

lib/Target/Mips/MipsISelLowering.cpp
626 ↗(On Diff #20866)

Nit: Can we call these ValueIfTrue and ValueIfFalse? I just want to avoid having case-sensitive names (e.g. true vs True).

test/CodeGen/Mips/fcmp.ll
1–14 ↗(On Diff #20866)

Just a comment, no change required: We haven't been as picky about the 80 char limit in tests as we are elsewhere.

28–30 ↗(On Diff #20866)

The $[[T0:2]] and $[[T2]] looks redundant but it's not. It constrains the ordering of the *-DAG checks, effectively ensuring that the movf occurs after the addiu.

Given that we don't constrain the c.eq.s properly at the moment, I think we should also drop the -DAG on the last line to get:

; 32-C-DAG:      addiu $2, $zero, 1
; 32-C-DAG:      c.eq.s $f12, $f14
; 32-C:          movf $2, $zero, $fcc0

This gets us the constraints we need.

Likewise for the 64-C case below

This revision is now accepted and ready to land.Mar 2 2015, 4:16 AM
This revision was automatically updated to reflect the committed changes.