[PATCH] D71312: [InstCombine] X / (select C, X, -X) -> select C ? 1 : -1

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 18:00:28 PST 2019


craig.topper added a comment.

Seems like we should maybe teach InstCombiner::FoldOpIntoSelect to handle cases where one of the select operands becomes a constant if we fold. But we might only call FoldOpIntoSelect when one of the operands of the binop is a constant today.

I think we also miss
x + (c ? -x : y) -> c ? 0 : x + y 
x - (c ? x : y) -> c ? 0 : x - y

Also does InstSimplify know X / -X -> -1 when the neg has NSW?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71312





More information about the llvm-commits mailing list