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
Vedant Kumar02b72f52020-02-13 11:53:15 -08005; CHECK-LABEL: test
6; CHECK: ret i32 0
Eric Christophercee313d2019-04-17 04:52:47 +00007 define i32 @test(i32 %X) {
8 %Y = and i32 %X, 0
9 ret i32 %Y
10}
11
Vedant Kumar02b72f52020-02-13 11:53:15 -080012; CHECK-LABEL: test2
13; CHECK: ret i32 -1
Eric Christophercee313d2019-04-17 04:52:47 +000014define i32 @test2(i32 %X) {
15 %Y = or i32 -1, %X
16 ret i32 %Y
17}
18
Vedant Kumar02b72f52020-02-13 11:53:15 -080019; CHECK-LABEL: test3
20; CHECK: ret i32 0
Eric Christophercee313d2019-04-17 04:52:47 +000021define i32 @test3(i32 %X) {
22 %Y = and i32 undef, %X
23 ret i32 %Y
24}
25
Vedant Kumar02b72f52020-02-13 11:53:15 -080026; CHECK-LABEL: test4
27; CHECK: ret i32 -1
Eric Christophercee313d2019-04-17 04:52:47 +000028define 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.
Vedant Kumar02b72f52020-02-13 11:53:15 -080034; CHECK-LABEL: test5
35; CHECK: ret i32 0
Eric Christophercee313d2019-04-17 04:52:47 +000036define i32 @test5(i32 %foo) {
Eric Christophercee313d2019-04-17 04:52:47 +000037 %patatino = mul i32 %foo, 0
38 ret i32 %patatino
39}