[llvm] [InstCombine] Do not use operand info in `replaceInInstruction` (PR #99492)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 18 08:10:14 PDT 2024


================
@@ -6796,12 +6797,15 @@ bool llvm::isSafeToSpeculativelyExecuteWithOpcode(
   case Instruction::URem: {
     // x / y is undefined if y == 0.
     const APInt *V;
-    if (match(Inst->getOperand(1), m_APInt(V)))
+    if (UseOperandInfo && match(Inst->getOperand(1), m_APInt(V)))
----------------
nikic wrote:

Hm, good point on the truncation.

My concern here is that we have quite a few transforms currently using isSafeToSpeculativelyExecute() when they're really interested in operand replacements, and most of these transforms are specifically interested in div/rem. It would be great if we could replace those uses of isSafeToSpeculativelyExecute(), but we won't be able to do this with the current implementation.

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


More information about the llvm-commits mailing list