This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add a PreprocessISelDAG peephole for (i64 (srl (and X, C)))
AbandonedPublic

Authored by craig.topper on Aug 24 2021, 4:58 PM.

Details

Summary

For cases where C is a uimm32 but not simm32. We can split the and
into (and (and X, sext32(C), 0xffffffff)). The outer and will be
selected with the srl to form srliw. The inner and will be selected
as an AND instruction with a sext32(C) materialized separately.

This prevents regressions from D108663, but is helpful on its own.

Diff Detail

Event Timeline

craig.topper created this revision.Aug 24 2021, 4:58 PM
craig.topper requested review of this revision.Aug 24 2021, 4:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2021, 4:58 PM
Herald added a subscriber: MaskRay. · View Herald Transcript

Maybe a better fix is to just move the and after the shift in DAG combine. That would guarantee bit 31 moves right at least 1 bit. That would be enough to guarantee it goes from a uimm32 constant to a simm32 constant.

craig.topper abandoned this revision.Aug 25 2021, 3:33 PM