Skip to content

Commit

Permalink
[SelectionDAG] Propagate Disjoint flag. (llvm#88370)
Browse files Browse the repository at this point in the history
Signed-off-by: feng.feng <feng.feng@iluvatar.com>
  • Loading branch information
fengfeng09 authored and aniplcc committed Apr 15, 2024
1 parent 26d394f commit 8ab50dd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9530,7 +9530,8 @@ static SDValue combineShiftOfShiftedLogic(SDNode *Shift, SelectionDAG &DAG) {
SDValue ShiftSumC = DAG.getConstant(*C0Val + C1Val, DL, ShiftAmtVT);
SDValue NewShift1 = DAG.getNode(ShiftOpcode, DL, VT, X, ShiftSumC);
SDValue NewShift2 = DAG.getNode(ShiftOpcode, DL, VT, Y, C1);
return DAG.getNode(LogicOpcode, DL, VT, NewShift1, NewShift2);
return DAG.getNode(LogicOpcode, DL, VT, NewShift1, NewShift2,
LogicOp->getFlags());
}

/// Handle transforms common to the three shifts, when the shift amount is a
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ bool TargetLowering::ShrinkDemandedConstant(SDValue Op,
if (!C.isSubsetOf(DemandedBits)) {
EVT VT = Op.getValueType();
SDValue NewC = TLO.DAG.getConstant(DemandedBits & C, DL, VT);
SDValue NewOp = TLO.DAG.getNode(Opcode, DL, VT, Op.getOperand(0), NewC);
SDValue NewOp = TLO.DAG.getNode(Opcode, DL, VT, Op.getOperand(0), NewC,
Op->getFlags());
return TLO.CombineTo(Op, NewOp);
}

Expand Down
15 changes: 15 additions & 0 deletions llvm/test/CodeGen/X86/propagate-disjoint-in-shl-or.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=x86_64 %s -start-before=x86-isel -o - | FileCheck %s

define i32 @add_shl_or_disjoint(i32 %x) {
; CHECK-LABEL: add_shl_or_disjoint:
; CHECK: # %bb.0:
; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
; CHECK-NEXT: leal 165036822(,%rdi,4), %eax
; CHECK-NEXT: retq
%or = or disjoint i32 %x, 4027584529
%shl = shl i32 %or, 2
%add = add i32 %shl, 1234567890
ret i32 %add
}

0 comments on commit 8ab50dd

Please sign in to comment.