blob: 6ca16de4489bc61bb94ee25646e3f8e483ace816 [file] [log] [blame]
Eric Christophercee313d2019-04-17 04:52:47 +00001; RUN: opt < %s -sccp -S | FileCheck %s
2
3; Test that SCCP has basic knowledge of when and/or/mul nuke overdefined values.
4
5; CHECK-LABEL: test
6; CHECK: ret i32 0
7 define i32 @test(i32 %X) {
8 %Y = and i32 %X, 0
9 ret i32 %Y
10}
11
12; CHECK-LABEL: test2
13; CHECK: ret i32 -1
14define i32 @test2(i32 %X) {
15 %Y = or i32 -1, %X
16 ret i32 %Y
17}
18
19; CHECK-LABEL: test3
20; CHECK: ret i32 0
21define i32 @test3(i32 %X) {
22 %Y = and i32 undef, %X
23 ret i32 %Y
24}
25
26; CHECK-LABEL: test4
27; CHECK: ret i32 -1
28define i32 @test4(i32 %X) {
29 %Y = or i32 %X, undef
30 ret i32 %Y
31}
32
33; X * 0 = 0 even if X is overdefined.
34; CHECK-LABEL: test5
35; CHECK: ret i32 0
36define i32 @test5(i32 %foo) {
37 %patatino = mul i32 %foo, 0
38 ret i32 %patatino
39}