Duncan Sands | fd26a95 | 2011-09-05 06:52:48 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -instsimplify -S | FileCheck %s |
| 2 | |
Duncan Sands | fd26a95 | 2011-09-05 06:52:48 +0000 | [diff] [blame] | 3 | declare void @bar() |
| 4 | |
David Majnemer | 7fddecc | 2015-06-17 20:52:32 +0000 | [diff] [blame] | 5 | define void @test1() personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0 { |
Duncan Sands | fd26a95 | 2011-09-05 06:52:48 +0000 | [diff] [blame] | 6 | entry: |
| 7 | invoke void @bar() to label %cont unwind label %lpad |
| 8 | cont: |
| 9 | ret void |
| 10 | lpad: |
David Majnemer | 7fddecc | 2015-06-17 20:52:32 +0000 | [diff] [blame] | 11 | %ex = landingpad { i8*, i32 } cleanup |
Duncan Sands | fd26a95 | 2011-09-05 06:52:48 +0000 | [diff] [blame] | 12 | %exc_ptr = extractvalue { i8*, i32 } %ex, 0 |
| 13 | %filter = extractvalue { i8*, i32 } %ex, 1 |
| 14 | %exc_ptr2 = insertvalue { i8*, i32 } undef, i8* %exc_ptr, 0 |
| 15 | %filter2 = insertvalue { i8*, i32 } %exc_ptr2, i32 %filter, 1 |
| 16 | resume { i8*, i32 } %filter2 |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 17 | ; CHECK-LABEL: @test1( |
Benjamin Kramer | 4b79c21 | 2011-09-05 18:16:19 +0000 | [diff] [blame] | 18 | ; CHECK-NOT: extractvalue |
| 19 | ; CHECK-NOT: insertvalue |
Duncan Sands | fd26a95 | 2011-09-05 06:52:48 +0000 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | declare i32 @__gxx_personality_v0(i32, i64, i8*, i8*) |
Benjamin Kramer | 4b79c21 | 2011-09-05 18:16:19 +0000 | [diff] [blame] | 23 | |
| 24 | define { i8, i32 } @test2({ i8*, i32 } %x) { |
| 25 | %ex = extractvalue { i8*, i32 } %x, 1 |
| 26 | %ins = insertvalue { i8, i32 } undef, i32 %ex, 1 |
| 27 | ret { i8, i32 } %ins |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 28 | ; CHECK-LABEL: @test2( |
Benjamin Kramer | 4b79c21 | 2011-09-05 18:16:19 +0000 | [diff] [blame] | 29 | } |
David Majnemer | 25a796e | 2015-07-13 01:15:46 +0000 | [diff] [blame] | 30 | |
| 31 | define i32 @test3(i32 %a, float %b) { |
| 32 | %agg1 = insertvalue {i32, float} undef, i32 %a, 0 |
| 33 | %agg2 = insertvalue {i32, float} %agg1, float %b, 1 |
| 34 | %ev = extractvalue {i32, float} %agg2, 0 |
| 35 | ret i32 %ev |
| 36 | ; CHECK-LABEL: @test3( |
| 37 | ; CHECK: ret i32 %a |
| 38 | } |
David Majnemer | c6bb0e2 | 2015-08-18 22:07:25 +0000 | [diff] [blame] | 39 | |
| 40 | define i8 @test4(<8 x i8> %V) { |
| 41 | %add = add <8 x i8> %V, bitcast (double 0x319BEB8FD172E36 to <8 x i8>) |
| 42 | %extract = extractelement <8 x i8> %add, i32 6 |
| 43 | ret i8 %extract |
| 44 | ; CHECK-LABEL: @test4( |
| 45 | ; CHECK: %[[add:.*]] = add <8 x i8> %V, bitcast (<1 x double> <double 0x319BEB8FD172E36> to <8 x i8>) |
| 46 | ; CHECK-NEXT: %[[extract:.*]] = extractelement <8 x i8> %[[add]], i32 6 |
| 47 | ; CHECK-NEXT: ret i8 %[[extract]] |
| 48 | } |