This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Extend G_SELECT of known condition combine to vectors.
ClosedPublic

Authored by aemerson on Sep 29 2021, 4:32 PM.

Details

Summary

Adds a new utility function: isConstantOrConstantVector().

Diff Detail

Event Timeline

aemerson created this revision.Sep 29 2021, 4:32 PM
aemerson requested review of this revision.Sep 29 2021, 4:32 PM
aemerson added inline comments.Sep 29 2021, 4:57 PM
llvm/lib/CodeGen/GlobalISel/Utils.cpp
1019–1030

Actually this doesn't have the same meaning as the DAG counterpart. This one only checks for constant scalars or splats of scalars. I'll rename this to make it clear.

aemerson updated this revision to Diff 376073.Sep 29 2021, 5:00 PM

Rename to isConstantOrConstantSplatVector().

foad added inline comments.Sep 30 2021, 1:00 AM
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
2247

New code should use isZero instead.

aemerson updated this revision to Diff 376152.Sep 30 2021, 4:03 AM
foad added inline comments.Sep 30 2021, 4:16 AM
llvm/lib/CodeGen/GlobalISel/Utils.cpp
1028

64 seems a bit imprecise here. Can't we handle the scalar and vector cases consistently, either using APInt throughout or int64_t throughout?

llvm/test/CodeGen/AArch64/GlobalISel/combine-select.mir
3

Unintended change?

aemerson updated this revision to Diff 376159.Sep 30 2021, 4:34 AM

I've changed it to use the vector element size for the APInt.

foad accepted this revision.Sep 30 2021, 5:10 AM

It still seems a bit messy that we throw away the constant's width in getBuildVectorConstantSplat and then put it back again in isConstantOrConstantSplatVector, but I guess that needn't hold up this patch.

This revision is now accepted and ready to land.Sep 30 2021, 5:10 AM