This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Use KnownBits struct in DAG's computeKnownBits and simplifyDemandedBits
ClosedPublic

Authored by craig.topper on Apr 26 2017, 4:20 PM.

Details

Summary

This patch replaces the separate APInts for KnownZero/KnownOne with a single KnownBits struct. This is similar to what was done to ValueTracking's version earlier today.

This should be a largely mechanical transformation from KnownZero to Known.Zero.

There are a few several places where I replaced

KnownZero = KnownOne = APInt(KnownZero.getBitWidth(), 0)

with

Known.Zero.clearAllBits(); Known.One.clearAllBits();

since the width was already dependent on KnownZero.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Apr 26 2017, 4:20 PM
RKSimon accepted this revision.Apr 27 2017, 7:20 AM

LGTM, I noticed a few APInt missed optimizations but nothing bound to this patch.

lib/CodeGen/SelectionDAG/DAGCombiner.cpp
7182 ↗(On Diff #96845)

subsetof (as pre-commit)

lib/CodeGen/SelectionDAG/SelectionDAG.cpp
2316 ↗(On Diff #96845)

<<= (pre-commit)

lib/CodeGen/SelectionDAG/TargetLowering.cpp
967 ↗(On Diff #96845)

subsetof

This revision is now accepted and ready to land.Apr 27 2017, 7:20 AM
craig.topper closed this revision.Apr 27 2017, 10:15 PM
craig.topper marked an inline comment as done.

Commited in r301618. Forgot the Differential Revision line in the commit message.

This revision is now accepted and ready to land.Apr 27 2017, 10:16 PM
This revision was automatically updated to reflect the committed changes.
hokein added a subscriber: hokein.Apr 28 2017, 1:17 AM

@craig.topper, your patch seems to break the WebAssembly builds:

In file included from ../lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp:63:0:
lib/Target/WebAssembly/WebAssemblyGenDAGISel.inc: In member function ‘virtual bool {anonymous}::WebAssemblyDAGToDAGISel::CheckNodePredicate(llvm::SDNode*, unsigned int) const’:
lib/Target/WebAssembly/WebAssemblyGenDAGISel.inc:5693:70: error: no matching function for call to ‘llvm::SelectionDAG::computeKnownBits(const llvm::SDValue&, llvm::APInt&, llvm::APInt&, int)’
   CurDAG->computeKnownBits(N->getOperand(0), KnownZero0, KnownOne0, 0);
                                                                      ^
lib/Target/WebAssembly/WebAssemblyGenDAGISel.inc:5693:70: note: candidates are:
In file included from ../include/llvm/Target/TargetLowering.h:35:0,
                 from ../lib/Target/WebAssembly/WebAssemblyISelLowering.h:19,
                 from ../lib/Target/WebAssembly/WebAssemblySubtarget.h:20,
                 from ../lib/Target/WebAssembly/WebAssemblyTargetMachine.h:19,
                 from ../lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp:17:
../include/llvm/CodeGen/SelectionDAG.h:1291:8: note: void llvm::SelectionDAG::computeKnownBits(llvm::SDValue, llvm::KnownBits&, unsigned int) const
   void computeKnownBits(SDValue Op, KnownBits &Known, unsigned Depth = 0) const;
        ^
../include/llvm/CodeGen/SelectionDAG.h:1291:8: note:   candidate expects 3 arguments, 4 provided
../include/llvm/CodeGen/SelectionDAG.h:1298:8: note: void llvm::SelectionDAG::computeKnownBits(llvm::SDValue, llvm::KnownBits&, const llvm::APInt&, unsigned int) const
   void computeKnownBits(SDValue Op, KnownBits &Known, const APInt &DemandedElts,
        ^

Can you take a look on it? Thanks.