[PATCH] D135700: [DAGCombine] Simplify (truncate (build_pair x, y)) -> (truncate x) or x
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 16 15:00:42 PST 2022
arsenm added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:13508
+ if (N0.getOpcode() == ISD::BUILD_PAIR) {
+ // if we match the low element of the pair, just return it.
+ if (N0.getOperand(0).getValueType() == VT)
----------------
Capitalize
================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:13511
+ return N0.getOperand(0);
+ // otherwise, if the low part is still too large, apply the truncate.
+ if (N0.getOperand(0).getValueType().bitsGT(VT))
----------------
Capitalize
================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:13513
+ if (N0.getOperand(0).getValueType().bitsGT(VT))
+ return DAG.getNode(ISD::TRUNCATE, SDLoc(N), VT, N0.getOperand(0));
+ }
----------------
Can just unconditionally truncate, it folds out the equality case for you
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135700/new/
https://reviews.llvm.org/D135700
More information about the llvm-commits
mailing list