[PATCH] D130839: [DAG] FoldConstantArithmetic - add initial support for undef elements in bitcasted binop constant folding
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 2 02:13:39 PDT 2022
RKSimon added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:5589
+ if (!(IsUndef1 || IsUndef2))
+ Fold = FoldValue(Opcode, C1, C2);
+ else if (Opcode == ISD::AND || Opcode == ISD::MUL)
----------------
xiangzhangllvm wrote:
> RKSimon wrote:
> > xiangzhangllvm wrote:
> > > Do we need to make sure the C1 C2 has no other uses ?
> > I don't think we have any one use limits on constant folding?
> Yes, sorry my mistake at first.
> take following case for example:
> ```
> A = and(x, undef)
> C = A op B
> ```
> If we directly let "A = 0" (I think A=undef before), seems it may break the undef propagation in other use. for example C when "op" can do undef propagation (but not constant zero propagation).
```
A = and(x, undef)
C = A op B
```
A can't (or shouldn't) propagate undef: https://alive2.llvm.org/ce/z/0EB60y - we almost certainly have cases of that in code, which need addressing
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130839/new/
https://reviews.llvm.org/D130839
More information about the llvm-commits
mailing list