[PATCH] D45287: [InstCombine] Properly change GEP type when reassociating loop invariant GEP chains

Daniel Neilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 4 13:49:19 PDT 2018


dneilson created this revision.
dneilson added reviewers: sebpop, spatel.

This is a fix to PR37005.

Essentially, https://reviews.llvm.org/rL328539 ([InstCombine] reassociate loop invariant GEP chains to enable LICM) contains a bug
whereby it will convert:
%src = getelementptr inbounds i8, i8* %base, <2 x i64> %val
%res = getelementptr inbounds i8, <2 x i8*> %src, i64 %val2
into:
%src = getelementptr inbounds i8, i8* %base, i64 %val2
%res = getelementptr inbounds i8, <2 x i8*> %src, <2 x i64> %val

By swapping the index operands if the GEPs are in a loop, and %val is loop variant while %val2
is loop invariant.

This fix recreates new GEP instructions if the index operand swap would result in the type
of %src changing from vector to scalar, or vice versa.


Repository:
  rL LLVM

https://reviews.llvm.org/D45287

Files:
  lib/Transforms/InstCombine/InstructionCombining.cpp
  test/Transforms/InstCombine/gep-combine-loop-invariant.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45287.141047.patch
Type: text/x-patch
Size: 6871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180404/bc04a1ec/attachment.bin>


More information about the llvm-commits mailing list