Skip to content

Commit a1973f9

Browse files
committed
[SelectionDAG] Propogate Disjoint flag.
Signed-off-by: feng.feng <[email protected]>
1 parent 6a5f3d4 commit a1973f9

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9530,6 +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+
// Propogate flags.
9534+
SelectionDAG::FlagInserter FlagsInserter(DAG, LogicOp->getFlags());
95339535
return DAG.getNode(LogicOpcode, DL, VT, NewShift1, NewShift2);
95349536
}
95359537

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +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+
// Propogate flags.
548+
SelectionDAG::FlagInserter FlagsInserter(TLO.DAG, Op->getFlags());
547549
SDValue NewOp = TLO.DAG.getNode(Opcode, DL, VT, Op.getOperand(0), NewC);
548550
return TLO.CombineTo(Op, NewOp);
549551
}

llvm/test/CodeGen/X86/propogate-disjoint-in-shl-or.ll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
define void @add_shl_or_disjoint(i32 %x, ptr addrspace(1) %o) {
55
; CHECK-LABEL: add_shl_or_disjoint:
66
; CHECK: # %bb.0:
7-
; CHECK-NEXT: shll $2, %edi
8-
; CHECK-NEXT: orl $-1069531068, %edi # imm = 0xC0404044
9-
; CHECK-NEXT: addl $1234567890, %edi # imm = 0x499602D2
10-
; CHECK-NEXT: movl %edi, (%rsi)
7+
; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
8+
; CHECK-NEXT: leal 165036822(,%rdi,4), %eax
9+
; CHECK-NEXT: movl %eax, (%rsi)
1110
; CHECK-NEXT: retq
1211
%or = or disjoint i32 %x, 4027584529
1312
%shl = shl i32 %or, 2

0 commit comments

Comments
 (0)