summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/shift-by-signext.ll
Commit message (Collapse)AuthorAgeFilesLines
* [InstCombine] Simplify shift-by-sext to shift-by-zextRoman Lebedev2019-09-271-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is valid for any `sext` bitwidth pair: ``` Processing /tmp/opt.ll.. ---------------------------------------- %signed = sext %y %r = shl %x, %signed ret %r => %unsigned = zext %y %r = shl %x, %unsigned ret %r %signed = sext %y Done: 2016 Optimization is correct! ``` (This isn't so for funnel shifts, there it's illegal for e.g. i6->i7.) Main motivation is the C++ semantics: ``` int shl(int a, char b) { return a << b; } ``` ends as ``` %3 = sext i8 %1 to i32 %4 = shl i32 %0, %3 ``` https://godbolt.org/z/0jgqUq which is, as this shows, too pessimistic. There is another problem here - we can only do the fold if sext is one-use. But we can trivially have cases where several shifts have the same sext shift amount. This should be resolved, later. Reviewers: spatel, nikic, RKSimon Reviewed By: spatel Subscribers: efriedma, hiraditya, nlopes, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68103 llvm-svn: 373106
* [NFC][InstCombine] Revisit shift-by-signext testsRoman Lebedev2019-09-271-18/+86
| | | | llvm-svn: 373055
* [InstCombine][NFC] Add tests for shift-by-signextRoman Lebedev2019-09-261-0/+105
llvm-svn: 373013
OpenPOWER on IntegriCloud