diff options
author | Guozhi Wei <carrot@google.com> | 2019-01-31 20:46:42 +0000 |
---|---|---|
committer | Guozhi Wei <carrot@google.com> | 2019-01-31 20:46:42 +0000 |
commit | 0bed9e0453e1298f4323a3ec5d94a6e812d53612 (patch) | |
tree | e304ac9a1043c8903a402067e2cc381f7fd6f15c /llvm/lib/Transforms/Utils/ModuleUtils.cpp | |
parent | f47d6b38c7a61d50db4566b02719de05492dcef1 (diff) | |
download | llvm-0bed9e0453e1298f4323a3ec5d94a6e812d53612.zip llvm-0bed9e0453e1298f4323a3ec5d94a6e812d53612.tar.gz llvm-0bed9e0453e1298f4323a3ec5d94a6e812d53612.tar.bz2 |
[DAGCombine] Avoid CombineZExtLogicopShiftLoad if there is free ZEXT
This patch fixes pr39098.
For the attached test case, CombineZExtLogicopShiftLoad can optimize it to
t25: i64 = Constant<1099511627775>
t35: i64 = Constant<0>
t0: ch = EntryToken
t57: i64,ch = load<(load 4 from `i40* undef`, align 8), zext from i32> t0, undef:i64, undef:i64
t58: i64 = srl t57, Constant:i8<1>
t60: i64 = and t58, Constant:i64<524287>
t29: ch = store<(store 5 into `i40* undef`, align 8), trunc to i40> t57:1, t60, undef:i64, undef:i64
But later visitANDLike transforms it to
t25: i64 = Constant<1099511627775>
t35: i64 = Constant<0>
t0: ch = EntryToken
t57: i64,ch = load<(load 4 from `i40* undef`, align 8), zext from i32> t0, undef:i64, undef:i64
t61: i32 = truncate t57
t63: i32 = srl t61, Constant:i8<1>
t64: i32 = and t63, Constant:i32<524287>
t65: i64 = zero_extend t64
t58: i64 = srl t57, Constant:i8<1>
t60: i64 = and t58, Constant:i64<524287>
t29: ch = store<(store 5 into `i40* undef`, align 8), trunc to i40> t57:1, t60, undef:i64, undef:i64
And it triggers CombineZExtLogicopShiftLoad again, causes a dead loop.
Both forms should generate same instructions, CombineZExtLogicopShiftLoad generated IR looks cleaner. But it looks more difficult to prevent visitANDLike to do the transform, so I prevent CombineZExtLogicopShiftLoad to do the transform if the ZExt is free.
Differential Revision: https://reviews.llvm.org/D57491
llvm-svn: 352792
Diffstat (limited to 'llvm/lib/Transforms/Utils/ModuleUtils.cpp')
0 files changed, 0 insertions, 0 deletions