1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt < %s -passes=sccp -S | FileCheck %s
4 ; Test that SCCP has basic knowledge of when div can nuke overdefined values.
6 ; 0 / X = 0 even if X is overdefined.
7 define i32 @test1(i32 %foo) {
8 ; CHECK-LABEL: define i32 @test1
9 ; CHECK-SAME: (i32 [[FOO:%.*]]) {
10 ; CHECK-NEXT: ret i32 0
12 %tinkywinky = udiv i32 0, %foo
16 define i32 @test2(i32 %foo) {
17 ; CHECK-LABEL: define i32 @test2
18 ; CHECK-SAME: (i32 [[FOO:%.*]]) {
19 ; CHECK-NEXT: ret i32 0
21 %tinkywinky = sdiv i32 0, %foo
25 define i32 @test3(i32 %foo) {
26 ; CHECK-LABEL: define i32 @test3
27 ; CHECK-SAME: (i32 [[FOO:%.*]]) {
28 ; CHECK-NEXT: [[TINKYWINKY:%.*]] = udiv i32 [[FOO]], 0
29 ; CHECK-NEXT: ret i32 [[TINKYWINKY]]
31 %tinkywinky = udiv i32 %foo, 0
35 define i32 @test4(i32 %foo) {
36 ; CHECK-LABEL: define i32 @test4
37 ; CHECK-SAME: (i32 [[FOO:%.*]]) {
38 ; CHECK-NEXT: [[TINKYWINKY:%.*]] = sdiv i32 [[FOO]], 0
39 ; CHECK-NEXT: ret i32 [[TINKYWINKY]]
41 %tinkywinky = sdiv i32 %foo, 0