[PATCH] D148210: [InstCombine] icmp(MulC * X * Y, C) --> icmp(X * Y, C)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 16 01:13:20 PDT 2023


nikic added a comment.

In D148210#4271709 <https://reviews.llvm.org/D148210#4271709>, @junaire wrote:

> I tried to unify `icmp((MulC * X) * Y, C)` and `icmp(X * MulC, C)` but it looks like adds more complexity. Because we have to extract the `MulC` bit by bit in case 1 in order to also get the `nsw` flags. And for case 2 `MulC` is needed in the below folds (MulC can't be zero or `X * MulC == C --> X == C/MulC` doesn't work anymore). What's more `C < 0` is OK for case 2 but it doesn't apply to case 1. That said, though these cases have almost the same effect, they don't actually share too much common code...

I'm not sure what you mean here. Why does MulC need to be extracted bit by bit? Don't we just need to implement these two rules on whether nuw/nsw can be preserved during reassociation? https://alive2.llvm.org/ce/z/KKtP62 https://alive2.llvm.org/ce/z/jgrYGB


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148210



More information about the llvm-commits mailing list