Allow SimplifyDemandedBits to use TargetLoweringOpt::computeKnownBits to look through bitcasted constants. This can help simplifying in some cases where bitcasts of constants generated during or after legalization can't be folded away, and thus didn't get picked up by SimplifyDemandedBits. This fixes PR34620, where a redundant pand created during legalization from lowering and lshr <16xi8> wasn't being simplified due to the presence of a bitcasted build_vector as an operand.
Details
Diff Detail
Event Timeline
lib/CodeGen/SelectionDAG/TargetLowering.cpp | ||
---|---|---|
1225 | Would this catch more if we used isConstantOrConstantVector from DAGCombiner.cpp (we'd have to move it to SelectionDAG.h or similar)? |
lib/CodeGen/SelectionDAG/TargetLowering.cpp | ||
---|---|---|
1225 | Why do we need to the constant qualifier at all? Isn't it generally useful to get any known bits from the other side of the bitcast? |
lib/CodeGen/SelectionDAG/TargetLowering.cpp | ||
---|---|---|
1225 | +1 Removing the isConstOrConstSplat condition entirely unearths a number of other improvements to various tests. |
lib/CodeGen/SelectionDAG/TargetLowering.cpp | ||
---|---|---|
1225 | I've updated to remove the isConstOrConstSplat condition. I originally added that because I was worried about hurting build times too much (since computeKnownBits can get pretty expensive), but if it unearths improvements to a lot of tests then it makes sense to remove the check. I'll work on updating the tests that are affected. |
@sameconrad Any update on the test fixes? I have a local version of the patch if its useful
Would this catch more if we used isConstantOrConstantVector from DAGCombiner.cpp (we'd have to move it to SelectionDAG.h or similar)?