This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Fix DAGTypeLegalizer::SplitInteger for shift amount type
ClosedPublic

Authored by yaxunl on Nov 16 2017, 2:14 PM.

Details

Summary

DAGTypeLegalizer::SplitInteger uses default pointer size as shift amount constant type,
which causes less performant ISA in amdgcn---amdgiz target since the default pointer
type is i64 whereas the desired shift amount type is i32.

This patch fixes that by using TLI.getScalarShiftAmountTy in DAGTypeLegalizer::SplitInteger.

The X86 change is necessary since splitting i512 requires shifting amount of 256, which
cannot be held by i8.

Diff Detail

Repository
rL LLVM

Event Timeline

yaxunl created this revision.Nov 16 2017, 2:14 PM
arsenm requested changes to this revision.Nov 16 2017, 6:10 PM

SplitInteger,
where default pointer type is used for the constant 16.

This is wrong. This should not be using getIntPtrConstant. For AMDGPU the shift type is always 32. If somewhere is creating a shift mask with something other than getScalarShiftAmountTy, that is a bug there.

This revision now requires changes to proceed.Nov 16 2017, 6:10 PM

SplitInteger,
where default pointer type is used for the constant 16.

This is wrong. This should not be using getIntPtrConstant. For AMDGPU the shift type is always 32. If somewhere is creating a shift mask with something other than getScalarShiftAmountTy, that is a bug there.

I see. Will fix SplitInteger to use getScalarShiftAmountTy.

yaxunl updated this revision to Diff 123352.Nov 17 2017, 8:46 AM
yaxunl edited edge metadata.
yaxunl retitled this revision from [AMDGPU] Fix SITargetLowering::lowerEXTRACT_VECTOR_ELT for constant type to [AMDGPU] Fix DAGTypeLegalizer::SplitInteger for shift amount type.
yaxunl edited the summary of this revision. (Show Details)

Revised by Matt's comments.

LGTM, but adding reviewers for x86 change

RKSimon accepted this revision.Nov 18 2017, 9:54 AM

LGTM with one minor

lib/Target/X86/X86ISelLowering.h
669 ↗(On Diff #123352)

Please can you put in an assert to check that the return type is big enough to hold the max shift value for VT.

yaxunl added inline comments.Nov 20 2017, 8:55 AM
lib/Target/X86/X86ISelLowering.h
669 ↗(On Diff #123352)

Will do. Thanks.

This revision was automatically updated to reflect the committed changes.