1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py 2; RUN: opt -S -analyze -scalar-evolution < %s | FileCheck %s 3 4; These testcases aren't *identical* but they have the same/similar meaning. 5 6; The obvious case. 7define i32 @div(i32 %val, i32 %num) nounwind { 8; CHECK-LABEL: 'div' 9; CHECK-NEXT: Classifying expressions for: @div 10; CHECK-NEXT: %tmp1 = udiv i32 %val, %num 11; CHECK-NEXT: --> (%val /u %num) U: full-set S: full-set 12; CHECK-NEXT: %tmp2 = mul i32 %tmp1, %num 13; CHECK-NEXT: --> ((%val /u %num) * %num) U: full-set S: full-set 14; CHECK-NEXT: Determining loop execution counts for: @div 15; 16 %tmp1 = udiv i32 %val, %num 17 %tmp2 = mul i32 %tmp1, %num 18 ret i32 %tmp2 19} 20 21define i32 @sdiv(i32 %val, i32 %num) nounwind { 22; CHECK-LABEL: 'sdiv' 23; CHECK-NEXT: Classifying expressions for: @sdiv 24; CHECK-NEXT: %tmp1 = sdiv i32 %val, %num 25; CHECK-NEXT: --> %tmp1 U: full-set S: full-set 26; CHECK-NEXT: %tmp2 = mul i32 %tmp1, %num 27; CHECK-NEXT: --> (%num * %tmp1) U: full-set S: full-set 28; CHECK-NEXT: Determining loop execution counts for: @sdiv 29; 30 %tmp1 = sdiv i32 %val, %num 31 %tmp2 = mul i32 %tmp1, %num 32 ret i32 %tmp2 33} 34 35; Or, it could be a number of equivalent patterns with mask: 36; b) x & (-1 << nbits) 37; d) x >> (32 - y) << (32 - y) 38 39define i32 @mask_b(i32 %val, i32 %numlowbits) nounwind { 40; CHECK-LABEL: 'mask_b' 41; CHECK-NEXT: Classifying expressions for: @mask_b 42; CHECK-NEXT: %mask = shl i32 -1, %numlowbits 43; CHECK-NEXT: --> %mask U: full-set S: full-set 44; CHECK-NEXT: %masked = and i32 %mask, %val 45; CHECK-NEXT: --> %masked U: full-set S: full-set 46; CHECK-NEXT: Determining loop execution counts for: @mask_b 47; 48 %mask = shl i32 -1, %numlowbits 49 %masked = and i32 %mask, %val 50 ret i32 %masked 51} 52 53define i32 @mask_d(i32 %val, i32 %lowbits) nounwind { 54; CHECK-LABEL: 'mask_d' 55; CHECK-NEXT: Classifying expressions for: @mask_d 56; CHECK-NEXT: %numlowbits = sub i32 32, %lowbits 57; CHECK-NEXT: --> (32 + (-1 * %lowbits)) U: full-set S: full-set 58; CHECK-NEXT: %lowbitscleared = lshr i32 %val, %numlowbits 59; CHECK-NEXT: --> %lowbitscleared U: full-set S: full-set 60; CHECK-NEXT: %masked = shl i32 %lowbitscleared, %numlowbits 61; CHECK-NEXT: --> %masked U: full-set S: full-set 62; CHECK-NEXT: Determining loop execution counts for: @mask_d 63; 64 %numlowbits = sub i32 32, %lowbits 65 %lowbitscleared = lshr i32 %val, %numlowbits 66 %masked = shl i32 %lowbitscleared, %numlowbits 67 ret i32 %masked 68} 69