Skip to content

Commit

Permalink
[AArch64] Additional tests for creating BIC from known bits. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
davemgreen committed Jul 5, 2023
1 parent 1077a34 commit 86bd9a4
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 4 deletions.
57 changes: 57 additions & 0 deletions llvm/test/CodeGen/AArch64/neon-bitwise-instructions.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,63 @@ define <2 x i64> @and64imm8h_lsl8(<2 x i64> %a) {
ret <2 x i64> %tmp1
}

define <8 x i16> @bic_shifted_knownbits(<8 x i16> %v) {
; CHECK-LABEL: bic_shifted_knownbits:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: movi v1.8h, #1
; CHECK-NEXT: ushr v0.8h, v0.8h, #9
; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
; CHECK-NEXT: ret
entry:
%vshr_n = lshr <8 x i16> %v, <i16 9, i16 9, i16 9, i16 9, i16 9, i16 9, i16 9, i16 9>
%and.i = and <8 x i16> %vshr_n, <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
ret <8 x i16> %and.i
}

define <8 x i32> @bic_shifted_knownbits2(<8 x i16> %v) {
; CHECK-LABEL: bic_shifted_knownbits2:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: mov w8, #-1048321 // =0xfff000ff
; CHECK-NEXT: ushll2 v1.4s, v0.8h, #0
; CHECK-NEXT: ushll v0.4s, v0.4h, #0
; CHECK-NEXT: dup v2.4s, w8
; CHECK-NEXT: and v1.16b, v1.16b, v2.16b
; CHECK-NEXT: and v0.16b, v0.16b, v2.16b
; CHECK-NEXT: ret
entry:
%vshr_n = zext <8 x i16> %v to <8 x i32>
%and.i = and <8 x i32> %vshr_n, <i32 4293918975, i32 4293918975, i32 4293918975, i32 4293918975, i32 4293918975, i32 4293918975, i32 4293918975, i32 4293918975>
ret <8 x i32> %and.i
}

define <8 x i32> @bic_shifted_knownbits3(<8 x i16> %v) {
; CHECK-LABEL: bic_shifted_knownbits3:
; CHECK: // %bb.0:
; CHECK-NEXT: bic v0.8h, #255, lsl #8
; CHECK-NEXT: ushll2 v1.4s, v0.8h, #0
; CHECK-NEXT: ushll v0.4s, v0.4h, #0
; CHECK-NEXT: ret
%a = and <8 x i16> %v, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
%and.i = zext <8 x i16> %a to <8 x i32>
ret <8 x i32> %and.i
}


define <8 x i32> @bic_shifted_knownbits4(<8 x i32> %v) {
; CHECK-LABEL: bic_shifted_knownbits4:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: movi v2.2d, #0xffff0000ffff0000
; CHECK-NEXT: shl v0.4s, v0.4s, #8
; CHECK-NEXT: shl v1.4s, v1.4s, #8
; CHECK-NEXT: and v0.16b, v0.16b, v2.16b
; CHECK-NEXT: and v1.16b, v1.16b, v2.16b
; CHECK-NEXT: ret
entry:
%vshr_n = shl <8 x i32> %v, <i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8>
%and.i = and <8 x i32> %vshr_n, <i32 4294901760, i32 4294901760, i32 4294901760, i32 4294901760, i32 4294901760, i32 4294901760, i32 4294901760, i32 4294901760>
ret <8 x i32> %and.i
}

define <8 x i8> @orr8imm2s_lsl0(<8 x i8> %a) {
; CHECK-LABEL: orr8imm2s_lsl0:
; CHECK: // %bb.0:
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/CodeGen/AArch64/shiftregister-from-and.ll
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ define i64 @and_shiftedreg_from_and(i64 %a, i64 %b) {
define i64 @bic_shiftedreg_from_and(i64 %a, i64 %b) {
; CHECK-LABEL: bic_shiftedreg_from_and:
; CHECK: // %bb.0:
; CHECK-NEXT: mov w8, #16777215
; CHECK-NEXT: mov w8, #16777215 // =0xffffff
; CHECK-NEXT: orn x8, x8, x0, asr #23
; CHECK-NEXT: and x0, x1, x8
; CHECK-NEXT: ret
Expand Down Expand Up @@ -67,7 +67,7 @@ define i64 @eor_shiftedreg_from_and(i64 %a, i64 %b) {
define i64 @mvn_shiftedreg_from_and(i64 %a) {
; CHECK-LABEL: mvn_shiftedreg_from_and:
; CHECK: // %bb.0:
; CHECK-NEXT: mov x8, #9007199254740991
; CHECK-NEXT: mov x8, #9007199254740991 // =0x1fffffffffffff
; CHECK-NEXT: orn x0, x8, x0, lsl #36
; CHECK-NEXT: ret
%shl = shl i64 %a, 36
Expand Down Expand Up @@ -205,7 +205,7 @@ define i32 @shiftedreg_from_and_negative_oneuse2(i32 %a, i32 %b) {
define i32 @shiftedreg_from_and_negative_andc1(i32 %a, i32 %b) {
; CHECK-LABEL: shiftedreg_from_and_negative_andc1:
; CHECK: // %bb.0:
; CHECK-NEXT: mov w8, #26215
; CHECK-NEXT: mov w8, #26215 // =0x6667
; CHECK-NEXT: movk w8, #65510, lsl #16
; CHECK-NEXT: and w8, w8, w0, asr #23
; CHECK-NEXT: add w0, w8, w1
Expand All @@ -221,7 +221,7 @@ define i32 @shiftedreg_from_and_negative_andc1(i32 %a, i32 %b) {
define i32 @shiftedreg_from_and_negative_andc2(i32 %a, i32 %b) {
; CHECK-LABEL: shiftedreg_from_and_negative_andc2:
; CHECK: // %bb.0:
; CHECK-NEXT: mov w8, #-285212672
; CHECK-NEXT: mov w8, #-285212672 // =0xef000000
; CHECK-NEXT: and w8, w8, w0, asr #23
; CHECK-NEXT: add w0, w8, w1
; CHECK-NEXT: ret
Expand Down

0 comments on commit 86bd9a4

Please sign in to comment.