xref: /llvm-project/llvm/test/CodeGen/SystemZ/int-uadd-multiple-carry-users.ll (revision ca515294879652a46c0e76aaa66f8e415e308b8d)
1; RUN: llc < %s -mtriple=s390x-linux-gnu -start-after=codegenprepare | FileCheck %s
2;
3; Test that compilation succeeds with multiple users of the carry resulting
4; in a truncation of the SELECT_CCMASK used by GET_CCMASK.
5
6define void @fun() {
7; CHECK-LABEL: fun:
8bb:
9  %0 = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 poison, i64 poison)
10  %ov = extractvalue { i64, i1 } %0, 1
11  %i2 = sext i1 %ov to i64
12  %i3 = select i1 %ov, i64 9223372036854775807, i64 -1
13  %i4 = sub nsw i64 %i3, %i2
14  %i5 = and i64 %i4, %i2
15  %i6 = icmp slt i64 %i5, 0
16  %i7 = xor i1 %ov, true
17  %i8 = select i1 %i6, i1 %i7, i1 false
18  %i9 = sext i1 %i8 to i16
19  store i16 %i9, ptr poison, align 2
20  unreachable
21}
22
23declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64)
24