[llvm] [InstCombine] Optimise the expression `(C & A) | (select (C ^ true), B, false) => (C & A) | (!C & B)` with `FoldOrOfAndsWithSelectToLogical` (PR #178438)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 2 06:48:49 PST 2026
================
@@ -789,6 +789,68 @@ define i1 @or_and2_commuted(i1 %a, i1 %b, i1 %c) {
ret i1 %r
}
+define i1 @fold_or_of_ands_with_select_to_logical1(i1 %a, i1 %b, i1 %c){
+; CHECK-LABEL: @fold_or_of_ands_with_select_to_logical1(
+; CHECK-NEXT: [[OR1:%.*]] = select i1 [[C:%.*]], i1 [[A:%.*]], i1 [[B:%.*]]
+; CHECK-NEXT: ret i1 [[OR1]]
+;
+ %not = xor i1 %c, true
+ %and1 = and i1 %c, %a
+ %and2 = select i1 %not, i1 %b, i1 false
----------------
boomanaiden154 wrote:
Can we add profile metadata here (and into the other tests where the output includes a select) to ensure that profile information is handled properly by this transform?
https://github.com/llvm/llvm-project/pull/178438
More information about the llvm-commits
mailing list