[PATCH] D50996: extend binop folds for selects to include true and false binops flag intersection
Michael Berg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 20 15:27:47 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340222: extend binop folds for selects to include true and false binops flag… (authored by mcberg2017, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D50996?vs=161563&id=161587#toc
Repository:
rL LLVM
https://reviews.llvm.org/D50996
Files:
llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/trunk/test/Transforms/InstCombine/select_meta.ll
Index: llvm/trunk/test/Transforms/InstCombine/select_meta.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/select_meta.ll
+++ llvm/trunk/test/Transforms/InstCombine/select_meta.ll
@@ -7,12 +7,12 @@
; CHECK-LABEL: @foo(
; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 %0, 2
; CHECK-NEXT: [[DOTV:%.*]] = select i1 [[TMP2]], i32 20, i32 -20, !prof ![[$MD1:[0-9]+]]
-; CHECK-NEXT: [[TMP3:%.*]] = add nsw i32 [[DOTV]], %0
+; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[DOTV]], %0
; CHECK-NEXT: ret i32 [[TMP3]]
;
%2 = icmp sgt i32 %0, 2
%3 = add nsw i32 %0, 20
- %4 = add nsw i32 %0, -20
+ %4 = add i32 %0, -20
select i1 %2, i32 %3, i32 %4, !prof !1
ret i32 %5
}
Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -355,7 +355,8 @@
Value *Op1 = MatchIsOpZero ? NewSI : MatchOp;
if (auto *BO = dyn_cast<BinaryOperator>(TI)) {
BinaryOperator *NewBO = BinaryOperator::Create(BO->getOpcode(), Op0, Op1);
- NewBO->copyIRFlags(BO);
+ NewBO->copyIRFlags(TI);
+ NewBO->andIRFlags(FI);
return NewBO;
}
if (auto *TGEP = dyn_cast<GetElementPtrInst>(TI)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50996.161587.patch
Type: text/x-patch
Size: 1372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180820/2d149923/attachment.bin>
More information about the llvm-commits
mailing list