[llvm] 70b1a8c - [PatternMatch] Make m_VScale compatible with opaque pointers

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 23 14:02:22 PDT 2021


Author: Nikita Popov
Date: 2021-06-23T23:02:13+02:00
New Revision: 70b1a8c095b2498ea05ba12d248513db19dce92e

URL: https://github.com/llvm/llvm-project/commit/70b1a8c095b2498ea05ba12d248513db19dce92e
DIFF: https://github.com/llvm/llvm-project/commit/70b1a8c095b2498ea05ba12d248513db19dce92e.diff

LOG: [PatternMatch] Make m_VScale compatible with opaque pointers

Use GEP source type instead of pointer element type.

Added: 
    

Modified: 
    llvm/include/llvm/IR/PatternMatch.h
    llvm/test/CodeGen/AArch64/sve-vscale.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h
index 8f9913252212..6efeeb0da958 100644
--- a/llvm/include/llvm/IR/PatternMatch.h
+++ b/llvm/include/llvm/IR/PatternMatch.h
@@ -2437,8 +2437,8 @@ struct VScaleVal_match {
       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;

diff  --git a/llvm/test/CodeGen/AArch64/sve-vscale.ll b/llvm/test/CodeGen/AArch64/sve-vscale.ll
index 3415d188feff..36485ff85df7 100644
--- a/llvm/test/CodeGen/AArch64/sve-vscale.ll
+++ b/llvm/test/CodeGen/AArch64/sve-vscale.ll
@@ -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


        


More information about the llvm-commits mailing list