[PATCH] D46413: [GlobalISel][Legalizer] Widening the second src op of shifts bug fix

Roman Tereshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 3 16:59:46 PDT 2018


rtereshin created this revision.
rtereshin added reviewers: bogner, rovka, aivchenk.
Herald added a subscriber: kristof.beyls.
Herald added a reviewer: javed.absar.

The second source operand of G_SHL, G_ASHR, and G_LSHR must preserve its
value as a (small) unsigned integer, therefore its incorrect to widen it
in any way but by zero extending it.

G_SHL was using G_ANYEXT and G_ASHR - G_SEXT (which is correct for their
destination and first source operands, but not the "number of bits to
shift" operand).

Generally, shifts aren't as similar to regular binary operations as it
might seem, for instance, they aren't commutative nor associative and
the second source operand usually requires a special treatment.


Repository:
  rL LLVM

https://reviews.llvm.org/D46413

Files:
  lib/CodeGen/GlobalISel/LegalizerHelper.cpp
  test/CodeGen/AArch64/GlobalISel/legalize-shift.mir
  test/CodeGen/X86/GlobalISel/ashr-scalar.ll
  test/CodeGen/X86/GlobalISel/shl-scalar.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46413.145119.patch
Type: text/x-patch
Size: 7879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180503/5bbf27e2/attachment.bin>


More information about the llvm-commits mailing list