Page MenuHomePhabricator

[GlobalISel]: Allow targets to override how to widen constants during legalization
ClosedPublic

Authored by aditya_nandakumar on Dec 2 2019, 1:22 PM.

Details

Summary

This adds a hook to allow targets to define exactly what extension operation should be performed for widening constants. This handles cases like widening i1 true which would end up becoming -1 which affects code quality during combines.
Additionally, in order to stay consistent with how DAG is promoting constants, we now signextend for byte sized types and zero extend otherwise (by default). Targets can of course override this if necessary.

Diff Detail

Event Timeline

volkan accepted this revision.Dec 3 2019, 9:56 AM

LGTM with a nit.

llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
1166

I think this function should be a member function of LowLevelType.

This revision is now accepted and ready to land.Dec 3 2019, 9:56 AM
arsenm added inline comments.Dec 3 2019, 10:00 AM
llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
1166

LLTs should also not be passed by reference