Skip to content

Commit 574b66f

Browse files
authored
[RISCV] Use Selection::haveNoCommonBitsSet in RISCVDAGToDAGISel::orDisjoint. (#147838)
1 parent 5b1db59 commit 574b66f

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3464,11 +3464,10 @@ bool RISCVDAGToDAGISel::selectSHXADD_UWOp(SDValue N, unsigned ShAmt,
34643464
}
34653465

34663466
bool RISCVDAGToDAGISel::orDisjoint(const SDNode *N) const {
3467+
assert(N->getOpcode() == ISD::OR || N->getOpcode() == RISCVISD::OR_VL);
34673468
if (N->getFlags().hasDisjoint())
34683469
return true;
3469-
KnownBits Known0 = CurDAG->computeKnownBits(N->getOperand(0), 0);
3470-
KnownBits Known1 = CurDAG->computeKnownBits(N->getOperand(1), 0);
3471-
return KnownBits::haveNoCommonBitsSet(Known0, Known1);
3470+
return CurDAG->haveNoCommonBitsSet(N->getOperand(0), N->getOperand(1));
34723471
}
34733472

34743473
bool RISCVDAGToDAGISel::selectImm64IfCheaper(int64_t Imm, int64_t OrigImm,

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ define i32 @inverted_masked_merge_i32(i32 %x, i32 %y, i32 %z) nounwind {
205205
; RV32ZBB-ZBKB: # %bb.0:
206206
; RV32ZBB-ZBKB-NEXT: and a1, a0, a1
207207
; RV32ZBB-ZBKB-NEXT: andn a0, a2, a0
208-
; RV32ZBB-ZBKB-NEXT: or a0, a1, a0
209-
; RV32ZBB-ZBKB-NEXT: not a0, a0
208+
; RV32ZBB-ZBKB-NEXT: xnor a0, a1, a0
210209
; RV32ZBB-ZBKB-NEXT: ret
211210
%a = and i32 %x, %y
212211
%notx = xor i32 %x, -1
@@ -231,14 +230,12 @@ define i64 @inverted_masked_merge_i64(i64 %x, i64 %y, i64 %z) nounwind {
231230
;
232231
; RV32ZBB-ZBKB-LABEL: inverted_masked_merge_i64:
233232
; RV32ZBB-ZBKB: # %bb.0:
234-
; RV32ZBB-ZBKB-NEXT: and a2, a0, a2
235233
; RV32ZBB-ZBKB-NEXT: and a3, a1, a3
236-
; RV32ZBB-ZBKB-NEXT: andn a0, a4, a0
234+
; RV32ZBB-ZBKB-NEXT: and a2, a0, a2
237235
; RV32ZBB-ZBKB-NEXT: andn a1, a5, a1
238-
; RV32ZBB-ZBKB-NEXT: or a1, a3, a1
239-
; RV32ZBB-ZBKB-NEXT: or a0, a2, a0
240-
; RV32ZBB-ZBKB-NEXT: not a0, a0
241-
; RV32ZBB-ZBKB-NEXT: not a1, a1
236+
; RV32ZBB-ZBKB-NEXT: andn a0, a4, a0
237+
; RV32ZBB-ZBKB-NEXT: xnor a0, a2, a0
238+
; RV32ZBB-ZBKB-NEXT: xnor a1, a3, a1
242239
; RV32ZBB-ZBKB-NEXT: ret
243240
%a = and i64 %x, %y
244241
%notx = xor i64 %x, -1

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ define signext i32 @inverted_masked_merge_i32(i32 signext %x, i32 signext %y, i3
186186
; RV64ZBB-ZBKB: # %bb.0:
187187
; RV64ZBB-ZBKB-NEXT: and a1, a0, a1
188188
; RV64ZBB-ZBKB-NEXT: andn a0, a2, a0
189-
; RV64ZBB-ZBKB-NEXT: or a0, a1, a0
190-
; RV64ZBB-ZBKB-NEXT: not a0, a0
189+
; RV64ZBB-ZBKB-NEXT: xnor a0, a1, a0
191190
; RV64ZBB-ZBKB-NEXT: ret
192191
%a = and i32 %x, %y
193192
%notx = xor i32 %x, -1
@@ -210,8 +209,7 @@ define i64 @inverted_masked_merge_i64(i64 %x, i64 %y, i64 %z) nounwind {
210209
; RV64ZBB-ZBKB: # %bb.0:
211210
; RV64ZBB-ZBKB-NEXT: and a1, a0, a1
212211
; RV64ZBB-ZBKB-NEXT: andn a0, a2, a0
213-
; RV64ZBB-ZBKB-NEXT: or a0, a1, a0
214-
; RV64ZBB-ZBKB-NEXT: not a0, a0
212+
; RV64ZBB-ZBKB-NEXT: xnor a0, a1, a0
215213
; RV64ZBB-ZBKB-NEXT: ret
216214
%a = and i64 %x, %y
217215
%notx = xor i64 %x, -1

0 commit comments

Comments
 (0)