[PATCH] D59227: [GlobalISel][Utils] Teach getConstantVRegVal how to look through trunc and z|sext
Quentin Colombet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 11 12:51:40 PDT 2019
qcolombet added a comment.
Hi Matt,
> Why wouldn’t the combiner fold casts of constants?
The problem is, let say you have G_CONSTANT being legal only for {s16, s32}
Now consider:
%0 = G_CONSTANT i14
The legalizer will then transform that into:
%tmp = G_CONSTANT i16
%0 = G_TRUNC i16 %tmp to i14
If you were to do the constant folding within the MachineIRBuilder, this would then be transformed back into:
%0 = G_CONSTANT i14
And now you have your loop.
We could do that in the combiner and then we don't need to look through this, However, in the middle of legalization, we will still have the truncates and extensions that may not be cleaned up at all given point in the legalization and that's when we would miss to get the constant value.
> Do any of these testcases hit the legalization loop problem you mentioned?
No, they just happen to exercise the code I added.
The problem I have arises during legalization with an out-of-tree target.
Essentially, we promote some illegal operation, then end-up with extensions in the way of the constants and some custom legalization fails (without this patch) because we don't support non-constant patterns.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59227/new/
https://reviews.llvm.org/D59227
More information about the llvm-commits
mailing list