Skip to content

Commit 386ab67

Browse files
toppercgithub-actions[bot]
authored andcommitted
Automerge: [LegalizeTypes] Preserve disjoint flag when expanding OR. (#147640)
2 parents 3220bfe + 2fc6c73 commit 386ab67

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4380,8 +4380,13 @@ void DAGTypeLegalizer::ExpandIntRes_Logical(SDNode *N,
43804380
SDValue LL, LH, RL, RH;
43814381
GetExpandedInteger(N->getOperand(0), LL, LH);
43824382
GetExpandedInteger(N->getOperand(1), RL, RH);
4383-
Lo = DAG.getNode(N->getOpcode(), dl, LL.getValueType(), LL, RL);
4384-
Hi = DAG.getNode(N->getOpcode(), dl, LL.getValueType(), LH, RH);
4383+
4384+
SDNodeFlags Flags;
4385+
if (N->getOpcode() == ISD::OR)
4386+
Flags.setDisjoint(N->getFlags().hasDisjoint());
4387+
4388+
Lo = DAG.getNode(N->getOpcode(), dl, LL.getValueType(), LL, RL, Flags);
4389+
Hi = DAG.getNode(N->getOpcode(), dl, LL.getValueType(), LH, RH, Flags);
43854390
}
43864391

43874392
void DAGTypeLegalizer::ExpandIntRes_MUL(SDNode *N,

llvm/test/CodeGen/RISCV/rv32zbb-zbkb.ll

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,19 @@ define i32 @disjoint_or_xnor_i32(i32 %a, i32 %b) nounwind {
128128
}
129129

130130
define i64 @disjoint_or_xnor_i64(i64 %a, i64 %b) nounwind {
131-
; CHECK-LABEL: disjoint_or_xnor_i64:
132-
; CHECK: # %bb.0:
133-
; CHECK-NEXT: or a1, a1, a3
134-
; CHECK-NEXT: or a0, a0, a2
135-
; CHECK-NEXT: not a0, a0
136-
; CHECK-NEXT: not a1, a1
137-
; CHECK-NEXT: ret
131+
; RV32I-LABEL: disjoint_or_xnor_i64:
132+
; RV32I: # %bb.0:
133+
; RV32I-NEXT: or a1, a1, a3
134+
; RV32I-NEXT: or a0, a0, a2
135+
; RV32I-NEXT: not a0, a0
136+
; RV32I-NEXT: not a1, a1
137+
; RV32I-NEXT: ret
138+
;
139+
; RV32ZBB-ZBKB-LABEL: disjoint_or_xnor_i64:
140+
; RV32ZBB-ZBKB: # %bb.0:
141+
; RV32ZBB-ZBKB-NEXT: xnor a0, a0, a2
142+
; RV32ZBB-ZBKB-NEXT: xnor a1, a1, a3
143+
; RV32ZBB-ZBKB-NEXT: ret
138144
%or = or disjoint i64 %a, %b
139145
%not = xor i64 %or, -1
140146
ret i64 %not

0 commit comments

Comments
 (0)