@@ -441,3 +441,31 @@ sw.default: ; preds = %if.end, %sw.bb9
441
441
; CHECK: i32 2, label [[DEST1]]
442
442
; CHECK: i32 4, label [[DEST2]]
443
443
}
444
+
445
+ ; FIXME: This is an invalid transform. If %b is false and %x is poison,
446
+ ; then the select produces poison (the result of the program is poison).
447
+ ; But with this transform, we may be branching on poison, and that is UB.
448
+
449
+ define i32 @TryToUnfoldSelectInCurrBB (i1 %b , i1 %ui , i32 %s , i1 %x ) {
450
+ ; CHECK-LABEL: @TryToUnfoldSelectInCurrBB(
451
+ ; CHECK-NEXT: entry:
452
+ ; CHECK-NEXT: br i1 [[B:%.*]], label [[IF_END_THREAD:%.*]], label [[IF_END:%.*]]
453
+ ; CHECK: if.end:
454
+ ; CHECK-NEXT: br i1 [[X:%.*]], label [[TMP0:%.*]], label [[IF_END_THREAD]]
455
+ ; CHECK: 0:
456
+ ; CHECK-NEXT: br label [[IF_END_THREAD]]
457
+ ; CHECK: if.end.thread:
458
+ ; CHECK-NEXT: [[TMP1:%.*]] = phi i32 [ [[S:%.*]], [[TMP0]] ], [ 42, [[IF_END]] ], [ 42, [[ENTRY:%.*]] ]
459
+ ; CHECK-NEXT: ret i32 [[TMP1]]
460
+ ;
461
+ entry:
462
+ br i1 %b , label %if.end , label %if.else
463
+
464
+ if.else:
465
+ br label %if.end
466
+
467
+ if.end:
468
+ %v = phi i1 [ %x , %if.else ], [ false , %entry ]
469
+ %v1 = select i1 %v , i32 %s , i32 42
470
+ ret i32 %v1
471
+ }
0 commit comments