[PATCH] D116941: [GlobalISel] Fix incorrect sign extension when combining G_INTTOPTR and G_ADD
Lucas Prates via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 10 07:21:32 PST 2022
pratlucas created this revision.
Herald added subscribers: hiraditya, arichardson, rovka.
pratlucas requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The GlobalISel combiner currently uses sign extension when manipulating
the LHS constant when combining a sequence of the following sequence of
machine instructions into a single constant:
%0:_(s32) = G_CONSTANT i32 <CONSTANT>
%1:_(p0) = G_INTTOPTR %0:_(s32)
%2:_(s64) = G_CONSTANT i64 <CONSTANT>
%3:_(p0) = G_PTR_ADD %1:_, %2:_(s64)
This causes an issue when the bit width of the first contant and the
target pointer size are different, as G_INTTOPTR has no sign extension
semantics.
This patch fixes this by capture an arbitrary precision in when matching
the constant, allowing the matching function to correctly zero extend
it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D116941
Files:
llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/test/CodeGen/AArch64/GlobalISel/combine-inttoptr-add.mir
llvm/test/CodeGen/AArch64/GlobalISel/inttoptr_add.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116941.398630.patch
Type: text/x-patch
Size: 4036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220110/d7f4f6b5/attachment.bin>
More information about the llvm-commits
mailing list