[PATCH] Restrict select_cc -> (sll (setcc ...)) transform

Richard Sandiford rsandifo at linux.vnet.ibm.com
Thu Jun 27 03:10:04 PDT 2013


The DAG combiner changes something like:

    (select_cc A, B, 16, 0, CC)

into:

    (sll (setcc A, B, C), 4)

This is conditional on the usual:

    !LegalOperations || TLI.isOperationLegal(ISD::SETCC, ...)

style of construct that's used throughout the file.

I don't think this really counts as a simplification on targets without
SETCC though.  It turns one node into two, effectively:

    (select_cc A, B, 16, 0, CC)

to:

    (sll (select_cc A, B, 1, 0, CC), 4)

And we never get rid of the shift.

The sll form doesn't seem any easier to analyse when combining users
of the node.  (Well, things like SelectionDAG::ComputeNumSignBits
might need a SELECT_CC case, but I'll look at that separately.)
Would it be OK to remove the !LegalOperations condition?

FWIW, a similar transform has been disabled:

  // Check to see if this is the equivalent of setcc
  // FIXME: Turn all of these into setcc if setcc if setcc is legal
  // otherwise, go ahead with the folds.
  if (0 && N3C && N3C->isNullValue() && N2C && (N2C->getAPIntValue() == 1ULL)) {

so maybe this kind of thing has been seen before.  The patch changes
the condition within that block too for consistency, even though it
isn't being used yet.

I added a new test rather than extending an existing one because I have
other select_cc-combine things lined up.  They'll go in this test too.

Richard

-------------- next part --------------
A non-text attachment was scrubbed...
Name: limit-shift-setcc.patch
Type: text/x-patch
Size: 1919 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130627/063fa8d9/attachment.bin>


More information about the llvm-commits mailing list