This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] complete fold extractvalue (any_mul_with_overflow X, -1)
ClosedPublic

Authored by Chenbing.Zheng on Aug 31 2022, 12:17 AM.

Details

Summary

When we do extractvalue (any_mul_with_overflow X, -1) --> (-X and icmp),
which left partly failed to match vector constant with poison element.
This patch try to fix it.

Alive2: https://alive2.llvm.org/ce/z/2rGp_3

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2022, 12:17 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
Chenbing.Zheng requested review of this revision.Aug 31 2022, 12:17 AM

Does this confirm with Alive2? (add link to patch summary)

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
3259–3266

Nit: that's a lot of capital letters. Just leave this named "C"?

3295

We need a test for this transform too? (and confirm that it is safe)

Chenbing.Zheng edited the summary of this revision. (Show Details)

add alive2 in summary

Chenbing.Zheng marked an inline comment as done.Aug 31 2022, 8:13 PM
Chenbing.Zheng added inline comments.
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
3295

It seems that the tests we fix in this patch can also test for this transform, and I add Alive2 conform in summary.

spatel accepted this revision.Sep 1 2022, 4:53 AM

LGTM - see inline for an extra test request.

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
3295

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
}
This revision is now accepted and ready to land.Sep 1 2022, 4:53 AM
This revision was landed with ongoing or failed builds.Sep 1 2022, 8:00 PM
This revision was automatically updated to reflect the committed changes.