[llvm] ee89c01 - [XCore] Use getPtrAdd() instead of getGetElementPtr() (NFC) (#222017)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 07:46:49 PDT 2026


Author: Nikita Popov
Date: 2026-09-08T16:46:44+02:00
New Revision: ee89c01e6ad49aeefc918e08bc27f6b50c5407ba

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

LOG: [XCore] Use getPtrAdd() instead of getGetElementPtr() (NFC) (#222017)

This was creating an i8 getelementptr, which is exactly what
ptradd is.

Added: 
    

Modified: 
    llvm/lib/Target/XCore/XCoreISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/XCore/XCoreISelLowering.cpp b/llvm/lib/Target/XCore/XCoreISelLowering.cpp
index c3cbb4b4752d2..8b193cfab7a74 100644
--- a/llvm/lib/Target/XCore/XCoreISelLowering.cpp
+++ b/llvm/lib/Target/XCore/XCoreISelLowering.cpp
@@ -264,8 +264,7 @@ LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const
     // Ideally we would not fold in offset with an index <= 11.
     Type *Ty = Type::getInt32Ty(*DAG.getContext());
     Constant *Idx = ConstantInt::get(Ty, Offset);
-    Constant *GAI = ConstantExpr::getGetElementPtr(
-        Type::getInt8Ty(*DAG.getContext()), const_cast<GlobalValue *>(GV), Idx);
+    Constant *GAI = ConstantExpr::getPtrAdd(const_cast<GlobalValue *>(GV), Idx);
     SDValue CP = DAG.getConstantPool(GAI, MVT::i32);
     return DAG.getLoad(getPointerTy(DAG.getDataLayout()), DL,
                        DAG.getEntryNode(), CP, MachinePointerInfo());


        


More information about the llvm-commits mailing list