Skip to content

Commit 36230f9

Browse files
authored
[SelectionDAG] Propagate Disjoint flag. (llvm#88370)
Signed-off-by: feng.feng <feng.feng@iluvatar.com>
1 parent 28d28d5 commit 36230f9

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9530,7 +9530,8 @@ static SDValue combineShiftOfShiftedLogic(SDNode *Shift, SelectionDAG &DAG) {
95309530
SDValue ShiftSumC = DAG.getConstant(*C0Val + C1Val, DL, ShiftAmtVT);
95319531
SDValue NewShift1 = DAG.getNode(ShiftOpcode, DL, VT, X, ShiftSumC);
95329532
SDValue NewShift2 = DAG.getNode(ShiftOpcode, DL, VT, Y, C1);
9533-
return DAG.getNode(LogicOpcode, DL, VT, NewShift1, NewShift2);
9533+
return DAG.getNode(LogicOpcode, DL, VT, NewShift1, NewShift2,
9534+
LogicOp->getFlags());
95349535
}
95359536

95369537
/// Handle transforms common to the three shifts, when the shift amount is a

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ bool TargetLowering::ShrinkDemandedConstant(SDValue Op,
544544
if (!C.isSubsetOf(DemandedBits)) {
545545
EVT VT = Op.getValueType();
546546
SDValue NewC = TLO.DAG.getConstant(DemandedBits & C, DL, VT);
547-
SDValue NewOp = TLO.DAG.getNode(Opcode, DL, VT, Op.getOperand(0), NewC);
547+
SDValue NewOp = TLO.DAG.getNode(Opcode, DL, VT, Op.getOperand(0), NewC,
548+
Op->getFlags());
548549
return TLO.CombineTo(Op, NewOp);
549550
}
550551

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -mtriple=x86_64 %s -start-before=x86-isel -o - | FileCheck %s
3+
4+
define i32 @add_shl_or_disjoint(i32 %x) {
5+
; CHECK-LABEL: add_shl_or_disjoint:
6+
; CHECK: # %bb.0:
7+
; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
8+
; CHECK-NEXT: leal 165036822(,%rdi,4), %eax
9+
; CHECK-NEXT: retq
10+
%or = or disjoint i32 %x, 4027584529
11+
%shl = shl i32 %or, 2
12+
%add = add i32 %shl, 1234567890
13+
ret i32 %add
14+
}
15+

0 commit comments

Comments
 (0)