File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
lib/CIR/Lowering/DirectToLLVM Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -612,10 +612,16 @@ class CIRBrCondOpLowering
612612 mlir::ConversionPatternRewriter &rewriter) const override {
613613 mlir::Value i1Condition;
614614
615+ auto hasOneUse = false ;
616+ if (auto defOp = brOp.getCond ().getDefiningOp ())
617+ if (defOp->getResult (0 ).hasOneUse ())
618+ hasOneUse = true ;
619+
615620 if (auto defOp = adaptor.getCond ().getDefiningOp ()) {
616621 if (auto zext = dyn_cast<mlir::LLVM::ZExtOp>(defOp)) {
617622 if (zext->use_empty () &&
618- zext->getOperand (0 ).getType () == rewriter.getI1Type ()) {
623+ zext->getOperand (0 ).getType () == rewriter.getI1Type () &&
624+ hasOneUse) {
619625 i1Condition = zext->getOperand (0 );
620626 rewriter.eraseOp (zext);
621627 }
Original file line number Diff line number Diff line change 1+ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -fclangir-mem2reg -emit-llvm %s -o %t.ll
2+
3+ #include <stdbool.h>
4+
5+ bool test () {
6+ bool x = false;
7+ if (x ) {
8+ bool u = x ;
9+ return u ;
10+ }
11+ return x ;
12+ }
You can’t perform that action at this time.
0 commit comments