diff options
author | Chris Lattner <sabre@nondot.org> | 2005-12-07 07:11:03 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-12-07 07:11:03 +0000 |
commit | cbd3d01a4367896d26e05e776f979e15b5900389 (patch) | |
tree | 2e9e9bde9840ebbe6aaeb344c04f4a7760ef899c /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 30aa5f735f6c8b2c4420974eac67e8b05b64f5ff (diff) | |
download | bcm5719-llvm-cbd3d01a4367896d26e05e776f979e15b5900389.tar.gz bcm5719-llvm-cbd3d01a4367896d26e05e776f979e15b5900389.zip |
Teach the dag combiner to turn a truncate/sign_extend pair into a sextinreg
when the types match up. This allows the X86 backend to compile:
sbyte %toggle_value(sbyte* %tmp.1) {
%tmp.2 = load sbyte* %tmp.1
ret sbyte %tmp.2
}
to this:
_toggle_value:
mov %EAX, DWORD PTR [%ESP + 4]
movsx %EAX, BYTE PTR [%EAX]
ret
instead of this:
_toggle_value:
mov %EAX, DWORD PTR [%ESP + 4]
movsx %EAX, BYTE PTR [%EAX]
movsx %EAX, %AL
ret
noticed in Shootout/objinst.
-Chris
llvm-svn: 24630
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 6cd66c7c19c..b7f6853f74c 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1546,6 +1546,10 @@ SDOperand DAGCombiner::visitSIGN_EXTEND(SDNode *N) { // fold (sext (sextload x)) -> (sextload x) if (N0.getOpcode() == ISD::SEXTLOAD && VT == N0.getValueType()) return N0; + // fold (sext (truncate x)) -> (sextinreg x) iff x size == sext size. + if (N0.getOpcode() == ISD::TRUNCATE && N0.getOperand(0).getValueType() == VT) + return DAG.getNode(ISD::SIGN_EXTEND_INREG, VT, N0.getOperand(0), + DAG.getValueType(N0.getValueType())); // fold (sext (load x)) -> (sextload x) if (N0.getOpcode() == ISD::LOAD && N0.hasOneUse()) { SDOperand ExtLoad = DAG.getExtLoad(ISD::SEXTLOAD, VT, N0.getOperand(0), |