[PATCH] D132996: [InstCombine] complete fold extractvalue (any_mul_with_overflow X, -1)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 04:53:41 PDT 2022


spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

LGTM - see inline for an extra test request.



================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:3290
   // checking for overflow.
-  const APInt *C;
-  if (match(WO->getRHS(), m_APInt(C))) {
+  if (WORHSC) {
     // Compute the no-wrap range for LHS given RHS=C, then construct an
----------------
Chenbing.Zheng wrote:
> spatel wrote:
> > We need a test for this transform too? (and confirm that it is safe)
> It seems that the tests we fix in this patch can also test for this transform, and I add Alive2 conform in summary.
Ah, sorry - I didn't notice that the test diffs showed the transform was partly enabled (because m_AllOnes accepts undef).

It would still be good to have an explicit test for this path, so please add a test like this with "not-negative-one" constant:

```
define <4 x i1> @smul_neg1_vec_poison(<4 x i8> %x) {
  %m = call { <4 x i8>, <4 x i1> } @llvm.smul.with.overflow.v4i8(<4 x i8> %x, <4 x i8> <i8 -3, i8 -3, i8 poison, i8 -3>)
  %ov = extractvalue { <4 x i8>, <4 x i1> } %m, 1
  ret <4 x i1> %ov
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132996



More information about the llvm-commits mailing list