Skip to content

Commit 42a5dda

Browse files
committed
[RISCV] Add more testcases for overflow-intrinsics.ll
1 parent 794d208 commit 42a5dda

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

llvm/test/CodeGen/RISCV/overflow-intrinsics.ll

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,3 +1281,41 @@ exit:
12811281
ret void
12821282
}
12831283

1284+
define i16 @overflow_not_used(i16 %a, i16 %b, ptr %res) nounwind ssp {
1285+
; RV32-LABEL: overflow_not_used:
1286+
; RV32: # %bb.0:
1287+
; RV32-NEXT: lui a3, 16
1288+
; RV32-NEXT: addi a3, a3, -1
1289+
; RV32-NEXT: and a0, a0, a3
1290+
; RV32-NEXT: and a4, a1, a3
1291+
; RV32-NEXT: add a0, a4, a0
1292+
; RV32-NEXT: and a3, a0, a3
1293+
; RV32-NEXT: bne a3, a0, .LBB37_2
1294+
; RV32-NEXT: # %bb.1:
1295+
; RV32-NEXT: li a1, 42
1296+
; RV32-NEXT: .LBB37_2:
1297+
; RV32-NEXT: sh a0, 0(a2)
1298+
; RV32-NEXT: mv a0, a1
1299+
; RV32-NEXT: ret
1300+
;
1301+
; RV64-LABEL: overflow_not_used:
1302+
; RV64: # %bb.0:
1303+
; RV64-NEXT: lui a3, 16
1304+
; RV64-NEXT: addiw a3, a3, -1
1305+
; RV64-NEXT: and a0, a0, a3
1306+
; RV64-NEXT: and a4, a1, a3
1307+
; RV64-NEXT: add a0, a4, a0
1308+
; RV64-NEXT: and a3, a0, a3
1309+
; RV64-NEXT: bne a3, a0, .LBB37_2
1310+
; RV64-NEXT: # %bb.1:
1311+
; RV64-NEXT: li a1, 42
1312+
; RV64-NEXT: .LBB37_2:
1313+
; RV64-NEXT: sh a0, 0(a2)
1314+
; RV64-NEXT: mv a0, a1
1315+
; RV64-NEXT: ret
1316+
%add = add i16 %b, %a
1317+
%cmp = icmp ult i16 %add, %b
1318+
%Q = select i1 %cmp, i16 %b, i16 42
1319+
store i16 %add, ptr %res
1320+
ret i16 %Q
1321+
}

0 commit comments

Comments
 (0)