[llvm] [InstCombine] Optimize redundant floating point comparisons in `or`/`and` inst's (PR #158097)
Rajveer Singh Bharadwaj via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 15 04:48:26 PDT 2025
================
@@ -4657,3 +4657,107 @@ define i1 @or_fcmp_reassoc4(i1 %x, double %a, double %b) {
%retval = or i1 %cmp1, %or
ret i1 %retval
}
+
+define i1 @or_fcmp_redundant_or1(ptr %arg0) {
+; CHECK-LABEL: @or_fcmp_redundant_or1(
+; CHECK-NEXT: [[V0:%.*]] = load double, ptr [[ARG0:%.*]], align 8
+; CHECK-NEXT: [[V2:%.*]] = fcmp nsz olt double [[V0]], 1.990000e+00
+; CHECK-NEXT: ret i1 [[V2]]
+;
+ %v0 = load double, ptr %arg0, align 8
+ %v1 = fcmp nsz olt double %v0, 1.000000e-02
+ %v2 = fcmp nsz olt double %v0, 1.990000e+00
+ %v3 = or i1 %v1, %v2
+ ret i1 %v3
+}
----------------
Rajveer100 wrote:
Not sure what you meant here, adding more combinations with multiple conditions?
https://github.com/llvm/llvm-project/pull/158097
More information about the llvm-commits
mailing list