75 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -O2 | FileCheck %s3 4; Test for issue #160612: OR conditions in branches should use multiple branches5; instead of materializing booleans with SETCC when no special optimizations apply.6 7declare void @subroutine_foo()8declare void @subroutine_bar()9 10; Original issue: (x == 0 || y == 0) was generating SETCC + TEST + BRANCH11; instead of using two conditional branches directly.12define void @func_a(i32 noundef %x, i32 noundef %y) {13; CHECK-LABEL: func_a:14; CHECK: # %bb.0: # %entry15; CHECK-NEXT: testl %edi, %edi16; CHECK-NEXT: je subroutine_foo@PLT # TAILCALL17; CHECK-NEXT: # %bb.1: # %entry18; CHECK-NEXT: testl %esi, %esi19; CHECK-NEXT: jne subroutine_bar@PLT # TAILCALL20; CHECK-NEXT: # %bb.2: # %if.then21; CHECK-NEXT: jmp subroutine_foo@PLT # TAILCALL22entry:23 %cmp = icmp eq i32 %x, 024 %cmp1 = icmp eq i32 %y, 025 %or.cond = or i1 %cmp, %cmp126 br i1 %or.cond, label %if.then, label %if.else27 28if.then:29 tail call void @subroutine_foo()30 br label %if.end31 32if.else:33 tail call void @subroutine_bar()34 br label %if.end35 36if.end:37 ret void38}39 40; Reference implementation that already generated optimal code.41; This should continue to generate the same optimal code.42define void @func_b(i32 noundef %x, i32 noundef %y) {43; CHECK-LABEL: func_b:44; CHECK: # %bb.0: # %entry45; CHECK-NEXT: testl %edi, %edi46; CHECK-NEXT: je subroutine_foo@PLT # TAILCALL47; CHECK-NEXT: # %bb.1: # %if.else48; CHECK-NEXT: testl %esi, %esi49; CHECK-NEXT: je subroutine_foo@PLT # TAILCALL50; CHECK-NEXT: # %bb.2: # %if.else351; CHECK-NEXT: jmp subroutine_bar@PLT # TAILCALL52entry:53 %cmp = icmp eq i32 %x, 054 br i1 %cmp, label %if.then, label %if.else55 56if.then:57 tail call void @subroutine_foo()58 br label %if.end459 60if.else:61 %cmp1 = icmp eq i32 %y, 062 br i1 %cmp1, label %if.then2, label %if.else363 64if.then2:65 tail call void @subroutine_foo()66 br label %if.end467 68if.else3:69 tail call void @subroutine_bar()70 br label %if.end471 72if.end4:73 ret void74}75