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; The obvious case. 5define i32 @mul(i32 %val) nounwind { 6; CHECK-LABEL: 'mul' 7; CHECK-NEXT: Classifying expressions for: @mul 8; CHECK-NEXT: %tmp1 = mul i32 %val, 16 9; CHECK-NEXT: --> (16 * %val) U: [0,-15) S: [-2147483648,2147483633) 10; CHECK-NEXT: %tmp2 = udiv i32 %tmp1, 16 11; CHECK-NEXT: --> ((16 * %val) /u 16) U: [0,268435456) S: [0,268435456) 12; CHECK-NEXT: Determining loop execution counts for: @mul 13; 14 %tmp1 = mul i32 %val, 16 15 %tmp2 = udiv i32 %tmp1, 16 16 ret i32 %tmp2 17} 18 19; Or, it could be any number of equivalent patterns with mask: 20; a) x & (1 << nbits) - 1 21; b) x & ~(-1 << nbits) 22; c) x & (-1 >> (32 - y)) 23; d) x << (32 - y) >> (32 - y) 24 25define i32 @mask_abc(i32 %val) nounwind { 26; CHECK-LABEL: 'mask_abc' 27; CHECK-NEXT: Classifying expressions for: @mask_abc 28; CHECK-NEXT: %masked = and i32 %val, 15 29; CHECK-NEXT: --> (zext i4 (trunc i32 %val to i4) to i32) U: [0,16) S: [0,16) 30; CHECK-NEXT: Determining loop execution counts for: @mask_abc 31; 32 %masked = and i32 %val, 15 33 ret i32 %masked 34} 35 36define i32 @mask_d(i32 %val) nounwind { 37; CHECK-LABEL: 'mask_d' 38; CHECK-NEXT: Classifying expressions for: @mask_d 39; CHECK-NEXT: %highbitscleared = shl i32 %val, 4 40; CHECK-NEXT: --> (16 * %val) U: [0,-15) S: [-2147483648,2147483633) 41; CHECK-NEXT: %masked = lshr i32 %highbitscleared, 4 42; CHECK-NEXT: --> ((16 * %val) /u 16) U: [0,268435456) S: [0,268435456) 43; CHECK-NEXT: Determining loop execution counts for: @mask_d 44; 45 %highbitscleared = shl i32 %val, 4 46 %masked = lshr i32 %highbitscleared, 4 47 ret i32 %masked 48} 49