1968468afSNoah Goldstein; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2968468afSNoah Goldstein; RUN: opt < %s -passes=instcombine -S | FileCheck %s 3968468afSNoah Goldstein 4968468afSNoah Goldsteindefine i8 @shl_add_nuw(i8 %amt_in, i8 %cnt_in) { 5968468afSNoah Goldstein; CHECK-LABEL: @shl_add_nuw( 6968468afSNoah Goldstein; CHECK-NEXT: [[AMT:%.*]] = and i8 [[AMT_IN:%.*]], 63 7968468afSNoah Goldstein; CHECK-NEXT: [[CNT:%.*]] = and i8 [[CNT_IN:%.*]], 2 8*2dd52b45SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = shl nuw i8 [[AMT]], [[CNT]] 9968468afSNoah Goldstein; CHECK-NEXT: ret i8 [[R]] 10968468afSNoah Goldstein; 11968468afSNoah Goldstein %amt = and i8 %amt_in, 63 12968468afSNoah Goldstein %cnt = and i8 %cnt_in, 2 13968468afSNoah Goldstein %r = shl i8 %amt, %cnt 14968468afSNoah Goldstein ret i8 %r 15968468afSNoah Goldstein} 16968468afSNoah Goldstein 17968468afSNoah Goldsteindefine i8 @shl_add_nuw_fail(i8 %amt_in, i8 %cnt_in) { 18968468afSNoah Goldstein; CHECK-LABEL: @shl_add_nuw_fail( 19968468afSNoah Goldstein; CHECK-NEXT: [[AMT:%.*]] = and i8 [[AMT_IN:%.*]], 63 20968468afSNoah Goldstein; CHECK-NEXT: [[CNT:%.*]] = and i8 [[CNT_IN:%.*]], 3 21968468afSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = shl i8 [[AMT]], [[CNT]] 22968468afSNoah Goldstein; CHECK-NEXT: ret i8 [[R]] 23968468afSNoah Goldstein; 24968468afSNoah Goldstein %amt = and i8 %amt_in, 63 25968468afSNoah Goldstein %cnt = and i8 %cnt_in, 3 26968468afSNoah Goldstein %r = shl i8 %amt, %cnt 27968468afSNoah Goldstein ret i8 %r 28968468afSNoah Goldstein} 29968468afSNoah Goldstein 30968468afSNoah Goldsteindefine i8 @shl_add_nuw_and_nsw(i8 %amt_in, i8 %cnt_in) { 31968468afSNoah Goldstein; CHECK-LABEL: @shl_add_nuw_and_nsw( 32968468afSNoah Goldstein; CHECK-NEXT: [[AMT:%.*]] = and i8 [[AMT_IN:%.*]], 31 33968468afSNoah Goldstein; CHECK-NEXT: [[CNT:%.*]] = and i8 [[CNT_IN:%.*]], 2 34*2dd52b45SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = shl nuw nsw i8 [[AMT]], [[CNT]] 35968468afSNoah Goldstein; CHECK-NEXT: ret i8 [[R]] 36968468afSNoah Goldstein; 37968468afSNoah Goldstein %amt = and i8 %amt_in, 31 38968468afSNoah Goldstein %cnt = and i8 %cnt_in, 2 39968468afSNoah Goldstein %r = shl i8 %amt, %cnt 40968468afSNoah Goldstein ret i8 %r 41968468afSNoah Goldstein} 42968468afSNoah Goldstein 43968468afSNoah Goldsteindefine i8 @shl_add_nsw(i8 %amt_in, i8 %cnt_in) { 44968468afSNoah Goldstein; CHECK-LABEL: @shl_add_nsw( 45968468afSNoah Goldstein; CHECK-NEXT: [[AMT:%.*]] = or i8 [[AMT_IN:%.*]], -32 46968468afSNoah Goldstein; CHECK-NEXT: [[CNT:%.*]] = and i8 [[CNT_IN:%.*]], 2 47*2dd52b45SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = shl nsw i8 [[AMT]], [[CNT]] 48968468afSNoah Goldstein; CHECK-NEXT: ret i8 [[R]] 49968468afSNoah Goldstein; 50968468afSNoah Goldstein %amt = or i8 %amt_in, 224 51968468afSNoah Goldstein %cnt = and i8 %cnt_in, 2 52968468afSNoah Goldstein %r = shl i8 %amt, %cnt 53968468afSNoah Goldstein ret i8 %r 54968468afSNoah Goldstein} 55968468afSNoah Goldstein 56968468afSNoah Goldsteindefine i8 @shl_add_nsw_fail(i8 %amt_in, i8 %cnt_in) { 57968468afSNoah Goldstein; CHECK-LABEL: @shl_add_nsw_fail( 58968468afSNoah Goldstein; CHECK-NEXT: [[AMT:%.*]] = or i8 [[AMT_IN:%.*]], -64 59968468afSNoah Goldstein; CHECK-NEXT: [[CNT:%.*]] = and i8 [[CNT_IN:%.*]], 2 60968468afSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = shl i8 [[AMT]], [[CNT]] 61968468afSNoah Goldstein; CHECK-NEXT: ret i8 [[R]] 62968468afSNoah Goldstein; 63968468afSNoah Goldstein %amt = or i8 %amt_in, 192 64968468afSNoah Goldstein %cnt = and i8 %cnt_in, 2 65968468afSNoah Goldstein %r = shl i8 %amt, %cnt 66968468afSNoah Goldstein ret i8 %r 67968468afSNoah Goldstein} 68968468afSNoah Goldstein 69968468afSNoah Goldsteindefine i8 @lshr_add_exact(i8 %amt_in, i8 %cnt_in) { 70968468afSNoah Goldstein; CHECK-LABEL: @lshr_add_exact( 71968468afSNoah Goldstein; CHECK-NEXT: [[AMT:%.*]] = and i8 [[AMT_IN:%.*]], -4 72968468afSNoah Goldstein; CHECK-NEXT: [[CNT:%.*]] = and i8 [[CNT_IN:%.*]], 2 73*2dd52b45SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = lshr exact i8 [[AMT]], [[CNT]] 74968468afSNoah Goldstein; CHECK-NEXT: ret i8 [[R]] 75968468afSNoah Goldstein; 76968468afSNoah Goldstein %amt = and i8 %amt_in, -4 77968468afSNoah Goldstein %cnt = and i8 %cnt_in, 2 78968468afSNoah Goldstein %r = lshr i8 %amt, %cnt 79968468afSNoah Goldstein ret i8 %r 80968468afSNoah Goldstein} 81968468afSNoah Goldstein 82968468afSNoah Goldsteindefine i8 @lshr_add_exact_fail(i8 %amt_in, i8 %cnt_in) { 83968468afSNoah Goldstein; CHECK-LABEL: @lshr_add_exact_fail( 84968468afSNoah Goldstein; CHECK-NEXT: [[AMT:%.*]] = and i8 [[AMT_IN:%.*]], -7 85968468afSNoah Goldstein; CHECK-NEXT: [[CNT:%.*]] = and i8 [[CNT_IN:%.*]], 2 86968468afSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = lshr i8 [[AMT]], [[CNT]] 87968468afSNoah Goldstein; CHECK-NEXT: ret i8 [[R]] 88968468afSNoah Goldstein; 89968468afSNoah Goldstein %amt = and i8 %amt_in, -7 90968468afSNoah Goldstein %cnt = and i8 %cnt_in, 2 91968468afSNoah Goldstein %r = lshr i8 %amt, %cnt 92968468afSNoah Goldstein ret i8 %r 93968468afSNoah Goldstein} 94968468afSNoah Goldstein 95968468afSNoah Goldsteindefine i8 @ashr_add_exact(i8 %amt_in, i8 %cnt_in) { 96968468afSNoah Goldstein; CHECK-LABEL: @ashr_add_exact( 97968468afSNoah Goldstein; CHECK-NEXT: [[AMT:%.*]] = and i8 [[AMT_IN:%.*]], -14 98968468afSNoah Goldstein; CHECK-NEXT: [[CNT:%.*]] = and i8 [[CNT_IN:%.*]], 1 99*2dd52b45SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = ashr exact i8 [[AMT]], [[CNT]] 100968468afSNoah Goldstein; CHECK-NEXT: ret i8 [[R]] 101968468afSNoah Goldstein; 102968468afSNoah Goldstein %amt = and i8 %amt_in, -14 103968468afSNoah Goldstein %cnt = and i8 %cnt_in, 1 104968468afSNoah Goldstein %r = ashr i8 %amt, %cnt 105968468afSNoah Goldstein ret i8 %r 106968468afSNoah Goldstein} 107968468afSNoah Goldstein 108968468afSNoah Goldsteindefine i8 @ashr_add_exact_fail(i8 %amt_in, i8 %cnt_in) { 109968468afSNoah Goldstein; CHECK-LABEL: @ashr_add_exact_fail( 110968468afSNoah Goldstein; CHECK-NEXT: [[AMT:%.*]] = and i8 [[AMT_IN:%.*]], -14 111968468afSNoah Goldstein; CHECK-NEXT: [[CNT:%.*]] = and i8 [[CNT_IN:%.*]], 2 112968468afSNoah Goldstein; CHECK-NEXT: [[R:%.*]] = ashr i8 [[AMT]], [[CNT]] 113968468afSNoah Goldstein; CHECK-NEXT: ret i8 [[R]] 114968468afSNoah Goldstein; 115968468afSNoah Goldstein %amt = and i8 %amt_in, -14 116968468afSNoah Goldstein %cnt = and i8 %cnt_in, 2 117968468afSNoah Goldstein %r = ashr i8 %amt, %cnt 118968468afSNoah Goldstein ret i8 %r 119968468afSNoah Goldstein} 120