This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Prevent constant hoisting for (ashr (add (shl X, 32), C<<32), 32).
AbandonedPublic

Authored by craig.topper on Aug 4 2022, 3:03 PM.

Details

Summary

Instead of hoisting the C<<32, keep in place so DAGCombiner can
match the pattern to an addw.

Diff Detail

Event Timeline

craig.topper created this revision.Aug 4 2022, 3:03 PM
Herald added a project: Restricted Project. · View Herald Transcript
craig.topper requested review of this revision.Aug 4 2022, 3:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2022, 3:03 PM
ributzka added inline comments.Aug 4 2022, 8:28 PM
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
42

Is this DAGCombine RISCV specific or a generic combine?

craig.topper added inline comments.Aug 4 2022, 8:29 PM
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
42

It's RISC-V specific. See https://reviews.llvm.org/D128869

Explicitly check the opcode of Inst in isShiftedADDWOrSUBW. This can get called with Opcode
being Instruction::Add, but the instruction being a GEP.

ributzka accepted this revision.Aug 4 2022, 8:41 PM

RISCV is not my expertise, but LGTM with respect to constant hoisting.

This revision is now accepted and ready to land.Aug 4 2022, 8:41 PM

Make sure all 3 instructions are in the same BB to be sure the pattern can be matched.

craig.topper abandoned this revision.Aug 5 2022, 1:34 PM

Abandoning in favor a pre-consthoist peephole in RISCVCodeGenPrepare. The single basic block restriction is too restrictive. We need to help SelectionDAG out here.