Skip to content

Commit e2074c6

Browse files
committed
[AArch64] Use implicitTrunc in isBitfieldDstMask() (NFC)
This code intentionally discards the high bits, so set implicitTrunc=true. This is currently NFC but will enable an APInt assertion in the future.
1 parent af6e188 commit e2074c6

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2792,7 +2792,9 @@ static bool isBitfieldDstMask(uint64_t DstMask, const APInt &BitsToBeInserted,
27922792
"i32 or i64 mask type expected!");
27932793
unsigned BitWidth = VT.getSizeInBits() - NumberOfIgnoredHighBits;
27942794

2795-
APInt SignificantDstMask = APInt(BitWidth, DstMask);
2795+
// Enable implicitTrunc as we're intentionally ignoring high bits.
2796+
APInt SignificantDstMask =
2797+
APInt(BitWidth, DstMask, /*isSigned=*/false, /*implicitTrunc=*/true);
27962798
APInt SignificantBitsToBeInserted = BitsToBeInserted.zextOrTrunc(BitWidth);
27972799

27982800
return (SignificantDstMask & SignificantBitsToBeInserted) == 0 &&

llvm/test/CodeGen/AArch64/bitfield-insert.ll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,3 +735,21 @@ define i32 @orr_not_bfxil_test2_i32(i32 %0) {
735735
%4 = or i32 %2, %3
736736
ret i32 %4
737737
}
738+
739+
define i16 @implicit_trunc_of_imm(ptr %p, i16 %a, i16 %b) {
740+
; CHECK-LABEL: implicit_trunc_of_imm:
741+
; CHECK: // %bb.0: // %entry
742+
; CHECK-NEXT: and w8, w1, #0xffffe000
743+
; CHECK-NEXT: mov x9, x0
744+
; CHECK-NEXT: mov w10, w8
745+
; CHECK-NEXT: mov w0, w8
746+
; CHECK-NEXT: bfxil w10, w2, #0, #1
747+
; CHECK-NEXT: strh w10, [x9]
748+
; CHECK-NEXT: ret
749+
entry:
750+
%and1 = and i16 %a, -8192
751+
%and2 = and i16 %b, 1
752+
%or = or i16 %and2, %and1
753+
store i16 %or, ptr %p
754+
ret i16 %and1
755+
}

0 commit comments

Comments
 (0)