Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[InstCombine] Fix PR35618: Instcombine hangs on single minmax load bi…
…tcast. Summary: If we have pattern `store (load(bitcast(select (cmp(V1, V2), &V1, &V2)))), bitcast)`, but the load is used in other instructions, it leads to looping in InstCombiner. Patch adds additional check that all users of the load instructions are stores and then replaces all uses of load instruction by the new one with new type. Reviewers: RKSimon, spatel, majnemer Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41072 llvm-svn: 320525
- Loading branch information
1 parent
212bcf8
commit 83c15b1
Showing
2 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
llvm/test/Transforms/InstCombine/multiple-uses-load-bitcast-select.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt < %s -instcombine -S -data-layout="E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64" | FileCheck %s | ||
|
||
define void @PR35618(i64* %st1, double* %st2) { | ||
; CHECK-LABEL: @PR35618( | ||
; CHECK-NEXT: [[Y1:%.*]] = alloca double, align 8 | ||
; CHECK-NEXT: [[Z1:%.*]] = alloca double, align 8 | ||
; CHECK-NEXT: [[LD1:%.*]] = load double, double* [[Y1]], align 8 | ||
; CHECK-NEXT: [[LD2:%.*]] = load double, double* [[Z1]], align 8 | ||
; CHECK-NEXT: [[TMP10:%.*]] = fcmp olt double [[LD1]], [[LD2]] | ||
; CHECK-NEXT: [[TMP121:%.*]] = select i1 [[TMP10]], double [[LD1]], double [[LD2]] | ||
; CHECK-NEXT: [[TMP1:%.*]] = bitcast i64* [[ST1:%.*]] to double* | ||
; CHECK-NEXT: store double [[TMP121]], double* [[TMP1]], align 8 | ||
; CHECK-NEXT: store double [[TMP121]], double* [[ST2:%.*]], align 8 | ||
; CHECK-NEXT: ret void | ||
; | ||
%y1 = alloca double | ||
%z1 = alloca double | ||
%ld1 = load double, double* %y1 | ||
%ld2 = load double, double* %z1 | ||
%tmp10 = fcmp olt double %ld1, %ld2 | ||
%sel = select i1 %tmp10, double* %y1, double* %z1 | ||
%tmp11 = bitcast double* %sel to i64* | ||
%tmp12 = load i64, i64* %tmp11 | ||
store i64 %tmp12, i64* %st1 | ||
%bc = bitcast double* %st2 to i64* | ||
store i64 %tmp12, i64* %bc | ||
ret void | ||
} | ||
|