File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -2575,7 +2575,7 @@ ValueCategory MLIRScanner::VisitAtomicExpr(clang::AtomicExpr *BO) {
2575
2575
ValueCategory MLIRScanner::VisitBinaryOperator (clang::BinaryOperator *BO) {
2576
2576
auto loc = getMLIRLocation (BO->getExprLoc ());
2577
2577
2578
- auto fixInteger = [&](mlir::Value res) {
2578
+ auto fixInteger = [&](mlir::Value res, bool forceUnsigned = false ) {
2579
2579
auto prevTy = res.getType ().cast <mlir::IntegerType>();
2580
2580
auto postTy = getMLIRType (BO->getType ()).cast <mlir::IntegerType>();
2581
2581
bool signedType = true ;
@@ -2585,6 +2585,8 @@ ValueCategory MLIRScanner::VisitBinaryOperator(clang::BinaryOperator *BO) {
2585
2585
if (bit->isSignedInteger ())
2586
2586
signedType = true ;
2587
2587
}
2588
+ if (forceUnsigned)
2589
+ signedType = false ;
2588
2590
if (postTy != prevTy) {
2589
2591
if (signedType) {
2590
2592
res = builder.create <mlir::arith::ExtSIOp>(loc, postTy, res);
@@ -2838,7 +2840,7 @@ ValueCategory MLIRScanner::VisitBinaryOperator(clang::BinaryOperator *BO) {
2838
2840
} else {
2839
2841
res = builder.create <arith::CmpIOp>(loc, IPred, lhs_v, rhs_v);
2840
2842
}
2841
- return fixInteger (res);
2843
+ return fixInteger (res, /* forceUnsigned */ true );
2842
2844
}
2843
2845
case clang::BinaryOperator::Opcode::BO_Mul: {
2844
2846
if (isa<clang::ComplexType>(BO->getType ())) {
Original file line number Diff line number Diff line change @@ -19,11 +19,11 @@ unsigned int cmp2() {
19
19
// CHECK-NEXT: scf.if %[[V0]] {
20
20
// CHECK-NEXT: call @run() : () -> ()
21
21
// CHECK-NEXT: }
22
- // CHECK-NEXT: %[[V1:.+]] = arith.extsi %[[V0]] : i1 to i32
22
+ // CHECK-NEXT: %[[V1:.+]] = arith.extui %[[V0]] : i1 to i32
23
23
// CHECK-NEXT: return %[[V1]] : i32
24
24
// CHECK-NEXT: }
25
25
// CHECK: func @cmp2() -> i32
26
- // CHECK-NEXT: %c-1_i32 = arith.constant - 1 : i32
26
+ // CHECK-NEXT: %c1_i32 = arith.constant 1 : i32
27
27
// CHECK-NEXT: call @run() : () -> ()
28
- // CHECK-NEXT: return %c-1_i32 : i32
28
+ // CHECK-NEXT: return %c1_i32 : i32
29
29
// CHECK-NEXT: }
You can’t perform that action at this time.
0 commit comments