[llvm-branch-commits] [llvm] [SelectionDAGBuilder] Use address width when lowering ptrtoaddr (PR #139423)

Matt Arsenault via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 11 18:01:54 PDT 2025


================
@@ -3980,8 +3980,16 @@ void SelectionDAGBuilder::visitSIToFP(const User &I) {
 }
 
 void SelectionDAGBuilder::visitPtrToAddr(const User &I) {
-  // FIXME: this is not correct for pointers with addr width != pointer width
-  visitPtrToInt(I);
+  const auto &TLI = DAG.getTargetLoweringInfo();
+  const DataLayout &DL = DAG.getDataLayout();
+  // ptrtoaddr is equivalent to a truncate of ptrtoint to address/index width
+  auto Op0 = I.getOperand(0);
----------------
arsenm wrote:

```suggestion
  const Value *Op0 = I.getOperand(0);
```

No auto 

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


More information about the llvm-branch-commits mailing list