[SCEVExpander] Avoid ConstantExpr::get() (NFCI)
authorNikita Popov <npopov@redhat.com>
Mon, 4 Jul 2022 12:56:23 +0000 (14:56 +0200)
committerNikita Popov <npopov@redhat.com>
Mon, 4 Jul 2022 12:59:00 +0000 (14:59 +0200)
Use ConstantFoldBinaryOpOperands() instead. This will be important
when not all binops have constant expression variants.

llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

index 401f1ee..0c8bf38 100644 (file)
@@ -220,7 +220,8 @@ Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode,
   // Fold a binop with constant operands.
   if (Constant *CLHS = dyn_cast<Constant>(LHS))
     if (Constant *CRHS = dyn_cast<Constant>(RHS))
-      return ConstantExpr::get(Opcode, CLHS, CRHS);
+      if (Constant *Res = ConstantFoldBinaryOpOperands(Opcode, CLHS, CRHS, DL))
+        return Res;
 
   // Do a quick scan to see if we have this binop nearby.  If so, reuse it.
   unsigned ScanLimit = 6;