[PatternMatch] Make m_VScale compatible with opaque pointers

Use GEP source type instead of pointer element type.
This commit is contained in:
Nikita Popov 2021-06-23 22:56:57 +02:00
parent e6a353061f
commit 70b1a8c095
2 changed files with 9 additions and 2 deletions

View File

@ -2437,8 +2437,8 @@ public:
return true;
if (m_PtrToInt(m_OffsetGep(m_Zero(), m_SpecificInt(1))).match(V)) {
Type *PtrTy = cast<Operator>(V)->getOperand(0)->getType();
auto *DerefTy = PtrTy->getPointerElementType();
auto *GEP = cast<GEPOperator>(cast<Operator>(V)->getOperand(0));
auto *DerefTy = GEP->getSourceElementType();
if (isa<ScalableVectorType>(DerefTy) &&
DL.getTypeAllocSizeInBits(DerefTy).getKnownMinSize() == 8)
return true;

View File

@ -48,6 +48,13 @@ define i32 @rdvl_const() nounwind {
ret i32 mul nsw (i32 ptrtoint (<vscale x 1 x i8>* getelementptr (<vscale x 1 x i8>, <vscale x 1 x i8>* null, i64 1) to i32), i32 16)
}
; CHECK-LABEL: rdvl_const_opaque_ptr:
; CHECK: rdvl x0, #1
; CHECK-NEXT: ret
define i32 @rdvl_const_opaque_ptr() nounwind {
ret i32 mul nsw (i32 ptrtoint (ptr getelementptr (<vscale x 1 x i8>, ptr null, i64 1) to i32), i32 16)
}
define i32 @vscale_1() nounwind {
; CHECK-LABEL: vscale_1:
; CHECK: rdvl [[TMP:x[0-9]+]], #1