[PATCH] D41576: [SCEV] Be careful with nuw/nsw in InsertBinop

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 26 01:23:17 PST 2017


skatkov created this revision.
skatkov added reviewers: sanjoy, mkazantsev, sebpop, jbhateja.

InsertBinop tries to find an appropriate instruction instead of
creating a new instruction. When it check whether instruction is
the same as we need to create it ignores nuw/nsw flags.

It leads to invalid behavior when poison instruction can be used
when it was not expected. Specifically, for example Expander
expands the SCEV built for instruction
%a = add i32 %v, 1
It is possible that InsertBinop can find an instruction
% b = add nuw nsw i32 %v, 1
and will use it instead of version w/o nuw nsw.
It is incorrect.

The patch conservatively ignores all instructions with any of
wrap flags installed.


https://reviews.llvm.org/D41576

Files:
  lib/Analysis/ScalarEvolutionExpander.cpp
  unittests/Analysis/ScalarEvolutionTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41576.128153.patch
Type: text/x-patch
Size: 4547 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171226/e4f83e34/attachment.bin>


More information about the llvm-commits mailing list