[llvm] [DirectX] Legalize i8 allocas (PR #137399)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 29 11:53:20 PDT 2025


================
@@ -81,16 +108,29 @@ static void fixI8TruncUseChain(Instruction &I,
     Value *NewInst =
         Builder.CreateBinOp(BO->getOpcode(), NewOperands[0], NewOperands[1]);
     if (auto *OBO = dyn_cast<OverflowingBinaryOperator>(&I)) {
-      if (OBO->hasNoSignedWrap())
-        cast<BinaryOperator>(NewInst)->setHasNoSignedWrap();
-      if (OBO->hasNoUnsignedWrap())
-        cast<BinaryOperator>(NewInst)->setHasNoUnsignedWrap();
+      auto *NewBO = dyn_cast<BinaryOperator>(NewInst);
----------------
bogner wrote:

Shouldn't we be casting to `OverflowingBinaryOperator` here anyway? It's in the `Operator` class heirarchy that abstracts over instructions and constant exprs.

It is pretty surprising / confusing that BinaryOperator is *not* in this heirarchy, but I guess that naming is a bit of a historical accident

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


More information about the llvm-commits mailing list