nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: bytecodealliance/wasmtime
Pull request #5772 (2023-02-13 21:46:22)

Cranelift: Collapse double extends into a single extend
<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

- [ ] This has been discussed in issue #..., or if not, please tell us why
  here.
- [ ] A short description of what this does, why it is needed; if the
  description becomes long, the matter should probably be discussed in an issue
  first.
- [ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
  If you don't know who could review this, please indicate so. The list of
  suggested reviewers on the right can help you.

Please ensure all communication adheres to the [code of
conduct](https://github.com/bytecodealliance/wasmtime/blob/master/CODE_OF_CONDUCT.md).
-->



Patch:
diff --git a/cranelift/codegen/src/opts/algebraic.isle b/cranelift/codegen/src/opts/algebraic.isle
index e227a4089..8193f7945 100644
--- a/cranelift/codegen/src/opts/algebraic.isle
+++ b/cranelift/codegen/src/opts/algebraic.isle
@@ -6,6 +6,12 @@
 ;; than a piece of the input or a new node that we construct; but we
 ;; can freely rewrite e.g. `x+y-y` to `x`.
 
+;; Chained `uextend` and `sextend`.
+(rule (simplify (uextend ty (uextend _intermediate_ty x)))
+      (uextend ty x))
+(rule (simplify (sextend ty (sextend _intermediate_ty x)))
+      (sextend ty x))
+
 ;; x+0 == 0+x == x.
 (rule (simplify (iadd ty
                       x


Test patch:
diff --git a/cranelift/filetests/filetests/egraph/algebraic.clif b/cranelift/filetests/filetests/egraph/algebraic.clif
index af8062d6a..3e8577cdb 100644
--- a/cranelift/filetests/filetests/egraph/algebraic.clif
+++ b/cranelift/filetests/filetests/egraph/algebraic.clif
@@ -337,3 +337,23 @@ block0(v1: i32):
 
 ; check: v5 = iconst.i8 1
 ; check: return v5
+
+function %double_uextend(i16) -> i64 {
+block0(v1: i16):
+    v2 = uextend.i32 v1
+    v3 = uextend.i64 v2
+    return v3
+}
+
+; check: v4 = uextend.i64 v1
+; check: return v4
+
+function %double_sextend(i16) -> i64 {
+block0(v1: i16):
+    v2 = sextend.i32 v1
+    v3 = sextend.i64 v2
+    return v3
+}
+
+; check: v4 = sextend.i64 v1
+; check: return v4
Repository: bytecodealliance/wasmtime
Pull request #5789 (2023-02-15 17:13:12)

x64: Fix the formatting for `andn`
The formatting for the x64 `AluRmRVex` instructions followed intel syntax, while we emit at&t syntax for everything else. This PR fixes the argument order in the pretty-printer, and updates the test outputs.

This was identified in https://github.com/bytecodealliance/wasmtime/pull/5780#discussion_r1106570415
<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

- [ ] This has been discussed in issue #..., or if not, please tell us why
  here.
- [ ] A short description of what this does, why it is needed; if the
  description becomes long, the matter should probably be discussed in an issue
  first.
- [ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
  If you don't know who could review this, please indicate so. The list of
  suggested reviewers on the right can help you.

Please ensure all communication adheres to the [code of
conduct](https://github.com/bytecodealliance/wasmtime/blob/master/CODE_OF_CONDUCT.md).
-->



Patch:
diff --git a/cranelift/codegen/src/isa/x64/inst/mod.rs b/cranelift/codegen/src/isa/x64/inst/mod.rs
index 518b544cf..6716ec21b 100644
--- a/cranelift/codegen/src/isa/x64/inst/mod.rs
+++ b/cranelift/codegen/src/isa/x64/inst/mod.rs
@@ -762,9 +762,9 @@ impl PrettyPrint for Inst {
                 format!(
                     "{} {}, {}, {}",
                     ljustify2(op.to_string(), String::new()),
-                    dst,
-                    src1,
                     src2,
+                    src1,
+                    dst,
                 )
             }
             Inst::UnaryRmR { src, dst, op, size } => {


Test patch:
diff --git a/cranelift/filetests/filetests/isa/x64/band_not_bmi1.clif b/cranelift/filetests/filetests/isa/x64/band_not_bmi1.clif
index 29101eaff..96dc33ef3 100644
--- a/cranelift/filetests/filetests/isa/x64/band_not_bmi1.clif
+++ b/cranelift/filetests/filetests/isa/x64/band_not_bmi1.clif
@@ -11,12 +11,11 @@ block0(v0: i8, v1: i8):
 ;   pushq   %rbp
 ;   movq    %rsp, %rbp
 ; block0:
-;   andn    %eax, %esi, %edi
+;   andn    %edi, %esi, %eax
 ;   movq    %rbp, %rsp
 ;   popq    %rbp
 ;   ret
 
-
 function %reversed_operands(i8, i8) -> i8 {
 block0(v0: i8, v1: i8):
     v2 = bnot v0
@@ -27,7 +26,7 @@ block0(v0: i8, v1: i8):
 ;   pushq   %rbp
 ;   movq    %rsp, %rbp
 ; block0:
-;   andn    %eax, %edi, %esi
+;   andn    %esi, %edi, %eax
 ;   movq    %rbp, %rsp
 ;   popq    %rbp
 ;   ret
diff --git a/cranelift/filetests/filetests/wasm/i32-not-x64.wat b/cranelift/filetests/filetests/wasm/i32-not-x64.wat
index 45d3798e7..e4eb54957 100644
--- a/cranelift/filetests/filetests/wasm/i32-not-x64.wat
+++ b/cranelift/filetests/filetests/wasm/i32-not-x64.wat
@@ -40,7 +40,7 @@
 ;; block0:
 ;;   jmp     label1
 ;; block1:
-;;   andn    %eax, %esi, %edi
+;;   andn    %edi, %esi, %eax
 ;;   movq    %rbp, %rsp
 ;;   popq    %rbp
 ;;   ret