[InstCombine] Signed saturation patterns
[llvm-core.git] / test / Transforms / InstCombine / pr43376-getFlippedStrictnessPredicateAndConstant-assert.ll
blob1e5bf5190a591e68ffd3e9b44392e5cdeb1ee407
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 ; We used to hit an assertion in getFlippedStrictnessPredicateAndConstant due
5 ; to assuming that edge cases such as %cmp (ult x, 0) already has been
6 ; simplified. But that depends on the worklist order, so that is not always
7 ; guaranteed.
9 define i16 @d(i16* %d.a, i16* %d.b) {
10 ; CHECK-LABEL: @d(
11 ; CHECK-NEXT:  entry:
12 ; CHECK-NEXT:    [[T0:%.*]] = load i16, i16* [[D_A:%.*]], align 1
13 ; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i16 [[T0]], 0
14 ; CHECK-NEXT:    br i1 [[TOBOOL]], label [[LAND_END:%.*]], label [[LAND_RHS:%.*]]
15 ; CHECK:       land.rhs:
16 ; CHECK-NEXT:    br label [[LAND_END]]
17 ; CHECK:       land.end:
18 ; CHECK-NEXT:    ret i16 -1
20 entry:
21   %t0 = load i16, i16* %d.a, align 1
22   %tobool = icmp ne i16 %t0, 0
23   br i1 %tobool, label %land.rhs, label %land.end
25 land.rhs:
26   %t1 = load i16, i16* %d.b, align 1
27   %cmp = icmp ult i16 %t1, 0
28   br label %land.end
30 land.end:
31   %t2 = phi i1 [ false, %entry ], [ %cmp, %land.rhs ]
32   %land.ext = zext i1 %t2 to i16
33   %mul = mul nsw i16 %land.ext, 3
34   %neg = xor i16 %mul, -1
35   ret i16 %neg