[LSR] Call canonicalize after we generate a new Formula in GenerateTruncates. Fix...
authorWei Mi <wmi@google.com>
Thu, 18 May 2017 17:21:22 +0000 (17:21 +0000)
committerWei Mi <wmi@google.com>
Thu, 18 May 2017 17:21:22 +0000 (17:21 +0000)
commit8848c1e3c7e94eac2b207fa4418419d8d6765e20
treea9d18013ad759854f533f81d7e4a319a3678962f
parent8b61764cbba4136e038fd94e035f1e965c82ba52
[LSR] Call canonicalize after we generate a new Formula in GenerateTruncates. Fix PR33077.

The testcase in PR33077 generates a LSR Use Formula with two SCEVAddRecExprs for the same
loop. Such uncommon formula will become non-canonical after GenerateTruncates adds sign
extension to the ScaledReg of the Formula, and it will break the assertion that every
Formula to be inserted is canonical.

The fix is to call canonicalize for the raw Formula generated by GenerateTruncates
before inserting it.

llvm-svn: 303361
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/test/Transforms/LoopStrengthReduce/X86/canonical-2.ll [new file with mode: 0644]