Skip to content

Commit 2070044

Browse files
[LLVM][AArch64] Set hasAndNot() to true for scalable vectors. (#139755)
NOTE: I've not added an SVE check because the use of scalable vectors implies SVE or StreamingSVE must be available.
1 parent a1664e5 commit 2070044

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -875,9 +875,10 @@ class AArch64TargetLowering : public TargetLowering {
875875
if (!VT.isVector())
876876
return hasAndNotCompare(Y);
877877

878-
TypeSize TS = VT.getSizeInBits();
879-
// TODO: We should be able to use bic/bif too for SVE.
880-
return !TS.isScalable() && TS.getFixedValue() >= 64; // vector 'bic'
878+
if (VT.isScalableVector())
879+
return true;
880+
881+
return VT.getFixedSizeInBits() >= 64; // vector 'bic'
881882
}
882883

883884
bool shouldProduceAndByConstByHoistingConstFromShiftsLHSOfAnd(

llvm/test/CodeGen/AArch64/sve2-bsl.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,16 @@ define <vscale x 2 x i64> @codegen_bsl2n_i64(<vscale x 2 x i64> %0, <vscale x 2
299299
%7 = or <vscale x 2 x i64> %4, %6
300300
ret <vscale x 2 x i64> %7
301301
}
302+
303+
; (A ^ B) & C) ^ B -> (A & C) | (B & !C) when BIC instructions are available.
304+
define <vscale x 4 x i32> @bsl_combine_when_bic_available(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b, <vscale x 4 x i32> %c) {
305+
; CHECK-LABEL: bsl_combine_when_bic_available:
306+
; CHECK: // %bb.0: // %entry
307+
; CHECK-NEXT: bsl z0.d, z0.d, z1.d, z2.d
308+
; CHECK-NEXT: ret
309+
entry:
310+
%t1 = xor <vscale x 4 x i32> %a, %b
311+
%t2 = and <vscale x 4 x i32> %t1, %c
312+
%t3 = xor <vscale x 4 x i32> %t2, %b
313+
ret <vscale x 4 x i32> %t3
314+
}

llvm/test/CodeGen/AArch64/vselect-constants.ll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,9 @@ define <2 x i64> @not_signbit_mask_v2i64(<2 x i64> %a, <2 x i64> %b) {
369369
define <vscale x 16 x i8> @signbit_mask_xor_nxv16i8(<vscale x 16 x i8> %a, <vscale x 16 x i8> %b) #0 {
370370
; CHECK-LABEL: signbit_mask_xor_nxv16i8:
371371
; CHECK: // %bb.0:
372-
; CHECK-NEXT: ptrue p0.b
373-
; CHECK-NEXT: cmplt p0.b, p0/z, z0.b, #0
374-
; CHECK-NEXT: eor z0.d, z0.d, z1.d
375-
; CHECK-NEXT: mov z0.b, p0/m, #0 // =0x0
372+
; CHECK-NEXT: eor z1.d, z0.d, z1.d
373+
; CHECK-NEXT: asr z0.b, z0.b, #7
374+
; CHECK-NEXT: bic z0.d, z1.d, z0.d
376375
; CHECK-NEXT: ret
377376
%cond = icmp slt <vscale x 16 x i8> %a, zeroinitializer
378377
%xor = xor <vscale x 16 x i8> %a, %b

0 commit comments

Comments
 (0)