1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py 2; RUN: opt < %s --data-layout="e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -S -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s 3; RUN: opt < %s --data-layout="e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128" -S -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s 4 5; In general, we can't deal with ashr. 6define i32 @t0(i32 %x, i32 %y) { 7; CHECK-LABEL: 't0' 8; CHECK-NEXT: Classifying expressions for: @t0 9; CHECK-NEXT: %i0 = ashr i32 %x, %y 10; CHECK-NEXT: --> %i0 U: full-set S: full-set 11; CHECK-NEXT: Determining loop execution counts for: @t0 12; 13 %i0 = ashr i32 %x, %y 14 ret i32 %i0 15} 16; Not even if we know it's exact 17define i32 @t1(i32 %x, i32 %y) { 18; CHECK-LABEL: 't1' 19; CHECK-NEXT: Classifying expressions for: @t1 20; CHECK-NEXT: %i0 = ashr exact i32 %x, %y 21; CHECK-NEXT: --> %i0 U: full-set S: full-set 22; CHECK-NEXT: Determining loop execution counts for: @t1 23; 24 %i0 = ashr exact i32 %x, %y 25 ret i32 %i0 26} 27; Not even if the shift amount is a constant. 28define i32 @t2(i32 %x, i32 %y) { 29; CHECK-LABEL: 't2' 30; CHECK-NEXT: Classifying expressions for: @t2 31; CHECK-NEXT: %i0 = ashr i32 %x, 4 32; CHECK-NEXT: --> %i0 U: [-134217728,134217728) S: [-134217728,134217728) 33; CHECK-NEXT: Determining loop execution counts for: @t2 34; 35 %i0 = ashr i32 %x, 4 36 ret i32 %i0 37} 38; However, if it's a constant AND the shift is exact, we can model it! 39define i32 @t3(i32 %x, i32 %y) { 40; CHECK-LABEL: 't3' 41; CHECK-NEXT: Classifying expressions for: @t3 42; CHECK-NEXT: %i0 = ashr exact i32 %x, 4 43; CHECK-NEXT: --> %i0 U: [-134217728,134217728) S: [-134217728,134217728) 44; CHECK-NEXT: Determining loop execution counts for: @t3 45; 46 %i0 = ashr exact i32 %x, 4 47 ret i32 %i0 48} 49; As long as the shift amount is in-bounds 50define i32 @t4(i32 %x, i32 %y) { 51; CHECK-LABEL: 't4' 52; CHECK-NEXT: Classifying expressions for: @t4 53; CHECK-NEXT: %i0 = ashr exact i32 %x, 32 54; CHECK-NEXT: --> %i0 U: [0,1) S: [0,1) 55; CHECK-NEXT: Determining loop execution counts for: @t4 56; 57 %i0 = ashr exact i32 %x, 32 58 ret i32 %i0 59} 60 61; One more test, just to see that we model constant correctly 62define i32 @t5(i32 %x, i32 %y) { 63; CHECK-LABEL: 't5' 64; CHECK-NEXT: Classifying expressions for: @t5 65; CHECK-NEXT: %i0 = ashr exact i32 %x, 5 66; CHECK-NEXT: --> %i0 U: [-67108864,67108864) S: [-67108864,67108864) 67; CHECK-NEXT: Determining loop execution counts for: @t5 68; 69 %i0 = ashr exact i32 %x, 5 70 ret i32 %i0 71} 72