diff options
author | Chris Lattner <sabre@nondot.org> | 2006-05-08 20:51:54 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-05-08 20:51:54 +0000 |
commit | 2935d8190cf20fb42702018cfa10a7e059180a36 (patch) | |
tree | 83dc82d73b6c1823e8e84a0472066a8c2828bb91 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 68a45419ccca4ea278f1dc1d705a22528438cd6e (diff) | |
download | bcm5719-llvm-2935d8190cf20fb42702018cfa10a7e059180a36.tar.gz bcm5719-llvm-2935d8190cf20fb42702018cfa10a7e059180a36.zip |
Compile this:
short test4(unsigned X) {
return (X >> 16);
}
to:
_test4:
movl 4(%esp), %eax
sarl $16, %eax
ret
instead of:
_test4:
movl $-65536, %eax
andl 4(%esp), %eax
sarl $16, %eax
ret
llvm-svn: 28171
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 9c469b53c71..e90f902736f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1575,6 +1575,11 @@ SDOperand DAGCombiner::visitSRA(SDNode *N) { } } + // Simplify, based on bits shifted out of the LHS. + if (N1C && SimplifyDemandedBits(SDOperand(N, 0))) + return SDOperand(N, 0); + + // If the sign bit is known to be zero, switch this to a SRL. if (TLI.MaskedValueIsZero(N0, MVT::getIntVTSignBit(VT))) return DAG.getNode(ISD::SRL, VT, N0, N1); |