[llvm] [ConstantFold][RFC] Refactor getBinOpAbsorber function (PR #109736)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 19:31:07 PDT 2024
================
@@ -729,13 +729,15 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
// Neither constant should be UndefValue, unless these are vector constants.
assert((!HasScalarUndefOrScalableVectorUndef) && "Unexpected UndefValue");
+ Constant *Absorber = ConstantExpr::getBinOpAbsorber(
+ Opcode, C1->getType(), /*AllowLHSAbsorber*/ true);
+
// Handle simplifications when the RHS is a constant int.
if (ConstantInt *CI2 = dyn_cast<ConstantInt>(C2)) {
+ if (C2 == Absorber)
+ return C2;
----------------
eric-xtang1008 wrote:
Yes, I modified it. Please help review it, thanks!
https://github.com/llvm/llvm-project/pull/109736
More information about the llvm-commits
mailing list