aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nadav.rotem@intel.com>2012-02-05 11:39:23 +0000
committerNadav Rotem <nadav.rotem@intel.com>2012-02-05 11:39:23 +0000
commitcc870a8f936bfc478b7d3d39724dd604a9de8f76 (patch)
treea95b505195f344d430d703c46590434e731ab74b /lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parentd52d9cd038ea325f81dda1fbfadaa3cddcfeb1a9 (diff)
Add additional documentation to the extract-and-trunc dagcombine optimization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149823 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 48b9a3939e..d029906fc3 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -4985,9 +4985,14 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
return N0.getOperand(0);
}
- // Fold Extract-and-trunc into a narrow extract:
- // trunc(extract(x)) -> extract(bitcast(x))
- // We only run this optimization after type legalization (which often
+ // Fold extract-and-trunc into a narrow extract. For example:
+ // i64 x = EXTRACT_VECTOR_ELT(v2i64 val, i32 1)
+ // i32 y = TRUNCATE(i64 x)
+ // -- becomes --
+ // v16i8 b = BITCAST (v2i64 val)
+ // i8 x = EXTRACT_VECTOR_ELT(v16i8 b, i32 8)
+ //
+ // Note: We only run this optimization after type legalization (which often
// creates this pattern) and before operation legalization after which
// we need to be more careful about the vector instructions that we generate.
if (N0.getOpcode() == ISD::EXTRACT_VECTOR_ELT &&