diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-11-14 05:28:08 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-11-14 05:28:08 +0000 | 
| commit | 97ff46b3ccee7a557b7cf349bd0dabbae38bdb14 (patch) | |
| tree | fb6dd0dc555e70b13f68c5a288f030c8952b9e9a /llvm | |
| parent | 0ad1e3845b5dcef05a5e3f11dd67296ef8244a69 (diff) | |
| download | bcm5719-llvm-97ff46b3ccee7a557b7cf349bd0dabbae38bdb14.tar.gz bcm5719-llvm-97ff46b3ccee7a557b7cf349bd0dabbae38bdb14.zip  | |
lower "X = seteq Y, Z" to '(shr (ctlz (xor Y, Z)), 5)' instead of
'(shr (ctlz (sub Y, Z)), 5)'.
The use of xor better exposes the operation to bit-twiddling logic in the
dag combiner.  For example, this:
typedef struct {
  unsigned prefix : 4;
  unsigned code : 4;
  unsigned unsigned_p : 4;
} tree_common;
int foo(tree_common *a, tree_common *b) {
  return a->code == b->code;
}
Now compiles to:
_foo:
        lwz r2, 0(r4)
        lwz r3, 0(r3)
        xor r2, r3, r2
        rlwinm r2, r2, 28, 28, 31
        cntlzw r2, r2
        srwi r3, r2, 5
        blr
instead of:
_foo:
        lbz r2, 3(r4)
        lbz r3, 3(r3)
        srwi r2, r2, 4
        srwi r3, r3, 4
        subf r2, r2, r3
        cntlzw r2, r2
        srwi r3, r2, 5
        blr
saving a cycle.
llvm-svn: 31725
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 8 | 
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index 066fd191c99..e2419298b56 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -1038,12 +1038,14 @@ static SDOperand LowerSETCC(SDOperand Op, SelectionDAG &DAG) {    }    // If we have an integer seteq/setne, turn it into a compare against zero -  // by subtracting the rhs from the lhs, which is faster than setting a -  // condition register, reading it back out, and masking the correct bit. +  // by xor'ing the rhs with the lhs, which is faster than setting a +  // condition register, reading it back out, and masking the correct bit.  The +  // normal approach here uses sub to do this instead of xor.  Using xor exposes +  // the result to other bit-twiddling opportunities.    MVT::ValueType LHSVT = Op.getOperand(0).getValueType();    if (MVT::isInteger(LHSVT) && (CC == ISD::SETEQ || CC == ISD::SETNE)) {      MVT::ValueType VT = Op.getValueType(); -    SDOperand Sub = DAG.getNode(ISD::SUB, LHSVT, Op.getOperand(0),  +    SDOperand Sub = DAG.getNode(ISD::XOR, LHSVT, Op.getOperand(0),                                   Op.getOperand(1));      return DAG.getSetCC(VT, Sub, DAG.getConstant(0, LHSVT), CC);    }  | 

