[llvm] [InstCombine] Fix incorect `foldPowiReassoc` on signed overflow (PR #197172)

Iris Shi via llvm-commits llvm-commits at lists.llvm.org
Tue May 12 22:42:01 PDT 2026


================
@@ -633,9 +633,17 @@ Instruction *InstCombinerImpl::foldFPSignBitOps(BinaryOperator &I) {
 
 Instruction *InstCombinerImpl::foldPowiReassoc(BinaryOperator &I) {
   auto createPowiExpr = [](BinaryOperator &I, InstCombinerImpl &IC, Value *X,
-                           Value *Y, Value *Z) {
+                           Value *Y, Value *Z) -> Instruction * {
+    auto *CY = dyn_cast<ConstantInt>(Y);
+    auto *CZ = dyn_cast<ConstantInt>(Z);
+    if (CY && CZ) {
----------------
el-ev wrote:

fixed both. thanks for suggestions.

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


More information about the llvm-commits mailing list