diff --git a/test/Transforms/InstCombine/sub-of-negatible.ll b/test/Transforms/InstCombine/sub-of-negatible.ll index d0850107a56..01889eaf564 100644 --- a/test/Transforms/InstCombine/sub-of-negatible.ll +++ b/test/Transforms/InstCombine/sub-of-negatible.ll @@ -1211,5 +1211,33 @@ define i8 @dont_negate_ordinary_select(i8 %x, i8 %y, i8 %z, i1 %c) { ret i8 %t1 } +; Freeze is transparent as far as negation is concerned +define i4 @negate_freeze(i4 %x, i4 %y, i4 %z) { +; CHECK-LABEL: @negate_freeze( +; CHECK-NEXT: [[T0:%.*]] = sub i4 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[T1:%.*]] = freeze i4 [[T0]] +; CHECK-NEXT: [[T2:%.*]] = sub i4 [[Z:%.*]], [[T1]] +; CHECK-NEXT: ret i4 [[T2]] +; + %t0 = sub i4 %x, %y + %t1 = freeze i4 %t0 + %t2 = sub i4 %z, %t1 + ret i4 %t2 +} +define i4 @negate_freeze_extrause(i4 %x, i4 %y, i4 %z) { +; CHECK-LABEL: @negate_freeze_extrause( +; CHECK-NEXT: [[T0:%.*]] = sub i4 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[T1:%.*]] = freeze i4 [[T0]] +; CHECK-NEXT: call void @use4(i4 [[T1]]) +; CHECK-NEXT: [[T2:%.*]] = sub i4 [[Z:%.*]], [[T1]] +; CHECK-NEXT: ret i4 [[T2]] +; + %t0 = sub i4 %x, %y + %t1 = freeze i4 %t0 + call void @use4(i4 %t1) + %t2 = sub i4 %z, %t1 + ret i4 %t2 +} + ; CHECK: !0 = !{!"branch_weights", i32 40, i32 1} !0 = !{!"branch_weights", i32 40, i32 1}