; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 ; NOTE: This test ensures InstCombine preserves dominance even when it ; reorders shifts through SimplifyDemandedBits/log2 folding. ; ; RUN: opt -passes=instcombine -S < %s | FileCheck %s define i64 @f(i64 %arg0, i64 %arg1) { ; CHECK-LABEL: define i64 @f( ; CHECK-SAME: i64 [[ARG0:%.*]], i64 [[ARG1:%.*]]) { ; CHECK-NEXT: [[ENTRY:.*:]] ; CHECK-NEXT: [[I:%.*]] = add i64 [[ARG1]], -1 ; CHECK-NEXT: [[I1:%.*]] = shl nuw i64 1, [[I]] ; CHECK-NEXT: [[SHL2:%.*]] = shl nuw i64 [[I1]], [[ARG1]] ; CHECK-NEXT: [[SREM:%.*]] = srem i64 [[ARG0]], [[SHL2]] ; CHECK-NEXT: ret i64 [[SREM]] ; entry: %shl = shl nuw i64 1, %arg1 %lshr = lshr exact i64 %shl, 1 %shl2 = shl nuw i64 %lshr, %arg1 %srem = srem i64 %arg0, %shl2 ret i64 %srem }