Skip to content

Commit 4607459

Browse files
committed
[AArch64] Fix TypeSize->uint64_t implicit conversion in AArch64ISelLowering::hasAndNot
For now I've just changed the code to only return true from AArch64ISelLowering::hasAndNot if the vector is fixed-length. Once we have the right patterns or DAG combines to use bic/bif we can also enable this for SVE. Test added here: CodeGen/AArch64/vselect-constants.ll Differential Revision: https://reviews.llvm.org/D113994
1 parent 35f798d commit 4607459

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,9 @@ class AArch64TargetLowering : public TargetLowering {
743743
if (!VT.isVector())
744744
return hasAndNotCompare(Y);
745745

746-
return VT.getSizeInBits() >= 64; // vector 'bic'
746+
TypeSize TS = VT.getSizeInBits();
747+
// TODO: We should be able to use bic/bif too for SVE.
748+
return !TS.isScalable() && TS.getFixedValue() >= 64; // vector 'bic'
747749
}
748750

749751
bool shouldProduceAndByConstByHoistingConstFromShiftsLHSOfAnd(

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,21 @@ define <2 x i64> @not_signbit_mask_v2i64(<2 x i64> %a, <2 x i64> %b) {
363363
%r = select <2 x i1> %cond, <2 x i64> %b, <2 x i64> zeroinitializer
364364
ret <2 x i64> %r
365365
}
366+
367+
; SVE
368+
369+
define <vscale x 16 x i8> @signbit_mask_xor_nxv16i8(<vscale x 16 x i8> %a, <vscale x 16 x i8> %b) #0 {
370+
; CHECK-LABEL: signbit_mask_xor_nxv16i8:
371+
; 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
376+
; CHECK-NEXT: ret
377+
%cond = icmp slt <vscale x 16 x i8> %a, zeroinitializer
378+
%xor = xor <vscale x 16 x i8> %a, %b
379+
%r = select <vscale x 16 x i1> %cond, <vscale x 16 x i8> zeroinitializer, <vscale x 16 x i8> %xor
380+
ret <vscale x 16 x i8> %r
381+
}
382+
383+
attributes #0 = { "target-features"="+sve" }

0 commit comments

Comments
 (0)