This is an archive of the discontinued LLVM Phabricator instance.

[DemandedBits] Improve analysis of second shl operand.
AbandonedPublic

Authored by fhahn on Jul 6 2023, 9:58 AM.

Details

Summary

For SHL, the demanded bits are currently improved for the first operand
by also considering second operand. As we use the second operand to
restrict the range for the first operand, we can also use it to restrict
the range of the second operand.

Diff Detail

Event Timeline

fhahn created this revision.Jul 6 2023, 9:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 9:58 AM
fhahn requested review of this revision.Jul 6 2023, 9:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 9:58 AM
Herald added a subscriber: wdng. · View Herald Transcript
nikic requested changes to this revision.Jul 6 2023, 11:46 AM

I don't really get what you're trying to do here, but this looks clearly incorrect to me. Shift operands aren't symmetrical, and the shift amount generally has to be fully demanded.

llvm/test/Analysis/DemandedBits/shl.ll
7

This is saying that shift amounts 0x4 and 0xfffffff4 behave the same way in this operation, which is clearly not the case: The latter would return poison.

This revision now requires changes to proceed.Jul 6 2023, 11:46 AM
fhahn abandoned this revision.Jul 7 2023, 7:57 AM

Yeah I realized I was thinking backwards about it. Put up D154717 to handle the motivating issue directly.