[llvm] [InstCombine] Fold A pred C ? (A >> BW - 1) : 1 --> ZExt(A pred C ? A < 0 : 1) (PR #69961)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 10:27:04 PST 2024


================
@@ -3409,6 +3409,25 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
       return replaceOperand(SI, 2, S);
   }
 
+  {
+    // A pred C ? (A >> BW - 1) : 1 --> ZExt(A pred C ? A < 0 : 1)
----------------
goldsteinn wrote:

No real comment about the real-world impact. I'm generally pretty in favor of "get anything we can in" but think thats a minority opinion.

I would refactor to make the goal explicit. Use `makeExactICmpRegion` on the `A Pred C` and just do the complete simplification if the range simplifies `A < 0` to a constant.

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


More information about the llvm-commits mailing list