[llvm] [LLVM][ConstProp] Enable intrinsic simplifications for vector ConstantInt based operands. (PR #159358)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 17 08:04:33 PDT 2025


================
@@ -2165,10 +2165,7 @@ Constant *constantFoldVectorReduce(Intrinsic::ID IID, Constant *Op) {
     return PoisonValue::get(VT->getElementType());
 
   // TODO: Handle undef.
-  if (!isa<ConstantVector>(Op) && !isa<ConstantDataVector>(Op))
-    return nullptr;
-
-  auto *EltC = dyn_cast<ConstantInt>(Op->getAggregateElement(0U));
+  auto *EltC = dyn_cast_or_null<ConstantInt>(Op->getAggregateElement(0U));
----------------
nikic wrote:

I think it would be good to also change the check for the non-0 elements to use dyn_cast_or_null. I think this can't happen in practice, but I'm not fully confident on that.

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


More information about the llvm-commits mailing list