Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10872,8 +10872,8 @@ SDValue DAGCombiner::visitSRA(SDNode *N) {
// on that type, and the truncate to that type is both legal and free,
// perform the transform.
if ((ShiftAmt > 0) &&
TLI.isOperationLegalOrCustom(ISD::SIGN_EXTEND, TruncVT) &&
TLI.isOperationLegalOrCustom(ISD::TRUNCATE, VT) &&
TLI.isOperationLegalOrCustom(ISD::SIGN_EXTEND, VT) &&
TLI.isOperationLegalOrCustom(ISD::TRUNCATE, TruncVT) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This amdgpu testcase hits this path:

define i64 @foo(i64 %x) {
  %shl = shl i64 %x, 22
  %sra = ashr i64 %shl, 32
  ret i64 %sra
}

But there's no net change in codegen after this change, probably because we have custom combines to hack out i64 shifts. Is the inner shift dropping flags that can be preserved?

TLI.isTruncateFree(VT, TruncVT)) {
SDValue Amt = DAG.getShiftAmountConstant(ShiftAmt, VT, DL);
SDValue Shift = DAG.getNode(ISD::SRL, DL, VT,
Expand Down