@@ -636,17 +636,16 @@ exit:
636636 ret i32 %outval
637637}
638638
639- ; Merging the icmps with logic-op defeats the purpose of the metadata.
639+ ; FIXME: Merging the icmps with logic-op defeats the purpose of the metadata.
640640; We can't tell which condition is expensive if they are combined.
641641
642642define void @or_icmps_harmful (i32 %x , i32 %y , i8* %p ) {
643643; CHECK-LABEL: @or_icmps_harmful(
644644; CHECK-NEXT: entry:
645645; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sgt i32 [[X:%.*]], -1
646- ; CHECK-NEXT: br i1 [[EXPECTED_TRUE]], label [[EXIT:%.*]], label [[RARE:%.*]], !prof !19
647- ; CHECK: rare:
648646; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
649- ; CHECK-NEXT: br i1 [[EXPENSIVE]], label [[EXIT]], label [[FALSE:%.*]]
647+ ; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[EXPECTED_TRUE]], [[EXPENSIVE]]
648+ ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !19
650649; CHECK: false:
651650; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
652651; CHECK-NEXT: br label [[EXIT]]
@@ -669,17 +668,16 @@ exit:
669668 ret void
670669}
671670
672- ; Merging the icmps with logic-op defeats the purpose of the metadata.
671+ ; FIXME: Merging the icmps with logic-op defeats the purpose of the metadata.
673672; We can't tell which condition is expensive if they are combined.
674673
675674define void @or_icmps_harmful_inverted (i32 %x , i32 %y , i8* %p ) {
676675; CHECK-LABEL: @or_icmps_harmful_inverted(
677676; CHECK-NEXT: entry:
678- ; CHECK-NEXT: [[EXPECTED_FALSE:%.*]] = icmp sgt i32 [[X:%.*]], -1
679- ; CHECK-NEXT: br i1 [[EXPECTED_FALSE]], label [[RARE:%.*]], label [[EXIT:%.*]], !prof !20
680- ; CHECK: rare:
677+ ; CHECK-NEXT: [[EXPECTED_FALSE:%.*]] = icmp sle i32 [[X:%.*]], -1
681678; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
682- ; CHECK-NEXT: br i1 [[EXPENSIVE]], label [[EXIT]], label [[FALSE:%.*]]
679+ ; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[EXPECTED_FALSE]], [[EXPENSIVE]]
680+ ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !19
683681; CHECK: false:
684682; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
685683; CHECK-NEXT: br label [[EXIT]]
@@ -702,16 +700,15 @@ exit:
702700 ret void
703701}
704702
705- ; The probability threshold is determined by a TTI setting.
706- ; In this example, we are just short of strongly expected, so speculate.
703+ ; The probability threshold is set by a builtin_expect setting.
707704
708705define void @or_icmps_not_that_harmful (i32 %x , i32 %y , i8* %p ) {
709706; CHECK-LABEL: @or_icmps_not_that_harmful(
710707; CHECK-NEXT: entry:
711708; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sgt i32 [[X:%.*]], -1
712709; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
713710; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[EXPECTED_TRUE]], [[EXPENSIVE]]
714- ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !21
711+ ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !20
715712; CHECK: false:
716713; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
717714; CHECK-NEXT: br label [[EXIT]]
@@ -734,16 +731,13 @@ exit:
734731 ret void
735732}
736733
737- ; The probability threshold is determined by a TTI setting.
738- ; In this example, we are just short of strongly expected, so speculate.
739-
740734define void @or_icmps_not_that_harmful_inverted (i32 %x , i32 %y , i8* %p ) {
741735; CHECK-LABEL: @or_icmps_not_that_harmful_inverted(
742736; CHECK-NEXT: entry:
743737; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sgt i32 [[X:%.*]], -1
744738; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
745739; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[EXPECTED_TRUE]], [[EXPENSIVE]]
746- ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !22
740+ ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !21
747741; CHECK: false:
748742; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
749743; CHECK-NEXT: br label [[EXIT]]
@@ -766,15 +760,13 @@ exit:
766760 ret void
767761}
768762
769- ; The 1st cmp is probably true, so speculating the 2nd is probably a win.
770-
771763define void @or_icmps_useful (i32 %x , i32 %y , i8* %p ) {
772764; CHECK-LABEL: @or_icmps_useful(
773765; CHECK-NEXT: entry:
774766; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sle i32 [[X:%.*]], -1
775767; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
776768; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[EXPECTED_TRUE]], [[EXPENSIVE]]
777- ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !23
769+ ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !22
778770; CHECK: false:
779771; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
780772; CHECK-NEXT: br label [[EXIT]]
@@ -797,15 +789,13 @@ exit:
797789 ret void
798790}
799791
800- ; The 1st cmp is probably false, so speculating the 2nd is probably a win.
801-
802792define void @or_icmps_useful_inverted (i32 %x , i32 %y , i8* %p ) {
803793; CHECK-LABEL: @or_icmps_useful_inverted(
804794; CHECK-NEXT: entry:
805795; CHECK-NEXT: [[EXPECTED_FALSE:%.*]] = icmp sgt i32 [[X:%.*]], -1
806796; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
807797; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[EXPECTED_FALSE]], [[EXPENSIVE]]
808- ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !23
798+ ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !22
809799; CHECK: false:
810800; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
811801; CHECK-NEXT: br label [[EXIT]]
@@ -859,17 +849,16 @@ exit:
859849 ret void
860850}
861851
862- ; Merging the icmps with logic-op defeats the purpose of the metadata.
852+ ; FIXME: Merging the icmps with logic-op defeats the purpose of the metadata.
863853; We can't tell which condition is expensive if they are combined.
864854
865855define void @and_icmps_harmful (i32 %x , i32 %y , i8* %p ) {
866856; CHECK-LABEL: @and_icmps_harmful(
867857; CHECK-NEXT: entry:
868858; CHECK-NEXT: [[EXPECTED_FALSE:%.*]] = icmp sgt i32 [[X:%.*]], -1
869- ; CHECK-NEXT: br i1 [[EXPECTED_FALSE]], label [[RARE:%.*]], label [[EXIT:%.*]], !prof !20
870- ; CHECK: rare:
871859; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
872- ; CHECK-NEXT: br i1 [[EXPENSIVE]], label [[FALSE:%.*]], label [[EXIT]]
860+ ; CHECK-NEXT: [[OR_COND:%.*]] = and i1 [[EXPECTED_FALSE]], [[EXPENSIVE]]
861+ ; CHECK-NEXT: br i1 [[OR_COND]], label [[FALSE:%.*]], label [[EXIT:%.*]], !prof !23
873862; CHECK: false:
874863; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
875864; CHECK-NEXT: br label [[EXIT]]
@@ -892,17 +881,16 @@ exit:
892881 ret void
893882}
894883
895- ; Merging the icmps with logic-op defeats the purpose of the metadata.
884+ ; FIXME: Merging the icmps with logic-op defeats the purpose of the metadata.
896885; We can't tell which condition is expensive if they are combined.
897886
898887define void @and_icmps_harmful_inverted (i32 %x , i32 %y , i8* %p ) {
899888; CHECK-LABEL: @and_icmps_harmful_inverted(
900889; CHECK-NEXT: entry:
901- ; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sgt i32 [[X:%.*]], -1
902- ; CHECK-NEXT: br i1 [[EXPECTED_TRUE]], label [[EXIT:%.*]], label [[RARE:%.*]], !prof !19
903- ; CHECK: rare:
890+ ; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sle i32 [[X:%.*]], -1
904891; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
905- ; CHECK-NEXT: br i1 [[EXPENSIVE]], label [[FALSE:%.*]], label [[EXIT]]
892+ ; CHECK-NEXT: [[OR_COND:%.*]] = and i1 [[EXPECTED_TRUE]], [[EXPENSIVE]]
893+ ; CHECK-NEXT: br i1 [[OR_COND]], label [[FALSE:%.*]], label [[EXIT:%.*]], !prof !23
906894; CHECK: false:
907895; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
908896; CHECK-NEXT: br label [[EXIT]]
@@ -925,9 +913,6 @@ exit:
925913 ret void
926914}
927915
928- ; The probability threshold is determined by a TTI setting.
929- ; In this example, we are just short of strongly expected, so speculate.
930-
931916define void @and_icmps_not_that_harmful (i32 %x , i32 %y , i8* %p ) {
932917; CHECK-LABEL: @and_icmps_not_that_harmful(
933918; CHECK-NEXT: entry:
@@ -957,9 +942,6 @@ exit:
957942 ret void
958943}
959944
960- ; The probability threshold is determined by a TTI setting.
961- ; In this example, we are just short of strongly expected, so speculate.
962-
963945define void @and_icmps_not_that_harmful_inverted (i32 %x , i32 %y , i8* %p ) {
964946; CHECK-LABEL: @and_icmps_not_that_harmful_inverted(
965947; CHECK-NEXT: entry:
@@ -989,8 +971,6 @@ exit:
989971 ret void
990972}
991973
992- ; The 1st cmp is probably true, so speculating the 2nd is probably a win.
993-
994974define void @and_icmps_useful (i32 %x , i32 %y , i8* %p ) {
995975; CHECK-LABEL: @and_icmps_useful(
996976; CHECK-NEXT: entry:
@@ -1020,8 +1000,6 @@ exit:
10201000 ret void
10211001}
10221002
1023- ; The 1st cmp is probably false, so speculating the 2nd is probably a win.
1024-
10251003define void @and_icmps_useful_inverted (i32 %x , i32 %y , i8* %p ) {
10261004; CHECK-LABEL: @and_icmps_useful_inverted(
10271005; CHECK-NEXT: entry:
0 commit comments