diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp index dd0412460f4e1..e5704c071b1a8 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -4380,8 +4380,13 @@ void DAGTypeLegalizer::ExpandIntRes_Logical(SDNode *N, SDValue LL, LH, RL, RH; GetExpandedInteger(N->getOperand(0), LL, LH); GetExpandedInteger(N->getOperand(1), RL, RH); - Lo = DAG.getNode(N->getOpcode(), dl, LL.getValueType(), LL, RL); - Hi = DAG.getNode(N->getOpcode(), dl, LL.getValueType(), LH, RH); + + SDNodeFlags Flags; + if (N->getOpcode() == ISD::OR) + Flags.setDisjoint(N->getFlags().hasDisjoint()); + + Lo = DAG.getNode(N->getOpcode(), dl, LL.getValueType(), LL, RL, Flags); + Hi = DAG.getNode(N->getOpcode(), dl, LL.getValueType(), LH, RH, Flags); } void DAGTypeLegalizer::ExpandIntRes_MUL(SDNode *N, diff --git a/llvm/test/CodeGen/RISCV/rv32zbb-zbkb.ll b/llvm/test/CodeGen/RISCV/rv32zbb-zbkb.ll index 3ec857dc41ead..0d6dba61b9a14 100644 --- a/llvm/test/CodeGen/RISCV/rv32zbb-zbkb.ll +++ b/llvm/test/CodeGen/RISCV/rv32zbb-zbkb.ll @@ -128,13 +128,19 @@ define i32 @disjoint_or_xnor_i32(i32 %a, i32 %b) nounwind { } define i64 @disjoint_or_xnor_i64(i64 %a, i64 %b) nounwind { -; CHECK-LABEL: disjoint_or_xnor_i64: -; CHECK: # %bb.0: -; CHECK-NEXT: or a1, a1, a3 -; CHECK-NEXT: or a0, a0, a2 -; CHECK-NEXT: not a0, a0 -; CHECK-NEXT: not a1, a1 -; CHECK-NEXT: ret +; RV32I-LABEL: disjoint_or_xnor_i64: +; RV32I: # %bb.0: +; RV32I-NEXT: or a1, a1, a3 +; RV32I-NEXT: or a0, a0, a2 +; RV32I-NEXT: not a0, a0 +; RV32I-NEXT: not a1, a1 +; RV32I-NEXT: ret +; +; RV32ZBB-ZBKB-LABEL: disjoint_or_xnor_i64: +; RV32ZBB-ZBKB: # %bb.0: +; RV32ZBB-ZBKB-NEXT: xnor a0, a0, a2 +; RV32ZBB-ZBKB-NEXT: xnor a1, a1, a3 +; RV32ZBB-ZBKB-NEXT: ret %or = or disjoint i64 %a, %b %not = xor i64 %or, -1 ret i64 %not