[PATCH] D32285: [InstCombineCasts] Fix checks in sext->lshr->trunc pattern.
Jacob Young via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 9 05:45:51 PDT 2017
jacobly added a comment.
All that needs to be changed to fix the test91 miscompile is changing ShiftAmt < ASize to ShiftAmt <= SExtSize - ASize. However, making this change actually introduces the test93 miscompile because the original code already assured that ShiftAmt < ASize (which is correct for avoiding a ub shift, but incorrect for avoiding pulling zero bits into the value). Note that by far the most common case of SExtSize >= 2*ASize (which is always true when all types are powers of 2) doesn't actually miscompile (because then ASize <= SExtSize - ASize anyway). I was planning on adding more optimization opportunities in a separate patch, but I'm not sure how to separate this change without introducing a miscompile. I could separate out the naming common subexpressions with variables if that helps.
https://reviews.llvm.org/D32285
More information about the llvm-commits
mailing list