[llvm] [X86][APX] Combine and/or with freeze to ccmp/ctest (PR #192362)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 15 21:10:40 PDT 2026
================
@@ -1816,5 +1816,43 @@ if.end: ; preds = %entry, %if.then
ret void
}
+; Fast-math patterns with CCMP instructions.
+; Fast-math canonicalization can introduce FREEZE nodes around SETCC operations,
+; and these tests verify that CCMP pattern matching works through those FREEZE
+; nodes.
+define i32 @test_or_fp_int(double %a, double %b, i32 %c, i32 %d) {
+; CHECK-LABEL: test_or_fp_int:
+; CHECK: # %bb.0:
+; CHECK-NEXT: ucomisd %xmm1, %xmm0 # encoding: [0x66,0x0f,0x2e,0xc1]
+; CHECK-NEXT: ccmpal {dfv=} %esi, %edi # encoding: [0x62,0xf4,0x04,0x07,0x39,0xf7]
+; CHECK-NEXT: setne %al # encoding: [0x0f,0x95,0xc0]
+; CHECK-NEXT: movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]
+; CHECK-NEXT: retq # encoding: [0xc3]
+;
+; NDD-LABEL: test_or_fp_int:
+; NDD: # %bb.0:
+; NDD-NEXT: ucomisd %xmm1, %xmm0 # encoding: [0x66,0x0f,0x2e,0xc1]
+; NDD-NEXT: ccmpal {dfv=} %esi, %edi # encoding: [0x62,0xf4,0x04,0x07,0x39,0xf7]
+; NDD-NEXT: setne %al # encoding: [0x0f,0x95,0xc0]
+; NDD-NEXT: movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]
+; NDD-NEXT: retq # encoding: [0xc3]
+;
+; SETZUCC-LABEL: test_or_fp_int:
+; SETZUCC: # %bb.0:
+; SETZUCC-NEXT: cmpl %esi, %edi # encoding: [0x39,0xf7]
+; SETZUCC-NEXT: setzune %al # encoding: [0x62,0xf4,0x7f,0x18,0x45,0xc0]
----------------
phoebewang wrote:
Is setzucc good or bad than ccmp here? But it is an independent question.
https://github.com/llvm/llvm-project/pull/192362
More information about the llvm-commits
mailing list