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