@@ -2469,70 +2469,58 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
24692469 assert_ty_eq ! ( self , lhs. ty, rhs. ty) ;
24702470 let b = SpirvType :: Bool . def ( self . span ( ) , self ) ;
24712471
2472- if let Some ( const_lhs) = self . try_get_const_value ( lhs) {
2473- if let Some ( const_rhs) = self . try_get_const_value ( rhs) {
2474- let const_result = match self . lookup_type ( lhs. ty ) {
2475- SpirvType :: Integer ( _, _) => match ( const_lhs, const_rhs, op) {
2476- ( ConstValue :: Unsigned ( lhs) , ConstValue :: Unsigned ( rhs) , IntEQ ) => {
2477- Some ( lhs. eq ( & rhs) )
2478- }
2479- ( ConstValue :: Signed ( lhs) , ConstValue :: Signed ( rhs) , IntEQ ) => {
2480- Some ( lhs. eq ( & rhs) )
2481- }
2482- ( ConstValue :: Unsigned ( lhs) , ConstValue :: Unsigned ( rhs) , IntNE ) => {
2483- Some ( lhs. ne ( & rhs) )
2484- }
2485- ( ConstValue :: Signed ( lhs) , ConstValue :: Signed ( rhs) , IntNE ) => {
2486- Some ( lhs. ne ( & rhs) )
2487- }
2488- ( ConstValue :: Unsigned ( lhs) , ConstValue :: Unsigned ( rhs) , IntUGT ) => {
2489- Some ( lhs. gt ( & rhs) )
2490- }
2491- ( ConstValue :: Unsigned ( lhs) , ConstValue :: Unsigned ( rhs) , IntUGE ) => {
2492- Some ( lhs. ge ( & rhs) )
2493- }
2494- ( ConstValue :: Unsigned ( lhs) , ConstValue :: Unsigned ( rhs) , IntULT ) => {
2495- Some ( lhs. lt ( & rhs) )
2496- }
2497- ( ConstValue :: Unsigned ( lhs) , ConstValue :: Unsigned ( rhs) , IntULE ) => {
2498- Some ( lhs. le ( & rhs) )
2499- }
2500- ( ConstValue :: Signed ( lhs) , ConstValue :: Signed ( rhs) , IntUGT ) => {
2501- Some ( lhs. gt ( & rhs) )
2502- }
2503- ( ConstValue :: Signed ( lhs) , ConstValue :: Signed ( rhs) , IntUGE ) => {
2504- Some ( lhs. ge ( & rhs) )
2505- }
2506- ( ConstValue :: Signed ( lhs) , ConstValue :: Signed ( rhs) , IntULT ) => {
2507- Some ( lhs. lt ( & rhs) )
2508- }
2509- ( ConstValue :: Signed ( lhs) , ConstValue :: Signed ( rhs) , IntULE ) => {
2510- Some ( lhs. le ( & rhs) )
2511- }
2512- ( _, _, _) => None ,
2513- } ,
2514- SpirvType :: Bool => match ( const_lhs, const_rhs, op) {
2515- ( ConstValue :: Bool ( lhs) , ConstValue :: Bool ( rhs) , IntEQ ) => Some ( lhs. eq ( & rhs) ) ,
2516- ( ConstValue :: Bool ( lhs) , ConstValue :: Bool ( rhs) , IntNE ) => Some ( lhs. ne ( & rhs) ) ,
2517- ( ConstValue :: Bool ( lhs) , ConstValue :: Bool ( rhs) , IntUGT ) => {
2518- Some ( lhs. gt ( & rhs) )
2519- }
2520- ( ConstValue :: Bool ( lhs) , ConstValue :: Bool ( rhs) , IntUGE ) => {
2521- Some ( lhs. ge ( & rhs) )
2522- }
2523- ( ConstValue :: Bool ( lhs) , ConstValue :: Bool ( rhs) , IntULT ) => {
2524- Some ( lhs. lt ( & rhs) )
2525- }
2526- ( ConstValue :: Bool ( lhs) , ConstValue :: Bool ( rhs) , IntULE ) => {
2527- Some ( lhs. le ( & rhs) )
2528- }
2529- ( _, _, _) => None ,
2530- } ,
2531- _ => None ,
2532- } ;
2533- if let Some ( result) = const_result {
2534- return self . const_bool ( result) ;
2535- }
2472+ if let Some ( const_lhs) = self . try_get_const_value ( lhs)
2473+ && let Some ( const_rhs) = self . try_get_const_value ( rhs)
2474+ {
2475+ let const_result = match self . lookup_type ( lhs. ty ) {
2476+ SpirvType :: Integer ( _, _) => match ( const_lhs, const_rhs, op) {
2477+ ( ConstValue :: Unsigned ( lhs) , ConstValue :: Unsigned ( rhs) , IntEQ ) => {
2478+ Some ( lhs. eq ( & rhs) )
2479+ }
2480+ ( ConstValue :: Signed ( lhs) , ConstValue :: Signed ( rhs) , IntEQ ) => Some ( lhs. eq ( & rhs) ) ,
2481+ ( ConstValue :: Unsigned ( lhs) , ConstValue :: Unsigned ( rhs) , IntNE ) => {
2482+ Some ( lhs. ne ( & rhs) )
2483+ }
2484+ ( ConstValue :: Signed ( lhs) , ConstValue :: Signed ( rhs) , IntNE ) => Some ( lhs. ne ( & rhs) ) ,
2485+ ( ConstValue :: Unsigned ( lhs) , ConstValue :: Unsigned ( rhs) , IntUGT ) => {
2486+ Some ( lhs. gt ( & rhs) )
2487+ }
2488+ ( ConstValue :: Unsigned ( lhs) , ConstValue :: Unsigned ( rhs) , IntUGE ) => {
2489+ Some ( lhs. ge ( & rhs) )
2490+ }
2491+ ( ConstValue :: Unsigned ( lhs) , ConstValue :: Unsigned ( rhs) , IntULT ) => {
2492+ Some ( lhs. lt ( & rhs) )
2493+ }
2494+ ( ConstValue :: Unsigned ( lhs) , ConstValue :: Unsigned ( rhs) , IntULE ) => {
2495+ Some ( lhs. le ( & rhs) )
2496+ }
2497+ ( ConstValue :: Signed ( lhs) , ConstValue :: Signed ( rhs) , IntUGT ) => {
2498+ Some ( lhs. gt ( & rhs) )
2499+ }
2500+ ( ConstValue :: Signed ( lhs) , ConstValue :: Signed ( rhs) , IntUGE ) => {
2501+ Some ( lhs. ge ( & rhs) )
2502+ }
2503+ ( ConstValue :: Signed ( lhs) , ConstValue :: Signed ( rhs) , IntULT ) => {
2504+ Some ( lhs. lt ( & rhs) )
2505+ }
2506+ ( ConstValue :: Signed ( lhs) , ConstValue :: Signed ( rhs) , IntULE ) => {
2507+ Some ( lhs. le ( & rhs) )
2508+ }
2509+ ( _, _, _) => None ,
2510+ } ,
2511+ SpirvType :: Bool => match ( const_lhs, const_rhs, op) {
2512+ ( ConstValue :: Bool ( lhs) , ConstValue :: Bool ( rhs) , IntEQ ) => Some ( lhs. eq ( & rhs) ) ,
2513+ ( ConstValue :: Bool ( lhs) , ConstValue :: Bool ( rhs) , IntNE ) => Some ( lhs. ne ( & rhs) ) ,
2514+ ( ConstValue :: Bool ( lhs) , ConstValue :: Bool ( rhs) , IntUGT ) => Some ( lhs. gt ( & rhs) ) ,
2515+ ( ConstValue :: Bool ( lhs) , ConstValue :: Bool ( rhs) , IntUGE ) => Some ( lhs. ge ( & rhs) ) ,
2516+ ( ConstValue :: Bool ( lhs) , ConstValue :: Bool ( rhs) , IntULT ) => Some ( lhs. lt ( & rhs) ) ,
2517+ ( ConstValue :: Bool ( lhs) , ConstValue :: Bool ( rhs) , IntULE ) => Some ( lhs. le ( & rhs) ) ,
2518+ ( _, _, _) => None ,
2519+ } ,
2520+ _ => None ,
2521+ } ;
2522+ if let Some ( result) = const_result {
2523+ return self . const_bool ( result) ;
25362524 }
25372525 }
25382526
0 commit comments