This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Add SimplifyDemandedBits to SimplifyDemandedVectorElts simplification
ClosedPublic

Authored by RKSimon on Oct 5 2018, 9:55 AM.

Details

Summary

This patch enables SimplifyDemandedBits to call SimplifyDemandedVectorElts in cases where the demanded bits mask covers entire elements of a bitcasted source vector.

There are a couple of cases here where simplification at a deeper level (such as through bitcasts) prevents further simplification - CommitTargetLoweringOpt only adds immediate uses/users back to the worklist when we might want to combine the original caller again to see what else it can simplify.

As well as that I had to disable handling of bool vector until SimplifyDemandedVectorElts better supports some of their opcodes (SETCC, shifts etc.).

Fixes PR39178

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Oct 5 2018, 9:55 AM
craig.topper added inline comments.Oct 5 2018, 10:15 AM
lib/CodeGen/SelectionDAG/TargetLowering.cpp
1213 ↗(On Diff #168483)

What exactly happens if you add bool vectors in today?

RKSimon added inline comments.Oct 5 2018, 10:17 AM
lib/CodeGen/SelectionDAG/TargetLowering.cpp
1213 ↗(On Diff #168483)

Mainly a load of extra gpr ANDs and kmask KSHIFTL/KSHIFTR

RKSimon added inline comments.Oct 5 2018, 10:20 AM
lib/CodeGen/SelectionDAG/TargetLowering.cpp
1213 ↗(On Diff #168483)

It won't be much work to fix them, I'd just prefer to do them later on.

craig.topper added inline comments.Oct 5 2018, 10:33 AM
lib/CodeGen/SelectionDAG/TargetLowering.cpp
1234 ↗(On Diff #168483)

Is this equivalent to APInt::getSplat(NumSrcElts, DemandedSubElts)?

RKSimon added inline comments.Oct 5 2018, 11:12 AM
lib/CodeGen/SelectionDAG/TargetLowering.cpp
1234 ↗(On Diff #168483)

Yup - never knew about that function!

RKSimon updated this revision to Diff 168496.Oct 5 2018, 11:25 AM

Use APInt::getSplat

This revision is now accepted and ready to land.Oct 5 2018, 12:24 PM
This revision was automatically updated to reflect the committed changes.