[PATCH] D84664: [InstCombine] Fold shift-select if all the operands are constant

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 28 05:39:27 PDT 2020


lebedev.ri added a comment.

In D84664#2178402 <https://reviews.llvm.org/D84664#2178402>, @fvrmatteo wrote:

> @lebedev.ri I just realised that obviously narrowing the problem from i64 to i8 will break it. I'll gladly relax the existing optimisation if possible and submit a new patch, but to me it's clear that there's something wrong going on with the i64 optimisation. I'm now trying to compile Alive2 with the trunk version of LLVM, but I would wait for your confirmation on the i64 case (with Alive2 or input values if possible) before updating the current patch.

I originally tried to proof i64 variant, and alive OOM's on it.
I'm not really sure what is going on there.

I'm not really familiar with `canEvaluateShifted()`,
but i will be really surprised if that one-use check
is there for correctness of the result.



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp:1053-1058
   if (Instruction *R = commonShiftTransforms(I))
     return R;
 
+  if (Value *V =
+          SimplifySelectsFeedingBinaryOp(I, I.getOperand(0), I.getOperand(1)))
+    return replaceInstUsesWith(I, V);
----------------
I would think `SimplifySelectsFeedingBinaryOp()` should be in `commonShiftTransforms()`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84664/new/

https://reviews.llvm.org/D84664



More information about the llvm-commits mailing list