@@ -645,3 +645,134 @@ void div_assign() {
645
645
// CIRGEN-FULL: %{{.+}} = cir.complex.binop div %{{.+}}, %{{.+}} range(full) : !cir.complex<!s32i>
646
646
647
647
// CHECK: }
648
+
649
+ void unary_plus () {
650
+ cd1 = + cd1 ;
651
+ ci1 = + ci1 ;
652
+ }
653
+
654
+ // CLANG: @unary_plus
655
+ // CPPLANG: @_Z10unary_plusv
656
+
657
+ // CIRGEN: %{{.+}} = cir.unary(plus, %{{.+}}) : !cir.complex<!cir.double>, !cir.complex<!cir.double>
658
+ // CIRGEN: %{{.+}} = cir.unary(plus, %{{.+}}) : !cir.complex<!s32i>, !cir.complex<!s32i>
659
+
660
+ // CIR: %[[#OPR:]] = cir.complex.real %{{.+}} : !cir.complex<!cir.double> -> !cir.double
661
+ // CIR-NEXT: %[[#OPI:]] = cir.complex.imag %{{.+}} : !cir.complex<!cir.double> -> !cir.double
662
+ // CIR-NEXT: %[[#RESR:]] = cir.unary(plus, %[[#OPR]]) : !cir.double, !cir.double
663
+ // CIR-NEXT: %[[#RESI:]] = cir.unary(plus, %[[#OPI]]) : !cir.double, !cir.double
664
+ // CIR-NEXT: %{{.+}} = cir.complex.create %[[#RESR]], %[[#RESI]] : !cir.double -> !cir.complex<!cir.double>
665
+
666
+ // CIR: %[[#OPR:]] = cir.complex.real %{{.+}} : !cir.complex<!s32i> -> !s32i
667
+ // CIR-NEXT: %[[#OPI:]] = cir.complex.imag %{{.+}} : !cir.complex<!s32i> -> !s32i
668
+ // CIR-NEXT: %[[#RESR:]] = cir.unary(plus, %[[#OPR]]) : !s32i, !s32i
669
+ // CIR-NEXT: %[[#RESI:]] = cir.unary(plus, %[[#OPI]]) : !s32i, !s32i
670
+ // CIR-NEXT: %{{.+}} = cir.complex.create %[[#RESR]], %[[#RESI]] : !s32i -> !cir.complex<!s32i>
671
+
672
+ // LLVM: %[[#OPR:]] = extractvalue { double, double } %{{.+}}, 0
673
+ // LLVM-NEXT: %[[#OPI:]] = extractvalue { double, double } %{{.+}}, 1
674
+ // LLVM-NEXT: %[[#A:]] = insertvalue { double, double } undef, double %[[#OPR]], 0
675
+ // LLVM-NEXT: %{{.+}} = insertvalue { double, double } %[[#A]], double %[[#OPI]], 1
676
+
677
+ // LLVM: %[[#OPR:]] = extractvalue { i32, i32 } %{{.+}}, 0
678
+ // LLVM-NEXT: %[[#OPI:]] = extractvalue { i32, i32 } %{{.+}}, 1
679
+ // LLVM-NEXT: %[[#A:]] = insertvalue { i32, i32 } undef, i32 %[[#OPR]], 0
680
+ // LLVM-NEXT: %{{.+}} = insertvalue { i32, i32 } %[[#A]], i32 %[[#OPI]], 1
681
+
682
+ // CHECK: }
683
+
684
+ void unary_minus () {
685
+ cd1 = - cd1 ;
686
+ ci1 = - ci1 ;
687
+ }
688
+
689
+ // CLANG: @unary_minus
690
+ // CPPLANG: @_Z11unary_minusv
691
+
692
+ // CIRGEN: %{{.+}} = cir.unary(minus, %{{.+}}) : !cir.complex<!cir.double>, !cir.complex<!cir.double>
693
+ // CIRGEN: %{{.+}} = cir.unary(minus, %{{.+}}) : !cir.complex<!s32i>, !cir.complex<!s32i>
694
+
695
+ // CIR: %[[#OPR:]] = cir.complex.real %{{.+}} : !cir.complex<!cir.double> -> !cir.double
696
+ // CIR-NEXT: %[[#OPI:]] = cir.complex.imag %{{.+}} : !cir.complex<!cir.double> -> !cir.double
697
+ // CIR-NEXT: %[[#RESR:]] = cir.unary(minus, %[[#OPR]]) : !cir.double, !cir.double
698
+ // CIR-NEXT: %[[#RESI:]] = cir.unary(minus, %[[#OPI]]) : !cir.double, !cir.double
699
+ // CIR-NEXT: %{{.+}} = cir.complex.create %[[#RESR]], %[[#RESI]] : !cir.double -> !cir.complex<!cir.double>
700
+
701
+ // CIR: %[[#OPR:]] = cir.complex.real %{{.+}} : !cir.complex<!s32i> -> !s32i
702
+ // CIR-NEXT: %[[#OPI:]] = cir.complex.imag %{{.+}} : !cir.complex<!s32i> -> !s32i
703
+ // CIR-NEXT: %[[#RESR:]] = cir.unary(minus, %[[#OPR]]) : !s32i, !s32i
704
+ // CIR-NEXT: %[[#RESI:]] = cir.unary(minus, %[[#OPI]]) : !s32i, !s32i
705
+ // CIR-NEXT: %{{.+}} = cir.complex.create %[[#RESR]], %[[#RESI]] : !s32i -> !cir.complex<!s32i>
706
+
707
+ // LLVM: %[[#OPR:]] = extractvalue { double, double } %{{.+}}, 0
708
+ // LLVM-NEXT: %[[#OPI:]] = extractvalue { double, double } %{{.+}}, 1
709
+ // LLVM-NEXT: %[[#RESR:]] = fneg double %[[#OPR]]
710
+ // LLVM-NEXT: %[[#RESI:]] = fneg double %[[#OPI]]
711
+ // LLVM-NEXT: %[[#A:]] = insertvalue { double, double } undef, double %[[#RESR]], 0
712
+ // LLVM-NEXT: %{{.+}} = insertvalue { double, double } %[[#A]], double %[[#RESI]], 1
713
+
714
+ // LLVM: %[[#OPR:]] = extractvalue { i32, i32 } %{{.+}}, 0
715
+ // LLVM-NEXT: %[[#OPI:]] = extractvalue { i32, i32 } %{{.+}}, 1
716
+ // LLVM-NEXT: %[[#RESR:]] = sub i32 0, %[[#OPR]]
717
+ // LLVM-NEXT: %[[#RESI:]] = sub i32 0, %[[#OPI]]
718
+ // LLVM-NEXT: %[[#A:]] = insertvalue { i32, i32 } undef, i32 %[[#RESR]], 0
719
+ // LLVM-NEXT: %{{.+}} = insertvalue { i32, i32 } %[[#A]], i32 %[[#RESI]], 1
720
+
721
+ // CHECK: }
722
+
723
+ void unary_not () {
724
+ cd1 = ~cd1 ;
725
+ ci1 = ~ci1 ;
726
+ }
727
+
728
+ // CLANG: @unary_not
729
+ // CPPLANG: @_Z9unary_notv
730
+
731
+ // CIRGEN: %{{.+}} = cir.unary(not, %{{.+}}) : !cir.complex<!cir.double>, !cir.complex<!cir.double>
732
+ // CIRGEN: %{{.+}} = cir.unary(not, %{{.+}}) : !cir.complex<!s32i>, !cir.complex<!s32i>
733
+
734
+ // CIR: %[[#OPR:]] = cir.complex.real %{{.+}} : !cir.complex<!cir.double> -> !cir.double
735
+ // CIR-NEXT: %[[#OPI:]] = cir.complex.imag %{{.+}} : !cir.complex<!cir.double> -> !cir.double
736
+ // CIR-NEXT: %[[#RESI:]] = cir.unary(minus, %[[#OPI]]) : !cir.double, !cir.double
737
+ // CIR-NEXT: %{{.+}} = cir.complex.create %[[#OPR]], %[[#RESI]] : !cir.double -> !cir.complex<!cir.double>
738
+
739
+ // CIR: %[[#OPR:]] = cir.complex.real %{{.+}} : !cir.complex<!s32i> -> !s32i
740
+ // CIR-NEXT: %[[#OPI:]] = cir.complex.imag %{{.+}} : !cir.complex<!s32i> -> !s32i
741
+ // CIR-NEXT: %[[#RESI:]] = cir.unary(minus, %[[#OPI]]) : !s32i, !s32i
742
+ // CIR-NEXT: %{{.+}} = cir.complex.create %[[#OPR]], %[[#RESI]] : !s32i -> !cir.complex<!s32i>
743
+
744
+ // LLVM: %[[#OPR:]] = extractvalue { double, double } %{{.+}}, 0
745
+ // LLVM-NEXT: %[[#OPI:]] = extractvalue { double, double } %{{.+}}, 1
746
+ // LLVM-NEXT: %[[#RESI:]] = fneg double %[[#OPI]]
747
+ // LLVM-NEXT: %[[#A:]] = insertvalue { double, double } undef, double %[[#OPR]], 0
748
+ // LLVM-NEXT: %{{.+}} = insertvalue { double, double } %[[#A]], double %[[#RESI]], 1
749
+
750
+ // LLVM: %[[#OPR:]] = extractvalue { i32, i32 } %{{.+}}, 0
751
+ // LLVM-NEXT: %[[#OPI:]] = extractvalue { i32, i32 } %{{.+}}, 1
752
+ // LLVM-NEXT: %[[#RESI:]] = sub i32 0, %[[#OPI]]
753
+ // LLVM-NEXT: %[[#A:]] = insertvalue { i32, i32 } undef, i32 %[[#OPR]], 0
754
+ // LLVM-NEXT: %{{.+}} = insertvalue { i32, i32 } %[[#A]], i32 %[[#RESI]], 1
755
+
756
+ // CHECK: }
757
+
758
+ void builtin_conj () {
759
+ cd1 = __builtin_conj (cd1 );
760
+ }
761
+
762
+ // CLANG: @builtin_conj
763
+ // CPPLANG: @_Z12builtin_conjv
764
+
765
+ // CIRGEN: %{{.+}} = cir.unary(not, %{{.+}}) : !cir.complex<!cir.double>, !cir.complex<!cir.double>
766
+
767
+ // CIR: %[[#OPR:]] = cir.complex.real %{{.+}} : !cir.complex<!cir.double> -> !cir.double
768
+ // CIR-NEXT: %[[#OPI:]] = cir.complex.imag %{{.+}} : !cir.complex<!cir.double> -> !cir.double
769
+ // CIR-NEXT: %[[#RESI:]] = cir.unary(minus, %[[#OPI]]) : !cir.double, !cir.double
770
+ // CIR-NEXT: %{{.+}} = cir.complex.create %[[#OPR]], %[[#RESI]] : !cir.double -> !cir.complex<!cir.double>
771
+
772
+ // LLVM: %[[#OPR:]] = extractvalue { double, double } %{{.+}}, 0
773
+ // LLVM-NEXT: %[[#OPI:]] = extractvalue { double, double } %{{.+}}, 1
774
+ // LLVM-NEXT: %[[#RESI:]] = fneg double %[[#OPI]]
775
+ // LLVM-NEXT: %[[#A:]] = insertvalue { double, double } undef, double %[[#OPR]], 0
776
+ // LLVM-NEXT: %{{.+}} = insertvalue { double, double } %[[#A]], double %[[#RESI]], 1
777
+
778
+ // CHECK: }
0 commit comments