[PATCH] D88287: [NARY-REASSOCIATE] Support reassociation of min/max
Nuno Lopes via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 25 08:39:48 PST 2021
nlopes added a comment.
This patch regressed the following tests:
- LLVM :: Transforms/NaryReassociate/nary-smax.ll
- LLVM :: Transforms/NaryReassociate/nary-smin.ll
- LLVM :: Transforms/NaryReassociate/nary-umax.ll
- LLVM :: Transforms/NaryReassociate/nary-umin.ll
The reason is that it doesn't account for undef values. Example:
----------------------------------------
define i32 @smax_test1(i32 %a, i32 %b, i32 %c) {
%0:
%c1 = icmp sgt i32 %a, %b
%smax1 = select i1 %c1, i32 %a, i32 %b
%c2 = icmp sgt i32 %b, %c
%smax2 = select i1 %c2, i32 %b, i32 %c
%c3 = icmp sgt i32 %smax2, %a
%smax3 = select i1 %c3, i32 %smax2, i32 %a
%res = add i32 %smax1, %smax3
ret i32 %res
}
=>
define i32 @smax_test1(i32 %a, i32 %b, i32 %c) {
%0:
%c1 = icmp sgt i32 %a, %b
%smax1 = select i1 %c1, i32 %a, i32 %b
%1 = icmp sgt i32 %smax1, %c
%smax3.nary = select i1 %1, i32 %smax1, i32 %c
%res = add i32 %smax1, %smax3.nary
ret i32 %res
}
Transformation doesn't verify!
ERROR: Target's return value is more undefined
Example:
i32 %a = #x7fffffff (2147483647)
i32 %b = #x00000000 (0)
i32 %c = undef
Source:
i1 %c1 = #x1 (1)
i32 %smax1 = #x7fffffff (2147483647)
i1 %c2 = any
i32 %smax2 = any
i1 %c3 = #x0 (0)
i32 %smax3 = #x7fffffff (2147483647)
i32 %res = #xfffffffe (4294967294, -2)
Target:
i1 %c1 = #x1 (1)
i32 %smax1 = #x7fffffff (2147483647)
i1 %1 = #x0 (0)
i32 %smax3.nary = #x03002006 (50339846)
i32 %res = #x83002005 (2197823493, -2097143803)
Source value: #xfffffffe (4294967294, -2)
Target value: #x83002005 (2197823493, -2097143803)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88287/new/
https://reviews.llvm.org/D88287
More information about the llvm-commits
mailing list