@@ -1055,6 +1055,69 @@ define i32 @caller_large_scalars_exhausted_regs() nounwind {
1055
1055
ret i32 %1
1056
1056
}
1057
1057
1058
+ ; Check passing of coerced integer arrays
1059
+
1060
+ define i32 @callee_small_coerced_struct ([2 x i32 ] %a.coerce ) nounwind {
1061
+ ; RV32I-LABEL: name: callee_small_coerced_struct
1062
+ ; RV32I: bb.1 (%ir-block.0):
1063
+ ; RV32I-NEXT: liveins: $x10, $x11
1064
+ ; RV32I-NEXT: {{ $}}
1065
+ ; RV32I-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
1066
+ ; RV32I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
1067
+ ; RV32I-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[COPY]](s32), [[COPY1]]
1068
+ ; RV32I-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[ICMP]](s1)
1069
+ ; RV32I-NEXT: $x10 = COPY [[ZEXT]](s32)
1070
+ ; RV32I-NEXT: PseudoRET implicit $x10
1071
+ %1 = extractvalue [2 x i32 ] %a.coerce , 0
1072
+ %2 = extractvalue [2 x i32 ] %a.coerce , 1
1073
+ %3 = icmp eq i32 %1 , %2
1074
+ %4 = zext i1 %3 to i32
1075
+ ret i32 %4
1076
+ }
1077
+
1078
+ define i32 @caller_small_coerced_struct () nounwind {
1079
+ ; ILP32-LABEL: name: caller_small_coerced_struct
1080
+ ; ILP32: bb.1 (%ir-block.0):
1081
+ ; ILP32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
1082
+ ; ILP32-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
1083
+ ; ILP32-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
1084
+ ; ILP32-NEXT: $x10 = COPY [[C]](s32)
1085
+ ; ILP32-NEXT: $x11 = COPY [[C1]](s32)
1086
+ ; ILP32-NEXT: PseudoCALL target-flags(riscv-call) @callee_small_coerced_struct, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
1087
+ ; ILP32-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
1088
+ ; ILP32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
1089
+ ; ILP32-NEXT: $x10 = COPY [[COPY]](s32)
1090
+ ; ILP32-NEXT: PseudoRET implicit $x10
1091
+ ;
1092
+ ; ILP32F-LABEL: name: caller_small_coerced_struct
1093
+ ; ILP32F: bb.1 (%ir-block.0):
1094
+ ; ILP32F-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
1095
+ ; ILP32F-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
1096
+ ; ILP32F-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
1097
+ ; ILP32F-NEXT: $x10 = COPY [[C]](s32)
1098
+ ; ILP32F-NEXT: $x11 = COPY [[C1]](s32)
1099
+ ; ILP32F-NEXT: PseudoCALL target-flags(riscv-call) @callee_small_coerced_struct, csr_ilp32f_lp64f, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
1100
+ ; ILP32F-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
1101
+ ; ILP32F-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
1102
+ ; ILP32F-NEXT: $x10 = COPY [[COPY]](s32)
1103
+ ; ILP32F-NEXT: PseudoRET implicit $x10
1104
+ ;
1105
+ ; ILP32D-LABEL: name: caller_small_coerced_struct
1106
+ ; ILP32D: bb.1 (%ir-block.0):
1107
+ ; ILP32D-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
1108
+ ; ILP32D-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
1109
+ ; ILP32D-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
1110
+ ; ILP32D-NEXT: $x10 = COPY [[C]](s32)
1111
+ ; ILP32D-NEXT: $x11 = COPY [[C1]](s32)
1112
+ ; ILP32D-NEXT: PseudoCALL target-flags(riscv-call) @callee_small_coerced_struct, csr_ilp32d_lp64d, implicit-def $x1, implicit $x10, implicit $x11, implicit-def $x10
1113
+ ; ILP32D-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
1114
+ ; ILP32D-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
1115
+ ; ILP32D-NEXT: $x10 = COPY [[COPY]](s32)
1116
+ ; ILP32D-NEXT: PseudoRET implicit $x10
1117
+ %1 = call i32 @callee_small_coerced_struct ([2 x i32 ] [i32 1 , i32 2 ])
1118
+ ret i32 %1
1119
+ }
1120
+
1058
1121
; Check return of 2x xlen scalars
1059
1122
1060
1123
define i64 @callee_small_scalar_ret () nounwind {
0 commit comments