@@ -636,16 +636,17 @@ exit:
636
636
ret i32 %outval
637
637
}
638
638
639
- ; FIXME: Merging the icmps with logic-op defeats the purpose of the metadata.
639
+ ; Merging the icmps with logic-op defeats the purpose of the metadata.
640
640
; We can't tell which condition is expensive if they are combined.
641
641
642
642
define void @or_icmps_harmful (i32 %x , i32 %y , i8* %p ) {
643
643
; CHECK-LABEL: @or_icmps_harmful(
644
644
; CHECK-NEXT: entry:
645
645
; 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:
646
648
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
647
- ; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[EXPECTED_TRUE]], [[EXPENSIVE]]
648
- ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !19
649
+ ; CHECK-NEXT: br i1 [[EXPENSIVE]], label [[EXIT]], label [[FALSE:%.*]]
649
650
; CHECK: false:
650
651
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
651
652
; CHECK-NEXT: br label [[EXIT]]
@@ -668,16 +669,17 @@ exit:
668
669
ret void
669
670
}
670
671
671
- ; FIXME: Merging the icmps with logic-op defeats the purpose of the metadata.
672
+ ; Merging the icmps with logic-op defeats the purpose of the metadata.
672
673
; We can't tell which condition is expensive if they are combined.
673
674
674
675
define void @or_icmps_harmful_inverted (i32 %x , i32 %y , i8* %p ) {
675
676
; CHECK-LABEL: @or_icmps_harmful_inverted(
676
677
; CHECK-NEXT: entry:
677
- ; CHECK-NEXT: [[EXPECTED_FALSE:%.*]] = icmp sle i32 [[X:%.*]], -1
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:
678
681
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
679
- ; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[EXPECTED_FALSE]], [[EXPENSIVE]]
680
- ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !19
682
+ ; CHECK-NEXT: br i1 [[EXPENSIVE]], label [[EXIT]], label [[FALSE:%.*]]
681
683
; CHECK: false:
682
684
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
683
685
; CHECK-NEXT: br label [[EXIT]]
@@ -700,15 +702,16 @@ exit:
700
702
ret void
701
703
}
702
704
703
- ; The probability threshold is set by a builtin_expect setting.
705
+ ; The probability threshold is determined by a TTI setting.
706
+ ; In this example, we are just short of strongly expected, so speculate.
704
707
705
708
define void @or_icmps_not_that_harmful (i32 %x , i32 %y , i8* %p ) {
706
709
; CHECK-LABEL: @or_icmps_not_that_harmful(
707
710
; CHECK-NEXT: entry:
708
711
; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sgt i32 [[X:%.*]], -1
709
712
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
710
713
; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[EXPECTED_TRUE]], [[EXPENSIVE]]
711
- ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !20
714
+ ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !21
712
715
; CHECK: false:
713
716
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
714
717
; CHECK-NEXT: br label [[EXIT]]
@@ -731,13 +734,16 @@ exit:
731
734
ret void
732
735
}
733
736
737
+ ; The probability threshold is determined by a TTI setting.
738
+ ; In this example, we are just short of strongly expected, so speculate.
739
+
734
740
define void @or_icmps_not_that_harmful_inverted (i32 %x , i32 %y , i8* %p ) {
735
741
; CHECK-LABEL: @or_icmps_not_that_harmful_inverted(
736
742
; CHECK-NEXT: entry:
737
743
; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sgt i32 [[X:%.*]], -1
738
744
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
739
745
; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[EXPECTED_TRUE]], [[EXPENSIVE]]
740
- ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !21
746
+ ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !22
741
747
; CHECK: false:
742
748
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
743
749
; CHECK-NEXT: br label [[EXIT]]
@@ -760,13 +766,15 @@ exit:
760
766
ret void
761
767
}
762
768
769
+ ; The 1st cmp is probably true, so speculating the 2nd is probably a win.
770
+
763
771
define void @or_icmps_useful (i32 %x , i32 %y , i8* %p ) {
764
772
; CHECK-LABEL: @or_icmps_useful(
765
773
; CHECK-NEXT: entry:
766
774
; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sle i32 [[X:%.*]], -1
767
775
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
768
776
; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[EXPECTED_TRUE]], [[EXPENSIVE]]
769
- ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !22
777
+ ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !23
770
778
; CHECK: false:
771
779
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
772
780
; CHECK-NEXT: br label [[EXIT]]
@@ -789,13 +797,15 @@ exit:
789
797
ret void
790
798
}
791
799
800
+ ; The 1st cmp is probably false, so speculating the 2nd is probably a win.
801
+
792
802
define void @or_icmps_useful_inverted (i32 %x , i32 %y , i8* %p ) {
793
803
; CHECK-LABEL: @or_icmps_useful_inverted(
794
804
; CHECK-NEXT: entry:
795
805
; CHECK-NEXT: [[EXPECTED_FALSE:%.*]] = icmp sgt i32 [[X:%.*]], -1
796
806
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
797
807
; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[EXPECTED_FALSE]], [[EXPENSIVE]]
798
- ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !22
808
+ ; CHECK-NEXT: br i1 [[OR_COND]], label [[EXIT:%.*]], label [[FALSE:%.*]], !prof !23
799
809
; CHECK: false:
800
810
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
801
811
; CHECK-NEXT: br label [[EXIT]]
@@ -849,16 +859,17 @@ exit:
849
859
ret void
850
860
}
851
861
852
- ; FIXME: Merging the icmps with logic-op defeats the purpose of the metadata.
862
+ ; Merging the icmps with logic-op defeats the purpose of the metadata.
853
863
; We can't tell which condition is expensive if they are combined.
854
864
855
865
define void @and_icmps_harmful (i32 %x , i32 %y , i8* %p ) {
856
866
; CHECK-LABEL: @and_icmps_harmful(
857
867
; CHECK-NEXT: entry:
858
868
; 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:
859
871
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
860
- ; CHECK-NEXT: [[OR_COND:%.*]] = and i1 [[EXPECTED_FALSE]], [[EXPENSIVE]]
861
- ; CHECK-NEXT: br i1 [[OR_COND]], label [[FALSE:%.*]], label [[EXIT:%.*]], !prof !23
872
+ ; CHECK-NEXT: br i1 [[EXPENSIVE]], label [[FALSE:%.*]], label [[EXIT]]
862
873
; CHECK: false:
863
874
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
864
875
; CHECK-NEXT: br label [[EXIT]]
@@ -881,16 +892,17 @@ exit:
881
892
ret void
882
893
}
883
894
884
- ; FIXME: Merging the icmps with logic-op defeats the purpose of the metadata.
895
+ ; Merging the icmps with logic-op defeats the purpose of the metadata.
885
896
; We can't tell which condition is expensive if they are combined.
886
897
887
898
define void @and_icmps_harmful_inverted (i32 %x , i32 %y , i8* %p ) {
888
899
; CHECK-LABEL: @and_icmps_harmful_inverted(
889
900
; CHECK-NEXT: entry:
890
- ; CHECK-NEXT: [[EXPECTED_TRUE:%.*]] = icmp sle i32 [[X:%.*]], -1
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:
891
904
; CHECK-NEXT: [[EXPENSIVE:%.*]] = icmp eq i32 [[Y:%.*]], 0
892
- ; CHECK-NEXT: [[OR_COND:%.*]] = and i1 [[EXPECTED_TRUE]], [[EXPENSIVE]]
893
- ; CHECK-NEXT: br i1 [[OR_COND]], label [[FALSE:%.*]], label [[EXIT:%.*]], !prof !23
905
+ ; CHECK-NEXT: br i1 [[EXPENSIVE]], label [[FALSE:%.*]], label [[EXIT]]
894
906
; CHECK: false:
895
907
; CHECK-NEXT: store i8 42, i8* [[P:%.*]], align 1
896
908
; CHECK-NEXT: br label [[EXIT]]
@@ -913,6 +925,9 @@ exit:
913
925
ret void
914
926
}
915
927
928
+ ; The probability threshold is determined by a TTI setting.
929
+ ; In this example, we are just short of strongly expected, so speculate.
930
+
916
931
define void @and_icmps_not_that_harmful (i32 %x , i32 %y , i8* %p ) {
917
932
; CHECK-LABEL: @and_icmps_not_that_harmful(
918
933
; CHECK-NEXT: entry:
@@ -942,6 +957,9 @@ exit:
942
957
ret void
943
958
}
944
959
960
+ ; The probability threshold is determined by a TTI setting.
961
+ ; In this example, we are just short of strongly expected, so speculate.
962
+
945
963
define void @and_icmps_not_that_harmful_inverted (i32 %x , i32 %y , i8* %p ) {
946
964
; CHECK-LABEL: @and_icmps_not_that_harmful_inverted(
947
965
; CHECK-NEXT: entry:
@@ -971,6 +989,8 @@ exit:
971
989
ret void
972
990
}
973
991
992
+ ; The 1st cmp is probably true, so speculating the 2nd is probably a win.
993
+
974
994
define void @and_icmps_useful (i32 %x , i32 %y , i8* %p ) {
975
995
; CHECK-LABEL: @and_icmps_useful(
976
996
; CHECK-NEXT: entry:
@@ -1000,6 +1020,8 @@ exit:
1000
1020
ret void
1001
1021
}
1002
1022
1023
+ ; The 1st cmp is probably false, so speculating the 2nd is probably a win.
1024
+
1003
1025
define void @and_icmps_useful_inverted (i32 %x , i32 %y , i8* %p ) {
1004
1026
; CHECK-LABEL: @and_icmps_useful_inverted(
1005
1027
; CHECK-NEXT: entry:
0 commit comments