[ConstantFolding] Avoid use of ConstantExpr::getOr() (NFC)
authorNikita Popov <npopov@redhat.com>
Mon, 24 Jul 2023 14:57:57 +0000 (16:57 +0200)
committerNikita Popov <npopov@redhat.com>
Mon, 24 Jul 2023 15:00:38 +0000 (17:00 +0200)
Constant folding cannot fail here, because we're really working
on plain integers. It might be better to make all of this work
on APInts instead of Constants.

llvm/lib/Analysis/ConstantFolding.cpp

index 08c60b4..fbc6275 100644 (file)
@@ -235,7 +235,8 @@ Constant *FoldBitCast(Constant *C, Type *DestTy, const DataLayout &DL) {
         ShiftAmt += isLittleEndian ? SrcBitSize : -SrcBitSize;
 
         // Mix it in.
-        Elt = ConstantExpr::getOr(Elt, Src);
+        Elt = ConstantFoldBinaryOpOperands(Instruction::Or, Elt, Src, DL);
+        assert(Elt && "Constant folding cannot fail on plain integers");
       }
       Result.push_back(Elt);
     }