1 ; RUN: opt < %s -instcombine -S | FileCheck %s 2 3 ; CHECK: @sub1 4 ; CHECK: %y = sub i32 0, %x 5 ; CHECK: %z = sdiv i32 %y, 337 6 ; CHECK: ret i32 %z 7 define i32 @sub1(i32 %x) { 8 %y = sub i32 0, %x 9 %z = sdiv i32 %y, 337 10 ret i32 %z 11 } 12 13 ; CHECK: @sub2 14 ; CHECK: %z = sdiv i32 %x, -337 15 ; CHECK: ret i32 %z 16 define i32 @sub2(i32 %x) { 17 %y = sub nsw i32 0, %x 18 %z = sdiv i32 %y, 337 19 ret i32 %z 20 } 21 22 ; CHECK: @shl_icmp 23 ; CHECK: %B = icmp eq i64 %X, 0 24 ; CHECK: ret i1 %B 25 define i1 @shl_icmp(i64 %X) nounwind { 26 %A = shl nuw i64 %X, 2 ; X/4 27 %B = icmp eq i64 %A, 0 28 ret i1 %B 29 } 30 31 ; CHECK: @shl1 32 ; CHECK: %B = shl nuw nsw i64 %A, 8 33 ; CHECK: ret i64 %B 34 define i64 @shl1(i64 %X, i64* %P) nounwind { 35 %A = and i64 %X, 312 36 store i64 %A, i64* %P ; multiple uses of A. 37 %B = shl i64 %A, 8 38 ret i64 %B 39 } 40