[PATCH] D48754: [InstCombine] canonicalize abs pattern
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 16 07:23:28 PDT 2018
spatel added a comment.
Actually, it will fail even without the extra use, so this is a minimal test:
define i32 @abs_canonical_9(i32 %a, i32 %b) {
%tmp2 = sub i32 %b, %a
%tmp1 = sub i32 %a, %b
%cmp = icmp sgt i32 %tmp1, -1
%abs = select i1 %cmp, i32 %tmp1, i32 %tmp2
ret i32 %abs
}
We can not just replace operands without considering the order of the instructions. It would be better to create a new instruction with the IRBuilder, so we don't have to worry about this problem.
https://reviews.llvm.org/D48754
More information about the llvm-commits
mailing list