This is an archive of the discontinued LLVM Phabricator instance.

Fix SGPR + offset Scratch offset folding
ClosedPublic

Authored by Petar.Avramovic on Feb 28 2023, 4:42 AM.

Details

Reviewers
foad
dstuttard
Group Reviewers
Restricted Project
Commits
rG5e56d5999914: Fix SGPR + offset Scratch offset folding
Summary

Values in SGPR register are treated as unsigned by hardware.

When value in 32-bit SGPR base can be negative calculate offset using
32-bit add instruction, otherwise use sgpr base(unsigned) + offset.
Does not affect case where whole offset comes from SGPR register
(immediate offset is 0).

LoopStrengthReduce.cpp changes offsets to negative and in some
iterations value in SGPR register could be negative.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2023, 4:42 AM
Petar.Avramovic requested review of this revision.Feb 28 2023, 4:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2023, 4:42 AM
foad accepted this revision.Feb 28 2023, 9:12 AM
This revision is now accepted and ready to land.Feb 28 2023, 9:12 AM
arsenm added a comment.Mar 2 2023, 5:02 AM

Missing corresponding globalisel change?

llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
1766

SignBitIsZero?

add same checks for globalisel

foad added inline comments.Mar 8 2023, 8:51 AM
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
16 ↗(On Diff #503384)

Just include SIDefines.h here?

foad accepted this revision.Mar 8 2023, 9:06 AM
This revision was automatically updated to reflect the committed changes.