[clang] [llvm] [mlir] [IRBuilder] Use ptrtoaddr in CreatePtrDiff() (PR #181855)

Alexander Richardson via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 18 07:53:52 PST 2026


================
@@ -815,6 +815,7 @@ void ReductionCodeGen::emitAggregateType(CodeGenFunction &CGF, unsigned N) {
     Size = CGF.Builder.CreatePtrDiff(ElemType,
                                      OrigAddresses[N].second.getPointer(CGF),
                                      OrigAddresses[N].first.getPointer(CGF));
+    Size = CGF.Builder.CreateZExtOrTrunc(Size, CGF.Int64Ty);
----------------
arichardson wrote:

Should this be using the `ElemSizeOf` type since we are multiplying with that instead of hardcoding Int64Ty? In case getSizeOf changes in the future?
```suggestion
    Size = CGF.Builder.CreateZExtOrTrunc(Size, ElemSizeOf->getType());
```

https://github.com/llvm/llvm-project/pull/181855


More information about the cfe-commits mailing list