Florian Hahn | f8045b2 | 2020-02-14 00:05:50 +0100 | [diff] [blame] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 2 | ; RUN: opt < %s -sccp -S | FileCheck %s |
| 3 | |
| 4 | ; Test that SCCP has basic knowledge of when and/or/mul nuke overdefined values. |
| 5 | |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 6 | define i32 @test(i32 %X) { |
Florian Hahn | f8045b2 | 2020-02-14 00:05:50 +0100 | [diff] [blame] | 7 | ; CHECK-LABEL: @test( |
| 8 | ; CHECK-NEXT: ret i32 0 |
| 9 | ; |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 10 | %Y = and i32 %X, 0 |
| 11 | ret i32 %Y |
| 12 | } |
| 13 | |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 14 | define i32 @test2(i32 %X) { |
Florian Hahn | f8045b2 | 2020-02-14 00:05:50 +0100 | [diff] [blame] | 15 | ; CHECK-LABEL: @test2( |
| 16 | ; CHECK-NEXT: ret i32 -1 |
| 17 | ; |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 18 | %Y = or i32 -1, %X |
| 19 | ret i32 %Y |
| 20 | } |
| 21 | |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 22 | define i32 @test3(i32 %X) { |
Florian Hahn | f8045b2 | 2020-02-14 00:05:50 +0100 | [diff] [blame] | 23 | ; CHECK-LABEL: @test3( |
| 24 | ; CHECK-NEXT: [[Y:%.*]] = and i32 undef, [[X:%.*]] |
| 25 | ; CHECK-NEXT: ret i32 [[Y]] |
| 26 | ; |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 27 | %Y = and i32 undef, %X |
| 28 | ret i32 %Y |
| 29 | } |
| 30 | |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 31 | define i32 @test4(i32 %X) { |
Florian Hahn | f8045b2 | 2020-02-14 00:05:50 +0100 | [diff] [blame] | 32 | ; CHECK-LABEL: @test4( |
| 33 | ; CHECK-NEXT: [[Y:%.*]] = or i32 [[X:%.*]], undef |
| 34 | ; CHECK-NEXT: ret i32 [[Y]] |
| 35 | ; |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 36 | %Y = or i32 %X, undef |
| 37 | ret i32 %Y |
| 38 | } |
| 39 | |
| 40 | ; X * 0 = 0 even if X is overdefined. |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 41 | define i32 @test5(i32 %foo) { |
Florian Hahn | f8045b2 | 2020-02-14 00:05:50 +0100 | [diff] [blame] | 42 | ; CHECK-LABEL: @test5( |
| 43 | ; CHECK-NEXT: ret i32 0 |
| 44 | ; |
Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 45 | %patatino = mul i32 %foo, 0 |
| 46 | ret i32 %patatino |
| 47 | } |