[llvm] [DirectX] Fix the writing of ConstantExpr GEPs to DXIL bitcode (PR #154446)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 26 09:45:22 PDT 2025


================
@@ -343,9 +343,7 @@ bool DataScalarizerVisitor::visitGetElementPtrInst(GetElementPtrInst &GEPI) {
 
   GOp->replaceAllUsesWith(NewGEP);
 
-  if (auto *CE = dyn_cast<ConstantExpr>(GOp))
-    CE->destroyConstant();
-  else if (auto *OldGEPI = dyn_cast<GetElementPtrInst>(GOp))
+  if (auto *OldGEPI = dyn_cast<GetElementPtrInst>(GOp))
----------------
farzonl wrote:

A little confused what is going on here. In the diff it looks like we always did `OldGEPI->eraseFromParent();` was this previously defined somewhere above? Is the diff off? Why do we have to `dyn_cast` `GOp`? Shouldn't that already be a GEP?

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


More information about the llvm-commits mailing list