1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 ; CHECK-LABEL: @oppositesign
6 ; CHECK: add nsw i16 %a, %b
7 define i16 @oppositesign(i16 %x, i16 %y) {
8 ; %a is negative, %b is positive
10 %b = and i16 %y, 32767
15 define i16 @zero_sign_bit(i16 %a) {
16 ; CHECK-LABEL: @zero_sign_bit(
20 %1 = and i16 %a, 32767
25 define i16 @zero_sign_bit2(i16 %a, i16 %b) {
26 ; CHECK-LABEL: @zero_sign_bit2(
31 %1 = and i16 %a, 32767
32 %2 = and i16 %b, 32767
37 ; CHECK-LABEL: @ripple_nsw1
38 ; CHECK: add nsw i16 %a, %b
39 define i16 @ripple_nsw1(i16 %x, i16 %y) {
40 ; %a has at most one bit set
43 ; %b has a 0 bit other than the sign bit
44 %b = and i16 %x, 49151
50 ; Like the previous test, but flip %a and %b
51 ; CHECK-LABEL: @ripple_nsw2
52 ; CHECK: add nsw i16 %b, %a
53 define i16 @ripple_nsw2(i16 %x, i16 %y) {
55 %b = and i16 %x, 49151
60 ; CHECK-LABEL: @ripple_no_nsw1
61 ; CHECK: add i32 %a, %x
62 define i32 @ripple_no_nsw1(i32 %x, i32 %y) {
63 ; We know nothing about %x
69 ; CHECK-LABEL: @ripple_no_nsw2
70 ; CHECK: add nuw i16 %a, %b
71 define i16 @ripple_no_nsw2(i16 %x, i16 %y) {
72 ; %a has at most one bit set
75 ; %b has a 0 bit, but it is the sign bit
76 %b = and i16 %x, 32767