Source file test/codegen/fuse.go

     1  // asmcheck
     2  
     3  // Copyright 2019 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package codegen
     8  
     9  // Notes:
    10  // - these examples use channels to provide a source of
    11  //   unknown values that cannot be optimized away
    12  // - these examples use for loops to force branches
    13  //   backward (predicted taken)
    14  
    15  // ---------------------------------- //
    16  // signed integer range (conjunction) //
    17  // ---------------------------------- //
    18  
    19  func si1c(c <-chan int64) {
    20  	// amd64:"CMPQ\t.+, [$]256"
    21  	// s390x:"CLGIJ\t[$]12, R[0-9]+, [$]255"
    22  	for x := <-c; x >= 0 && x < 256; x = <-c {
    23  	}
    24  }
    25  
    26  func si2c(c <-chan int32) {
    27  	// amd64:"CMPL\t.+, [$]256"
    28  	// s390x:"CLIJ\t[$]12, R[0-9]+, [$]255"
    29  	for x := <-c; x >= 0 && x < 256; x = <-c {
    30  	}
    31  }
    32  
    33  func si3c(c <-chan int16) {
    34  	// amd64:"CMPW\t.+, [$]256"
    35  	// s390x:"CLIJ\t[$]12, R[0-9]+, [$]255"
    36  	for x := <-c; x >= 0 && x < 256; x = <-c {
    37  	}
    38  }
    39  
    40  func si4c(c <-chan int8) {
    41  	// amd64:"CMPB\t.+, [$]10"
    42  	// s390x:"CLIJ\t[$]4, R[0-9]+, [$]10"
    43  	for x := <-c; x >= 0 && x < 10; x = <-c {
    44  	}
    45  }
    46  
    47  func si5c(c <-chan int64) {
    48  	// amd64:"CMPQ\t.+, [$]251","ADDQ\t[$]-5,"
    49  	// s390x:"CLGIJ\t[$]4, R[0-9]+, [$]251","ADD\t[$]-5,"
    50  	for x := <-c; x < 256 && x > 4; x = <-c {
    51  	}
    52  }
    53  
    54  func si6c(c <-chan int32) {
    55  	// amd64:"CMPL\t.+, [$]255","DECL\t"
    56  	// s390x:"CLIJ\t[$]12, R[0-9]+, [$]255","ADDW\t[$]-1,"
    57  	for x := <-c; x > 0 && x <= 256; x = <-c {
    58  	}
    59  }
    60  
    61  func si7c(c <-chan int16) {
    62  	// amd64:"CMPW\t.+, [$]60","ADDL\t[$]10,"
    63  	// s390x:"CLIJ\t[$]12, R[0-9]+, [$]60","ADDW\t[$]10,"
    64  	for x := <-c; x >= -10 && x <= 50; x = <-c {
    65  	}
    66  }
    67  
    68  func si8c(c <-chan int8) {
    69  	// amd64:"CMPB\t.+, [$]126","ADDL\t[$]126,"
    70  	// s390x:"CLIJ\t[$]4, R[0-9]+, [$]126","ADDW\t[$]126,"
    71  	for x := <-c; x >= -126 && x < 0; x = <-c {
    72  	}
    73  }
    74  
    75  // ---------------------------------- //
    76  // signed integer range (disjunction) //
    77  // ---------------------------------- //
    78  
    79  func si1d(c <-chan int64) {
    80  	// amd64:"CMPQ\t.+, [$]256"
    81  	// s390x:"CLGIJ\t[$]2, R[0-9]+, [$]255"
    82  	for x := <-c; x < 0 || x >= 256; x = <-c {
    83  	}
    84  }
    85  
    86  func si2d(c <-chan int32) {
    87  	// amd64:"CMPL\t.+, [$]256"
    88  	// s390x:"CLIJ\t[$]2, R[0-9]+, [$]255"
    89  	for x := <-c; x < 0 || x >= 256; x = <-c {
    90  	}
    91  }
    92  
    93  func si3d(c <-chan int16) {
    94  	// amd64:"CMPW\t.+, [$]256"
    95  	// s390x:"CLIJ\t[$]2, R[0-9]+, [$]255"
    96  	for x := <-c; x < 0 || x >= 256; x = <-c {
    97  	}
    98  }
    99  
   100  func si4d(c <-chan int8) {
   101  	// amd64:"CMPB\t.+, [$]10"
   102  	// s390x:"CLIJ\t[$]10, R[0-9]+, [$]10"
   103  	for x := <-c; x < 0 || x >= 10; x = <-c {
   104  	}
   105  }
   106  
   107  func si5d(c <-chan int64) {
   108  	// amd64:"CMPQ\t.+, [$]251","ADDQ\t[$]-5,"
   109  	// s390x:"CLGIJ\t[$]10, R[0-9]+, [$]251","ADD\t[$]-5,"
   110  	for x := <-c; x >= 256 || x <= 4; x = <-c {
   111  	}
   112  }
   113  
   114  func si6d(c <-chan int32) {
   115  	// amd64:"CMPL\t.+, [$]255","DECL\t"
   116  	// s390x:"CLIJ\t[$]2, R[0-9]+, [$]255","ADDW\t[$]-1,"
   117  	for x := <-c; x <= 0 || x > 256; x = <-c {
   118  	}
   119  }
   120  
   121  func si7d(c <-chan int16) {
   122  	// amd64:"CMPW\t.+, [$]60","ADDL\t[$]10,"
   123  	// s390x:"CLIJ\t[$]2, R[0-9]+, [$]60","ADDW\t[$]10,"
   124  	for x := <-c; x < -10 || x > 50; x = <-c {
   125  	}
   126  }
   127  
   128  func si8d(c <-chan int8) {
   129  	// amd64:"CMPB\t.+, [$]126","ADDL\t[$]126,"
   130  	// s390x:"CLIJ\t[$]10, R[0-9]+, [$]126","ADDW\t[$]126,"
   131  	for x := <-c; x < -126 || x >= 0; x = <-c {
   132  	}
   133  }
   134  
   135  // ------------------------------------ //
   136  // unsigned integer range (conjunction) //
   137  // ------------------------------------ //
   138  
   139  func ui1c(c <-chan uint64) {
   140  	// amd64:"CMPQ\t.+, [$]251","ADDQ\t[$]-5,"
   141  	// s390x:"CLGIJ\t[$]4, R[0-9]+, [$]251","ADD\t[$]-5,"
   142  	for x := <-c; x < 256 && x > 4; x = <-c {
   143  	}
   144  }
   145  
   146  func ui2c(c <-chan uint32) {
   147  	// amd64:"CMPL\t.+, [$]255","DECL\t"
   148  	// s390x:"CLIJ\t[$]12, R[0-9]+, [$]255","ADDW\t[$]-1,"
   149  	for x := <-c; x > 0 && x <= 256; x = <-c {
   150  	}
   151  }
   152  
   153  func ui3c(c <-chan uint16) {
   154  	// amd64:"CMPW\t.+, [$]40","ADDL\t[$]-10,"
   155  	// s390x:"CLIJ\t[$]12, R[0-9]+, [$]40","ADDW\t[$]-10,"
   156  	for x := <-c; x >= 10 && x <= 50; x = <-c {
   157  	}
   158  }
   159  
   160  func ui4c(c <-chan uint8) {
   161  	// amd64:"CMPB\t.+, [$]2","ADDL\t[$]-126,"
   162  	// s390x:"CLIJ\t[$]4, R[0-9]+, [$]2","ADDW\t[$]-126,"
   163  	for x := <-c; x >= 126 && x < 128; x = <-c {
   164  	}
   165  }
   166  
   167  // ------------------------------------ //
   168  // unsigned integer range (disjunction) //
   169  // ------------------------------------ //
   170  
   171  func ui1d(c <-chan uint64) {
   172  	// amd64:"CMPQ\t.+, [$]251","ADDQ\t[$]-5,"
   173  	// s390x:"CLGIJ\t[$]10, R[0-9]+, [$]251","ADD\t[$]-5,"
   174  	for x := <-c; x >= 256 || x <= 4; x = <-c {
   175  	}
   176  }
   177  
   178  func ui2d(c <-chan uint32) {
   179  	// amd64:"CMPL\t.+, [$]254","ADDL\t[$]-2,"
   180  	// s390x:"CLIJ\t[$]2, R[0-9]+, [$]254","ADDW\t[$]-2,"
   181  	for x := <-c; x <= 1 || x > 256; x = <-c {
   182  	}
   183  }
   184  
   185  func ui3d(c <-chan uint16) {
   186  	// amd64:"CMPW\t.+, [$]40","ADDL\t[$]-10,"
   187  	// s390x:"CLIJ\t[$]2, R[0-9]+, [$]40","ADDW\t[$]-10,"
   188  	for x := <-c; x < 10 || x > 50; x = <-c {
   189  	}
   190  }
   191  
   192  func ui4d(c <-chan uint8) {
   193  	// amd64:"CMPB\t.+, [$]2","ADDL\t[$]-126,"
   194  	// s390x:"CLIJ\t[$]10, R[0-9]+, [$]2","ADDW\t[$]-126,"
   195  	for x := <-c; x < 126 || x >= 128; x = <-c {
   196  	}
   197  }
   198  

View as plain text