[llvm] [InstCombine] Simplify and/or by replacing operands with constants (PR #77231)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 16 09:02:46 PST 2024
dtcxzyw wrote:
> Could you check whether this patch simplifies (or partially) the example like https://alive2.llvm.org/ce/z/7MHnzm? It's a piece of unreduced real-world IR. It seems to be covered by the `X & Y` case here. If so, I could post a issue for it without reduction.
Optimized result:
```
define dso_local noundef zeroext i1 @src(i64 noundef %features) local_unnamed_addr {
for.inc.1310:
%svq_features.1.3 = and i64 %features, -7784628225
%and.5 = and i64 %features, 8589934592
%or.5 = xor i64 %and.5, 8589934592
%spec.select13.4 = or i64 %svq_features.1.3, %or.5
%spec.select13.5 = or disjoint i64 %spec.select13.4, 4294967296
%and4.6 = and i64 %features, 17179869184
%tobool5.not.6 = icmp eq i64 %and4.6, 0
%and8.6 = and i64 %spec.select13.5, -20669530113
%svq_features.1.6 = select i1 %tobool5.not.6, i64 %spec.select13.5, i64 %and8.6
%and4.13 = and i64 %svq_features.1.6, 2199023255552
%tobool5.not.13 = icmp eq i64 %and4.13, 0
br i1 %tobool5.not.13, label %for.inc.13, label %if.then11
for.inc.13: ; preds = %for.inc.1310
%0 = and i64 %features, 16374562816
%narrow = icmp eq i64 %0, 12884901888
%and4.7 = and i64 %svq_features.1.6, 34359738368
%i2 = or disjoint i64 %and4.7, %and4.6
%i3 = icmp eq i64 %i2, 0
%1 = and i64 %svq_features.1.6, 2130303778816
%i8 = icmp eq i64 %1, 0
%i9 = select i1 %i8, i1 %i3, i1 false
%narrow31 = and i1 %narrow, %i9
br i1 %narrow31, label %if.end12, label %if.then11
if.then11: ; preds = %for.inc.13, %for.inc.1310
%svq_features.2.13 = and i64 %svq_features.1.6, -4367176433665
tail call void @use(i64 noundef %svq_features.2.13)
br label %if.end12
if.end12: ; preds = %if.then11, %for.inc.13
%tobool1022 = phi i1 [ false, %if.then11 ], [ true, %for.inc.13 ]
ret i1 %tobool1022
}
```
https://github.com/llvm/llvm-project/pull/77231
More information about the llvm-commits
mailing list