xref: /llvm-project/llvm/test/CodeGen/RISCV/rv64-typepromotion.ll (revision e005a09df5b5c7d210ac7cd8cbddb3a4a8663173)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2; RUN: opt -mtriple=riscv64 -passes=typepromotion -S %s | FileCheck %s
3
4; Test that this does not crash
5define i16 @test(i8 %a, i32 %b) {
6; CHECK-LABEL: define i16 @test(
7; CHECK-SAME: i8 [[A:%.*]], i32 [[B:%.*]]) {
8; CHECK-NEXT:  entry:
9; CHECK-NEXT:    [[TMP0:%.*]] = zext i8 [[A]] to i32
10; CHECK-NEXT:    [[TMP1:%.*]] = trunc i32 [[B]] to i16
11; CHECK-NEXT:    [[TMP2:%.*]] = zext i16 [[TMP1]] to i64
12; CHECK-NEXT:    [[TMP3:%.*]] = icmp eq i64 [[TMP2]], 0
13; CHECK-NEXT:    [[TMP4:%.*]] = and i32 [[TMP0]], 255
14; CHECK-NEXT:    [[TMP5:%.*]] = zext i32 [[TMP4]] to i64
15; CHECK-NEXT:    [[TMP6:%.*]] = xor i64 [[TMP5]], [[TMP2]]
16; CHECK-NEXT:    [[TMP7:%.*]] = trunc i64 [[TMP6]] to i16
17; CHECK-NEXT:    ret i16 [[TMP7]]
18;
19entry:
20  %0 = zext i8 %a to i32
21  %1 = trunc i32 %b to i16
22  %2 = icmp eq i16 %1, 0
23  %3 = trunc i32 %0 to i8
24  %4 = zext i8 %3 to i16
25  %5 = xor i16 %4, %1
26  ret i16 %5
27}
28