[PATCH] D105344: [DAGCombiner] Fold SETCC(FREEZE(x), y) to SETCC(x, y) if used by BRCOND
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 16 22:19:05 PDT 2021
aqjune added a comment.
> %z = op1(FREEZE(x), y)
> op2(%z)
> => // step 1
> %z = op1(FREEZE(x), FREEZE(y))
> op2(%z)
> => // step 2
> %z = op1(x, y)
> %z.fr = FREEZE(%z)
> op2(%z.fr)
> => // step 3
> %z = op1(x, y)
> op2(%z)
>
> Step 2: Relying on `canCreateUndefOrPoison` makes checking this step simpler, maybe?
I found that `canCreateUndefOrPoison` isn't enough. A non-poison-generating operation can be problematic as well.
Look at this example: https://alive2.llvm.org/ce/z/xGDGHF
%n.fr = freeze i8 %n // Assume that %n = poison
%m.fr = freeze i8 %m // Assume that %m = -128
%v = icmp slt i8 %n.fr, %m.fr // This is always false, but...
=>
%v = icmp slt i8 %n, %m // This is poison, so
%v.fr = freeze i1 %v // This (freeze poison) can be true.
ret i1 %v.fr
So, even in SETCC (which is analogous to icmp) pushing freeze should have been carefully done.
Fortunately, we only need to deal with one operand being constant, so this can be checked in advance.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105344/new/
https://reviews.llvm.org/D105344
More information about the llvm-commits
mailing list