[PATCH] D25485: [x86] use 'neg' for negation of bool

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 13 08:04:14 PDT 2016


spatel added subscribers: sdardis, dsanders.
spatel added a comment.

In https://reviews.llvm.org/D25485#568808, @efriedma wrote:

> DAGCombine can eliminate the mask instruction in a lot of cases (if the value is in fact zero-extended).  Also, the mask+neg is probably slightly more efficient than two shifts on most processors.


Yes, you're correct - thanks!

So I tried the SelectionDAGLegalize::ExpandNode suggestion, and I see one problem case: micromips.
I don't know micromips (cc'ing @sdardis and @dsanders), but it doesn't appear to have a negate instruction. If we legalize to and+negate, the code grows from something like:

  sll	$1, $1, 31
  jr	$ra
  sra	$2, $1, 31

To:

  andi16	$2, $2, 1
  li16	$3, 0
  subu16	$2, $3, $2
  jrc	$ra

Given this potential regression, I'd like to proceed with the x86-only solution for now (I will add a TODO comment about making it more general). As noted in the initial summary, I have filed bugs for the PPC and ARM folks and linked to this patch, so they are aware of what is needed to pursue the common solution.


https://reviews.llvm.org/D25485





More information about the llvm-commits mailing list